blob: 94f53c258f0ee4c66f828e13208f5864d1fb7436 (
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
63
64
65
66
67
68
69
70
71
72
73
74
|
(.using
[library
[lux "*"
[abstract
[equivalence {"+" Equivalence}]
[monad {"+" do}]]
[control
["[0]" try {"+" Try}]]
[data
[format
[binary {"+" Writer}]]
[text
["%" format {"+" Format}]]]
[math
[number
["n" nat]]]
[type
[abstract "*"]]]]
["[0]" // "_"
[jump {"+" Big_Jump}]
["/[1]" // "_"
[encoding
["[1][0]" unsigned {"+" U2}]
["[1][0]" signed {"+" S4}]]]])
(abstract: .public Address
U2
(def: .public value
(-> Address U2)
(|>> representation))
(def: .public start
Address
(|> 0 ///unsigned.u2 try.trusted abstraction))
(def: .public (move distance)
(-> U2 (-> Address (Try Address)))
(|>> representation
(///unsigned.+/2 distance)
(# try.functor each (|>> abstraction))))
(def: with_sign
(-> Address (Try S4))
(|>> representation ///unsigned.value .int ///signed.s4))
(def: .public (jump from to)
(-> Address Address (Try Big_Jump))
(do try.monad
[from (with_sign from)
to (with_sign to)]
(///signed.-/4 from to)))
(def: .public (after? reference subject)
(-> Address Address Bit)
(n.> (|> reference representation ///unsigned.value)
(|> subject representation ///unsigned.value)))
(implementation: .public equivalence
(Equivalence Address)
(def: (= reference subject)
(# ///unsigned.equivalence =
(representation reference)
(representation subject))))
(def: .public writer
(Writer Address)
(|>> representation ///unsigned.writer/2))
(def: .public format
(Format Address)
(|>> representation ///unsigned.value %.nat))
)
|