blob: ff3a4d24e31eadcde8b83a3d2e378ff83a19b2ef (
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
(.module:
lux
(lux (control [monad #+ do]
["ex" exception #+ exception:])
(data ["e" error]
[text]
(coll [dict #+ Dict]))
[macro])
[//]
(// ["la" analysis]
["ls" synthesis]))
(exception: #export Unknown-Analysis)
(exception: #export Unknown-Synthesis)
(exception: #export Unknown-Translation)
(exception: #export Unknown-Statement)
(exception: #export Cannot-Define-Analysis-More-Than-Once)
(exception: #export Cannot-Define-Synthesis-More-Than-Once)
(exception: #export Cannot-Define-Translation-More-Than-Once)
(exception: #export Cannot-Define-Statement-More-Than-Once)
(type: #export Analysis
(-> (-> Code (Meta Code))
(-> Type Code (Meta Top))
(List Code) (Meta Code)))
(type: #export Synthesis
(-> (-> la.Analysis ls.Synthesis) (List Code) Code))
(type: #export Syntheses (Dict Text Synthesis))
(type: #export Translation
(-> (List Code) (Meta Code)))
(type: #export Statement
(-> (List Code) (Meta Unit)))
(type: #export Extensions
{#analysis (Dict Text Analysis)
#synthesis Syntheses
#translation (Dict Text Translation)
#statement (Dict Text Statement)})
(def: #export fresh
Extensions
{#analysis (dict.new text.Hash<Text>)
#synthesis (dict.new text.Hash<Text>)
#translation (dict.new text.Hash<Text>)
#statement (dict.new text.Hash<Text>)})
(def: get
(Meta Extensions)
(function [compiler]
(#e.Success [compiler
(|> compiler (get@ #.extensions) (:! Extensions))])))
(def: (set extensions)
(-> Extensions (Meta Unit))
(function [compiler]
(#e.Success [(set@ #.extensions (:! Void extensions) compiler)
[]])))
(do-template [<name> <type> <category> <exception>]
[(def: #export (<name> name)
(-> Text (Meta <type>))
(do macro.Monad<Meta>
[extensions ..get]
(case (dict.get name (get@ <category> extensions))
(#.Some extension)
(wrap extension)
#.None
(//.throw <exception> name))))]
[find-analysis Analysis #analysis Unknown-Analysis]
[find-synthesis Synthesis #synthesis Unknown-Synthesis]
[find-translation Translation #translation Unknown-Translation]
[find-statement Statement #statement Unknown-Statement]
)
(do-template [<name> <type> <category>]
[(def: #export <name>
(Meta <type>)
(|> ..get
(:: macro.Monad<Meta> map (get@ <category>))))]
[all-syntheses (Dict Text Synthesis) #synthesis]
)
(do-template [<name> <type> <category> <exception>]
[(def: #export (<name> name extension)
(-> Text <type> (Meta Unit))
(do macro.Monad<Meta>
[extensions ..get
_ (//.assert <exception> name
(not (dict.contains? name (get@ <category> extensions))))
_ (..set (update@ <category> (dict.put name extension) extensions))]
(wrap [])))]
[install-analysis Analysis #analysis Cannot-Define-Analysis-More-Than-Once]
[install-synthesis Synthesis #synthesis Cannot-Define-Synthesis-More-Than-Once]
[install-translation Translation #translation Cannot-Define-Translation-More-Than-Once]
[install-statement Statement #statement Cannot-Define-Statement-More-Than-Once]
)
|