aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/licentia/output.lux
blob: fdbd9accdb2db5cc5a01ffaf874e90574d52a857 (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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
(.module:
  [lux (#- Definition)
   [data
    ["." maybe ("#\." functor)]
    ["." text
     ["%" format (#+ format)]]
    [collection
     ["." list ("#\." functor monoid)]]]]
  [//
   ["." license (#+ Identification
                    Termination
                    Liability
                    Distribution
                    Commercial
                    Extension
                    Entity Black-List
                    URL Attribution
                    License)
    ["." copyright]
    ["." definition (#+ Definition)]
    ["." grant]
    ["." limitation]
    ["." assurance]
    ["." liability]
    ["." distribution]
    ["." commercial]
    ["." extension]
    ["." submission]
    ["." miscellaneous]
    ["." black-list]
    ["." notice]
    ["_" term]
    ["." addendum]]
   ["$" document]])

(def: #export (definition value)
  (-> Definition Text)
  (format ($.quote (get@ #definition.term value)) ": " (get@ #definition.meaning value)))

(def: #export (identification value)
  (-> Identification Text)
  (format (get@ #license.name value) text.new-line
          (get@ #license.version value)))

(def: #export (grant termination)
  (-> Termination Text)
  (`` (format (~~ (template [<title> <content>]
                    [($.block ($.section {#$.title <title>
                                          #$.content <content>}))]
                    
                    ["Grant of Copyright License"
                     grant.copyright]
                    
                    ["Grant of Patent License"
                     (grant.patent (get@ #license.patent-retaliation? termination))]
                    
                    ["Effective Date for the Grants"
                     grant.date]

                    ["Grant Termination"
                     (grant.termination (get@ #license.termination-period termination)
                                        (get@ #license.grace-period termination))]

                    ["No Retroactive Effect of Termination"
                     grant.no-retroactive-termination])))))

(def: #export limitation
  Text
  (`` (format (~~ (template [<title> <content>]
                    [($.block ($.section {#$.title <title>
                                          #$.content <content>}))]
                    
                    ["Limitations on Grant Scope"
                     limitation.grant]
                    
                    ["Limitations on Trademarks"
                     limitation.trademark]

                    [(format "Limitations on " ($.plural _.secondary-license))
                     limitation.secondary-licenses])))))

(def: #export assurance
  Text
  (`` (format (~~ (template [<title> <content>]
                    [($.block ($.section {#$.title <title>
                                          #$.content <content>}))]
                    
                    ["Representation"
                     assurance.representation]
                    
                    ["Fair Use"
                     assurance.fair-use])))))

(def: #export (liability value)
  (-> Liability Text)
  (`` (format (~~ (template [<title> <condition> <content>]
                    [(if <condition>
                       ($.block ($.section {#$.title <title>
                                            #$.content <content>}))
                       "")]

                    ["Disclaimer of Warranty"
                     on
                     liability.warranty]
                    
                    ["Limitation of Liability"
                     on
                     liability.limitation]
                    
                    ["Litigation"
                     on
                     liability.litigation]
                    
                    ["Accepting Warranty or Additional Liability"
                     (get@ #license.can-accept? value)
                     liability.can-accept]

                    ["High Risk Activities"
                     (get@ #license.disclaim-high-risk? value)
                     liability.disclaim-high-risk])))))

(def: #export (distribution distribution)
  (-> Distribution Text)
  (`` (format (~~ (template [<title> <condition> <content>]
                    [(if <condition>
                       ($.block ($.section {#$.title <title>
                                            #$.content <content>}))
                       "")]
                    
                    [(format "Distribution of a " _.source-code-form)
                     on
                     distribution.source-code-form]
                    
                    [(format "Distribution of an " _.object-form)
                     on
                     distribution.object-form]
                    
                    [(format "Distribution of an " _.extension)
                     (or (get@ #license.can-re-license? distribution)
                         (get@ #license.can-multi-license? distribution))
                     (distribution.extension distribution)])))))

(def: #export (commercial value)
  (-> Commercial Text)
  (`` (format (~~ (template [<title> <condition> <content>]
                    [(if <condition>
                       ($.block ($.section {#$.title <title>
                                            #$.content <content>}))
                       "")]

                    ["Non-Commerciality"
                     (not (get@ #license.can-sell? value))
                     commercial.cannot-sell]

                    [(format _.contributor " Attribution")
                     (get@ #license.require-contributor-credit? value)
                     commercial.require-contributor-attribution]

                    [(format _.contributor " Endorsement")
                     (not (get@ #license.allow-contributor-endorsement? value))
                     commercial.disallow-contributor-endorsement]
                    )))))

(def: #export (extension value)
  (-> Extension Text)
  (let [[show? document] (case (get@ #license.notification-period value)
                           (#.Some period)
                           [true (extension.notification-requirement period)]

                           #.None
                           [false ""])]
    (`` (format (~~ (template [<condition> <title> <content>]
                      [(if <condition>
                         ($.block ($.section {#$.title <title>
                                              #$.content <content>}))
                         "")]

                      [(get@ #license.same-license? value) "License Retention"
                       ($.paragraph (list\compose extension.sharing-requirement
                                                  extension.license-conflict-resolution))]
                      
                      [(get@ #license.must-be-distinguishable? value) (format _.extension " Distinctness")
                       extension.distinctness-requirement]
                      
                      [show? (format _.source-code-form " Availability")
                       document]
                      
                      [(get@ #license.must-describe-modifications? value) (format "Description of " ($.plural _.modification))
                       extension.description-requirement]))))))

(def: #export (attribution value)
  (-> Attribution Text)
  (let [copyright-notice (format "Attribution Copyright Notice: " (get@ #license.copyright-notice value))
        phrase (case (get@ #license.phrase value)
                 (#.Some phrase)
                 (format text.new-line "Attribution Phrase: " phrase text.new-line)

                 #.None
                 "")
        url (format text.new-line "Attribution URL: " (get@ #license.url value))
        image (case (get@ #license.image value)
                (#.Some image)
                (format text.new-line "Attribution Image: " image)

                #.None
                "")]
    (format copyright-notice
            phrase
            url
            image)))

(def: #export (miscellaneous identified?)
  (-> Bit Text)
  (`` (format (~~ (template [<title> <condition> <content>]
                    [(if <condition>
                       ($.block ($.section {#$.title <title>
                                            #$.content <content>}))
                       "")]

                    ["Entire Agreement"
                     on
                     miscellaneous.entire-agreement]

                    ["Relationship of Parties"
                     on
                     miscellaneous.relationship-of-parties]

                    ["Independent Development"
                     on
                     miscellaneous.independent-development]

                    ["Consent To Breach Not Waiver"
                     on
                     miscellaneous.not-waiver]
                    
                    ["Severability"
                     on
                     miscellaneous.severability]

                    ["Export Restrictions"
                     on
                     miscellaneous.export-restrictions]

                    [(format "Versions of " _.license)
                     identified?
                     miscellaneous.new-versions]
                    )))))

(def: black-list-spacing (format text.new-line text.new-line))

(def: #export (license value)
  (-> License Text)
  (let [identification (|> value
                           (get@ #license.identification)
                           (maybe\map ..identification)
                           (maybe.default ""))
        identified? (case (get@ #license.identification value)
                      (#.Some _)
                      true

                      #.None
                      false)]
    (`` (format ($.block identification)
                ($.block (notice.copyright (get@ #license.copyright-holders value)))
                
                (case (get@ #license.black-lists value)
                  #.Nil
                  ""

                  black-lists
                  ($.block ($.section {#$.title (format "Denial of " _.license)
                                       #$.content (|> black-lists
                                                      (list\map black-list.black-list)
                                                      (text.join-with ..black-list-spacing))})))
                
                ($.section {#$.title "Definitions"
                            #$.content (|> definition.all
                                           (list\map (|>> ..definition $.block))
                                           (text.join-with ""))})

                ($.block ($.section {#$.title (format "Acceptance of " _.license)
                                     #$.content limitation.acceptance}))

                (..grant (get@ #license.termination value))
                ..limitation
                ..assurance

                ($.block ($.section {#$.title (format _.submission " of " ($.plural _.contribution))
                                     #$.content submission.contribution}))

                (..liability (get@ #license.liability value))
                (..distribution (get@ #license.distribution value))
                (..commercial (get@ #license.commercial value))
                (..extension (get@ #license.extension value))

                (|> value
                    (get@ #license.attribution)
                    (maybe\map (|>> ..attribution
                                    ["Attribution Information"]
                                    $.section
                                    $.block))
                    (maybe.default ""))

                (..miscellaneous identified?)

                (addendum.output (get@ #license.addendum value))
                
                notice.end-of-license
                ))))