diff options
Diffstat (limited to 'stdlib/source/library/lux/world')
-rw-r--r-- | stdlib/source/library/lux/world/console.lux | 30 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/db/jdbc/input.lux | 4 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/db/jdbc/output.lux | 62 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/db/sql.lux | 8 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/file.lux | 220 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/file/watch.lux | 62 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/net/http.lux | 22 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/net/http/client.lux | 64 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/net/http/cookie.lux | 8 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/net/http/request.lux | 32 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/net/http/response.lux | 10 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/net/http/route.lux | 34 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/program.lux | 72 | ||||
-rw-r--r-- | stdlib/source/library/lux/world/shell.lux | 46 |
14 files changed, 337 insertions, 337 deletions
diff --git a/stdlib/source/library/lux/world/console.lux b/stdlib/source/library/lux/world/console.lux index 7c974630f..276fd51de 100644 --- a/stdlib/source/library/lux/world/console.lux +++ b/stdlib/source/library/lux/world/console.lux @@ -71,14 +71,14 @@ (do io.monad [?jvm_console (java/lang/System::console)] (case ?jvm_console - #.None + {.#None} (in (exception.except ..cannot_open [])) - {#.Some jvm_console} + {.#Some jvm_console} (let [jvm_input (java/lang/System::in) jvm_output (java/lang/System::out)] (<| in - #try.Success + {try.#Success} (: (Console IO)) ... TODO: Remove ASAP (implementation (def: (read _) @@ -122,13 +122,13 @@ (do [! io.monad] [|state| (atom.read! state)] (case (\ mock <mock> |state|) - {#try.Success [|state| output]} + {try.#Success [|state| output]} (do ! [_ (atom.write! |state| state)] - (in {#try.Success output})) + (in {try.#Success output})) - {#try.Failure error} - (in {#try.Failure error}))))] + {try.#Failure error} + (in {try.#Failure error}))))] [read on_read] [read_line on_read_line] @@ -138,23 +138,23 @@ (do [! io.monad] [|state| (atom.read! state)] (case (\ mock on_write input |state|) - {#try.Success |state|} + {try.#Success |state|} (do ! [_ (atom.write! |state| state)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error})))) + {try.#Failure error} + (in {try.#Failure error})))) (def: (close _) (do [! io.monad] [|state| (atom.read! state)] (case (\ mock on_close |state|) - {#try.Success |state|} + {try.#Success |state|} (do ! [_ (atom.write! |state| state)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error})))) + {try.#Failure error} + (in {try.#Failure error})))) )))) diff --git a/stdlib/source/library/lux/world/db/jdbc/input.lux b/stdlib/source/library/lux/world/db/jdbc/input.lux index aa8a168af..117edaab3 100644 --- a/stdlib/source/library/lux/world/db/jdbc/input.lux +++ b/stdlib/source/library/lux/world/db/jdbc/input.lux @@ -64,12 +64,12 @@ (def: .public (fail error) (All (_ a) (-> Text (Input a))) (function (_ value [idx context]) - {#try.Failure error})) + {try.#Failure error})) (def: .public empty (Input Any) (function (_ value context) - {#try.Success context})) + {try.#Success context})) (template [<function> <type> <setter>] [(def: .public <function> diff --git a/stdlib/source/library/lux/world/db/jdbc/output.lux b/stdlib/source/library/lux/world/db/jdbc/output.lux index 3772ff0e1..0ec397faf 100644 --- a/stdlib/source/library/lux/world/db/jdbc/output.lux +++ b/stdlib/source/library/lux/world/db/jdbc/output.lux @@ -56,11 +56,11 @@ (def: (each f fa) (function (_ idx+rs) (case (fa idx+rs) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [idx' value]} - {#try.Success [idx' (f value)]})))) + {try.#Success [idx' value]} + {try.#Success [idx' (f value)]})))) (implementation: .public apply (Apply Output) @@ -70,16 +70,16 @@ (def: (apply ff fa) (function (_ [idx rs]) (case (ff [idx rs]) - {#try.Success [idx' f]} + {try.#Success [idx' f]} (case (fa [idx' rs]) - {#try.Success [idx'' a]} - {#try.Success [idx'' (f a)]} + {try.#Success [idx'' a]} + {try.#Success [idx'' (f a)]} - {#try.Failure msg} - {#try.Failure msg}) + {try.#Failure msg} + {try.#Failure msg}) - {#try.Failure msg} - {#try.Failure msg})))) + {try.#Failure msg} + {try.#Failure msg})))) (implementation: .public monad (Monad Output) @@ -88,21 +88,21 @@ (def: (in a) (function (_ [idx rs]) - {#.Some [idx a]})) + {.#Some [idx a]})) (def: (conjoint mma) (function (_ [idx rs]) (case (mma [idx rs]) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [idx' ma]} + {try.#Success [idx' ma]} (ma [idx' rs]))))) (def: .public (fail error) (All (_ a) (-> Text (Output a))) (function (_ [idx result_set]) - {#try.Failure error})) + {try.#Failure error})) (def: .public (and left right) (All (_ a b) @@ -117,11 +117,11 @@ (Output <type>) (function (_ [idx result_set]) (case (<method_name> [(.int idx)] result_set) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success value} - {#try.Success [(++ idx) value]})))] + {try.#Success value} + {try.#Success [(++ idx) value]})))] [boolean java/sql/ResultSet::getBoolean Bit] @@ -142,11 +142,11 @@ (Output Instant) (function (_ [idx result_set]) (case (<method_name> [(.int idx)] result_set) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success value} - {#try.Success [(++ idx) + {try.#Success value} + {try.#Success [(++ idx) (instant.from_millis (java/util/Date::getTime value))]})))] [date java/sql/ResultSet::getDate] @@ -157,24 +157,24 @@ (def: .public (rows output results) (All (_ a) (-> (Output a) java/sql/ResultSet (IO (Try (List a))))) (case (java/sql/ResultSet::next results) - {#try.Success has_next?} + {try.#Success has_next?} (if has_next? (case (output [1 results]) - {#.Some [_ head]} + {.#Some [_ head]} (do io.monad [?tail (rows output results)] (case ?tail - {#try.Success tail} - (in {#try.Success {#.Item head tail}}) + {try.#Success tail} + (in {try.#Success {.#Item head tail}}) - {#try.Failure error} + {try.#Failure error} (do io.monad [temp (java/sql/ResultSet::close results)] (in (do try.monad [_ temp] (try.failure error)))))) - {#try.Failure error} + {try.#Failure error} (do io.monad [temp (java/sql/ResultSet::close results)] (in (do try.monad @@ -186,7 +186,7 @@ [_ temp] (in (list)))))) - {#try.Failure error} + {try.#Failure error} (do io.monad [temp (java/sql/ResultSet::close results)] (in (do try.monad diff --git a/stdlib/source/library/lux/world/db/sql.lux b/stdlib/source/library/lux/world/db/sql.lux index 60abb4484..dd0a2dd7e 100644 --- a/stdlib/source/library/lux/world/db/sql.lux +++ b/stdlib/source/library/lux/world/db/sql.lux @@ -214,7 +214,7 @@ (format <op> " " (case columns - #.End + {.#End} "*" _ @@ -292,7 +292,7 @@ (Query where having No_Order group limit offset) (Query where having With_Order group limit offset))) (case pairs - #.End + {.#End} (|> query :representation :abstraction) _ @@ -310,7 +310,7 @@ (Query where having order No_Group limit offset) (Query where having order With_Group limit offset))) (case pairs - #.End + {.#End} (|> query :representation :abstraction) _ @@ -335,7 +335,7 @@ (-> Table (List [Column Value]) (Command No_Where No_Having)) (:abstraction (format "UPDATE " (:representation table) (case pairs - #.End + {.#End} "" _ diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 82796463c..5a8c23c48 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -81,10 +81,10 @@ (All (_ !) (-> (System !) Path (Maybe [Path Text]))) (let [/ (\ fs separator)] (case (text.last_index / path) - #.None - #.None + {.#None} + {.#None} - {#.Some last_separator} + {.#Some last_separator} (do maybe.monad [[parent temp] (text.split_at last_separator path) [_ child] (text.split_at (text.size /) temp)] @@ -230,14 +230,14 @@ (do [! (try.with io.monad)] [?children (java/io/File::listFiles (java/io/File::new path))] (case ?children - {#.Some children} + {.#Some children} (|> children - (array.list #.None) + (array.list {.#None}) (monad.only ! (|>> <method>)) (\ ! each (monad.each ! (|>> java/io/File::getAbsolutePath))) (\ ! conjoint)) - #.None + {.#None} (\ io.monad in (exception.except ..cannot_find_directory [path])))))] [directory_files java/io/File::isFile] @@ -354,8 +354,8 @@ io.run! write! (if (ffi.null? error) - {#try.Success []} - {#try.Failure (Error::toString [] (:as Error error))}))) + {try.#Success []} + {try.#Failure (Error::toString [] (:as Error error))}))) (def: (value_callback write!) (All (_ a) (-> (async.Resolver (Try a)) ffi.Function)) @@ -363,8 +363,8 @@ io.run! write! (if (ffi.null? error) - {#try.Success (:expected datum)} - {#try.Failure (Error::toString [] (:as Error error))}))) + {try.#Success (:expected datum)} + {try.#Failure (Error::toString [] (:as Error error))}))) (ffi.import: JsPath ["[1]::[0]" @@ -383,9 +383,9 @@ (def: (require _) (-> [] (-> ffi.String Any)) (case [(normal_require []) (global_require []) (process_load [])] - (^or [{#.Some require} _ _] - [_ {#.Some require} _] - [_ _ {#.Some require}]) + (^or [{.#Some require} _ _] + [_ {.#Some require} _] + [_ _ {.#Some require}]) require _ @@ -418,10 +418,10 @@ (Fs::stat [path (..value_callback write!)] (..node_fs [])))] (in (case ?stats - {#try.Success stats} + {try.#Success stats} (<method> [] stats) - {#try.Failure _} + {try.#Failure _} false))))] [file? Stats::isFile] @@ -437,10 +437,10 @@ (..any_callback write!)] node_fs))] (case outcome - {#try.Success _} + {try.#Success _} (in (exception.except ..cannot_make_directory [path])) - {#try.Failure _} + {try.#Failure _} (with_async write! (Try Any) (Fs::mkdir [path (..any_callback write!)] node_fs))))) @@ -451,7 +451,7 @@ subs (with_async write! (Try (Array ffi.String)) (Fs::readdir [path (..value_callback write!)] node_fs))] (|> subs - (array.list #.None) + (array.list {.#None}) (list\each (|>> (format path ..js_separator))) (monad.each ! (function (_ sub) (\ ! each (|>> (<method> []) [sub]) @@ -487,12 +487,12 @@ (def: (can_execute? path) (let [node_fs (..node_fs [])] (\ async.monad each - (|>> (case> {#try.Success _} + (|>> (case> {try.#Success _} true - {#try.Failure _} + {try.#Failure _} false) - #try.Success) + {try.#Success}) (with_async write! (Try Any) (Fs::access [path (|> node_fs Fs::constants FsConstants::X_OK) @@ -598,7 +598,7 @@ (let [! (try.with io.monad)] (|> path os::listdir - (\ ! each (|>> (array.list #.None) + (\ ! each (|>> (array.list {.#None}) (list\each (|>> (format path ..python_separator))) (monad.each ! (function (_ sub) (\ ! each (|>> [sub]) (<method> [sub])))) @@ -725,19 +725,19 @@ [self (RubyDir::open [path]) children (RubyDir::children [] self) output (loop [input (|> children - (array.list #.None) + (array.list {.#None}) (list\each (|>> (format path ..ruby_separator)))) output (: (List ..Path) (list))] (case input - #.End + {.#End} (in output) - {#.Item head tail} + {.#Item head tail} (do ! [verdict (<test> head)] (recur tail (if verdict - {#.Item head output} + {.#Item head output} output))))) _ (RubyDir::close [] self)] (in output)))] @@ -918,21 +918,21 @@ ... (do [! (try.with io.monad)] ... [children (..scandir [path])] ... (loop [input (|> children - ... (array.list #.None) + ... (array.list {.#None}) ... (list.only (function (_ child) ... (not (or (text\= "." child) ... (text\= ".." child)))))) ... output (: (List (<capability> IO)) ... (list))] ... (case input - ... #.End + ... {.#End} ... (in output) - ... {#.Item head tail} + ... {.#Item head tail} ... (do ! ... [verdict (<test> head)] ... (if verdict - ... (recur tail {#.Item (<constructor> head) output}) + ... (recur tail {.#Item (<constructor> head) output}) ... (recur tail output)))))))] ... [files ..is_file ..file File] @@ -956,7 +956,7 @@ ... [verdict (<test> path)] ... (\ io.monad in ... (if verdict - ... {#try.Success (<constructor> path)} + ... {try.#Success (<constructor> path)} ... (exception.except <exception> [path])))))] ... [file ..is_file ..file ..cannot_find_file] @@ -968,7 +968,7 @@ ... [verdict (..touch [path (|> instant.now io.run! instant.relative duration.millis (i./ +1,000))])] ... (\ io.monad in ... (if verdict - ... {#try.Success (..file path)} + ... {try.#Success (..file path)} ... (exception.except ..cannot_make_file [path]))))) ... (def: (make_directory path) @@ -976,7 +976,7 @@ ... [verdict (..mkdir path)] ... (\ io.monad in ... (if verdict - ... {#try.Success (..directory path)} + ... {try.#Success (..directory path)} ... (exception.except ..cannot_make_directory [path]))))) ... (def: separator @@ -1013,23 +1013,23 @@ (loop [directory mock trail (text.all_split_by separator path)] (case trail - {#.Item head tail} + {.#Item head tail} (case (dictionary.value head directory) - #.None + {.#None} (exception.except ..cannot_find_file [path]) - {#.Some node} + {.#Some node} (case [node tail] - [{#.Left file} #.End] - {#try.Success [head file]} + [{.#Left file} {.#End}] + {try.#Success [head file]} - [{#.Right sub_directory} {#.Item _}] + [{.#Right sub_directory} {.#Item _}] (recur sub_directory tail) _ (exception.except ..cannot_find_file [path]))) - #.End + {.#End} (exception.except ..cannot_find_file [path])))) (def: (update_mock_file! / path now content mock) @@ -1037,38 +1037,38 @@ (loop [directory mock trail (text.all_split_by / path)] (case trail - {#.Item head tail} + {.#Item head tail} (case (dictionary.value head directory) - #.None + {.#None} (case tail - #.End - {#try.Success (dictionary.has head - {#.Left [#mock_last_modified now + {.#End} + {try.#Success (dictionary.has head + {.#Left [#mock_last_modified now #mock_can_execute false #mock_content content]} directory)} - {#.Item _} + {.#Item _} (exception.except ..cannot_find_file [path])) - {#.Some node} + {.#Some node} (case [node tail] - [{#.Left file} #.End] - {#try.Success (dictionary.has head - {#.Left (|> file + [{.#Left file} {.#End}] + {try.#Success (dictionary.has head + {.#Left (|> file (with@ #mock_last_modified now) (with@ #mock_content content))} directory)} - [{#.Right sub_directory} {#.Item _}] + [{.#Right sub_directory} {.#Item _}] (do try.monad [sub_directory (recur sub_directory tail)] - (in (dictionary.has head {#.Right sub_directory} directory))) + (in (dictionary.has head {.#Right sub_directory} directory))) _ (exception.except ..cannot_find_file [path]))) - #.End + {.#End} (exception.except ..cannot_find_file [path])))) (def: (delete_mock_node! / path mock) @@ -1076,34 +1076,34 @@ (loop [directory mock trail (text.all_split_by / path)] (case trail - {#.Item head tail} + {.#Item head tail} (case (dictionary.value head directory) - #.None + {.#None} (exception.except ..cannot_delete [path]) - {#.Some node} + {.#Some node} (case tail - #.End + {.#End} (case node - {#.Left file} - {#try.Success (dictionary.lacks head directory)} + {.#Left file} + {try.#Success (dictionary.lacks head directory)} - {#.Right sub_directory} + {.#Right sub_directory} (if (dictionary.empty? sub_directory) - {#try.Success (dictionary.lacks head directory)} + {try.#Success (dictionary.lacks head directory)} (exception.except ..cannot_delete [path]))) - {#.Item _} + {.#Item _} (case node - {#.Left file} + {.#Left file} (exception.except ..cannot_delete [path]) - {#.Right sub_directory} + {.#Right sub_directory} (do try.monad [sub_directory' (recur sub_directory tail)] - (in (dictionary.has head {#.Right sub_directory'} directory)))))) + (in (dictionary.has head {.#Right sub_directory'} directory)))))) - #.End + {.#End} (exception.except ..cannot_delete [path])))) (def: (attempt! transform var) @@ -1111,40 +1111,40 @@ (do [! stm.monad] [|var| (stm.read var)] (case (transform |var|) - {#try.Success |var|} + {try.#Success |var|} (do ! [_ (stm.write |var| var)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error})))) + {try.#Failure error} + (in {try.#Failure error})))) (def: (make_mock_directory! / path mock) (-> Text Path Mock (Try Mock)) (loop [directory mock trail (text.all_split_by / path)] (case trail - {#.Item head tail} + {.#Item head tail} (case (dictionary.value head directory) - #.None + {.#None} (case tail - #.End - {#try.Success (dictionary.has head {#.Right ..empty_mock} directory)} + {.#End} + {try.#Success (dictionary.has head {.#Right ..empty_mock} directory)} - {#.Item _} + {.#Item _} (exception.except ..cannot_make_directory [path])) - {#.Some node} + {.#Some node} (case [node tail] - [{#.Right sub_directory} {#.Item _}] + [{.#Right sub_directory} {.#Item _}] (do try.monad [sub_directory (recur sub_directory tail)] - (in (dictionary.has head {#.Right sub_directory} directory))) + (in (dictionary.has head {.#Right sub_directory} directory))) _ (exception.except ..cannot_make_directory [path]))) - #.End + {.#End} (exception.except ..cannot_make_directory [path])))) (def: (retrieve_mock_directory! / path mock) @@ -1152,25 +1152,25 @@ (loop [directory mock trail (text.all_split_by / path)] (case trail - #.End - {#try.Success directory} + {.#End} + {try.#Success directory} - {#.Item head tail} + {.#Item head tail} (case (dictionary.value head directory) - #.None + {.#None} (exception.except ..cannot_find_directory [path]) - {#.Some node} + {.#Some node} (case node - {#.Left _} + {.#Left _} (exception.except ..cannot_find_directory [path]) - {#.Right sub_directory} + {.#Right sub_directory} (case tail - #.End - {#try.Success sub_directory} + {.#End} + {try.#Success sub_directory} - {#.Item _} + {.#Item _} (recur sub_directory tail))))))) (def: .public (mock separator) @@ -1198,13 +1198,13 @@ (do [! stm.monad] [|store| (stm.read store)] (case (..make_mock_directory! separator path |store|) - {#try.Success |store|} + {try.#Success |store|} (do ! [_ (stm.write |store| store)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error}))))) + {try.#Failure error} + (in {try.#Failure error}))))) (~~ (template [<method> <tag>] [(def: (<method> path) @@ -1218,13 +1218,13 @@ (list.all (function (_ [node_name node]) (case node {<tag> _} - {#.Some (format path separator node_name)} + {.#Some (format path separator node_name)} _ - #.None))))))))))] + {.#None}))))))))))] - [directory_files #.Left] - [sub_directories #.Right] + [directory_files .#Left] + [sub_directories .#Right] )) (def: (file_size path) @@ -1304,13 +1304,13 @@ [[name file] (..retrieve_mock_file! separator origin |store|) |store| (..delete_mock_node! separator origin |store|)] (..update_mock_file! separator destination (value@ #mock_last_modified file) (value@ #mock_content file) |store|)) - {#try.Success |store|} + {try.#Success |store|} (do ! [_ (stm.write |store| store)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error}))))) + {try.#Failure error} + (in {try.#Failure error}))))) )))) (def: (check_or_make_directory monad fs path) @@ -1318,7 +1318,7 @@ (do monad [? (\ fs directory? path)] (if ? - (in {#try.Success []}) + (in {try.#Success []}) (\ fs make_directory path)))) (def: .public (make_directories monad fs path) @@ -1328,10 +1328,10 @@ (case (if rooted? (list.after 1 segments) segments) - #.End + {.#End} (\ monad in (exception.except ..cannot_make_directory [path])) - {#.Item head tail} + {.#Item head tail} (case head "" (\ monad in (exception.except ..cannot_make_directory [path])) _ (loop [current (if rooted? @@ -1341,17 +1341,17 @@ (do monad [? (..check_or_make_directory monad fs current)] (case ? - {#try.Success _} + {try.#Success _} (case next - #.End - (in {#try.Success []}) + {.#End} + (in {try.#Success []}) - {#.Item head tail} + {.#Item head tail} (recur (format current (\ fs separator) head) tail)) - {#try.Failure error} - (in {#try.Failure error})))))))) + {try.#Failure error} + (in {try.#Failure error})))))))) (def: .public (make_file monad fs content path) (All (_ !) (-> (Monad !) (System !) Binary Path (! (Try Any)))) diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index 51ac92a90..86620bd7b 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -112,12 +112,12 @@ (do [! stm.monad] [@tracker (stm.read tracker)] (case (dictionary.value path @tracker) - {#.Some [old_concern last_modified]} + {.#Some [old_concern last_modified]} (do ! [_ (stm.update (dictionary.has path [new_concern last_modified]) tracker)] (in true)) - #.None + {.#None} (in false)))) (def: (file_tracker fs directory) @@ -143,7 +143,7 @@ (\ ! each (|>> [file])))) files))) -(def: (available_directory_changes fs [directory [concern file_tracker]]) +(def: (available_directory_changes fs [directory [the_concern file_tracker]]) (-> (//.System Async) [//.Path [Concern File_Tracker]] (Async (Try [[//.Path [Concern File_Tracker]] [(List [//.Path Instant]) @@ -151,14 +151,14 @@ (List //.Path)]]))) (do [! (try.with async.monad)] [current_files (..available_files fs directory) - .let [creations (if (..creation? concern) + .let [creations (if (..creation? the_concern) (list.only (|>> product.left (dictionary.key? file_tracker) not) current_files) (list)) available (|> current_files (list\each product.left) (set.of_list text.hash)) - deletions (if (..deletion? concern) + deletions (if (..deletion? the_concern) (|> (dictionary.entries file_tracker) (list\each product.left) (list.only (|>> (set.member? available) not))) @@ -169,7 +169,7 @@ (in [path previous_modification current_modification]))) current_files)]] (in [[directory - [concern + [the_concern (let [with_deletions (list\mix dictionary.lacks file_tracker deletions) with_creations (list\mix (function (_ [path last_modified] tracker) (dictionary.has path last_modified tracker)) @@ -196,34 +196,34 @@ (do ! [updated? (stm.commit! (..update_watch! new_concern path tracker))] (if updated? - (in {#try.Success []}) + (in {try.#Success []}) (do (try.with !) [file_tracker (..file_tracker fs path)] (do ! [_ (stm.commit! (stm.update (dictionary.has path [new_concern file_tracker]) tracker))] - (in {#try.Success []}))))) + (in {try.#Success []}))))) (in (exception.except ..cannot_poll_a_non_existent_directory [path]))))) (def: (concern path) (stm.commit! (do stm.monad [@tracker (stm.read tracker)] (in (case (dictionary.value path @tracker) - {#.Some [concern file_tracker]} - {#try.Success concern} + {.#Some [it file_tracker]} + {try.#Success it} - #.None + {.#None} (exception.except ..not_being_watched [path])))))) (def: (stop path) (stm.commit! (do [! stm.monad] [@tracker (stm.read tracker)] (case (dictionary.value path @tracker) - {#.Some [concern file_tracker]} + {.#Some [the_concern file_tracker]} (do ! [_ (stm.update (dictionary.lacks path) tracker)] - (in {#try.Success concern})) + (in {try.#Success the_concern})) - #.None + {.#None} (in (exception.except ..not_being_watched [path])))))) (def: (poll _) (do async.monad @@ -237,7 +237,7 @@ (list\each product.left) (dictionary.of_list text.hash)) tracker))] - (in {#try.Success []})) + (in {try.#Success []})) .let [[creations modifications deletions] (list\mix (function (_ [_ [creations modifications deletions]] [all_creations all_modifications all_deletions]) @@ -275,10 +275,10 @@ (All (_ a) (-> (java/util/List a) (List a))) (let [size (.nat (java/util/List::size list))] (loop [idx 0 - output #.End] + output {.#End}] (if (n.< size idx) (recur (++ idx) - {#.Item (java/util/List::get (.int idx) list) + {.#Item (java/util/List::get (.int idx) list) output}) output)))) @@ -375,7 +375,7 @@ (do (try.with io.monad) [?key (java/nio/file/WatchService::poll watcher)] (case ?key - {#.Some key} + {.#Some key} (do [! io.monad] [valid? (java/nio/file/WatchKey::reset key)] (if valid? @@ -385,12 +385,12 @@ (:as java/nio/file/Path) java/nio/file/Path::toString (:as //.Path))] - concern (..default_key_concern key)] - (recur {#.Item [concern path] + the_concern (..default_key_concern key)] + (recur {.#Item [the_concern path] output})) (recur output))) - #.None + {.#None} (in output))))) (def: (watch_events concern) @@ -420,36 +420,36 @@ (do [! async.monad] [@tracker (stm.commit! (stm.read tracker))] (case (dictionary.value path @tracker) - {#.Some [concern key]} + {.#Some [the_concern key]} (do ! [_ (async.future (java/nio/file/WatchKey::cancel key)) _ (stm.commit! (stm.update (dictionary.lacks path) tracker))] - (in {#try.Success concern})) + (in {try.#Success the_concern})) - #.None + {.#None} (in (exception.except ..not_being_watched [path]))))))]] (in (: (Watcher Async) (implementation - (def: (start concern path) + (def: (start the_concern path) (do async.monad [?concern (stop path)] (do (try.with async.monad) [key (..default_start (..watch_events (..also (try.else ..none ?concern) - concern)) + the_concern)) watcher path)] (do async.monad - [_ (stm.commit! (stm.update (dictionary.has path [concern key]) tracker))] - (in {#try.Success []}))))) + [_ (stm.commit! (stm.update (dictionary.has path [the_concern key]) tracker))] + (in {try.#Success []}))))) (def: (concern path) (do async.monad [@tracker (stm.commit! (stm.read tracker))] (case (dictionary.value path @tracker) - {#.Some [concern key]} - (in {#try.Success concern}) + {.#Some [it key]} + (in {try.#Success it}) - #.None + {.#None} (in (exception.except ..not_being_watched [path]))))) (def: stop stop) (def: (poll _) diff --git a/stdlib/source/library/lux/world/net/http.lux b/stdlib/source/library/lux/world/net/http.lux index 8afbd105b..8e61f33a0 100644 --- a/stdlib/source/library/lux/world/net/http.lux +++ b/stdlib/source/library/lux/world/net/http.lux @@ -17,15 +17,15 @@ (type: .public Method (Variant - #Post - #Get - #Put - #Patch - #Delete - #Head - #Connect - #Options - #Trace)) + {#Post} + {#Get} + {#Put} + {#Patch} + {#Delete} + {#Head} + {#Connect} + {#Options} + {#Trace})) (type: .public Port Nat) @@ -48,8 +48,8 @@ (type: .public Scheme (Variant - #HTTP - #HTTPS)) + {#HTTP} + {#HTTPS})) (type: .public Address (Record diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux index 472c49a52..7fed7739e 100644 --- a/stdlib/source/library/lux/world/net/http/client.lux +++ b/stdlib/source/library/lux/world/net/http/client.lux @@ -36,8 +36,8 @@ (! (Try (//.Response !)))) request))) -(syntax: (method_function [[_ name] <code>.tag]) - (in (list (code.local_identifier (text.lower_cased name))))) +(syntax: (method_function [[_ name] <code>.identifier]) + (in (list (code.local_identifier (text.replaced "#" "" (text.lower_cased name)))))) (template [<method>] [(with_expansions [<name> (method_function <method>)] @@ -45,17 +45,17 @@ (All (_ !) (-> URL //.Headers (Maybe Binary) (Client !) (! (Try (//.Response !))))) - (\ client request <method> url headers data)))] - - [#//.Post] - [#//.Get] - [#//.Put] - [#//.Patch] - [#//.Delete] - [#//.Head] - [#//.Connect] - [#//.Options] - [#//.Trace] + (\ client request {<method>} url headers data)))] + + [//.#Post] + [//.#Get] + [//.#Put] + [//.#Patch] + [//.#Delete] + [//.#Head] + [//.#Connect] + [//.#Options] + [//.#Trace] ) (def: default_buffer_size @@ -108,15 +108,15 @@ (def: jvm_method (-> //.Method Text) - (|>> (case> #//.Post "POST" - #//.Get "GET" - #//.Put "PUT" - #//.Patch "PATCH" - #//.Delete "DELETE" - #//.Head "HEAD" - #//.Connect "CONNECT" - #//.Options "OPTIONS" - #//.Trace "TRACE"))) + (|>> (case> {//.#Post} "POST" + {//.#Get} "GET" + {//.#Put} "PUT" + {//.#Patch} "PATCH" + {//.#Delete} "DELETE" + {//.#Head} "HEAD" + {//.#Connect} "CONNECT" + {//.#Options} "OPTIONS" + {//.#Trace} "TRACE"))) (def: (default_body input) (-> java/io/BufferedInputStream (//.Body IO)) @@ -172,13 +172,13 @@ (do [! (try.with io.monad)] [?name (java/net/URLConnection::getHeaderFieldKey index connection)] (case ?name - {#.Some name} + {.#Some name} (do ! [?value (java/net/URLConnection::getHeaderField index connection)] (recur (++ index) (dictionary.has name (maybe.else "" ?value) headers))) - #.None + {.#None} (in headers))))) (implementation: .public default @@ -194,7 +194,7 @@ (java/net/URLConnection::setRequestProperty name value connection)) (dictionary.entries headers)) _ (case data - {#.Some data} + {.#Some data} (do ! [_ (java/net/URLConnection::setDoOutput true connection) stream (java/net/URLConnection::getOutputStream connection) @@ -203,7 +203,7 @@ _ (java/lang/AutoCloseable::close stream)] (in [])) - #.None + {.#None} (in [])) status (java/net/HttpURLConnection::getResponseCode connection) headers (..default_headers connection) @@ -211,8 +211,8 @@ java/net/URLConnection::getInputStream (\ ! each (|>> java/io/BufferedInputStream::new)))] (in [(.nat status) - [#//.headers headers - #//.body (..default_body input)]]))))))] + [//.#headers headers + //.#body (..default_body input)]]))))))] (for [@.old (as_is <jvm>) @.jvm (as_is <jvm>)] (as_is))) @@ -224,14 +224,14 @@ (|> (\ client request method url headers data) async.future (\ async.monad each - (|>> (case> {#try.Success [status message]} - {#try.Success [status (revised@ #//.body (: (-> (//.Body IO) (//.Body Async)) + (|>> (case> {try.#Success [status message]} + {try.#Success [status (revised@ //.#body (: (-> (//.Body IO) (//.Body Async)) (function (_ body) (|>> body async.future))) message)]} - {#try.Failure error} - {#try.Failure error})))))) + {try.#Failure error} + {try.#Failure error})))))) (def: .public headers (-> (List [Text Text]) //.Headers) diff --git a/stdlib/source/library/lux/world/net/http/cookie.lux b/stdlib/source/library/lux/world/net/http/cookie.lux index b1a829f9a..a7e2d1644 100644 --- a/stdlib/source/library/lux/world/net/http/cookie.lux +++ b/stdlib/source/library/lux/world/net/http/cookie.lux @@ -59,14 +59,14 @@ (type: .public CSRF_Policy (Variant - #Strict - #Lax)) + {#Strict} + {#Lax})) (def: .public (same_site policy) (-> CSRF_Policy Directive) (..directive (format "SameSite=" (case policy - #Strict "Strict" - #Lax "Lax")))) + {#Strict} "Strict" + {#Lax} "Lax")))) (def: (cookie context) (-> Context (Parser Context)) diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index c6185bc09..12287083d 100644 --- a/stdlib/source/library/lux/world/net/http/request.lux +++ b/stdlib/source/library/lux/world/net/http/request.lux @@ -56,73 +56,73 @@ (All (_ a) (-> (<json>.Reader a) (-> a Server) Server)) (function (_ (^@ request [identification protocol resource message])) (do async.monad - [?raw (read_text_body (value@ #//.body message))] + [?raw (read_text_body (value@ //.#body message))] (case (do try.monad [raw ?raw content (\ json.codec decoded raw)] (json.result content reader)) - {#try.Success input} + {try.#Success input} (server input request) - {#try.Failure error} + {try.#Failure error} (async.resolved ..failure))))) (def: .public (text server) (-> (-> Text Server) Server) (function (_ (^@ request [identification protocol resource message])) (do async.monad - [?raw (read_text_body (value@ #//.body message))] + [?raw (read_text_body (value@ //.#body message))] (case ?raw - {#try.Success content} + {try.#Success content} (server content request) - {#try.Failure error} + {try.#Failure error} (async.resolved ..failure))))) (def: .public (query property server) (All (_ a) (-> (Property a) (-> a Server) Server)) (function (_ [identification protocol resource message]) - (let [full (value@ #//.uri resource) + (let [full (value@ //.#uri resource) [uri query] (|> full (text.split_by "?") (maybe.else [full ""]))] (case (do try.monad [query (//query.parameters query) input (context.result query property)] - (in [[identification protocol (with@ #//.uri uri resource) message] + (in [[identification protocol (with@ //.#uri uri resource) message] input])) - {#try.Success [request input]} + {try.#Success [request input]} (server input request) - {#try.Failure error} + {try.#Failure error} (async.resolved ..failure))))) (def: .public (form property server) (All (_ a) (-> (Property a) (-> a Server) Server)) (function (_ (^@ request [identification protocol resource message])) (do async.monad - [?body (read_text_body (value@ #//.body message))] + [?body (read_text_body (value@ //.#body message))] (case (do try.monad [body ?body form (//query.parameters body)] (context.result form property)) - {#try.Success input} + {try.#Success input} (server input request) - {#try.Failure error} + {try.#Failure error} (async.resolved ..failure))))) (def: .public (cookies property server) (All (_ a) (-> (Property a) (-> a Server) Server)) (function (_ (^@ request [identification protocol resource message])) (case (do try.monad - [cookies (|> (value@ #//.headers message) + [cookies (|> (value@ //.#headers message) (dictionary.value "Cookie") (maybe.else "") //cookie.get)] (context.result cookies property)) - {#try.Success input} + {try.#Success input} (server input request) - {#try.Failure error} + {try.#Failure error} (async.resolved ..failure)))) diff --git a/stdlib/source/library/lux/world/net/http/response.lux b/stdlib/source/library/lux/world/net/http/response.lux index 0a03f9f31..272e906b5 100644 --- a/stdlib/source/library/lux/world/net/http/response.lux +++ b/stdlib/source/library/lux/world/net/http/response.lux @@ -32,15 +32,15 @@ (let [body (frp\in (\ encoding.utf8 encoded ""))] (function (_ status) [status - [#//.headers (|> context.empty + [//.#headers (|> context.empty (header.content_length 0) (header.content_type mime.utf_8)) - #//.body body]]))) + //.#body body]]))) (def: .public (temporary_redirect to) (-> URL Response) (let [[status message] (..empty status.temporary_redirect)] - [status (revised@ #//.headers (header.location to) message)])) + [status (revised@ //.#headers (header.location to) message)])) (def: .public not_found Response @@ -49,10 +49,10 @@ (def: .public (content status type data) (-> Status MIME Binary Response) [status - [#//.headers (|> context.empty + [//.#headers (|> context.empty (header.content_length (binary.size data)) (header.content_type type)) - #//.body (frp\in data)]]) + //.#body (frp\in data)]]) (def: .public bad_request (-> Text Response) diff --git a/stdlib/source/library/lux/world/net/http/route.lux b/stdlib/source/library/lux/world/net/http/route.lux index 4232f4481..92b522254 100644 --- a/stdlib/source/library/lux/world/net/http/route.lux +++ b/stdlib/source/library/lux/world/net/http/route.lux @@ -18,46 +18,46 @@ [(def: .public (<name> server) (-> Server Server) (function (_ (^@ request [identification protocol resource message])) - (case (value@ #//.scheme protocol) - <scheme> + (case (value@ //.#scheme protocol) + {<scheme>} (server request) _ (async.resolved //response.not_found))))] - [#//.HTTP http] - [#//.HTTPS https] + [//.#HTTP http] + [//.#HTTPS https] ) (template [<method> <name>] [(def: .public (<name> server) (-> Server Server) (function (_ (^@ request [identification protocol resource message])) - (case (value@ #//.method resource) - <method> + (case (value@ //.#method resource) + {<method>} (server request) _ (async.resolved //response.not_found))))] - [#//.Get get] - [#//.Post post] - [#//.Put put] - [#//.Patch patch] - [#//.Delete delete] - [#//.Head head] - [#//.Connect connect] - [#//.Options options] - [#//.Trace trace] + [//.#Get get] + [//.#Post post] + [//.#Put put] + [//.#Patch patch] + [//.#Delete delete] + [//.#Head head] + [//.#Connect connect] + [//.#Options options] + [//.#Trace trace] ) (def: .public (uri path server) (-> URI Server Server) (function (_ [identification protocol resource message]) - (if (text.starts_with? path (value@ #//.uri resource)) + (if (text.starts_with? path (value@ //.#uri resource)) (server [identification protocol - (revised@ #//.uri + (revised@ //.#uri (|>> (text.clip_since (text.size path)) maybe.trusted) resource) message]) diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index 5d5604777..3a4b1417a 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -62,11 +62,11 @@ (in (|> entries (list.all (function (_ [name value]) (case value - {#try.Success value} - {#.Some [name value]} + {try.#Success value} + {.#Some [name value]} - {#try.Failure _} - #.None))) + {try.#Failure _} + {.#None}))) (dictionary.of_list text.hash))))) (`` (implementation: .public (async program) @@ -97,10 +97,10 @@ (function.constant (io.io (dictionary.keys environment)))) (def: (variable name) (io.io (case (dictionary.value name environment) - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None + {.#None} (exception.except ..unknown_environment_variable [name])))) (def: home home) @@ -137,9 +137,9 @@ (def: (jvm\\consume iterator) (All (_ a) (-> (java/util/Iterator a) (List a))) (if (java/util/Iterator::hasNext iterator) - {#.Item (java/util/Iterator::next iterator) + {.#Item (java/util/Iterator::next iterator) (jvm\\consume iterator)} - #.End)) + {.#End})) )] (for [@.old (as_is <jvm>) @.jvm (as_is <jvm>) @@ -155,10 +155,10 @@ (def: (exit_node_js! code) (-> Exit (IO Nothing)) (case (ffi.constant ..NodeJs_Process [process]) - {#.Some process} + {.#Some process} (NodeJs_Process::exit (i.frac code) process) - #.None + {.#None} (..default_exit! code))) (import: Browser_Window @@ -173,23 +173,23 @@ (-> Exit (IO Nothing)) (case [(ffi.constant ..Browser_Window [window]) (ffi.constant ..Browser_Location [location])] - [{#.Some window} {#.Some location}] + [{.#Some window} {.#Some location}] (exec (Browser_Window::close [] window) (Browser_Location::reload [] location) (..default_exit! code)) - [{#.Some window} #.None] + [{.#Some window} {.#None}] (exec (Browser_Window::close [] window) (..default_exit! code)) - [#.None {#.Some location}] + [{.#None} {.#Some location}] (exec (Browser_Location::reload [] location) (..default_exit! code)) - [#.None #.None] + [{.#None} {.#None}] (..default_exit! code))) (import: Object @@ -213,9 +213,9 @@ (def: (require _) (-> [] (-> ffi.String Any)) (case [(normal_require []) (global_require []) (process_load [])] - (^or [{#.Some require} _ _] - [_ {#.Some require} _] - [_ _ {#.Some require}]) + (^or [{.#Some require} _ _] + [_ {.#Some require} _] + [_ _ {.#Some require}]) require _ @@ -247,18 +247,18 @@ (do [! io.monad] [outcome (io/popen [command])] (case outcome - {#try.Success outcome} + {try.#Success outcome} (case outcome - {#.Some file} + {.#Some file} (do ! [?output (LuaFile::read ["*l"] file) _ (LuaFile::close [] file)] (in (maybe.else default ?output))) - #.None + {.#None} (in default)) - {#try.Failure _} + {try.#Failure _} (in default))))) @.ruby (as_is (ffi.import: Env "as" RubyEnv ["[1]::[0]" @@ -314,25 +314,25 @@ @.jvm <jvm> @.js (io.io (if ffi.on_node_js? (case (ffi.constant Object [process env]) - {#.Some process/env} + {.#Some process/env} (|> (Object::entries [process/env]) - (array.list #.None) + (array.list {.#None}) (list\each (|>> (array.read! 0) maybe.trusted))) - #.None + {.#None} (list)) (list))) - @.python (\ io.monad each (array.list #.None) (os/environ::keys [])) + @.python (\ io.monad each (array.list {.#None}) (os/environ::keys [])) ... Lua offers no way to get all the environment variables available. @.lua (io.io (list)) @.ruby (|> (RubyEnv::keys []) - (array.list #.None) + (array.list {.#None}) io.io) ... @.php (do io.monad ... [environment (..getenv/0 [])] ... (in (|> environment ... ..array_keys - ... (array.list #.None) + ... (array.list {.#None}) ... (list\each (function (_ variable) ... [variable ("php array read" (:as Nat variable) environment)])) ... (dictionary.of_list text.hash)))) @@ -352,10 +352,10 @@ [(do io.monad [value (<method> name)] (in (case value - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None + {.#None} (exception.except ..unknown_environment_variable [name]))))]] (with_expansions [<jvm> (!fetch java/lang/System::resolveEnv)] (for [@.old <jvm> @@ -365,10 +365,10 @@ [process/env (ffi.constant Object [process env])] (array.read! (:as Nat name) (:as (Array Text) process/env))) - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None + {.#None} (exception.except ..unknown_environment_variable [name])) (exception.except ..unknown_environment_variable [name]))) @.python (!fetch os/environ::get) @@ -407,10 +407,10 @@ @.jvm <jvm> @.js (if ffi.on_node_js? (case (ffi.constant ..NodeJs_Process [process]) - {#.Some process} + {.#Some process} (NodeJs_Process::cwd [] process) - #.None + {.#None} (io.io <default>)) (io.io <default>)) @.python (os::getcwd []) diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index 3fd76261b..29ff3ab2e 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -50,7 +50,7 @@ (: (-> [] (! (Try Text))) read) (: (-> [] (! (Try Text))) - error) + fail) (: (-> Text (! (Try Any))) write) (: (-> [] (! (Try Any))) @@ -67,7 +67,7 @@ async.future))] [read] - [error] + [fail] [write] [destroy] [await] @@ -140,11 +140,11 @@ (Ex (_ ?) (-> (Sanitizer Command) (Sanitizer Argument) (Policy ?))) (?.with_policy (: (Context Safety Policy) - (function (_ (^open "?\[0]")) + (function (_ (^open "?[0]")) (implementation - (def: command (|>> safe_command ?\can_upgrade)) - (def: argument (|>> safe_argument ?\can_upgrade)) - (def: value ?\can_downgrade)))))) + (def: command (|>> safe_command ?#can_upgrade)) + (def: argument (|>> safe_argument ?#can_upgrade)) + (def: value ?#can_downgrade)))))) (def: unix_policy (let [replacer (: Replacer @@ -249,14 +249,14 @@ (do ! [output (java/io/BufferedReader::readLine <stream>)] (case output - {#.Some output} + {.#Some output} (in output) - #.None + {.#None} (\ io.monad in (exception.except ..no_more_output [])))))] [read jvm_input] - [error jvm_error] + [fail jvm_error] )) (def: (write message) (java/io/OutputStream::write (\ utf8.codec encoded message) jvm_output)) @@ -315,7 +315,7 @@ (: (-> s (Try [s Text])) on_read) (: (-> s (Try [s Text])) - on_error) + on_fail) (: (-> Text s (Try s)) on_write) (: (-> s (Try s)) @@ -331,40 +331,40 @@ (do [! io.monad] [|state| (atom.read! state)] (case (\ mock <mock> |state|) - {#try.Success [|state| output]} + {try.#Success [|state| output]} (do ! [_ (atom.write! |state| state)] - (in {#try.Success output})) + (in {try.#Success output})) - {#try.Failure error} - (in {#try.Failure error}))))] + {try.#Failure error} + (in {try.#Failure error}))))] [read on_read] - [error on_error] + [fail on_fail] [await on_await] )) (def: (write message) (do [! io.monad] [|state| (atom.read! state)] (case (\ mock on_write message |state|) - {#try.Success |state|} + {try.#Success |state|} (do ! [_ (atom.write! |state| state)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error})))) + {try.#Failure error} + (in {try.#Failure error})))) (def: (destroy _) (do [! io.monad] [|state| (atom.read! state)] (case (\ mock on_destroy |state|) - {#try.Success |state|} + {try.#Success |state|} (do ! [_ (atom.write! |state| state)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error})))))) + {try.#Failure error} + (in {try.#Failure error})))))) (implementation: .public (mock mock init) (All (_ s) |