blob: d0628f160f74e6dddca60e27c639859514763842 (
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
(.using
[library
[lux "*"
[data
["[0]" text ("[1]#[0]" equivalence)]
[collection
["[0]" dictionary {"+" Dictionary}]
["[0]" list ("[1]#[0]" monad)]
["[0]" set {"+" Set}]]]
[macro
["[0]" code]
["[0]" template]]
[tool
[compiler
[meta
[cli
[compiler {"+" Compiler}]]]]]]]
["[0]" // "_"
["/" profile]
["[1][0]" runtime {"+" Runtime}]
["[1][0]" project {"+" Project}]
["[1][0]" dependency {"+" Dependency}]
["[1][0]" artifact {"+" Artifact}
["[1]/[0]" type]]])
(type: .public (Format a)
(-> a Code))
(def: (license [name url type])
(Format /.License)
(`' [#name (~ (code.text name))
#url (~ (code.text url))
#type (~ (case type
{/.#Repo}
(' "repo")
{/.#Manual}
(' "manual")))]))
(def: (organization [name url])
(Format /.Organization)
(`' [#name (~ (code.text name))
#url (~ (code.text url))]))
(def: (developer [name url organization])
(Format /.Developer)
(case organization
{.#None}
(`' [#name (~ (code.text name))
#url (~ (code.text url))])
{.#Some value}
(`' [#name (~ (code.text name))
#url (~ (code.text url))
#organization (~ (..organization value))])))
(def: contributor
(Format /.Contributor)
..developer)
(type: Aggregate
(Dictionary Text Code))
(def: aggregate
(Format Aggregate)
(|>> dictionary.entries
(list#each (function (_ [key value])
(list (code.text key) value)))
list#conjoint
code.tuple))
(def: empty
Aggregate
(dictionary.empty text.hash))
(def: (on_maybe field value format aggregate)
(All (_ a)
(-> Text (Maybe a) (Format a) Aggregate Aggregate))
(case value
{.#None}
aggregate
{.#Some value}
(dictionary.has field (format value) aggregate)))
(def: (on_list field value format aggregate)
(All (_ a)
(-> Text (List a) (Format a) Aggregate Aggregate))
(case value
{.#End}
aggregate
value
(dictionary.has field (` [(~+ (list#each format value))]) aggregate)))
(def: (on_set field value format aggregate)
(All (_ a)
(-> Text (Set a) (Format a) Aggregate Aggregate))
(..on_list field (set.list value) format aggregate))
(def: (on_dictionary field value key_format value_format aggregate)
(All (_ k v)
(-> Text (Dictionary k v) (Format k) (Format v) Aggregate Aggregate))
(if (dictionary.empty? value)
aggregate
(dictionary.has field
(|> value
dictionary.entries
(list#each (function (_ [key value])
(list (key_format key) (value_format value))))
list#conjoint
code.tuple)
aggregate)))
(def: (info value)
(Format /.Info)
(|> ..empty
(..on_maybe "url" (value@ /.#url value) code.text)
(..on_maybe "scm" (value@ /.#scm value) code.text)
(..on_maybe "description" (value@ /.#description value) code.text)
(..on_list "licenses" (value@ /.#licenses value) ..license)
(..on_maybe "organization" (value@ /.#organization value) ..organization)
(..on_list "developers" (value@ /.#developers value) ..developer)
(..on_list "contributors" (value@ /.#contributors value) ..contributor)
..aggregate))
(def: (artifact' [group name version])
(-> Artifact (List Code))
(list (code.text group)
(code.text name)
(code.text version)))
(def: (artifact value)
(Format Artifact)
(` [(~+ (..artifact' value))]))
(def: (dependency [artifact type])
(Format Dependency)
(if (text#= //artifact/type.lux_library type)
(` [(~+ (..artifact' artifact))])
(` [(~+ (..artifact' artifact))
(~ (code.text type))])))
(def: (runtime [program parameters])
(Format Runtime)
(` [(~ (code.text program))
(~+ (list#each code.text parameters))]))
(def: (compiler [definition parameters])
(Format Compiler)
(` [(~ (code.symbol definition))
(~+ (list#each code.text parameters))]))
(def: .public lux_compiler_label
"lux")
(def: (profile value)
(Format /.Profile)
(`` (|> ..empty
(..on_list "parents" (value@ /.#parents value) code.text)
(..on_maybe "identity" (value@ /.#identity value) ..artifact)
(..on_maybe "info" (value@ /.#info value) ..info)
(..on_set "repositories" (value@ /.#repositories value) code.text)
(..on_set "dependencies" (value@ /.#dependencies value) ..dependency)
(dictionary.has ..lux_compiler_label (..dependency (value@ /.#lux value)))
(..on_list "compilers" (value@ /.#compilers value) ..compiler)
(..on_set "sources" (value@ /.#sources value) code.text)
(dictionary.has "target" (code.text (value@ /.#target value)))
(..on_maybe "program" (value@ /.#program value) code.text)
(..on_maybe "test" (value@ /.#test value) code.text)
(..on_dictionary "deploy_repositories" (value@ /.#deploy_repositories value) code.text code.text)
(~~ (template [<tag>]
[(dictionary.has (template.text [<tag>]) (..runtime (value@ <tag> value)))]
[/.#java]
[/.#js]
[/.#python]
[/.#lua]
[/.#ruby]))
..aggregate)))
(def: .public project
(Format Project)
(|>> dictionary.entries
(list#each (function (_ [key value])
(list (code.text key) (..profile value))))
list#conjoint
code.tuple))
|