blob: 85952b623005af13109efd8acc5a4da9b595fe49 (
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 (.except)
[abstract
[equivalence (.only Equivalence)]
[monad (.only do)]]
[control
["[0]" try (.only Try)]]
[data
[binary
[\\format (.only Writer)]]
[text
["%" \\format (.only Format)]]]
[math
[number
["n" nat]]]
[type
[primitive (.except)]]]]
["[0]" //
[jump (.only Big_Jump)]
["/[1]" //
[encoding
["[1][0]" unsigned (.only U2)]
["[1][0]" signed (.only S4)]]]])
(primitive: .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)
(at 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)))
(def: .public equivalence
(Equivalence Address)
(implementation
(def: (= reference subject)
(at ///unsigned.equivalence =
(representation reference)
(representation subject)))))
(def: .public writer
(Writer Address)
(|>> representation ///unsigned.writer/2))
(def: .public format
(Format Address)
(|>> representation ///unsigned.value %.nat))
)
|