aboutsummaryrefslogtreecommitdiff
path: root/licentia/source/program/licentia/output.lux
blob: 9f08bd25075d1f091fc55048b590af892e659b40 (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
310
311
312
(.using
 [library
  [lux {"-" Definition}
   [control
    ["[0]" maybe ("[1]#[0]" functor)]]
   [data
    ["[0]" bit]
    ["[0]" text
     ["%" format {"+" format}]]
    [collection
     ["[0]" list ("[1]#[0]" functor monoid)]]]]]
 [//
  ["[0]" license {"+" Identification
                  Termination
                  Liability
                  Distribution
                  Commercial
                  Extension
                  Entity Black_List
                  URL Attribution
                  License}
   ["[0]" copyright]
   ["[0]" definition {"+" Definition}]
   ["[0]" grant]
   ["[0]" limitation]
   ["[0]" assurance]
   ["[0]" liability]
   ["[0]" distribution]
   ["[0]" commercial]
   ["[0]" extension]
   ["[0]" submission]
   ["[0]" miscellaneous]
   ["[0]" black_list]
   ["[0]" notice]
   ["_" term]
   ["[0]" addendum]]
  ["$" document]])

(def: .public (definition value)
  (-> Definition Text)
  (format ($.quote (the definition.#term value)) ": " (the definition.#meaning value)))

(def: .public (identification value)
  (-> Identification Text)
  (format (the license.#name value) text.new_line
          (the license.#version value)))

(def: .public (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 (the license.#patent_retaliation? termination))]
                    
                    ["Effective Date for the Grants"
                     grant.date]

                    ["Grant Termination"
                     (grant.termination (the license.#termination_period termination)
                                        (the license.#grace_period termination))]

                    ["No Retroactive Effect of Termination"
                     grant.no_retroactive_termination])))))

(def: .public 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: .public assurance
  Text
  (`` (format (~~ (template [<title> <content>]
                    [($.block ($.section [#$.title <title>
                                          #$.content <content>]))]
                    
                    ["Representation"
                     assurance.representation]
                    
                    ["Fair Use"
                     assurance.fair_use])))))

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

                    ["Disclaimer of Warranty"
                     bit.on
                     liability.warranty]
                    
                    ["Limitation of Liability"
                     bit.on
                     liability.limitation]
                    
                    ["Litigation"
                     bit.on
                     liability.litigation]
                    
                    ["Accepting Warranty or Additional Liability"
                     (the license.#can_accept? value)
                     liability.can_accept]

                    ["High Risk Activities"
                     (the license.#disclaim_high_risk? value)
                     liability.disclaim_high_risk])))))

(def: .public (distribution distribution)
  (-> Distribution Text)
  (`` (format (~~ (template [<title> <condition> <content>]
                    [(if <condition>
                       ($.block ($.section [#$.title <title>
                                            #$.content <content>]))
                       "")]
                    
                    [(format "Distribution of a " _.source_code_form)
                     bit.on
                     distribution.source_code_form]
                    
                    [(format "Distribution of an " _.object_form)
                     bit.on
                     distribution.object_form]
                    
                    [(format "Distribution of an " _.extension)
                     (or (the license.#can_re_license? distribution)
                         (the license.#can_multi_license? distribution))
                     (distribution.extension distribution)])))))

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

                    ["Non-Commerciality"
                     (not (the license.#can_sell? value))
                     commercial.cannot_sell]

                    [(format _.contributor " Attribution")
                     (the license.#require_contributor_credit? value)
                     commercial.require_contributor_attribution]

                    [(format _.contributor " Endorsement")
                     (not (the license.#allow_contributor_endorsement? value))
                     commercial.disallow_contributor_endorsement]
                    )))))

(def: .public (extension value)
  (-> Extension Text)
  (let [[show? document] (case (the 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>]))
                         "")]

                      [(the license.#same_license? value) "License Retention"
                       ($.paragraph (list#composite extension.sharing_requirement
                                                    extension.license_conflict_resolution))]
                      
                      [(the license.#must_be_distinguishable? value) (format _.extension " Distinctness")
                       extension.distinctness_requirement]
                      
                      [show? (format _.source_code_form " Availability")
                       document]
                      
                      [(the license.#must_describe_modifications? value) (format "Description of " ($.plural _.modification))
                       extension.description_requirement]))))))

(def: .public (attribution value)
  (-> Attribution Text)
  (let [copyright_notice (format "Attribution Copyright Notice: " (the license.#copyright_notice value))
        phrase (case (the license.#phrase value)
                 {.#Some phrase}
                 (format text.new_line "Attribution Phrase: " phrase text.new_line)

                 {.#None}
                 "")
        url (format text.new_line "Attribution URL: " (the license.#url value))
        image (case (the license.#image value)
                {.#Some image}
                (format text.new_line "Attribution Image: " image)

                {.#None}
                "")]
    (format copyright_notice
            phrase
            url
            image)))

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

                    ["Entire Agreement"
                     bit.on
                     miscellaneous.entire_agreement]

                    ["Relationship of Parties"
                     bit.on
                     miscellaneous.relationship_of_parties]

                    ["Independent Development"
                     bit.on
                     miscellaneous.independent_development]

                    ["Consent To Breach Not Waiver"
                     bit.on
                     miscellaneous.not_waiver]
                    
                    ["Severability"
                     bit.on
                     miscellaneous.severability]

                    ["Export Restrictions"
                     bit.on
                     miscellaneous.export_restrictions]

                    [(format "Versions of " _.license)
                     identified?
                     miscellaneous.new_versions]
                    )))))

(def: black_list_spacing (format text.new_line text.new_line))

(def: .public (license value)
  (-> License Text)
  (let [identification (|> value
                           (the license.#identification)
                           (maybe#each ..identification)
                           (maybe.default ""))
        identified? (case (the license.#identification value)
                      {.#Some _}
                      true

                      {.#None}
                      false)]
    (`` (format ($.block identification)
                ($.block (notice.copyright (the license.#copyright_holders value)))
                
                (case (the license.#black_lists value)
                  {.#End}
                  ""

                  black_lists
                  ($.block ($.section [#$.title (format "Denial of " _.license)
                                       #$.content (|> black_lists
                                                      (list#each black_list.black_list)
                                                      (text.interposed ..black_list_spacing))])))
                
                ($.section [#$.title "Definitions"
                            #$.content (|> definition.all
                                           (list#each (|>> ..definition $.block))
                                           (text.interposed ""))])

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

                (..grant (the license.#termination value))
                ..limitation
                ..assurance

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

                (..liability (the license.#liability value))
                (..distribution (the license.#distribution value))
                (..commercial (the license.#commercial value))
                (..extension (the license.#extension value))

                (|> value
                    (the license.#attribution)
                    (maybe#each (|>> ..attribution
                                     ["Attribution Information"]
                                     $.section
                                     $.block))
                    (maybe.default ""))

                (..miscellaneous identified?)

                (addendum.output (the license.#addendum value))
                
                notice.end_of_license
                ))))