aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/licentia/license/distribution.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/program/licentia/license/distribution.lux112
1 files changed, 112 insertions, 0 deletions
diff --git a/stdlib/source/program/licentia/license/distribution.lux b/stdlib/source/program/licentia/license/distribution.lux
new file mode 100644
index 000000000..346f3a3b4
--- /dev/null
+++ b/stdlib/source/program/licentia/license/distribution.lux
@@ -0,0 +1,112 @@
+(.module:
+ [lux #*
+ [data
+ ["." text
+ format]
+ [collection
+ [list ("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)))))