blob: 63b0ad2d70610851fd1f642b6772be62214dd004 (
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
58
59
60
61
62
|
(.module:
[library
[lux #*
["_" test (#+ Test)]
[abstract
[monad (#+ do)]]
[data
["." maybe]
[collection
["." list]]]
[math
["." random]
[number
["n" nat]]]]]
[\\library
["." / (#+ Functor)]])
(def: #export test
Test
(do random.monad
[left random.nat
right random.nat
shift random.nat]
(<| (_.covering /._)
($_ _.and
(_.cover [/.Or /.sum]
(and (case (\ (/.sum maybe.functor list.functor) map
(n.+ shift)
(#.Left (#.Some left)))
(#.Left (#.Some actual))
(n.= (n.+ shift left) actual)
_
false)
(case (\ (/.sum maybe.functor list.functor) map
(n.+ shift)
(#.Right (list right)))
(^ (#.Right (list actual)))
(n.= (n.+ shift right) actual)
_
false)))
(_.cover [/.And /.product]
(case (\ (/.product maybe.functor list.functor) map
(n.+ shift)
[(#.Some left) (list right)])
(^ [(#.Some actualL) (list actualR)])
(and (n.= (n.+ shift left) actualL)
(n.= (n.+ shift right) actualR))
_
false))
(_.cover [/.Then /.compose]
(case (\ (/.compose maybe.functor list.functor) map
(n.+ shift)
(#.Some (list left)))
(^ (#.Some (list actual)))
(n.= (n.+ shift left) actual)
_
false))
))))
|