From d747aada2d6df6538d0a88d70169f3757aef50af Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 10 Dec 2020 07:28:48 -0400 Subject: Updated Lux license to v0.1.1. --- stdlib/source/program/aedifex.lux | 12 +- stdlib/source/program/aedifex/command/auto.lux | 13 +- stdlib/source/program/aedifex/command/build.lux | 71 ++++----- stdlib/source/program/aedifex/command/test.lux | 45 +++--- stdlib/source/program/licentia/input.lux | 171 +++++++++++---------- .../source/program/licentia/license/commercial.lux | 12 +- 6 files changed, 166 insertions(+), 158 deletions(-) (limited to 'stdlib/source/program') diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux index 160720fa7..aac616597 100644 --- a/stdlib/source/program/aedifex.lux +++ b/stdlib/source/program/aedifex.lux @@ -33,7 +33,7 @@ [world ["." shell (#+ Shell)] ["." console (#+ Console)] - ["." program] + ["." program (#+ Program)] ["." file (#+ Path) ["." watch]]]] ["." / #_ @@ -68,13 +68,11 @@ (def: (with-dependencies console command profile) (All [a] (-> (Console Promise) - (-> (Console Promise) Environment (file.System Promise) (Shell Promise) Resolution (Command a)) + (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command a)) (Command a))) - (do promise.monad - [environment (promise.future (\ program.default environment []))] - (do /action.monad - [resolution (/command/deps.do! console (file.async file.default) (..repositories profile) profile)] - ((command console environment (file.async file.default) (shell.async shell.default) resolution) profile)))) + (do /action.monad + [resolution (/command/deps.do! console (file.async file.default) (..repositories profile) profile)] + ((command console (program.async program.default) (file.async file.default) (shell.async shell.default) resolution) profile))) (exception: (cannot-find-repository {repository Text} {options (Dictionary Text Address)}) diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux index a2f2b1ff5..4b151861b 100644 --- a/stdlib/source/program/aedifex/command/auto.lux +++ b/stdlib/source/program/aedifex/command/auto.lux @@ -7,14 +7,13 @@ [concurrency ["." promise (#+ Promise)]] [security - ["!" capability]] - [parser - [environment (#+ Environment)]]] + ["!" capability]]] [data [collection ["." list] ["." set]]] [world + [program (#+ Program)] [shell (#+ Shell)] ["." console (#+ Console)] ["." file (#+ Path) @@ -50,11 +49,11 @@ (def: #export (do! watcher command) (All [a] (-> (Watcher Promise) - (-> (Console Promise) Environment (file.System Promise) (Shell Promise) Resolution (Command a)) - (-> (Console Promise) Environment (file.System Promise) (Shell Promise) Resolution (Command Any)))) - (function (_ console environment fs shell resolution) + (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command a)) + (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command Any)))) + (function (_ console program fs shell resolution) (function (_ profile) - (with-expansions [ ((command console environment fs shell resolution) profile)] + (with-expansions [ ((command console program fs shell resolution) profile)] (do {! promise.monad} [targets (|> profile (get@ #///.sources) diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index 78e38a6c5..8960d9c75 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -9,9 +9,7 @@ [concurrency ["." promise (#+ Promise) ("#\." monad)]] [security - ["!" capability]] - [parser - [environment (#+ Environment)]]] + ["!" capability]]] [data ["." product] ["." maybe] @@ -24,6 +22,7 @@ [number ["i" int]]] [world + [program (#+ Program)] ["." file (#+ Path)] ["." shell (#+ Shell)] ["." console (#+ Console)]]] @@ -108,10 +107,6 @@ (list.filter (|>> (get@ #///dependency.type) (text\= ///artifact/type.lux-library))) (list\map (|>> (get@ #///dependency.artifact) (///local.path fs))))) -(def: #export working-directory - (-> Environment (Try Text)) - (|>> (dictionary.get "user.dir") try.from-maybe)) - (def: (singular name) (-> Text Text (List Text)) (|>> (list name))) @@ -124,8 +119,8 @@ (def: #export success "[BUILD ENDED]") (def: #export failure "[BUILD FAILED]") -(def: #export (do! console environment fs shell resolution profile) - (-> (Console Promise) Environment (file.System Promise) (Shell Promise) Resolution (Command [Compiler Path])) +(def: #export (do! console program fs shell resolution profile) + (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Compiler Path])) (case [(get@ #///.program profile) (get@ #///.target profile)] [#.None _] @@ -134,31 +129,33 @@ [_ #.None] (promise\wrap (exception.throw ..no-specified-target [])) - [(#.Some program) (#.Some target)] - (do ///action.monad - [[resolution compiler] (promise\wrap (..compiler resolution)) - working-directory (promise\wrap (..working-directory environment)) - #let [[command output] (let [[compiler output] (case compiler - (#JVM artifact) [(///runtime.java (///local.path fs artifact)) - "program.jar"] - (#JS artifact) [(///runtime.node (///local.path fs artifact)) - "program.js"])] - [(format compiler " build") output]) - / (\ fs separator) - cache-directory (format working-directory / target)] - _ (console.write-line ..start console) - process (!.use (\ shell execute) - [environment - working-directory - command - (list.concat (list (..plural "--library" (..libraries fs resolution)) - (..plural "--source" (set.to-list (get@ #///.sources profile))) - (..singular "--target" cache-directory) - (..singular "--module" program)))]) - exit (!.use (\ process await) []) - _ (console.write-line (if (i.= shell.normal exit) - ..success - ..failure) - console)] - (wrap [compiler - (format cache-directory / output)])))) + [(#.Some program-module) (#.Some target)] + (do promise.monad + [environment (\ program environment []) + working-directory (\ program directory [])] + (do ///action.monad + [[resolution compiler] (promise\wrap (..compiler resolution)) + #let [[command output] (let [[compiler output] (case compiler + (#JVM artifact) [(///runtime.java (///local.path fs artifact)) + "program.jar"] + (#JS artifact) [(///runtime.node (///local.path fs artifact)) + "program.js"])] + [(format compiler " build") output]) + / (\ fs separator) + cache-directory (format working-directory / target)] + _ (console.write-line ..start console) + process (!.use (\ shell execute) + [environment + working-directory + command + (list.concat (list (..plural "--library" (..libraries fs resolution)) + (..plural "--source" (set.to-list (get@ #///.sources profile))) + (..singular "--target" cache-directory) + (..singular "--module" program-module)))]) + exit (!.use (\ process await) []) + _ (console.write-line (if (i.= shell.normal exit) + ..success + ..failure) + console)] + (wrap [compiler + (format cache-directory / output)]))))) diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux index 3b5afaabf..089417b94 100644 --- a/stdlib/source/program/aedifex/command/test.lux +++ b/stdlib/source/program/aedifex/command/test.lux @@ -6,15 +6,14 @@ [concurrency ["." promise (#+ Promise) ("#\." monad)]] [security - ["!" capability]] - [parser - [environment (#+ Environment)]]] + ["!" capability]]] [data [text ["%" format (#+ format)]] [number ["i" int]]] [world + [program (#+ Program)] ["." file] ["." shell (#+ Shell)] ["." console (#+ Console)]]] @@ -31,22 +30,24 @@ (def: #export success "[TEST ENDED]") (def: #export failure "[TEST FAILED]") -(def: #export (do! console environment fs shell resolution profile) - (-> (Console Promise) Environment (file.System Promise) (Shell Promise) Resolution (Command Any)) - (do ///action.monad - [[compiler program] (//build.do! console environment fs shell resolution profile) - working-directory (promise\wrap (//build.working-directory environment)) - _ (console.write-line ..start console) - process (!.use (\ shell execute) - [environment - working-directory - (case compiler - (#//build.JVM artifact) (///runtime.java program) - (#//build.JS artifact) (///runtime.node program)) - (list)]) - exit (!.use (\ process await) []) - _ (console.write-line (if (i.= shell.normal exit) - ..success - ..failure) - console)] - (wrap []))) +(def: #export (do! console program fs shell resolution profile) + (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command Any)) + (do promise.monad + [environment (\ program environment []) + working-directory (\ program directory [])] + (do ///action.monad + [[compiler program] (//build.do! console program fs shell resolution profile) + _ (console.write-line ..start console) + process (!.use (\ shell execute) + [environment + working-directory + (case compiler + (#//build.JVM artifact) (///runtime.java program) + (#//build.JS artifact) (///runtime.node program)) + (list)]) + exit (!.use (\ process await) []) + _ (console.write-line (if (i.= shell.normal exit) + ..success + ..failure) + console)] + (wrap [])))) 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)))) + (.object + ($_ <>.and + (.field "name" .string) + (.field "version" .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 .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) + (.object + (do <>.monad + [start (.field "start" ..amount) + end (.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)))) + (.object + ($_ <>.and + (.field "name" .string) + (.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)))) + (.object + ($_ <>.and + (.field "patent retaliation?" .boolean) + (.field "termination period" ..amount) + (.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)))) + (.object + ($_ <>.and + (.field "can accept?" .boolean) + (.field "disclaim high risk?" .boolean)))) (def: distribution (Parser Distribution) - (json.object - ($_ parser.and - (json.field "can re-license?" json.boolean) - (json.field "can multi-license?" json.boolean)))) + (.object + ($_ <>.and + (.field "can re-license?" .boolean) + (.field "can multi-license?" .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)))) + (.object + ($_ <>.and + (.field "can sell?" .boolean) + (.field "require contributor credit?" .boolean) + (.field "allow contributor endorsement?" .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)))) + (.object + ($_ <>.and + (.field "same license?" .boolean) + (.field "must be distinguishable?" .boolean) + (.field "notification period" (.nullable ..period)) + (.field "must describe modifications?" .boolean)))) (def: entity (Parser Entity) - json.string) + .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)))))) + (.object + ($_ <>.and + (.field "justification" (.nullable .string)) + (.field "entities" (.array (<>.many ..entity)))))) (def: url (Parser URL) - json.string) + .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))))) + (.object + ($_ <>.and + (.field "copyright-notice" .string) + (.field "phrase" (.nullable .string)) + (.field "url" ..url) + (.field "image" (.nullable ..url))))) + +(def: addendum + (Parser Addendum) + (.object + ($_ <>.and + (.field "commons clause?" .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))))) + (.object + ($_ <>.and + (.field "copyright-holders" (.array (<>.many ..copyright-holder))) + (.field "identification" (.nullable ..identification)) + (.field "termination" ..termination) + (.field "liability" ..liability) + (.field "distribution" ..distribution) + (.field "commercial" ..commercial) + (.field "extension" ..extension) + (.field "black-lists" (.array (<>.some ..black-list))) + (.field "attribution" (.nullable ..attribution)) + (<>.default {#//.commons-clause? false} + (.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 -- cgit v1.2.3