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.lux171
-rw-r--r--stdlib/source/program/licentia/license/commercial.lux12
2 files changed, 98 insertions, 85 deletions
diff --git a/stdlib/source/program/licentia/input.lux b/stdlib/source/program/licentia/input.lux
index 48617f045..5ec07e32b 100644
--- a/stdlib/source/program/licentia/input.lux
+++ b/stdlib/source/program/licentia/input.lux
@@ -4,8 +4,8 @@
[monad (#+ do)]]
[control
["." exception (#+ exception:)]
- ["." parser
- ["." json (#+ Parser)]]]
+ ["<>" parser
+ ["<.>" json (#+ Parser)]]]
[data
[text
["%" format (#+ format)]]
@@ -13,25 +13,26 @@
["n" nat]
["i" int]
["f" frac]]]]
- [//
- [license (#+ Identification
- Termination
- Liability
- Distribution
- Commercial
- Extension
- Entity Black-List
- URL Attribution
- License)
+ ["." // #_
+ ["#" license (#+ Identification
+ Termination
+ Liability
+ Distribution
+ Commercial
+ Extension
+ Entity Black-List
+ URL Attribution
+ Addendum
+ License)
["." time (#+ Period)]
["." copyright]]])
(def: identification
(Parser Identification)
- (json.object
- ($_ parser.and
- (json.field "name" json.string)
- (json.field "version" json.string))))
+ (<json>.object
+ ($_ <>.and
+ (<json>.field "name" <json>.string)
+ (<json>.field "version" <json>.string))))
(exception: #export (cannot-use-fractional-amount {amount Frac})
(exception.report
@@ -43,14 +44,14 @@
(def: amount
(Parser Nat)
- (do parser.monad
- [amountF json.number
+ (do <>.monad
+ [amountF <json>.number
#let [amountI (f.int amountF)]
- _ (parser.assert (exception.construct cannot-use-fractional-amount amountF)
- (f.= amountF
- (i.frac amountI)))
- _ (parser.assert (exception.construct cannot-use-negative-amount amountI)
- (i.> +0 amountI))]
+ _ (<>.assert (exception.construct cannot-use-fractional-amount amountF)
+ (f.= amountF
+ (i.frac amountI)))
+ _ (<>.assert (exception.construct cannot-use-negative-amount amountI)
+ (i.> +0 amountI))]
(wrap (.nat amountI))))
(exception: #export (invalid-period {period (Period Nat)})
@@ -60,96 +61,106 @@
(def: period
(Parser (Period Nat))
- (json.object
- (do parser.monad
- [start (json.field "start" ..amount)
- end (json.field "end" ..amount)
+ (<json>.object
+ (do <>.monad
+ [start (<json>.field "start" ..amount)
+ end (<json>.field "end" ..amount)
#let [period {#time.start start
#time.end end}]
- _ (parser.assert (exception.construct invalid-period period)
- (n.<= end start))]
+ _ (<>.assert (exception.construct invalid-period period)
+ (n.<= end start))]
(wrap period))))
(def: copyright-holder
(Parser copyright.Holder)
- (json.object
- ($_ parser.and
- (json.field "name" json.string)
- (json.field "period" ..period))))
+ (<json>.object
+ ($_ <>.and
+ (<json>.field "name" <json>.string)
+ (<json>.field "period" ..period))))
(def: termination
(Parser Termination)
- (json.object
- ($_ parser.and
- (json.field "patent retaliation?" json.boolean)
- (json.field "termination period" ..amount)
- (json.field "grace period" ..amount))))
+ (<json>.object
+ ($_ <>.and
+ (<json>.field "patent retaliation?" <json>.boolean)
+ (<json>.field "termination period" ..amount)
+ (<json>.field "grace period" ..amount))))
(def: liability
(Parser Liability)
- (json.object
- ($_ parser.and
- (json.field "can accept?" json.boolean)
- (json.field "disclaim high risk?" json.boolean))))
+ (<json>.object
+ ($_ <>.and
+ (<json>.field "can accept?" <json>.boolean)
+ (<json>.field "disclaim high risk?" <json>.boolean))))
(def: distribution
(Parser Distribution)
- (json.object
- ($_ parser.and
- (json.field "can re-license?" json.boolean)
- (json.field "can multi-license?" json.boolean))))
+ (<json>.object
+ ($_ <>.and
+ (<json>.field "can re-license?" <json>.boolean)
+ (<json>.field "can multi-license?" <json>.boolean))))
(def: commercial
(Parser Commercial)
- (json.object
- ($_ parser.and
- (json.field "can sell?" json.boolean)
- (json.field "require contributor credit?" json.boolean)
- (json.field "allow contributor endorsement?" json.boolean))))
+ (<json>.object
+ ($_ <>.and
+ (<json>.field "can sell?" <json>.boolean)
+ (<json>.field "require contributor credit?" <json>.boolean)
+ (<json>.field "allow contributor endorsement?" <json>.boolean))))
(def: extension
(Parser Extension)
- (json.object
- ($_ parser.and
- (json.field "same license?" json.boolean)
- (json.field "must be distinguishable?" json.boolean)
- (json.field "notification period" (json.nullable ..period))
- (json.field "must describe modifications?" json.boolean))))
+ (<json>.object
+ ($_ <>.and
+ (<json>.field "same license?" <json>.boolean)
+ (<json>.field "must be distinguishable?" <json>.boolean)
+ (<json>.field "notification period" (<json>.nullable ..period))
+ (<json>.field "must describe modifications?" <json>.boolean))))
(def: entity
(Parser Entity)
- json.string)
+ <json>.string)
(def: black-list
(Parser Black-List)
- (json.object
- ($_ parser.and
- (json.field "justification" (json.nullable json.string))
- (json.field "entities" (json.array (parser.many ..entity))))))
+ (<json>.object
+ ($_ <>.and
+ (<json>.field "justification" (<json>.nullable <json>.string))
+ (<json>.field "entities" (<json>.array (<>.many ..entity))))))
(def: url
(Parser URL)
- json.string)
+ <json>.string)
(def: attribution
(Parser Attribution)
- (json.object
- ($_ parser.and
- (json.field "copyright-notice" json.string)
- (json.field "phrase" (json.nullable json.string))
- (json.field "url" ..url)
- (json.field "image" (json.nullable ..url)))))
+ (<json>.object
+ ($_ <>.and
+ (<json>.field "copyright-notice" <json>.string)
+ (<json>.field "phrase" (<json>.nullable <json>.string))
+ (<json>.field "url" ..url)
+ (<json>.field "image" (<json>.nullable ..url)))))
+
+(def: addendum
+ (Parser Addendum)
+ (<json>.object
+ ($_ <>.and
+ (<json>.field "commons clause?" <json>.boolean)
+ )))
(def: #export license
(Parser License)
- (json.object
- ($_ parser.and
- (json.field "copyright-holders" (json.array (parser.many ..copyright-holder)))
- (json.field "identification" (json.nullable ..identification))
- (json.field "termination" ..termination)
- (json.field "liability" ..liability)
- (json.field "distribution" ..distribution)
- (json.field "commercial" ..commercial)
- (json.field "extension" ..extension)
- (json.field "black-lists" (json.array (parser.some ..black-list)))
- (json.field "attribution" (json.nullable ..attribution)))))
+ (<json>.object
+ ($_ <>.and
+ (<json>.field "copyright-holders" (<json>.array (<>.many ..copyright-holder)))
+ (<json>.field "identification" (<json>.nullable ..identification))
+ (<json>.field "termination" ..termination)
+ (<json>.field "liability" ..liability)
+ (<json>.field "distribution" ..distribution)
+ (<json>.field "commercial" ..commercial)
+ (<json>.field "extension" ..extension)
+ (<json>.field "black-lists" (<json>.array (<>.some ..black-list)))
+ (<json>.field "attribution" (<json>.nullable ..attribution))
+ (<>.default {#//.commons-clause? false}
+ (<json>.field "addendum" ..addendum))
+ )))
diff --git a/stdlib/source/program/licentia/license/commercial.lux b/stdlib/source/program/licentia/license/commercial.lux
index 05b8c3966..e044baa43 100644
--- a/stdlib/source/program/licentia/license/commercial.lux
+++ b/stdlib/source/program/licentia/license/commercial.lux
@@ -10,11 +10,13 @@
(def: #export cannot-sell
(let [preamble (format "Without limiting other conditions in " _.license)
- condition (format "the grant of rights under " _.license
- " will not include, and " _.license
- " does not grant to " _.recipient
- ", the right to " _.sell " " _.work)]
- ($.sentence (format preamble ", " condition))))
+ direct-condition (format "the grant of rights under " _.license
+ " will not include, and does not grant to " _.recipient
+ ", the right to " _.sell " " _.work)
+ derivative-condition (format "or any " _.derivative-work)]
+ ($.sentence (format preamble
+ ", " direct-condition
+ ", " derivative-condition))))
(def: #export require-contributor-attribution
($.sentence (format "All advertising materials mentioning features or use of " _.work