blob: 5f71df5427f7a4e7d33109e4fff57a2e0bcc716b (
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
53
54
55
56
57
|
(.module:
[lux #*
["_" test (#+ Test)]
[abstract
[functor (#+ Functor)]
[apply (#+ Apply)]
[monad (#+ Monad do)]
{[0 #spec]
[/
["$." functor (#+ Injection Comparison)]
["$." apply]
["$." monad]]}]
[data
[collection
["." list ("#\." functor)]]]
[math
["." random]]]
{1
["." /]})
(def: injection
(Injection (/.Free List))
(|>> #/.Pure))
(def: (interpret free)
(All [a] (-> (/.Free List a) (List a)))
(case free
(#/.Pure value)
(list value)
(#/.Effect effect)
(|> effect
(list\map interpret)
list.concat)))
(def: comparison
(Comparison (/.Free List))
(function (_ == left right)
(\ (list.equivalence ==) =
(..interpret left)
(..interpret right))))
(def: #export test
Test
(<| (_.covering /._)
(_.for [/.Free])
($_ _.and
(_.for [/.functor]
($functor.spec ..injection ..comparison (: (Functor (/.Free List))
(/.functor list.functor))))
(_.for [/.apply]
($apply.spec ..injection ..comparison (: (Apply (/.Free List))
(/.apply list.functor))))
(_.for [/.monad]
($monad.spec ..injection ..comparison (: (Monad (/.Free List))
(/.monad list.functor))))
)))
|