blob: a14a240cbb4c54df415d079ef451f71ffaf8904e (
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
|
(.module:
[lux #*
[control
[monad (#+ do)]
{[0 #test]
[/
[".T" functor (#+ Injection Comparison)]
[".T" apply]
[".T" monad]]}]
["." function]
[math
["r" random]]
["_" test (#+ Test)]]
{1
["." / (#+ IO)]})
(def: injection
(Injection IO)
(|>> /.io))
(def: comparison
(Comparison IO)
(function (_ == left right)
(== (/.run left) (/.run right))))
(def: #export test
Test
(do r.monad
[sample r.nat
exit-code r.int]
($_ _.and
(_.test "Can execute computations designated as I/O computations."
(n/= sample (/.run (/.io sample))))
(_.test "I/O operations won't execute unless they are explicitly run."
(exec (/.exit exit-code)
true))
(functorT.laws /.functor ..injection ..comparison)
(applyT.laws /.apply ..injection ..comparison)
(monadT.laws /.monad ..injection ..comparison))))
|