blob: 541977fc5591f20c989ddc024d8a4f508a9a928e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
(.module:
[library
[lux #*
["_" test (#+ Test)]
[abstract
[functor (#+ Functor)]
[comonad (#+ CoMonad)]
[\\specification
["$." functor (#+ Injection Comparison)]
["$." comonad]]]
[control
["//" continuation]]
[data
[collection
["." list]
["." sequence (#+ Sequence) ("#\." comonad)]]]
[math
["." random]]]]
[\\library
["." /]])
(def: (injection value)
(Injection (/.CoFree Sequence))
[value (sequence\map injection (sequence.repeated value))])
(def: (interpret [head tail])
(All [a] (-> (/.CoFree Sequence a) (Sequence a)))
(|> tail
(sequence\map (\ (/.comonad sequence.functor) out))
[head]
//.pending))
(def: comparison
(Comparison (/.CoFree Sequence))
(function (_ == left right)
(\ (list.equivalence ==) =
(sequence.take 100 (..interpret left))
(sequence.take 100 (..interpret right)))))
(def: .public test
Test
(<| (_.covering /._)
(_.for [/.CoFree])
($_ _.and
(_.for [/.functor]
($functor.spec ..injection ..comparison (: (Functor (/.CoFree Sequence))
(/.functor sequence.functor))))
(_.for [/.comonad]
($comonad.spec ..injection ..comparison (: (CoMonad (/.CoFree Sequence))
(/.comonad sequence.functor))))
)))
|