diff options
Diffstat (limited to 'stdlib/source/library')
-rw-r--r-- | stdlib/source/library/lux/control/parser/environment.lux | 44 | ||||
-rw-r--r-- | stdlib/source/library/lux/test.lux | 4 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/environment.lux (renamed from stdlib/source/library/lux/world/program.lux) | 29 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/net/http.lux | 9 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/shell.lux | 8 |
5 files changed, 25 insertions, 69 deletions
diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux deleted file mode 100644 index df9bf0fbc..000000000 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ /dev/null @@ -1,44 +0,0 @@ -(.require - [library - [lux (.except) - [control - ["[0]" try (.only Try)] - ["[0]" exception (.only exception)]] - [data - ["[0]" product] - ["[0]" text (.only) - ["%" \\format (.only format)]] - [collection - ["[0]" dictionary (.only Dictionary)]]]]] - ["[0]" //]) - -(type .public Property - Text) - -(type .public Environment - (Dictionary Property Text)) - -(exception .public (unknown_property [property Property]) - (exception.report - "Property" (%.text property))) - -(type .public (Parser a) - (//.Parser Environment a)) - -(def .public empty - Environment - (dictionary.empty text.hash)) - -(def .public (property name) - (-> Property (Parser Text)) - (function (_ environment) - (case (dictionary.value name environment) - {.#Some value} - {try.#Success [environment value]} - - {.#None} - (exception.except ..unknown_property [name])))) - -(def .public (result parser environment) - (All (_ a) (-> (Parser a) Environment (Try a))) - (at try.monad each product.right (parser environment))) diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index 110675c5d..5f086c633 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -39,7 +39,7 @@ ["[0]" meta (.only) ["[0]" symbol]] [world - ["[0]" program] + ["[0]" environment] ["[0]" console]]]]) (type .public Tally @@ -259,7 +259,7 @@ {.#Some console} (console.write_line report console)) <else>))] - (async.future (at program.default exit + (async.future (at environment.default exit (case (the #failures tally) 0 ..success_exit_code _ ..failure_exit_code))))) diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/environment.lux index 9923535c9..2955c5343 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/environment.lux @@ -12,9 +12,7 @@ ["[0]" exception (.only exception)] [concurrency ["[0]" atom] - ["[0]" async (.only Async)]] - [parser - ["[0]" environment (.only Environment)]]] + ["[0]" async (.only Async)]]] [data ["[0]" bit (.use "[1]#[0]" equivalence)] ["[0]" text (.only) @@ -32,6 +30,7 @@ [math [number ["i" int]]]]] + ["[0]" \\parser] [// [file (.only Path)] [shell (.only Exit)]]))) @@ -40,7 +39,7 @@ (exception.report "Name" (%.text name))) -(type .public (Program !) +(type .public (Environment !) (Interface (is (-> Any (! (List Text))) available_variables) @@ -53,12 +52,12 @@ (is (-> Exit (! Nothing)) exit))) -(def .public (environment monad program) - (All (_ !) (-> (Monad !) (Program !) (! Environment))) +(def .public (environment monad environment) + (All (_ !) (-> (Monad !) (Environment !) (! \\parser.Environment))) (do [! monad] - [variables (at program available_variables []) + [variables (at environment available_variables []) entries (monad.each ! (function (_ name) - (at ! each (|>> [name]) (at program variable name))) + (at ! each (|>> [name]) (at environment variable name))) variables)] (in (|> entries (list.all (function (_ [name value]) @@ -70,12 +69,12 @@ {.#None}))) (dictionary.of_list text.hash))))) -(`` (def .public (async program) - (-> (Program IO) (Program Async)) +(`` (def .public (async environment) + (-> (Environment IO) (Environment Async)) (implementation (~~ (with_template [<method>] [(def <method> - (at program <method>))] + (at environment <method>))] [home] [directory] @@ -83,7 +82,7 @@ (~~ (with_template [<method>] [(def <method> - (|>> (at program <method>) async.future))] + (|>> (at environment <method>) async.future))] [available_variables] [variable] @@ -91,7 +90,7 @@ ))))) (def .public (mock environment home directory) - (-> Environment Path Path (Program IO)) + (-> \\parser.Environment Path Path (Environment IO)) (let [@dead? (atom.atom false)] (implementation (def available_variables @@ -284,7 +283,7 @@ (these))) (def .public default - (Program IO) + (Environment IO) (implementation (def (available_variables _) (with_expansions [<jvm> (|> (java/lang/System::getenv) @@ -320,7 +319,7 @@ ... @.scheme (do io.monad ... [input (..get-environment-variables [])] ... (loop (again [input input - ... output environment.empty]) + ... output \\parser.empty]) ... (if ("scheme object nil?" input) ... (in output) ... (let [entry (..head input)] diff --git a/stdlib/source/library/lux/world/net/http.lux b/stdlib/source/library/lux/world/net/http.lux index d98151768..0582c9192 100644 --- a/stdlib/source/library/lux/world/net/http.lux +++ b/stdlib/source/library/lux/world/net/http.lux @@ -4,13 +4,14 @@ [control [try (.only Try)] [concurrency - [frp (.only Channel)]] - [parser - ["[0]" environment (.only Environment)]]] + [frp (.only Channel)]]] [data [binary (.only Binary)]]]] [// (.only URL) - [uri (.only URI)]]) + [uri (.only URI)] + [// + ["[0]" environment + ["[1]" \\parser (.only Environment)]]]]) (type .public Version Text) diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index 9c6b37c12..f9d7a6fd6 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -14,9 +14,7 @@ ["?" policy (.only Context Safety Safe)]] [concurrency ["[0]" atom (.only Atom)] - ["[0]" async (.only Async)]] - [parser - [environment (.only Environment)]]] + ["[0]" async (.only Async)]]] [data ["[0]" product] ["[0]" text (.only) @@ -31,7 +29,9 @@ [number (.only hex) ["n" nat]]]]] [// - [file (.only Path)]]) + [file (.only Path)] + [environment + [\\parser (.only Environment)]]]) (type .public Exit Int) |