aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/licentia/input.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/program/licentia/input.lux')
-rw-r--r--stdlib/source/program/licentia/input.lux55
1 files changed, 29 insertions, 26 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)))