aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/profile.lux
blob: 627073d7976de07022127b6cf2322535673d01d9 (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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
(.require
 [library
  [lux (.except Info Source Module)
   [abstract
    [monoid (.only Monoid)]
    [equivalence (.only Equivalence)]]
   [control
    ["[0]" maybe (.use "[1]#[0]" monoid)]
    ["[0]" exception (.only exception)]]
   [data
    ["[0]" product]
    ["[0]" text (.use "[1]#[0]" equivalence)]
    [collection
     ["[0]" set (.only Set)]
     ["[0]" dictionary (.only Dictionary)]
     ["[0]" list (.use "[1]#[0]" monoid)
      ["[0]" property (.use "[1]#[0]" monoid)]]]]
   [meta
    ["[0]" symbol]
    [macro
     ["^" pattern]
     ["[0]" template]]
    [compiler
     [meta
      ["[0]" cli
       ["[0]" compiler (.only Compiler)]]
      [archive
       [module
        [descriptor (.only Module)]]]]]]
   [world
    [net (.only URL)]
    [file (.only Path)]]]]
 [//
  ["[0]" runtime (.only Runtime) (.use "[1]#[0]" equivalence)]
  ["[0]" dependency (.only Dependency) (.use "[1]#[0]" equivalence)]
  ["[0]" artifact (.only Artifact)
   ["[0]" type]]
  [repository
   [remote (.only Address)]]])

(def .public default_lux
  Dependency
  [dependency.#artifact ["com.github.luxlang" "lux-jvm" "0.6.5"]
   dependency.#type type.jvm_library])

(type .public Distribution
  (Variant
   {#Repo}
   {#Manual}))

(def distribution_equivalence
  (Equivalence Distribution)
  (implementation
   (def (= reference subject)
     (case [reference subject]
       (^.with_template [<tag>]
         [[{<tag>} {<tag>}]
          true])
       ([#Repo]
        [#Manual])

       _
       false))))

(type .public License
  [Text
   URL
   Distribution])

(def license_equivalence
  (Equivalence License)
  (all product.equivalence
       text.equivalence
       text.equivalence
       ..distribution_equivalence))

(type .public SCM
  URL)

(type .public Organization
  [Text
   URL])

(def organization_equivalence
  (Equivalence Organization)
  (all product.equivalence
       text.equivalence
       text.equivalence))

(type .public Email
  Text)

(type .public Developer
  [Text
   Email
   (Maybe Organization)])

(def developer_equivalence
  (Equivalence Developer)
  (all product.equivalence
       text.equivalence
       text.equivalence
       (maybe.equivalence ..organization_equivalence)))

(type .public Contributor
  Developer)

(type .public Info
  (Record
   [#name (Maybe Text)
    #url (Maybe URL)
    #scm (Maybe SCM)
    #description (Maybe Text)
    #licenses (List License)
    #organization (Maybe Organization)
    #developers (List Developer)
    #contributors (List Contributor)]))

(def info_equivalence
  (Equivalence Info)
  (all product.equivalence
       (maybe.equivalence text.equivalence)
       (maybe.equivalence text.equivalence)
       (maybe.equivalence text.equivalence)
       (maybe.equivalence text.equivalence)
       (list.equivalence ..license_equivalence)
       (maybe.equivalence ..organization_equivalence)
       (list.equivalence ..developer_equivalence)
       (list.equivalence ..developer_equivalence)))

(def .public default_info
  Info
  [#name {.#None}
   #url {.#None}
   #scm {.#None}
   #description {.#None}
   #licenses (list)
   #organization {.#None}
   #developers (list)
   #contributors (list)])

(type .public Source
  Path)

(def .public default_source
  Source
  "source")

(type .public Target
  Path)

(def .public default_target
  Target
  "target")

(def .public default_repository
  Address
  "https://repo1.maven.org/maven2/")

(type .public Name
  Text)

(def .public default
  Name
  "")

(type .public Profile
  (Record
   [#parents (List Name)
    #identity (Maybe Artifact)
    #info (Maybe Info)
    #repositories (Set Address)
    #dependencies (Set Dependency)
    #lux Dependency
    #compilers (List Compiler)
    #sources (Set Source)
    #target Target
    #program (Maybe Symbol)
    #test (Maybe Symbol)
    #deploy_repositories (Dictionary Text Address)
    #configuration (property.List Text)
    #java Runtime
    #js Runtime
    #python Runtime
    #lua Runtime
    #ruby Runtime]))

(def .public equivalence
  (Equivalence Profile)
  (all product.equivalence
       ... #parents
       (list.equivalence text.equivalence)
       ... #identity
       (maybe.equivalence artifact.equivalence)
       ... #info
       (maybe.equivalence ..info_equivalence)
       ... #repositories
       set.equivalence
       ... #dependencies
       set.equivalence
       ... #lux
       dependency.equivalence
       ... #compilers
       (list.equivalence compiler.equivalence)
       ... #sources
       set.equivalence
       ... #target
       text.equivalence
       ... #program
       (maybe.equivalence symbol.equivalence)
       ... #test
       (maybe.equivalence symbol.equivalence)
       ... #deploy_repositories
       (dictionary.equivalence text.equivalence)
       ... #configuration
       (property.equivalence text.equivalence)
       ... #java
       runtime.equivalence
       ... #js
       runtime.equivalence
       ... #python
       runtime.equivalence
       ... #lua
       runtime.equivalence
       ... #ruby
       runtime.equivalence))

(def .public monoid
  (Monoid Profile)
  (implementation
   (def identity
     [#parents (list)
      #identity {.#None}
      #info {.#None}
      #repositories (set.empty text.hash)
      #dependencies (set.empty dependency.hash)
      #lux ..default_lux
      #compilers (list)
      #sources (set.empty text.hash)
      #target ..default_target
      #program {.#None}
      #test {.#None}
      #deploy_repositories (dictionary.empty text.hash)
      #configuration property.empty
      #java runtime.default_java
      #js runtime.default_js
      #python runtime.default_python
      #lua runtime.default_lua
      #ruby runtime.default_ruby])

   (def (composite override baseline)
     (template.let [(!runtime <tag> <runtime>)
                    [(if (runtime#= <runtime> (the <tag> override))
                       (the <tag> baseline)
                       (the <tag> override))]]
       [#parents (list#composite (the #parents baseline) (the #parents override))
        #identity (maybe#composite (the #identity override) (the #identity baseline))
        #info (maybe#composite (the #info override) (the #info baseline))
        #repositories (set.union (the #repositories baseline) (the #repositories override))
        #dependencies (set.union (the #dependencies baseline) (the #dependencies override))
        #lux (if (dependency#= ..default_lux (the #lux override))
               (the #lux baseline)
               (the #lux override))
        #compilers (list#composite (the #compilers baseline) (the #compilers override))
        #sources (set.union (the #sources baseline) (the #sources override))
        #target (if (text#= ..default_target (the #target baseline))
                  (the #target override)
                  (the #target baseline))
        #program (maybe#composite (the #program override) (the #program baseline))
        #test (maybe#composite (the #test override) (the #test baseline))
        #deploy_repositories (dictionary.composite (the #deploy_repositories override) (the #deploy_repositories baseline))
        #configuration (property#composite (the #configuration override) (the #configuration baseline))
        #java (!runtime #java runtime.default_java)
        #js (!runtime #js runtime.default_js)
        #python (!runtime #python runtime.default_python)
        #lua (!runtime #lua runtime.default_lua)
        #ruby (!runtime #ruby runtime.default_ruby)]))))

(exception .public no_identity)