aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/profile.lux
blob: d8ebf9b1871ecd38300db6c63a69517d3357ade4 (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
(.module:
  [lux (#- Info Source Module Name)
   [abstract
    [monoid (#+ Monoid)]
    ["." equivalence (#+ Equivalence)]]
   [control
    ["." exception (#+ exception:)]]
   [data
    ["." maybe ("#@." monoid)]
    ["." text]
    [collection
     ["." dictionary (#+ Dictionary)]
     ["." list ("#@." monoid)]
     ["." set (#+ Set)]]]
   [world
    [net (#+ URL)]
    [file (#+ Path)]]
   [tool
    [compiler
     [meta
      [archive
       [descriptor (#+ Module)]]]]]]
  [//
   ["." artifact (#+ Artifact)]
   ["." dependency]])

(def: #export file
  "project.lux")

(type: #export Distribution
  #Repo
  #Manual)

(structure: distribution-equivalence
  (Equivalence Distribution)

  (def: (= reference subject)
    (case [reference subject]
      (^template [<tag>]
        [<tag> <tag>]
        true)
      ([#Repo]
       [#Manual])

      _
      false)))

(type: #export License
  [Text
   URL
   Distribution])

(def: license-equivalence
  (Equivalence License)
  ($_ equivalence.product
      text.equivalence
      text.equivalence
      ..distribution-equivalence))

(type: #export SCM
  URL)

(type: #export Organization
  [Text
   URL])

(def: organization-equivalence
  (Equivalence Organization)
  ($_ equivalence.product
      text.equivalence
      text.equivalence))

(type: #export Email
  Text)

(type: #export Developer
  [Text
   Email
   (Maybe Organization)])

(def: developer-equivalence
  (Equivalence Developer)
  ($_ equivalence.product
      text.equivalence
      text.equivalence
      (maybe.equivalence ..organization-equivalence)))

(type: #export Contributor
  Developer)

(type: #export Info
  {#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)
  ($_ equivalence.product
      (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: #export default-info
  Info
  {#url #.None
   #scm #.None
   #description #.None
   #licenses (list)
   #organization #.None
   #developers (list)
   #contributors (list)})

(type: #export Source
  Path)

(def: #export default-source
  Source
  "source")

(type: #export Target
  Path)

(def: #export default-target
  Target
  "target")

(type: #export Name
  Text)

(def: #export default
  Name
  "")

(type: #export Profile
  {#parents (List Name)
   #identity (Maybe Artifact)
   #info (Maybe Info)
   #repositories (Set dependency.Repository)
   #dependencies (Set dependency.Dependency)
   #sources (Set Source)
   #target (Maybe Target)
   #program (Maybe Module)
   #test (Maybe Module)
   #deploy-repositories (Dictionary Text dependency.Repository)})

(def: #export equivalence
  (Equivalence Profile)
  ($_ equivalence.product
      ## #parents
      (list.equivalence text.equivalence)
      ## #identity
      (maybe.equivalence artifact.equivalence)
      ## #info
      (maybe.equivalence ..info-equivalence)
      ## #repositories
      set.equivalence
      ## #dependencies
      set.equivalence
      ## #sources
      set.equivalence
      ## #target
      (maybe.equivalence text.equivalence)
      ## #program
      (maybe.equivalence text.equivalence)
      ## #test
      (maybe.equivalence text.equivalence)
      ## #deploy-repositories
      (dictionary.equivalence text.equivalence)))

(structure: #export monoid
  (Monoid Profile)

  (def: identity
    {#parents (list)
     #identity #.None
     #info #.None
     #repositories (set.new text.hash)
     #dependencies (set.new dependency.hash)
     #sources (set.new text.hash)
     #target #.None
     #program #.None
     #test #.None
     #deploy-repositories (dictionary.new text.hash)})

  (def: (compose override baseline)
    {#parents (list@compose (get@ #parents baseline) (get@ #parents override))
     #identity (maybe@compose (get@ #identity override) (get@ #identity baseline))
     #info (maybe@compose (get@ #info override) (get@ #info baseline))
     #repositories (set.union (get@ #repositories baseline) (get@ #repositories override))
     #dependencies (set.union (get@ #dependencies baseline) (get@ #dependencies override))
     #sources (set.union (get@ #sources baseline) (get@ #sources override))
     #target (maybe@compose (get@ #target override) (get@ #target baseline))
     #program (maybe@compose (get@ #program override) (get@ #program baseline))
     #test (maybe@compose (get@ #test override) (get@ #test baseline))
     #deploy-repositories (dictionary.merge (get@ #deploy-repositories override) (get@ #deploy-repositories baseline))}))

(exception: #export no-identity)