blob: 10cd3ac24d0bb814299487fd5efaa3794da9ee98 (
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
52
|
(.require
[library
[lux (.except)
[abstract
[comonad (.only CoMonad)]
["[0]" functor (.only Functor)
["[1]T" \\test (.only Injection Comparison)]]
["[0]" comonad
["[1]T" \\test]]]
[control
["//" continuation]]
[data
[collection
["[0]" list]
["[0]" stream (.only Stream) (.use "[1]#[0]" comonad)]]]
[math
["[0]" random]]
[test
["_" property (.only Test)]]]]
[\\library
["[0]" /]])
(def (injection value)
(Injection (/.Free Stream))
[value (stream#each injection (stream.repeated value))])
(def (interpret [head tail])
(All (_ a) (-> (/.Free Stream a) (Stream a)))
(|> tail
(stream#each (of (/.comonad stream.functor) out))
[head]
//.pending))
(def comparison
(Comparison (/.Free Stream))
(function (_ == left right)
(of (list.equivalence ==) =
(stream.first 100 (..interpret left))
(stream.first 100 (..interpret right)))))
(def .public test
Test
(<| (_.covering /._)
(_.for [/.Free])
(all _.and
(_.for [/.functor]
(functorT.spec ..injection ..comparison (is (Functor (/.Free Stream))
(/.functor stream.functor))))
(_.for [/.comonad]
(comonadT.spec ..injection ..comparison (is (CoMonad (/.Free Stream))
(/.comonad stream.functor))))
)))
|