aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/licentia/license/distribution.lux
blob: 077735b2c94c2b9a302a1689b22d6f4a6fc55271 (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
(.module:
  [lux #*
   [data
    ["." text
     format]
    [collection
     ["." list ("#;." monoid)]]]]
  ["." // (#+ Distribution)
   ["_" term]
   [//
    ["$" document]]])

(def: notices
  (List Text)
  (let [notices (: (-> Text Text)
                   (function (_ what)
                     (format what " notices")))]
    (list (notices "copyright")
          (notices "patent")
          (notices "trademark")
          (notices "attribution")
          (notices "disclaimer of warranty")
          (notices "limitation of liability")
          (notices "other"))))

(def: #export source-code-form
  (let [on-license-propagation (let [coverage (format "All distribution of " _.work " in " _.source-code-form)
                                     with-contributions (format "including any " ($.plural _.contribution)
                                                                " that " _.recipient
                                                                " creates")
                                     same-license (format "must be under the terms of " _.license)]
                                 (format coverage ", " with-contributions ", " same-license))
        on-license-access (let [responsibility-to-inform (format _.recipient
                                                                 " must inform recipients that the " _.source-code-form
                                                                 " of " _.work
                                                                 " is governed by the terms of " _.license)
                                license-copy (format "and how they can obtain a copy of " _.license)]
                            (format responsibility-to-inform ", " license-copy))
        on-license-immutability (format _.recipient
                                        " may not attempt to alter or restrict the recipients’ rights in the " _.source-code-form
                                        ", as specified in " _.license)
        on-notice-retention (let [obligation (format _.recipient " must retain")
                                  location (format "in the " _.source-code-form
                                                   " of any " _.extension
                                                   " that " _.recipient
                                                   " distributes")
                                  what (format "all " ($.and notices) " from the " _.source-code-form " of " _.work)
                                  exclusion ($.or (list (format "those notices that do not pertain to any part of the " _.extension)
                                                        "those notices that contain known factual inaccuracies"))]
                              (format obligation ", " location ", " what ", excluding " exclusion))
        on-additional-notices (let [right (format _.recipient
                                                  " may add additional "($.and notices)
                                                  " within an " _.extension
                                                  " that " _.recipient
                                                  " distributes")
                                    constraint (format "such additional " ($.and notices) " cannot be construed as modifying " _.license)]
                                (format right ", provided that " constraint))]
    ($.paragraph (list on-license-propagation
                       on-license-access
                       on-license-immutability
                       on-notice-retention
                       on-additional-notices))))

(def: #export object-form
  (let [on-responsibility (let [condition (format "If " _.recipient
                                                  " distributes " _.work
                                                  " in " _.object-form)
                                responsibility (let [availability-responsibility (format _.work " must also be made available in " _.source-code-form)
                                                     source-code-responsibility (format _.recipient
                                                                                        " must inform recipients of the " _.object-form
                                                                                        " how they can obtain a copy of such " _.source-code-form)
                                                     constraints "by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient"]
                                                 (format availability-responsibility ", and " source-code-responsibility " " constraints))]
                            (format condition " then " responsibility))
        on-licensing (format _.recipient
                             " may distribute such " _.object-form
                             " under the terms of "_.license)]
    ($.paragraph (list on-responsibility
                       on-licensing))))

(def: #export allow-re-licensing
  (let [can-license (format _.recipient
                            " may create and distribute an " _.extension
                            " under terms " _.recipient
                            " chooses")
        requirement (format _.recipient
                            " also comply with the requirements of " _.license
                            " for the " _.work)]
    (format can-license ", " "provided that " requirement)))

(def: #export allow-multi-licensing
  (let [condition (format "the " _.extension " is a combination of " _.work " with a work governed by one or more " ($.plural _.secondary-license))
        permission (let [relicensing (format _.license
                                             " permits " _.recipient
                                             " to additionally distribute " _.work
                                             " under the terms of such " ($.plural _.secondary-license))
                         distribution (format "so that the recipient of the " _.extension
                                              " may, at their option, further distribute " _.work
                                              " under the terms of either " _.license
                                              " or such " ($.plural _.secondary-license))]
                     (format relicensing ", " distribution))]
    (format "If " condition ", " permission)))

(def: #export (extension distribution)
  (-> Distribution Text)
  ($.paragraph ($_ list;compose
                   (if (get@ #//.can-re-license? distribution)
                     (list allow-re-licensing)
                     (list))
                   (if (get@ #//.can-multi-license? distribution)
                     (list allow-multi-licensing)
                     (list)))))