aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/licentia
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/program/licentia')
-rw-r--r--stdlib/source/program/licentia/input.lux55
-rw-r--r--stdlib/source/program/licentia/license.lux6
-rw-r--r--stdlib/source/program/licentia/license/addendum.lux28
-rw-r--r--stdlib/source/program/licentia/output.lux5
4 files changed, 66 insertions, 28 deletions
diff --git a/stdlib/source/program/licentia/input.lux b/stdlib/source/program/licentia/input.lux
index 7d2192fe1..48617f045 100644
--- a/stdlib/source/program/licentia/input.lux
+++ b/stdlib/source/program/licentia/input.lux
@@ -1,14 +1,14 @@
(.module:
[lux #*
+ [abstract
+ [monad (#+ do)]]
[control
- [monad (#+ do)]
- ["ex" exception (#+ exception:)]
- ["." parser]]
+ ["." exception (#+ exception:)]
+ ["." parser
+ ["." json (#+ Parser)]]]
[data
[text
["%" format (#+ format)]]
- [format
- ["." json (#+ Reader)]]
[number
["n" nat]
["i" int]
@@ -27,55 +27,58 @@
["." copyright]]])
(def: identification
- (Reader Identification)
+ (Parser Identification)
(json.object
($_ parser.and
(json.field "name" json.string)
(json.field "version" json.string))))
(exception: #export (cannot-use-fractional-amount {amount Frac})
- (ex.report ["Amount" (%.frac amount)]))
+ (exception.report
+ ["Amount" (%.frac amount)]))
(exception: #export (cannot-use-negative-amount {amount Int})
- (ex.report ["Amount" (%.int amount)]))
+ (exception.report
+ ["Amount" (%.int amount)]))
(def: amount
- (Reader Nat)
+ (Parser Nat)
(do parser.monad
[amountF json.number
#let [amountI (f.int amountF)]
- _ (parser.assert (ex.construct cannot-use-fractional-amount amountF)
+ _ (parser.assert (exception.construct cannot-use-fractional-amount amountF)
(f.= amountF
(i.frac amountI)))
- _ (parser.assert (ex.construct cannot-use-negative-amount amountI)
+ _ (parser.assert (exception.construct cannot-use-negative-amount amountI)
(i.> +0 amountI))]
(wrap (.nat amountI))))
(exception: #export (invalid-period {period (Period Nat)})
- (ex.report ["Start" (%.nat (get@ #time.start period))]
- ["End" (%.nat (get@ #time.end period))]))
+ (exception.report
+ ["Start" (%.nat (get@ #time.start period))]
+ ["End" (%.nat (get@ #time.end period))]))
(def: period
- (Reader (Period Nat))
+ (Parser (Period Nat))
(json.object
(do parser.monad
[start (json.field "start" ..amount)
end (json.field "end" ..amount)
#let [period {#time.start start
#time.end end}]
- _ (parser.assert (ex.construct invalid-period period)
+ _ (parser.assert (exception.construct invalid-period period)
(n.<= end start))]
(wrap period))))
(def: copyright-holder
- (Reader copyright.Holder)
+ (Parser copyright.Holder)
(json.object
($_ parser.and
(json.field "name" json.string)
(json.field "period" ..period))))
(def: termination
- (Reader Termination)
+ (Parser Termination)
(json.object
($_ parser.and
(json.field "patent retaliation?" json.boolean)
@@ -83,21 +86,21 @@
(json.field "grace period" ..amount))))
(def: liability
- (Reader Liability)
+ (Parser Liability)
(json.object
($_ parser.and
(json.field "can accept?" json.boolean)
(json.field "disclaim high risk?" json.boolean))))
(def: distribution
- (Reader Distribution)
+ (Parser Distribution)
(json.object
($_ parser.and
(json.field "can re-license?" json.boolean)
(json.field "can multi-license?" json.boolean))))
(def: commercial
- (Reader Commercial)
+ (Parser Commercial)
(json.object
($_ parser.and
(json.field "can sell?" json.boolean)
@@ -105,7 +108,7 @@
(json.field "allow contributor endorsement?" json.boolean))))
(def: extension
- (Reader Extension)
+ (Parser Extension)
(json.object
($_ parser.and
(json.field "same license?" json.boolean)
@@ -114,22 +117,22 @@
(json.field "must describe modifications?" json.boolean))))
(def: entity
- (Reader Entity)
+ (Parser Entity)
json.string)
(def: black-list
- (Reader Black-List)
+ (Parser Black-List)
(json.object
($_ parser.and
(json.field "justification" (json.nullable json.string))
(json.field "entities" (json.array (parser.many ..entity))))))
(def: url
- (Reader URL)
+ (Parser URL)
json.string)
(def: attribution
- (Reader Attribution)
+ (Parser Attribution)
(json.object
($_ parser.and
(json.field "copyright-notice" json.string)
@@ -138,7 +141,7 @@
(json.field "image" (json.nullable ..url)))))
(def: #export license
- (Reader License)
+ (Parser License)
(json.object
($_ parser.and
(json.field "copyright-holders" (json.array (parser.many ..copyright-holder)))
diff --git a/stdlib/source/program/licentia/license.lux b/stdlib/source/program/licentia/license.lux
index 375ed8c12..c62c8419d 100644
--- a/stdlib/source/program/licentia/license.lux
+++ b/stdlib/source/program/licentia/license.lux
@@ -46,6 +46,9 @@
#url URL
#image (Maybe URL)})
+(type: #export Addendum
+ {#commons-clause? Bit})
+
(type: #export License
{#copyright-holders (List /copyright.Holder)
#identification (Maybe Identification)
@@ -55,4 +58,5 @@
#commercial Commercial
#extension Extension
#black-lists (List Black-List)
- #attribution (Maybe Attribution)})
+ #attribution (Maybe Attribution)
+ #addendum Addendum})
diff --git a/stdlib/source/program/licentia/license/addendum.lux b/stdlib/source/program/licentia/license/addendum.lux
new file mode 100644
index 000000000..7e467c630
--- /dev/null
+++ b/stdlib/source/program/licentia/license/addendum.lux
@@ -0,0 +1,28 @@
+(.module:
+ [lux #*
+ [data
+ [text
+ ["%" format (#+ format)]]]]
+ ["." // (#+ Addendum)
+ [//
+ ["$" document]]])
+
+## https://commonsclause.com/
+(def: #export commons-clause
+ Text
+ (format ($.block "The Software is provided to you by the Licensor under the License, as defined below, subject to the following condition.")
+ ($.block "Without limiting other conditions in the License, the grant of rights under the License will not include, and the License does not grant to you, the right to Sell the Software.")
+ ($.block "For purposes of the foregoing, “Sell” means practicing any or all of the rights granted to you under the License to provide to third parties, for a fee or other consideration (including without limitation fees for hosting or consulting/ support services related to the Software), a product or service whose value derives, entirely or substantially, from the functionality of the Software. Any license notice or attribution required by the License must also include this Commons Clause License Condition notice.")))
+
+(def: #export (output value)
+ (-> Addendum Text)
+ (`` (format (~~ (template [<title> <condition> <content>]
+ [(if <condition>
+ ($.block ($.section {#$.title <title>
+ #$.content <content>}))
+ "")]
+
+ ["“Commons Clause” License Condition v1.0"
+ (get@ #//.commons-clause? value)
+ ..commons-clause]
+ )))))
diff --git a/stdlib/source/program/licentia/output.lux b/stdlib/source/program/licentia/output.lux
index 5d3899170..fdbd9accd 100644
--- a/stdlib/source/program/licentia/output.lux
+++ b/stdlib/source/program/licentia/output.lux
@@ -29,7 +29,8 @@
["." miscellaneous]
["." black-list]
["." notice]
- ["_" term]]
+ ["_" term]
+ ["." addendum]]
["$" document]])
(def: #export (definition value)
@@ -301,6 +302,8 @@
(maybe.default ""))
(..miscellaneous identified?)
+
+ (addendum.output (get@ #license.addendum value))
notice.end-of-license
))))