From 77259cb45d346d66c6feb5b5a5070837780e7bb9 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 11 Feb 2019 21:09:29 -0400 Subject: Updated license for 2019. --- stdlib/source/lux/world/file.lux | 28 ++++++++++++------------- stdlib/source/program/licentia.lux | 42 ++++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 32 deletions(-) (limited to 'stdlib/source') diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux index b909578d8..0592d41af 100644 --- a/stdlib/source/lux/world/file.lux +++ b/stdlib/source/lux/world/file.lux @@ -144,20 +144,20 @@ (def: separator (:: system separator))))) -(def: #export (un-nest System file) +(def: #export (un-nest system file) (All [!] (-> (System !) Path (Maybe [Path Text]))) - (case (text.last-index-of (:: System separator) file) + (case (text.last-index-of (:: system separator) file) #.None #.None (#.Some last-separator) (let [[parent temp] (maybe.assume (text.split last-separator file)) - [_ child] (maybe.assume (text.split (text.size (:: System separator)) temp))] + [_ child] (maybe.assume (text.split (text.size (:: system separator)) temp))] (#.Some [parent child])))) -(def: #export (nest System [parent child]) +(def: #export (nest system [parent child]) (All [!] (-> (System !) [Path Text] Path)) - (format parent (:: System separator) child)) + (format parent (:: system separator) child)) (do-template [] [(exception: #export ( {file Path}) @@ -368,34 +368,34 @@ })) (do-template [ ] - [(def: #export ( Monad System path) + [(def: #export ( monad system path) (All [!] (-> (Monad !) (System !) Path (! (Error ( !))))) - (do Monad - [outcome (!.use (:: System ) path)] + (do monad + [outcome (!.use (:: system ) path)] (case outcome (#error.Success file) (wrap (#error.Success file)) (#error.Failure error) (if (ex.match? error) - (!.use (:: System ) path) + (!.use (:: system ) path) (wrap (#error.Failure error))))))] [get-file File create-file file ..cannot-create-file] [get-directory Directory create-directory directory ..cannot-create-directory] ) -(def: #export (exists? Monad System path) +(def: #export (exists? monad system path) (All [!] (-> (Monad !) (System !) Path (! Bit))) - (do Monad - [?file (!.use (:: System file) path)] + (do monad + [?file (!.use (:: system file) path)] (case ?file (#error.Success file) (wrap true) (#error.Failure _) - (do Monad - [?directory (!.use (:: System directory) path)] + (do monad + [?directory (!.use (:: system directory) path)] (case ?directory (#error.Success directory) (wrap true) diff --git a/stdlib/source/program/licentia.lux b/stdlib/source/program/licentia.lux index 479af7793..3300c380d 100644 --- a/stdlib/source/program/licentia.lux +++ b/stdlib/source/program/licentia.lux @@ -16,19 +16,21 @@ [control [remember (#+ to-do)] [monad (#+ do)] - ["." parser]] + ["." parser] + [security + ["!" capability]]] [data ["." maybe] - ["." error] + ["." error (#+ Error)] ["." text format ["." encoding]] [format ["." json]]] ["." cli (#+ program:)] - ["." io ("#/." monad)] + ["." io (#+ IO) ("#/." monad)] [world - ["." file (#+ File)]] + ["." file (#+ Path File)]] [host (#+ import:)]] [/ ["/." input] @@ -44,28 +46,32 @@ (def: default-output-file "LICENSE") (def: (success-message output) - (-> File Text) + (-> Path Text) (format "Your license has been made!" text.new-line "Check the file " output ".")) (program: [{input (cli.named "--input" cli.any)} {output (parser.default ..default-output-file (cli.named "--output" cli.any))}] - (do io.Monad - [?done (do io.Monad - [blob (:: file.JVM@System read input) - document (io/wrap (do error.Monad - [raw-json (encoding.from-utf8 blob) - json (|> raw-json - (:coerce java/lang/String) - java/lang/String::trim - (:: json.Codec decode)) - license (json.run json /input.license)] - (wrap (/output.license license))))] - (:: file.JVM@System write (encoding.to-utf8 document) output))] + (do io.monad + [?done (: (IO (Error Any)) + (do (error.with-error io.monad) + [file (!.use (:: file.system file) input) + blob (!.use (:: file content) []) + document (io/wrap (do error.monad + [raw-json (encoding.from-utf8 blob) + json (|> raw-json + (:coerce java/lang/String) + java/lang/String::trim + (:: json.codec decode)) + license (json.run json /input.license)] + (wrap (/output.license license)))) + output-file (: (IO (Error (File IO))) + (file.get-file io.monad file.system output))] + (!.use (:: output-file over-write) (encoding.to-utf8 document))))] (case ?done (#error.Success _) (wrap (log! (success-message output))) - (#error.Error message) + (#error.Failure message) (wrap (log! message))))) -- cgit v1.2.3