blob: a9d4f432efb0ad12c007091e5f6af0fc8b17e56b (
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
75
|
(.using
[library
[lux "*"
[abstract
[equivalence {"+" Equivalence}]
[hash {"+" Hash}]]
[control
["[0]" pipe]]
[data
[text
["%" format {"+" Format}]]]
[macro
["^" pattern]]
[math
[number
["n" nat]
["i" int]]]]])
(type: .public Register
Nat)
(type: .public Variable
(Variant
{#Local Register}
{#Foreign Register}))
(implementation: .public equivalence
(Equivalence Variable)
(def: (= reference sample)
(case [reference sample]
(^.template [<tag>]
[[{<tag> reference'} {<tag> sample'}]
(n.= reference' sample')])
([#Local] [#Foreign])
_
#0)))
(implementation: .public hash
(Hash Variable)
(def: &equivalence
..equivalence)
(def: hash
(|>> (pipe.case
(^.template [<factor> <tag>]
[{<tag> register}
(|> register
(# n.hash hash)
(n.* <factor>))])
([2 #Local]
[3 #Foreign])))))
(template: .public (self)
[{..#Local 0}])
(def: .public self?
(-> Variable Bit)
(|>> (pipe.case
(pattern (..self))
true
_
false)))
(def: .public format
(Format Variable)
(|>> (pipe.case
{#Local local}
(%.format "+" (%.nat local))
{#Foreign foreign}
(%.format "-" (%.nat foreign)))))
|