diff options
Diffstat (limited to 'stdlib')
408 files changed, 3770 insertions, 3648 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 5e27a94c4..9034ba1fd 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -1752,7 +1752,7 @@ (identifier$ ["library/lux" "List"])))] (form$ (list (text$ "lux type check") type expression)))) -(def:''' .private (spliced replace? untemplate elems) +(def:''' .private (spliced replace? untemplated elems) #End (-> Bit (-> Code ($' Meta Code)) ($' List Code) ($' Meta Code)) ({#1 @@ -1766,7 +1766,7 @@ _ (do meta_monad - [lastO (untemplate lastI)] + [lastO (untemplated lastI)] (in (code_list (form$ (list (tag$ ["library/lux" "Item"]) (tuple$ (list lastO (tag$ ["library/lux" "End"]))))))))} lastI)] @@ -1780,7 +1780,7 @@ _ (do meta_monad - [leftO (untemplate leftI)] + [leftO (untemplated leftI)] (in (form$ (list (tag$ ["library/lux" "Item"]) (tuple$ (list leftO rightO))))))} leftI)) lastO @@ -1788,7 +1788,7 @@ (list\reverse elems)) #0 (do meta_monad - [=elems (monad\map meta_monad untemplate elems)] + [=elems (monad\map meta_monad untemplated elems)] (in (untemplated_list =elems)))} replace?)) @@ -1797,7 +1797,7 @@ (-> Text Code) (with_location (form$ (list (tag$ ["library/lux" "Text"]) (text$ value))))) -(def:''' .private (untemplate replace? subst token) +(def:''' .private (untemplated replace? subst token) #End (-> Bit Text Code ($' Meta Code)) ({[_ [_ (#Bit value)]] @@ -1853,24 +1853,24 @@ [#1 [_ (#Form (#Item [[_ (#Identifier ["" "~!"])] (#Item [dependent #End])]))]] (do meta_monad - [independent (untemplate replace? subst dependent)] + [independent (untemplated replace? subst dependent)] (in (with_location (form$ (list (tag$ ["library/lux" "Form"]) (untemplated_list (list (untemplated_text "lux in-module") (untemplated_text subst) independent))))))) [#1 [_ (#Form (#Item [[_ (#Identifier ["" "~'"])] (#Item [keep_quoted #End])]))]] - (untemplate #0 subst keep_quoted) + (untemplated #0 subst keep_quoted) [_ [meta (#Form elems)]] (do meta_monad - [output (spliced replace? (untemplate replace? subst) elems) + [output (spliced replace? (untemplated replace? subst) elems) .let' [[_ output'] (with_location (form$ (list (tag$ ["library/lux" "Form"]) output)))]] (in [meta output'])) [_ [meta (#Tuple elems)]] (do meta_monad - [output (spliced replace? (untemplate replace? subst) elems) + [output (spliced replace? (untemplated replace? subst) elems) .let' [[_ output'] (with_location (form$ (list (tag$ ["library/lux" "Tuple"]) output)))]] (in [meta output'])) @@ -1881,8 +1881,8 @@ (function' [kv] (let' [[k v] kv] (do meta_monad - [=k (untemplate replace? subst k) - =v (untemplate replace? subst v)] + [=k (untemplated replace? subst k) + =v (untemplated replace? subst v)] (in (tuple$ (list =k =v))))))) fields)] (in (with_location (form$ (list (tag$ ["library/lux" "Record"]) (untemplated_list =fields))))))} @@ -1928,7 +1928,7 @@ ({(#Item template #End) (do meta_monad [current_module current_module_name - =template (untemplate #1 current_module template)] + =template (untemplated #1 current_module template)] (in (list (form$ (list (text$ "lux type check") (identifier$ ["library/lux" "Code"]) =template))))) @@ -1944,7 +1944,7 @@ "(`' (def: (~ name) (function (_ (~+ args)) (~ body))))"))]) ({(#Item template #End) (do meta_monad - [=template (untemplate #1 "" template)] + [=template (untemplated #1 "" template)] (in (list (form$ (list (text$ "lux type check") (identifier$ ["library/lux" "Code"]) =template))))) _ @@ -1958,7 +1958,7 @@ "(' YOLO)"))]) ({(#Item template #End) (do meta_monad - [=template (untemplate #0 "" template)] + [=template (untemplated #0 "" template)] (in (list (form$ (list (text$ "lux type check") (identifier$ ["library/lux" "Code"]) =template))))) _ @@ -1969,9 +1969,9 @@ (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "... Piping macro." __paragraph - "(|> elems (list\map int\encode) (interpose '' '') (fold text\compose ''''))" __paragraph + "(|> elems (list\map int\encode) (interposed '' '') (fold text\compose ''''))" __paragraph "... =>" __paragraph - "(fold text\compose '''' (interpose '' '' (list\map int\encode elems)))"))]) + "(fold text\compose '''' (interposed '' '' (list\map int\encode elems)))"))]) ({(#Item [init apps]) (in_meta (list (list\fold ("lux type check" (-> Code Code Code) (function' [app acc] @@ -1995,9 +1995,9 @@ (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "... Reverse piping macro." __paragraph - "(<| (fold text\compose '''') (interpose '' '') (list\map int\encode) elems)" __paragraph + "(<| (fold text\compose '''') (interposed '' '') (list\map int\encode) elems)" __paragraph "... =>" __paragraph - "(fold text\compose '''' (interpose '' '' (list\map int\encode elems)))"))]) + "(fold text\compose '''' (interposed '' '' (list\map int\encode elems)))"))]) ({(#Item [init apps]) (in_meta (list (list\fold ("lux type check" (-> Code Code Code) (function' [app acc] @@ -2064,7 +2064,7 @@ #None} tuple)) -(def:''' .private (apply_template env template) +(def:''' .private (realized_template env template) #End (-> Replacement_Environment Code Code) ({[_ (#Identifier "" sname)] @@ -2076,16 +2076,16 @@ (..replacement sname env)) [meta (#Tuple elems)] - [meta (#Tuple (list\map (apply_template env) elems))] + [meta (#Tuple (list\map (realized_template env) elems))] [meta (#Form elems)] - [meta (#Form (list\map (apply_template env) elems))] + [meta (#Form (list\map (realized_template env) elems))] [meta (#Record members)] [meta (#Record (list\map ("lux type check" (-> (Tuple Code Code) (Tuple Code Code)) (function' [kv] (let' [[slot value] kv] - [(apply_template env slot) (apply_template env value)]))) + [(realized_template env slot) (realized_template env value)]))) members))] _ @@ -2150,7 +2150,7 @@ ({(#Item [[_ (#Tuple bindings)] (#Item [[_ (#Tuple templates)] data])]) ({[(#Some bindings') (#Some data')] (let' [apply ("lux type check" (-> Replacement_Environment ($' List Code)) - (function' [env] (list\map (apply_template env) templates))) + (function' [env] (list\map (realized_template env) templates))) num_bindings (list\size bindings')] (if (every? (function' [size] ("lux i64 =" num_bindings size)) (list\map list\size data')) @@ -2348,7 +2348,7 @@ #None #0} output)))) -(def:''' .private (interpose sep xs) +(def:''' .private (list\interposed sep xs) #End (All [a] (-> a ($' List a) ($' List a))) @@ -2359,7 +2359,7 @@ xs (#Item [x xs']) - (list& x sep (interpose sep xs'))} + (list& x sep (list\interposed sep xs'))} xs)) (def:''' .private (single_expansion token) @@ -2591,7 +2591,7 @@ (failure "Improper type-definition syntax")} type_codes)) -(def:''' .private (gensym prefix state) +(def:''' .private (identifier prefix state) #End (-> Text ($' Meta Code)) ({{#info info #source source #current_module _ #modules modules @@ -2721,14 +2721,14 @@ [_ (#Form xs)] ($_ text\compose "(" (|> xs (list\map code\encode) - (interpose " ") + (list\interposed " ") list\reverse (list\fold text\compose "")) ")") [_ (#Tuple xs)] ($_ text\compose "[" (|> xs (list\map code\encode) - (interpose " ") + (list\interposed " ") list\reverse (list\fold text\compose "")) "]") @@ -2736,7 +2736,7 @@ ($_ text\compose "{" (|> kvs (list\map (function' [kv] ({[k v] ($_ text\compose (code\encode k) " " (code\encode v))} kv))) - (interpose " ") + (list\interposed " ") list\reverse (list\fold text\compose "")) "}")} code)) @@ -2769,7 +2769,7 @@ _ (failure ($_ text\compose "'lux.case' expects an even number of tokens: " (|> branches (list\map code\encode) - (interpose " ") + (list\interposed " ") list\reverse (list\fold text\compose ""))))} branches)) @@ -3090,7 +3090,7 @@ (case tokens (^ (list else then)) (do meta_monad - [g!_ (gensym "g!_")] + [g!_ (..identifier "g!_")] (in (list (` (..case (~ then) (#..Some (~ g!_)) (#..Some (~ g!_)) @@ -3313,10 +3313,10 @@ (-> Text Text (Maybe Nat)) ("lux text index" 0 part text)) -(def: .public (error! message) +(def: .public (panic! message) {#.doc (text$ ($_ "lux text concat" "... Causes an error, with the given error message." ..\n - "(error! ''OH NO!'')"))} + "(panic! ''OH NO!'')"))} (-> Text Nothing) ("lux io error" message)) @@ -3745,7 +3745,7 @@ {#.doc (text$ ($_ "lux text concat" "... The type-definition macro." ..\n "(type: (List a)" ..\n - " {#.doc (doc (: (List Nat) (list 0 1 2 3)))}" ..\n + " {#.doc (example (: (List Nat) (list 0 1 2 3)))}" ..\n " #End" ..\n " (#Item a (List a)))"))} (case (typeP tokens) @@ -4022,7 +4022,7 @@ _ #.None)) -(def: (count_relatives relatives input) +(def: (relative_ups relatives input) (-> Nat Text Nat) (case ("lux text index" relatives ..module_separator input) #None @@ -4030,7 +4030,7 @@ (#Some found) (if ("lux i64 =" relatives found) - (count_relatives ("lux i64 +" 1 relatives) input) + (relative_ups ("lux i64 +" 1 relatives) input) relatives))) (def: (list\take amount list) @@ -4053,7 +4053,7 @@ (def: (absolute_module_name nested? relative_root module) (-> Bit Text Text (Meta Text)) - (case (count_relatives 0 module) + (case (relative_ups 0 module) 0 (in_meta (if nested? ($_ "lux text concat" relative_root ..module_separator module) @@ -4067,7 +4067,7 @@ list\reverse (list\drop jumps) list\reverse - (interpose ..module_separator) + (list\interposed ..module_separator) (text\join_with "")) clean ("lux text clip" relatives (|> module "lux text size" ("lux i64 -" relatives)) module) output (case ("lux text size" clean) @@ -4370,16 +4370,16 @@ name _ - ($_ text\compose "(" name " " (|> params (list\map type\encode) (interpose " ") list\reverse (list\fold text\compose "")) ")")) + ($_ text\compose "(" name " " (|> params (list\map type\encode) (list\interposed " ") list\reverse (list\fold text\compose "")) ")")) (#Sum _) - ($_ text\compose "(Or " (|> (flat_variant type) (list\map type\encode) (interpose " ") list\reverse (list\fold text\compose "")) ")") + ($_ text\compose "(Or " (|> (flat_variant type) (list\map type\encode) (list\interposed " ") list\reverse (list\fold text\compose "")) ")") (#Product _) - ($_ text\compose "[" (|> (flat_tuple type) (list\map type\encode) (interpose " ") list\reverse (list\fold text\compose "")) "]") + ($_ text\compose "[" (|> (flat_tuple type) (list\map type\encode) (list\interposed " ") list\reverse (list\fold text\compose "")) "]") (#Function _) - ($_ text\compose "(-> " (|> (flat_lambda type) (list\map type\encode) (interpose " ") list\reverse (list\fold text\compose "")) ")") + ($_ text\compose "(-> " (|> (flat_lambda type) (list\map type\encode) (list\interposed " ") list\reverse (list\fold text\compose "")) ")") (#Parameter id) (nat\encode id) @@ -4400,7 +4400,7 @@ (let [[func args] (flat_application type)] ($_ text\compose "(" (type\encode func) " " - (|> args (list\map type\encode) (interpose " ") list\reverse (list\fold text\compose "")) + (|> args (list\map type\encode) (list\interposed " ") list\reverse (list\fold text\compose "")) ")")) (#Named name _) @@ -4417,7 +4417,7 @@ (case tokens (^ (list& [_ (#Form (list [_ (#Text alias)]))] body branches)) (do meta_monad - [g!temp (gensym "temp")] + [g!temp (..identifier "temp")] (in (list& g!temp (` (..^open (~ g!temp) (~ (text$ alias)) (~ body))) branches))) (^ (list [_ (#Identifier name)] [_ (#Text alias)] body)) @@ -4510,8 +4510,8 @@ [slot (normal slot') output (..type_tag slot) .let [[idx tags exported? type] output] - g!_ (gensym "_") - g!output (gensym "")] + g!_ (..identifier "_") + g!output (..identifier "")] (case (interface_methods type) (#Some members) (let [pattern (record$ (list\map (: (-> [Name [Nat Type]] [Code Code]) @@ -4535,8 +4535,8 @@ (^ (list selector)) (do meta_monad - [g!_ (gensym "_") - g!record (gensym "record")] + [g!_ (..identifier "_") + g!record (..identifier "record")] (in (list (` (function ((~ g!_) (~ g!record)) (..get@ (~ selector) (~ g!record))))))) _ @@ -4546,7 +4546,7 @@ (-> Text (List Name) Nat Name Code Type (Meta (List Code))) (do meta_monad [output (record_slots type) - g!_ (gensym "g!_") + g!_ (..identifier "g!_") .let [g!output (local_identifier$ short) pattern (|> tags enumeration @@ -4606,7 +4606,7 @@ _ (do meta_monad - [g!struct (gensym "struct")] + [g!struct (..identifier "struct")] (in_meta (list (` ("lux def" (~ g!struct) (~ struct) [(~ location_code) (#.Record #End)] #0)) @@ -4618,23 +4618,23 @@ (macro: .public (|>> tokens) {#.doc (text$ ($_ "lux text concat" "... Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n - "(|>> (list\map int\encode) (interpose '' '') (fold text\compose ''''))" ..\n + "(|>> (list\map int\encode) (interposed '' '') (fold text\compose ''''))" ..\n "... =>" ..\n - "(function (_ <arg>) (fold text\compose '''' (interpose '' '' (list\map int\encode <arg>))))"))} + "(function (_ <arg>) (fold text\compose '''' (interposed '' '' (list\map int\encode <arg>))))"))} (do meta_monad - [g!_ (gensym "_") - g!arg (gensym "arg")] + [g!_ (..identifier "_") + g!arg (..identifier "arg")] (in_meta (list (` (function ((~ g!_) (~ g!arg)) (|> (~ g!arg) (~+ tokens)))))))) (macro: .public (<<| tokens) {#.doc (text$ ($_ "lux text concat" "... Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n - "(<<| (fold text\compose '''') (interpose '' '') (list\map int\encode))" ..\n + "(<<| (fold text\compose '''') (interposed '' '') (list\map int\encode))" ..\n "... =>" ..\n - "(function (_ <arg>) (fold text\compose '''' (interpose '' '' (list\map int\encode <arg>))))"))} + "(function (_ <arg>) (fold text\compose '''' (interposed '' '' (list\map int\encode <arg>))))"))} (do meta_monad - [g!_ (gensym "_") - g!arg (gensym "arg")] + [g!_ (..identifier "_") + g!arg (..identifier "arg")] (in_meta (list (` (function ((~ g!_) (~ g!arg)) (<| (~+ tokens) (~ g!arg)))))))) (def: (imported_by? import_name module_name) @@ -4661,7 +4661,7 @@ (failure ($_ text\compose "Wrong syntax for refer @ " current_module ..\n (|> options (list\map code\encode) - (interpose " ") + (list\interposed " ") (list\fold text\compose ""))))))) (def: (referral_definitions module_name [r_defs r_opens]) @@ -4831,7 +4831,7 @@ (: (-> [Name [Nat Type]] (Meta [Name Nat Code])) (function (_ [r_slot_name [r_idx r_type]]) (do meta_monad - [g!slot (gensym "")] + [g!slot (..identifier "")] (in_meta [r_slot_name r_idx g!slot])))) (zipped/2 tags (enumeration members)))] (let [pattern (record$ (list\map (: (-> [Name Nat Code] [Code Code]) @@ -4860,7 +4860,7 @@ (do meta_monad [bindings (monad\map meta_monad (: (-> Code (Meta Code)) - (function (_ _) (gensym "temp"))) + (function (_ _) (..identifier "temp"))) slots) .let [pairs (zipped/2 slots bindings) update_expr (list\fold (: (-> [Code Code] Code Code) @@ -4880,16 +4880,16 @@ (^ (list selector value)) (do meta_monad - [g!_ (gensym "_") - g!record (gensym "record")] + [g!_ (..identifier "_") + g!record (..identifier "record")] (in (list (` (function ((~ g!_) (~ g!record)) (..set@ (~ selector) (~ value) (~ g!record))))))) (^ (list selector)) (do meta_monad - [g!_ (gensym "_") - g!value (gensym "value") - g!record (gensym "record")] + [g!_ (..identifier "_") + g!value (..identifier "value") + g!record (..identifier "record")] (in (list (` (function ((~ g!_) (~ g!value) (~ g!record)) (..set@ (~ selector) (~ g!value) (~ g!record))))))) @@ -4920,7 +4920,7 @@ (: (-> [Name [Nat Type]] (Meta [Name Nat Code])) (function (_ [r_slot_name [r_idx r_type]]) (do meta_monad - [g!slot (gensym "")] + [g!slot (..identifier "")] (in_meta [r_slot_name r_idx g!slot])))) (zipped/2 tags (enumeration members)))] (let [pattern (record$ (list\map (: (-> [Name Nat Code] [Code Code]) @@ -4947,24 +4947,24 @@ _ (do meta_monad - [g!record (gensym "record") - g!temp (gensym "temp")] + [g!record (..identifier "record") + g!temp (..identifier "temp")] (in (list (` (let [(~ g!record) (~ record) (~ g!temp) (get@ [(~+ slots)] (~ g!record))] (set@ [(~+ slots)] ((~ fun) (~ g!temp)) (~ g!record)))))))) (^ (list selector fun)) (do meta_monad - [g!_ (gensym "_") - g!record (gensym "record")] + [g!_ (..identifier "_") + g!record (..identifier "record")] (in (list (` (function ((~ g!_) (~ g!record)) (..update@ (~ selector) (~ fun) (~ g!record))))))) (^ (list selector)) (do meta_monad - [g!_ (gensym "_") - g!fun (gensym "fun") - g!record (gensym "record")] + [g!_ (..identifier "_") + g!fun (..identifier "fun") + g!record (..identifier "record")] (in (list (` (function ((~ g!_) (~ g!fun) (~ g!record)) (..update@ (~ selector) (~ g!fun) (~ g!record))))))) @@ -5019,7 +5019,7 @@ (if (every? (|>> ("lux i64 =" num_bindings)) (list\map list\size data')) (let [apply (: (-> Replacement_Environment (List Code)) - (function (_ env) (list\map (apply_template env) templates)))] + (function (_ env) (list\map (realized_template env) templates)))] (|> data' (list\map (compose apply (replacement_environment bindings'))) list\join @@ -5106,11 +5106,11 @@ (-> Text Nat) ("lux text size" x)) -(def: (update_location [file line column] code_text) +(def: (updated_location [file line column] code_text) (-> Location Text Location) [file line ("lux i64 +" column (text\size code_text))]) -(def: (delim_update_location [file line column]) +(def: (delimiter_updated_location [file line column]) (-> Location Location) [file line (inc column)]) @@ -5129,7 +5129,7 @@ (^template [<tag> <encode>] [[new_location (<tag> value)] (let [as_text (<encode> value)] - [(update_location new_location as_text) + [(updated_location new_location as_text) (text\compose (location_padding baseline prev_location new_location) as_text)])]) ([#Bit bit\encode] @@ -5145,9 +5145,9 @@ (let [[group_location' parts_text] (list\fold (function (_ part [last_location text_accum]) (let [[part_location part_text] (example_documentation last_location baseline part)] [part_location (text\compose text_accum part_text)])) - [(delim_update_location group_location) ""] + [(delimiter_updated_location group_location) ""] (<prep> parts))] - [(delim_update_location group_location') + [(delimiter_updated_location group_location') ($_ text\compose (location_padding baseline prev_location group_location) <open> parts_text @@ -5179,18 +5179,18 @@ [_ text] (..example_documentation (with_baseline baseline location) baseline example)] (text\compose text __paragraph)))) -(macro: .public (doc tokens) +(macro: .public (example tokens) {#.doc (text$ ($_ "lux text concat" "... Creates code documentation, embedding text as comments and properly formatting the forms it's being given." __paragraph "... For Example:" ..\n - "(doc ''Allows arbitrary looping, using the 'recur' form to re-start the loop.''" ..\n - " ''Can be used in monadic code to create monadic loops.''" ..\n - " (loop [count +0" ..\n - " x init]" ..\n - " (if (< +10 count)" ..\n - " (recur (inc count) (f x))" ..\n - " x)))"))} + "(example ''Allows arbitrary looping, using the 'recur' form to re-start the loop.''" ..\n + " ''Can be used in monadic code to create monadic loops.''" ..\n + " (loop [count +0" ..\n + " x init]" ..\n + " (if (< +10 count)" ..\n + " (recur (inc count) (f x))" ..\n + " x)))"))} (in_meta (list (` [(~ location_code) (#.Text (~ (|> tokens (list\map (|>> ..documentation_fragment ..fragment_documentation)) @@ -5243,21 +5243,21 @@ (identifier$ [module name]))) (macro: .public (loop tokens) - {#.doc (doc "Allows arbitrary looping, using the 'recur' form to re-start the loop." - "Can be used in monadic code to create monadic loops." - (loop [count +0 + {#.doc (example "Allows arbitrary looping, using the 'recur' form to re-start the loop." + "Can be used in monadic code to create monadic loops." + (loop [count +0 + x init] + (if (< +10 count) + (recur (inc count) (f x)) + x)) + + "Loops can also be given custom names." + (loop my_loop + [count +0 x init] - (if (< +10 count) - (recur (inc count) (f x)) - x)) - - "Loops can also be given custom names." - (loop my_loop - [count +0 - x init] - (if (< +10 count) - (my_loop (inc count) (f x)) - x)))} + (if (< +10 count) + (my_loop (inc count) (f x)) + x)))} (let [?params (case tokens (^ (list name [_ (#Tuple bindings)] body)) (#.Some [name bindings body]) @@ -5289,7 +5289,7 @@ (do meta_monad [aliases (monad\map meta_monad (: (-> Code (Meta Code)) - (function (_ _) (gensym ""))) + (function (_ _) (..identifier ""))) inits)] (in_meta (list (` (let [(~+ (..interleaved aliases inits))] (.loop (~ name) @@ -5300,10 +5300,10 @@ (failure "Wrong syntax for loop")))) (macro: .public (^slots tokens) - {#.doc (doc "Allows you to extract record members as local variables with the same names." - "For example:" - (let [(^slots [#foo #bar #baz]) quux] - (f foo bar baz)))} + {#.doc (example "Allows you to extract record members as local variables with the same names." + "For example:" + (let [(^slots [#foo #bar #baz]) quux] + (f foo bar baz)))} (case tokens (^ (list& [_ (#Form (list [_ (#Tuple (list& hslot' tslots'))]))] body branches)) (do meta_monad @@ -5322,7 +5322,7 @@ hslot (..normal hslot) tslots (monad\map meta_monad ..normal tslots) output (..type_tag hslot) - g!_ (gensym "_") + g!_ (..identifier "_") .let [[idx tags exported? type] output slot_pairings (list\map (: (-> Name [Text Code]) (function (_ [module name]) @@ -5378,25 +5378,25 @@ (in (list [location (#Record =pairs)]))))) (macro: .public (with_expansions tokens) - {#.doc (doc "Controlled macro-expansion." - "Bind an arbitraty number of Code nodes resulting from macro-expansion to local bindings." - "Wherever a binding appears, the bound Code nodes will be spliced in there." - (test: "Code operations & implementations" - (with_expansions - [<tests> (template [<expr> <text>] - [(compare <text> (\ Code/encode encode <expr>))] - - [(bit #1) "#1"] - [(int +123) "+123"] - [(frac +123.0) "+123.0"] - [(text "123") "'123'"] - [(tag ["yolo" "lol"]) "#yolo.lol"] - [(identifier ["yolo" "lol"]) "yolo.lol"] - [(form (list (bit #1))) "(#1)"] - [(tuple (list (bit #1))) "[#1]"] - [(record (list [(bit #1) (int +123)])) "{#1 +123}"] - )] - (test_all <tests>))))} + {#.doc (example "Controlled macro-expansion." + "Bind an arbitraty number of Code nodes resulting from macro-expansion to local bindings." + "Wherever a binding appears, the bound Code nodes will be spliced in there." + (test: "Code operations & implementations" + (with_expansions + [<tests> (template [<expr> <text>] + [(compare <text> (\ Code/encode encode <expr>))] + + [(bit #1) "#1"] + [(int +123) "+123"] + [(frac +123.0) "+123.0"] + [(text "123") "'123'"] + [(tag ["yolo" "lol"]) "#yolo.lol"] + [(identifier ["yolo" "lol"]) "yolo.lol"] + [(form (list (bit #1))) "(#1)"] + [(tuple (list (bit #1))) "[#1]"] + [(record (list [(bit #1) (int +123)])) "{#1 +123}"] + )] + (test_all <tests>))))} (case tokens (^ (list& [_ (#Tuple bindings)] bodies)) (case bindings @@ -5550,26 +5550,26 @@ (list init_pattern inner_pattern_body))) (macro: .public (^multi tokens) - {#.doc (doc "Multi-level pattern matching." - "Useful in situations where the result of a branch depends on further refinements on the values being matched." - "For example:" - (case (split (size static) uri) - (^multi (#.Some [chunk uri']) - {(text\= static chunk) #1}) - (match_uri endpoint? parts' uri') + {#.doc (example "Multi-level pattern matching." + "Useful in situations where the result of a branch depends on further refinements on the values being matched." + "For example:" + (case (split (size static) uri) + (^multi (#.Some [chunk uri']) + {(text\= static chunk) #1}) + (match_uri endpoint? parts' uri') - _ - (#.Left (format "Static part " (%t static) " does not match URI: " uri))) + _ + (#.Left (format "Static part " (%t static) " does not match URI: " uri))) - "Short-cuts can be taken when using bit tests." - "The example above can be rewritten as..." - (case (split (size static) uri) - (^multi (#.Some [chunk uri']) - (text\= static chunk)) - (match_uri endpoint? parts' uri') + "Short-cuts can be taken when using bit tests." + "The example above can be rewritten as..." + (case (split (size static) uri) + (^multi (#.Some [chunk uri']) + (text\= static chunk)) + (match_uri endpoint? parts' uri') - _ - (#.Left (format "Static part " (%t static) " does not match URI: " uri))))} + _ + (#.Left (format "Static part " (%t static) " does not match URI: " uri))))} (case tokens (^ (list& [_meta (#Form levels)] body next_branches)) (do meta_monad @@ -5581,7 +5581,7 @@ _ #0)] expected get_expected_type - g!temp (gensym "temp")] + g!temp (..identifier "temp")] (let [output (list g!temp (` ({(#Some (~ g!temp)) (~ g!temp) @@ -5610,10 +5610,10 @@ (text\compose "Wrong syntax for "))) (macro: .public (name_of tokens) - {#.doc (doc "Given an identifier or a tag, gives back a 2 tuple with the module and name parts, both as Text." - (name_of #.doc) - "=>" - ["library/lux" "doc"])} + {#.doc (example "Given an identifier or a tag, gives back a 2 tuple with the module and name parts, both as Text." + (name_of #.doc) + "=>" + ["library/lux" "doc"])} (case tokens (^template [<tag>] [(^ (list [_ (<tag> [module name])])) @@ -5634,14 +5634,14 @@ )) (macro: .public (:parameter tokens) - {#.doc (doc "Allows you to refer to the type-variables in a polymorphic function's type, by their index." - "In the example below, 0 corresponds to the 'a' variable." - (def: .public (of_list list) - (All [a] (-> (List a) (Row a))) - (list\fold add - (: (Row (:parameter 0)) - empty) - list)))} + {#.doc (example "Allows you to refer to the type-variables in a polymorphic function's type, by their index." + "In the example below, 0 corresponds to the 'a' variable." + (def: .public (of_list list) + (All [a] (-> (List a) (Row a))) + (list\fold add + (: (Row (:parameter 0)) + empty) + list)))} (case tokens (^ (list [_ (#Nat idx)])) (do meta_monad @@ -5657,22 +5657,22 @@ (failure (..wrong_syntax_error (name_of ..$))))) (def: .public (is? reference sample) - {#.doc (doc "Tests whether the 2 values are identical (not just 'equal')." - "This one should succeed:" - (let [value +5] - (is? value value)) + {#.doc (example "Tests whether the 2 values are identical (not just 'equal')." + "This one should succeed:" + (let [value +5] + (is? value value)) - "This one should fail:" - (is? +5 (+ +2 +3)))} + "This one should fail:" + (is? +5 (+ +2 +3)))} (All [a] (-> a a Bit)) ("lux is" reference sample)) (macro: .public (^@ tokens) - {#.doc (doc "Allows you to simultaneously bind and de-structure a value." - (def: (hash (^@ set [Hash<a> _])) - (list\fold (function (_ elem acc) (+ (\ Hash<a> hash elem) acc)) - 0 - (to_list set))))} + {#.doc (example "Allows you to simultaneously bind and de-structure a value." + (def: (hash (^@ set [Hash<a> _])) + (list\fold (function (_ elem acc) (+ (\ Hash<a> hash elem) acc)) + 0 + (to_list set))))} (case tokens (^ (list& [_meta (#Form (list [_ (#Identifier ["" name])] pattern))] body branches)) (let [g!whole (local_identifier$ name)] @@ -5684,10 +5684,10 @@ (failure (..wrong_syntax_error (name_of ..^@))))) (macro: .public (^|> tokens) - {#.doc (doc "Pipes the value being pattern-matched against prior to binding it to a variable." - (case input - (^|> value [inc (% 10) (max 1)]) - (foo value)))} + {#.doc (example "Pipes the value being pattern-matched against prior to binding it to a variable." + (case input + (^|> value [inc (% 10) (max 1)]) + (foo value)))} (case tokens (^ (list& [_meta (#Form (list [_ (#Identifier ["" name])] [_ (#Tuple steps)]))] body branches)) (let [g!name (local_identifier$ name)] @@ -5700,8 +5700,8 @@ (failure (..wrong_syntax_error (name_of ..^|>))))) (macro: .public (:assume tokens) - {#.doc (doc "Coerces the given expression to the type of whatever is expected." - (: Dinosaur (:assume (list +1 +2 +3))))} + {#.doc (example "Coerces the given expression to the type of whatever is expected." + (: Dinosaur (:assume (list +1 +2 +3))))} (case tokens (^ (list expr)) (do meta_monad @@ -5718,12 +5718,12 @@ (#Right [compiler (get@ #location compiler)]))) (macro: .public (undefined tokens) - {#.doc (doc "Meant to be used as a stand-in for functions with undefined implementations." - "Undefined expressions will type-check against everything, so they make good dummy implementations." - "However, if an undefined expression is ever evaluated, it will raise a runtime error." - (def: (square x) - (-> Int Int) - (undefined)))} + {#.doc (example "Meant to be used as a stand-in for functions with undefined implementations." + "Undefined expressions will type-check against everything, so they make good dummy implementations." + "However, if an undefined expression is ever evaluated, it will raise a runtime error." + (def: (square x) + (-> Int Int) + (undefined)))} (case tokens #End (do meta_monad @@ -5731,23 +5731,23 @@ .let [[module line column] location location ($_ "lux text concat" (text\encode module) "," (nat\encode line) "," (nat\encode column)) message ($_ "lux text concat" "Undefined behavior @ " location)]] - (in (list (` (..error! (~ (text$ message))))))) + (in (list (` (..panic! (~ (text$ message))))))) _ (failure (..wrong_syntax_error (name_of ..undefined))))) (macro: .public (:of tokens) - {#.doc (doc "Generates the type corresponding to a given expression." - "Example #1:" - (let [my_num +123] - (:of my_num)) - "==" - Int - "-------------------" - "Example #2:" - (:of +123) - "==" - Int)} + {#.doc (example "Generates the type corresponding to a given expression." + "Example #1:" + (let [my_num +123] + (:of my_num)) + "==" + Int + "-------------------" + "Example #2:" + (:of +123) + "==" + Int)} (case tokens (^ (list [_ (#Identifier var_name)])) (do meta_monad @@ -5756,7 +5756,7 @@ (^ (list expression)) (do meta_monad - [g!temp (gensym "g!temp")] + [g!temp (..identifier "g!temp")] (in (list (` (let [(~ g!temp) (~ expression)] (..:of (~ g!temp))))))) @@ -5804,16 +5804,16 @@ )) (macro: .public (template: tokens) - {#.doc (doc "Define macros in the style of template and ^template." - "For simple macros that do not need any fancy features." - (template: (square x) - (* x x)))} + {#.doc (example "Define macros in the style of template and ^template." + "For simple macros that do not need any fancy features." + (template: (square x) + (* x x)))} (case (templateP tokens) (#.Some [export_policy name args anns input_templates]) (do meta_monad - [g!tokens (gensym "tokens") - g!compiler (gensym "compiler") - g!_ (gensym "_") + [g!tokens (..identifier "tokens") + g!compiler (..identifier "compiler") + g!_ (..identifier "_") .let [rep_env (list\map (function (_ arg) [arg (` ((~' ~) (~ (local_identifier$ arg))))]) args)] @@ -5924,7 +5924,7 @@ (case code (^ [ann (#Form (list [_ (#Identifier ["" "~~"])] expansion))]) (do meta_monad - [g!expansion (gensym "g!expansion")] + [g!expansion (..identifier "g!expansion")] (in [(list [g!expansion expansion]) g!expansion])) (^template [<tag>] @@ -6015,7 +6015,7 @@ (def: (untemplated_pattern pattern) (-> Code (Meta Code)) (do meta_monad - [g!meta (gensym "g!meta")] + [g!meta (..identifier "g!meta")] (case pattern (^template [<tag> <gen>] [[_ (<tag> value)] @@ -6035,9 +6035,9 @@ [_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))] (failure "Cannot use (~+) inside of ^code unless it is the last element in a form or a tuple.") - (^template [<tag> <untemplate>] + (^template [<tag> <untemplated>] [[_ (<tag> elems)] - (<untemplate> g!meta untemplated_pattern elems)]) + (<untemplated> g!meta untemplated_pattern elems)]) ([#.Tuple ..untemplated_tuple] [#.Form ..untemplated_form]) @@ -6084,16 +6084,16 @@ (..failure (..wrong_syntax_error (name_of ..:let))))) (macro: .public (try tokens) - {#.doc (doc (case (try (risky_computation input)) - (#.Right success) - (do_something success) + {#.doc (example (case (try (risky_computation input)) + (#.Right success) + (do_something success) - (#.Left error) - (recover_from_failure error)))} + (#.Left error) + (recover_from_failure error)))} (case tokens (^ (list expression)) (do meta_monad - [g!_ (gensym "g!_")] + [g!_ (..identifier "g!_")] (in (list (` ("lux try" (.function ((~ g!_) (~ g!_)) (~ expression))))))) diff --git a/stdlib/source/library/lux/abstract/comonad.lux b/stdlib/source/library/lux/abstract/comonad.lux index 589ed47f2..6de44d5f2 100644 --- a/stdlib/source/library/lux/abstract/comonad.lux +++ b/stdlib/source/library/lux/abstract/comonad.lux @@ -13,8 +13,8 @@ [functor (#+ Functor)]]) (interface: .public (CoMonad w) - {#.doc (doc "CoMonads are the opposite/complement to monads." - "CoMonadic structures are often infinite in size and built upon lazily-evaluated functions.")} + {#.doc (example "CoMonads are the opposite/complement to monads." + "CoMonadic structures are often infinite in size and built upon lazily-evaluated functions.")} (: (Functor w) &functor) (: (All [a] @@ -25,11 +25,11 @@ split)) (macro: .public (be tokens state) - {#.doc (doc "A co-monadic parallel to the 'do' macro." - (let [square (function (_ n) (* n n))] - (be comonad - [inputs (iterate inc +2)] - (square (head inputs)))))} + {#.doc (example "A co-monadic parallel to the 'do' macro." + (let [square (function (_ n) (* n n))] + (be comonad + [inputs (iterate inc +2)] + (square (head inputs)))))} (case (: (Maybe [(Maybe Text) Code (List Code) Code]) (case tokens (^ (list [_ (#.Record (list [[_ (#.Identifier ["" name])] comonad]))] [_ (#.Tuple bindings)] body)) @@ -43,11 +43,11 @@ (#.Some [?name comonad bindings body]) (if (|> bindings list.size (n.% 2) (n.= 0)) (let [[module short] (name_of ..be) - gensym (: (-> Text Code) - (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [location.dummy])) - g!_ (gensym "_") - g!map (gensym "map") - g!split (gensym "split") + identifier (: (-> Text Code) + (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [location.dummy])) + g!_ (identifier "_") + g!map (identifier "map") + g!split (identifier "split") body' (list\fold (: (-> [Code Code] Code Code) (function (_ binding body') (with_expansions [<default> (` (|> (~ value) (~ g!split) ((~ g!map) (function ((~ g!_) (~ var)) (~ body')))))] diff --git a/stdlib/source/library/lux/abstract/comonad/cofree.lux b/stdlib/source/library/lux/abstract/comonad/cofree.lux index 271795e14..1431ee3cc 100644 --- a/stdlib/source/library/lux/abstract/comonad/cofree.lux +++ b/stdlib/source/library/lux/abstract/comonad/cofree.lux @@ -6,7 +6,7 @@ [functor (#+ Functor)]]]) (type: .public (CoFree F a) - {#.doc (doc "The CoFree CoMonad.")} + {#.doc "The CoFree CoMonad."} [a (F (CoFree F a))]) (implementation: .public (functor dsl) diff --git a/stdlib/source/library/lux/abstract/equivalence.lux b/stdlib/source/library/lux/abstract/equivalence.lux index 7834363bf..ad3e90d00 100644 --- a/stdlib/source/library/lux/abstract/equivalence.lux +++ b/stdlib/source/library/lux/abstract/equivalence.lux @@ -11,7 +11,7 @@ =)) (def: .public (rec sub) - {#.doc (doc "A recursive equivalence combinator.")} + {#.doc (example "A recursive equivalence combinator.")} (All [a] (-> (-> (Equivalence a) (Equivalence a)) (Equivalence a))) (implementation (def: (= left right) diff --git a/stdlib/source/library/lux/abstract/fold.lux b/stdlib/source/library/lux/abstract/fold.lux index b2ce974da..1a7ba054f 100644 --- a/stdlib/source/library/lux/abstract/fold.lux +++ b/stdlib/source/library/lux/abstract/fold.lux @@ -11,7 +11,7 @@ fold)) (def: .public (with_monoid monoid fold value) - {#.doc (doc "Fold over a foldable structure using the monoid's identity as the initial value.")} + {#.doc "Fold over a foldable structure using the monoid's identity as the initial value."} (All [F a] (-> (Monoid a) (Fold F) (F a) a)) (let [(^open "/\.") monoid] diff --git a/stdlib/source/library/lux/abstract/functor.lux b/stdlib/source/library/lux/abstract/functor.lux index 32e1c6671..3d6e38883 100644 --- a/stdlib/source/library/lux/abstract/functor.lux +++ b/stdlib/source/library/lux/abstract/functor.lux @@ -15,7 +15,7 @@ (All [a] (.Or (f a) (g a)))) (def: .public (sum (^open "f\.") (^open "g\.")) - {#.doc (doc "Co-product (sum) composition for functors.")} + {#.doc (example "Co-product (sum) composition for functors.")} (All [F G] (-> (Functor F) (Functor G) (Functor (..Or F G)))) (implementation (def: (map f fa|ga) @@ -30,7 +30,7 @@ (All [a] (.And (f a) (g a)))) (def: .public (product (^open "f\.") (^open "g\.")) - {#.doc (doc "Product composition for functors.")} + {#.doc (example "Product composition for functors.")} (All [F G] (-> (Functor F) (Functor G) (Functor (..And F G)))) (implementation (def: (map f [fa ga]) diff --git a/stdlib/source/library/lux/abstract/functor/contravariant.lux b/stdlib/source/library/lux/abstract/functor/contravariant.lux index 659105afa..1cf16ce24 100644 --- a/stdlib/source/library/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/library/lux/abstract/functor/contravariant.lux @@ -3,7 +3,7 @@ [lux #*]]) (interface: .public (Functor f) - {#.doc (doc "The contravariant functor.")} + {#.doc (example "The contravariant functor.")} (: (All [a b] (-> (-> b a) diff --git a/stdlib/source/library/lux/abstract/hash.lux b/stdlib/source/library/lux/abstract/hash.lux index 84f80723c..3a27317de 100644 --- a/stdlib/source/library/lux/abstract/hash.lux +++ b/stdlib/source/library/lux/abstract/hash.lux @@ -7,8 +7,8 @@ ["." contravariant]]]) (interface: .public (Hash a) - {#.doc (doc "A way to produce hash-codes for a type's instances." - "A necessity when working with some data-structures, such as dictionaries or sets.")} + {#.doc (example "A way to produce hash-codes for a type's instances." + "A necessity when working with some data-structures, such as dictionaries or sets.")} (: (Equivalence a) &equivalence) (: (-> a Nat) diff --git a/stdlib/source/library/lux/abstract/interval.lux b/stdlib/source/library/lux/abstract/interval.lux index acd7be087..5961039b9 100644 --- a/stdlib/source/library/lux/abstract/interval.lux +++ b/stdlib/source/library/lux/abstract/interval.lux @@ -26,7 +26,7 @@ (def: top top))) (def: .public (singleton enum elem) - {#.doc (doc "An interval where both top and bottom are the same value.")} + {#.doc (example "An interval where both top and bottom are the same value.")} (All [a] (-> (Enum a) a (Interval a))) (implementation (def: &enum enum) @@ -70,13 +70,13 @@ ) (def: .public (borders? interval elem) - {#.doc (doc "Where a value is at the border of an interval.")} + {#.doc (example "Where a value is at the border of an interval.")} (All [a] (-> (Interval a) a Bit)) (or (starts_with? elem interval) (ends_with? elem interval))) (implementation: .public (union left right) - {#.doc (doc "An interval that spans both predecessors.")} + {#.doc (example "An interval that spans both predecessors.")} (All [a] (-> (Interval a) (Interval a) (Interval a))) (def: &enum (get@ #&enum right)) @@ -84,7 +84,7 @@ (def: top (order.max (\ right &order) (\ left top) (\ right top)))) (implementation: .public (intersection left right) - {#.doc (doc "An interval spanned by both predecessors.")} + {#.doc (example "An interval spanned by both predecessors.")} (All [a] (-> (Interval a) (Interval a) (Interval a))) (def: &enum (get@ #&enum right)) @@ -92,7 +92,7 @@ (def: top (order.min (\ right &order) (\ left top) (\ right top)))) (implementation: .public (complement interval) - {#.doc (doc "The inverse of an interval.")} + {#.doc (example "The inverse of an interval.")} (All [a] (-> (Interval a) (Interval a))) (def: &enum (get@ #&enum interval)) @@ -122,7 +122,7 @@ ) (def: .public (meets? reference sample) - {#.doc (doc "Whether an interval meets another one on its bottom/lower side.")} + {#.doc (example "Whether an interval meets another one on its bottom/lower side.")} (All [a] (-> (Interval a) (Interval a) Bit)) (let [(^open ",\.") reference limit (\ reference bottom)] diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index 01e22b7a7..31002b5be 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -44,8 +44,8 @@ #.End)) (interface: .public (Monad m) - {#.doc (doc "A monad is a monoid in the category of endofunctors." - "What's the problem?")} + {#.doc (example "A monad is a monoid in the category of endofunctors." + "What's the problem?")} (: (Functor m) &functor) @@ -57,11 +57,11 @@ join)) (macro: .public (do tokens state) - {#.doc (doc "Macro for easy concatenation of monadic operations." - (do monad - [y (f1 x) - z (f2 z)] - (in (f3 z))))} + {#.doc (example "Macro for easy concatenation of monadic operations." + (do monad + [y (f1 x) + z (f2 z)] + (in (f3 z))))} (case (: (Maybe [(Maybe Text) Code (List Code) Code]) (case tokens (^ (list [_ (#.Record (list [[_ (#.Identifier ["" name])] monad]))] [_ (#.Tuple bindings)] body)) @@ -75,11 +75,11 @@ (#.Some [?name monad bindings body]) (if (|> bindings list\size .int ("lux i64 %" +2) ("lux i64 =" +0)) (let [[module short] (name_of ..do) - gensym (: (-> Text Code) - (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [location.dummy])) - g!_ (gensym "_") - g!map (gensym "map") - g!join (gensym "join") + identifier (: (-> Text Code) + (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [location.dummy])) + g!_ (identifier "_") + g!map (identifier "map") + g!join (identifier "join") body' (list\fold (: (-> [Code Code] Code Code) (function (_ binding body') (with_expansions [<default> (` (|> (~ value) ((~ g!map) (function ((~ g!_) (~ var)) (~ body'))) (~ g!join)))] @@ -114,7 +114,7 @@ (#.Left "Wrong syntax for 'do'"))) (def: .public (bind monad f) - {#.doc (doc "Apply a function with monadic effects to a monadic value and yield a new monadic value.")} + {#.doc (example "Apply a function with monadic effects to a monadic value and yield a new monadic value.")} (All [! a b] (-> (Monad !) (-> a (! b)) (-> (! a) (! b)))) diff --git a/stdlib/source/library/lux/abstract/monad/indexed.lux b/stdlib/source/library/lux/abstract/monad/indexed.lux index 290db1419..2c2700f8d 100644 --- a/stdlib/source/library/lux/abstract/monad/indexed.lux +++ b/stdlib/source/library/lux/abstract/monad/indexed.lux @@ -62,7 +62,7 @@ (syntax: .public (do {[?name monad] ..named_monad} {context (<code>.tuple (<>.some context))} expression) - (macro.with_gensyms [g!_ g!bind] + (macro.with_identifiers [g!_ g!bind] (let [body (list\fold (function (_ context next) (case context (#Macro macro parameter) diff --git a/stdlib/source/library/lux/abstract/monoid.lux b/stdlib/source/library/lux/abstract/monoid.lux index 800a14c50..4e55a9a3b 100644 --- a/stdlib/source/library/lux/abstract/monoid.lux +++ b/stdlib/source/library/lux/abstract/monoid.lux @@ -3,8 +3,8 @@ [lux #*]]) (interface: .public (Monoid a) - {#.doc (doc "A way to compose values." - "Includes an identity value which does not alter any other value when combined with.")} + {#.doc (example "A way to compose values." + "Includes an identity value which does not alter any other value when combined with.")} (: a identity) (: (-> a a a) diff --git a/stdlib/source/library/lux/abstract/order.lux b/stdlib/source/library/lux/abstract/order.lux index 2dbd078e3..17bb2109d 100644 --- a/stdlib/source/library/lux/abstract/order.lux +++ b/stdlib/source/library/lux/abstract/order.lux @@ -19,37 +19,37 @@ ) (type: .public (Comparison a) - {#.doc (doc "An arbitrary comparison between two values, with the knowledge of how to order them.")} + {#.doc (example "An arbitrary comparison between two values, with the knowledge of how to order them.")} (-> (Order a) a a Bit)) (def: .public (<= order parameter subject) - {#.doc (doc "Less than or equal.")} + {#.doc (example "Less than or equal.")} Comparison (or (\ order < parameter subject) (\ order = parameter subject))) (def: .public (> order parameter subject) - {#.doc (doc "Greater than.")} + {#.doc (example "Greater than.")} Comparison (\ order < subject parameter)) (def: .public (>= order parameter subject) - {#.doc (doc "Greater than or equal.")} + {#.doc (example "Greater than or equal.")} Comparison (or (\ order < subject parameter) (\ order = subject parameter))) (type: .public (Choice a) - {#.doc (doc "A choice comparison between two values, with the knowledge of how to order them.")} + {#.doc (example "A choice comparison between two values, with the knowledge of how to order them.")} (-> (Order a) a a a)) (def: .public (min order x y) - {#.doc (doc "Minimum.")} + {#.doc (example "Minimum.")} Choice (if (\ order < y x) x y)) (def: .public (max order x y) - {#.doc (doc "Maximum.")} + {#.doc (example "Maximum.")} Choice (if (\ order < y x) y x)) diff --git a/stdlib/source/library/lux/abstract/predicate.lux b/stdlib/source/library/lux/abstract/predicate.lux index 625cd42ec..a3702c20c 100644 --- a/stdlib/source/library/lux/abstract/predicate.lux +++ b/stdlib/source/library/lux/abstract/predicate.lux @@ -9,7 +9,7 @@ ["." contravariant]]]) (type: .public (Predicate a) - {#.doc (doc "A question that can be asked of a value, yield either false (#0) or true (#1).")} + {#.doc (example "A question that can be asked of a value, yield either false (#0) or true (#1).")} (-> a Bit)) (template [<identity_name> <identity_value> <composition_name> <composition> @@ -27,11 +27,11 @@ (right value))))] [none #0 or .or - (doc "A predicate that always fails.") - (doc "A predicate that meets either predecessor.")] + (example "A predicate that always fails.") + (example "A predicate that meets either predecessor.")] [all #1 and .and - (doc "A predicate that always succeeds.") - (doc "A predicate that meets both predecessors.")] + (example "A predicate that always succeeds.") + (example "A predicate that meets both predecessors.")] ) (template [<name> <identity> <composition>] @@ -46,19 +46,19 @@ ) (def: .public (complement predicate) - {#.doc (doc "The opposite of a predicate.")} + {#.doc (example "The opposite of a predicate.")} (All [a] (-> (Predicate a) (Predicate a))) (|>> predicate not)) (def: .public (difference sub base) - {#.doc (doc "A predicate that meeds 'base', but not 'sub'.")} + {#.doc (example "A predicate that meeds 'base', but not 'sub'.")} (All [a] (-> (Predicate a) (Predicate a) (Predicate a))) (function (_ value) (.and (base value) (not (sub value))))) (def: .public (rec predicate) - {#.doc (doc "Ties the knot for a recursive predicate.")} + {#.doc (example "Ties the knot for a recursive predicate.")} (All [a] (-> (-> (Predicate a) (Predicate a)) (Predicate a))) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index 91dd6740d..554e6b21d 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -4,13 +4,14 @@ ["." meta] [abstract ["." monad]] + [control + ["." maybe ("#\." monad)]] [data - ["." maybe ("#\." monad)] ["." text ["%" format (#+ format)]] [collection ["." list ("#\." fold functor)]]] - ["." macro (#+ with_gensyms) + ["." macro (#+ with_identifiers) ["." code] ["." template] [syntax (#+ syntax:) @@ -71,15 +72,15 @@ (syntax: .public (=> {aliases aliases^} {inputs stack^} {outputs stack^}) - {#.doc (doc "Concatenative function types." - (=> [Nat] [Nat]) - (All [a] (-> a (=> [] [a]))) - (All [t] (=> [t] [])) - (All [a b c] (=> [a b c] [b c a])) - (All [___a ___z] - (=> {then (=> ___a ___z) - else (=> ___a ___z)} - ___a [Bit then else] ___z)))} + {#.doc (example "Concatenative function types." + (=> [Nat] [Nat]) + (All [a] (-> a (=> [] [a]))) + (All [t] (=> [t] [])) + (All [a b c] (=> [a b c] [b c a])) + (All [___a ___z] + (=> {then (=> ___a ___z) + else (=> ___a ___z)} + ___a [Bit then else] ___z)))} (let [de_alias (function (_ aliased) (list\fold (function (_ [from to] pre) (code.replaced (code.local_identifier from) to pre)) @@ -95,7 +96,7 @@ (~ (de_alias outputC))))))) [?bottomI ?bottomO] - (with_gensyms [g!stack] + (with_identifiers [g!stack] (monad.do meta.monad [inputC (singleton (macro.full_expansion (stack_fold (get@ #top inputs) (maybe.else g!stack ?bottomI)))) outputC (singleton (macro.full_expansion (stack_fold (get@ #top outputs) (maybe.else g!stack ?bottomO))))] @@ -111,13 +112,13 @@ top)) (syntax: .public (||> {commands (<>.some <code>.any)}) - {#.doc (doc "A self-contained sequence of concatenative instructions." - (is? value - (||> (..push sample))) + {#.doc (example "A self-contained sequence of concatenative instructions." + (is? value + (||> (..push sample))) - (||> (push 123) - dup - n/=))} + (||> (push 123) + dup + n/=))} (in (list (` (|> (~! ..begin!) (~+ commands) ((~! ..end!))))))) (def: word @@ -135,24 +136,24 @@ (syntax: .public (word: {[export_policy name annotations type commands] ..word}) - {#.doc (doc "A named concatenative function." - (word: square - (=> [Nat] [Nat]) + {#.doc (example "A named concatenative function." + (word: square + (=> [Nat] [Nat]) - dup - (apply/2 n.*)))} + dup + (apply/2 n.*)))} (in (list (` (def: (~ export_policy) (~ (code.local_identifier name)) (~ (|annotations|.format annotations)) (~ type) (|>> (~+ commands))))))) (syntax: .public (apply {arity (<>.only (n.> 0) <code>.nat)}) - {#.doc (doc "A generator for functions that turn arity N functions into arity N concatenative functions." - (: (=> [Nat] [Nat]) - ((apply 1) inc)))} - (with_gensyms [g! g!func g!stack g!output] + {#.doc (example "A generator for functions that turn arity N functions into arity N concatenative functions." + (: (=> [Nat] [Nat]) + ((apply 1) inc)))} + (with_identifiers [g! g!func g!stack g!output] (monad.do {! meta.monad} - [g!inputs (|> (macro.gensym "input") (list.repeated arity) (monad.seq !))] + [g!inputs (|> (macro.identifier "input") (list.repeated arity) (monad.seq !))] (in (list (` (: (All [(~+ g!inputs) (~ g!output)] (-> (-> (~+ g!inputs) (~ g!output)) (=> [(~+ g!inputs)] [(~ g!output)]))) @@ -165,7 +166,7 @@ <doc> (template.text ["Lift a function of arity " <arity> " into a concatenative function of arity " <arity> "."])] (def: .public <name> - {#.doc (doc <doc>)} + {#.doc (example <doc>)} (apply <arity>)))] [1] [2] [3] [4] @@ -173,68 +174,68 @@ ) (def: .public (push x) - {#.doc (doc "Push a value onto the stack.")} + {#.doc (example "Push a value onto the stack.")} (All [a] (-> a (=> [] [a]))) (function (_ stack) [stack x])) (def: .public drop - {#.doc (doc "Drop/pop a value from the top of the stack.")} + {#.doc (example "Drop/pop a value from the top of the stack.")} (All [t] (=> [t] [])) (function (_ [stack top]) stack)) (def: .public nip - {#.doc (doc "Drop the second-to-last value from the top of the stack.")} + {#.doc (example "Drop the second-to-last value from the top of the stack.")} (All [_ a] (=> [_ a] [a])) (function (_ [[stack _] top]) [stack top])) (def: .public dup - {#.doc (doc "Duplicate the top of the stack.")} + {#.doc (example "Duplicate the top of the stack.")} (All [a] (=> [a] [a a])) (function (_ [stack top]) [[stack top] top])) (def: .public swap - {#.doc (doc "Swaps the 2 topmost stack values.")} + {#.doc (example "Swaps the 2 topmost stack values.")} (All [a b] (=> [a b] [b a])) (function (_ [[stack l] r]) [[stack r] l])) (def: .public rotL - {#.doc (doc "Rotes the 3 topmost stack values to the left.")} + {#.doc (example "Rotes the 3 topmost stack values to the left.")} (All [a b c] (=> [a b c] [b c a])) (function (_ [[[stack a] b] c]) [[[stack b] c] a])) (def: .public rotR - {#.doc (doc "Rotes the 3 topmost stack values to the right.")} + {#.doc (example "Rotes the 3 topmost stack values to the right.")} (All [a b c] (=> [a b c] [c a b])) (function (_ [[[stack a] b] c]) [[[stack c] a] b])) (def: .public && - {#.doc (doc "Groups the 2 topmost stack values as a 2-tuple.")} + {#.doc (example "Groups the 2 topmost stack values as a 2-tuple.")} (All [a b] (=> [a b] [(Tuple a b)])) (function (_ [[stack l] r]) [stack [l r]])) (def: .public ||L - {#.doc (doc "Left-injects the top into sum.")} + {#.doc (example "Left-injects the top into sum.")} (All [a b] (=> [a] [(Or a b)])) (function (_ [stack l]) [stack (0 #0 l)])) (def: .public ||R - {#.doc (doc "Right-injects the top into sum.")} + {#.doc (example "Right-injects the top into sum.")} (All [a b] (=> [b] [(Or a b)])) (function (_ [stack r]) [stack (0 #1 r)])) (template [<input> <output> <word> <func>] [(`` (def: .public <word> - {#.doc (doc (~~ (template.text [<func> " for " <input> " arithmetic."])))} + {#.doc (example (~~ (template.text [<func> " for " <input> " arithmetic."])))} (=> [<input> <input>] [<output>]) (function (_ [[stack subject] param]) [stack (<func> param subject)])))] @@ -285,12 +286,12 @@ ) (def: .public if - {#.doc (doc "If expression." - (is? "then" - (||> (push true) - (push "then") - (push "else") - if)))} + {#.doc (example "If expression." + (is? "then" + (||> (push true) + (push "then") + (push "else") + if)))} (All [___a ___z] (=> {then (=> ___a ___z) else (=> ___a ___z)} @@ -301,7 +302,7 @@ (else stack)))) (def: .public call - {#.doc (doc "Executes an anonymous block on the stack.")} + {#.doc (example "Executes an anonymous block on the stack.")} (All [___a ___z] (=> {quote (=> ___a ___z)} ___a [quote] ___z)) @@ -309,7 +310,7 @@ (quote stack))) (def: .public loop - {#.doc (doc "Executes a block as a loop until it yields #0 to stop.")} + {#.doc (example "Executes a block as a loop until it yields #0 to stop.")} (All [___] (=> {test (=> ___ ___ [Bit])} ___ [test] ___)) @@ -320,7 +321,7 @@ stack')))) (def: .public dip - {#.doc (doc "Executes a block on the stack, save for the topmost value.")} + {#.doc (example "Executes a block on the stack, save for the topmost value.")} (All [___ a] (=> ___ [a (=> ___ ___)] ___ [a])) @@ -328,7 +329,7 @@ [(quote stack) a])) (def: .public dip/2 - {#.doc (doc "Executes a block on the stack, save for the 2 topmost values.")} + {#.doc (example "Executes a block on the stack, save for the 2 topmost values.")} (All [___ a b] (=> ___ [a b (=> ___ ___)] ___ [a b])) @@ -336,12 +337,12 @@ [[(quote stack) a] b])) (def: .public do - {#.doc (doc "Do-while loop expression." - (n.= (inc sample) - (||> (push sample) - (push (push false)) - (push (|>> (push 1) n/+)) - do while)))} + {#.doc (example "Do-while loop expression." + (n.= (inc sample) + (||> (push sample) + (push (push false)) + (push (|>> (push 1) n/+)) + do while)))} (All [___a ___z] (=> {body (=> ___a ___z) pred (=> ___z ___a [Bit])} @@ -351,14 +352,14 @@ [[(body stack) pred] body])) (def: .public while - {#.doc (doc "While loop expression." - (n.= (n.+ distance start) - (||> (push start) - (push (|>> dup - (push start) n/- - (push distance) n/<)) - (push (|>> (push 1) n/+)) - while)))} + {#.doc (example "While loop expression." + (n.= (n.+ distance start) + (||> (push start) + (push (|>> dup + (push start) n/- + (push distance) n/<)) + (push (|>> (push 1) n/+)) + while)))} (All [___a ___z] (=> {body (=> ___z ___a) pred (=> ___a ___z [Bit])} @@ -371,13 +372,13 @@ stack')))) (def: .public compose - {#.doc (doc "Function composition." - (n.= (n.+ 2 sample) - (||> (push sample) - (push (|>> (push 1) n/+)) - (push (|>> (push 1) n/+)) - compose - call)))} + {#.doc (example "Function composition." + (n.= (n.+ 2 sample) + (||> (push sample) + (push (|>> (push 1) n/+)) + (push (|>> (push 1) n/+)) + compose + call)))} (All [___a ___ ___z] (=> [(=> ___a ___) (=> ___ ___z)] [(=> ___a ___z)])) @@ -385,13 +386,13 @@ [stack (|>> f g)])) (def: .public partial - {#.doc (doc "Partial application." - (n.= (n.+ sample sample) - (||> (push sample) - (push sample) - (push n/+) - partial - call)))} + {#.doc (example "Partial application." + (n.= (n.+ sample sample) + (||> (push sample) + (push sample) + (push n/+) + partial + call)))} (All [___a ___z a] (=> ___a [a (=> ___a [a] ___z)] ___a [(=> ___a ___z)])) @@ -399,7 +400,7 @@ [stack (|>> (push arg) quote)])) (word: .public when - {#.doc (doc "Only execute the block when #1.")} + {#.doc (example "Only execute the block when #1.")} (All [___] (=> {body (=> ___ ___)} ___ [Bit body] @@ -410,7 +411,7 @@ if) (word: .public ? - {#.doc (doc "Choose the top value when #0 and the second-to-top when #1.")} + {#.doc (example "Choose the top value when #0 and the second-to-top when #1.")} (All [a] (=> [Bit a a] [a])) rotL diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index ee3a1e5d3..84d41564c 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -20,7 +20,7 @@ ["%" format (#+ format)]] [collection ["." list ("#\." monoid monad fold)]]] - ["." macro (#+ with_gensyms) + ["." macro (#+ with_identifiers) ["." code] [syntax (#+ syntax:) ["|.|" input] @@ -64,27 +64,27 @@ (in #.End)))) (abstract: .public (Actor s) - {#.doc (doc "An entity that can react to messages (mail) sent to it concurrently.")} + {#.doc (example "An entity that can react to messages (mail) sent to it concurrently.")} {#obituary [(Async <Obituary>) (Resolver <Obituary>)] #mailbox (Atom <Mailbox>)} (type: .public (Mail s) - {#.doc (doc "A one-way message sent to an actor, without expecting a reply.")} + {#.doc (example "A one-way message sent to an actor, without expecting a reply.")} <Mail>) (type: .public (Obituary s) - {#.doc (doc "Details on the death of an actor.")} + {#.doc (example "Details on the death of an actor.")} <Obituary>) (type: .public (Behavior o s) - {#.doc (doc "An actor's behavior when mail is received and when a fatal error occurs.")} + {#.doc (example "An actor's behavior when mail is received and when a fatal error occurs.")} {#on_init (-> o s) #on_mail (-> (Mail s) s (Actor s) (Async (Try s)))}) (def: .public (spawn! behavior init) - {#.doc (doc "Given a behavior and initial state, spawns an actor and returns it.")} + {#.doc (example "Given a behavior and initial state, spawns an actor and returns it.")} (All [o s] (-> (Behavior o s) o (IO (Actor s)))) (io (let [[on_init on_mail] behavior self (:sharing [o s] @@ -95,14 +95,14 @@ (:abstraction {#obituary (async.async []) #mailbox (atom (async.async []))})) process (loop [state (on_init init) - [|mailbox| _] (io.run (atom.read! (get@ #mailbox (:representation self))))] + [|mailbox| _] (io.run! (atom.read! (get@ #mailbox (:representation self))))] (do {! async.monad} [[head tail] |mailbox| ?state' (on_mail head state self)] (case ?state' (#try.Failure error) (let [[_ resolve] (get@ #obituary (:representation self))] - (exec (io.run + (exec (io.run! (do io.monad [pending (..pending tail)] (resolve [error state (#.Item head pending)]))) @@ -130,14 +130,14 @@ (async.poll obituary))) (def: .public obituary - {#.doc (doc "Await for an actor to stop working.")} + {#.doc (example "Await for an actor to stop working.")} (All [s] (-> (Actor s) (Async (Obituary s)))) (|>> :representation (get@ #obituary) product.left)) (def: .public (mail! mail actor) - {#.doc (doc "Send mail to an actor.")} + {#.doc (example "Send mail to an actor.")} (All [s] (-> (Mail s) (Actor s) (IO (Try Any)))) (do {! io.monad} [alive? (..alive? actor)] @@ -163,7 +163,7 @@ (in (exception.except ..dead []))))) (type: .public (Message s o) - {#.doc (doc "A two-way message sent to an actor, expecting a reply.")} + {#.doc (example "A two-way message sent to an actor, expecting a reply.")} (-> s (Actor s) (Async (Try [s o])))) (def: (mail message) @@ -181,15 +181,17 @@ [outcome (message state self)] (case outcome (#try.Success [state' return]) - (exec (io.run (resolve (#try.Success return))) + (exec + (io.run! (resolve (#try.Success return))) (async.resolved (#try.Success state'))) (#try.Failure error) - (exec (io.run (resolve (#try.Failure error))) + (exec + (io.run! (resolve (#try.Failure error))) (async.resolved (#try.Failure error))))))])) (def: .public (tell! message actor) - {#.doc (doc "Communicate with an actor through message-passing.")} + {#.doc (example "Communicate with an actor through message-passing.")} (All [s o] (-> (Message s o) (Actor s) (Async (Try o)))) (let [[async mail] (..mail message)] (do async.monad @@ -208,14 +210,14 @@ (mail state self)) (def: .public default - {#.doc (doc "Default actor behavior.")} + {#.doc (example "Default actor behavior.")} (All [s] (Behavior s s)) {#on_init function.identity #on_mail ..default_on_mail}) (def: .public (poison! actor) - {#.doc (doc "Kills the actor by sending mail that will kill it upon processing," - "but allows the actor to handle previous mail.")} + {#.doc (example "Kills the actor by sending mail that will kill it upon processing," + "but allows the actor to handle previous mail.")} (All [s] (-> (Actor s) (IO (Try Any)))) (..mail! (function (_ state self) (async.resolved (exception.except ..poisoned []))) @@ -300,12 +302,12 @@ (async.resolved (#try.Success [state state])))))] (syntax: .public (actor: {[export_policy [name vars] annotations state_type [?on_mail messages]] ..actorP}) - {#.doc (doc "Defines a named actor, with its behavior and internal state." - "Messages for the actor must be defined after the on_mail handler." - <examples>)} - (with_gensyms [g!_] + {#.doc (example "Defines a named actor, with its behavior and internal state." + "Messages for the actor must be defined after the on_mail handler." + <examples>)} + (with_identifiers [g!_] (do meta.monad - [g!type (macro.gensym (format name "_abstract_type")) + [g!type (macro.identifier (format name "_abstract_type")) .let [g!actor (code.local_identifier name) g!vars (list\map code.local_identifier vars)]] (in (list (` ((~! abstract:) (~ export_policy) ((~ g!type) (~+ g!vars)) @@ -323,13 +325,13 @@ (syntax: .public (actor {[state_type init] (<code>.record (<>.and <code>.any <code>.any))} {[?on_mail messages] behavior^}) - {#.doc (doc "Defines an anonymous actor, with its behavior and internal state." - "Messages for the actor must be defined after the on_mail handler." - (actor {Nat - 123} - ((on_mail message state self) - (message (inc state) self))))} - (with_gensyms [g!_] + {#.doc (example "Defines an anonymous actor, with its behavior and internal state." + "Messages for the actor must be defined after the on_mail handler." + (actor {Nat + 123} + ((on_mail message state self) + (message (inc state) self))))} + (with_identifiers [g!_] (in (list (` (: ((~! io.IO) (..Actor (~ state_type))) (..spawn! (: (..Behavior (~ state_type) (~ state_type)) {#..on_init (|>>) @@ -371,13 +373,13 @@ (syntax: .public (message: {[export_policy signature annotations output_type body] ..messageP}) - {#.doc (doc "A message can access the actor's state through the state parameter." - "A message can also access the actor itself through the self parameter." - "A message's output must be an async containing a 2-tuple with the updated state and a return value." - "A message may succeed or fail (in case of failure, the actor dies)." + {#.doc (example "A message can access the actor's state through the state parameter." + "A message can also access the actor itself through the self parameter." + "A message's output must be an async containing a 2-tuple with the updated state and a return value." + "A message may succeed or fail (in case of failure, the actor dies)." - <examples>)} - (with_gensyms [g!_ g!return] + <examples>)} + (with_identifiers [g!_ g!return] (do meta.monad [actor_scope abstract.current .let [g!type (code.local_identifier (get@ #abstract.name actor_scope)) @@ -405,16 +407,16 @@ )))))) (type: .public Stop - {#.doc (doc "A signal to stop an actor from observing a channel.")} + {#.doc (example "A signal to stop an actor from observing a channel.")} (IO Any)) (def: continue! true) (def: stop! false) (def: .public (observe! action channel actor) - {#.doc (doc "Use an actor to observe a channel by transforming each datum" - "flowing through the channel into mail the actor can process." - "Can stop observing the channel by executing the Stop value.")} + {#.doc (example "Use an actor to observe a channel by transforming each datum" + "flowing through the channel into mail the actor can process." + "Can stop observing the channel by executing the Stop value.")} (All [e s] (-> (-> e Stop (Mail s)) (Channel e) (Actor s) (IO Any))) (let [signal (: (Atom Bit) (atom.atom ..continue!)) diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index 72736ef94..35ab37cac 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -23,8 +23,8 @@ (Atom [(Maybe a) (List (-> a (IO Any)))]) (type: .public (Resolver a) - {#.doc (doc "The function used to give a value to an async." - "Will signal 'true' if the async has been resolved for the 1st time, 'false' otherwise.")} + {#.doc (example "The function used to give a value to an async." + "Will signal 'true' if the async has been resolved for the 1st time, 'false' otherwise.")} (-> a (IO Bit))) (def: (resolver async) @@ -50,12 +50,12 @@ (resolve value)))))))) (def: .public (resolved value) - {#.doc (doc "Produces an async that has already been resolved to the given value.")} + {#.doc (example "Produces an async that has already been resolved to the given value.")} (All [a] (-> a (Async a))) (:abstraction (atom [(#.Some value) (list)]))) (def: .public (async _) - {#.doc (doc "Creates a fresh async that has not been resolved yet.")} + {#.doc (example "Creates a fresh async that has not been resolved yet.")} (All [a] (-> Any [(Async a) (Resolver a)])) (let [async (:abstraction (atom [#.None (list)]))] [async (..resolver async)])) @@ -68,7 +68,7 @@ (\ io.functor map product.left))) (def: .public (upon! f async) - {#.doc (doc "Executes the given function as soon as the async has been resolved.")} + {#.doc (example "Executes the given function as soon as the async has been resolved.")} (All [a] (-> (-> a (IO Any)) (Async a) (IO Any))) (do {! io.monad} [.let [async (:representation async)] @@ -102,7 +102,8 @@ (def: (map f fa) (let [[fb resolve] (..async [])] - (exec (io.run (..upon! (|>> f resolve) fa)) + (exec + (io.run! (..upon! (|>> f resolve) fa)) fb)))) (implementation: .public apply @@ -112,9 +113,10 @@ (def: (apply ff fa) (let [[fb resolve] (..async [])] - (exec (io.run (..upon! (function (_ f) - (..upon! (|>> f resolve) fa)) - ff)) + (exec + (io.run! (..upon! (function (_ f) + (..upon! (|>> f resolve) fa)) + ff)) fb)))) (implementation: .public monad @@ -126,11 +128,12 @@ (def: (join mma) (let [[ma resolve] (async [])] - (exec (io.run (..upon! (..upon! resolve) mma)) + (exec + (io.run! (..upon! (..upon! resolve) mma)) ma)))) (def: .public (and left right) - {#.doc (doc "Combines the results of both asyncs, in-order.")} + {#.doc (example "Combines the results of both asyncs, in-order.")} (All [a b] (-> (Async a) (Async b) (Async [a b]))) (let [[read! write!] (:sharing [a b] [(Async a) (Async b)] @@ -139,55 +142,58 @@ [(Async [a b]) (Resolver [a b])] (..async [])) - _ (io.run (..upon! (function (_ left) - (..upon! (function (_ right) - (write! [left right])) - right)) - left))] + _ (io.run! (..upon! (function (_ left) + (..upon! (function (_ right) + (write! [left right])) + right)) + left))] read!)) (def: .public (or left right) - {#.doc (doc "Yields the results of whichever async gets resolved first." - "You can tell which one was resolved first through pattern-matching.")} + {#.doc (example "Yields the results of whichever async gets resolved first." + "You can tell which one was resolved first through pattern-matching.")} (All [a b] (-> (Async a) (Async b) (Async (Or a b)))) (let [[a|b resolve] (..async [])] (with_expansions [<sides> (template [<async> <tag>] - [(io.run (upon! (|>> <tag> resolve) <async>))] + [(io.run! (upon! (|>> <tag> resolve) <async>))] [left #.Left] [right #.Right] )] - (exec <sides> + (exec + <sides> a|b)))) (def: .public (either left right) - {#.doc (doc "Yields the results of whichever async gets resolved first." - "You cannot tell which one was resolved first.")} + {#.doc (example "Yields the results of whichever async gets resolved first." + "You cannot tell which one was resolved first.")} (All [a] (-> (Async a) (Async a) (Async a))) (let [[left||right resolve] (..async [])] - (`` (exec (~~ (template [<async>] - [(io.run (upon! resolve <async>))] + (`` (exec + (~~ (template [<async>] + [(io.run! (upon! resolve <async>))] - [left] - [right])) + [left] + [right])) left||right)))) (def: .public (schedule! millis_delay computation) - {#.doc (doc "Runs an I/O computation on its own thread (after a specified delay)." - "Returns an async that will eventually host its result.")} + {#.doc (example "Runs an I/O computation on its own thread (after a specified delay)." + "Returns an async that will eventually host its result.")} (All [a] (-> Nat (IO a) (Async a))) (let [[!out resolve] (..async [])] - (exec (|> (do io.monad - [value computation] - (resolve value)) - (thread.schedule! millis_delay) - io.run) + (exec + (|> (do io.monad + [value computation] + (resolve value)) + (thread.schedule! millis_delay) + io.run!) !out))) (def: .public future - {#.doc (doc "Runs an I/O computation on its own thread." - "Returns an async that will eventually host its result.")} + {#.doc (example "Runs an I/O computation on its own thread." + "Returns an async that will eventually host its result.")} (All [a] (-> (IO a) (Async a))) (..schedule! 0)) diff --git a/stdlib/source/library/lux/control/concurrency/atom.lux b/stdlib/source/library/lux/control/concurrency/atom.lux index a607fa8d3..0f42393ee 100644 --- a/stdlib/source/library/lux/control/concurrency/atom.lux +++ b/stdlib/source/library/lux/control/concurrency/atom.lux @@ -7,7 +7,7 @@ [monad (#+ do)]] [control ["." function] - ["." io (#- run) ("#\." functor)]] + ["." io (#+ IO) ("#\." functor)]] [data ["." product] [collection @@ -63,29 +63,29 @@ (def: .public (read! atom) (All [a] (-> (Atom a) (IO a))) - (io (with_expansions [<jvm> (java/util/concurrent/atomic/AtomicReference::get (:representation atom))] - (for {@.old <jvm> - @.jvm <jvm>} - (<read> 0 (:representation atom)))))) + (io.io (with_expansions [<jvm> (java/util/concurrent/atomic/AtomicReference::get (:representation atom))] + (for {@.old <jvm> + @.jvm <jvm>} + (<read> 0 (:representation atom)))))) (def: .public (compare_and_swap! current new atom) - {#.doc (doc "Only mutates an atom if you can present its current value." - "That guarantees that atom was not updated since you last read from it.")} + {#.doc (example "Only mutates an atom if you can present its current value." + "That guarantees that atom was not updated since you last read from it.")} (All [a] (-> a a (Atom a) (IO Bit))) - (io (with_expansions [<jvm> (java/util/concurrent/atomic/AtomicReference::compareAndSet current new (:representation atom))] - (for {@.old <jvm> - @.jvm <jvm>} - (let [old (<read> 0 (:representation atom))] - (if (is? old current) - (exec (<write> 0 new (:representation atom)) - true) - false)))))) + (io.io (with_expansions [<jvm> (java/util/concurrent/atomic/AtomicReference::compareAndSet current new (:representation atom))] + (for {@.old <jvm> + @.jvm <jvm>} + (let [old (<read> 0 (:representation atom))] + (if (is? old current) + (exec (<write> 0 new (:representation atom)) + true) + false)))))) )) (def: .public (update! f atom) - {#.doc (doc "Updates an atom by applying a function to its current value." - "If it fails to update it (because some other process wrote to it first), it will retry until it succeeds." - "The retries will be done with the new values of the atom, as they show up.")} + {#.doc (example "Updates an atom by applying a function to its current value." + "If it fails to update it (because some other process wrote to it first), it will retry until it succeeds." + "The retries will be done with the new values of the atom, as they show up.")} (All [a] (-> (-> a a) (Atom a) (IO [a a]))) (loop [_ []] (do io.monad @@ -97,8 +97,8 @@ (recur []))))) (def: .public (write! value atom) - {#.doc (doc "Writes the given value to an atom." - "If it fails to write it (because some other process wrote to it first), it will retry until it succeeds.")} + {#.doc (example "Writes the given value to an atom." + "If it fails to write it (because some other process wrote to it first), it will retry until it succeeds.")} (All [a] (-> a (Atom a) (IO a))) (|> atom (..update! (function.constant value)) diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index 7d22b5924..32cc8118a 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -7,11 +7,10 @@ [apply (#+ Apply)] ["." monad (#+ Monad do)]] [control + ["." maybe ("#\." functor)] ["." try (#+ Try)] ["." exception (#+ exception:)] ["." io (#+ IO io)]] - [data - ["." maybe ("#\." functor)]] [type (#+ :sharing) abstract]]] [// @@ -25,7 +24,7 @@ (exception: .public channel_is_already_closed) (interface: .public (Sink a) - {#.doc (doc "The tail-end of a channel, which can be written-to to fee the channel.")} + {#.doc (example "The tail-end of a channel, which can be written-to to fee the channel.")} (: (IO (Try Any)) close) (: (-> a (IO (Try Any))) @@ -81,7 +80,7 @@ (recur [])))))))))) (def: .public (channel _) - {#.doc (doc "Creates a brand-new channel and hands it over, along with the sink to write to it.")} + {#.doc (example "Creates a brand-new channel and hands it over, along with the sink to write to it.")} (All [a] (-> Any [(Channel a) (Sink a)])) (let [[async resolve] (async.async [])] [async (..sink resolve)])) @@ -137,7 +136,7 @@ [?ma ma] (case ?ma (#.Some [a ma']) - (exec (io.run (\ sink feed a)) + (exec (io.run! (\ sink feed a)) (recur ma')) #.None @@ -145,11 +144,11 @@ (recur mma')) #.None - (in (: Any (io.run (\ sink close)))))))) + (in (: Any (io.run! (\ sink close)))))))) output)))) (type: .public (Subscriber a) - {#.doc (doc "A function that can receive every value fed into a channel.")} + {#.doc (example "A function that can receive every value fed into a channel.")} (-> a (IO (Maybe Any)))) (def: .public (subscribe subscriber channel) @@ -160,7 +159,7 @@ [item channel] (case item (#.Some [head tail]) - (case (io.run (subscriber head)) + (case (io.run! (subscriber head)) (#.Some _) (recur tail) @@ -172,8 +171,8 @@ []))) (def: .public (only pass? channel) - {#.doc (doc "Produces a new channel based on the old one, only with values" - "that pass the test.")} + {#.doc (example "Produces a new channel based on the old one, only with values" + "that pass the test.")} (All [a] (-> (-> a Bit) (Channel a) (Channel a))) (do async.monad [item channel] @@ -188,7 +187,7 @@ (in #.None)))) (def: .public (of_async async) - {#.doc (doc "A one-element channel containing the output from an async.")} + {#.doc (example "A one-element channel containing the output from an async.")} (All [a] (-> (Async a) (Channel a))) (async\map (function (_ value) (#.Some [value ..empty])) @@ -229,11 +228,11 @@ (All [a] (-> Nat (IO a) [(Channel a) (Sink a)])) (let [[output sink] (channel [])] - (exec (io.run (loop [_ []] - (do io.monad - [value action - _ (\ sink feed value)] - (async.upon! recur (async.delay milli_seconds))))) + (exec (io.run! (loop [_ []] + (do io.monad + [value action + _ (\ sink feed value)] + (async.upon! recur (async.delay milli_seconds))))) [output sink]))) (def: .public (periodic milli_seconds) @@ -288,7 +287,7 @@ (in #.End)))) (def: .public (sequential milli_seconds values) - {#.doc (doc "Transforms the given list into a channel with the same elements.")} + {#.doc (example "Transforms the given list into a channel with the same elements.")} (All [a] (-> Nat (List a) (Channel a))) (case values #.End diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index 046651c1b..06bb81b4e 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -46,13 +46,13 @@ #waiting_list queue.empty})))) (def: .public (wait semaphore) - {#.doc (doc "Wait on a semaphore until there are open positions." - "After finishing your work, you must 'signal' to the semaphore that you're done.")} + {#.doc (example "Wait on a semaphore until there are open positions." + "After finishing your work, you must 'signal' to the semaphore that you're done.")} (Ex [k] (-> Semaphore (Async Any))) (let [semaphore (:representation semaphore) [signal sink] (: [(Async Any) (Resolver Any)] (async.async []))] - (exec (io.run + (exec (io.run! (with_expansions [<had_open_position?> (as_is (get@ #open_positions) (i.> -1))] (do io.monad [[_ state'] (atom.update! (|>> (update@ #open_positions dec) @@ -72,7 +72,7 @@ ["Max Positions" (%.nat max_positions)])) (def: .public (signal semaphore) - {#.doc (doc "Signal to a semaphore that you're done with your work, and that there is a new open position.")} + {#.doc (example "Signal to a semaphore that you're done with your work, and that there is a new open position.")} (Ex [k] (-> Semaphore (Async (Try Int)))) (let [semaphore (:representation semaphore)] (async.future @@ -103,7 +103,7 @@ Semaphore (def: .public (mutex _) - {#.doc (doc "Creates a brand-new mutex.")} + {#.doc (example "Creates a brand-new mutex.")} (-> Any Mutex) (:abstraction (semaphore 1))) @@ -116,21 +116,21 @@ (|>> :representation ..signal)) (def: .public (synchronize mutex procedure) - {#.doc (doc "Runs the procedure with exclusive control of the mutex.")} + {#.doc (example "Runs the procedure with exclusive control of the mutex.")} (All [a] (-> Mutex (IO (Async a)) (Async a))) (do async.monad [_ (..acquire mutex) - output (io.run procedure) + output (io.run! procedure) _ (..release mutex)] (in output))) ) (def: .public limit - {#.doc (doc "Produce a limit for a barrier.")} + {#.doc (example "Produce a limit for a barrier.")} (refinement.refiner (n.> 0))) (type: .public Limit - {#.doc (doc "A limit for barriers.")} + {#.doc (example "A limit for barriers.")} (:~ (refinement.type limit))) (abstract: .public Barrier @@ -163,7 +163,7 @@ (do async.monad [.let [limit (refinement.value (get@ #limit barrier)) goal <goal> - [_ count] (io.run (atom.update! <update> (get@ #count barrier))) + [_ count] (io.run! (atom.update! <update> (get@ #count barrier))) reached? (n.= goal count)]] (if reached? (..un_block (dec limit) (get@ <turnstile> barrier)) @@ -174,7 +174,7 @@ ) (def: .public (block barrier) - {#.doc (doc "Wait on a barrier until all processes have arrived and met the barrier's limit.")} + {#.doc (example "Wait on a barrier until all processes have arrived and met the barrier's limit.")} (-> Barrier (Async Any)) (do async.monad [_ (..start barrier)] diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux index 1ad5d9ac0..321e8bfa8 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -7,10 +7,10 @@ ["." monad (#+ Monad do)]] [control ["." io (#+ IO io)] + ["." maybe] ["." try]] [data ["." product] - ["." maybe] [collection ["." list]]] [type @@ -35,7 +35,7 @@ (def: read! (All [a] (-> (Var a) a)) - (|>> :representation atom.read! io.run product.left)) + (|>> :representation atom.read! io.run! product.left)) (def: (un_follow sink var) (All [a] (-> (Sink a) (Var a) (IO Any))) @@ -262,12 +262,12 @@ ))) (def: .public (commit stm_proc) - {#.doc (doc "Commits a transaction and returns its result (asynchronously)." - "Note that a transaction may be re-run an indeterminate number of times if other transactions involving the same variables successfully commit first." - "For this reason, it's important to note that transactions must be free from side-effects, such as I/O.")} + {#.doc (example "Commits a transaction and returns its result (asynchronously)." + "Note that a transaction may be re-run an indeterminate number of times if other transactions involving the same variables successfully commit first." + "For this reason, it's important to note that transactions must be free from side-effects, such as I/O.")} (All [a] (-> (STM a) (Async a))) (let [[output resolver] (async.async [])] - (exec (io.run (do io.monad - [_ init_processor!] - (issue_commit [stm_proc output resolver]))) + (exec (io.run! (do io.monad + [_ init_processor!] + (issue_commit [stm_proc output resolver]))) output))) diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index 767107af7..6d47059b0 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -65,7 +65,7 @@ )) (def: .public parallelism - {#.doc (doc "How many processes can run in parallel.")} + {#.doc (example "How many processes can run in parallel.")} Nat (with_expansions [<jvm> (|> (java/lang/Runtime::getRuntime) (java/lang/Runtime::availableProcessors) @@ -90,7 +90,7 @@ (def: (execute! action) (-> (IO Any) Any) - (case (try (io.run action)) + (case (try (io.run! action)) (#try.Failure error) (exec ("lux io log" ($_ "lux text concat" @@ -102,7 +102,7 @@ [])) (def: .public (schedule! milli_seconds action) - {#.doc (doc "Executes an I/O procedure after some milli-seconds.")} + {#.doc (example "Executes an I/O procedure after some milli-seconds.")} (-> Nat (IO Any) (IO Any)) (with_expansions [<jvm> (as_is (let [runnable (ffi.object [] [java/lang/Runnable] [] @@ -146,7 +146,7 @@ ... https://en.wikipedia.org/wiki/Event_loop (def: .public run! - {#.doc (doc "Starts the event-loop.")} + {#.doc (example "Starts the event-loop.")} (IO Any) (loop [_ []] (do {! io.monad} @@ -169,6 +169,6 @@ (do ! [_ (monad.map ! (|>> (get@ #action) ..execute! io.io) ready)] (recur [])) - (error! (exception.error ..cannot_continue_running_threads [])))) + (panic! (exception.error ..cannot_continue_running_threads [])))) )))) )) diff --git a/stdlib/source/library/lux/control/continuation.lux b/stdlib/source/library/lux/control/continuation.lux index ef0392fe9..7a46ed8a7 100644 --- a/stdlib/source/library/lux/control/continuation.lux +++ b/stdlib/source/library/lux/control/continuation.lux @@ -9,7 +9,7 @@ ["." function] [parser ["s" code]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code]]]]) @@ -22,7 +22,7 @@ (All [i o] (-> (-> i o) (Cont i o) o)) (cont next)) -(def: .public (run cont) +(def: .public (result cont) {#.doc "Forces a continuation thunk to be evaluated."} (All [a] (-> (Cont a a) a)) (cont function.identity)) @@ -38,15 +38,15 @@ k))) (syntax: .public (pending expr) - {#.doc (doc "Turns any expression into a function that is pending a continuation." - (pending (some_function some_input)))} - (with_gensyms [g!_ g!k] + {#.doc (example "Turns any expression into a function that is pending a continuation." + (pending (some_function some_input)))} + (with_identifiers [g!_ g!k] (in (list (` (.function ((~ g!_) (~ g!k)) ((~ g!k) (~ expr)))))))) (def: .public (reset scope) (All [i o] (-> (Cont i i) (Cont i o))) (function (_ k) - (k (run scope)))) + (k (result scope)))) (def: .public (shift f) (All [a] diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index 1edd4bc04..ee5fd753a 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -7,10 +7,10 @@ [abstract [monad (#+ do)]] [control + ["." maybe] ["<>" parser ("#\." monad) ["<.>" code (#+ Parser)]]] [data - ["." maybe] ["." product] ["." text ("#\." monoid)] [collection @@ -33,13 +33,13 @@ #constructor (-> a Text)}) (def: .public (match? exception error) - {#.doc (doc "Is this exception the cause of the error message?")} + {#.doc (example "Is this exception the cause of the error message?")} (All [e] (-> (Exception e) Text Bit)) (text.starts_with? (get@ #label exception) error)) (def: .public (when exception then try) - {#.doc (doc "If a particular exception is detected on a possibly-erroneous value, handle it." - "If no exception was detected, or a different one from the one being checked, then pass along the original value.")} + {#.doc (example "If a particular exception is detected on a possibly-erroneous value, handle it." + "If no exception was detected, or a different one from the one being checked, then pass along the original value.")} (All [e a] (-> (Exception e) (-> Text a) (Try a) (Try a))) @@ -98,16 +98,16 @@ ))) (syntax: .public (exception: {[export_policy t_vars [name inputs] body] ..exception}) - {#.doc (doc "Define a new exception type." - "It mostly just serves as a way to tag error messages for later catching." - "" - "Simple case:" - (exception: .public some_exception) - "" - "Complex case:" - (exception: .public [arbitrary type variables] (some_exception {optional Text} {arguments Int}) - optional_body))} - (macro.with_gensyms [g!descriptor] + {#.doc (example "Define a new exception type." + "It mostly just serves as a way to tag error messages for later catching." + "" + "Simple case:" + (exception: .public some_exception) + "" + "Complex case:" + (exception: .public [arbitrary type variables] (some_exception {optional Text} {arguments Int}) + optional_body))} + (macro.with_identifiers [g!descriptor] (do meta.monad [current_module meta.current_module_name .let [descriptor ($_ text\compose "{" current_module "." name "}" text.new_line) @@ -154,19 +154,19 @@ tail)))) (syntax: .public (report {entries (<>.many (<code>.tuple (<>.and <code>.any <code>.any)))}) - {#.doc (doc "An error report." - (: Text - (report ["Row 0" value/0] - ["Row 1" value/1] - ,,, - ["Row N" value/N])))} + {#.doc (example "An error report." + (: Text + (report ["Row 0" value/0] + ["Row 1" value/1] + ,,, + ["Row N" value/N])))} (in (list (` ((~! report') (list (~+ (|> entries (list\map (function (_ [header message]) (` [(~ header) (~ message)]))))))))))) (def: .public (listing format entries) - {#.doc (doc "A numbered report of the entries on a list." - "NOTE: 0-based numbering.")} + {#.doc (example "A numbered report of the entries on a list." + "NOTE: 0-based numbering.")} (All [a] (-> (-> a Text) (List a) Text)) (|> entries @@ -195,7 +195,7 @@ error)) (def: .public (with exception message computation) - {#.doc (doc "If a computation fails, prepends the exception to the error.")} + {#.doc (example "If a computation fails, prepends the exception to the error.")} (All [e a] (-> (Exception e) e (Try a) (Try a))) (case computation (#//.Failure error) diff --git a/stdlib/source/library/lux/control/function.lux b/stdlib/source/library/lux/control/function.lux index 3e0669133..2f31e896a 100644 --- a/stdlib/source/library/lux/control/function.lux +++ b/stdlib/source/library/lux/control/function.lux @@ -5,38 +5,38 @@ [monoid (#+ Monoid)]]]]) (def: .public identity - {#.doc (doc "Identity function." - "Does nothing to its argument and just returns it." - (is? (identity value) - value))} + {#.doc (example "Identity function." + "Does nothing to its argument and just returns it." + (is? (identity value) + value))} (All [a] (-> a a)) (|>>)) (def: .public (compose f g) - {#.doc (doc "Function composition." - (= ((compose f g) "foo") - (f (g "foo"))))} + {#.doc (example "Function composition." + (= ((compose f g) "foo") + (f (g "foo"))))} (All [a b c] (-> (-> b c) (-> a b) (-> a c))) (|>> g f)) (def: .public (constant value) - {#.doc (doc "Create constant functions." - (= ((constant "foo") "bar") - "foo"))} + {#.doc (example "Create constant functions." + (= ((constant "foo") "bar") + "foo"))} (All [o] (-> o (All [i] (-> i o)))) (function (_ _) value)) (def: .public (flip f) - {#.doc (doc "Flips the order of the arguments of a function." - (= ((flip f) "foo" "bar") - (f "bar" "foo")))} + {#.doc (example "Flips the order of the arguments of a function." + (= ((flip f) "foo" "bar") + (f "bar" "foo")))} (All [a b c] (-> (-> a b c) (-> b a c))) (function (_ x y) (f y x))) (def: .public (apply input function) - {#.doc (doc "Simple 1-argument function application.")} + {#.doc (example "Simple 1-argument function application.")} (All [i o] (-> i (-> i o) o)) (function input)) diff --git a/stdlib/source/library/lux/control/function/contract.lux b/stdlib/source/library/lux/control/function/contract.lux index 8b0baca0f..ce62f8c45 100644 --- a/stdlib/source/library/lux/control/function/contract.lux +++ b/stdlib/source/library/lux/control/function/contract.lux @@ -6,7 +6,7 @@ [data [text ["%" format (#+ format)]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code]] [math @@ -26,27 +26,27 @@ (-> Text Bit []) (if test [] - (error! message))) + (panic! message))) (syntax: .public (pre test expr) - {#.doc (doc "Pre-conditions." - "Given a test and an expression to run, only runs the expression if the test passes." - "Otherwise, an error is raised." - (pre (i.= +4 (i.+ +2 +2)) - (foo +123 +456 +789)))} + {#.doc (example "Pre-conditions." + "Given a test and an expression to run, only runs the expression if the test passes." + "Otherwise, an error is raised." + (pre (i.= +4 (i.+ +2 +2)) + (foo +123 +456 +789)))} (in (list (` (exec ((~! ..assert!) (~ (code.text (exception.error ..pre_condition_failed test))) (~ test)) (~ expr)))))) (syntax: .public (post test expr) - {#.doc (doc "Post-conditions." - "Given a predicate and an expression to run, evaluates the expression and then tests the output with the predicate." - "If the predicate returns #1, returns the value of the expression." - "Otherwise, an error is raised." - (post i.even? - (i.+ +2 +2)))} - (with_gensyms [g!output] + {#.doc (example "Post-conditions." + "Given a predicate and an expression to run, evaluates the expression and then tests the output with the predicate." + "If the predicate returns #1, returns the value of the expression." + "Otherwise, an error is raised." + (post i.even? + (i.+ +2 +2)))} + (with_identifiers [g!output] (in (list (` (let [(~ g!output) (~ expr)] (exec ((~! ..assert!) (~ (code.text (exception.error ..post_condition_failed test))) diff --git a/stdlib/source/library/lux/control/function/memo.lux b/stdlib/source/library/lux/control/function/memo.lux index 87131ad57..924ec4c00 100644 --- a/stdlib/source/library/lux/control/function/memo.lux +++ b/stdlib/source/library/lux/control/function/memo.lux @@ -1,6 +1,5 @@ ... Inspired by; ... "The Different Aspects of Monads and Mixins" by Bruno C. d. S. Oliveira - (.module: [library [lux #* @@ -37,28 +36,28 @@ (Recursive i (State (Dictionary i o) o))) (def: .public (open memo) - {#.doc (doc "Memoization where the memoized results can be re-used accross invocations.")} + {#.doc (example "Memoization where the memoized results can be re-used accross invocations.")} (All [i o] (:let [Memory (Dictionary i o)] (-> (Memo i o) (-> [Memory i] [Memory o])))) - (let [memo (//.mixin (//.inherit ..memoization (//.of_recursive memo)))] + (let [memo (//.mixin (//.with ..memoization (//.of_recursive memo)))] (function (_ [memory input]) - (|> input memo (state.run memory))))) + (|> input memo (state.result memory))))) (def: .public (closed hash memo) - {#.doc (doc "Memoization confined to a single invocation to the function (not counting any subsequent recursive invocations)." - "Memoized results will be re-used during recursive invocations, but cannot be accessed after the main invocation has ended.")} + {#.doc (example "Memoization confined to a single invocation to the function (not counting any subsequent recursive invocations)." + "Memoized results will be re-used during recursive invocations, but cannot be accessed after the main invocation has ended.")} (All [i o] (-> (Hash i) (Memo i o) (-> i o))) - (let [memo (//.mixin (//.inherit ..memoization (//.of_recursive memo))) + (let [memo (//.mixin (//.with ..memoization (//.of_recursive memo))) empty (dictionary.empty hash)] - (|>> memo (state.run empty) product.right))) + (|>> memo (state.result empty) product.right))) (def: .public (none hash memo) - {#.doc (doc "No memoization at all." - "This is useful as a test control when measuring the effect of using memoization.")} + {#.doc (example "No memoization at all." + "This is useful as a test control when measuring the effect of using memoization.")} (All [i o] (-> (Hash i) (Memo i o) (-> i o))) (let [memo (//.mixin (//.of_recursive memo)) empty (dictionary.empty hash)] - (|>> memo (state.run empty) product.right))) + (|>> memo (state.result empty) product.right))) diff --git a/stdlib/source/library/lux/control/function/mixin.lux b/stdlib/source/library/lux/control/function/mixin.lux index 25ca0240b..cdaa35a6c 100644 --- a/stdlib/source/library/lux/control/function/mixin.lux +++ b/stdlib/source/library/lux/control/function/mixin.lux @@ -10,23 +10,23 @@ [monad (#+ Monad do)]]]]) (type: .public (Mixin i o) - {#.doc (doc "A function which can be mixed with others to inherit their behavior.")} + {#.doc (example "A function which can be mixed with others to inherit their behavior.")} (-> (-> i o) (-> i o) (-> i o))) (def: .public (mixin f) - {#.doc (doc "Given a mixin, produces a normal function.")} + {#.doc (example "Given a mixin, produces a normal function.")} (All [i o] (-> (Mixin i o) (-> i o))) (function (mix input) ((f mix mix) input))) (def: .public nothing - {#.doc (doc "A mixin that does nothing and just delegates work to the next mixin.")} + {#.doc (example "A mixin that does nothing and just delegates work to the next mixin.")} Mixin (function (_ delegate recur) delegate)) -(def: .public (inherit parent child) - {#.doc (doc "Produces a new mixin, where the behavior of the child can make use of the behavior of the parent.")} +(def: .public (with parent child) + {#.doc (example "Produces a new mixin, where the behavior of the child can make use of the behavior of the parent.")} (All [i o] (-> (Mixin i o) (Mixin i o) (Mixin i o))) (function (_ delegate recur) (parent (child delegate recur) recur))) @@ -35,10 +35,10 @@ (All [i o] (Monoid (Mixin i o))) (def: identity ..nothing) - (def: compose ..inherit)) + (def: compose ..with)) (def: .public (advice when then) - {#.doc (doc "Only apply then mixin when the input meets some criterion.")} + {#.doc (example "Only apply then mixin when the input meets some criterion.")} (All [i o] (-> (Predicate i) (Mixin i o) (Mixin i o))) (function (_ delegate recur input) (if (when input) @@ -46,7 +46,7 @@ (delegate input)))) (def: .public (before monad action) - {#.doc (doc "Executes an action before doing the main work.")} + {#.doc (example "Executes an action before doing the main work.")} (All [! i o] (-> (Monad !) (-> i (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) (do monad @@ -54,7 +54,7 @@ (delegate input)))) (def: .public (after monad action) - {#.doc (doc "Executes an action after doing the main work.")} + {#.doc (example "Executes an action after doing the main work.")} (All [! i o] (-> (Monad !) (-> i o (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) (do monad @@ -63,11 +63,11 @@ (in output)))) (type: .public (Recursive i o) - {#.doc (doc "An indirectly recursive function.")} + {#.doc (example "An indirectly recursive function.")} (-> (-> i o) (-> i o))) (def: .public (of_recursive recursive) - {#.doc (doc "Transform an indirectly recursive function into a mixin.")} + {#.doc (example "Transform an indirectly recursive function into a mixin.")} (All [i o] (-> (Recursive i o) (Mixin i o))) (function (_ delegate recur) (recursive recur))) diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index 6f0479cc6..e9cac3871 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -1,5 +1,5 @@ (.module: - {#.doc (.doc "Macros for implementing mutually-recursive functions.")} + {#.doc (.example "Macros for implementing mutually-recursive functions.")} [library [lux (#- Definition let def:) ["." meta] @@ -54,20 +54,20 @@ (syntax: .public (let {functions (<code>.tuple (<>.some ..mutual))} body) - {#.doc (doc "Locally-defined mutually-recursive functions." - (let [(even? number) - (-> Nat Bit) - (case number - 0 true - _ (odd? (dec number))) + {#.doc (example "Locally-defined mutually-recursive functions." + (let [(even? number) + (-> Nat Bit) + (case number + 0 true + _ (odd? (dec number))) - (odd? number) - (-> Nat Bit) - (case number - 0 false - _ (even? (dec number)))] - (and (even? 4) - (odd? 5))))} + (odd? number) + (-> Nat Bit) + (case number + 0 false + _ (even? (dec number)))] + (and (even? 4) + (odd? 5))))} (case functions #.End (in (list body)) @@ -80,10 +80,10 @@ (~ body)))))) _ - (macro.with_gensyms [g!context g!output] + (macro.with_identifiers [g!context g!output] (do {! meta.monad} [here_name meta.current_module_name - hidden_names (monad.map ! (//.constant (macro.gensym "mutual_function#")) + hidden_names (monad.map ! (//.constant (macro.identifier "mutual_function#")) functions) .let [definitions (list\map (..mutual_definition hidden_names g!context) (list.zipped/2 hidden_names @@ -119,19 +119,19 @@ (<>.and (<>\in (` .private)) ..mutual)))) (syntax: .public (def: {functions (<>.many ..definition)}) - {#.doc (doc "Globally-defined mutually-recursive functions." - (def: - [.public (even? number) - (-> Nat Bit) - (case number - 0 true - _ (odd? (dec number)))] + {#.doc (example "Globally-defined mutually-recursive functions." + (def: + [.public (even? number) + (-> Nat Bit) + (case number + 0 true + _ (odd? (dec number)))] - [.public (odd? number) - (-> Nat Bit) - (case number - 0 false - _ (even? (dec number)))]))} + [.public (odd? number) + (-> Nat Bit) + (case number + 0 false + _ (even? (dec number)))]))} (case functions #.End (in (list)) @@ -144,10 +144,10 @@ (~ body)))))) _ - (macro.with_gensyms [g!context g!output] + (macro.with_identifiers [g!context g!output] (do {! meta.monad} [here_name meta.current_module_name - hidden_names (monad.map ! (//.constant (macro.gensym "mutual_function#")) + hidden_names (monad.map ! (//.constant (macro.identifier "mutual_function#")) functions) .let [definitions (list\map (..mutual_definition hidden_names g!context) (list.zipped/2 hidden_names diff --git a/stdlib/source/library/lux/control/io.lux b/stdlib/source/library/lux/control/io.lux index 801be1c2a..bcb0f4d8c 100644 --- a/stdlib/source/library/lux/control/io.lux +++ b/stdlib/source/library/lux/control/io.lux @@ -11,7 +11,7 @@ ["s" code]]] [type abstract] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." template]]]]) @@ -29,30 +29,30 @@ (function (g!func g!arg) computation)))]) - (template: (!run io) + (template: (run!' io) ... creatio ex nihilo [((:representation io) [])]) (syntax: .public (io computation) - {#.doc (doc "Delays the evaluation of an expression, by wrapping it in an IO 'thunk'." - "Great for wrapping effectful computations (which will not be performed until the IO is 'run')." - (io (exec - (log! msg) - "Some value...")))} - (with_gensyms [g!func g!arg] + {#.doc (example "Delays the evaluation of an expression, by wrapping it in an IO 'thunk'." + "Great for wrapping effectful computations (which will not be performed until the IO is 'run!')." + (io (exec + (log! msg) + "Some value...")))} + (with_identifiers [g!func g!arg] (in (list (` ((~! ..label) (function ((~ g!func) (~ g!arg)) (~ computation)))))))) - (def: .public run + (def: .public run! {#.doc "A way to execute IO computations and perform their side-effects."} (All [a] (-> (IO a) a)) - (|>> !run)) + (|>> run!')) (implementation: .public functor (Functor IO) (def: (map f) - (|>> !run f !io))) + (|>> run!' f !io))) (implementation: .public apply (Apply IO) @@ -60,7 +60,7 @@ (def: &functor ..functor) (def: (apply ff fa) - (!io ((!run ff) (!run fa))))) + (!io ((run!' ff) (run!' fa))))) (implementation: .public monad (Monad IO) @@ -69,5 +69,5 @@ (def: in (|>> !io)) - (def: join (|>> !run !run !io))) + (def: join (|>> run!' run!' !io))) ) diff --git a/stdlib/source/library/lux/data/lazy.lux b/stdlib/source/library/lux/control/lazy.lux index 9b0efc9f7..677832ebd 100644 --- a/stdlib/source/library/lux/data/lazy.lux +++ b/stdlib/source/library/lux/control/lazy.lux @@ -12,14 +12,14 @@ ["s" code]] [concurrency ["." atom]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)]] [type abstract]]]) (abstract: .public (Lazy a) - {#.doc (doc "A value specified by an expression that is calculated only at the last moment possible." - "Afterwards, the value is cached for future reference.")} + {#.doc (example "A value specified by an expression that is calculated only at the last moment possible." + "Afterwards, the value is cached for future reference.")} (-> [] a) @@ -27,13 +27,14 @@ (All [a] (-> (-> [] a) (Lazy a))) (let [cache (atom.atom #.None)] (:abstraction (function (_ _) - (case (io.run (atom.read! cache)) + (case (io.run! (atom.read! cache)) (#.Some value) value _ (let [value (generator [])] - (exec (io.run (atom.compare_and_swap! _ (#.Some value) cache)) + (exec + (io.run! (atom.compare_and_swap! _ (#.Some value) cache)) value))))))) (def: .public (value lazy) @@ -41,8 +42,8 @@ ((:representation lazy) []))) (syntax: .public (lazy expression) - {#.doc (doc "Specifies a lazy value by providing the expression that computes it.")} - (with_gensyms [g!_] + {#.doc (example "Specifies a lazy value by providing the expression that computes it.")} + (with_identifiers [g!_] (in (list (` ((~! lazy') (function ((~ g!_) (~ g!_)) (~ expression)))))))) (implementation: .public (equivalence (^open "\.")) diff --git a/stdlib/source/library/lux/data/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index a019a4c79..2d9b56039 100644 --- a/stdlib/source/library/lux/data/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -111,21 +111,21 @@ Mma)))) (def: .public (lift monad) - {#.doc (doc "Wraps a monadic value with Maybe machinery.")} + {#.doc (example "Wraps a monadic value with Maybe machinery.")} (All [M a] (-> (Monad M) (-> (M a) (M (Maybe a))))) (\ monad map (\ ..monad in))) (macro: .public (else tokens state) - {#.doc (doc "Allows you to provide a default value that will be used" - "if a (Maybe x) value turns out to be #.None." - "Note: the expression for the default value will not be computed if the base computation succeeds." - (else +20 (#.Some +10)) - "=>" - +10 - -------------------------- - (else +20 #.None) - "=>" - +20)} + {#.doc (example "Allows you to provide a default value that will be used" + "if a (Maybe x) value turns out to be #.None." + "Note: the expression for the default value will not be computed if the base computation succeeds." + (else +20 (#.Some +10)) + "=>" + +10 + -------------------------- + (else +20 #.None) + "=>" + +20)} (case tokens (^ (.list else maybe)) (let [g!temp (: Code [location.dummy (#.Identifier ["" ""])])] @@ -140,9 +140,9 @@ (#.Left "Wrong syntax for else"))) (def: .public assume - {#.doc (doc "Assumes that a Maybe value is a #.Some and yields its value." - "Raises/throws a runtime error otherwise." - "WARNING: Use with caution.")} + {#.doc (example "Assumes that a Maybe value is a #.Some and yields its value." + "Raises/throws a runtime error otherwise." + "WARNING: Use with caution.")} (All [a] (-> (Maybe a) a)) (|>> (..else (undefined)))) @@ -156,11 +156,11 @@ (#.Item value #.End))) (macro: .public (when tokens state) - {#.doc (doc "Can be used as a guard in (co)monadic be/do expressions." - (do monad - [value (do_something 1 2 3) - ..when (passes_test? value)] - (do_something_else 4 5 6)))} + {#.doc (example "Can be used as a guard in (co)monadic be/do expressions." + (do monad + [value (do_something 1 2 3) + ..when (passes_test? value)] + (do_something_else 4 5 6)))} (case tokens (^ (.list test then)) (#.Right [state (.list (` (.if (~ test) diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index 8ddce370f..4c86373f5 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -89,10 +89,10 @@ (#try.Success [input' x]) (#try.Success [input' (#.Some x)])))) -(def: .public (run parser input) - {#.doc (doc "Executes the parser on the input." - "Does not verify that all of the input has been consumed by the parser." - "Returns both the parser's output, and a value that represents the remaining input.")} +(def: .public (result parser input) + {#.doc (example "Executes the parser on the input." + "Does not verify that all of the input has been consumed by the parser." + "Returns both the parser's output, and a value that represents the remaining input.")} (All [s a] (-> (Parser s a) s (Try [s a]))) (parser input)) @@ -144,9 +144,9 @@ (#try.Success [input (list)]) (#try.Success [input' head]) - (..run (\ ..monad map (|>> (list& head)) - (some parser)) - input')))) + (..result (\ ..monad map (|>> (list& head)) + (some parser)) + input')))) (def: .public (many parser) {#.doc "1-or-more combinator."} @@ -185,9 +185,9 @@ (#try.Success [input (list)]) (#try.Success [input' x]) - (..run (\ ..monad map (|>> (#.Item x)) - (at_most (dec amount) parser)) - input'))))) + (..result (\ ..monad map (|>> (#.Item x)) + (at_most (dec amount) parser)) + input'))))) (def: .public (between minimum additional parser) (All [s a] (-> Nat Nat (Parser s a) (Parser s (List a)))) @@ -214,7 +214,7 @@ (\ ! map (|>> (list\map product.right) (#.Item x))))))) (def: .public (not parser) - {#.doc (doc "Only succeeds when the underlying parser fails.")} + {#.doc (example "Only succeeds when the underlying parser fails.")} (All [s a] (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) @@ -225,13 +225,13 @@ (#try.Failure "Expected to fail; yet succeeded.")))) (def: .public (failure message) - {#.doc (doc "Always fail with this 'message'.")} + {#.doc (example "Always fail with this 'message'.")} (All [s a] (-> Text (Parser s a))) (function (_ input) (#try.Failure message))) (def: .public (lift operation) - {#.doc (doc "Lift a potentially failed computation into a parser.")} + {#.doc (example "Lift a potentially failed computation into a parser.")} (All [s a] (-> (Try a) (Parser s a))) (function (_ input) (case operation @@ -253,7 +253,7 @@ (#try.Success [input' output])))) (def: .public remaining - {#.doc (doc "Yield the remaining input (without consuming it).")} + {#.doc (example "Yield the remaining input (without consuming it).")} (All [s] (Parser s s)) (function (_ inputs) (#try.Success [inputs inputs]))) @@ -262,17 +262,17 @@ {#.doc "Combinator for recursive parsers."} (All [s a] (-> (-> (Parser s a) (Parser s a)) (Parser s a))) (function (_ inputs) - (..run (parser (rec parser)) inputs))) + (..result (parser (rec parser)) inputs))) (def: .public (after param subject) - {#.doc (doc "Run the parser after another one (whose output is ignored).")} + {#.doc (example "Run the parser after another one (whose output is ignored).")} (All [s _ a] (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [_ param] subject)) (def: .public (before param subject) - {#.doc (doc "Run the parser before another one (whose output is ignored).")} + {#.doc (example "Run the parser before another one (whose output is ignored).")} (All [s _ a] (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [output subject @@ -280,7 +280,7 @@ (in output))) (def: .public (only test parser) - {#.doc (doc "Only succeed when the parser's output passes a test.")} + {#.doc (example "Only succeed when the parser's output passes a test.")} (All [s a] (-> (-> a Bit) (Parser s a) (Parser s a))) (do ..monad [output parser @@ -288,7 +288,7 @@ (in output))) (def: .public (parses? parser) - {#.doc (doc "Ignore a parser's output and just verify that it succeeds.")} + {#.doc (example "Ignore a parser's output and just verify that it succeeds.")} (All [s a] (-> (Parser s a) (Parser s Bit))) (function (_ input) (case (parser input) @@ -299,7 +299,7 @@ (#try.Success [input' true])))) (def: .public (parses parser) - {#.doc (doc "Ignore a parser's output and just execute it.")} + {#.doc (example "Ignore a parser's output and just execute it.")} (All [s a] (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) @@ -310,8 +310,8 @@ (#try.Success [input' []])))) (def: .public (speculative parser) - {#.doc (doc "Executes a parser, without actually consuming the input." - "That way, the same input can be consumed again by another parser.")} + {#.doc (example "Executes a parser, without actually consuming the input." + "That way, the same input can be consumed again by another parser.")} (All [s a] (-> (Parser s a) (Parser s a))) (function (_ input) (case (parser input) @@ -322,7 +322,7 @@ output))) (def: .public (codec codec parser) - {#.doc (doc "Decode the output of a parser using a codec.")} + {#.doc (example "Decode the output of a parser using a codec.")} (All [s a z] (-> (Codec a z) (Parser s a) (Parser s z))) (function (_ input) (case (parser input) diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/library/lux/control/parser/analysis.lux index 7d64289bc..94e7ca9c1 100644 --- a/stdlib/source/library/lux/control/parser/analysis.lux +++ b/stdlib/source/library/lux/control/parser/analysis.lux @@ -37,7 +37,7 @@ (format text.new_line "Remaining input: " (|> asts (list\map /.%analysis) - (list.interpose " ") + (list.interposed " ") (text.join_with "")))) (exception: .public (cannot_parse {input (List Analysis)}) @@ -49,11 +49,11 @@ ["Input" (exception.listing /.%analysis input)])) (type: .public Parser - {#.doc (doc "A parser for Lux code analysis nodes.")} + {#.doc (example "A parser for Lux code analysis nodes.")} (//.Parser (List Analysis))) -(def: .public (run parser input) - {#.doc (doc "Executes a parser and makes sure no inputs go unconsumed.")} +(def: .public (result parser input) + {#.doc (example "Executes a parser and makes sure no inputs go unconsumed.")} (All [a] (-> (Parser a) (List Analysis) (Try a))) (case (parser input) (#try.Failure error) @@ -66,7 +66,7 @@ (exception.except ..unconsumed_input unconsumed))) (def: .public any - {#.doc (doc "Matches any value, without discrimination.")} + {#.doc (example "Matches any value, without discrimination.")} (Parser Analysis) (function (_ input) (case input @@ -95,7 +95,7 @@ (template [<query> <assertion> <tag> <type> <eq>] [(`` (as_is (def: .public <query> - {#.doc (doc (~~ (template.text ["Queries for a " <query> " value."])))} + {#.doc (example (~~ (template.text ["Queries for a " <query> " value."])))} (Parser <type>) (function (_ input) (case input @@ -106,7 +106,7 @@ (exception.except ..cannot_parse input)))) (def: .public (<assertion> expected) - {#.doc (doc (~~ (template.text ["Assert a specific " <query> " value."])))} + {#.doc (example (~~ (template.text ["Assert a specific " <query> " value."])))} (-> <type> (Parser Any)) (function (_ input) (case input @@ -130,13 +130,13 @@ ) (def: .public (tuple parser) - {#.doc (doc "Parses only within the context of a tuple's contents.")} + {#.doc (example "Parses only within the context of a tuple's contents.")} (All [a] (-> (Parser a) (Parser a))) (function (_ input) (case input (^ (list& (/.tuple head) tail)) (do try.monad - [output (..run parser head)] + [output (..result parser head)] (#try.Success [tail output])) _ diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index 1018e7683..7cf526d41 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -27,11 +27,11 @@ ["." // ("#\." monad)]) (type: .public Offset - {#.doc (doc "An offset for reading within binary data.")} + {#.doc (example "An offset for reading within binary data.")} Nat) (type: .public Parser - {#.doc (doc "A parser for raw binary data.")} + {#.doc (example "A parser for raw binary data.")} (//.Parser [Offset Binary])) (exception: .public (binary_was_not_fully_read {binary_length Nat} {bytes_read Nat}) @@ -39,8 +39,8 @@ ["Binary length" (%.nat binary_length)] ["Bytes read" (%.nat bytes_read)])) -(def: .public (run parser input) - {#.doc (doc "Runs a parser and checks that all the binary data was read by it.")} +(def: .public (result parser input) + {#.doc (example "Runs a parser and checks that all the binary data was read by it.")} (All [a] (-> (Parser a) Binary (Try a))) (case (parser [0 input]) (#try.Failure msg) @@ -53,25 +53,25 @@ (exception.except ..binary_was_not_fully_read [length end]))))) (def: .public end? - {#.doc (doc "Checks whether there is no more data to read.")} + {#.doc (example "Checks whether there is no more data to read.")} (Parser Bit) (function (_ (^@ input [offset data])) (#try.Success [input (n.= offset (/.size data))]))) (def: .public offset - {#.doc (doc "The current offset (i.e. how much data has been read).")} + {#.doc (example "The current offset (i.e. how much data has been read).")} (Parser Offset) (function (_ (^@ input [offset data])) (#try.Success [input offset]))) (def: .public remaining - {#.doc (doc "How much of the data remains to be read.")} + {#.doc (example "How much of the data remains to be read.")} (Parser Nat) (function (_ (^@ input [offset data])) (#try.Success [input (n.- offset (/.size data))]))) (type: .public Size - {#.doc (doc "The size of a chunk of data within a binary array.")} + {#.doc (example "The size of a chunk of data within a binary array.")} Nat) (def: .public size/8 Size 1) @@ -129,14 +129,14 @@ [1 #.Right right]])) (def: .public (rec body) - {#.doc (doc "Tie the knot for a recursive parser.")} + {#.doc (example "Tie the knot for a recursive parser.")} (All [a] (-> (-> (Parser a) (Parser a)) (Parser a))) (function (_ input) (let [parser (body (rec body))] (parser input)))) (def: .public any - {#.doc (doc "Does no parsing, and just returns a dummy value.")} + {#.doc (example "Does no parsing, and just returns a dummy value.")} (Parser Any) (//\in [])) @@ -156,18 +156,18 @@ _ (//.lift (exception.except ..not_a_bit [value]))))) (def: .public (segment size) - {#.doc (doc "Parses a chunk of data of a given size.")} + {#.doc (example "Parses a chunk of data of a given size.")} (-> Nat (Parser Binary)) (function (_ [offset binary]) (case size - 0 (#try.Success [[offset binary] (/.create 0)]) + 0 (#try.Success [[offset binary] (/.empty 0)]) _ (|> binary (/.slice offset size) (\ try.monad map (|>> [[(n.+ size offset) binary]])))))) (template [<size> <name> <bits>] [(`` (def: .public <name> - {#.doc (doc (~~ (template.text ["Parses a block of data prefixed with a size that is " <size> " bytes long."])))} + {#.doc (example (~~ (template.text ["Parses a block of data prefixed with a size that is " <size> " bytes long."])))} (Parser Binary) (do //.monad [size (//\map .nat <bits>)] @@ -181,7 +181,7 @@ (template [<size> <name> <binary>] [(`` (def: .public <name> - {#.doc (doc (~~ (template.text ["Parses a block of (UTF-8 encoded) text prefixed with a size that is " <size> " bytes long."])))} + {#.doc (example (~~ (template.text ["Parses a block of (UTF-8 encoded) text prefixed with a size that is " <size> " bytes long."])))} (Parser Text) (do //.monad [utf8 <binary>] @@ -197,7 +197,7 @@ (template [<size> <name> <bits>] [(def: .public (<name> valueP) - {#.doc (doc (~~ (template.text ["Parses a row of values prefixed with a size that is " <size> " bytes long."])))} + {#.doc (example (~~ (template.text ["Parses a row of values prefixed with a size that is " <size> " bytes long."])))} (All [v] (-> (Parser v) (Parser (Row v)))) (do //.monad [amount (: (Parser Nat) @@ -227,7 +227,7 @@ (..or ..any)) (def: .public (list value) - {#.doc (doc "Parses an arbitrarily long list of values.")} + {#.doc (example "Parses an arbitrarily long list of values.")} (All [a] (-> (Parser a) (Parser (List a)))) (..rec (|>> (//.and value) diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/library/lux/control/parser/cli.lux index b4051eb43..cc9bf19ab 100644 --- a/stdlib/source/library/lux/control/parser/cli.lux +++ b/stdlib/source/library/lux/control/parser/cli.lux @@ -14,10 +14,10 @@ {#.doc "A command-line interface parser."} (//.Parser (List Text) a)) -(def: .public (run parser inputs) - {#.doc (doc "Executes the parser and verifies that all inputs are processed.")} +(def: .public (result parser inputs) + {#.doc (example "Executes the parser and verifies that all inputs are processed.")} (All [a] (-> (Parser a) (List Text) (Try a))) - (case (//.run parser inputs) + (case (//.result parser inputs) (#try.Success [remaining output]) (case remaining #.End @@ -64,7 +64,7 @@ (All [a] (-> (Parser a) (Parser a))) (function (_ inputs) (loop [immediate inputs] - (case (//.run cli immediate) + (case (//.result cli immediate) (#try.Success [remaining output]) (#try.Success [remaining output]) @@ -88,14 +88,14 @@ _ (#try.Failure (format "Unknown parameters: " (text.join_with " " inputs)))))) (def: .public (named name value) - {#.doc (doc "Parses a named parameter and yields its value.")} + {#.doc (example "Parses a named parameter and yields its value.")} (All [a] (-> Text (Parser a) (Parser a))) (|> value (//.after (..this name)) ..somewhere)) (def: .public (parameter [short long] value) - {#.doc (doc "Parses a parameter that can have either a short or a long name.")} + {#.doc (example "Parses a parameter that can have either a short or a long name.")} (All [a] (-> [Text Text] (Parser a) (Parser a))) (|> value (//.after (//.either (..this short) (..this long))) diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index c3ac5dca0..d22039f4a 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -34,7 +34,7 @@ (def: (remaining_inputs codes) (-> (List Code) Text) ($_ text\compose text.new_line "Remaining input: " - (|> codes (list\map code.format) (list.interpose " ") (text.join_with "")))) + (|> codes (list\map code.format) (list.interposed " ") (text.join_with "")))) (def: .public any {#.doc "Yields the next input without applying any logic."} @@ -176,8 +176,8 @@ #.End true _ false)]))) -(def: .public (run parser inputs) - {#.doc (doc "Executes a parser against a stream of code, and verifies all the inputs are consumed.")} +(def: .public (result parser inputs) + {#.doc (example "Executes a parser against a stream of code, and verifies all the inputs are consumed.")} (All [a] (-> (Parser a) (List Code) (Try a))) (case (parser inputs) (#try.Failure error) @@ -198,5 +198,5 @@ (All [a] (-> (List Code) (Parser a) (Parser a))) (function (_ real) (do try.monad - [value (..run parser inputs)] + [value (..result parser inputs)] (in [real value])))) diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index b83ef9165..5358da9ca 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -13,11 +13,11 @@ ["." //]) (type: .public Property - {#.doc (doc "A property in the environment.")} + {#.doc (example "A property in the environment.")} Text) (type: .public Environment - {#.doc (doc "An abstraction for environment variables of a program.")} + {#.doc (example "An abstraction for environment variables of a program.")} (Dictionary Property Text)) (exception: .public (unknown_property {property Property}) @@ -25,11 +25,11 @@ ["Property" (%.text property)])) (type: .public (Parser a) - {#.doc (doc "A parser of environment variables of a program.")} + {#.doc (example "A parser of environment variables of a program.")} (//.Parser Environment a)) (def: .public empty - {#.doc (doc "An empty environment.")} + {#.doc (example "An empty environment.")} Environment (dictionary.empty text.hash)) @@ -43,8 +43,8 @@ #.None (exception.except ..unknown_property [name])))) -(def: .public (run parser environment) - {#.doc (doc "Executes a parser against the given environment variables." - "Does not check whether all environment variables were parsed, since they're usually an open set.")} +(def: .public (result parser environment) + {#.doc (example "Executes a parser against the given environment variables." + "Does not check whether all environment variables were parsed, since they're usually an open set.")} (All [a] (-> (Parser a) Environment (Try a))) (\ try.monad map product.right (parser environment))) diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/library/lux/control/parser/json.lux index f1112ffbe..133f78332 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -32,11 +32,11 @@ (exception: .public empty_input) -(def: .public (run parser json) - {#.doc (doc "Executes the parser against a JSON object." - "Verifies that all of the JSON was consumed by the parser.")} +(def: .public (result parser json) + {#.doc (example "Executes the parser against a JSON object." + "Verifies that all of the JSON was consumed by the parser.")} (All [a] (-> (Parser a) JSON (Try a))) - (case (//.run parser (list json)) + (case (//.result parser (list json)) (#try.Success [remainder output]) (case remainder #.End @@ -120,7 +120,7 @@ ) (def: .public (nullable parser) - {#.doc (doc "Enhances parser by adding NULL-handling.")} + {#.doc (example "Enhances parser by adding NULL-handling.")} (All [a] (-> (Parser a) (Parser (Maybe a)))) (//.or ..null parser)) @@ -132,7 +132,7 @@ [head ..any] (case head (#/.Array values) - (case (//.run parser (row.list values)) + (case (//.result parser (row.list values)) (#try.Failure error) (//.failure error) @@ -148,8 +148,8 @@ (//.failure (exception.error ..unexpected_value [head]))))) (def: .public (object parser) - {#.doc (doc "Parses the contents of a JSON object." - "Use this with the 'field' combinator.")} + {#.doc (example "Parses the contents of a JSON object." + "Use this with the 'field' combinator.")} (All [a] (-> (Parser a) (Parser a))) (do //.monad [head ..any] @@ -160,7 +160,7 @@ (list\map (function (_ [key value]) (list (#/.String key) value))) list.concat - (//.run parser)) + (//.result parser)) (#try.Failure error) (//.failure error) @@ -176,14 +176,14 @@ (//.failure (exception.error ..unexpected_value [head]))))) (def: .public (field field_name parser) - {#.doc (doc "Parses a field inside a JSON object." - "Use this inside the 'object' combinator.")} + {#.doc (example "Parses a field inside a JSON object." + "Use this inside the 'object' combinator.")} (All [a] (-> Text (Parser a) (Parser a))) (function (recur inputs) (case inputs (^ (list& (#/.String key) value inputs')) (if (text\= key field_name) - (case (//.run parser (list value)) + (case (//.result parser (list value)) (#try.Success [#.End output]) (#try.Success [inputs' output]) diff --git a/stdlib/source/library/lux/control/parser/synthesis.lux b/stdlib/source/library/lux/control/parser/synthesis.lux index cde50518e..dadf00655 100644 --- a/stdlib/source/library/lux/control/parser/synthesis.lux +++ b/stdlib/source/library/lux/control/parser/synthesis.lux @@ -49,12 +49,12 @@ (exception: .public empty_input) (type: .public Parser - {#.doc (doc "A parser for the Lux compiler's synthesis nodes using during optimization.")} + {#.doc (example "A parser for the Lux compiler's synthesis nodes using during optimization.")} (//.Parser (List Synthesis))) -(def: .public (run parser input) - {#.doc (doc "Executes the parser against the inputs." - "Ensures all inputs are consumed by the parser.")} +(def: .public (result parser input) + {#.doc (example "Executes the parser against the inputs." + "Ensures all inputs are consumed by the parser.")} (All [a] (-> (Parser a) (List Synthesis) (Try a))) (case (parser input) (#try.Failure error) @@ -67,7 +67,7 @@ (exception.except ..unconsumed_input unconsumed))) (def: .public any - {#.doc (doc "Yields a synthesis node without subjecting it to any analysis.")} + {#.doc (example "Yields a synthesis node without subjecting it to any analysis.")} (Parser Synthesis) (.function (_ input) (case input @@ -95,7 +95,7 @@ (template [<query> <assertion> <tag> <type> <eq>] [(`` (def: .public <query> - {#.doc (doc (~~ (template.text ["Queries for a " <query> " synthesis node."])))} + {#.doc (example (~~ (template.text ["Queries for a " <query> " synthesis node."])))} (Parser <type>) (.function (_ input) (case input @@ -106,7 +106,7 @@ (exception.except ..cannot_parse input))))) (`` (def: .public (<assertion> expected) - {#.doc (doc (~~ (template.text ["Checks for a specific " <query> " synthesis node."])))} + {#.doc (example (~~ (template.text ["Checks for a specific " <query> " synthesis node."])))} (-> <type> (Parser Any)) (.function (_ input) (case input @@ -128,27 +128,27 @@ ) (def: .public (tuple parser) - {#.doc (doc "Parses the contents of a tuple.")} + {#.doc (example "Parses the contents of a tuple.")} (All [a] (-> (Parser a) (Parser a))) (.function (_ input) (case input (^ (list& (/.tuple head) tail)) (do try.monad - [output (..run parser head)] + [output (..result parser head)] (#try.Success [tail output])) _ (exception.except ..cannot_parse input)))) (def: .public (function expected parser) - {#.doc (doc "Parses the body of a function with the 'expected' arity.")} + {#.doc (example "Parses the body of a function with the 'expected' arity.")} (All [a] (-> Arity (Parser a) (Parser [(Environment Synthesis) a]))) (.function (_ input) (case input (^ (list& (/.function/abstraction [environment actual body]) tail)) (if (n.= expected actual) (do try.monad - [output (..run parser (list body))] + [output (..result parser (list body))] (#try.Success [tail [environment output]])) (exception.except ..wrong_arity [expected actual])) @@ -156,14 +156,14 @@ (exception.except ..cannot_parse input)))) (def: .public (loop init_parsers iteration_parser) - {#.doc (doc "Parses the initial values and the body of a loop.")} + {#.doc (example "Parses the initial values and the body of a loop.")} (All [a b] (-> (Parser a) (Parser b) (Parser [Register a b]))) (.function (_ input) (case input (^ (list& (/.loop/scope [start inits iteration]) tail)) (do try.monad - [inits (..run init_parsers inits) - iteration (..run iteration_parser (list iteration))] + [inits (..result init_parsers inits) + iteration (..result iteration_parser (list iteration))] (#try.Success [tail [start inits iteration]])) _ diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux index f593f311f..8d314634c 100644 --- a/stdlib/source/library/lux/control/parser/text.lux +++ b/stdlib/source/library/lux/control/parser/text.lux @@ -4,12 +4,12 @@ [abstract [monad (#+ Monad do)]] [control + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)]] [data ["/" text (#+ Char) ("#\." monoid)] ["." product] - ["." maybe] [collection ["." list ("#\." fold)]]] [macro @@ -21,7 +21,7 @@ ["." //]) (type: .public Offset - {#.doc (doc "An offset into a block of text.")} + {#.doc (example "An offset into a block of text.")} Nat) (def: start_offset @@ -29,11 +29,11 @@ 0) (type: .public Parser - {#.doc (doc "A parser for text.")} + {#.doc (example "A parser for text.")} (//.Parser [Offset Text])) (type: .public Slice - {#.doc (doc "A slice of a block of text.")} + {#.doc (example "A slice of a block of text.")} {#basis Offset #distance Offset}) @@ -55,9 +55,9 @@ (exception: .public cannot_parse) (exception: .public cannot_slice) -(def: .public (run parser input) - {#.doc (doc "Executes a parser against a block of text." - "Verifies that the entire input has been processed.")} +(def: .public (result parser input) + {#.doc (example "Executes a parser against a block of text." + "Verifies that the entire input has been processed.")} (All [a] (-> (Parser a) Text (Try a))) (case (parser [start_offset input]) (#try.Failure msg) @@ -69,7 +69,7 @@ (exception.except ..unconsumed_input [end_offset input])))) (def: .public offset - {#.doc (doc "Yields the current offset into the input.")} + {#.doc (example "Yields the current offset into the input.")} (Parser Offset) (function (_ (^@ input [offset tape])) (#try.Success [input offset]))) @@ -112,7 +112,7 @@ (template [<name> <type> <any> <caveat>] [(`` (def: .public (<name> parser) - {#.doc (doc (~~ (template.text ["Produce a character" <caveat> " if the parser fails."])))} + {#.doc (example (~~ (template.text ["Produce a character" <caveat> " if the parser fails."])))} (All [a] (-> (Parser a) (Parser <type>))) (function (_ input) (case (parser input) @@ -131,7 +131,7 @@ ["Reference" (/.format reference)])) (def: .public (this reference) - {#.doc (doc "Checks that a specific text shows up in the input.")} + {#.doc (example "Checks that a specific text shows up in the input.")} (-> Text (Parser Any)) (function (_ [offset tape]) (case (/.index_of' offset reference tape) @@ -283,7 +283,7 @@ (..satisfies /.space?)) (def: .public (and left right) - {#.doc (doc "Yields the outputs of both parsers composed together.")} + {#.doc (example "Yields the outputs of both parsers composed together.")} (-> (Parser Text) (Parser Text) (Parser Text)) (do //.monad [=left left @@ -291,7 +291,7 @@ (in ($_ /\compose =left =right)))) (def: .public (and! left right) - {#.doc (doc "Yields the outputs of both parsers composed together (as a slice).")} + {#.doc (example "Yields the outputs of both parsers composed together (as a slice).")} (-> (Parser Slice) (Parser Slice) (Parser Slice)) (do //.monad [[left::basis left::distance] left @@ -364,7 +364,7 @@ {#.doc "Applies a parser against the given input."} (All [a] (-> Text (Parser a) (Parser a))) (function (_ real_input) - (case (..run parser local_input) + (case (..result parser local_input) (#try.Failure error) (#try.Failure error) @@ -372,7 +372,7 @@ (#try.Success [real_input value])))) (def: .public (slice parser) - {#.doc (doc "Converts a slice to a block of text.")} + {#.doc (example "Converts a slice to a block of text.")} (-> (Parser Slice) (Parser Text)) (do //.monad [[basis distance] parser] @@ -385,11 +385,11 @@ (exception.except ..cannot_slice []))))) (def: .public (then structured text) - {#.doc (doc "Embeds a text parser into an arbitrary parser that yields text.")} + {#.doc (example "Embeds a text parser into an arbitrary parser that yields text.")} (All [s a] (-> (Parser a) (//.Parser s Text) (//.Parser s a))) (do //.monad [raw text] - (//.lift (..run structured raw)))) + (//.lift (..result structured raw)))) diff --git a/stdlib/source/library/lux/control/parser/tree.lux b/stdlib/source/library/lux/control/parser/tree.lux index 6daf1129e..cba23cf82 100644 --- a/stdlib/source/library/lux/control/parser/tree.lux +++ b/stdlib/source/library/lux/control/parser/tree.lux @@ -13,23 +13,23 @@ ["." //]) (type: .public (Parser t a) - {#.doc (doc "A parser of arbitrary trees.")} + {#.doc (example "A parser of arbitrary trees.")} (//.Parser (Zipper t) a)) -(def: .public (run' parser zipper) - {#.doc (doc "Applies the parser against a tree zipper.")} +(def: .public (result' parser zipper) + {#.doc (example "Applies the parser against a tree zipper.")} (All [t a] (-> (Parser t a) (Zipper t) (Try a))) (do try.monad - [[zipper output] (//.run parser zipper)] + [[zipper output] (//.result parser zipper)] (in output))) -(def: .public (run parser tree) - {#.doc (doc "Applies the parser against a tree.")} +(def: .public (result parser tree) + {#.doc (example "Applies the parser against a tree.")} (All [t a] (-> (Parser t a) (Tree t) (Try a))) - (run' parser (zipper.zipper tree))) + (result' parser (zipper.zipper tree))) (def: .public value - {#.doc (doc "Yields the value inside the current tree node.")} + {#.doc (example "Yields the value inside the current tree node.")} (All [t] (Parser t t)) (function (_ zipper) (#try.Success [zipper (zipper.value zipper)]))) @@ -38,7 +38,7 @@ (template [<name> <direction> <doc>] [(def: .public <name> - {#.doc (doc <doc>)} + {#.doc (example <doc>)} (All [t] (Parser t [])) (function (_ zipper) (case (<direction> zipper) diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 6e5c0f005..aaebfb594 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -1,6 +1,6 @@ (.module: - {#.doc (.doc "Parsing of Lux types." - "Used mostly for polytypic programming.")} + {#.doc (.example "Parsing of Lux types." + "Used mostly for polytypic programming.")} [library [lux (#- function local) [abstract @@ -61,21 +61,21 @@ (text.join_with ""))])) (type: .public Env - {#.doc (doc "An environment for type parsing.")} + {#.doc (example "An environment for type parsing.")} (Dictionary Nat [Type Code])) (type: .public (Parser a) - {#.doc (doc "A parser of Lux types.")} + {#.doc (example "A parser of Lux types.")} (//.Parser [Env (List Type)] a)) (def: .public fresh - {#.doc (doc "An empty parsing environment.")} + {#.doc (example "An empty parsing environment.")} Env (dictionary.empty n.hash)) -(def: (run' env poly types) +(def: (result' env poly types) (All [a] (-> Env (Parser a) (List Type) (Try a))) - (case (//.run poly [env types]) + (case (//.result poly [env types]) (#try.Failure error) (#try.Failure error) @@ -87,14 +87,14 @@ _ (exception.except ..unconsumed_input remaining)))) -(def: .public (run poly type) - {#.doc (doc "Applies a parser against a type." - "Verifies that the parser fully consumes the type's information.")} +(def: .public (result poly type) + {#.doc (example "Applies a parser against a type." + "Verifies that the parser fully consumes the type's information.")} (All [a] (-> (Parser a) Type (Try a))) - (run' ..fresh poly (list type))) + (result' ..fresh poly (list type))) (def: .public env - {#.doc (doc "Yields the current parsing environment.")} + {#.doc (example "Yields the current parsing environment.")} (Parser Env) (.function (_ [env inputs]) (#try.Success [[env inputs] env]))) @@ -102,7 +102,7 @@ (def: (with_env temp poly) (All [a] (-> Env (Parser a) (Parser a))) (.function (_ [env inputs]) - (case (//.run poly [temp inputs]) + (case (//.result poly [temp inputs]) (#try.Failure error) (#try.Failure error) @@ -110,7 +110,7 @@ (#try.Success [[env remaining] output])))) (def: .public peek - {#.doc (doc "Inspect a type in the input stream without consuming it.")} + {#.doc (example "Inspect a type in the input stream without consuming it.")} (Parser Type) (.function (_ [env inputs]) (case inputs @@ -121,7 +121,7 @@ (#try.Success [[env inputs] headT])))) (def: .public any - {#.doc (doc "Yields a type, without examination.")} + {#.doc (example "Yields a type, without examination.")} (Parser Type) (.function (_ [env inputs]) (case inputs @@ -132,10 +132,10 @@ (#try.Success [[env tail] headT])))) (def: .public (local types poly) - {#.doc (doc "Apply a parser to the given inputs.")} + {#.doc (example "Apply a parser to the given inputs.")} (All [a] (-> (List Type) (Parser a) (Parser a))) (.function (_ [env pass_through]) - (case (run' env poly types) + (case (result' env poly types) (#try.Failure error) (#try.Failure error) @@ -151,9 +151,9 @@ (.function (_ [env inputs]) (let [current_id (dictionary.size env) g!var (label current_id)] - (case (//.run poly - [(dictionary.put current_id [type g!var] env) - inputs]) + (case (//.result poly + [(dictionary.put current_id [type g!var] env) + inputs]) (#try.Failure error) (#try.Failure error) @@ -162,7 +162,7 @@ (template [<name> <flattener> <tag> <exception>] [(`` (def: .public (<name> poly) - {#.doc (doc (~~ (template.text ["Parses the contents of a " <name> " type."])))} + {#.doc (example (~~ (template.text ["Parses the contents of a " <name> " type."])))} (All [a] (-> (Parser a) (Parser a))) (do //.monad [headT ..any] @@ -222,7 +222,7 @@ (in [funcL all_varsL output]))))) (def: .public (function in_poly out_poly) - {#.doc (doc "Parses a function's inputs and output.")} + {#.doc (example "Parses a function's inputs and output.")} (All [i o] (-> (Parser i) (Parser o) (Parser [i o]))) (do //.monad [headT any @@ -233,7 +233,7 @@ (//.failure (exception.error ..not_function headT))))) (def: .public (applied poly) - {#.doc (doc "Parses a type application.")} + {#.doc (example "Parses a type application.")} (All [a] (-> (Parser a) (Parser a))) (do //.monad [headT any @@ -244,7 +244,7 @@ (template [<name> <test> <doc>] [(def: .public (<name> expected) - {#.doc (doc <doc>)} + {#.doc (example <doc>)} (-> Type (Parser Any)) (do //.monad [actual any] @@ -254,9 +254,9 @@ [exactly type\= "Parses a type exactly."] - [sub check.checks? + [sub check.subsumes? "Parses a sub type."] - [super (function.flip check.checks?) + [super (function.flip check.subsumes?) "Parses a super type."] ) @@ -299,7 +299,7 @@ (//.failure (exception.error ..not_parameter headT))))) (def: .public existential - {#.doc (doc "Yields an existential type.")} + {#.doc (example "Yields an existential type.")} (Parser Nat) (do //.monad [headT any] @@ -311,7 +311,7 @@ (//.failure (exception.error ..not_existential headT))))) (def: .public named - {#.doc (doc "Yields a named type.")} + {#.doc (example "Yields a named type.")} (Parser [Name Type]) (do //.monad [inputT any] diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/library/lux/control/parser/xml.lux index 14072c73c..6e7dfe3e1 100644 --- a/stdlib/source/library/lux/control/parser/xml.lux +++ b/stdlib/source/library/lux/control/parser/xml.lux @@ -18,7 +18,7 @@ ["." //]) (type: .public (Parser a) - {#.doc (doc "A parser of XML-encoded data.")} + {#.doc (example "A parser of XML-encoded data.")} (//.Parser [Attrs (List XML)] a)) (exception: .public empty_input) @@ -38,9 +38,9 @@ (exception.report ["Inputs" (exception.listing (\ /.codec encode) inputs)])) -(def: (run' parser attrs documents) +(def: (result' parser attrs documents) (All [a] (-> (Parser a) Attrs (List XML) (Try a))) - (case (//.run parser [attrs documents]) + (case (//.result parser [attrs documents]) (#try.Success [[attrs' remaining] output]) (if (list.empty? remaining) (#try.Success output) @@ -49,14 +49,14 @@ (#try.Failure error) (#try.Failure error))) -(def: .public (run parser documents) - {#.doc (doc "Applies a parser against a stream of XML documents." - "Verifies that all of the inputs are consumed by the parser.")} +(def: .public (result parser documents) + {#.doc (example "Applies a parser against a stream of XML documents." + "Verifies that all of the inputs are consumed by the parser.")} (All [a] (-> (Parser a) (List XML) (Try a))) - (..run' parser /.attributes documents)) + (..result' parser /.attributes documents)) (def: .public text - {#.doc (doc "Yields text from a text node.")} + {#.doc (example "Yields text from a text node.")} (Parser Text) (function (_ [attrs documents]) (case documents @@ -72,7 +72,7 @@ (exception.except ..unexpected_input []))))) (def: .public tag - {#.doc (doc "Yields the tag from the next node.")} + {#.doc (example "Yields the tag from the next node.")} (Parser Tag) (function (_ [attrs documents]) (case documents @@ -88,7 +88,7 @@ (#try.Success [[attrs documents] tag]))))) (def: .public (attribute name) - {#.doc (doc "Yields the value of an attribute in the current node.")} + {#.doc (example "Yields the value of an attribute in the current node.")} (-> Attribute (Parser Text)) (function (_ [attrs documents]) (case (dictionary.get name attrs) @@ -99,7 +99,7 @@ (#try.Success [[attrs documents] value])))) (def: .public (node expected parser) - {#.doc (doc "Parses the contents of the next node if the tag matches.")} + {#.doc (example "Parses the contents of the next node if the tag matches.")} (All [a] (-> Tag (Parser a) (Parser a))) (function (_ [attrs documents]) (case documents @@ -114,28 +114,28 @@ (#/.Node actual attrs' children) (if (name\= expected actual) (|> children - (..run' parser attrs') + (..result' parser attrs') (try\map (|>> [[attrs tail]]))) (exception.except ..wrong_tag [expected actual])))))) -(def: .public ignore - {#.doc (doc "Skips the next node.")} - (Parser Any) +(def: .public any + {#.doc (example "Yields the next node.")} + (Parser XML) (function (_ [attrs documents]) (case documents #.End (exception.except ..empty_input []) (#.Item head tail) - (#try.Success [[attrs tail] []])))) + (#try.Success [[attrs tail] head])))) (exception: .public nowhere) (def: .public (somewhere parser) - {#.doc (doc "Applies the parser somewhere among the remaining inputs; instead of demanding that the parser succeeds against the immediate inputs.")} + {#.doc (example "Applies the parser somewhere among the remaining inputs; instead of demanding that the parser succeeds against the immediate inputs.")} (All [a] (-> (Parser a) (Parser a))) (function (recur [attrs input]) - (case (//.run parser [attrs input]) + (case (//.result parser [attrs input]) (#try.Success [[attrs remaining] output]) (#try.Success [[attrs remaining] output]) diff --git a/stdlib/source/library/lux/control/pipe.lux b/stdlib/source/library/lux/control/pipe.lux index 7e551f43c..07f38e15e 100644 --- a/stdlib/source/library/lux/control/pipe.lux +++ b/stdlib/source/library/lux/control/pipe.lux @@ -12,7 +12,7 @@ ["." identity] [collection ["." list ("#\." fold monad)]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code]] [math @@ -27,19 +27,19 @@ (syntax: .public (new> start {body body^} prev) - {#.doc (doc "Ignores the piped argument, and begins a new pipe." - (n.= 1 - (|> 20 - (n.* 3) - (n.+ 4) - (new> 0 [inc]))))} + {#.doc (example "Ignores the piped argument, and begins a new pipe." + (n.= 1 + (|> 20 + (n.* 3) + (n.+ 4) + (new> 0 [inc]))))} (in (list (` (|> (~ start) (~+ body)))))) (syntax: .public (let> binding body prev) - {#.doc (doc "Gives a name to the piped-argument, within the given expression." - (n.= 10 - (|> 5 - (let> x (n.+ x x)))))} + {#.doc (example "Gives a name to the piped-argument, within the given expression." + (n.= 10 + (|> 5 + (let> x (n.+ x x)))))} (in (list (` (let [(~ binding) (~ prev)] (~ body)))))) @@ -53,13 +53,13 @@ {else body^} {_ _reversed_} {branches (p.some (p.and body^ body^))}) - {#.doc (doc "Branching for pipes." - "Both the tests and the bodies are piped-code, and must be given inside a tuple." - (|> +5 - (cond> [i.even?] [(i.* +2)] - [i.odd?] [(i.* +3)] - [(new> -1 [])])))} - (with_gensyms [g!temp] + {#.doc (example "Branching for pipes." + "Both the tests and the bodies are piped-code, and must be given inside a tuple." + (|> +5 + (cond> [i.even?] [(i.* +2)] + [i.odd?] [(i.* +3)] + [(new> -1 [])])))} + (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ prev)] (cond (~+ (do list.monad [[test then] branches] @@ -68,26 +68,26 @@ (|> (~ g!temp) (~+ else))))))))) (syntax: .public (if> {test body^} {then body^} {else body^} prev) - {#.doc (doc "If-branching." - (is? (if (n.even? sample) - "even" - "odd") - (|> sample - (if> [n.even?] - [(new> "even" [])] - [(new> "odd" [])]))))} + {#.doc (example "If-branching." + (is? (if (n.even? sample) + "even" + "odd") + (|> sample + (if> [n.even?] + [(new> "even" [])] + [(new> "odd" [])]))))} (in (list (` (cond> [(~+ test)] [(~+ then)] [(~+ else)] (~ prev)))))) (syntax: .public (when> {test body^} {then body^} prev) - {#.doc (doc "Only execute the body when the test passes." - (is? (if (n.even? sample) - (n.* 2 sample) - sample) - (|> sample - (when> [n.even?] - [(n.* 2)]))))} + {#.doc (example "Only execute the body when the test passes." + (is? (if (n.even? sample) + (n.* 2 sample) + sample) + (|> sample + (when> [n.even?] + [(n.* 2)]))))} (in (list (` (cond> [(~+ test)] [(~+ then)] [] (~ prev)))))) @@ -95,12 +95,12 @@ (syntax: .public (loop> {test body^} {then body^} prev) - {#.doc (doc "Loops for pipes." - "Both the testing and calculating steps are pipes and must be given inside tuples." - (|> +1 - (loop> [(i.< +10)] - [inc])))} - (with_gensyms [g!temp] + {#.doc (example "Loops for pipes." + "Both the testing and calculating steps are pipes and must be given inside tuples." + (|> +1 + (loop> [(i.< +10)] + [inc])))} + (with_identifiers [g!temp] (in (list (` (loop [(~ g!temp) (~ prev)] (if (|> (~ g!temp) (~+ test)) ((~' recur) (|> (~ g!temp) (~+ then))) @@ -109,14 +109,14 @@ (syntax: .public (do> monad {steps (p.some body^)} prev) - {#.doc (doc "Monadic pipes." - "Each steps in the monadic computation is a pipe and must be given inside a tuple." - (|> +5 - (do> identity.monad - [(i.* +3)] - [(i.+ +4)] - [inc])))} - (with_gensyms [g!temp] + {#.doc (example "Monadic pipes." + "Each steps in the monadic computation is a pipe and must be given inside a tuple." + (|> +5 + (do> identity.monad + [(i.* +3)] + [(i.+ +4)] + [inc])))} + (with_identifiers [g!temp] (case (list.reversed steps) (^ (list& last_step prev_steps)) (let [step_bindings (do list.monad @@ -132,46 +132,46 @@ (syntax: .public (exec> {body body^} prev) - {#.doc (doc "Non-updating pipes." - "Will generate piped computations, but their results will not be used in the larger scope." - (|> +5 - (exec> [.nat %n log!]) - (i.* +10)))} - (with_gensyms [g!temp] + {#.doc (example "Non-updating pipes." + "Will generate piped computations, but their results will not be used in the larger scope." + (|> +5 + (exec> [.nat %n log!]) + (i.* +10)))} + (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ prev)] (exec (|> (~ g!temp) (~+ body)) (~ g!temp)))))))) (syntax: .public (tuple> {paths (p.many body^)} prev) - {#.doc (doc "Parallel branching for pipes." - "Allows to run multiple pipelines for a value and gives you a tuple of the outputs." - (|> +5 - (tuple> [(i.* +10)] - [dec (i./ +2)] - [Int/encode])) - "Will become: [+50 +2 '+5']")} - (with_gensyms [g!temp] + {#.doc (example "Parallel branching for pipes." + "Allows to run multiple pipelines for a value and gives you a tuple of the outputs." + (|> +5 + (tuple> [(i.* +10)] + [dec (i./ +2)] + [Int/encode])) + "Will become: [+50 +2 '+5']")} + (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ prev)] [(~+ (list\map (function (_ body) (` (|> (~ g!temp) (~+ body)))) paths))])))))) (syntax: .public (case> {branches (p.many (p.and s.any s.any))} prev) - {#.doc (doc "Pattern-matching for pipes." - "The bodies of each branch are NOT pipes; just regular values." - (|> +5 - (case> +0 "zero" - +1 "one" - +2 "two" - +3 "three" - +4 "four" - +5 "five" - +6 "six" - +7 "seven" - +8 "eight" - +9 "nine" - _ "???")))} + {#.doc (example "Pattern-matching for pipes." + "The bodies of each branch are NOT pipes; just regular values." + (|> +5 + (case> +0 "zero" + +1 "one" + +2 "two" + +3 "three" + +4 "four" + +5 "five" + +6 "six" + +7 "seven" + +8 "eight" + +9 "nine" + _ "???")))} (in (list (` (case (~ prev) (~+ (list\join (list\map (function (_ [pattern body]) (list pattern body)) branches)))))))) diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index 947c18b21..b2e5b9399 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -20,8 +20,8 @@ (All [r a] (-> (-> r r) (Reader r a) (Reader r a))) (|>> change proc)) -(def: .public (run env proc) - {#.doc (doc "Executes the reader against the given environment.")} +(def: .public (result env proc) + {#.doc "Executes the reader against the given environment."} (All [r a] (-> r (Reader r a) a)) (proc env)) @@ -64,8 +64,8 @@ (def: (join eMeMa) (function (_ env) (do monad - [eMa (run env eMeMa)] - (run env eMa))))) + [eMa (result env eMeMa)] + (result env eMa))))) (def: .public lift {#.doc "Lift monadic values to the Reader wrapper."} diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index daf4b33d3..d84f0e027 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -19,8 +19,8 @@ (-> r (! (Try Any)))) (type: .public (Region r ! a) - {#.doc (doc "A region where resources may be be claimed and where a side-effecting computation may be performed." - "Every resource is paired with a function that knows how to clean/reclaim it, to make sure there are no leaks.")} + {#.doc (example "A region where resources may be be claimed and where a side-effecting computation may be performed." + "Every resource is paired with a function that knows how to clean/reclaim it, to make sure there are no leaks.")} (-> [r (List (Cleaner r !))] (! [(List (Cleaner r !)) (Try a)]))) @@ -53,8 +53,8 @@ (#try.Failure error) (exception.except ..clean_up_error [error output]))) -(def: .public (run monad computation) - {#.doc (doc "Executes a region-based computation, with a side-effect determined by the monad.")} +(def: .public (run! monad computation) + {#.doc (example "Executes a region-based computation, with a side-effect determined by the monad.")} (All [! a] (-> (Monad !) (All [r] (Region r ! a)) (! (Try a)))) @@ -65,7 +65,7 @@ (\ ! map (list\fold clean output))))) (def: .public (acquire monad cleaner value) - {#.doc (doc "Acquire a resource while pairing it a function that knows how to reclaim it.")} + {#.doc (example "Acquire a resource while pairing it a function that knows how to reclaim it.")} (All [! a] (-> (Monad !) (-> a (! (Try Any))) a (All [r] (Region r ! a)))) (function (_ [region cleaners]) @@ -140,7 +140,7 @@ (in [cleaners (#try.Failure error)])))))) (def: .public (failure monad error) - {#.doc (doc "Immediately fail with this 'message'.")} + {#.doc (example "Immediately fail with this 'message'.")} (All [! a] (-> (Monad !) Text (All [r] (Region r ! a)))) @@ -148,14 +148,14 @@ (\ monad in [cleaners (#try.Failure error)]))) (def: .public (except monad exception message) - {#.doc (doc "Fail by throwing/raising an exception.")} + {#.doc (example "Fail by throwing/raising an exception.")} (All [! e a] (-> (Monad !) (Exception e) e (All [r] (Region r ! a)))) (failure monad (exception.error exception message))) (def: .public (lift monad operation) - {#.doc (doc "Lift an effectful computation into a region-based computation.")} + {#.doc (example "Lift an effectful computation into a region-based computation.")} (All [! a] (-> (Monad !) (! a) (All [r] (Region r ! a)))) diff --git a/stdlib/source/library/lux/control/remember.lux b/stdlib/source/library/lux/control/remember.lux index 44289b3cb..f4f9c4213 100644 --- a/stdlib/source/library/lux/control/remember.lux +++ b/stdlib/source/library/lux/control/remember.lux @@ -48,14 +48,14 @@ (<>.failure message))))) (syntax: .public (remember {deadline ..deadline} {message <c>.text} {focus (<>.maybe <c>.any)}) - {#.doc (doc "A message with an expiration date." - "Can have an optional piece of code to focus on." - (remember "2022-04-01" - "Do this, that and the other.") - (remember "2022-04-01" - "Improve the performace." - (some (complicated (computation 123)))))} - (let [now (io.run instant.now) + {#.doc (example "A message with an expiration date." + "Can have an optional piece of code to focus on." + (remember "2022-04-01" + "Do this, that and the other.") + (remember "2022-04-01" + "Improve the performace." + (some (complicated (computation 123)))))} + (let [now (io.run! instant.now) today (instant.date now)] (if (date\< deadline today) (in (case focus @@ -68,13 +68,13 @@ (template [<name> <message>] [(`` (syntax: .public (<name> {deadline ..deadline} {message <c>.text} {focus (<>.maybe <c>.any)}) - {#.doc (doc (~~ (template.text ["A " <message> " message with an expiration date."])) - "Can have an optional piece of code to focus on." - (<name> "2022-04-01" - "Do this, that and the other.") - (<name> "2022-04-01" - "Improve the performace." - (some (complicated (computation 123)))))} + {#.doc (example (~~ (template.text ["A " <message> " message with an expiration date."])) + "Can have an optional piece of code to focus on." + (<name> "2022-04-01" + "Do this, that and the other.") + (<name> "2022-04-01" + "Improve the performace." + (some (complicated (computation 123)))))} (in (list (` (..remember (~ (code.text (%.date deadline))) (~ (code.text (format <message> " " message))) (~+ (case focus diff --git a/stdlib/source/library/lux/control/security/capability.lux b/stdlib/source/library/lux/control/security/capability.lux index b0123dc68..bf689a80c 100644 --- a/stdlib/source/library/lux/control/security/capability.lux +++ b/stdlib/source/library/lux/control/security/capability.lux @@ -25,8 +25,8 @@ ["|.|" annotations]]]]]) (abstract: .public (Capability brand input output) - {#.doc (doc "Represents the capability to perform an operation." - "This operation is assumed to have security implications.")} + {#.doc (example "Represents the capability to perform an operation." + "This operation is assumed to have security implications.")} (-> input output) @@ -37,7 +37,7 @@ (|>> :abstraction)) (def: .public (use capability input) - {#.doc (doc "Applies a capability against its required input.")} + {#.doc (example "Applies a capability against its required input.")} (All [brand input output] (-> (Capability brand input output) input @@ -50,21 +50,21 @@ |declaration|.parser (<>.maybe |annotations|.parser) (<c>.form ($_ <>.and <c>.local_identifier <c>.any <c>.any))))}) - {#.doc (doc "Defines a capability as a unique type, and a constructor for instances." + {#.doc (example "Defines a capability as a unique type, and a constructor for instances." - (capability: (Can_Duplicate a) - (can_duplicate a [a a])) - - (let [capability (can_duplicate - (function (_ value) - [value value])) - [left right] (..use capability 123)] - (is? left right)))} + (capability: (Can_Duplicate a) + (can_duplicate a [a a])) + + (let [capability (can_duplicate + (function (_ value) + [value value])) + [left right] (..use capability 123)] + (is? left right)))} (do {! meta.monad} [this_module meta.current_module_name .let [[name vars] declaration] g!brand (\ ! map (|>> %.code code.text) - (macro.gensym (format (%.name [this_module name])))) + (macro.identifier (format (%.name [this_module name])))) .let [capability (` (..Capability (.primitive (~ g!brand)) (~ input) (~ output)))]] (in (list (` (type: (~ export_policy) (~ (|declaration|.format declaration)) @@ -77,7 +77,7 @@ )))) (def: .public (async capability) - {#.doc (doc "Converts a synchronous I/O-based capability into an asynchronous capability.")} + {#.doc (example "Converts a synchronous I/O-based capability into an asynchronous capability.")} (All [brand input output] (-> (Capability brand input (IO output)) (Capability brand input (Async output)))) diff --git a/stdlib/source/library/lux/control/security/policy.lux b/stdlib/source/library/lux/control/security/policy.lux index 32bf06c38..ea47056bd 100644 --- a/stdlib/source/library/lux/control/security/policy.lux +++ b/stdlib/source/library/lux/control/security/policy.lux @@ -9,38 +9,38 @@ abstract]]]) (abstract: .public (Policy brand value label) - {#.doc (doc "A security policy encoded as the means to 'upgrade' or 'downgrade' in a secure context.")} + {#.doc (example "A security policy encoded as the means to 'upgrade' or 'downgrade' in a secure context.")} value (type: .public (Can_Upgrade brand label value) - {#.doc (doc "Represents the capacity to 'upgrade' a value.")} + {#.doc (example "Represents the capacity to 'upgrade' a value.")} (-> value (Policy brand value label))) (type: .public (Can_Downgrade brand label value) - {#.doc (doc "Represents the capacity to 'downgrade' a value.")} + {#.doc (example "Represents the capacity to 'downgrade' a value.")} (-> (Policy brand value label) value)) (type: .public (Privilege brand label) - {#.doc (doc "Represents the privilege to both 'upgrade' and 'downgrade' a value.")} + {#.doc (example "Represents the privilege to both 'upgrade' and 'downgrade' a value.")} {#can_upgrade (Can_Upgrade brand label) #can_downgrade (Can_Downgrade brand label)}) (type: .public (Delegation brand from to) - {#.doc (doc "Represents the act of delegating policy capacities.")} + {#.doc (example "Represents the act of delegating policy capacities.")} (All [value] (-> (Policy brand value from) (Policy brand value to)))) (def: .public (delegation downgrade upgrade) - {#.doc (doc "Delegating policy capacities.")} + {#.doc (example "Delegating policy capacities.")} (All [brand from to] (-> (Can_Downgrade brand from) (Can_Upgrade brand to) (Delegation brand from to))) (|>> downgrade upgrade)) (type: .public (Context brand scope label) - {#.doc (doc "A computational context with an associated policy privilege.")} + {#.doc (example "A computational context with an associated policy privilege.")} (-> (Privilege brand label) (scope label))) @@ -50,27 +50,27 @@ #can_downgrade (|>> :representation)}) (def: .public (with_policy context) - {#.doc (doc "Activates a security context with the priviledge to enforce it's policy." - - (type: Password - (Private Text)) - - (interface: (Policy %) - (: (-> Text (Password %)) - password) - (: (-> (Password %) Text) - unsafe)) - - (def: (policy _) - (Ex [%] (-> Any (Policy %))) - (with_policy - (: (Context Privacy Policy) - (function (_ (^open "%::.")) - (implementation - (def: (password value) - (%::can_upgrade value)) - (def: (unsafe password) - (%::can_downgrade password))))))))} + {#.doc (example "Activates a security context with the priviledge to enforce it's policy." + + (type: Password + (Private Text)) + + (interface: (Policy %) + (: (-> Text (Password %)) + password) + (: (-> (Password %) Text) + unsafe)) + + (def: (policy _) + (Ex [%] (-> Any (Policy %))) + (with_policy + (: (Context Privacy Policy) + (function (_ (^open "%::.")) + (implementation + (def: (password value) + (%::can_upgrade value)) + (def: (unsafe password) + (%::can_downgrade password))))))))} (All [brand scope] (Ex [label] (-> (Context brand scope label) @@ -121,9 +121,9 @@ )] [Privacy Private Can_Conceal Can_Reveal - (doc "A security context for privacy." - "Private data is data which cannot be allowed to leak outside of the programmed.")] + (example "A security context for privacy." + "Private data is data which cannot be allowed to leak outside of the programmed.")] [Safety Safe Can_Trust Can_Distrust - (doc "A security context for safety." - "Safe data is data coming from outside the program which can be trusted to be properly formatted and lacking injections.")] + (example "A security context for safety." + "Safe data is data coming from outside the program which can be trusted to be properly formatted and lacking injections.")] ) diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index 5021d293d..9cb56fb89 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -41,7 +41,7 @@ (let [[state' output] (action (change state))] [state output]))) -(def: .public (run state action) +(def: .public (result state action) {#.doc "Run a stateful computation."} (All [s a] (-> s (State s a) [s a])) (action state)) @@ -80,7 +80,7 @@ (ma state'))))) (def: .public (while condition body) - {#.doc (doc "A stateful while loop.")} + {#.doc (example "A stateful while loop.")} (All [s] (-> (State s Bit) (State s Any) (State s Any))) (do {! ..monad} [execute? condition] @@ -91,7 +91,7 @@ (in [])))) (def: .public (do_while condition body) - {#.doc (doc "A stateful do-while loop.")} + {#.doc (example "A stateful do-while loop.")} (All [s] (-> (State s Bit) (State s Any) (State s Any))) (do ..monad [_ body] @@ -121,7 +121,7 @@ {#.doc "Stateful computations decorated by a monad."} (-> s (M [s a]))) -(def: .public (run' state action) +(def: .public (result' state action) {#.doc "Execute a stateful computation decorated by a monad."} (All [M s a] (-> s (+State M s a) (M [s a]))) (action state)) diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux index 8b6323863..c0a8c5955 100644 --- a/stdlib/source/library/lux/control/thread.lux +++ b/stdlib/source/library/lux/control/thread.lux @@ -15,7 +15,7 @@ abstract]]]) (type: .public (Thread ! a) - {#.doc (doc "An imperative process with access to mutable values.")} + {#.doc (example "An imperative process with access to mutable values.")} (-> ! a)) (abstract: .public (Box t v) @@ -24,7 +24,7 @@ (Array v) (def: .public (box init) - {#.doc (doc "A brand-new box initialized to the given value.")} + {#.doc (example "A brand-new box initialized to the given value.")} (All [a] (-> a (All [!] (Thread ! (Box ! a))))) (function (_ !) (|> (array.empty 1) @@ -32,7 +32,7 @@ :abstraction))) (def: .public (read box) - {#.doc (doc "Reads the current value in the box.")} + {#.doc (example "Reads the current value in the box.")} (All [! a] (-> (Box ! a) (Thread ! a))) (function (_ !) (for {@.old @@ -54,25 +54,25 @@ @.scheme ("scheme array read" 0 (:representation box))}))) (def: .public (write value box) - {#.doc (doc "Mutates the value in the box.")} + {#.doc (example "Mutates the value in the box.")} (All [a] (-> a (All [!] (-> (Box ! a) (Thread ! Any))))) (function (_ !) (|> box :representation (array.write! 0 value) :abstraction))) ) -(def: .public (run thread) - {#.doc (doc "Executes the imperative thread in a self-contained way.")} +(def: .public (result thread) + {#.doc (example "Executes the imperative thread in a self-contained way.")} (All [a] (-> (All [!] (Thread ! a)) a)) (thread [])) (def: .public io - {#.doc (doc "Transforms the imperative thread into an I/O computation.")} + {#.doc (example "Transforms the imperative thread into an I/O computation.")} (All [a] (-> (All [!] (Thread ! a)) (IO a))) - (|>> ..run io.io)) + (|>> ..result io.io)) (implementation: .public functor (All [!] (Functor (Thread !))) @@ -105,7 +105,7 @@ ((ffa !) !)))) (def: .public (update f box) - {#.doc (doc "Update a box's value by applying a function to it.")} + {#.doc (example "Update a box's value by applying a function to it.")} (All [a !] (-> (-> a a) (Box ! a) (Thread ! a))) (do ..monad [old (read box) diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 6d547f778..7e785b6fa 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -10,7 +10,7 @@ ["." location]]]]) (type: .public (Try a) - {#.doc (doc "A computation that can fail with an error message.")} + {#.doc (example "A computation that can fail with an error message.")} (#Failure Text) (#Success a)) @@ -60,7 +60,7 @@ ma))) (implementation: .public (with monad) - {#.doc (doc "Enhances a monad with error-handling functionality.")} + {#.doc (example "Enhances a monad with error-handling functionality.")} ... TODO: Replace (All [a] (! (Try a))) with (functor.Then ! Try) (All [!] (-> (Monad !) (Monad (All [a] (! (Try a)))))) @@ -82,7 +82,7 @@ Mea)))) (def: .public (lifted monad) - {#.doc (doc "Wraps a monadic value with error-handling machinery.")} + {#.doc (example "Wraps a monadic value with error-handling machinery.")} (All [! a] (-> (Monad !) (-> (! a) (! (Try a))))) (\ monad map (\ ..monad in))) @@ -102,16 +102,16 @@ ))) (def: .public (assumed try) - {#.doc (doc "Assumes a Try value succeeded, and yields its value." - "If it didn't, raises the error as a runtime error." - "WARNING: Use with caution.")} + {#.doc (example "Assumes a Try value succeeded, and yields its value." + "If it didn't, raises the error as a runtime error." + "WARNING: Use with caution.")} (All [a] (-> (Try a) a)) (case try (#Success value) value (#Failure message) - (error! message))) + (panic! message))) (def: .public (maybe try) (All [a] (-> (Try a) (Maybe a))) @@ -133,13 +133,13 @@ (name_of ..of_maybe)))))) (macro: .public (else tokens compiler) - {#.doc (doc "Allows you to provide a default value that will be used" - "if a (Try x) value turns out to be #Failure." - "Note: the expression for the default value will not be computed if the base computation succeeds." - (= "bar" - (else "foo" (#..Success "bar"))) - (= "foo" - (else "foo" (#..Failure "KABOOM!"))))} + {#.doc (example "Allows you to provide a default value that will be used" + "if a (Try x) value turns out to be #Failure." + "Note: the expression for the default value will not be computed if the base computation succeeds." + (= "bar" + (else "foo" (#..Success "bar"))) + (= "foo" + (else "foo" (#..Failure "KABOOM!"))))} (case tokens (^ (list else try)) (#Success [compiler (list (` (case (~ try) diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index c02d6f8bb..7ac976d6b 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -51,7 +51,7 @@ [(\ monoid compose log1 log2) a]))) (implementation: .public (with monoid monad) - {#.doc (doc "Enhances a monad with Writer functionality.")} + {#.doc (example "Enhances a monad with Writer functionality.")} (All [l M] (-> (Monoid l) (Monad M) (Monad (All [a] (M (Writer l a)))))) (def: &functor @@ -73,7 +73,7 @@ (in [(\ monoid compose l1 l2) a])))) (def: .public (lift monoid monad) - {#.doc (doc "Wraps a monadic value with Writer machinery.")} + {#.doc (example "Wraps a monadic value with Writer machinery.")} (All [l M a] (-> (Monoid l) (Monad M) (-> (M a) (M (Writer l a))))) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index ef3ad5f91..b1290557f 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -8,10 +8,10 @@ [equivalence (#+ Equivalence)] [monoid (#+ Monoid)]] [control + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)]] [data - ["." maybe] [text ["%" format (#+ format)]] [collection @@ -33,7 +33,7 @@ ["Offset" (%.nat offset)] ["Length" (%.nat length)])) -(with_expansions [<documentation> (as_is {#.doc (doc "A binary BLOB of data.")}) +(with_expansions [<documentation> (as_is {#.doc (example "A binary BLOB of data.")}) <jvm> (as_is (type: .public Binary <documentation> (ffi.type [byte])) @@ -170,8 +170,8 @@ (-> Binary Nat) (|>> !size)) -(def: .public (create size) - {#.doc (doc "A fresh/empty binary BLOB of the specified size.")} +(def: .public (empty size) + {#.doc (example "A fresh/empty binary BLOB of the specified size.")} (-> Nat Binary) (for {@.old (ffi.array byte size) @.jvm (ffi.array byte size) @@ -200,14 +200,14 @@ output)))) (def: .public (read/8! index binary) - {#.doc (doc "Read 1 byte (8 bits) at the given index.")} + {#.doc (example "Read 1 byte (8 bits) at the given index.")} (-> Nat Binary (Try I64)) (if (n.< (..!size binary) index) (#try.Success (!read index binary)) (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (read/16! index binary) - {#.doc (doc "Read 2 bytes (16 bits) at the given index.")} + {#.doc (example "Read 2 bytes (16 bits) at the given index.")} (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 1 index)) (#try.Success ($_ i64.or @@ -216,7 +216,7 @@ (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (read/32! index binary) - {#.doc (doc "Read 4 bytes (32 bits) at the given index.")} + {#.doc (example "Read 4 bytes (32 bits) at the given index.")} (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 3 index)) (#try.Success ($_ i64.or @@ -227,7 +227,7 @@ (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (read/64! index binary) - {#.doc (doc "Read 8 bytes (64 bits) at the given index.")} + {#.doc (example "Read 8 bytes (64 bits) at the given index.")} (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 7 index)) (#try.Success ($_ i64.or @@ -242,7 +242,7 @@ (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (write/8! index value binary) - {#.doc (doc "Write 1 byte (8 bits) at the given index.")} + {#.doc (example "Write 1 byte (8 bits) at the given index.")} (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) index) (#try.Success (|> binary @@ -250,7 +250,7 @@ (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (write/16! index value binary) - {#.doc (doc "Write 2 bytes (16 bits) at the given index.")} + {#.doc (example "Write 2 bytes (16 bits) at the given index.")} (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 1 index)) (#try.Success (|> binary @@ -259,7 +259,7 @@ (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (write/32! index value binary) - {#.doc (doc "Write 4 bytes (32 bits) at the given index.")} + {#.doc (example "Write 4 bytes (32 bits) at the given index.")} (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 3 index)) (#try.Success (|> binary @@ -270,7 +270,7 @@ (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (write/64! index value binary) - {#.doc (doc "Write 8 bytes (64 bits) at the given index.")} + {#.doc (example "Write 8 bytes (64 bits) at the given index.")} (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 7 index)) (for {@.scheme (let [write_high (|>> (!write index (i64.right_shifted 56 value)) @@ -323,7 +323,7 @@ ["Target output space" (%.nat target_output)]))) (def: .public (copy bytes source_offset source target_offset target) - {#.doc (doc "Mutates the target binary BLOB by copying bytes from the source BLOB to it.")} + {#.doc (example "Mutates the target binary BLOB by copying bytes from the source BLOB to it.")} (-> Nat Nat Binary Nat Binary (Try Binary)) (with_expansions [<jvm> (as_is (do try.monad [_ (java/lang/System::arraycopy source (.int source_offset) target (.int target_offset) (.int bytes))] @@ -345,7 +345,7 @@ (#try.Success target)))))))) (def: .public (slice offset length binary) - {#.doc (doc "Yields a subset of the binary BLOB, so long as the specified range is valid.")} + {#.doc (example "Yields a subset of the binary BLOB, so long as the specified range is valid.")} (-> Nat Nat Binary (Try Binary)) (let [size (..!size binary) limit (n.+ length offset)] @@ -356,10 +356,10 @@ @.jvm <jvm>} ... Default - (..copy length offset binary 0 (..create length))))))) + (..copy length offset binary 0 (..empty length))))))) (def: .public (drop bytes binary) - {#.doc (doc "Yields a binary BLOB with at most the specified number of bytes removed.")} + {#.doc (example "Yields a binary BLOB with at most the specified number of bytes removed.")} (-> Nat Binary Binary) (case bytes 0 binary @@ -369,18 +369,18 @@ slice (#try.Failure _) - (..create 0))))) + (..empty 0))))) (implementation: .public monoid (Monoid Binary) (def: identity - (..create 0)) + (..empty 0)) (def: (compose left right) (let [sizeL (!size left) sizeR (!size right) - output (..create (n.+ sizeL sizeR))] + output (..empty (n.+ sizeL sizeR))] (exec (..copy sizeL 0 left 0 output) (..copy sizeR 0 right sizeL output) diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux index 69111ccb4..22ff7fe2f 100644 --- a/stdlib/source/library/lux/data/bit.lux +++ b/stdlib/source/library/lux/data/bit.lux @@ -61,7 +61,7 @@ _ (#.Left "Wrong syntax for Bit.")))) (def: .public complement - {#.doc (doc "Generates the complement of a predicate." - "That is a predicate that returns the oposite of the original predicate.")} + {#.doc (example "Generates the complement of a predicate." + "That is a predicate that returns the oposite of the original predicate.")} (All [a] (-> (-> a Bit) (-> a Bit))) (function.compose not)) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 8a3d0db92..af865d541 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -8,9 +8,10 @@ [equivalence (#+ Equivalence)] [fold (#+ Fold)] [predicate (#+ Predicate)]] + [control + ["." maybe]] [data ["." product] - ["." maybe] [collection ["." list ("#\." fold)]]] [math @@ -36,7 +37,7 @@ (as_is)) (def: .public (empty size) - {#.doc (doc "An empty array of the specified size.")} + {#.doc (example "An empty array of the specified size.")} (All [a] (-> Nat (Array a))) (for {@.old (:assume ("jvm anewarray" "(java.lang.Object )" size)) @@ -109,7 +110,7 @@ #.None)) (def: .public (write! index value array) - {#.doc (doc "Mutate the array by writing a value to the specified index.")} + {#.doc (example "Mutate the array by writing a value to the specified index.")} (All [a] (-> Nat a (Array a) (Array a))) (for {@.old @@ -129,7 +130,7 @@ @.scheme ("scheme array write" index value array)})) (def: .public (delete! index array) - {#.doc (doc "Mutate the array by deleting the value at the specified index.")} + {#.doc (example "Mutate the array by deleting the value at the specified index.")} (All [a] (-> Nat (Array a) (Array a))) (if (n.< (size array) index) @@ -159,7 +160,7 @@ false)) (def: .public (update! index transform array) - {#.doc (doc "Mutate the array by updating the value at the specified index.")} + {#.doc (example "Mutate the array by updating the value at the specified index.")} (All [a] (-> Nat (-> a a) (Array a) (Array a))) (case (read index array) @@ -170,8 +171,8 @@ (write! index (transform value) array))) (def: .public (upsert! index default transform array) - {#.doc (doc "Mutate the array by updating the value at the specified index." - "If there is no value, update and write the default value given.")} + {#.doc (example "Mutate the array by updating the value at the specified index." + "If there is no value, update and write the default value given.")} (All [a] (-> Nat a (-> a a) (Array a) (Array a))) (write! index @@ -179,7 +180,7 @@ array)) (def: .public (copy! length src_start src_array dest_start dest_array) - {#.doc (doc "Writes the contents of one array into the other.")} + {#.doc (example "Writes the contents of one array into the other.")} (All [a] (-> Nat Nat (Array a) Nat (Array a) (Array a))) @@ -214,7 +215,7 @@ (n.- (..occupancy array) (..size array))) (def: .public (filter! p xs) - {#.doc (doc "Delete every item of the array that fails to satisfy the predicate.")} + {#.doc (example "Delete every item of the array that fails to satisfy the predicate.")} (All [a] (-> (Predicate a) (Array a) (Array a))) (list\fold (function (_ idx xs') @@ -230,7 +231,7 @@ (list.indices (size xs)))) (def: .public (find p xs) - {#.doc (doc "Yields the first item in the array that satisfies the predicate.")} + {#.doc (example "Yields the first item in the array that satisfies the predicate.")} (All [a] (-> (Predicate a) (Array a) (Maybe a))) (let [arr_size (size xs)] @@ -264,7 +265,7 @@ #.None)))) (def: .public (clone xs) - {#.doc (doc "Yields a shallow clone of the array.")} + {#.doc (example "Yields a shallow clone of the array.")} (All [a] (-> (Array a) (Array a))) (let [arr_size (size xs)] (list\fold (function (_ idx ys) @@ -289,7 +290,7 @@ (dec 0)) (def: .public (list array) - {#.doc (doc "Yields a list with every non-empty item in the array.")} + {#.doc (example "Yields a list with every non-empty item in the array.")} (All [a] (-> (Array a) (List a))) (loop [idx (dec (size array)) output #.End] @@ -307,7 +308,7 @@ output))))) (def: .public (list' default array) - {#.doc (doc "Like 'list', but uses the 'default' value when encountering an empty cell in the array.")} + {#.doc (example "Like 'list', but uses the 'default' value when encountering an empty cell in the array.")} (All [a] (-> a (Array a) (List a))) (loop [idx (dec (size array)) output #.End] diff --git a/stdlib/source/library/lux/data/collection/bits.lux b/stdlib/source/library/lux/data/collection/bits.lux index d88827cf1..d7063ac08 100644 --- a/stdlib/source/library/lux/data/collection/bits.lux +++ b/stdlib/source/library/lux/data/collection/bits.lux @@ -4,9 +4,9 @@ [abstract [equivalence (#+ Equivalence)]] [control - pipe] + pipe + ["." maybe]] [data - ["." maybe] [collection ["." array (#+ Array) ("#\." fold)]]] [math @@ -21,7 +21,7 @@ i64.width) (type: .public Bits - {#.doc (doc "A bit-map.")} + {#.doc (example "A bit-map.")} (Array Chunk)) (def: empty_chunk @@ -33,10 +33,10 @@ (array.empty 0)) (def: .public (size bits) - {#.doc (doc "Measures the size of a bit-map by counting all the 1s in the bit-map.")} + {#.doc (example "Measures the size of a bit-map by counting all the 1s in the bit-map.")} (-> Bits Nat) (array\fold (function (_ chunk total) - (|> chunk i64.count (n.+ total))) + (|> chunk i64.ones (n.+ total))) 0 bits)) diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index 49c684929..e86eb437b 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -6,10 +6,10 @@ [equivalence (#+ Equivalence)] [functor (#+ Functor)]] [control + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)]] [data - ["." maybe] ["." product] [collection ["." list ("#\." fold functor monoid)] @@ -207,7 +207,7 @@ ... 1s within the bitmap. (def: bitmap_size (-> Bit_Map Nat) - i64.count) + i64.ones) ... A mask that, for a given bit position, only allows all the 1s prior ... to it, which would indicate the bitmap-size (and, thus, index) @@ -565,7 +565,7 @@ (get@ #..hash)) (def: .public (empty key_hash) - {#.doc (doc "An empty dictionary.")} + {#.doc (example "An empty dictionary.")} (All [k v] (-> (Hash k) (Dictionary k v))) {#hash key_hash #root empty_node}) @@ -611,8 +611,8 @@ (put key (f val) dict))) (def: .public (upsert key default f dict) - {#.doc (doc "Updates the value at the key; if it exists." - "Otherwise, puts a value by applying the function to a default.")} + {#.doc (example "Updates the value at the key; if it exists." + "Otherwise, puts a value by applying the function to a default.")} (All [k v] (-> k v (-> v v) (Dictionary k v) (Dictionary k v))) (..put key (f (maybe.else default @@ -651,16 +651,16 @@ ) (def: .public (merged dict2 dict1) - {#.doc (doc "Merges 2 dictionaries." - "If any collisions with keys occur, the values of dict2 will overwrite those of dict1.")} + {#.doc (example "Merges 2 dictionaries." + "If any collisions with keys occur, the values of dict2 will overwrite those of dict1.")} (All [k v] (-> (Dictionary k v) (Dictionary k v) (Dictionary k v))) (list\fold (function (_ [key val] dict) (put key val dict)) dict1 (entries dict2))) (def: .public (merged_with f dict2 dict1) - {#.doc (doc "Merges 2 dictionaries." - "If any collisions with keys occur, a new value will be computed by applying 'f' to the values of dict2 and dict1.")} + {#.doc (example "Merges 2 dictionaries." + "If any collisions with keys occur, a new value will be computed by applying 'f' to the values of dict2 and dict1.")} (All [k v] (-> (-> v v v) (Dictionary k v) (Dictionary k v) (Dictionary k v))) (list\fold (function (_ [key val2] dict) (case (get key dict) @@ -673,7 +673,7 @@ (entries dict2))) (def: .public (re_bind from_key to_key dict) - {#.doc (doc "If there is a value under 'from_key', remove 'from_key' and store the value under 'to_key'.")} + {#.doc (example "If there is a value under 'from_key', remove 'from_key' and store the value under 'to_key'.")} (All [k v] (-> k k (Dictionary k v) (Dictionary k v))) (case (get from_key dict) #.None diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index b64cf7067..6d343f573 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -5,9 +5,10 @@ equivalence [monad (#+ Monad do)] ["." order (#+ Order)]] + [control + ["." maybe]] [data ["p" product] - ["." maybe] [collection ["." list ("#\." monoid fold)]]] [macro @@ -45,12 +46,12 @@ ) (type: .public (Dictionary k v) - {#.doc (doc "A dictionary data-structure with ordered entries.")} + {#.doc (example "A dictionary data-structure with ordered entries.")} {#&order (Order k) #root (Maybe (Node k v))}) (def: .public (empty order) - {#.doc (doc "An empty dictionary, employing the given order.")} + {#.doc (example "An empty dictionary, employing the given order.")} (All [k v] (-> (Order k) (Dictionary k v))) {#&order order #root #.None}) @@ -102,7 +103,7 @@ (template [<name> <side>] [(def: .public (<name> dict) - {#.doc (doc (~~ (template.text ["Yields value under the " <name> "imum key."])))} + {#.doc (example (~~ (template.text ["Yields value under the " <name> "imum key."])))} (All [k v] (-> (Dictionary k v) (Maybe v))) (case (get@ #root dict) #.None @@ -148,7 +149,7 @@ ))] [blackened #Red #Black self] - [reddened #Black #Red (error! error_message)] + [reddened #Black #Red (panic! error_message)] ) (def: (with_left addition center) @@ -360,7 +361,7 @@ (\ maybe.functor map reddened (get@ #right right))))) _ - (error! error_message)) + (panic! error_message)) )) (def: (without_right key value ?left ?right) @@ -389,7 +390,7 @@ (#.Some (black key value (get@ #right left>>right) ?right))) _ - (error! error_message) + (panic! error_message) ))) (def: (prepended ?left ?right) diff --git a/stdlib/source/library/lux/data/collection/dictionary/plist.lux b/stdlib/source/library/lux/data/collection/dictionary/plist.lux index a834e3036..a251109f4 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux @@ -14,8 +14,8 @@ ... https://en.wikipedia.org/wiki/Property_list (type: .public (PList a) - {#.doc (doc "A property list." - "It's a simple dictionary-like structure with Text keys.")} + {#.doc (example "A property list." + "It's a simple dictionary-like structure with Text keys.")} (List [Text a])) (def: .public empty diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index 1056c034b..fc57c691a 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -51,7 +51,7 @@ xs)) (def: .public (only keep? xs) - {#.doc (doc "A list with only values that satisfy the predicate.")} + {#.doc (example "A list with only values that satisfy the predicate.")} (All [a] (-> (Predicate a) (List a) (List a))) (case xs @@ -77,8 +77,8 @@ [in (#.Item head out)])))) (def: .public (pairs xs) - {#.doc (doc "Cut the list into pairs of 2." - "Caveat emptor: If the list has an un-even number of elements, the last one will be skipped.")} + {#.doc (example "Cut the list into pairs of 2." + "Caveat emptor: If the list has an un-even number of elements, the last one will be skipped.")} (All [a] (-> (List a) (List [a a]))) (case xs (^ (list& x1 x2 xs')) @@ -153,8 +153,8 @@ (let [[ys' xs'] (split_with' predicate #.End xs)] [(reversed ys') xs'])) -(def: .public (chunk size list) - {#.doc "Segment the list in chunks of the given size."} +(def: .public (sub size list) + {#.doc "Segment the list into sub-lists of (at most) the given size."} (All [a] (-> Nat (List a) (List (List a)))) (case list #.End @@ -162,7 +162,7 @@ _ (let [[pre post] (split size list)] - (#.Item pre (chunk size post))))) + (#.Item pre (sub size post))))) (def: .public (repeated n x) {#.doc "A list of the value x, repeated n times."} @@ -244,7 +244,7 @@ #.None)) xs)) -(def: .public (interpose sep xs) +(def: .public (interposed sep xs) {#.doc "Puts a value between every two elements in the list."} (All [a] (-> a (List a) (List a))) @@ -256,7 +256,7 @@ xs (#.Item x xs') - (list& x sep (interpose sep xs')))) + (list& x sep (interposed sep xs')))) (def: .public (size list) (All [a] (-> (List a) Nat)) @@ -375,8 +375,8 @@ (def: join (|>> reversed (fold compose identity)))) -(def: .public (sort < xs) - {#.doc (doc "A list ordered by a comparison function.")} +(def: .public (sorted < xs) + {#.doc (example "A list ordered by a comparison function.")} (All [a] (-> (-> a a Bit) (List a) (List a))) (case xs #.End @@ -389,7 +389,7 @@ [pre (#.Item x' post)])) [(list) (list)] xs')] - ($_ compose (sort < pre) (list x) (sort < post))))) + ($_ compose (sorted < pre) (list x) (sorted < post))))) (def: .public (empty? xs) (All [a] (Predicate (List a))) @@ -459,11 +459,11 @@ (recur input' output'))))) (macro: .public (zipped tokens state) - {#.doc (doc "Create list zippers with the specified number of input lists." - (def: .public zipped/2 (zipped 2)) - (def: .public zipped/3 (zipped 3)) - (zipped/3 xs ys zs) - ((zipped 3) xs ys zs))} + {#.doc (example "Create list zippers with the specified number of input lists." + (def: .public zipped/2 (zipped 2)) + (def: .public zipped/3 (zipped 3)) + (zipped/3 xs ys zs) + ((zipped 3) xs ys zs))} (case tokens (^ (list [_ (#.Nat num_lists)])) (if (n.> 0 num_lists) @@ -504,11 +504,11 @@ (def: .public zipped/3 (zipped 3)) (macro: .public (zipped_with tokens state) - {#.doc (doc "Create list zippers with the specified number of input lists." - (def: .public zipped_with/2 (zipped_with 2)) - (def: .public zipped_with/3 (zipped_with 3)) - (zipped_with/2 + xs ys) - ((zipped_with 2) + xs ys))} + {#.doc (example "Create list zippers with the specified number of input lists." + (def: .public zipped_with/2 (zipped_with 2)) + (def: .public zipped_with/3 (zipped_with 3)) + (zipped_with/2 + xs ys) + ((zipped_with 2) + xs ys))} (case tokens (^ (list [_ (#.Nat num_lists)])) (if (n.> 0 num_lists) @@ -564,8 +564,8 @@ (last xs'))) (def: .public (inits xs) - {#.doc (doc "For a list of size N, yields the first N-1 elements." - "Will yield a #.None for empty lists.")} + {#.doc (example "For a list of size N, yields the first N-1 elements." + "Will yield a #.None for empty lists.")} (All [a] (-> (List a) (Maybe (List a)))) (case xs #.End @@ -584,12 +584,12 @@ )) (def: .public concat - {#.doc (doc "The sequential combination of all the lists.")} + {#.doc (example "The sequential combination of all the lists.")} (All [a] (-> (List (List a)) (List a))) (\ ..monad join)) (implementation: .public (with monad) - {#.doc (doc "Enhances a monad with List functionality.")} + {#.doc (example "Enhances a monad with List functionality.")} (All [M] (-> (Monad M) (Monad (All [a] (M (List a)))))) (def: &functor (functor.compose (get@ #monad.&functor monad) ..functor)) @@ -607,7 +607,7 @@ (in (concat lla))))) (def: .public (lift monad) - {#.doc (doc "Wraps a monadic value with List machinery.")} + {#.doc (example "Wraps a monadic value with List machinery.")} (All [M a] (-> (Monad M) (-> (M a) (M (List a))))) (\ monad map (\ ..monad in))) @@ -624,11 +624,11 @@ (#.Item [idx x] (recur (inc idx) xs'))))) (macro: .public (when tokens state) - {#.doc (doc "Can be used as a guard in (co)monadic be/do expressions." - (do monad - [value (do_something 1 2 3) - ..when (passes_test? value)] - (do_something_else 4 5 6)))} + {#.doc (example "Can be used as a guard in (co)monadic be/do expressions." + (do monad + [value (do_something 1 2 3) + ..when (passes_test? value)] + (do_something_else 4 5 6)))} (case tokens (^ (.list test then)) (#.Right [state (.list (` (.if (~ test) diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index 80b454c58..04fd1c6b5 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -12,7 +12,7 @@ ["n" nat]]]]]) (type: .public (Queue a) - {#.doc (doc "A first-in, first-out sequential data-structure.")} + {#.doc (example "A first-in, first-out sequential data-structure.")} {#front (List a) #rear (List a)}) @@ -32,7 +32,7 @@ (list\compose front (list.reversed rear)))) (def: .public peek - {#.doc (doc "Yields the first value in the queue, if any.")} + {#.doc (example "Yields the first value in the queue, if any.")} (All [a] (-> (Queue a) (Maybe a))) (|>> (get@ #front) list.head)) diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux index 763f1836d..138b86876 100644 --- a/stdlib/source/library/lux/data/collection/queue/priority.lux +++ b/stdlib/source/library/lux/data/collection/queue/priority.lux @@ -4,8 +4,9 @@ [abstract [equivalence (#+ Equivalence)] [monad (#+ do)]] + [control + ["." maybe]] [data - ["." maybe] [collection ["." tree #_ ["#" finger (#+ Tree)]]]] diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index b81cb2534..2a6a1020d 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -14,17 +14,17 @@ [fold (#+ Fold)] [predicate (#+ Predicate)]] [control + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)] ["p" parser ["s" code (#+ Parser)]]] [data - ["." maybe] ["." product] [collection ["." list ("#\." fold functor monoid)] ["." array (#+ Array) ("#\." functor fold)]]] - [macro (#+ with_gensyms) + [macro [syntax (#+ syntax:)] ["." code]] [math @@ -183,7 +183,7 @@ #.End)))) (type: .public (Row a) - {#.doc (doc "A sequential data-structure with fast random access.")} + {#.doc (example "A sequential data-structure with fast random access.")} {#level Level #size Nat #root (Hierarchy a) @@ -242,7 +242,7 @@ (exception: base_was_not_found) (def: .public (within_bounds? row idx) - {#.doc (doc "Determines whether the index is within the bounds of the row.")} + {#.doc (example "Determines whether the index is within the bounds of the row.")} (All [a] (-> (Row a) Nat Bit)) (n.< (get@ #size row) idx)) @@ -359,8 +359,8 @@ (|>> (get@ #size) (n.= 0))) (syntax: .public (row {elems (p.some s.any)}) - {#.doc (doc "Row literals." - (row 12 34 56 78 90))} + {#.doc (example "Row literals." + (row 12 34 56 78 90))} (in (.list (` (..of_list (.list (~+ elems))))))) (implementation: (node_equivalence Equivalence<a>) diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index 5decabfde..f26f57d97 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -8,7 +8,7 @@ ["//" continuation (#+ Cont)] ["<>" parser ["<.>" code (#+ Parser)]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code]] [data @@ -36,8 +36,8 @@ (//.pending [x (repeated x)])) (def: .public (cycle [start next]) - {#.doc (doc "Go over the elements of a list forever." - "The list should not be empty.")} + {#.doc (example "Go over the elements of a list forever." + "The list should not be empty.")} (All [a] (-> [a (List a)] (Sequence a))) (loop [head start @@ -52,7 +52,7 @@ (template [<name> <return>] [(def: .public (<name> sequence) (All [a] (-> (Sequence a) <return>)) - (let [[head tail] (//.run sequence)] + (let [[head tail] (//.result sequence)] <name>))] [head a] @@ -61,7 +61,7 @@ (def: .public (item idx sequence) (All [a] (-> Nat (Sequence a) a)) - (let [[head tail] (//.run sequence)] + (let [[head tail] (//.result sequence)] (case idx 0 head _ (item (dec idx) tail)))) @@ -70,7 +70,7 @@ [(def: .public (<taker> pred xs) (All [a] (-> <pred_type> (Sequence a) (List a))) - (let [[x xs'] (//.run xs)] + (let [[x xs'] (//.result xs)] (if <pred_test> (list& x (<taker> <pred_step> xs')) (list)))) @@ -78,7 +78,7 @@ (def: .public (<dropper> pred xs) (All [a] (-> <pred_type> (Sequence a) (Sequence a))) - (let [[x xs'] (//.run xs)] + (let [[x xs'] (//.result xs)] (if <pred_test> (<dropper> <pred_step> xs') xs))) @@ -86,7 +86,7 @@ (def: .public (<splitter> pred xs) (All [a] (-> <pred_type> (Sequence a) [(List a) (Sequence a)])) - (let [[x xs'] (//.run xs)] + (let [[x xs'] (//.result xs)] (if <pred_test> (let [[tail next] (<splitter> <pred_step> xs')] [(#.Item [x tail]) next]) @@ -104,17 +104,17 @@ (//.pending [x (unfold step next)]))) (def: .public (only predicate sequence) - {#.doc (doc "A new sequence only with items that satisfy the predicate.")} + {#.doc (example "A new sequence only with items that satisfy the predicate.")} (All [a] (-> (-> a Bit) (Sequence a) (Sequence a))) - (let [[head tail] (//.run sequence)] + (let [[head tail] (//.result sequence)] (if (predicate head) (//.pending [head (only predicate tail)]) (only predicate tail)))) (def: .public (partition left? xs) - {#.doc (doc "Split a sequence in two based on a predicate." - "The left side contains all entries for which the predicate is #1." - "The right side contains all entries for which the predicate is #0.")} + {#.doc (example "Split a sequence in two based on a predicate." + "The left side contains all entries for which the predicate is #1." + "The right side contains all entries for which the predicate is #0.")} (All [a] (-> (-> a Bit) (Sequence a) [(Sequence a) (Sequence a)])) [(..only left? xs) (..only (bit.complement left?) xs)]) @@ -123,7 +123,7 @@ (Functor Sequence) (def: (map f fa) - (let [[head tail] (//.run fa)] + (let [[head tail] (//.result fa)] (//.pending [(f head) (map f tail)])))) (implementation: .public comonad @@ -134,20 +134,20 @@ (def: out head) (def: (split wa) - (let [[head tail] (//.run wa)] + (let [[head tail] (//.result wa)] (//.pending [wa (split tail)])))) (syntax: .public (^sequence& {patterns (<code>.form (<>.many <code>.any))} body {branches (<>.some <code>.any)}) - {#.doc (doc "Allows destructuring of sequences in pattern-matching expressions." - "Caveat emptor: Only use it for destructuring, and not for testing values within the sequences." - (let [(^sequence& x y z _tail) (some_sequence_func +1 +2 +3)] - (func x y z)))} - (with_gensyms [g!sequence] + {#.doc (example "Allows destructuring of sequences in pattern-matching expressions." + "Caveat emptor: Only use it for destructuring, and not for testing values within the sequences." + (let [(^sequence& x y z _tail) (some_sequence_func +1 +2 +3)] + (func x y z)))} + (with_identifiers [g!sequence] (let [body+ (` (let [(~+ (list\join (list\map (function (_ pattern) (list (` [(~ pattern) (~ g!sequence)]) - (` ((~! //.run) (~ g!sequence))))) + (` ((~! //.result) (~ g!sequence))))) patterns)))] (~ body)))] (in (list& g!sequence body+ branches))))) diff --git a/stdlib/source/library/lux/data/collection/set.lux b/stdlib/source/library/lux/data/collection/set.lux index 2269117ca..f3ccdc7fb 100644 --- a/stdlib/source/library/lux/data/collection/set.lux +++ b/stdlib/source/library/lux/data/collection/set.lux @@ -16,8 +16,8 @@ ["#" dictionary (#+ Dictionary)]]) (type: .public (Set a) - {#.doc (doc "An un-ordered data-structure with unique items." - "This means there is no repetition/duplication among the items.")} + {#.doc (example "An un-ordered data-structure with unique items." + "This means there is no repetition/duplication among the items.")} (Dictionary a Any)) (def: .public member_hash diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index 9d7d956de..4131578c1 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -6,7 +6,8 @@ [equivalence (#+ Equivalence)] [hash (#+ Hash)]] [control - ["." function]] + ["." function] + ["." maybe]] [math [number ["n" nat]]] @@ -15,12 +16,10 @@ ["." // [// ["." list ("#\." fold monoid)] - ["." dictionary (#+ Dictionary)] - [// - ["." maybe]]]]) + ["." dictionary (#+ Dictionary)]]]) (abstract: .public (Set a) - {#.doc (doc "A set that keeps track of repetition in its entries.")} + {#.doc (example "A set that keeps track of repetition in its entries.")} (Dictionary a Nat) @@ -96,7 +95,7 @@ subject))) (def: .public (sub? reference subject) - {#.doc (doc "Is 'subject' a sub-set of 'reference'?")} + {#.doc (example "Is 'subject' a sub-set of 'reference'?")} (All [a] (-> (Set a) (Set a) Bit)) (|> subject :representation @@ -107,7 +106,7 @@ (n.>= multiplicity)))))) (def: .public (support set) - {#.doc (doc "A set of the unique (non repeated) members.")} + {#.doc (example "A set of the unique (non repeated) members.")} (All [a] (-> (Set a) (//.Set a))) (let [(^@ set [hash _]) (:representation set)] (|> set @@ -158,6 +157,6 @@ (//.list subject))) (def: .public super? - {#.doc (doc "Is 'subject' a super-set of 'reference'?")} + {#.doc (example "Is 'subject' a super-set of 'reference'?")} (All [a] (-> (Set a) (Set a) Bit)) (function.flip sub?)) diff --git a/stdlib/source/library/lux/data/collection/set/ordered.lux b/stdlib/source/library/lux/data/collection/set/ordered.lux index 8f2992ebc..e69dba5fe 100644 --- a/stdlib/source/library/lux/data/collection/set/ordered.lux +++ b/stdlib/source/library/lux/data/collection/set/ordered.lux @@ -13,7 +13,7 @@ abstract]]]) (abstract: .public (Set a) - {#.doc (doc "A set with ordered entries.")} + {#.doc (example "A set with ordered entries.")} (/.Dictionary a a) @@ -77,13 +77,13 @@ ) (def: .public (sub? super sub) - {#.doc (doc "Is 'sub' a sub-set of 'super'?")} + {#.doc (example "Is 'sub' a sub-set of 'super'?")} (All [a] (-> (Set a) (Set a) Bit)) (|> sub ..list (list.every? (..member? super)))) (def: .public (super? sub super) - {#.doc (doc "Is 'super' a super-set of 'sub'?")} + {#.doc (example "Is 'super' a super-set of 'sub'?")} (All [a] (-> (Set a) (Set a) Bit)) (sub? super sub)) diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux index d34fe97ac..af2b3c3ea 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -11,7 +11,7 @@ abstract]]]) (abstract: .public (Stack a) - {#.doc (doc "A first-in, last-out sequential data-structure.")} + {#.doc (example "A first-in, last-out sequential data-structure.")} (List a) @@ -28,7 +28,7 @@ (|>> :representation //.empty?)) (def: .public (peek stack) - {#.doc (doc "Yields the top value in the stack, if any.")} + {#.doc (example "Yields the top value in the stack, if any.")} (All [a] (-> (Stack a) (Maybe a))) (case (:representation stack) #.End diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux index 7d12bad74..69043cb63 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -17,12 +17,12 @@ ["." code]]]]) (type: .public (Tree a) - {#.doc (doc "A generic tree data-structure.")} + {#.doc (example "A generic tree data-structure.")} {#value a #children (List (Tree a))}) (def: .public (flat tree) - {#.doc (doc "All the leaf values of the tree, in order.")} + {#.doc (example "All the leaf values of the tree, in order.")} (All [a] (-> (Tree a) (List a))) (|> tree (get@ #children) @@ -55,12 +55,12 @@ (<>.and <code>.any))) (syntax: .public (tree {root tree^}) - {#.doc (doc "Tree literals." - (: (Tree Nat) - (tree 12 - {34 {} - 56 {} - 78 {90 {}}})))} + {#.doc (example "Tree literals." + (: (Tree Nat) + (tree 12 + {34 {} + 56 {} + 78 {90 {}}})))} (in (list (` (~ (loop [[value children] root] (` {#value (~ value) #children (list (~+ (list\map recur children)))}))))))) diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index 207d3bc41..9c2844be7 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -12,7 +12,7 @@ ... https://en.wikipedia.org/wiki/Finger_tree (abstract: .public (Tree @ t v) - {#.doc (doc "A finger tree.")} + {#.doc (example "A finger tree.")} {#monoid (Monoid t) #tag t @@ -20,7 +20,7 @@ [(Tree @ t v) (Tree @ t v)])} (interface: .public (Builder @ t) - {#.doc (doc "A builder for finter tree structures.")} + {#.doc (example "A builder for finter tree structures.")} (: (All [v] (-> t v (Tree @ t v))) leaf) @@ -40,7 +40,7 @@ ) (implementation: .public (builder monoid) - {#.doc (doc "A new builder using the given monoid.")} + {#.doc (example "A new builder using the given monoid.")} (All [t] (Ex [@] (-> (Monoid t) (Builder @ t)))) (def: (leaf tag value) @@ -85,7 +85,7 @@ (values right)))) (def: .public (one predicate tree) - {#.doc (doc "Finds one value that meets the predicate.")} + {#.doc (example "Finds one value that meets the predicate.")} (All [@ t v] (-> (Predicate t) (Tree @ t v) (Maybe v))) (let [[monoid tag root] (:representation tree)] (if (predicate tag) @@ -105,7 +105,7 @@ ) (def: .public (exists? predicate tree) - {#.doc (doc "Verifies that a value exists which meets the predicate.")} + {#.doc (example "Verifies that a value exists which meets the predicate.")} (All [@ t v] (-> (Predicate t) (Tree @ t v) Bit)) (case (..one predicate tree) (#.Some _) diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index 874c63ee8..b6fb27355 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -7,9 +7,10 @@ [comonad (#+ CoMonad)] [monad (#+ do)] [equivalence (#+ Equivalence)]] + [control + ["." maybe ("#\." monad)]] [data ["." product] - ["." maybe ("#\." monad)] [text ["%" format (#+ format)]] [collection diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux index ef2bff638..673e74e60 100644 --- a/stdlib/source/library/lux/data/color.lux +++ b/stdlib/source/library/lux/data/color.lux @@ -42,28 +42,28 @@ (|>> (f.* rgb_factor) f.int .nat)) (type: .public RGB - {#.doc (doc "Red-Green-Blue color format.")} + {#.doc (example "Red-Green-Blue color format.")} {#red Nat #green Nat #blue Nat}) (type: .public HSL - {#.doc (doc "Hue-Saturation-Lightness color format.")} + {#.doc (example "Hue-Saturation-Lightness color format.")} [Frac Frac Frac]) (type: .public CMYK - {#.doc (doc "Cyan-Magenta-Yellow-Key color format.")} + {#.doc (example "Cyan-Magenta-Yellow-Key color format.")} {#cyan Frac #magenta Frac #yellow Frac #key Frac}) (type: .public HSB - {#.doc (doc "Hue-Saturation-Brightness color format.")} + {#.doc (example "Hue-Saturation-Brightness color format.")} [Frac Frac Frac]) (abstract: .public Color - {#.doc (doc "A color value, independent of color format.")} + {#.doc (example "A color value, independent of color format.")} RGB @@ -128,7 +128,7 @@ (|> ..top (n.- value))) (def: .public (complement color) - {#.doc (doc "The opposite color.")} + {#.doc (example "The opposite color.")} (-> Color Color) (let [[red green blue] (:representation color)] (:abstraction {#red (complement' red) @@ -363,7 +363,7 @@ (syntax: (color_scheme_documentation {name <code>.local_identifier}) (let [name (text.replaced "_" "-" name) g!documentation (code.text (format "A " name " color scheme."))] - (in (list (` {#.doc (.doc (~ g!documentation))}))))) + (in (list (` {#.doc (.example (~ g!documentation))}))))) (template [<name> <1> <2>] [(`` (def: .public (<name> color) @@ -412,7 +412,7 @@ (syntax: (palette_documentation {name <code>.local_identifier}) (let [name (text.replaced "_" "-" name) g!documentation (code.text (format "A " name " palette."))] - (in (list (` {#.doc (.doc (~ g!documentation))}))))) + (in (list (` {#.doc (.example (~ g!documentation))}))))) (`` (def: .public (analogous spread variations color) (~~ (..palette_documentation analogous)) @@ -439,25 +439,25 @@ of_hsb)))))) (type: .public Alpha - {#.doc (doc "The degree of transparency of a pigment.")} + {#.doc (example "The degree of transparency of a pigment.")} Rev) (def: .public transparent - {#.doc (doc "The maximum degree of transparency.")} + {#.doc (example "The maximum degree of transparency.")} Alpha rev\bottom) (def: .public translucent - {#.doc (doc "The average degree of transparency.")} + {#.doc (example "The average degree of transparency.")} Alpha .5) (def: .public opaque - {#.doc (doc "The minimum degree of transparency.")} + {#.doc (example "The minimum degree of transparency.")} Alpha rev\top) (type: .public Pigment - {#.doc (doc "A color with some degree of transparency.")} + {#.doc (example "A color with some degree of transparency.")} {#color Color #alpha Alpha}) diff --git a/stdlib/source/library/lux/data/color/named.lux b/stdlib/source/library/lux/data/color/named.lux index 7637e1514..32e395bb1 100644 --- a/stdlib/source/library/lux/data/color/named.lux +++ b/stdlib/source/library/lux/data/color/named.lux @@ -27,7 +27,7 @@ (template [<red> <green> <blue> <name>] [(`` (def: .public <name> - {#.doc (doc (~~ (..documentation <red> <green> <blue> <name>)))} + {#.doc (example (~~ (..documentation <red> <green> <blue> <name>)))} Color (//.of_rgb {#//.red (hex <red>) #//.green (hex <green>) diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux index aac550b8b..f3ce9f830 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -33,22 +33,22 @@ (|>> (n.* i64.bits_per_byte) i64.mask)) (type: .public Mutation - {#.doc (doc "A mutation of binary data, tracking where in the data to transform.")} + {#.doc (example "A mutation of binary data, tracking where in the data to transform.")} (-> [Offset Binary] [Offset Binary])) (type: .public Specification - {#.doc (doc "A description of how to transform binary data.")} + {#.doc (example "A description of how to transform binary data.")} [Size Mutation]) (def: .public no_op - {#.doc (doc "A specification for empty binary data.")} + {#.doc (example "A specification for empty binary data.")} Specification [0 function.identity]) (def: .public (instance [size mutation]) - {#.doc (doc "Given a specification of how to construct binary data, yields a binary blob that matches it.")} + {#.doc (example "Given a specification of how to construct binary data, yields a binary blob that matches it.")} (-> Specification Binary) - (|> size binary.create [0] mutation product.right)) + (|> size binary.empty [0] mutation product.right)) (implementation: .public monoid (Monoid Specification) @@ -61,11 +61,11 @@ (|>> mutL mutR)])) (type: .public (Writer a) - {#.doc (doc "An operation that knows how to write information into a binary blob.")} + {#.doc (example "An operation that knows how to write information into a binary blob.")} (-> a Specification)) -(def: .public (run writer value) - {#.doc (doc "Yields a binary blob with all the information written to it.")} +(def: .public (result writer value) + {#.doc (example "Yields a binary blob with all the information written to it.")} (All [a] (-> (Writer a) a Binary)) (..instance (writer value))) @@ -110,7 +110,7 @@ (\ ..monoid compose (pre preV) (post postV)))) (def: .public (rec body) - {#.doc (doc "A combinator for recursive writers.")} + {#.doc (example "A combinator for recursive writers.")} (All [a] (-> (-> (Writer a) (Writer a)) (Writer a))) (function (recur value) (body recur value))) @@ -136,7 +136,7 @@ (|>> frac.bits ..bits/64)) (def: .public (segment size) - {#.doc (doc "Writes at most 'size' bytes of an input binary blob.")} + {#.doc (example "Writes at most 'size' bytes of an input binary blob.")} (-> Nat (Writer Binary)) (function (_ value) [size diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux index 52a44d226..e9288ecff 100644 --- a/stdlib/source/library/lux/data/format/css.lux +++ b/stdlib/source/library/lux/data/format/css.lux @@ -1,8 +1,9 @@ (.module: [library [lux (#- and) + [control + ["." maybe]] [data - ["." maybe] [number ["." nat]] ["." text diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index b0f7aa086..6b36f1443 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -2,12 +2,12 @@ [library [lux (#- All Cursor and static false true) [control + ["." maybe] [parser ["s" code]]] [data ["." color] ["." product] - ["." maybe] [number ["n" nat] ["i" int] diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index bcda0d2f3..34ab99976 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -1,10 +1,11 @@ (.module: [library [lux (#- Meta Source comment and) - ["." function] + [control + ["." function] + ["." maybe ("#\." functor)]] [data ["." product] - ["." maybe ("#\." functor)] ["." text ["%" format (#+ format)]] [collection @@ -293,7 +294,7 @@ (-> Attributes (List [Attributes Shape]) Image Image) ($_ ..and for - (case (list\map (product.uncurry ..area) areas) + (case (list\map (product.uncurried ..area) areas) #.End (..empty "map" attributes) diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index 5dd7e9c81..5d678fb2c 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -1,6 +1,6 @@ (.module: - {#.doc (.doc "Functionality for reading and writing values in the JSON format." - "For more information, please see: http://www.json.org/")} + {#.doc (.example "Functionality for reading and writing values in the JSON format." + "For more information, please see: http://www.json.org/")} [library [lux #* ["." meta (#+ monad)] @@ -11,19 +11,19 @@ ["." monad (#+ do)]] [control pipe + ["." maybe] ["." try (#+ Try)] ["<>" parser ("#\." monad) ["<.>" text (#+ Parser)]]] [data ["." bit] - ["." maybe] ["." product] ["." text ("#\." equivalence monoid)] [collection ["." list ("#\." fold functor)] ["." row (#+ Row row) ("#\." monad)] ["." dictionary (#+ Dictionary)]]] - [macro (#+ with_gensyms) + [macro [syntax (#+ syntax:)] ["." code]] [math @@ -67,14 +67,14 @@ (|>> (dictionary.of_list text.hash) #..Object)) (syntax: .public (json token) - {#.doc (doc "A simple way to produce JSON literals." - (json #null) - (json #1) - (json +123.456) - (json "this is a string") - (json ["this" "is" "an" "array"]) - (json {"this" "is" - "an" "object"}))} + {#.doc (example "A simple way to produce JSON literals." + (json #null) + (json #1) + (json +123.456) + (json "this is a string") + (json ["this" "is" "an" "array"]) + (json {"this" "is" + "an" "object"}))} (let [(^open ".") ..monad wrapper (function (_ x) (` (..json (~ x))))] (case token @@ -420,4 +420,4 @@ (Codec Text JSON) (def: encode ..format) - (def: decode (<text>.run json_parser))) + (def: decode (<text>.result json_parser))) diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index 802b7e03d..0278235b0 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -641,11 +641,11 @@ (Writer Header) (let [checksum (|> header (set@ #checksum ..dummy_checksum) - (format.run ..header_writer') + (format.result ..header_writer') ..checksum_code)] (|> header (set@ #checksum checksum) - (format.run ..header_writer') + (format.result ..header_writer') (format.segment ..block_size)))) (def: modification_time @@ -733,7 +733,7 @@ (def: .public writer (Writer Tar) - (let [end_of_archive (binary.create ..end_of_archive_size)] + (let [end_of_archive (binary.empty ..end_of_archive_size)] (function (_ tar) (format\compose (row\fold (function (_ next total) (format\compose total (..entry_writer next))) diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index b978eb195..637ba71f7 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -31,7 +31,7 @@ (Dictionary Attribute Text)) (def: .public attributes - {#.doc (doc "An empty set of XML attributes.")} + {#.doc (example "An empty set of XML attributes.")} Attrs (dictionary.empty name.hash)) @@ -207,14 +207,14 @@ (text.replaced text.double_quote """))) (def: .public (tag [namespace name]) - {#.doc (doc "The text format of a XML tag.")} + {#.doc (example "The text format of a XML tag.")} (-> Tag Text) (case namespace "" name _ ($_ text\compose namespace ..namespace_separator name))) (def: .public attribute - {#.doc (doc "The text format of a XML attribute.")} + {#.doc (example "The text format of a XML attribute.")} (-> Attribute Text) ..tag) @@ -273,7 +273,7 @@ text.new_line prefix "</" tag ">"))))) )))) (def: decode - (<text>.run ..xml^))) + (<text>.result ..xml^))) (implementation: .public equivalence (Equivalence XML) @@ -290,7 +290,7 @@ (n.= (list.size reference/children) (list.size sample/children)) (|> (list.zipped/2 reference/children sample/children) - (list.every? (product.uncurry =)))) + (list.every? (product.uncurried =)))) _ false))) diff --git a/stdlib/source/library/lux/data/identity.lux b/stdlib/source/library/lux/data/identity.lux index be7560d60..1a7f1ec76 100644 --- a/stdlib/source/library/lux/data/identity.lux +++ b/stdlib/source/library/lux/data/identity.lux @@ -10,7 +10,7 @@ ["." function]]]]) (type: .public (Identity a) - {#.doc (doc "A value, as is, without any extra structure super-imposed on it.")} + {#.doc (example "A value, as is, without any extra structure super-imposed on it.")} a) (implementation: .public functor diff --git a/stdlib/source/library/lux/data/name.lux b/stdlib/source/library/lux/data/name.lux index 901de118e..531a343b7 100644 --- a/stdlib/source/library/lux/data/name.lux +++ b/stdlib/source/library/lux/data/name.lux @@ -15,7 +15,7 @@ (template [<name> <doc>] [(def: .public (<name> name) - {#.doc (doc <doc>)} + {#.doc (example <doc>)} (-> Name Text) (let [[module short] name] <name>))] diff --git a/stdlib/source/library/lux/data/product.lux b/stdlib/source/library/lux/data/product.lux index 91358313b..4173f8133 100644 --- a/stdlib/source/library/lux/data/product.lux +++ b/stdlib/source/library/lux/data/product.lux @@ -8,7 +8,7 @@ (template [<name> <doc>] [(def: .public (<name> pair) - {#.doc (doc <doc>)} + {#.doc (example <doc>)} (All [left right] (-> [left right] <name>)) (let [[left right] pair] @@ -19,16 +19,16 @@ ) ... https://en.wikipedia.org/wiki/Currying -(def: .public (curry f) - {#.doc (doc "Converts a 2-argument function into nested single-argument functions.")} +(def: .public (curried f) + {#.doc (example "Converts a 2-argument function into nested single-argument functions.")} (All [a b c] (-> (-> [a b] c) (-> a b c))) (function (_ x y) (f [x y]))) -(def: .public (uncurry f) - {#.doc (doc "Converts nested single-argument functions into a 2-argument function.")} +(def: .public (uncurried f) + {#.doc (example "Converts nested single-argument functions into a 2-argument function.")} (All [a b c] (-> (-> a b c) (-> [a b] c))) @@ -36,13 +36,13 @@ (let [[x y] xy] (f x y)))) -(def: .public (swap xy) +(def: .public (swapped xy) (All [a b] (-> [a b] [b a])) (let [[x y] xy] [y x])) (def: .public (apply f g) - {#.doc (doc "Apply functions to both sides of a pair.")} + {#.doc (example "Apply functions to both sides of a pair.")} (All [a b c d] (-> (-> a c) (-> b d) (-> [a b] [c d]))) @@ -50,7 +50,7 @@ [(f x) (g y)])) (def: .public (fork f g) - {#.doc (doc "Yields a pair by applying both functions to a single value.")} + {#.doc (example "Yields a pair by applying both functions to a single value.")} (All [a l r] (-> (-> a l) (-> a r) (-> a [l r]))) diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux index bde3fc86f..84b19ffc3 100644 --- a/stdlib/source/library/lux/data/sum.lux +++ b/stdlib/source/library/lux/data/sum.lux @@ -8,7 +8,7 @@ (template [<right?> <name> <doc>] [(def: .public (<name> value) - {#.doc (doc <doc>)} + {#.doc (example <doc>)} (All [left right] (-> <name> (Or left right))) (0 <right?> value))] @@ -19,7 +19,7 @@ "Lifts value to the right side of a 2-variant."]) (def: .public (either fl fr) - {#.doc (doc "Applies a function to either side of a 2-variant.")} + {#.doc (example "Applies a function to either side of a 2-variant.")} (All [a b c] (-> (-> a c) (-> b c) (-> (Or a b) c))) @@ -29,7 +29,7 @@ (0 #1 r) (fr r)))) (def: .public (apply fl fr) - {#.doc (doc "Applies functions to both sides of a 2-variant.")} + {#.doc (example "Applies functions to both sides of a 2-variant.")} (All [l l' r r'] (-> (-> l l') (-> r r') (-> (Or l r) (Or l' r')))) diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index c6a418bb7..a1048d638 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -9,8 +9,9 @@ [order (#+ Order)] [monad (#+ do)] [codec (#+ Codec)]] + [control + ["." maybe]] [data - ["." maybe] [collection ["." list ("#\." fold)]]] [math @@ -19,7 +20,7 @@ ["." i64]]]]]) (type: .public Char - {#.doc (doc "A character code number.")} + {#.doc (example "A character code number.")} Nat) ... TODO: Instead of ints, chars should be produced fron nats. @@ -44,7 +45,7 @@ ) (def: .public line_feed - {#.doc (doc "Same as 'new_line'.")} + {#.doc (example "Same as 'new_line'.")} ..new_line) (def: .public size @@ -52,7 +53,7 @@ (|>> "lux text size")) (def: .public (char index input) - {#.doc (doc "Yields the character at the specified index.")} + {#.doc (example "Yields the character at the specified index.")} (-> Nat Text (Maybe Char)) (if (n.< ("lux text size" input) index) (#.Some ("lux text char" index input)) @@ -139,14 +140,14 @@ (..enclosed' ..double_quote)) (def: .public (clip offset size input) - {#.doc (doc "Clips a chunk of text from the input at the specified offset and of the specified size.")} + {#.doc (example "Clips a chunk of text from the input at the specified offset and of the specified size.")} (-> Nat Nat Text (Maybe Text)) (if (|> size (n.+ offset) (n.<= ("lux text size" input))) (#.Some ("lux text clip" offset size input)) #.None)) (def: .public (clip' offset input) - {#.doc (doc "Clips the remaining text from the input at the specified offset.")} + {#.doc (example "Clips the remaining text from the input at the specified offset.")} (-> Nat Text (Maybe Text)) (let [size ("lux text size" input)] (if (n.<= size offset) @@ -298,7 +299,7 @@ (def: .public (join_with separator texts) (-> Text (List Text) Text) - (|> texts (list.interpose separator) concat)) + (|> texts (list.interposed separator) concat)) (def: .public (empty? text) (-> Text Bit) diff --git a/stdlib/source/library/lux/data/text/encoding.lux b/stdlib/source/library/lux/data/text/encoding.lux index 673abe522..83474b909 100644 --- a/stdlib/source/library/lux/data/text/encoding.lux +++ b/stdlib/source/library/lux/data/text/encoding.lux @@ -1,24 +1,26 @@ (.module: [library [lux #* + [macro + ["." template]] [type abstract]]]) -... https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html - +... https://en.wikipedia.org/wiki/Character_encoding#Common_character_encodings (abstract: .public Encoding - {} + {#.doc (example "Encoding formats for text.")} Text (template [<name> <encoding>] - [(def: .public <name> - Encoding - (:abstraction <encoding>))] + [(`` (def: .public <name> + {#.doc (example (~~ (template.text ["'" <encoding> "' text encoding. "])))} + Encoding + (:abstraction <encoding>)))] [ascii "ASCII"] - [ibm_37 "IBM037"] + [ibm_037 "IBM037"] [ibm_273 "IBM273"] [ibm_277 "IBM277"] [ibm_278 "IBM278"] diff --git a/stdlib/source/library/lux/data/text/encoding/utf8.lux b/stdlib/source/library/lux/data/text/encoding/utf8.lux index d65231922..60955ba63 100644 --- a/stdlib/source/library/lux/data/text/encoding/utf8.lux +++ b/stdlib/source/library/lux/data/text/encoding/utf8.lux @@ -158,7 +158,7 @@ #try.Success)}))) (implementation: .public codec - {#.doc (doc "A codec for binary encoding of text as UTF-8.")} + {#.doc (example "A codec for binary encoding of text as UTF-8.")} (Codec Binary Text) (def: encode ..encode) diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux index f7fbaaf46..a8e2c79cc 100644 --- a/stdlib/source/library/lux/data/text/escape.lux +++ b/stdlib/source/library/lux/data/text/escape.lux @@ -5,12 +5,11 @@ [abstract [monad (#+ do)]] [control + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)] ["<>" parser ["<.>" code]]] - [data - ["." maybe]] [math [number (#+ hex) ["n" nat]]] @@ -111,7 +110,7 @@ post_limit])) (def: .public (escaped text) - {#.doc (doc "Yields a escaped version of the text.")} + {#.doc (example "Yields a escaped version of the text.")} (-> Text Text) (loop [offset 0 previous "" @@ -193,8 +192,8 @@ (exception.except ..invalid_unicode_escape [current offset]))) (def: .public (un_escaped text) - {#.doc (doc "Yields an un-escaped text." - "Fails if it was improperly escaped.")} + {#.doc (example "Yields an un-escaped text." + "Fails if it was improperly escaped.")} (-> Text (Try Text)) (loop [offset 0 previous "" @@ -240,7 +239,7 @@ _ (format previous current)))))) (syntax: .public (literal {literal <code>.text}) - {#.doc (doc "If given a escaped text literal, expands to an un-escaped version.")} + {#.doc (example "If given a escaped text literal, expands to an un-escaped version.")} (case (..un_escaped literal) (#try.Success un_escaped) (in (list (code.text un_escaped))) diff --git a/stdlib/source/library/lux/data/text/format.lux b/stdlib/source/library/lux/data/text/format.lux index 4cfd5cb34..612928a26 100644 --- a/stdlib/source/library/lux/data/text/format.lux +++ b/stdlib/source/library/lux/data/text/format.lux @@ -50,8 +50,8 @@ (|>> f fb))) (syntax: .public (format {fragments (<>.many <c>.any)}) - {#.doc (doc "Text interpolation." - (format "Static part " (text static) " does not match URI: " uri))} + {#.doc (example "Text interpolation." + (format "Static part " (text static) " does not match URI: " uri))} (in (.list (` ($_ "lux text concat" (~+ fragments)))))) (template [<name> <type> <formatter>] diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index ff9f48eee..a81b28c5a 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -5,6 +5,7 @@ [abstract monad] [control + ["." maybe] ["." try] ["." exception (#+ exception:)] ["<>" parser ("#\." monad) @@ -12,10 +13,9 @@ ["<.>" code]]] [data ["." product] - ["." maybe] [collection ["." list ("#\." fold monad)]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code]] [math @@ -412,68 +412,68 @@ (\ <>.monad map product.right (re_alternative^ #1 re_scoped^ current_module))) (syntax: .public (regex {pattern <code>.text}) - {#.doc (doc "Create lexers using regular-expression syntax." - "For example:" - - "Literals" - (regex "a") - - "Wildcards" - (regex ".") - - "Escaping" - (regex "\.") - - "Character classes" - (regex "\d") - (regex "\p{Lower}") - (regex "[abc]") - (regex "[a-z]") - (regex "[a-zA-Z]") - (regex "[a-z&&[def]]") - - "Negation" - (regex "[^abc]") - (regex "[^a-z]") - (regex "[^a-zA-Z]") - (regex "[a-z&&[^bc]]") - (regex "[a-z&&[^m-p]]") - - "Combinations" - (regex "aa") - (regex "a?") - (regex "a*") - (regex "a+") - - "Specific amounts" - (regex "a{2}") - - "At least" - (regex "a{1,}") - - "At most" - (regex "a{,1}") - - "Between" - (regex "a{1,2}") - - "Groups" - (regex "a(.)c") - (regex "a(b+)c") - (regex "(\d{3})-(\d{3})-(\d{4})") - (regex "(\d{3})-(?:\d{3})-(\d{4})") - (regex "(?<code>\d{3})-\k<code>-(\d{4})") - (regex "(?<code>\d{3})-\k<code>-(\d{4})-\0") - (regex "(\d{3})-((\d{3})-(\d{4}))") - - "Alternation" - (regex "a|b") - (regex "a(.)(.)|b(.)(.)") - )} + {#.doc (example "Create lexers using regular-expression syntax." + "For example:" + + "Literals" + (regex "a") + + "Wildcards" + (regex ".") + + "Escaping" + (regex "\.") + + "Character classes" + (regex "\d") + (regex "\p{Lower}") + (regex "[abc]") + (regex "[a-z]") + (regex "[a-zA-Z]") + (regex "[a-z&&[def]]") + + "Negation" + (regex "[^abc]") + (regex "[^a-z]") + (regex "[^a-zA-Z]") + (regex "[a-z&&[^bc]]") + (regex "[a-z&&[^m-p]]") + + "Combinations" + (regex "aa") + (regex "a?") + (regex "a*") + (regex "a+") + + "Specific amounts" + (regex "a{2}") + + "At least" + (regex "a{1,}") + + "At most" + (regex "a{,1}") + + "Between" + (regex "a{1,2}") + + "Groups" + (regex "a(.)c") + (regex "a(b+)c") + (regex "(\d{3})-(\d{3})-(\d{4})") + (regex "(\d{3})-(?:\d{3})-(\d{4})") + (regex "(?<code>\d{3})-\k<code>-(\d{4})") + (regex "(?<code>\d{3})-\k<code>-(\d{4})-\0") + (regex "(\d{3})-((\d{3})-(\d{4}))") + + "Alternation" + (regex "a|b") + (regex "a(.)(.)|b(.)(.)") + )} (do meta.monad [current_module meta.current_module_name] - (case (<text>.run (regex^ current_module) - pattern) + (case (<text>.result (regex^ current_module) + pattern) (#try.Failure error) (meta.failure (format "Error while parsing regular-expression:" //.new_line error)) @@ -485,20 +485,20 @@ (syntax: .public (^regex {[pattern bindings] (<code>.form (<>.and <code>.text (<>.maybe <code>.any)))} body {branches (<>.many <code>.any)}) - {#.doc (doc "Allows you to test text against regular expressions." - (case some_text - (^regex "(\d{3})-(\d{3})-(\d{4})" - [_ country_code area_code place_code]) - do_some_thing_when_number - - (^regex "\w+") - do_some_thing_when_word - - _ - do_something_else))} - (with_gensyms [g!temp] + {#.doc (example "Allows you to test text against regular expressions." + (case some_text + (^regex "(\d{3})-(\d{3})-(\d{4})" + [_ country_code area_code place_code]) + do_some_thing_when_number + + (^regex "\w+") + do_some_thing_when_word + + _ + do_something_else))} + (with_identifiers [g!temp] (in (list& (` (^multi (~ g!temp) - {((~! <text>.run) (..regex (~ (code.text pattern))) (~ g!temp)) + {((~! <text>.result) (..regex (~ (code.text pattern))) (~ g!temp)) (#try.Success (~ (maybe.else g!temp bindings)))})) body branches)))) diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux index e9c1298fe..16f8ba47a 100644 --- a/stdlib/source/library/lux/data/text/unicode/block.lux +++ b/stdlib/source/library/lux/data/text/unicode/block.lux @@ -22,7 +22,7 @@ ["." /// (#+ Char)]) (abstract: .public Block - {#.doc (doc "A block of valid unicode characters.")} + {#.doc (example "A block of valid unicode characters.")} (Interval Char) @@ -87,7 +87,7 @@ [(with_expansions [<block_name> (..block_name <name>) <documentation> (template.text [<start> "-" <end> " | " <block_name>])] (def: .public <name> - {#.doc (doc <documentation>)} + {#.doc (example <documentation>)} Block (let [start (hex <start>) end (hex <end>)] diff --git a/stdlib/source/library/lux/data/trace.lux b/stdlib/source/library/lux/data/trace.lux index 5767084eb..8917fc89a 100644 --- a/stdlib/source/library/lux/data/trace.lux +++ b/stdlib/source/library/lux/data/trace.lux @@ -31,6 +31,6 @@ ((get@ #trace wa) (\ monoid compose t1 t2)))})}))) -(def: .public (run context tracer) +(def: .public (result context tracer) (All [t a] (-> t (Trace t a) a)) (\ tracer trace context)) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 235528c6b..45fdba0d2 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -513,7 +513,7 @@ (def: .public (representation type value) (-> Type Any (Try Text)) - (case (<type>.run ..representation_parser type) + (case (<type>.result ..representation_parser type) (#try.Success representation) (#try.Success (representation value)) diff --git a/stdlib/source/library/lux/extension.lux b/stdlib/source/library/lux/extension.lux index ae9745baa..4a97254e9 100644 --- a/stdlib/source/library/lux/extension.lux +++ b/stdlib/source/library/lux/extension.lux @@ -12,7 +12,7 @@ ["." product] [collection ["." list ("#\." functor)]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) ["." code] [syntax (#+ syntax:)]] [tool @@ -56,7 +56,7 @@ <c>.local_identifier (<>.some (..input default))))) -(template [<any> <end> <and> <run> <extension> <name>] +(template [<any> <end> <and> <result> <extension> <name>] [(syntax: .public (<name> {[name extension phase archive inputs] (..declaration (` <any>))} body) @@ -69,10 +69,10 @@ g!name (code.local_identifier extension) g!phase (code.local_identifier phase) g!archive (code.local_identifier archive)] - (with_gensyms [g!handler g!inputs g!error] + (with_identifiers [g!handler g!inputs g!error] (in (list (` (<extension> (~ name) (.function ((~ g!handler) (~ g!name) (~ g!phase) (~ g!archive) (~ g!inputs)) - (.case ((~! <run>) (~ g!parser) (~ g!inputs)) + (.case ((~! <result>) (~ g!parser) (~ g!inputs)) (#.Right [(~+ (list\map (|>> product.left code.local_identifier) inputs))]) @@ -82,8 +82,8 @@ ((~! phase.failure) (~ g!error))) ))))))))] - [<c>.any <c>.end! <c>.and <c>.run "lux def analysis" analysis:] - [<a>.any <a>.end! <a>.and <a>.run "lux def synthesis" synthesis:] - [<s>.any <s>.end! <s>.and <s>.run "lux def generation" generation:] - [<c>.any <c>.end! <c>.and <c>.run "lux def directive" directive:] + [<c>.any <c>.end! <c>.and <c>.result "lux def analysis" analysis:] + [<a>.any <a>.end! <a>.and <a>.result "lux def synthesis" synthesis:] + [<s>.any <s>.end! <s>.and <s>.result "lux def generation" generation:] + [<c>.any <c>.end! <c>.and <c>.result "lux def directive" directive:] ) diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux index 9cd8c739c..ef3837e6c 100644 --- a/stdlib/source/library/lux/ffi.js.lux +++ b/stdlib/source/library/lux/ffi.js.lux @@ -6,18 +6,18 @@ [monad (#+ do)]] [control ["." io] + ["." maybe] ["<>" parser ("#\." monad) ["<.>" code (#+ Parser)]]] [data ["." product] - ["." maybe] ["." text ["%" format]] [collection ["." list ("#\." functor fold)]]] [type abstract] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code] ["." template]]]]) @@ -167,7 +167,7 @@ (` (let [(~ g!temp) (~ output)] (if (not ("js object null?" (~ g!temp))) (~ g!temp) - (.error! "Null is an invalid value.")))))) + (.panic! "Null is an invalid value.")))))) (type: Class_Declaration [Text (List Text)]) @@ -233,10 +233,10 @@ (~+ (list\map (with_null g!temp) g!inputs))))))))))) (syntax: .public (import: {import ..import}) - (with_gensyms [g!temp] + (with_identifiers [g!temp] (case import (#Class [[class_name class_parameters] format members]) - (with_gensyms [g!object] + (with_identifiers [g!object] (let [qualify (: (-> Text Code) (function (_ member_name) (|> format @@ -324,7 +324,7 @@ (syntax: .public (constant type {[head tail] (<code>.tuple (<>.and <code>.local_identifier (<>.some <code>.local_identifier)))}) - (with_gensyms [g!_] + (with_identifiers [g!_] (let [constant (` ("js constant" (~ (code.text head))))] (case tail #.End diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index 70eafbd8d..1b0133aa8 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -8,12 +8,12 @@ [control ["." function] ["." io] + ["." maybe] ["." try (#+ Try)] ["." exception (#+ Exception exception:)] ["<>" parser ("#\." monad) ["<.>" code (#+ Parser)]]] [data - ["." maybe] ["." product] ["." text ("#\." equivalence) ["%" format (#+ format)]] @@ -21,7 +21,7 @@ ["." array] ["." list ("#\." monad fold monoid)] ["." dictionary (#+ Dictionary)]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code] ["." template]] @@ -125,9 +125,9 @@ (template [<name> <op> <from> <to>] [(template: .public (<name> value) - {#.doc (doc "Type converter." - (: <to> - (<name> (: <from> foo))))} + {#.doc (example "Type converter." + (: <to> + (<name> (: <from> foo))))} [(|> value (: <from>) "jvm object cast" @@ -168,9 +168,9 @@ (template [<name> <from> <to> <0> <1>] [(template: .public (<name> value) - {#.doc (doc "Type converter." - (: <to> - (<name> (: <from> foo))))} + {#.doc (example "Type converter." + (: <to> + (<name> (: <from> foo))))} [(|> value <0> <1>)])] [long_to_char ..Long ..Character ..long_to_int ..int_to_char] @@ -436,7 +436,7 @@ (def: (parser->replacer p ast) (-> (Parser Code) (-> Code Code)) - (case (<>.run p (list ast)) + (case (<>.result p (list ast)) (#.Right [#.End ast']) ast' @@ -1210,37 +1210,37 @@ {annotations ..annotations^} {fields (<>.some (..field_decl^ class_vars))} {methods (<>.some (..method_def^ class_vars))}) - {#.doc (doc "Allows defining JVM classes in Lux code." - "For example:" - (class: #final (TestClass A) [Runnable] - ... Fields - (#private foo boolean) - (#private bar A) - (#private baz java/lang/Object) - ... Methods - (#public [] (new [value A]) [] - (exec - (:= ::foo #1) - (:= ::bar value) - (:= ::baz "") - [])) - (#public (virtual) java/lang/Object - "") - (#public #static (static) java/lang/Object - "") - (Runnable [] (run) void - []) - ) - - "The tuple corresponds to parent interfaces." - "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." - "Fields and methods defined in the class can be used with special syntax." - "For example:" - "::resolved, for accessing the 'resolved' field." - "(:= ::resolved #1) for modifying it." - "(::new! []) for calling the class's constructor." - "(::resolve! container [value]) for calling the 'resolve' method." - )} + {#.doc (example "Allows defining JVM classes in Lux code." + "For example:" + (class: #final (TestClass A) [Runnable] + ... Fields + (#private foo boolean) + (#private bar A) + (#private baz java/lang/Object) + ... Methods + (#public [] (new [value A]) [] + (exec + (:= ::foo #1) + (:= ::bar value) + (:= ::baz "") + [])) + (#public (virtual) java/lang/Object + "") + (#public #static (static) java/lang/Object + "") + (Runnable [] (run) void + []) + ) + + "The tuple corresponds to parent interfaces." + "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." + "Fields and methods defined in the class can be used with special syntax." + "For example:" + "::resolved, for accessing the 'resolved' field." + "(:= ::resolved #1) for modifying it." + "(::new! []) for calling the class's constructor." + "(::resolve! container [value]) for calling the 'resolve' method." + )} (do meta.monad [.let [fully_qualified_class_name full_class_name method_parser (: (Parser Code) @@ -1263,9 +1263,9 @@ (<code>.tuple (<>.some (class^ class_vars))))} {annotations ..annotations^} {members (<>.some (..method_decl^ class_vars))}) - {#.doc (doc "Allows defining JVM interfaces." - (interface: TestInterface - ([] foo [boolean String] void #throws [Exception])))} + {#.doc (example "Allows defining JVM interfaces." + (interface: TestInterface + ([] foo [boolean String] void #throws [Exception])))} (in (list (` ("jvm class interface" (~ (declaration$ (type.declaration full_class_name class_vars))) [(~+ (list\map class$ supers))] @@ -1280,17 +1280,17 @@ (<code>.tuple (<>.some (class^ class_vars))))} {constructor_args (..constructor_args^ class_vars)} {methods (<>.some ..overriden_method_def^)}) - {#.doc (doc "Allows defining anonymous classes." - "The 1st tuple corresponds to class-level type-variables." - "The 2nd tuple corresponds to parent interfaces." - "The 3rd tuple corresponds to arguments to the super class constructor." - "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." - (object [] [Runnable] - [] - (Runnable [] (run self) void - (exec (do_something some_value) - []))) - )} + {#.doc (example "Allows defining anonymous classes." + "The 1st tuple corresponds to class-level type-variables." + "The 2nd tuple corresponds to parent interfaces." + "The 3rd tuple corresponds to arguments to the super class constructor." + "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." + (object [] [Runnable] + [] + (Runnable [] (run self) void + (exec (do_something some_value) + []))) + )} (in (list (` ("jvm class anonymous" [(~+ (list\map var$ class_vars))] (~ (class$ super)) @@ -1299,39 +1299,39 @@ [(~+ (list\map (method_def$ "" (<>.failure "") super (list)) methods))]))))) (syntax: .public (null) - {#.doc (doc "Null object reference." - (null))} + {#.doc (example "Null object reference." + (null))} (in (list (` ("jvm object null"))))) (def: .public (null? obj) - {#.doc (doc "Test for null object reference." - (= (null? (null)) - true) - (= (null? "YOLO") - false))} + {#.doc (example "Test for null object reference." + (= (null? (null)) + true) + (= (null? "YOLO") + false))} (-> (primitive "java.lang.Object") Bit) ("jvm object null?" obj)) (syntax: .public (??? expr) - {#.doc (doc "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." - (= (??? (: java/lang/String (null))) - #.None) - (= (??? "YOLO") - (#.Some "YOLO")))} - (with_gensyms [g!temp] + {#.doc (example "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." + (= (??? (: java/lang/String (null))) + #.None) + (= (??? "YOLO") + (#.Some "YOLO")))} + (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ expr)] (if ("jvm object null?" (~ g!temp)) #.None (#.Some (~ g!temp))))))))) (syntax: .public (!!! expr) - {#.doc (doc "Takes a (Maybe ObjectType) and returns a ObjectType." - "A #.None would get translated into a (null)." - (= (null) - (!!! (??? (: java/lang/Thread (null))))) - (= "foo" - (!!! (??? "foo"))))} - (with_gensyms [g!value] + {#.doc (example "Takes a (Maybe ObjectType) and returns a ObjectType." + "A #.None would get translated into a (null)." + (= (null) + (!!! (??? (: java/lang/Thread (null))))) + (= "foo" + (!!! (??? "foo"))))} + (with_identifiers [g!value] (in (list (` ({(#.Some (~ g!value)) (~ g!value) @@ -1341,12 +1341,12 @@ (syntax: .public (check {class (..type^ (list))} {unchecked (<>.maybe <code>.any)}) - {#.doc (doc "Checks whether an object is an instance of a particular class." - "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes." - (case (check String "YOLO") - (#.Some value_as_string) - #.None))} - (with_gensyms [g!_ g!unchecked] + {#.doc (example "Checks whether an object is an instance of a particular class." + "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes." + (case (check String "YOLO") + (#.Some value_as_string) + #.None))} + (with_identifiers [g!_ g!unchecked] (let [class_name (..reflection class) class_type (` (.primitive (~ (code.text class_name)))) check_type (` (.Maybe (~ class_type))) @@ -1367,19 +1367,19 @@ )))) (syntax: .public (synchronized lock body) - {#.doc (doc "Evaluates body, while holding a lock on a given object." - (synchronized object_to_be_locked - (exec (do_something ___) - (do_something_else ___) - (finish_the_computation ___))))} + {#.doc (example "Evaluates body, while holding a lock on a given object." + (synchronized object_to_be_locked + (exec (do_something ___) + (do_something_else ___) + (finish_the_computation ___))))} (in (list (` ("jvm object synchronized" (~ lock) (~ body)))))) (syntax: .public (do_to obj {methods (<>.some partial_call^)}) - {#.doc (doc "Call a variety of methods on an object. Then, return the object." - (do_to object - (ClassName::method1 arg0 arg1 arg2) - (ClassName::method2 arg3 arg4 arg5)))} - (with_gensyms [g!obj] + {#.doc (example "Call a variety of methods on an object. Then, return the object." + (do_to object + (ClassName::method1 arg0 arg1 arg2) + (ClassName::method2 arg3 arg4 arg5)))} + (with_identifiers [g!obj] (in (list (` (let [(~ g!obj) (~ obj)] (exec (~+ (list\map (complete_call$ g!obj) methods)) (~ g!obj)))))))) @@ -1422,7 +1422,7 @@ [arg_inputs (monad.map ! (: (-> [Bit (Type Value)] (Meta [Bit Code])) (function (_ [maybe? _]) - (with_gensyms [arg_name] + (with_identifiers [arg_name] (in [maybe? arg_name])))) import_member_args) .let [input_jvm_types (list\map product.right import_member_args) @@ -1455,7 +1455,7 @@ (if (not (..null? (:as (primitive "java.lang.Object") (~ g!temp)))) (~ g!temp) - (error! "Cannot produce null references from method calls.")))))) + (panic! "Cannot produce null references from method calls.")))))) _ return_term)) @@ -1607,7 +1607,7 @@ ((~' in) (.list (.` (~ jvm_interop))))))))) (#MethodDecl [commons method]) - (with_gensyms [g!obj] + (with_identifiers [g!obj] (do meta.monad [.let [def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))]) (^slots [#import_member_kind]) commons @@ -1665,7 +1665,7 @@ [.let [(^open ".") fad getter_name (code.identifier ["" (..import_name import_format method_prefix import_field_name)]) setter_name (code.identifier ["" (..import_name import_format method_prefix (format import_field_name "!"))])] - getter_interop (with_gensyms [g!obj] + getter_interop (with_identifiers [g!obj] (let [getter_call (if import_field_static? (` ((~ getter_name))) (` ((~ getter_name) (~ g!obj)))) @@ -1684,7 +1684,7 @@ ((~' in) (.list (.` (~ getter_body))))))))) setter_interop (: (Meta (List Code)) (if import_field_setter? - (with_gensyms [g!obj g!value] + (with_identifiers [g!obj g!value] (let [setter_call (if import_field_static? (` ((~ setter_name) (~ g!value))) (` ((~ setter_name) (~ g!value) (~ g!obj)))) @@ -1743,57 +1743,57 @@ {declaration ..declaration^} {.let [[class_name class_type_vars] (parser.declaration declaration)]} {bundles (<>.some (..bundle class_type_vars))}) - {#.doc (doc "Allows importing JVM classes, and using them as types." - "Their methods, fields and enum options can also be imported." - (import: java/lang/Object - ["#::." - (new []) - (equals [java/lang/Object] boolean) - (wait [int] #io #try void)]) - - "Special options can also be given for the return values." - "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None." - "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type." - "#io means the computation has side effects, and will be wrapped by the IO type." - "These options must show up in the following order [#io #try #?] (although, each option can be used independently)." - (import: java/lang/String - ["#::." - (new [[byte]]) - (#static valueOf [char] java/lang/String) - (#static valueOf #as int_valueOf [int] java/lang/String)]) - - (import: (java/util/List e) - ["#::." - (size [] int) - (get [int] e)]) - - (import: (java/util/ArrayList a) - ["#::." - ([T] toArray [[T]] [T])]) - - "The class-type that is generated is of the fully-qualified name." - "This avoids a clash between the java.util.List type, and Lux's own List type." - "All enum options to be imported must be specified." - (import: java/lang/Character$UnicodeScript - ["#::." - (#enum ARABIC CYRILLIC LATIN)]) - - "It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars." - "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)." - (import: (lux/concurrency/async/JvmAsync A) - ["#::." - (resolve [A] boolean) - (poll [] A) - (wasResolved [] boolean) - (waitOn [lux/Function] void) - (#static [A] make [A] (lux/concurrency/async/JvmAsync A))]) - - "Also, the names of the imported members will look like Class::member" - (java/lang/Object::new []) - (java/lang/Object::equals [other_object] my_object) - (java/util/List::size [] my_list) - java/lang/Character$UnicodeScript::LATIN - )} + {#.doc (example "Allows importing JVM classes, and using them as types." + "Their methods, fields and enum options can also be imported." + (import: java/lang/Object + ["#::." + (new []) + (equals [java/lang/Object] boolean) + (wait [int] #io #try void)]) + + "Special options can also be given for the return values." + "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None." + "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type." + "#io means the computation has side effects, and will be wrapped by the IO type." + "These options must show up in the following order [#io #try #?] (although, each option can be used independently)." + (import: java/lang/String + ["#::." + (new [[byte]]) + (#static valueOf [char] java/lang/String) + (#static valueOf #as int_valueOf [int] java/lang/String)]) + + (import: (java/util/List e) + ["#::." + (size [] int) + (get [int] e)]) + + (import: (java/util/ArrayList a) + ["#::." + ([T] toArray [[T]] [T])]) + + "The class-type that is generated is of the fully-qualified name." + "This avoids a clash between the java.util.List type, and Lux's own List type." + "All enum options to be imported must be specified." + (import: java/lang/Character$UnicodeScript + ["#::." + (#enum ARABIC CYRILLIC LATIN)]) + + "It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars." + "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)." + (import: (lux/concurrency/async/JvmAsync A) + ["#::." + (resolve [A] boolean) + (poll [] A) + (wasResolved [] boolean) + (waitOn [lux/Function] void) + (#static [A] make [A] (lux/concurrency/async/JvmAsync A))]) + + "Also, the names of the imported members will look like Class::member" + (java/lang/Object::new []) + (java/lang/Object::equals [other_object] my_object) + (java/util/List::size [] my_list) + java/lang/Character$UnicodeScript::LATIN + )} (do {! meta.monad} [kind (class_kind declaration) =members (|> bundles @@ -1805,8 +1805,8 @@ (syntax: .public (array {type (..type^ (list))} size) - {#.doc (doc "Create an array of the given type, with the given size." - (array java/lang/Object 10))} + {#.doc (example "Create an array of the given type, with the given size." + (array java/lang/Object 10))} (let [g!size (` (|> (~ size) (.: .Nat) (.:as (.primitive (~ (code.text box.long)))) @@ -1924,8 +1924,8 @@ <failure>)))) (syntax: .public (array_length array) - {#.doc (doc "Gives the length of an array." - (array_length my_array))} + {#.doc (example "Gives the length of an array." + (array_length my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -1955,13 +1955,13 @@ (.:as .Nat)))))) _ - (with_gensyms [g!array] + (with_identifiers [g!array] (in (list (` (let [(~ g!array) (~ array)] (..array_length (~ g!array))))))))) (syntax: .public (array_read idx array) - {#.doc (doc "Loads an element from an array." - (array_read 10 my_array))} + {#.doc (example "Loads an element from an array." + (array_read 10 my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -1993,13 +1993,13 @@ (in (list (` ("jvm array read object" (~ g!idx) (~ array)))))))) _ - (with_gensyms [g!array] + (with_identifiers [g!array] (in (list (` (let [(~ g!array) (~ array)] (..array_read (~ idx) (~ g!array))))))))) (syntax: .public (array_write idx value array) - {#.doc (doc "Stores an element into an array." - (array_write 10 my_object my_array))} + {#.doc (example "Stores an element into an array." + (array_write 10 my_object my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -2032,13 +2032,13 @@ (in (list (` ("jvm array write object" (~ g!idx) (~ value) (~ array)))))))) _ - (with_gensyms [g!array] + (with_identifiers [g!array] (in (list (` (let [(~ g!array) (~ array)] (..array_write (~ idx) (~ value) (~ g!array))))))))) (syntax: .public (class_for {type (..type^ (list))}) - {#.doc (doc "Loads the class as a java.lang.Class object." - (class_for java/lang/String))} + {#.doc (example "Loads the class as a java.lang.Class object." + (class_for java/lang/String))} (in (list (` ("jvm object class" (~ (code.text (..reflection type)))))))) (syntax: .public (type {type (..type^ (list))}) diff --git a/stdlib/source/library/lux/ffi.lua.lux b/stdlib/source/library/lux/ffi.lua.lux index a0ee4ab01..8370a58d4 100644 --- a/stdlib/source/library/lux/ffi.lua.lux +++ b/stdlib/source/library/lux/ffi.lua.lux @@ -7,18 +7,18 @@ [monad (#+ do)]] [control ["." io] + ["." maybe] ["<>" parser ("#\." monad) ["<.>" code (#+ Parser)]]] [data ["." product] - ["." maybe] ["." text ["%" format]] [collection ["." list ("#\." functor fold)]]] [type abstract] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code] ["." template]]]]) @@ -154,7 +154,7 @@ (` (let [(~ g!temp) (~ output)] (if (not ("lua object nil?" (~ g!temp))) (~ g!temp) - (.error! "Nil is an invalid value!")))))) + (.panic! "Nil is an invalid value!")))))) (type: Import (#Class [Text Text (List Member)]) @@ -213,10 +213,10 @@ (~+ (list\map (with_nil g!temp) g!inputs))))))))))) (syntax: .public (import: {import ..import}) - (with_gensyms [g!temp] + (with_identifiers [g!temp] (case import (#Class [class format members]) - (with_gensyms [g!object] + (with_identifiers [g!object] (let [qualify (: (-> Text Code) (function (_ member_name) (|> format diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index 8c20e8ae2..3413ee442 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -8,11 +8,11 @@ [control ["." function] ["." io] + ["." maybe] ["." try (#+ Try)] ["<>" parser ["<.>" code (#+ Parser)]]] [data - ["." maybe] ["." product] ["." bit ("#\." codec)] ["." text ("#\." equivalence monoid) @@ -20,7 +20,7 @@ [collection ["." array (#+ Array)] ["." list ("#\." monad fold monoid)]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code]] ["." meta @@ -28,9 +28,9 @@ (template [<name> <op> <from> <to>] [(def: .public (<name> value) - {#.doc (doc "Type converter." - (: <to> - (<name> (: <from> foo))))} + {#.doc (example "Type converter." + (: <to> + (<name> (: <from> foo))))} (-> (primitive <from>) (primitive <to>)) (<op> value))] @@ -426,7 +426,7 @@ (def: (parser_replacer p ast) (-> (Parser Code) (-> Code Code)) - (case (<>.run p (list ast)) + (case (<>.result p (list ast)) (#.Right [#.End ast']) ast' @@ -1177,36 +1177,36 @@ {annotations ..annotations^} {fields (<>.some (..field_decl^ class_vars))} {methods (<>.some (..method_def^ class_vars))}) - {#.doc (doc "Allows defining JVM classes in Lux code." - "For example:" - (class: #final (TestClass A) [Runnable] - ... Fields - (#private foo boolean) - (#private bar A) - (#private baz java/lang/Object) - ... Methods - (#public [] (new [value A]) [] - (exec (:= ::foo #1) - (:= ::bar value) - (:= ::baz "") - [])) - (#public (virtual) java/lang/Object - "") - (#public #static (static) java/lang/Object - "") - (Runnable [] (run) void - []) - ) - - "The tuple corresponds to parent interfaces." - "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." - "Fields and methods defined in the class can be used with special syntax." - "For example:" - "::resolved, for accessing the 'resolved' field." - "(:= ::resolved #1) for modifying it." - "(::new! []) for calling the class's constructor." - "(::resolve! container [value]) for calling the 'resolve' method." - )} + {#.doc (example "Allows defining JVM classes in Lux code." + "For example:" + (class: #final (TestClass A) [Runnable] + ... Fields + (#private foo boolean) + (#private bar A) + (#private baz java/lang/Object) + ... Methods + (#public [] (new [value A]) [] + (exec (:= ::foo #1) + (:= ::bar value) + (:= ::baz "") + [])) + (#public (virtual) java/lang/Object + "") + (#public #static (static) java/lang/Object + "") + (Runnable [] (run) void + []) + ) + + "The tuple corresponds to parent interfaces." + "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." + "Fields and methods defined in the class can be used with special syntax." + "For example:" + "::resolved, for accessing the 'resolved' field." + "(:= ::resolved #1) for modifying it." + "(::new! []) for calling the class's constructor." + "(::resolve! container [value]) for calling the 'resolve' method." + )} (do meta.monad [current_module meta.current_module_name .let [fully_qualified_class_name (format (safe current_module) "." full_class_name) @@ -1232,9 +1232,9 @@ (<code>.tuple (<>.some (..super_class_decl^ class_vars))))} {annotations ..annotations^} {members (<>.some (..method_decl^ class_vars))}) - {#.doc (doc "Allows defining JVM interfaces." - (interface: TestInterface - ([] foo [boolean String] void #throws [Exception])))} + {#.doc (example "Allows defining JVM interfaces." + (interface: TestInterface + ([] foo [boolean String] void #throws [Exception])))} (let [def_code (format "jvm interface:" (spaced (list (class_decl$ class_decl) (with_brackets (spaced (list\map super_class_decl$ supers))) @@ -1251,17 +1251,17 @@ (<code>.tuple (<>.some (..super_class_decl^ class_vars))))} {constructor_args (..constructor_args^ class_vars)} {methods (<>.some ..overriden_method_def^)}) - {#.doc (doc "Allows defining anonymous classes." - "The 1st tuple corresponds to class-level type-variables." - "The 2nd tuple corresponds to parent interfaces." - "The 3rd tuple corresponds to arguments to the super class constructor." - "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." - (object [] [Runnable] - [] - (Runnable [] (run self) void - (exec (do_something some_value) - []))) - )} + {#.doc (example "Allows defining anonymous classes." + "The 1st tuple corresponds to class-level type-variables." + "The 2nd tuple corresponds to parent interfaces." + "The 3rd tuple corresponds to arguments to the super class constructor." + "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." + (object [] [Runnable] + [] + (Runnable [] (run self) void + (exec (do_something some_value) + []))) + )} (let [def_code (format "jvm anon-class:" (spaced (list (super_class_decl$ super) (with_brackets (spaced (list\map super_class_decl$ interfaces))) @@ -1270,39 +1270,39 @@ (in (list (` ((~ (code.text def_code)))))))) (syntax: .public (null) - {#.doc (doc "Null object reference." - (null))} + {#.doc (example "Null object reference." + (null))} (in (list (` ("jvm object null"))))) (def: .public (null? obj) - {#.doc (doc "Test for null object reference." - (= (null? (null)) - true) - (= (null? "YOLO") - false))} + {#.doc (example "Test for null object reference." + (= (null? (null)) + true) + (= (null? "YOLO") + false))} (-> (primitive "java.lang.Object") Bit) ("jvm object null?" obj)) (syntax: .public (??? expr) - {#.doc (doc "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." - (= (??? (: java/lang/String (null))) - #.None) - (= (??? "YOLO") - (#.Some "YOLO")))} - (with_gensyms [g!temp] + {#.doc (example "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." + (= (??? (: java/lang/String (null))) + #.None) + (= (??? "YOLO") + (#.Some "YOLO")))} + (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ expr)] (if ("jvm object null?" (~ g!temp)) #.None (#.Some (~ g!temp))))))))) (syntax: .public (!!! expr) - {#.doc (doc "Takes a (Maybe ObjectType) and returns a ObjectType." - "A #.None would get translated into a (null)." - (= (null) - (!!! (??? (: java/lang/Thread (null))))) - (= "foo" - (!!! (??? "foo"))))} - (with_gensyms [g!value] + {#.doc (example "Takes a (Maybe ObjectType) and returns a ObjectType." + "A #.None would get translated into a (null)." + (= (null) + (!!! (??? (: java/lang/Thread (null))))) + (= "foo" + (!!! (??? "foo"))))} + (with_identifiers [g!value] (in (list (` ({(#.Some (~ g!value)) (~ g!value) @@ -1312,12 +1312,12 @@ (syntax: .public (check {class (..generic_type^ (list))} {unchecked (<>.maybe <code>.any)}) - {#.doc (doc "Checks whether an object is an instance of a particular class." - "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes." - (case (check java/lang/String "YOLO") - (#.Some value_as_string) - #.None))} - (with_gensyms [g!_ g!unchecked] + {#.doc (example "Checks whether an object is an instance of a particular class." + "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes." + (case (check java/lang/String "YOLO") + (#.Some value_as_string) + #.None))} + (with_identifiers [g!_ g!unchecked] (let [class_name (simple_class$ (list) class) class_type (` (.primitive (~ (code.text class_name)))) check_type (` (.Maybe (~ class_type))) @@ -1338,19 +1338,19 @@ )))) (syntax: .public (synchronized lock body) - {#.doc (doc "Evaluates body, while holding a lock on a given object." - (synchronized object_to_be_locked - (exec (do_something ___) - (do_something_else ___) - (finish_the_computation ___))))} + {#.doc (example "Evaluates body, while holding a lock on a given object." + (synchronized object_to_be_locked + (exec (do_something ___) + (do_something_else ___) + (finish_the_computation ___))))} (in (list (` ("jvm object synchronized" (~ lock) (~ body)))))) (syntax: .public (do_to obj {methods (<>.some partial_call^)}) - {#.doc (doc "Call a variety of methods on an object. Then, return the object." - (do_to object - (ClassName::method1 arg0 arg1 arg2) - (ClassName::method2 arg3 arg4 arg5)))} - (with_gensyms [g!obj] + {#.doc (example "Call a variety of methods on an object. Then, return the object." + (do_to object + (ClassName::method1 arg0 arg1 arg2) + (ClassName::method2 arg3 arg4 arg5)))} + (with_identifiers [g!obj] (in (list (` (let [(~ g!obj) (~ obj)] (exec (~+ (list\map (complete_call$ g!obj) methods)) (~ g!obj)))))))) @@ -1391,7 +1391,7 @@ [arg_inputs (monad.map ! (: (-> [Bit GenericType] (Meta [Bit Code])) (function (_ [maybe? _]) - (with_gensyms [arg_name] + (with_identifiers [arg_name] (in [maybe? arg_name])))) import_member_args) .let [arg_classes (: (List Text) @@ -1420,7 +1420,7 @@ (if (not (..null? (:as (primitive "java.lang.Object") (~ g!temp)))) (~ g!temp) - (error! (~ (code.text (format "Cannot produce null references from method calls @ " + (panic! (~ (code.text (format "Cannot produce null references from method calls @ " (get@ #class_name class) "." (get@ #import_member_alias commons)))))))))) @@ -1533,7 +1533,7 @@ ((~' in) (.list (.` (~ jvm_interop))))))))) (#MethodDecl [commons method]) - (with_gensyms [g!obj] + (with_identifiers [g!obj] (do meta.monad [.let [def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))]) (^slots [#import_member_kind]) commons @@ -1579,7 +1579,7 @@ (list\map lux_type_parameter))) getter_name (code.identifier ["" (..import_name import_format method_prefix import_field_name)]) setter_name (code.identifier ["" (..import_name import_format method_prefix (format import_field_name "!"))])] - getter_interop (with_gensyms [g!obj] + getter_interop (with_identifiers [g!obj] (let [getter_call (if import_field_static? (` ((~ getter_name))) (` ((~ getter_name) (~ g!obj)))) @@ -1600,7 +1600,7 @@ ((~' in) (.list (.` (~ getter_body))))))))) setter_interop (: (Meta (List Code)) (if import_field_setter? - (with_gensyms [g!obj g!value] + (with_identifiers [g!obj g!value] (let [setter_call (if import_field_static? (` ((~ setter_name) (~ g!value))) (` ((~ setter_name) (~ g!value) (~ g!obj)))) @@ -1655,57 +1655,57 @@ (syntax: .public (import: {class_decl ..class_decl^} {bundles (<>.some (..bundle (product.right class_decl)))}) - {#.doc (doc "Allows importing JVM classes, and using them as types." - "Their methods, fields and enum options can also be imported." - (import: java/lang/Object - ["#::." - (new []) - (equals [java/lang/Object] boolean) - (wait [int] #io #try void)]) - - "Special options can also be given for the return values." - "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None." - "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type." - "#io means the computation has side effects, and will be wrapped by the IO type." - "These options must show up in the following order [#io #try #?] (although, each option can be used independently)." - (import: java/lang/String - ["#::." - (new [[byte]]) - (#static valueOf [char] java/lang/String) - (#static valueOf #as int_valueOf [int] java/lang/String)]) - - (import: (java/util/List e) - ["#::." - (size [] int) - (get [int] e)]) - - (import: (java/util/ArrayList a) - ["#::." - ([T] toArray [[T]] [T])]) - - "The class-type that is generated is of the fully-qualified name." - "This avoids a clash between the java.util.List type, and Lux's own List type." - "All enum options to be imported must be specified." - (import: java/lang/Character$UnicodeScript - ["#::." - (#enum ARABIC CYRILLIC LATIN)]) - - "It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-parameters." - "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)." - (import: (lux/concurrency/async/JvmAsync A) - ["#::." - (resolve [A] boolean) - (poll [] A) - (wasResolved [] boolean) - (waitOn [lux/Function] void) - (#static [A] make [A] (lux/concurrency/async/JvmAsync A))]) - - "Also, the names of the imported members will look like Class::member" - (java/lang/Object::new []) - (java/lang/Object::equals [other_object] my_object) - (java/util/List::size [] my_list) - java/lang/Character$UnicodeScript::LATIN - )} + {#.doc (example "Allows importing JVM classes, and using them as types." + "Their methods, fields and enum options can also be imported." + (import: java/lang/Object + ["#::." + (new []) + (equals [java/lang/Object] boolean) + (wait [int] #io #try void)]) + + "Special options can also be given for the return values." + "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None." + "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type." + "#io means the computation has side effects, and will be wrapped by the IO type." + "These options must show up in the following order [#io #try #?] (although, each option can be used independently)." + (import: java/lang/String + ["#::." + (new [[byte]]) + (#static valueOf [char] java/lang/String) + (#static valueOf #as int_valueOf [int] java/lang/String)]) + + (import: (java/util/List e) + ["#::." + (size [] int) + (get [int] e)]) + + (import: (java/util/ArrayList a) + ["#::." + ([T] toArray [[T]] [T])]) + + "The class-type that is generated is of the fully-qualified name." + "This avoids a clash between the java.util.List type, and Lux's own List type." + "All enum options to be imported must be specified." + (import: java/lang/Character$UnicodeScript + ["#::." + (#enum ARABIC CYRILLIC LATIN)]) + + "It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-parameters." + "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)." + (import: (lux/concurrency/async/JvmAsync A) + ["#::." + (resolve [A] boolean) + (poll [] A) + (wasResolved [] boolean) + (waitOn [lux/Function] void) + (#static [A] make [A] (lux/concurrency/async/JvmAsync A))]) + + "Also, the names of the imported members will look like Class::member" + (java/lang/Object::new []) + (java/lang/Object::equals [other_object] my_object) + (java/util/List::size [] my_list) + java/lang/Character$UnicodeScript::LATIN + )} (do {! meta.monad} [kind (class_kind class_decl) =members (|> bundles @@ -1717,8 +1717,8 @@ (syntax: .public (array {type (..generic_type^ (list))} size) - {#.doc (doc "Create an array of the given type, with the given size." - (array java/lang/Object 10))} + {#.doc (example "Create an array of the given type, with the given size." + (array java/lang/Object 10))} (case type (^template [<type> <array_op>] [(^ (#GenericClass <type> (list))) @@ -1736,8 +1736,8 @@ (in (list (` ("jvm anewarray" (~ (code.text (generic_type$ type))) (~ size))))))) (syntax: .public (array_length array) - {#.doc (doc "Gives the length of an array." - (array_length my_array))} + {#.doc (example "Gives the length of an array." + (array_length my_array))} (in (list (` ("jvm arraylength" (~ array)))))) (def: (type_class_name type) @@ -1763,8 +1763,8 @@ (meta.failure (format "Cannot convert to JvmType: " (type.format type)))))) (syntax: .public (array_read idx array) - {#.doc (doc "Loads an element from an array." - (array_read 10 my_array))} + {#.doc (example "Loads an element from an array." + (array_read 10 my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -1787,13 +1787,13 @@ (in (list (` ("jvm aaload" (~ array) (~ idx))))))) _ - (with_gensyms [g!array] + (with_identifiers [g!array] (in (list (` (let [(~ g!array) (~ array)] (..array_read (~ idx) (~ g!array))))))))) (syntax: .public (array_write idx value array) - {#.doc (doc "Stores an element into an array." - (array_write 10 my_object my_array))} + {#.doc (example "Stores an element into an array." + (array_write 10 my_object my_array))} (case array [_ (#.Identifier array_name)] (do meta.monad @@ -1816,13 +1816,13 @@ (in (list (` ("jvm aastore" (~ array) (~ idx) (~ value))))))) _ - (with_gensyms [g!array] + (with_identifiers [g!array] (in (list (` (let [(~ g!array) (~ array)] (..array_write (~ idx) (~ value) (~ g!array))))))))) (syntax: .public (class_for {type (..generic_type^ (list))}) - {#.doc (doc "Loads the class as a java.lang.Class object." - (class_for java/lang/String))} + {#.doc (example "Loads the class as a java.lang.Class object." + (class_for java/lang/String))} (in (list (` ("jvm object class" (~ (code.text (simple_class$ (list) type)))))))) (syntax: .public (type {type (..generic_type^ (list))}) diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux index 1097cacf5..6b4ffc631 100644 --- a/stdlib/source/library/lux/ffi.php.lux +++ b/stdlib/source/library/lux/ffi.php.lux @@ -7,18 +7,18 @@ [monad (#+ do)]] [control ["." io] + ["." maybe] ["<>" parser ("#\." monad) ["<.>" code (#+ Parser)]]] [data ["." product] - ["." maybe] ["." text ["%" format]] [collection ["." list ("#\." functor fold)]]] [type abstract] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code] ["." template]]]]) @@ -162,7 +162,7 @@ (` (let [(~ g!temp) (~ output)] (if (not ("php object null?" (~ g!temp))) (~ g!temp) - (.error! "Null is an invalid value!")))))) + (.panic! "Null is an invalid value!")))))) (type: Import (#Class Text (Maybe Alias) Text (List Member)) @@ -183,12 +183,12 @@ )) (syntax: .public (try expression) - {#.doc (doc (case (try (risky_computation input)) - (#.Right success) - (do_something success) + {#.doc (example (case (try (risky_computation input)) + (#.Right success) + (do_something success) - (#.Left error) - (recover_from_failure error)))} + (#.Left error) + (recover_from_failure error)))} (in (list (` ("lux try" ((~! io.io) (~ expression))))))) (def: (with_io with? without) @@ -233,10 +233,10 @@ (~+ (list\map (with_null g!temp) g!inputs))))))))))) (syntax: .public (import: {import ..import}) - (with_gensyms [g!temp] + (with_identifiers [g!temp] (case import (#Class [class alias format members]) - (with_gensyms [g!object] + (with_identifiers [g!object] (let [qualify (: (-> Text Code) (function (_ member_name) (|> format diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux index 8878c85a2..93eaf6ccc 100644 --- a/stdlib/source/library/lux/ffi.py.lux +++ b/stdlib/source/library/lux/ffi.py.lux @@ -7,18 +7,18 @@ [monad (#+ do)]] [control ["." io] + ["." maybe] ["<>" parser ["<.>" code (#+ Parser)]]] [data ["." product] - ["." maybe] ["." text ["%" format]] [collection ["." list ("#\." functor fold)]]] [type abstract] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code] ["." template]]]]) @@ -157,7 +157,7 @@ (` (let [(~ g!temp) (~ output)] (if (not ("python object none?" (~ g!temp))) (~ g!temp) - (.error! "None is an invalid value!")))))) + (.panic! "None is an invalid value!")))))) (type: Import (#Class [Text Text (List Member)]) @@ -213,10 +213,10 @@ (~+ (list\map (with_none g!temp) g!inputs))))))))))) (syntax: .public (import: {import ..import}) - (with_gensyms [g!temp] + (with_identifiers [g!temp] (case import (#Class [class format members]) - (with_gensyms [g!object] + (with_identifiers [g!object] (let [qualify (: (-> Text Code) (function (_ member_name) (|> format diff --git a/stdlib/source/library/lux/ffi.rb.lux b/stdlib/source/library/lux/ffi.rb.lux index 26fea6c27..8bffde0d6 100644 --- a/stdlib/source/library/lux/ffi.rb.lux +++ b/stdlib/source/library/lux/ffi.rb.lux @@ -7,18 +7,18 @@ [monad (#+ do)]] [control ["." io] + ["." maybe] ["<>" parser ("#\." monad) ["<.>" code (#+ Parser)]]] [data ["." product] - ["." maybe] ["." text ["%" format]] [collection ["." list ("#\." functor fold)]]] [type abstract] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code] ["." template]]]]) @@ -162,7 +162,7 @@ (` (let [(~ g!temp) (~ output)] (if (not ("ruby object nil?" (~ g!temp))) (~ g!temp) - (.error! "Nil is an invalid value!")))))) + (.panic! "Nil is an invalid value!")))))) (type: Import (#Class Text (Maybe Alias) Text (List Member)) @@ -226,10 +226,10 @@ (~+ (list\map (with_nil g!temp) g!inputs))))))))))) (syntax: .public (import: {[?module import] ..import}) - (with_gensyms [g!temp] + (with_identifiers [g!temp] (case import (#Class [class alias format members]) - (with_gensyms [g!object] + (with_identifiers [g!object] (let [qualify (: (-> Text Code) (function (_ member_name) (|> format diff --git a/stdlib/source/library/lux/ffi.scm.lux b/stdlib/source/library/lux/ffi.scm.lux index 85f3f560a..6a1e79cec 100644 --- a/stdlib/source/library/lux/ffi.scm.lux +++ b/stdlib/source/library/lux/ffi.scm.lux @@ -7,18 +7,18 @@ [monad (#+ do)]] [control ["." io] + ["." maybe] ["<>" parser ("#\." monad) ["<.>" code (#+ Parser)]]] [data ["." product] - ["." maybe] ["." text ["%" format (#+ format)]] [collection ["." list ("#\." functor fold)]]] [type abstract] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code] ["." template]]]]) @@ -136,7 +136,7 @@ (` (let [(~ g!temp) (~ output)] (if (not ("scheme object nil?" (~ g!temp))) (~ g!temp) - (.error! "Nil is an invalid value!")))))) + (.panic! "Nil is an invalid value!")))))) (type: Import (#Function Common_Method) @@ -150,12 +150,12 @@ )) (syntax: .public (try expression) - {#.doc (doc (case (try (risky_computation input)) - (#.Right success) - (do_something success) + {#.doc (example (case (try (risky_computation input)) + (#.Right success) + (do_something success) - (#.Left error) - (recover_from_failure error)))} + (#.Left error) + (recover_from_failure error)))} (in (list (` ("lux try" ((~! io.io) (~ expression))))))) (def: (with_io with? without) @@ -200,7 +200,7 @@ (~+ (list\map (with_nil g!temp) g!inputs))))))))))) (syntax: .public (import: {import ..import}) - (with_gensyms [g!temp] + (with_identifiers [g!temp] (case import (#Function [name alias inputsT io? try? outputT]) (let [imported (` ("scheme constant" (~ (code.text name))))] diff --git a/stdlib/source/library/lux/locale.lux b/stdlib/source/library/lux/locale.lux index 512d214c6..39befd846 100644 --- a/stdlib/source/library/lux/locale.lux +++ b/stdlib/source/library/lux/locale.lux @@ -4,8 +4,9 @@ [abstract [equivalence (#+ Equivalence)] ["." hash (#+ Hash)]] + [control + ["." maybe ("#\." functor)]] [data - ["." maybe ("#\." functor)] ["." text ["%" format (#+ format)] ["." encoding (#+ Encoding)]]] diff --git a/stdlib/source/library/lux/locale/language.lux b/stdlib/source/library/lux/locale/language.lux index 7204c4823..4bff5041e 100644 --- a/stdlib/source/library/lux/locale/language.lux +++ b/stdlib/source/library/lux/locale/language.lux @@ -13,7 +13,7 @@ ... https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes (abstract: .public Language - {#.doc (doc "An ISO 639 language.")} + {#.doc (example "An ISO 639 language.")} {#name Text #code Text} diff --git a/stdlib/source/library/lux/locale/territory.lux b/stdlib/source/library/lux/locale/territory.lux index 279cb1148..48526b897 100644 --- a/stdlib/source/library/lux/locale/territory.lux +++ b/stdlib/source/library/lux/locale/territory.lux @@ -13,7 +13,7 @@ ... https://en.wikipedia.org/wiki/ISO_3166-1 (abstract: .public Territory - {#.doc (doc "An ISO 3166 territory.")} + {#.doc (example "An ISO 3166 territory.")} {#name Text #short Text diff --git a/stdlib/source/library/lux/macro.lux b/stdlib/source/library/lux/macro.lux index 193b5a25e..c05d45cde 100644 --- a/stdlib/source/library/lux/macro.lux +++ b/stdlib/source/library/lux/macro.lux @@ -19,8 +19,8 @@ ["." location]]]) (def: .public (single_expansion syntax) - {#.doc (doc "Given code that requires applying a macro, does it once and returns the result." - "Otherwise, returns the code as-is.")} + {#.doc (example "Given code that requires applying a macro, does it once and returns the result." + "Otherwise, returns the code as-is.")} (-> Code (Meta (List Code))) (case syntax [_ (#.Form (#.Item [[_ (#.Identifier name)] args]))] @@ -37,8 +37,8 @@ (\ //.monad in (list syntax)))) (def: .public (expansion syntax) - {#.doc (doc "Given code that requires applying a macro, expands repeatedly until no more direct macro-calls are left." - "Otherwise, returns the code as-is.")} + {#.doc (example "Given code that requires applying a macro, expands repeatedly until no more direct macro-calls are left." + "Otherwise, returns the code as-is.")} (-> Code (Meta (List Code))) (case syntax [_ (#.Form (#.Item [[_ (#.Identifier name)] args]))] @@ -106,9 +106,9 @@ _ (\ //.monad in (list syntax)))) -(def: .public (gensym prefix) - {#.doc (doc "Generates a unique name as an Code node (ready to be used in code templates)." - "A prefix can be given (or just be empty text) to better identify the code for debugging purposes.")} +(def: .public (identifier prefix) + {#.doc (example "Generates a unique name as an Code node (ready to be used in code templates)." + "A prefix can be given (or just be empty text) to better identify the code for debugging purposes.")} (-> Text (Meta Code)) (do //.monad [id //.seed] @@ -131,29 +131,29 @@ (|>> name\encode (text\compose "Wrong syntax for "))) -(macro: .public (with_gensyms tokens) - {#.doc (doc "Creates new identifiers and offers them to the body expression." - (syntax: .public (synchronized lock body) - (with_gensyms [g!lock g!body g!_] - (in (list (` (let [(~ g!lock) (~ lock) - (~ g!_) ("jvm monitorenter" (~ g!lock)) - (~ g!body) (~ body) - (~ g!_) ("jvm monitorexit" (~ g!lock))] - (~ g!body))))) - )))} +(macro: .public (with_identifiers tokens) + {#.doc (example "Creates new identifiers and offers them to the body expression." + (syntax: .public (synchronized lock body) + (with_identifiers [g!lock g!body g!_] + (in (list (` (let [(~ g!lock) (~ lock) + (~ g!_) ("jvm monitorenter" (~ g!lock)) + (~ g!body) (~ body) + (~ g!_) ("jvm monitorexit" (~ g!lock))] + (~ g!body))))) + )))} (case tokens (^ (list [_ (#.Tuple identifiers)] body)) (do {! //.monad} [identifier_names (monad.map ! ..get_local_identifier identifiers) .let [identifier_defs (list\join (list\map (: (-> Text (List Code)) - (function (_ name) (list (code.identifier ["" name]) (` (gensym (~ (code.text name))))))) + (function (_ name) (list (code.identifier ["" name]) (` (..identifier (~ (code.text name))))))) identifier_names))]] (in (list (` ((~! do) (~! //.monad) [(~+ identifier_defs)] (~ body)))))) _ - (//.failure (..wrong_syntax_error (name_of ..with_gensyms))))) + (//.failure (..wrong_syntax_error (name_of ..with_identifiers))))) (def: .public (one_expansion token) {#.doc "Works just like expand, except that it ensures that the output is a single Code token."} @@ -169,13 +169,13 @@ (template [<macro> <func>] [(macro: .public (<macro> tokens) - {#.doc (doc "Performs a macro-expansion and logs the resulting code." - "You can either use the resulting code, or omit them." - "By omitting them, this macro produces nothing (just like the lux.comment macro)." - (<macro> #omit - (def: (foo bar baz) - (-> Int Int Int) - (int.+ bar baz))))} + {#.doc (example "Performs a macro-expansion and logs the resulting code." + "You can either use the resulting code, or omit them." + "By omitting them, this macro produces nothing (just like the lux.comment macro)." + (<macro> #omit + (def: (foo bar baz) + (-> Int Int Int) + (int.+ bar baz))))} (let [[module _] (name_of .._) [_ short] (name_of <macro>) macro_name [module short]] diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux index 8a4360ac7..67434aa09 100644 --- a/stdlib/source/library/lux/macro/local.lux +++ b/stdlib/source/library/lux/macro/local.lux @@ -100,7 +100,7 @@ (do meta.monad [_ (monad.map meta.monad ..push_one macros) seed meta.seed - g!pop (//.gensym "pop") + g!pop (//.identifier "pop") _ (let [g!pop (: Name ["" (//code.format g!pop)])] (..push_one [g!pop (..pop_all (list\map product.left macros) g!pop)]))] (in (` ((~ g!pop)))))) diff --git a/stdlib/source/library/lux/macro/poly.lux b/stdlib/source/library/lux/macro/poly.lux index 535c8236f..7c79dd3d7 100644 --- a/stdlib/source/library/lux/macro/poly.lux +++ b/stdlib/source/library/lux/macro/poly.lux @@ -6,17 +6,17 @@ [abstract ["." monad (#+ do)]] [control + ["." maybe] ["<>" parser ("#\." monad) ["<.>" type (#+ Env)] ["<.>" code (#+ Parser)]]] [data ["." product] - ["." maybe] ["." text] [collection ["." list ("#\." fold functor)] ["." dictionary]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) ["." code] [syntax (#+ syntax:)]] [math @@ -32,15 +32,15 @@ (<>.and (<>\in (` .private)) private)))) (syntax: .public (poly: {[export_policy name body] ..polyP}) - (with_gensyms [g!_ g!type g!output] + (with_identifiers [g!_ g!type g!output] (let [g!name (code.identifier ["" name])] (in (.list (` ((~! syntax:) (~ export_policy) ((~ g!name) {(~ g!type) (~! <code>.identifier)}) ((~! do) (~! meta.monad) [(~ g!type) ((~! meta.type_definition) (~ g!type))] (case (: (.Either .Text .Code) - ((~! <type>.run) ((~! <>.rec) - (function ((~ g!_) (~ g!name)) - (~ body))) + ((~! <type>.result) ((~! <>.rec) + (function ((~ g!_) (~ g!name)) + (~ body))) (~ g!type))) (#.Left (~ g!output)) ((~! meta.failure) (~ g!output)) diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index 2689d68f3..0a3e28707 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -1,16 +1,16 @@ (.module: [library [lux #* - ["." macro (#+ with_gensyms)] + ["." macro (#+ with_identifiers)] ["." meta] [abstract ["." monad (#+ do)]] [control + ["." maybe] ["." try] ["<>" parser ["</>" code (#+ Parser)]]] [data - ["." maybe] ["." text ("#\." monoid)] [collection ["." list ("#\." functor)]]] @@ -42,22 +42,22 @@ (#.Item [[x y] pairs']) (list& x y (un_paired pairs')))) (macro: .public (syntax: tokens) - {#.doc (doc "A more advanced way to define macros than 'macro:'." - "The inputs to the macro can be parsed in complex ways through the use of syntax parsers." - "The macro body is also (implicitly) run in the Meta monad, to save some typing." - "Also, the compiler state can be accessed through the *compiler* binding." - (syntax: .public (object {.let [imports (class_imports *compiler*)]} - {.let [class_vars (list)]} - {super (opt (super_class_decl^ imports class_vars))} - {interfaces (tuple (some (super_class_decl^ imports class_vars)))} - {constructor_args (constructor_args^ imports class_vars)} - {methods (some (overriden_method_def^ imports))}) - (let [def_code ($_ text\compose "anon-class:" - (spaced (list (super_class_decl$ (maybe.else object_super_class super)) - (with_brackets (spaced (list\map super_class_decl$ interfaces))) - (with_brackets (spaced (list\map constructor_arg$ constructor_args))) - (with_brackets (spaced (list\map (method_def$ id) methods))))))] - (in (list (` ((~ (code.text def_code)))))))))} + {#.doc (example "A more advanced way to define macros than 'macro:'." + "The inputs to the macro can be parsed in complex ways through the use of syntax parsers." + "The macro body is also (implicitly) run in the Meta monad, to save some typing." + "Also, the compiler state can be accessed through the *lux* binding." + (syntax: .public (object {.let [imports (class_imports *lux*)]} + {.let [class_vars (list)]} + {super (opt (super_class_decl^ imports class_vars))} + {interfaces (tuple (some (super_class_decl^ imports class_vars)))} + {constructor_args (constructor_args^ imports class_vars)} + {methods (some (overriden_method_def^ imports))}) + (let [def_code ($_ text\compose "anon-class:" + (spaced (list (super_class_decl$ (maybe.else object_super_class super)) + (with_brackets (spaced (list\map super_class_decl$ interfaces))) + (with_brackets (spaced (list\map constructor_arg$ constructor_args))) + (with_brackets (spaced (list\map (method_def$ id) methods))))))] + (in (list (` ((~ (code.text def_code)))))))))} (let [?parts (: (Maybe [Code Text (List Code) Code Code]) (case tokens (^ (list export_policy @@ -84,7 +84,7 @@ #.None))] (case ?parts (#.Some [export_policy name args meta body]) - (with_gensyms [g!tokens g!body g!error] + (with_identifiers [g!tokens g!body g!error] (do {! meta.monad} [vars+parsers (monad.map ! (: (-> Code (Meta [Code Code])) @@ -113,7 +113,7 @@ (meta.failure "Syntax pattern expects records or identifiers.")))) args) this_module meta.current_module_name - .let [g!state (code.identifier ["" "*compiler*"]) + .let [g!state (code.identifier ["" "*lux*"]) error_msg (code.text (macro.wrong_syntax_error [this_module name]))]] (in (list (` (macro: (~ export_policy) ((~ (code.identifier ["" name])) (~ g!tokens) (~ g!state)) (~ meta) @@ -122,7 +122,7 @@ (#.Left (~ g!error)) (#.Left ((~! text.join_with) (~! text.new_line) (list (~ error_msg) (~ g!error))))} - ((~! </>.run) + ((~! </>.result) (: ((~! </>.Parser) (Meta (List Code))) ((~! do) (~! <>.monad) [(~+ (..un_paired vars+parsers))] diff --git a/stdlib/source/library/lux/macro/syntax/annotations.lux b/stdlib/source/library/lux/macro/syntax/annotations.lux index 88d43f03d..1db17d9b5 100644 --- a/stdlib/source/library/lux/macro/syntax/annotations.lux +++ b/stdlib/source/library/lux/macro/syntax/annotations.lux @@ -16,7 +16,7 @@ ["." code]]]]) (type: .public Annotations - {#.doc (doc "Definition/module annotations.")} + {#.doc (example "Definition/module annotations.")} (List [Name Code])) (def: .public equivalence diff --git a/stdlib/source/library/lux/macro/syntax/check.lux b/stdlib/source/library/lux/macro/syntax/check.lux index c55f6f233..26450894a 100644 --- a/stdlib/source/library/lux/macro/syntax/check.lux +++ b/stdlib/source/library/lux/macro/syntax/check.lux @@ -18,7 +18,7 @@ "lux check") (type: .public Check - {#.doc (doc "A type annotation for an expression.")} + {#.doc (example "A type annotation for an expression.")} {#type Code #value Code}) diff --git a/stdlib/source/library/lux/macro/syntax/declaration.lux b/stdlib/source/library/lux/macro/syntax/declaration.lux index 158bb618f..c85e74822 100644 --- a/stdlib/source/library/lux/macro/syntax/declaration.lux +++ b/stdlib/source/library/lux/macro/syntax/declaration.lux @@ -15,7 +15,7 @@ ["." code]]]]) (type: .public Declaration - {#.doc (doc "A declaration for either a constant or a function.")} + {#.doc (example "A declaration for either a constant or a function.")} {#name Text #arguments (List Text)}) @@ -27,10 +27,10 @@ )) (def: .public parser - {#.doc (doc "A parser for declaration syntax." - "Such as:" - quux - (foo bar baz))} + {#.doc (example "A parser for declaration syntax." + "Such as:" + quux + (foo bar baz))} (Parser Declaration) (<>.either (<>.and <code>.local_identifier (<>\in (list))) diff --git a/stdlib/source/library/lux/macro/syntax/definition.lux b/stdlib/source/library/lux/macro/syntax/definition.lux index eeefc3074..b0322f507 100644 --- a/stdlib/source/library/lux/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/macro/syntax/definition.lux @@ -26,7 +26,7 @@ ["#." check (#+ Check)]]) (type: .public Definition - {#.doc (doc "Syntax for a constant definition.")} + {#.doc (example "Syntax for a constant definition.")} {#name Text #value (Either Check Code) @@ -107,7 +107,7 @@ [raw <code>.any me_raw (|> raw macro.full_expansion - (meta.run compiler) + (meta.result compiler) <>.lift)] (<| (<code>.local me_raw) <code>.form diff --git a/stdlib/source/library/lux/macro/syntax/export.lux b/stdlib/source/library/lux/macro/syntax/export.lux index 56ee91491..077e36256 100644 --- a/stdlib/source/library/lux/macro/syntax/export.lux +++ b/stdlib/source/library/lux/macro/syntax/export.lux @@ -1,5 +1,5 @@ (.module: - {#.doc (.doc "Syntax for marking a definition as an export.")} + {#.doc (.example "Syntax for marking a definition as an export.")} [library [lux #* [control diff --git a/stdlib/source/library/lux/macro/syntax/input.lux b/stdlib/source/library/lux/macro/syntax/input.lux index d577d68e3..6754185af 100644 --- a/stdlib/source/library/lux/macro/syntax/input.lux +++ b/stdlib/source/library/lux/macro/syntax/input.lux @@ -12,7 +12,7 @@ ["." code]]]]) (type: .public Input - {#.doc (doc "The common typed-argument syntax used by many macros.")} + {#.doc (example "The common typed-argument syntax used by many macros.")} {#binding Code #type Code}) diff --git a/stdlib/source/library/lux/macro/syntax/type/variable.lux b/stdlib/source/library/lux/macro/syntax/type/variable.lux index 09dbdcd62..9f69dfbe0 100644 --- a/stdlib/source/library/lux/macro/syntax/type/variable.lux +++ b/stdlib/source/library/lux/macro/syntax/type/variable.lux @@ -12,7 +12,7 @@ ["." code]]]]) (type: .public Variable - {#.doc (doc "A variable'S name.")} + {#.doc (example "A variable'S name.")} Text) (def: .public equivalence diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index c8a211113..e3651d36e 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -36,7 +36,7 @@ body) (do {! meta.monad} [g!locals (|> locals - (list\map //.gensym) + (list\map //.identifier) (monad.seq !))] (in (list (` (.with_expansions [(~+ (|> (list.zipped/2 locals g!locals) (list\map (function (_ [name identifier]) @@ -177,7 +177,7 @@ (..macro local)]) locals))] (if expression? - (//.with_gensyms [g!body] + (//.with_identifiers [g!body] (in (list (` (.let [(~ g!body) (~ body)] (exec (~ g!pop) (~ g!body))))))) diff --git a/stdlib/source/library/lux/math/infix.lux b/stdlib/source/library/lux/math/infix.lux index 55653989a..a04cf8944 100644 --- a/stdlib/source/library/lux/math/infix.lux +++ b/stdlib/source/library/lux/math/infix.lux @@ -25,28 +25,32 @@ (#Unary Code Infix) (#Binary Infix Code Infix)) -(def: infix^ +(def: literal + (Parser Code) + ($_ <>.either + (<>\map code.bit <code>.bit) + (<>\map code.nat <code>.nat) + (<>\map code.int <code>.int) + (<>\map code.rev <code>.rev) + (<>\map code.frac <code>.frac) + (<>\map code.text <code>.text) + (<>\map code.identifier <code>.identifier) + (<>\map code.tag <code>.tag))) + +(def: expression (Parser Infix) - (<| <>.rec (function (_ infix^)) + (<| <>.rec (function (_ expression)) ($_ <>.or - ($_ <>.either - (<>\map code.bit <code>.bit) - (<>\map code.nat <code>.nat) - (<>\map code.int <code>.int) - (<>\map code.rev <code>.rev) - (<>\map code.frac <code>.frac) - (<>\map code.text <code>.text) - (<>\map code.identifier <code>.identifier) - (<>\map code.tag <code>.tag)) + ..literal (<code>.form (<>.many <code>.any)) - (<code>.tuple (<>.and <code>.any infix^)) + (<code>.tuple (<>.and <code>.any expression)) (<code>.tuple ($_ <>.either (do <>.monad [_ (<code>.this! (' #and)) - init_subject infix^ + init_subject expression init_op <code>.any - init_param infix^ - steps (<>.some (<>.and <code>.any infix^))] + init_param expression + steps (<>.some (<>.and <code>.any expression))] (in (product.right (list\fold (function (_ [op param] [subject [_subject _op _param]]) [param [(#Binary _subject _op _param) (` and) @@ -54,10 +58,10 @@ [init_param [init_subject init_op init_param]] steps)))) (do <>.monad - [init_subject infix^ + [init_subject expression init_op <code>.any - init_param infix^ - steps (<>.some (<>.and <code>.any infix^))] + init_param expression + steps (<>.some (<>.and <code>.any expression))] (in (list\fold (function (_ [op param] [_subject _op _param]) [(#Binary _subject _op _param) op param]) [init_subject init_op init_param] @@ -80,17 +84,17 @@ (#Binary left op right) (` ((~ op) (~ (prefix right)) (~ (prefix left)))))) -(syntax: .public (infix {expr infix^}) - {#.doc (doc "Infix math syntax." - (infix [x i.* +10]) - (infix [[x i.+ y] i.* [x i.- y]]) - (infix [sin [x i.+ y]]) - (infix [[x n.< y] and [y n.< z]]) - (infix [#and x n.< y n.< z]) - (infix [(n.* 3 9) gcd 450]) +(syntax: .public (infix {expr ..expression}) + {#.doc (example "Infix math syntax." + (infix [x i.* +10]) + (infix [[x i.+ y] i.* [x i.- y]]) + (infix [sin [x i.+ y]]) + (infix [[x n.< y] and [y n.< z]]) + (infix [#and x n.< y n.< z]) + (infix [(n.* 3 9) gcd 450]) - "The rules for infix syntax are simple." - "If you want your binary function to work well with it." - "Then take the argument to the right (y) as your first argument," - "and take the argument to the left (x) as your second argument.")} + "The rules for infix syntax are simple." + "If you want your binary function to work well with it." + "Then take the argument to the right (y) as your first argument," + "and take the argument to the left (x) as your second argument.")} (in (list (..prefix expr)))) diff --git a/stdlib/source/library/lux/math/logic/continuous.lux b/stdlib/source/library/lux/math/logic/continuous.lux index 0d36f9968..cffcc4e5d 100644 --- a/stdlib/source/library/lux/math/logic/continuous.lux +++ b/stdlib/source/library/lux/math/logic/continuous.lux @@ -1,8 +1,8 @@ ... https://en.wikipedia.org/wiki/Many-valued_logic (.module: - {#.doc (.doc "Continuous logic using Rev values." - "Continuous logic is logic in the interval [0,1] instead of just the binary #0 and #1 options." - "Because Rev is being used, the interval is actual [0,1).")} + {#.doc (.example "Continuous logic using Rev values." + "Continuous logic is logic in the interval [0,1] instead of just the binary #0 and #1 options." + "Because Rev is being used, the interval is actual [0,1).")} [library [lux (#- false true or and not) [abstract diff --git a/stdlib/source/library/lux/math/logic/fuzzy.lux b/stdlib/source/library/lux/math/logic/fuzzy.lux index 9e8e1835c..843af83ad 100644 --- a/stdlib/source/library/lux/math/logic/fuzzy.lux +++ b/stdlib/source/library/lux/math/logic/fuzzy.lux @@ -1,6 +1,6 @@ ... https://en.wikipedia.org/wiki/Fuzzy_logic (.module: - {#.doc (.doc "Fuzzy logic, implemented on top of the Rev type.")} + {#.doc "Fuzzy logic, implemented on top of the Rev type."} [library [lux #* [abstract @@ -18,7 +18,7 @@ ["#" continuous]]) (type: .public (Fuzzy a) - {#.doc (doc "A fuzzy set.")} + {#.doc (example "A fuzzy set.")} (-> a Rev)) (implementation: .public functor diff --git a/stdlib/source/library/lux/math/modular.lux b/stdlib/source/library/lux/math/modular.lux index 7bfbf34a0..5588ed574 100644 --- a/stdlib/source/library/lux/math/modular.lux +++ b/stdlib/source/library/lux/math/modular.lux @@ -72,7 +72,7 @@ (i\encode (//.divisor expected))))) (def: decode - (<text>.run + (<text>.result (do <>.monad [[value _ actual] ($_ <>.and intL (<text>.this ..separator) intL) _ (<>.assertion (exception.error ..incorrect_modulus [expected actual]) diff --git a/stdlib/source/library/lux/math/modulus.lux b/stdlib/source/library/lux/math/modulus.lux index 72f5d583e..434535443 100644 --- a/stdlib/source/library/lux/math/modulus.lux +++ b/stdlib/source/library/lux/math/modulus.lux @@ -21,8 +21,8 @@ (exception: .public zero_cannot_be_a_modulus) (abstract: .public (Modulus %) - {#.doc (doc "A number used as a modulus in modular arithmetic." - "It cannot be 0.")} + {#.doc (example "A number used as a modulus in modular arithmetic." + "It cannot be 0.")} Int @@ -50,11 +50,11 @@ ) (syntax: .public (literal {divisor <code>.int}) - {#.doc (doc "Success!" - (literal 123) + {#.doc (example "Success!" + (literal 123) - "Failure!" - (literal 0))} + "Failure!" + (literal 0))} (meta.lift (do try.monad [_ (..modulus divisor)] diff --git a/stdlib/source/library/lux/math/number.lux b/stdlib/source/library/lux/math/number.lux index 0aba205b5..2f2259c18 100644 --- a/stdlib/source/library/lux/math/number.lux +++ b/stdlib/source/library/lux/math/number.lux @@ -22,9 +22,9 @@ " number, generates a Nat, an Int, a Rev or a Frac.") separators "Allows for the presence of commas among the digits." description [location (#.Text ($_ "lux text concat" encoding " " separators))]] - (#try.Success [state (list (` (doc (~ description) - (~ example_1) - (~ example_2))))])) + (#try.Success [state (list (` (.example (~ description) + (~ example_1) + (~ example_2))))])) _ (#try.Failure "Wrong syntax for 'documentation'."))) diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux index 63df9b5ae..ba63fec12 100644 --- a/stdlib/source/library/lux/math/number/complex.lux +++ b/stdlib/source/library/lux/math/number/complex.lux @@ -8,10 +8,10 @@ [codec (#+ Codec)] ["M" monad (#+ Monad do)]] [control + ["." maybe] ["<>" parser ["<.>" code (#+ Parser)]]] [data - ["." maybe] [collection ["." list ("#\." functor)]]] [macro @@ -24,15 +24,15 @@ ["." int]]]]]) (type: .public Complex - {#.doc (doc "A complex number.")} + {#.doc (example "A complex number.")} {#real Frac #imaginary Frac}) (syntax: .public (complex real {?imaginary (<>.maybe <code>.any)}) - {#.doc (doc "Complex literals." - (complex real imaginary) - "The imaginary part can be omitted if it's +0.0." - (complex real))} + {#.doc (example "Complex literals." + (complex real imaginary) + "The imaginary part can be omitted if it's +0.0." + (complex real))} (in (list (` {#..real (~ real) #..imaginary (~ (maybe.else (' +0.0) ?imaginary))})))) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index 977c5a8b7..9dce6d30b 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -11,9 +11,9 @@ [order (#+ Order)] [monad (#+ do)]] [control + ["." maybe] ["." try (#+ Try)]] [data - ["." maybe] ["." text]]]] ["." // #_ ["#." i64] diff --git a/stdlib/source/library/lux/math/number/i16.lux b/stdlib/source/library/lux/math/number/i16.lux index 0f273497c..3bbbbe6f4 100644 --- a/stdlib/source/library/lux/math/number/i16.lux +++ b/stdlib/source/library/lux/math/number/i16.lux @@ -3,7 +3,7 @@ [lux (#- i64) [abstract [equivalence (#+ Equivalence)]] - [data + [control ["." maybe]] [type (#+ :by_example)]]] [// @@ -13,7 +13,7 @@ (maybe.assume (i64.sub 16))) (def: .public I16 - {#.doc (doc "A 16-bit integer.")} + {#.doc (example "A 16-bit integer.")} (:by_example [size] (Sub size) ..sub diff --git a/stdlib/source/library/lux/math/number/i32.lux b/stdlib/source/library/lux/math/number/i32.lux index 61fe87f40..bd0a705cf 100644 --- a/stdlib/source/library/lux/math/number/i32.lux +++ b/stdlib/source/library/lux/math/number/i32.lux @@ -1,11 +1,11 @@ (.module: [library [lux (#- i64) + [type (#+ :by_example)] [abstract [equivalence (#+ Equivalence)]] - [data - ["." maybe]] - [type (#+ :by_example)]]] + [control + ["." maybe]]]] [// ["." i64 (#+ Sub)]]) @@ -13,7 +13,7 @@ (maybe.assume (i64.sub 32))) (def: .public I32 - {#.doc (doc "A 32-bit integer.")} + {#.doc (example "A 32-bit integer.")} (:by_example [size] (Sub size) ..sub diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index 4f44826f9..fd79d7bb3 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -37,16 +37,16 @@ ... https://en.wikipedia.org/wiki/Mask_(computing) (type: .public Mask - {#.doc (doc "A pattern of bits that can be imposed on I64 values.")} + {#.doc (example "A pattern of bits that can be imposed on I64 values.")} I64) (def: .public (bit position) - {#.doc (doc "A mask with only a specific bit set.")} + {#.doc (example "A mask with only a specific bit set.")} (-> Nat Mask) (|> 1 .i64 (..left_shifted (n.% ..width position)))) (def: .public sign - {#.doc (doc "A mask for the sign bit of ints.")} + {#.doc (example "A mask for the sign bit of ints.")} Mask (..bit (dec ..width))) @@ -64,7 +64,7 @@ (..not ..false)) (def: .public (mask amount_of_bits) - {#.doc (doc "Mask a block of bits of the specified size.")} + {#.doc (example "Mask a block of bits of the specified size.")} (-> Nat Mask) (case amount_of_bits 0 ..false @@ -72,21 +72,21 @@ 0 ..true bits (|> 1 .i64 (..left_shifted (n.% ..width bits)) .dec)))) -(def: (add_shift shift value) +(def: (with_shift shift value) (-> Nat Nat Nat) (|> value (right_shifted shift) (n.+ value))) -(def: .public (count subject) +(def: .public (ones subject) {#.doc "Count the number of 1s in a bit-map."} (-> (I64 Any) Nat) - (let [count' (n.- (|> subject (right_shifted 1) (..and 6148914691236517205) i64) - (i64 subject))] - (|> count' - (right_shifted 2) (..and 3689348814741910323) (n.+ (..and 3689348814741910323 count')) - (add_shift 4) (..and 1085102592571150095) - (add_shift 8) - (add_shift 16) - (add_shift 32) + (let [ones' (n.- (|> subject (right_shifted 1) (..and 6148914691236517205) i64) + (i64 subject))] + (|> ones' + (right_shifted 2) (..and 3689348814741910323) (n.+ (..and 3689348814741910323 ones')) + (with_shift 4) (..and 1085102592571150095) + (with_shift 8) + (with_shift 16) + (with_shift 32) (..and 127)))) (def: .public (clear index input) @@ -123,7 +123,7 @@ ) (def: .public (region offset size) - {#.doc (doc "A mask for a block of bits of the given size, starting at the given offset.")} + {#.doc (example "A mask for a block of bits of the given size, starting at the given offset.")} (-> Nat Nat Mask) (..left_rotated offset (..mask size))) @@ -189,7 +189,7 @@ swap/01))) (interface: .public (Sub size) - {#.doc (doc "A sub-space of I64 with a reduce amount of bits.")} + {#.doc (example "A sub-space of I64 with a reduce amount of bits.")} (: (Equivalence (I64 size)) &equivalence) @@ -201,7 +201,7 @@ widen)) (def: .public (sub width) - {#.doc (doc "Given a width in the interval (0,64), yields an implementation for integers of that width.")} + {#.doc (example "Given a width in the interval (0,64), yields an implementation for integers of that width.")} (Ex [size] (-> Nat (Maybe (Sub size)))) (if (.and (n.> 0 width) (n.< ..width width)) diff --git a/stdlib/source/library/lux/math/number/i8.lux b/stdlib/source/library/lux/math/number/i8.lux index 1c3bccea6..ba935b2d8 100644 --- a/stdlib/source/library/lux/math/number/i8.lux +++ b/stdlib/source/library/lux/math/number/i8.lux @@ -3,7 +3,7 @@ [lux (#- i64) [abstract [equivalence (#+ Equivalence)]] - [data + [control ["." maybe]] [type (#+ :by_example)]]] [// @@ -13,7 +13,7 @@ (maybe.assume (i64.sub 8))) (def: .public I8 - {#.doc (doc "An 8-bit integer.")} + {#.doc (example "An 8-bit integer.")} (:by_example [size] (Sub size) ..sub diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index afe1e7745..88ba6bba1 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -11,10 +11,10 @@ [predicate (#+ Predicate)] ["." order (#+ Order)]] [control + ["." maybe] ["." try (#+ Try)]] [data - [text (#+ Char)] - ["." maybe]]]] + [text (#+ Char)]]]] ["." // #_ ["#." nat] ["#." i64]]) @@ -90,19 +90,19 @@ (..% param subject)]) (def: .public (opposite value) - {#.doc (doc "A value of equal magnitude and opposite sign.")} + {#.doc (example "A value of equal magnitude and opposite sign.")} (-> Int Int) (..- value +0)) (def: .public (abs x) - {#.doc (doc "A value of equal magnitude and positive sign.")} + {#.doc (example "A value of equal magnitude and positive sign.")} (-> Int Int) (if (..< +0 x) (..* -1 x) x)) (def: .public (signum x) - {#.doc (doc "A value (either -1, 0 or +0) which represents the sign.")} + {#.doc (example "A value (either -1, 0 or +0) which represents the sign.")} (-> Int Int) (cond (..= +0 x) +0 (..< +0 x) -1 @@ -111,8 +111,8 @@ ... https://rob.conery.io/2018/08/21/mod-and-remainder-are-not-the-same/ (def: .public (mod divisor dividend) - {#.doc (doc "Integer modulo." - "Note: The modulo and the remainder are not the same.")} + {#.doc (example "Integer modulo." + "Note: The modulo and the remainder are not the same.")} (All [m] (-> Int Int Int)) (let [remainder (..% divisor dividend)] (if (or (and (..< +0 divisor) diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux index 63c2302c4..bd6ff389c 100644 --- a/stdlib/source/library/lux/math/number/nat.lux +++ b/stdlib/source/library/lux/math/number/nat.lux @@ -11,9 +11,8 @@ ["." order (#+ Order)]] [control ["." function] - ["." try (#+ Try)]] - [data - ["." maybe]]]]) + ["." maybe] + ["." try (#+ Try)]]]]) (template [<extension> <output> <name> <documentation>] [(def: .public (<name> parameter subject) diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux index a9a494208..bf0b2eff2 100644 --- a/stdlib/source/library/lux/math/number/ratio.lux +++ b/stdlib/source/library/lux/math/number/ratio.lux @@ -10,12 +10,12 @@ [monad (#+ do)]] [control ["." function] + ["." maybe] ["." try] ["<>" parser ["<.>" code (#+ Parser)]]] [data ["." product] - ["." maybe] ["." text ("#\." monoid)]] [macro [syntax (#+ syntax:)] @@ -24,7 +24,7 @@ ["n" nat ("#\." decimal)]]) (type: .public Ratio - {#.doc (doc "An unsigned ratio of numbers.")} + {#.doc (example "An unsigned ratio of numbers.")} {#numerator Nat #denominator Nat}) @@ -41,10 +41,10 @@ #denominator (n./ common denominator)})) (syntax: .public (ratio numerator {?denominator (<>.maybe <code>.any)}) - {#.doc (doc "Rational literals." - (ratio numerator denominator) - "The denominator can be omitted if it is 1." - (ratio numerator))} + {#.doc (example "Rational literals." + (ratio numerator denominator) + "The denominator can be omitted if it is 1." + (ratio numerator))} (in (list (` ((~! ..normal) {#..numerator (~ numerator) #..denominator (~ (maybe.else (' 1) ?denominator))}))))) diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index 917f2ad72..20e1d6130 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -10,9 +10,9 @@ [codec (#+ Codec)] [order (#+ Order)]] [control + ["." maybe] ["." try]] [data - ["." maybe] [collection ["." array (#+ Array)]]]]] ["." // #_ @@ -142,7 +142,7 @@ {#.doc "Rev(olution) division."} (-> Rev Rev Rev) (if ("lux i64 =" +0 param) - (error! "Cannot divide Rev by zero!") + (panic! "Cannot divide Rev by zero!") (let [reciprocal (case (: Nat ("lux i64 and" <least_significant_bit> param)) 0 (..even_reciprocal (.nat param)) _ (..odd_reciprocal (.nat param)))] diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index a6dbe75d4..2757d62e8 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -142,7 +142,7 @@ (\ ..monad map (|>> .i64 f.of_bits) ..nat)) (def: .public safe_frac - {#.doc (doc "A number in the interval [0.0,1.0].")} + {#.doc (example "A number in the interval [0.0,1.0].")} (Random Frac) (let [mantissa_range (.int (i64.left_shifted 53 1)) mantissa_max (i.frac (dec mantissa_range))] @@ -343,7 +343,7 @@ (..either (\in #day.Friday) (\in #day.Saturday)))))) -(def: .public (run prng calc) +(def: .public (result prng calc) (All [a] (-> PRNG (Random a) [PRNG a])) (calc prng)) @@ -355,8 +355,8 @@ (return state)]))) (def: .public (pcg_32 [increase seed]) - {#.doc (doc "An implementation of the PCG32 algorithm." - "For more information, please see: http://www.pcg-random.org/")} + {#.doc (example "An implementation of the PCG32 algorithm." + "For more information, please see: http://www.pcg-random.org/")} (-> [(I64 Any) (I64 Any)] PRNG) (let [magic 6364136223846793005] (function (_ _) @@ -370,8 +370,8 @@ .i64))]))) (def: .public (xoroshiro_128+ [s0 s1]) - {#.doc (doc "An implementation of the Xoroshiro128+ algorithm." - "For more information, please see: http://xoroshiro.di.unimi.it/")} + {#.doc (example "An implementation of the Xoroshiro128+ algorithm." + "For more information, please see: http://xoroshiro.di.unimi.it/")} (-> [(I64 Any) (I64 Any)] PRNG) (function (_ _) [(let [s01 (i64.xor s0 s1)] @@ -385,7 +385,7 @@ ... https://en.wikipedia.org/wiki/Xorshift#Initialization ... http://xorshift.di.unimi.it/splitmix64.c (def: .public split_mix_64 - {#.doc (doc "An implementation of the SplitMix64 algorithm.")} + {#.doc (example "An implementation of the SplitMix64 algorithm.")} (-> Nat PRNG) (let [twist (: (-> Nat Nat Nat) (function (_ shift value) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index f966b9d9f..6c2d013c9 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -7,10 +7,10 @@ [apply (#+ Apply)] ["." monad (#+ Monad do)]] [control + ["." maybe] ["." try (#+ Try)]] [data ["." product] - ["." maybe] ["." text ("#\." monoid equivalence)] ["." name ("#\." codec equivalence)] [collection @@ -78,11 +78,11 @@ (#try.Success [compiler' ma]) (ma compiler'))))) -(def: .public (run' compiler action) +(def: .public (result' compiler action) (All [a] (-> Lux (Meta a) (Try [Lux a]))) (action compiler)) -(def: .public (run compiler action) +(def: .public (result compiler action) (All [a] (-> Lux (Meta a) (Try a))) (case (action compiler) (#try.Failure error) @@ -154,8 +154,8 @@ false))) (def: .public (normal name) - {#.doc (doc "If given a name without a module prefix, gives it the current module's name as prefix." - "Otherwise, returns the name as-is.")} + {#.doc (example "If given a name without a module prefix, gives it the current module's name as prefix." + "Otherwise, returns the name as-is.")} (-> Name (Meta Name)) (case name ["" name] diff --git a/stdlib/source/library/lux/meta/annotation.lux b/stdlib/source/library/lux/meta/annotation.lux index 5180187e6..42d151df3 100644 --- a/stdlib/source/library/lux/meta/annotation.lux +++ b/stdlib/source/library/lux/meta/annotation.lux @@ -1,11 +1,12 @@ (.module: - {#.doc (.doc "Machinary for querying annotations on modules and definitions.")} + {#.doc (.example "Machinary for querying annotations on modules and definitions.")} [library [lux (#- nat int rev) [abstract ["." monad (#+ do)]] + [control + ["." maybe]] [data - ["." maybe] ["." name ("#\." equivalence)]]]]) (type: .public Annotation diff --git a/stdlib/source/library/lux/meta/location.lux b/stdlib/source/library/lux/meta/location.lux index 7e21951ce..0c089da36 100644 --- a/stdlib/source/library/lux/meta/location.lux +++ b/stdlib/source/library/lux/meta/location.lux @@ -19,8 +19,8 @@ #.column 0}) (macro: .public (here tokens compiler) - {#.doc (doc "The Location of the current form." - (here))} + {#.doc (example "The Location of the current form." + (here))} (case tokens #.End (let [location (get@ #.location compiler)] diff --git a/stdlib/source/library/lux/program.lux b/stdlib/source/library/lux/program.lux index d2caa1a85..20939ab03 100644 --- a/stdlib/source/library/lux/program.lux +++ b/stdlib/source/library/lux/program.lux @@ -15,7 +15,7 @@ ["." text] [collection ["." list ("#\." monad)]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code]]]]) @@ -34,23 +34,23 @@ (syntax: .public (program: {args ..arguments^} body) - {#.doc (doc "Defines the entry-point to a program (similar to the 'main' function/method in other programming languages)." - "Can take a list of all the input parameters to the program." - "Or, can destructure them using CLI-option combinators from the lux/control/parser/cli module." - (program: all_args - (do io.monad - [foo init_program - bar (do_something all_args)] - (in []))) + {#.doc (example "Defines the entry-point to a program (similar to the 'main' function/method in other programming languages)." + "Can take a list of all the input parameters to the program." + "Or, can destructure them using CLI-option combinators from the lux/control/parser/cli module." + (program: all_args + (do io.monad + [foo init_program + bar (do_something all_args)] + (in []))) - (program: [name] - (io (log! (\ text.monoid compose "Hello, " name)))) + (program: [name] + (io (log! (\ text.monoid compose "Hello, " name)))) - (program: [{config configuration_parser}] - (do io.monad - [data (init_program config)] - (do_something data))))} - (with_gensyms [g!program g!args g!_ g!output g!message] + (program: [{config configuration_parser}] + (do io.monad + [data (init_program config)] + (do_something data))))} + (with_identifiers [g!program g!args g!_ g!output g!message] (let [initialization+event_loop (` ((~! do) (~! io.monad) [(~ g!output) (~ body) @@ -68,17 +68,17 @@ (#Parsed args) (` (.function ((~ g!program) (~ g!args)) - (case ((~! <cli>.run) (: (~! (<cli>.Parser (io.IO .Any))) - ((~! do) (~! <>.monad) - [(~+ (|> args - (list\map (function (_ [binding parser]) - (list binding parser))) - list\join)) - (~ g!_) (~! <cli>.end)] - ((~' in) (~ initialization+event_loop)))) + (case ((~! <cli>.result) (: (~! (<cli>.Parser (io.IO .Any))) + ((~! do) (~! <>.monad) + [(~+ (|> args + (list\map (function (_ [binding parser]) + (list binding parser))) + list\join)) + (~ g!_) (~! <cli>.end)] + ((~' in) (~ initialization+event_loop)))) (~ g!args)) (#.Right (~ g!output)) (~ g!output) (#.Left (~ g!message)) - (.error! (~ g!message)))))))))))))) + (.panic! (~ g!message)))))))))))))) diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 2891e83fa..13363a06f 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -9,11 +9,11 @@ ["." writer (#+ Writer)] ["." state (#+ +State)] ["." function] + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)]] [data ["." product] - ["." maybe] [text ["%" format (#+ format)]] [collection @@ -876,10 +876,10 @@ (def: .public (lookupswitch default cases) (-> Label (List [S4 Label]) (Bytecode Any)) - (let [cases (list.sort (function (_ [left _] [right _]) - (i.< (//signed.value left) - (//signed.value right))) - cases) + (let [cases (list.sorted (function (_ [left _] [right _]) + (i.< (//signed.value left) + (//signed.value right))) + cases) [estimator bytecode] _.lookupswitch] (function (_ [pool environment tracker]) (do try.monad diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux index a825e6699..5499207cf 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux @@ -4,9 +4,9 @@ [abstract ["." equivalence (#+ Equivalence)]] [control + ["." maybe] ["." try (#+ Try)]] [data - ["." maybe] [text ["%" format (#+ Format)]] [format diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index 7d76f4c78..22777c083 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -52,7 +52,7 @@ Instruction function.identity) -(def: .public run +(def: .public result (-> Instruction Specification) (function.apply format.no_op)) diff --git a/stdlib/source/library/lux/target/jvm/class.lux b/stdlib/source/library/lux/target/jvm/class.lux index 17561fa0d..b4cb88ec4 100644 --- a/stdlib/source/library/lux/target/jvm/class.lux +++ b/stdlib/source/library/lux/target/jvm/class.lux @@ -92,7 +92,7 @@ (Try Class)) (do try.monad [[pool [@this @super @interfaces] =fields =methods] - (<| (state.run' //constant/pool.empty) + (<| (state.result' //constant/pool.empty) (do //constant/pool.monad [classes (install_classes this super interfaces) =fields (monad.seq //constant/pool.monad fields) diff --git a/stdlib/source/library/lux/target/jvm/loader.lux b/stdlib/source/library/lux/target/jvm/loader.lux index 5676f1f4a..892d1e1ee 100644 --- a/stdlib/source/library/lux/target/jvm/loader.lux +++ b/stdlib/source/library/lux/target/jvm/loader.lux @@ -113,7 +113,7 @@ (java/lang/Class [? < java/lang/Object]) #throws [java/lang/ClassNotFoundException] (let [class_name (:as Text class_name) - classes (|> library atom.read! io.run)] + classes (|> library atom.read! io.run!)] (case (dictionary.get class_name classes) (#.Some bytecode) (case (..define class_name bytecode (<| <cast> self)) @@ -121,10 +121,10 @@ (:assume class) (#try.Failure error) - (error! (exception.error ..cannot_define [class_name error]))) + (panic! (exception.error ..cannot_define [class_name error]))) #.None - (error! (exception.error ..unknown [class_name]))))))))) + (panic! (exception.error ..unknown [class_name]))))))))) (def: .public (store name bytecode library) (-> Text Binary Library (IO (Try Any))) diff --git a/stdlib/source/library/lux/target/jvm/method.lux b/stdlib/source/library/lux/target/jvm/method.lux index 54aee2e60..8c42130d1 100644 --- a/stdlib/source/library/lux/target/jvm/method.lux +++ b/stdlib/source/library/lux/target/jvm/method.lux @@ -68,7 +68,7 @@ (#try.Failure error) (function (_ _) (#try.Failure error))) [environment exceptions instruction output] (//bytecode.resolve environment code) - .let [bytecode (|> instruction //bytecode/instruction.run format.instance)] + .let [bytecode (|> instruction //bytecode/instruction.result format.instance)] @code (//attribute.code {#//attribute/code.limit (get@ #//bytecode/environment.limit environment) #//attribute/code.code bytecode #//attribute/code.exception_table exceptions diff --git a/stdlib/source/library/lux/target/jvm/modifier.lux b/stdlib/source/library/lux/target/jvm/modifier.lux index 92aeafec2..8689834c4 100644 --- a/stdlib/source/library/lux/target/jvm/modifier.lux +++ b/stdlib/source/library/lux/target/jvm/modifier.lux @@ -11,7 +11,7 @@ [data [format [".F" binary (#+ Writer)]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)] ["." code]] [math @@ -81,7 +81,7 @@ ) (syntax: .public (modifiers: ofT {options (<>.many <c>.any)}) - (with_gensyms [g!modifier g!code] + (with_identifiers [g!modifier g!code] (in (list (` (template [(~ g!code) (~ g!modifier)] [(def: (~' .public) (~ g!modifier) (..Modifier (~ ofT)) diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index 256fc2863..eb219a297 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -243,7 +243,7 @@ [/reflection.double /.double] [/reflection.char /.char])) (if (text.starts_with? /descriptor.array_prefix class_name) - (<t>.run /parser.value (|> class_name //name.internal //name.read)) + (<t>.result /parser.value (|> class_name //name.internal //name.read)) (#try.Success (/.class class_name (list))))))) _) (case (ffi.check java/lang/reflect/GenericArrayType reflection) diff --git a/stdlib/source/library/lux/target/jvm/type.lux b/stdlib/source/library/lux/target/jvm/type.lux index c4a5abd0b..e6beb53d2 100644 --- a/stdlib/source/library/lux/target/jvm/type.lux +++ b/stdlib/source/library/lux/target/jvm/type.lux @@ -4,8 +4,9 @@ [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)]] + [control + ["." maybe]] [data - ["." maybe] ["." text ["%" format (#+ Format)]] [collection diff --git a/stdlib/source/library/lux/target/jvm/type/alias.lux b/stdlib/source/library/lux/target/jvm/type/alias.lux index 05ecd1f29..9c01faea3 100644 --- a/stdlib/source/library/lux/target/jvm/type/alias.lux +++ b/stdlib/source/library/lux/target/jvm/type/alias.lux @@ -4,12 +4,12 @@ [abstract ["." monad (#+ do)]] [control + ["." maybe] ["." try] ["." exception (#+ exception:)] ["<>" parser ["<.>" text (#+ Parser)]]] [data - ["." maybe] ["." text ["%" format (#+ format)]] [collection @@ -119,13 +119,13 @@ (-> Aliasing (-> (Type Method) (Type Method))) (|>> //.signature //signature.signature - (<text>.run (do <>.monad - [type_variables (|> (<>.some (..bound_type_var aliasing)) - (<>.after (<text>.this //signature.parameters_start)) - (<>.before (<text>.this //signature.parameters_end)) - (<>.else (list))) - inputs (..inputs aliasing) - return (..return aliasing) - exceptions (<>.some (..exception aliasing))] - (in (//.method [type_variables inputs return exceptions])))) + (<text>.result (do <>.monad + [type_variables (|> (<>.some (..bound_type_var aliasing)) + (<>.after (<text>.this //signature.parameters_start)) + (<>.before (<text>.this //signature.parameters_end)) + (<>.else (list))) + inputs (..inputs aliasing) + return (..return aliasing) + exceptions (<>.some (..exception aliasing))] + (in (//.method [type_variables inputs return exceptions])))) try.assumed)) diff --git a/stdlib/source/library/lux/target/jvm/type/descriptor.lux b/stdlib/source/library/lux/target/jvm/type/descriptor.lux index df751407b..60e8eead3 100644 --- a/stdlib/source/library/lux/target/jvm/type/descriptor.lux +++ b/stdlib/source/library/lux/target/jvm/type/descriptor.lux @@ -3,8 +3,9 @@ [lux (#- int char) [abstract [equivalence (#+ Equivalence)]] + [control + ["." maybe]] [data - ["." maybe] ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index dc10d216a..c6721ab41 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -228,7 +228,7 @@ (def: .public (check operation input) (All [a] (-> (Parser (Check a)) Text (Check a))) - (case (<text>.run operation input) + (case (<text>.result operation input) (#try.Success check) check diff --git a/stdlib/source/library/lux/target/jvm/type/parser.lux b/stdlib/source/library/lux/target/jvm/type/parser.lux index f54b961cc..6712f7ee0 100644 --- a/stdlib/source/library/lux/target/jvm/type/parser.lux +++ b/stdlib/source/library/lux/target/jvm/type/parser.lux @@ -90,14 +90,14 @@ (-> (Type Value) (Maybe Text)) (|>> //.signature //signature.signature - (<text>.run ..var') + (<text>.result ..var') try.maybe)) (def: .public name (-> (Type Var) Text) (|>> //.signature //signature.signature - (<text>.run ..var') + (<text>.result ..var') try.assumed)) (template [<name> <prefix> <constructor>] @@ -125,7 +125,7 @@ (def: class' (-> (Parser (Type Parameter)) (Parser (Type Class))) (|>> ..class'' - (\ <>.monad map (product.uncurry //.class)))) + (\ <>.monad map (product.uncurried //.class)))) (def: .public parameter (Parser (Type Parameter)) @@ -154,7 +154,7 @@ (-> (Type Value) (Maybe (Type Class))) (|>> //.signature //signature.signature - (<text>.run (<>.after (<text>.this <prefix>) ..class)) + (<text>.result (<>.after (<text>.this <prefix>) ..class)) try.maybe))] [lower? //signature.lower_prefix //.lower] @@ -165,7 +165,7 @@ (-> (Type Class) [External (List (Type Parameter))]) (|>> //.signature //signature.signature - (<text>.run (..class'' ..parameter)) + (<text>.result (..class'' ..parameter)) try.assumed)) (def: .public value @@ -223,7 +223,7 @@ (<>.some ..exception)))] (|>> //.signature //signature.signature - (<text>.run parser) + (<text>.result parser) try.assumed))) (template [<name> <category> <parser>] @@ -231,7 +231,7 @@ (-> (Type Value) (Maybe <category>)) (|>> //.signature //signature.signature - (<text>.run <parser>) + (<text>.result <parser>) try.maybe))] [array? (Type Value) @@ -261,5 +261,5 @@ (-> (Type Declaration) [External (List (Type Var))]) (|>> //.signature //signature.signature - (<text>.run ..declaration') + (<text>.result ..declaration') try.assumed)) diff --git a/stdlib/source/library/lux/target/r.lux b/stdlib/source/library/lux/target/r.lux index e446c0cb1..d0a5f7b58 100644 --- a/stdlib/source/library/lux/target/r.lux +++ b/stdlib/source/library/lux/target/r.lux @@ -4,10 +4,10 @@ [control [pipe (#+ case> cond> new>)] ["." function] + ["." maybe ("#\." functor)] [parser ["<.>" code]]] [data - ["." maybe ("#\." functor)] ["." text ["%" format (#+ format)]] [collection diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index a2ff484ab..310243fc4 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -8,6 +8,7 @@ ["." monad (#+ do)]] [control [pipe (#+ case>)] + ["." maybe] ["." try] ["." exception (#+ exception:)] ["." io] @@ -17,7 +18,6 @@ ["<>" parser ["<.>" code]]] [data - ["." maybe] ["." product] ["." name] ["." text @@ -93,7 +93,7 @@ (write! [(..total l_tally r_tally) (format l_documentation ..separator r_documentation)])) right))) - io.run)] + io.run!)] read!)) (def: .public (and left right) @@ -153,8 +153,8 @@ (def: .public (seed value test) (-> Seed Test Test) (function (_ prng) - (let [[_ result] (random.run (random.pcg_32 [..pcg_32_magic_inc value]) - test)] + (let [[_ result] (random.result (random.pcg_32 [..pcg_32_magic_inc value]) + test)] [prng result]))) (def: failed? @@ -175,7 +175,7 @@ _ (do random.monad [seed random.nat] (function (recur prng) - (let [[prng' instance] (random.run (random.pcg_32 [..pcg_32_magic_inc seed]) test)] + (let [[prng' instance] (random.result (random.pcg_32 [..pcg_32_magic_inc seed]) test)] [prng' (do {! async.monad} [[tally documentation] instance] (if (..failed? tally) @@ -184,7 +184,7 @@ 1 instance _ (|> test (times (dec amount)) - (random.run prng') + (random.result prng') product.right))))]))))) (def: (description duration tally) @@ -197,7 +197,7 @@ (get@ #actual_coverage tally)) report (: (-> (Set Name) Text) (|>> set.list - (list.sort (\ name.order <)) + (list.sorted (\ name.order <)) (exception.listing %.name))) expected_definitions_to_cover (set.size (get@ #expected_coverage tally)) unexpected_definitions_covered (set.size unexpected) @@ -246,7 +246,7 @@ [pre (async.future instant.now) .let [seed (instant.millis pre) prng (random.pcg_32 [..pcg_32_magic_inc seed])] - [tally documentation] (|> test (random.run prng) product.right) + [tally documentation] (|> test (random.result prng) product.right) post (async.future instant.now) .let [duration (instant.span pre post) _ (debug.log! (format documentation text.new_line text.new_line @@ -382,7 +382,7 @@ [seed random.nat .let [prng (random.pcg_32 [..pcg_32_magic_inc seed]) run! (: (-> Test Assertion) - (|>> (random.run prng) + (|>> (random.result prng) product.right (function (_ _)) "lux try" @@ -399,22 +399,22 @@ [read! write!] (: [Assertion (async.Resolver [Tally Text])] (async.async [])) - _ (io.run (monad.map io.monad - (function (_ [index test]) - (async.upon! (function (_ assertion) - (do io.monad - [[_ results] (atom.update! (dictionary.put index assertion) state)] - (if (n.= expected_tests (dictionary.size results)) - (let [assertions (|> results - dictionary.entries - (list\map product.right))] - (write! [(|> assertions - (list\map product.left) - (list\fold ..total ..start)) - (|> assertions - (list\map product.right) - (text.join_with ..separator))])) - (in [])))) - (run! test))) - (list.enumeration tests)))]] + _ (io.run! (monad.map io.monad + (function (_ [index test]) + (async.upon! (function (_ assertion) + (do io.monad + [[_ results] (atom.update! (dictionary.put index assertion) state)] + (if (n.= expected_tests (dictionary.size results)) + (let [assertions (|> results + dictionary.entries + (list\map product.right))] + (write! [(|> assertions + (list\map product.left) + (list\fold ..total ..start)) + (|> assertions + (list\map product.right) + (text.join_with ..separator))])) + (in [])))) + (run! test))) + (list.enumeration tests)))]] (in read!)))) diff --git a/stdlib/source/library/lux/time.lux b/stdlib/source/library/lux/time.lux index fe40eece2..dbe7ff1fa 100644 --- a/stdlib/source/library/lux/time.lux +++ b/stdlib/source/library/lux/time.lux @@ -209,9 +209,9 @@ (..millis_format milli_second)))) (implementation: .public codec - {#.doc (doc "Based on ISO 8601." - "For example: 21:14:51.827")} + {#.doc (example "Based on ISO 8601." + "For example: 21:14:51.827")} (Codec Text Time) (def: encode ..format) - (def: decode (<text>.run ..parser))) + (def: decode (<text>.result ..parser))) diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux index 9318e7be0..402700a81 100644 --- a/stdlib/source/library/lux/time/date.lux +++ b/stdlib/source/library/lux/time/date.lux @@ -8,12 +8,12 @@ [codec (#+ Codec)] [monad (#+ do)]] [control + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)] ["<>" parser ["<.>" text (#+ Parser)]]] [data - ["." maybe] ["." text ("#\." monoid)] [collection ["." list ("#\." fold)] @@ -68,14 +68,14 @@ "-") (abstract: .public Date - {#.doc (doc "A date specified as a year/month/day triplet.")} + {#.doc (example "A date specified as a year/month/day triplet.")} {#year Year #month Month #day Nat} (def: .public (date year month day_of_month) - {#.doc (doc "A date, within the allowed limits.")} + {#.doc (example "A date, within the allowed limits.")} (-> Year Month Nat (Try Date)) (if (..day_is_within_limits? year month day_of_month) (#try.Success @@ -190,12 +190,12 @@ ..separator (..padded (..day_of_month value)))) (implementation: .public codec - {#.doc (doc "Based on ISO 8601." - "For example: 2017-01-15")} + {#.doc (example "Based on ISO 8601." + "For example: 2017-01-15")} (Codec Text Date) (def: encode ..format) - (def: decode (<text>.run ..parser))) + (def: decode (<text>.result ..parser))) (def: days_per_leap (|> //year.days diff --git a/stdlib/source/library/lux/time/day.lux b/stdlib/source/library/lux/time/day.lux index 384802851..b44ace3a8 100644 --- a/stdlib/source/library/lux/time/day.lux +++ b/stdlib/source/library/lux/time/day.lux @@ -19,7 +19,7 @@ ["n" nat]]]]]) (type: .public Day - {#.doc (doc "A day of the week.")} + {#.doc (example "A day of the week.")} #Sunday #Monday #Tuesday @@ -123,7 +123,7 @@ _ (exception.except ..not_a_day_of_the_week [value])))) (def: .public week - {#.doc (doc "All the days, ordered by when they come in a week.")} + {#.doc (example "All the days, ordered by when they come in a week.")} (List Day) (list #Sunday #Monday diff --git a/stdlib/source/library/lux/time/duration.lux b/stdlib/source/library/lux/time/duration.lux index 6de3b80a7..995d0c678 100644 --- a/stdlib/source/library/lux/time/duration.lux +++ b/stdlib/source/library/lux/time/duration.lux @@ -187,7 +187,7 @@ (Codec Text Duration) (def: encode ..encode) - (def: decode (<text>.run ..parser))) + (def: decode (<text>.result ..parser))) (def: .public (difference from to) (-> Duration Duration Duration) diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux index 630388641..cc19a4ecc 100644 --- a/stdlib/source/library/lux/time/instant.lux +++ b/stdlib/source/library/lux/time/instant.lux @@ -10,12 +10,12 @@ [monad (#+ Monad do)]] [control [io (#+ IO io)] + ["." maybe] ["." try] ["." exception (#+ exception:)] ["<>" parser ["<.>" text (#+ Parser)]]] [data - ["." maybe] ["." text ("#\." monoid)] [collection ["." row]]] @@ -148,15 +148,15 @@ ..absolute)))) (implementation: .public codec - {#.doc (doc "Based on ISO 8601." - "For example: 2017-01-15T21:14:51.827Z")} + {#.doc (example "Based on ISO 8601." + "For example: 2017-01-15T21:14:51.827Z")} (Codec Text Instant) (def: encode ..format) - (def: decode (<text>.run ..parser))) + (def: decode (<text>.result ..parser))) (def: .public now - {#.doc (doc "Yields the current instant, as measured from the operating-system's clock.")} + {#.doc (example "Yields the current instant, as measured from the operating-system's clock.")} (IO Instant) (io (..of_millis (for {@.old ("jvm invokestatic:java.lang.System:currentTimeMillis:") @.jvm (|> ("jvm member invoke static" [] "java.lang.System" "currentTimeMillis" []) diff --git a/stdlib/source/library/lux/time/month.lux b/stdlib/source/library/lux/time/month.lux index 6e626f325..d8203e175 100644 --- a/stdlib/source/library/lux/time/month.lux +++ b/stdlib/source/library/lux/time/month.lux @@ -19,7 +19,7 @@ ["n" nat]]]]]) (type: .public Month - {#.doc (doc "A month of the year.")} + {#.doc (example "A month of the year.")} #January #February #March @@ -159,7 +159,7 @@ #January #December))) (def: .public (days month) - {#.doc (doc "The amount of days of a month.")} + {#.doc (example "The amount of days of a month.")} (-> Month Nat) (case month (^template [<days> <month>] @@ -181,14 +181,14 @@ [31 #December]))) (def: .public (leap_year_days month) - {#.doc (doc "The amount of days of a month (in a leap year).")} + {#.doc (example "The amount of days of a month (in a leap year).")} (-> Month Nat) (case month #February (inc (..days month)) _ (..days month))) (def: .public year - {#.doc (doc "All the months, ordered by when they come in a year.")} + {#.doc (example "All the months, ordered by when they come in a year.")} (List Month) (list #January #February diff --git a/stdlib/source/library/lux/time/year.lux b/stdlib/source/library/lux/time/year.lux index 44534707c..e7ed644ce 100644 --- a/stdlib/source/library/lux/time/year.lux +++ b/stdlib/source/library/lux/time/year.lux @@ -36,14 +36,14 @@ ... https://en.wikipedia.org/wiki/Gregorian_calendar (abstract: .public Year - {#.doc (doc "A year in the gregorian calendar." - "Both negative (< 0) and positive (> 0) values are valid, but not 0." - "This is because the first year of the gregorian calendar was year 1.")} + {#.doc (example "A year in the gregorian calendar." + "Both negative (< 0) and positive (> 0) values are valid, but not 0." + "This is because the first year of the gregorian calendar was year 1.")} Int (def: .public (year value) - {#.doc (doc "A valid year in the gregorian calendar, if possible.")} + {#.doc (example "A valid year in the gregorian calendar, if possible.")} (-> Int (Try Year)) (case value +0 (exception.except ..there_is_no_year_0 []) @@ -59,12 +59,12 @@ ) (def: .public days - {#.doc (doc "The amount of days in a typical year.")} + {#.doc (example "The amount of days in a typical year.")} Nat 365) (type: .public Period - {#.doc (doc "An amount of years.")} + {#.doc (example "An amount of years.")} Nat) (template [<period> <name>] @@ -96,7 +96,7 @@ days))) (def: .public (leaps year) - {#.doc (doc "The number of leap years in a period of years.")} + {#.doc (example "The number of leap years in a period of years.")} (-> Year Int) (let [year (|> year ..value ..internal) limit (if (i.> +0 year) @@ -130,12 +130,12 @@ (#.Right _) raw_year))))) (implementation: .public codec - {#.doc (doc "Based on ISO 8601." - "For example: 2017")} + {#.doc (example "Based on ISO 8601." + "For example: 2017")} (Codec Text Year) (def: encode ..encode) - (def: decode (<text>.run ..parser))) + (def: decode (<text>.result ..parser))) (implementation: .public equivalence (Equivalence Year) diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux index 6127ea59a..6af02e080 100644 --- a/stdlib/source/library/lux/tool/compiler/default/init.lux +++ b/stdlib/source/library/lux/tool/compiler/default/init.lux @@ -208,7 +208,7 @@ [reader (///directive.lift_analysis (..reader module aliases source))] (function (_ state) - (case (///phase.run' state (..iteration' archive expander reader source pre_payload)) + (case (///phase.result' state (..iteration' archive expander reader source pre_payload)) (#try.Success [state source&requirements&buffer]) (#try.Success [state (#.Some source&requirements&buffer)]) @@ -239,17 +239,17 @@ #///.process (function (_ state archive) (do {! try.monad} [.let [hash (text\hash (get@ #///.code input))] - [state [source buffer]] (<| (///phase.run' state) + [state [source buffer]] (<| (///phase.result' state) (..begin dependencies hash input)) .let [module (get@ #///.module input)]] - (loop [iteration (<| (///phase.run' state) + (loop [iteration (<| (///phase.result' state) (..iteration archive expander module source buffer ///syntax.no_aliases))] (do ! [[state ?source&requirements&temporary_payload] iteration] (case ?source&requirements&temporary_payload #.None (do ! - [[state [analysis_module [final_buffer final_registry]]] (///phase.run' state (..end module)) + [[state [analysis_module [final_buffer final_registry]]] (///phase.result' state (..end module)) .let [descriptor {#descriptor.hash hash #descriptor.name module #descriptor.file (get@ #///.file input) @@ -270,7 +270,7 @@ (get@ #///directive.imports) (list\map product.left)) #///.process (function (_ state archive) - (recur (<| (///phase.run' state) + (recur (<| (///phase.result' state) (do {! ///phase.monad} [analysis_module (<| (: (Operation .Module)) ///directive.lift_analysis diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index 814e6dfd2..e5ed96552 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -8,6 +8,7 @@ ["." monad (#+ Monad do)]] [control ["." function] + ["." maybe] ["." try (#+ Try) ("#\." monad)] ["." exception (#+ exception:)] [concurrency @@ -17,7 +18,6 @@ ["." binary (#+ Binary)] ["." bit] ["." product] - ["." maybe] ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection @@ -105,7 +105,7 @@ [_ (ioW.prepare system static module_id) _ (for {@.python (|> output row.list - (list.chunk 128) + (list.sub 128) (monad.map ! (monad.map ! write_artifact!)) (: (Action (List (List Any)))))} (|> output @@ -115,7 +115,7 @@ document (\ async.monad in (document.check $.key document))] (ioW.cache system static module_id - (_.run ..writer [descriptor document]))))) + (_.result ..writer [descriptor document]))))) ... TODO: Inline ASAP (def: initialize_buffer! @@ -192,7 +192,7 @@ (extension.with extender (:assume generators))) _ (extension.with extender (:assume directives))] (in []))) - (///phase.run' state) + (///phase.result' state) (\ try.monad map product.left))) (def: (phase_wrapper archive platform state) @@ -202,7 +202,7 @@ (|> archive phase_wrapper ///directive.lift_generation - (///phase.run' state)))) + (///phase.result' state)))) (def: (complete_extensions host_directive_bundle phase_wrapper [analysers synthesizers generators directives]) (All [<type_vars>] @@ -263,7 +263,7 @@ (in [state archive])) (do ! [[state [archive payload]] (|> (..process_runtime archive platform) - (///phase.run' state) + (///phase.result' state) async\in) _ (..cache_module static platform 0 payload) @@ -519,7 +519,7 @@ (All [<type_vars>] (-> Module <State+> <State+>)) (|> (///directive.set_current_module module) - (///phase.run' state) + (///phase.result' state) try.assumed product.left)) @@ -593,7 +593,7 @@ ... TODO: The "///directive.set_current_module" below shouldn't be necessary. Remove it ASAP. ... TODO: The context shouldn't need to be re-set either. (|> (///directive.set_current_module module) - (///phase.run' state) + (///phase.result' state) try.assumed product.left) archive) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux index c79f514c3..eb325ddd0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux @@ -7,11 +7,11 @@ [monad (#+ do)]] [control ["." function] + ["." maybe] ["." try] ["." exception (#+ Exception)]] [data ["." product] - ["." maybe] ["." bit ("#\." equivalence)] ["." text ("#\." equivalence) ["%" format (#+ Format format)]] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux index 74cadee55..5ae124d96 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux @@ -49,9 +49,9 @@ module (extensionP.lift meta.current_module_name)] (phase.lift (do try.monad - [exprS (|> exprA (synthesisP.phase archive) (phase.run synthesis_state))] - (phase.run generation_state - (do phase.monad - [exprO (generate archive exprS) - module_id (generation.module_id module archive)] - (generation.evaluate! (..context [module_id count]) exprO))))))))) + [exprS (|> exprA (synthesisP.phase archive) (phase.result synthesis_state))] + (phase.result generation_state + (do phase.monad + [exprO (generate archive exprS) + module_id (generation.module_id module archive)] + (generation.evaluate! (..context [module_id count]) exprO))))))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux index 315424e3c..0a1841ad1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux @@ -173,7 +173,7 @@ _ (extension.update (update@ #counter inc))] (in count))) -(def: .public (gensym prefix) +(def: .public (identifier prefix) (All [anchor expression directive] (-> Text (Operation anchor expression directive Text))) (\ phase.monad map (|>> %.nat (format prefix)) ..next)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux index 11c4ba626..454704918 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux @@ -5,11 +5,11 @@ [abstract ["." monad (#+ do)]] [control + ["." maybe] ["." try] ["." exception (#+ exception:)]] [data ["." product] - ["." maybe] [text ["%" format (#+ format)]] [collection diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux index 7dd813c09..5a47352b4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux @@ -5,11 +5,11 @@ equivalence ["." monad (#+ do)]] [control + ["." maybe] ["." try (#+ Try) ("#\." monad)] ["." exception (#+ exception:)]] [data ["." bit ("#\." equivalence)] - ["." maybe] ["." text ["%" format (#+ Format format)]] [collection diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux index 265311550..8063f450d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux @@ -4,9 +4,9 @@ [abstract monad] [control + ["." maybe] ["ex" exception (#+ exception:)]] [data - ["." maybe] ["." text ["%" format (#+ format)]] [collection diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux index a07afe1fa..1a8d43477 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux @@ -4,9 +4,9 @@ [abstract [monad (#+ do)]] [control + ["." maybe] ["." exception (#+ exception:)]] [data - ["." maybe] ["." text ["%" format (#+ format)]] [collection diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux index 097f47cce..351c396e0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux @@ -4,11 +4,11 @@ [abstract monad] [control + ["." maybe ("#\." monad)] ["." try] ["." exception (#+ exception:)]] [data ["." text ("#\." equivalence)] - ["." maybe ("#\." monad)] ["." product] [collection ["." list ("#\." functor fold monoid)] @@ -118,8 +118,8 @@ (|>> (update@ #.counter inc) (update@ #.mappings (plist.put name [type new_var_id])))) head)] - (case (///.run' [bundle (set@ #.scopes (#.Item new_head tail) state)] - action) + (case (///.result' [bundle (set@ #.scopes (#.Item new_head tail) state)] + action) (#try.Success [[bundle' state'] output]) (case (get@ #.scopes state') (#.Item head' tail') diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux index 6ff5f7ce4..f5f5d89c8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux @@ -5,12 +5,12 @@ [abstract ["." monad (#+ do)]] [control + ["." maybe] ["ex" exception (#+ exception:)] ["." state]] [data ["." name] ["." product] - ["." maybe] [text ["%" format (#+ format)]] [collection diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux index 0620b8c01..3142451e4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux @@ -80,7 +80,7 @@ ["Extension" (%.text name)] ["Available" (|> bundle dictionary.keys - (list.sort text\<) + (list.sorted text\<) (exception.listing %.text))])) (type: .public (Extender s i o) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index d74b18019..27ce292a0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -7,13 +7,13 @@ ["." monad (#+ do)]] [control pipe + ["." maybe] ["." try (#+ Try) ("#\." monad)] ["." exception (#+ exception:)] ["<>" parser ["<.>" code (#+ Parser)] ["<.>" text]]] [data - ["." maybe] ["." product] ["." text ("#\." equivalence) ["%" format (#+ format)]] @@ -400,7 +400,7 @@ [objectJ (jvm_type objectT)] (|> objectJ ..signature - (<text>.run jvm_parser.array) + (<text>.result jvm_parser.array) phase.lift))) (def: (primitive_array_length_handler primitive_type) @@ -845,7 +845,7 @@ (template [<name> <category> <parser>] [(def: .public (<name> mapping typeJ) (-> Mapping (Type <category>) (Operation .Type)) - (case (|> typeJ ..signature (<text>.run (<parser> mapping))) + (case (|> typeJ ..signature (<text>.result (<parser> mapping))) (#try.Success check) (typeA.with_env check) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux index 5a76b1804..979af197a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux @@ -4,12 +4,12 @@ [abstract ["." monad (#+ do)]] [control + ["." maybe] ["." try] ["." exception (#+ exception:)] ["<>" parser ["<.>" code (#+ Parser)]]] [data - ["." maybe] ["." text ["%" format (#+ format)]] [collection @@ -40,7 +40,7 @@ (-> Text Phase Archive s (Operation Analysis))] Handler)) (function (_ extension_name analyse archive args) - (case (<code>.run syntax args) + (case (<code>.result syntax args) (#try.Success inputs) (handler extension_name analyse archive inputs) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux index 5c130e466..6e3ca3a70 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux @@ -12,7 +12,6 @@ ["<.>" code (#+ Parser)]]] [data ["." product] - ["." maybe] ["." text ["%" format (#+ format)]] [collection @@ -54,7 +53,7 @@ (Operation anchor expression directive Requirements))] (Handler anchor expression directive))) (function (_ extension_name phase archive inputs) - (case (<code>.run syntax inputs) + (case (<code>.result syntax inputs) (#try.Success inputs) (handler extension_name phase archive inputs) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux index bfe808472..e8518812e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux @@ -44,7 +44,7 @@ (-> Text (Generator s))] Handler)) (function (_ extension_name phase archive input) - (case (<s>.run parser input) + (case (<s>.result parser input) (#try.Success input') (handler extension_name phase archive input') @@ -64,7 +64,7 @@ ... <s>.any)))) ... (function (_ extension_name phase archive [input else conditionals]) ... (do {! /////.monad} -... [@input (\ ! map _.var (generation.gensym "input")) +... [@input (\ ! map _.var (generation.identifier "input")) ... inputG (phase archive input) ... elseG (phase archive else) ... conditionalsG (: (Operation (List [Expression Expression])) @@ -101,7 +101,7 @@ (/.install "or" (binary _.logior/2)) (/.install "xor" (binary _.logxor/2)) (/.install "left-shift" (binary _.ash/2)) - (/.install "right-shift" (binary (product.uncurry //runtime.i64//right_shifted))) + (/.install "right-shift" (binary (product.uncurried //runtime.i64//right_shifted))) (/.install "=" (binary _.=/2)) (/.install "<" (binary _.</2)) (/.install "+" (binary _.+/2)) @@ -117,13 +117,13 @@ Bundle (<| (/.prefix "f64") (|> /.empty - ... (/.install "=" (binary (product.uncurry _.=/2))) - ... (/.install "<" (binary (product.uncurry _.</2))) - ... (/.install "+" (binary (product.uncurry _.+/2))) - ... (/.install "-" (binary (product.uncurry _.-/2))) - ... (/.install "*" (binary (product.uncurry _.*/2))) - ... (/.install "/" (binary (product.uncurry _.//2))) - ... (/.install "%" (binary (product.uncurry _.rem/2))) + ... (/.install "=" (binary (product.uncurried _.=/2))) + ... (/.install "<" (binary (product.uncurried _.</2))) + ... (/.install "+" (binary (product.uncurried _.+/2))) + ... (/.install "-" (binary (product.uncurried _.-/2))) + ... (/.install "*" (binary (product.uncurried _.*/2))) + ... (/.install "/" (binary (product.uncurried _.//2))) + ... (/.install "%" (binary (product.uncurried _.rem/2))) ... (/.install "i64" (unary _.truncate/1)) (/.install "encode" (unary _.write_to_string/1)) ... (/.install "decode" (unary //runtime.f64//decode)) @@ -146,7 +146,7 @@ (<| (/.prefix "text") (|> /.empty (/.install "=" (binary _.string=/2)) - ... (/.install "<" (binary (product.uncurry _.string<?/2))) + ... (/.install "<" (binary (product.uncurried _.string<?/2))) (/.install "concat" (binary (function (_ [left right]) (_.concatenate/3 [(_.symbol "string") left right])))) (/.install "index" (trinary ..text//index)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux index f17ea75a3..50b60d954 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux @@ -38,7 +38,7 @@ (-> Text (Generator s))] Handler)) (function (_ extension_name phase archive input) - (case (<s>.run parser input) + (case (<s>.result parser input) (#try.Success input') (handler extension_name phase archive input') @@ -122,25 +122,25 @@ Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) - (/.install "is" (binary (product.uncurry _.=))) + (/.install "is" (binary (product.uncurried _.=))) (/.install "try" (unary //runtime.lux//try)))) (def: i64_procs Bundle (<| (/.prefix "i64") (|> /.empty - (/.install "and" (binary (product.uncurry //runtime.i64//and))) - (/.install "or" (binary (product.uncurry //runtime.i64//or))) - (/.install "xor" (binary (product.uncurry //runtime.i64//xor))) + (/.install "and" (binary (product.uncurried //runtime.i64//and))) + (/.install "or" (binary (product.uncurried //runtime.i64//or))) + (/.install "xor" (binary (product.uncurried //runtime.i64//xor))) (/.install "left-shift" (binary i64//left_shifted)) (/.install "right-shift" (binary i64//right_shifted)) - (/.install "=" (binary (product.uncurry //runtime.i64//=))) - (/.install "<" (binary (product.uncurry //runtime.i64//<))) - (/.install "+" (binary (product.uncurry //runtime.i64//+))) - (/.install "-" (binary (product.uncurry //runtime.i64//-))) - (/.install "*" (binary (product.uncurry //runtime.i64//*))) - (/.install "/" (binary (product.uncurry //runtime.i64///))) - (/.install "%" (binary (product.uncurry //runtime.i64//%))) + (/.install "=" (binary (product.uncurried //runtime.i64//=))) + (/.install "<" (binary (product.uncurried //runtime.i64//<))) + (/.install "+" (binary (product.uncurried //runtime.i64//+))) + (/.install "-" (binary (product.uncurried //runtime.i64//-))) + (/.install "*" (binary (product.uncurried //runtime.i64//*))) + (/.install "/" (binary (product.uncurried //runtime.i64///))) + (/.install "%" (binary (product.uncurried //runtime.i64//%))) (/.install "f64" (unary //runtime.i64//number)) (/.install "char" (unary i64//char)) ))) @@ -149,13 +149,13 @@ Bundle (<| (/.prefix "f64") (|> /.empty - (/.install "+" (binary (product.uncurry _.+))) - (/.install "-" (binary (product.uncurry _.-))) - (/.install "*" (binary (product.uncurry _.*))) - (/.install "/" (binary (product.uncurry _./))) - (/.install "%" (binary (product.uncurry _.%))) - (/.install "=" (binary (product.uncurry _.=))) - (/.install "<" (binary (product.uncurry _.<))) + (/.install "+" (binary (product.uncurried _.+))) + (/.install "-" (binary (product.uncurried _.-))) + (/.install "*" (binary (product.uncurried _.*))) + (/.install "/" (binary (product.uncurried _./))) + (/.install "%" (binary (product.uncurried _.%))) + (/.install "=" (binary (product.uncurried _.=))) + (/.install "<" (binary (product.uncurried _.<))) (/.install "i64" (unary //runtime.i64//of_number)) (/.install "encode" (unary (_.do "toString" (list)))) (/.install "decode" (unary f64//decode))))) @@ -164,12 +164,12 @@ Bundle (<| (/.prefix "text") (|> /.empty - (/.install "=" (binary (product.uncurry _.=))) - (/.install "<" (binary (product.uncurry _.<))) + (/.install "=" (binary (product.uncurried _.=))) + (/.install "<" (binary (product.uncurried _.<))) (/.install "concat" (binary text//concat)) (/.install "index" (trinary text//index)) (/.install "size" (unary (|>> (_.the "length") //runtime.i64//of_number))) - (/.install "char" (binary (product.uncurry //runtime.text//char))) + (/.install "char" (binary (product.uncurried //runtime.text//char))) (/.install "clip" (trinary text//clip)) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux index b2c84251e..9e681c65d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux @@ -133,7 +133,7 @@ (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) .let [variable (: (-> Text (Operation Var)) - (|>> generation.gensym + (|>> generation.identifier (\ ! map _.var)))] g!inputs (monad.map ! (function (_ _) (variable "input")) (list.repeated (.nat arity) [])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux index 4bd10e9ec..770e1cce0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux @@ -48,7 +48,7 @@ (-> Text Phase Archive s (Operation (Bytecode Any)))] Handler)) (function (_ extension_name phase archive input) - (case (<s>.run parser input) + (case (<s>.result parser input) (#try.Success input') (handler extension_name phase archive input') diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux index 953a4b88a..b3b4be343 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux @@ -4,6 +4,7 @@ [abstract ["." monad (#+ do)]] [control + ["." maybe] ["." try] ["." exception (#+ exception:)] ["<>" parser @@ -11,7 +12,6 @@ ["<s>" synthesis (#+ Parser)]]] [data ["." product] - ["." maybe] ["." text ("#\." equivalence) ["%" format (#+ format)]] [number @@ -1070,7 +1070,7 @@ bodyG (returnG returnT))))))) normalized_methods) - bytecode (<| (\ ! map (format.run class.writer)) + bytecode (<| (\ ! map (format.result class.writer)) //////.lift (class.class version.v6_0 ($_ modifier\compose class.public class.final) (name.internal anonymous_class_name) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux index 1ef715e28..db25d1d70 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux @@ -41,7 +41,7 @@ (-> Text (Generator s))] Handler)) (function (_ extension_name phase archive input) - (case (<s>.run parser input) + (case (<s>.result parser input) (#try.Success input') (handler extension_name phase archive input') @@ -63,7 +63,7 @@ (do {! /////.monad} [inputG (phase archive input) elseG (phase archive else) - @input (\ ! map _.var (generation.gensym "input")) + @input (\ ! map _.var (generation.identifier "input")) conditionalsG (: (Operation (List [Expression Expression])) (monad.map ! (function (_ [chars branch]) (do ! @@ -88,25 +88,25 @@ Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) - (/.install "is" (binary (product.uncurry _.=))) + (/.install "is" (binary (product.uncurried _.=))) (/.install "try" (unary //runtime.lux//try)))) (def: i64_procs Bundle (<| (/.prefix "i64") (|> /.empty - (/.install "and" (binary (product.uncurry _.bit_and))) - (/.install "or" (binary (product.uncurry _.bit_or))) - (/.install "xor" (binary (product.uncurry _.bit_xor))) - (/.install "left-shift" (binary (product.uncurry //runtime.i64//left_shift))) - (/.install "right-shift" (binary (product.uncurry //runtime.i64//right_shift))) - (/.install "=" (binary (product.uncurry _.=))) - (/.install "+" (binary (product.uncurry _.+))) - (/.install "-" (binary (product.uncurry _.-))) - (/.install "<" (binary (product.uncurry _.<))) - (/.install "*" (binary (product.uncurry _.*))) - (/.install "/" (binary (product.uncurry //runtime.i64//division))) - (/.install "%" (binary (product.uncurry //runtime.i64//remainder))) + (/.install "and" (binary (product.uncurried _.bit_and))) + (/.install "or" (binary (product.uncurried _.bit_or))) + (/.install "xor" (binary (product.uncurried _.bit_xor))) + (/.install "left-shift" (binary (product.uncurried //runtime.i64//left_shift))) + (/.install "right-shift" (binary (product.uncurried //runtime.i64//right_shift))) + (/.install "=" (binary (product.uncurried _.=))) + (/.install "+" (binary (product.uncurried _.+))) + (/.install "-" (binary (product.uncurried _.-))) + (/.install "<" (binary (product.uncurried _.<))) + (/.install "*" (binary (product.uncurried _.*))) + (/.install "/" (binary (product.uncurried //runtime.i64//division))) + (/.install "%" (binary (product.uncurried //runtime.i64//remainder))) (/.install "f64" (unary (_./ (_.float +1.0)))) (/.install "char" (unary (_.apply/1 (_.var "utf8.char")))) ))) @@ -119,13 +119,13 @@ Bundle (<| (/.prefix "f64") (|> /.empty - (/.install "+" (binary (product.uncurry _.+))) - (/.install "-" (binary (product.uncurry _.-))) - (/.install "*" (binary (product.uncurry _.*))) - (/.install "/" (binary (product.uncurry _./))) - (/.install "%" (binary (product.uncurry (function.flip (_.apply/2 (_.var "math.fmod")))))) - (/.install "=" (binary (product.uncurry _.=))) - (/.install "<" (binary (product.uncurry _.<))) + (/.install "+" (binary (product.uncurried _.+))) + (/.install "-" (binary (product.uncurried _.-))) + (/.install "*" (binary (product.uncurried _.*))) + (/.install "/" (binary (product.uncurried _./))) + (/.install "%" (binary (product.uncurried (function.flip (_.apply/2 (_.var "math.fmod")))))) + (/.install "=" (binary (product.uncurried _.=))) + (/.install "<" (binary (product.uncurried _.<))) (/.install "i64" (unary (!unary "math.floor"))) (/.install "encode" (unary (_.apply/2 (_.var "string.format") (_.string "%.17g")))) (/.install "decode" (unary ..f64//decode))))) @@ -146,9 +146,9 @@ Bundle (<| (/.prefix "text") (|> /.empty - (/.install "=" (binary (product.uncurry _.=))) - (/.install "<" (binary (product.uncurry _.<))) - (/.install "concat" (binary (product.uncurry (function.flip _.concat)))) + (/.install "=" (binary (product.uncurried _.=))) + (/.install "<" (binary (product.uncurried _.<))) + (/.install "concat" (binary (product.uncurried (function.flip _.concat)))) (/.install "index" (trinary ..text//index)) (/.install "size" (unary //runtime.text//size)) ... TODO: Use version below once the Lua compiler becomes self-hosted. diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux index e3363fe01..f3525e411 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux @@ -171,7 +171,7 @@ (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) .let [variable (: (-> Text (Operation Var)) - (|>> generation.gensym + (|>> generation.identifier (\ ! map _.var)))] g!inputs (monad.map ! (function (_ _) (variable "input")) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux index b061d4cc1..957407cc8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux @@ -44,7 +44,7 @@ (-> Text (Generator s))] Handler)) (function (_ extension_name phase archive input) - (case (<s>.run parser input) + (case (<s>.result parser input) (#try.Success input') (handler extension_name phase archive input') @@ -67,7 +67,7 @@ [inputG (phase archive input) [[context_module context_artifact] elseG] (generation.with_new_context archive (phase archive else)) - @input (\ ! map _.var (generation.gensym "input")) + @input (\ ! map _.var (generation.identifier "input")) conditionalsG (: (Operation (List [Expression Expression])) (monad.map ! (function (_ [chars branch]) (do ! @@ -101,7 +101,7 @@ Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) - (/.install "is" (binary (product.uncurry _.===))) + (/.install "is" (binary (product.uncurried _.===))) (/.install "try" (unary //runtime.lux//try)) )) @@ -113,19 +113,19 @@ Bundle (<| (/.prefix "i64") (|> /.empty - (/.install "and" (binary (product.uncurry _.bit_and))) - (/.install "or" (binary (product.uncurry _.bit_or))) - (/.install "xor" (binary (product.uncurry _.bit_xor))) + (/.install "and" (binary (product.uncurried _.bit_and))) + (/.install "or" (binary (product.uncurried _.bit_or))) + (/.install "xor" (binary (product.uncurried _.bit_xor))) (/.install "left-shift" (binary ..left_shifted)) - (/.install "right-shift" (binary (product.uncurry //runtime.i64//right_shifted))) - (/.install "=" (binary (product.uncurry _.==))) - (/.install "<" (binary (product.uncurry _.<))) - (/.install "+" (binary (product.uncurry //runtime.i64//+))) - (/.install "-" (binary (product.uncurry //runtime.i64//-))) - (/.install "*" (binary (product.uncurry //runtime.i64//*))) + (/.install "right-shift" (binary (product.uncurried //runtime.i64//right_shifted))) + (/.install "=" (binary (product.uncurried _.==))) + (/.install "<" (binary (product.uncurried _.<))) + (/.install "+" (binary (product.uncurried //runtime.i64//+))) + (/.install "-" (binary (product.uncurried //runtime.i64//-))) + (/.install "*" (binary (product.uncurried //runtime.i64//*))) (/.install "/" (binary (function (_ [parameter subject]) (_.intdiv/2 [subject parameter])))) - (/.install "%" (binary (product.uncurry _.%))) + (/.install "%" (binary (product.uncurried _.%))) (/.install "f64" (unary (_./ (_.float +1.0)))) (/.install "char" (unary //runtime.i64//char)) ))) @@ -142,12 +142,12 @@ Bundle (<| (/.prefix "f64") (|> /.empty - (/.install "=" (binary (product.uncurry _.==))) - (/.install "<" (binary (product.uncurry _.<))) - (/.install "+" (binary (product.uncurry _.+))) - (/.install "-" (binary (product.uncurry _.-))) - (/.install "*" (binary (product.uncurry _.*))) - (/.install "/" (binary (product.uncurry _./))) + (/.install "=" (binary (product.uncurried _.==))) + (/.install "<" (binary (product.uncurried _.<))) + (/.install "+" (binary (product.uncurried _.+))) + (/.install "-" (binary (product.uncurried _.-))) + (/.install "*" (binary (product.uncurried _.*))) + (/.install "/" (binary (product.uncurried _./))) (/.install "%" (binary ..f64//%)) (/.install "i64" (unary _.intval/1)) (/.install "encode" (unary ..f64//encode)) @@ -165,12 +165,12 @@ Bundle (<| (/.prefix "text") (|> /.empty - (/.install "=" (binary (product.uncurry _.==))) - (/.install "<" (binary (product.uncurry _.<))) - (/.install "concat" (binary (product.uncurry (function.flip _.concat)))) + (/.install "=" (binary (product.uncurried _.==))) + (/.install "<" (binary (product.uncurried _.<))) + (/.install "concat" (binary (product.uncurried (function.flip _.concat)))) (/.install "index" (trinary ..text//index)) (/.install "size" (unary //runtime.text//size)) - (/.install "char" (binary (product.uncurry //runtime.text//char))) + (/.install "char" (binary (product.uncurried //runtime.text//char))) (/.install "clip" (trinary ..text//clip)) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux index 7d32ad88a..5b9eba41e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux @@ -41,7 +41,7 @@ (-> Text (Generator s))] Handler)) (function (_ extension_name phase archive input) - (case (<s>.run parser input) + (case (<s>.result parser input) (#try.Success input') (handler extension_name phase archive input') @@ -60,7 +60,7 @@ (do {! /////.monad} [inputG (phase archive input) elseG (phase archive else) - @input (\ ! map _.var (generation.gensym "input")) + @input (\ ! map _.var (generation.identifier "input")) conditionalsG (: (Operation (List [(Expression Any) (Expression Any)])) (monad.map ! (function (_ [chars branch]) @@ -86,7 +86,7 @@ Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) - (/.install "is" (binary (product.uncurry _.is))) + (/.install "is" (binary (product.uncurried _.is))) (/.install "try" (unary //runtime.lux::try)))) (def: (capped operation parameter subject) @@ -98,19 +98,19 @@ Bundle (<| (/.prefix "i64") (|> /.empty - (/.install "and" (binary (product.uncurry //runtime.i64::and))) - (/.install "or" (binary (product.uncurry //runtime.i64::or))) - (/.install "xor" (binary (product.uncurry //runtime.i64::xor))) - (/.install "left-shift" (binary (product.uncurry //runtime.i64::left_shift))) - (/.install "right-shift" (binary (product.uncurry //runtime.i64::right_shift))) + (/.install "and" (binary (product.uncurried //runtime.i64::and))) + (/.install "or" (binary (product.uncurried //runtime.i64::or))) + (/.install "xor" (binary (product.uncurried //runtime.i64::xor))) + (/.install "left-shift" (binary (product.uncurried //runtime.i64::left_shift))) + (/.install "right-shift" (binary (product.uncurried //runtime.i64::right_shift))) - (/.install "<" (binary (product.uncurry _.<))) - (/.install "=" (binary (product.uncurry _.=))) - (/.install "+" (binary (product.uncurry (..capped _.+)))) - (/.install "-" (binary (product.uncurry (..capped _.-)))) - (/.install "*" (binary (product.uncurry (..capped _.*)))) - (/.install "/" (binary (product.uncurry //runtime.i64::division))) - (/.install "%" (binary (product.uncurry //runtime.i64::remainder))) + (/.install "<" (binary (product.uncurried _.<))) + (/.install "=" (binary (product.uncurried _.=))) + (/.install "+" (binary (product.uncurried (..capped _.+)))) + (/.install "-" (binary (product.uncurried (..capped _.-)))) + (/.install "*" (binary (product.uncurried (..capped _.*)))) + (/.install "/" (binary (product.uncurried //runtime.i64::division))) + (/.install "%" (binary (product.uncurried //runtime.i64::remainder))) (/.install "f64" (unary _.float/1)) (/.install "char" (unary //runtime.i64::char)) ))) @@ -119,15 +119,15 @@ Bundle (<| (/.prefix "f64") (|> /.empty - (/.install "+" (binary (product.uncurry _.+))) - (/.install "-" (binary (product.uncurry _.-))) - (/.install "*" (binary (product.uncurry _.*))) - (/.install "/" (binary (product.uncurry //runtime.f64::/))) + (/.install "+" (binary (product.uncurried _.+))) + (/.install "-" (binary (product.uncurried _.-))) + (/.install "*" (binary (product.uncurried _.*))) + (/.install "/" (binary (product.uncurried //runtime.f64::/))) (/.install "%" (binary (function (_ [parameter subject]) (|> (_.__import__/1 (_.unicode "math")) (_.do "fmod" (list subject parameter)))))) - (/.install "=" (binary (product.uncurry _.=))) - (/.install "<" (binary (product.uncurry _.<))) + (/.install "=" (binary (product.uncurried _.=))) + (/.install "<" (binary (product.uncurried _.<))) (/.install "i64" (unary _.int/1)) (/.install "encode" (unary _.repr/1)) (/.install "decode" (unary //runtime.f64::decode))))) @@ -144,12 +144,12 @@ Bundle (<| (/.prefix "text") (|> /.empty - (/.install "=" (binary (product.uncurry _.=))) - (/.install "<" (binary (product.uncurry _.<))) - (/.install "concat" (binary (product.uncurry (function.flip _.+)))) + (/.install "=" (binary (product.uncurried _.=))) + (/.install "<" (binary (product.uncurried _.<))) + (/.install "concat" (binary (product.uncurried (function.flip _.+)))) (/.install "index" (trinary ..text::index)) (/.install "size" (unary _.len/1)) - (/.install "char" (binary (product.uncurry //runtime.text::char))) + (/.install "char" (binary (product.uncurried //runtime.text::char))) (/.install "clip" (trinary ..text::clip)) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux index 81d1373d6..8db4b2ffd 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux @@ -131,7 +131,7 @@ (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) .let [variable (: (-> Text (Operation SVar)) - (|>> generation.gensym + (|>> generation.identifier (\ ! map _.var)))] g!inputs (monad.map ! (function (_ _) (variable "input")) (list.repeated (.nat arity) []))] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux index f14017891..25e244035 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux @@ -44,7 +44,7 @@ (-> Text (Generator s))] Handler)) (function (_ extension_name phase archive input) - (case (<s>.run parser input) + (case (<s>.result parser input) (#try.Success input') (handler extension_name phase archive input') @@ -64,7 +64,7 @@ ... ... <s>.any)))) ... ... (function (_ extension_name phase archive [input else conditionals]) ... ... (do {! /////.monad} -... ... [@input (\ ! map _.var (generation.gensym "input")) +... ... [@input (\ ! map _.var (generation.identifier "input")) ... ... inputG (phase archive input) ... ... elseG (phase archive else) ... ... conditionalsG (: (Operation (List [Expression Expression])) @@ -101,7 +101,7 @@ ... (/.install "or" (binary _.logior/2)) ... (/.install "xor" (binary _.logxor/2)) ... (/.install "left-shift" (binary _.ash/2)) - ... (/.install "right-shift" (binary (product.uncurry //runtime.i64//right_shift))) + ... (/.install "right-shift" (binary (product.uncurried //runtime.i64//right_shift))) ... (/.install "=" (binary _.=/2)) ... (/.install "<" (binary _.</2)) ... (/.install "+" (binary _.+/2)) @@ -117,13 +117,13 @@ ... Bundle ... (<| (/.prefix "f64") ... (|> /.empty -... ... (/.install "=" (binary (product.uncurry _.=/2))) -... ... (/.install "<" (binary (product.uncurry _.</2))) -... ... (/.install "+" (binary (product.uncurry _.+/2))) -... ... (/.install "-" (binary (product.uncurry _.-/2))) -... ... (/.install "*" (binary (product.uncurry _.*/2))) -... ... (/.install "/" (binary (product.uncurry _.//2))) -... ... (/.install "%" (binary (product.uncurry _.rem/2))) +... ... (/.install "=" (binary (product.uncurried _.=/2))) +... ... (/.install "<" (binary (product.uncurried _.</2))) +... ... (/.install "+" (binary (product.uncurried _.+/2))) +... ... (/.install "-" (binary (product.uncurried _.-/2))) +... ... (/.install "*" (binary (product.uncurried _.*/2))) +... ... (/.install "/" (binary (product.uncurried _.//2))) +... ... (/.install "%" (binary (product.uncurried _.rem/2))) ... ... (/.install "i64" (unary _.truncate/1)) ... (/.install "encode" (unary _.write_to_string/1)) ... ... (/.install "decode" (unary //runtime.f64//decode)) @@ -146,7 +146,7 @@ (<| (/.prefix "text") (|> /.empty ... (/.install "=" (binary _.string=/2)) - ... (/.install "<" (binary (product.uncurry _.string<?/2))) + ... (/.install "<" (binary (product.uncurried _.string<?/2))) (/.install "concat" (binary _.paste/2)) ... (/.install "index" (trinary ..text//index)) ... (/.install "size" (unary _.length/1)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux index cfe4e85e6..651f7a62d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux @@ -41,7 +41,7 @@ (-> Text (Generator s))] Handler)) (function (_ extension_name phase archive input) - (case (<s>.run parser input) + (case (<s>.result parser input) (#try.Success input') (handler extension_name phase archive input') @@ -60,7 +60,7 @@ (do {! /////.monad} [inputG (phase archive input) elseG (phase archive else) - @input (\ ! map _.local (generation.gensym "input")) + @input (\ ! map _.local (generation.identifier "input")) conditionalsG (: (Operation (List [Expression Expression])) (monad.map ! (function (_ [chars branch]) (do ! @@ -98,18 +98,18 @@ Bundle (<| (/.prefix "i64") (|> /.empty - (/.install "and" (binary (product.uncurry //runtime.i64//and))) - (/.install "or" (binary (product.uncurry //runtime.i64//or))) - (/.install "xor" (binary (product.uncurry //runtime.i64//xor))) - (/.install "left-shift" (binary (product.uncurry //runtime.i64//left_shift))) - (/.install "right-shift" (binary (product.uncurry //runtime.i64//right_shift))) + (/.install "and" (binary (product.uncurried //runtime.i64//and))) + (/.install "or" (binary (product.uncurried //runtime.i64//or))) + (/.install "xor" (binary (product.uncurried //runtime.i64//xor))) + (/.install "left-shift" (binary (product.uncurried //runtime.i64//left_shift))) + (/.install "right-shift" (binary (product.uncurried //runtime.i64//right_shift))) - (/.install "<" (binary (product.uncurry _.<))) - (/.install "=" (binary (product.uncurry _.=))) - (/.install "+" (binary (product.uncurry (..capped _.+)))) - (/.install "-" (binary (product.uncurry (..capped _.-)))) - (/.install "*" (binary (product.uncurry (..capped _.*)))) - (/.install "/" (binary (product.uncurry //runtime.i64//division))) + (/.install "<" (binary (product.uncurried _.<))) + (/.install "=" (binary (product.uncurried _.=))) + (/.install "+" (binary (product.uncurried (..capped _.+)))) + (/.install "-" (binary (product.uncurried (..capped _.-)))) + (/.install "*" (binary (product.uncurried (..capped _.*)))) + (/.install "/" (binary (product.uncurried //runtime.i64//division))) (/.install "%" (binary (function (_ [parameter subject]) (_.do "remainder" (list parameter) subject)))) @@ -121,14 +121,14 @@ Bundle (<| (/.prefix "f64") (|> /.empty - (/.install "+" (binary (product.uncurry _.+))) - (/.install "-" (binary (product.uncurry _.-))) - (/.install "*" (binary (product.uncurry _.*))) - (/.install "/" (binary (product.uncurry _./))) + (/.install "+" (binary (product.uncurried _.+))) + (/.install "-" (binary (product.uncurried _.-))) + (/.install "*" (binary (product.uncurried _.*))) + (/.install "/" (binary (product.uncurried _./))) (/.install "%" (binary (function (_ [parameter subject]) (_.do "remainder" (list parameter) subject)))) - (/.install "=" (binary (product.uncurry _.=))) - (/.install "<" (binary (product.uncurry _.<))) + (/.install "=" (binary (product.uncurried _.=))) + (/.install "<" (binary (product.uncurried _.<))) (/.install "i64" (unary (_.do "floor" (list)))) (/.install "encode" (unary (_.do "to_s" (list)))) (/.install "decode" (unary //runtime.f64//decode))))) @@ -149,12 +149,12 @@ Bundle (<| (/.prefix "text") (|> /.empty - (/.install "=" (binary (product.uncurry _.=))) - (/.install "<" (binary (product.uncurry _.<))) - (/.install "concat" (binary (product.uncurry (function.flip _.+)))) + (/.install "=" (binary (product.uncurried _.=))) + (/.install "<" (binary (product.uncurried _.<))) + (/.install "concat" (binary (product.uncurried (function.flip _.+)))) (/.install "index" (trinary text//index)) (/.install "size" (unary (_.the "length"))) - (/.install "char" (binary (product.uncurry //runtime.text//char))) + (/.install "char" (binary (product.uncurried //runtime.text//char))) (/.install "clip" (trinary text//clip)) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux index c90072ef1..2b2fca71f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux @@ -44,7 +44,7 @@ (-> Text (Generator s))] Handler)) (function (_ extension_name phase archive input) - (case (<s>.run parser input) + (case (<s>.result parser input) (#try.Success input') (handler extension_name phase archive input') @@ -64,7 +64,7 @@ <s>.any)))) (function (_ extension_name phase archive [input else conditionals]) (do {! /////.monad} - [@input (\ ! map _.var (generation.gensym "input")) + [@input (\ ! map _.var (generation.identifier "input")) inputG (phase archive input) elseG (phase archive else) conditionalsG (: (Operation (List [Expression Expression])) @@ -84,7 +84,7 @@ Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) - (/.install "is" (binary (product.uncurry _.eq?/2))) + (/.install "is" (binary (product.uncurried _.eq?/2))) (/.install "try" (unary //runtime.lux//try)) )) @@ -97,18 +97,18 @@ Bundle (<| (/.prefix "i64") (|> /.empty - (/.install "and" (binary (product.uncurry //runtime.i64//and))) - (/.install "or" (binary (product.uncurry //runtime.i64//or))) - (/.install "xor" (binary (product.uncurry //runtime.i64//xor))) - (/.install "left-shift" (binary (product.uncurry //runtime.i64//left_shift))) - (/.install "right-shift" (binary (product.uncurry //runtime.i64//right_shift))) - (/.install "=" (binary (product.uncurry _.=/2))) - (/.install "<" (binary (product.uncurry _.</2))) - (/.install "+" (binary (product.uncurry (..capped _.+/2)))) - (/.install "-" (binary (product.uncurry (..capped _.-/2)))) - (/.install "*" (binary (product.uncurry (..capped _.*/2)))) - (/.install "/" (binary (product.uncurry //runtime.i64//division))) - (/.install "%" (binary (product.uncurry _.remainder/2))) + (/.install "and" (binary (product.uncurried //runtime.i64//and))) + (/.install "or" (binary (product.uncurried //runtime.i64//or))) + (/.install "xor" (binary (product.uncurried //runtime.i64//xor))) + (/.install "left-shift" (binary (product.uncurried //runtime.i64//left_shift))) + (/.install "right-shift" (binary (product.uncurried //runtime.i64//right_shift))) + (/.install "=" (binary (product.uncurried _.=/2))) + (/.install "<" (binary (product.uncurried _.</2))) + (/.install "+" (binary (product.uncurried (..capped _.+/2)))) + (/.install "-" (binary (product.uncurried (..capped _.-/2)))) + (/.install "*" (binary (product.uncurried (..capped _.*/2)))) + (/.install "/" (binary (product.uncurried //runtime.i64//division))) + (/.install "%" (binary (product.uncurried _.remainder/2))) (/.install "f64" (unary (_.//2 (_.float +1.0)))) (/.install "char" (unary (|>> _.integer->char/1 (_.make_string/2 (_.int +1))))) ))) @@ -117,13 +117,13 @@ Bundle (<| (/.prefix "f64") (|> /.empty - (/.install "=" (binary (product.uncurry _.=/2))) - (/.install "<" (binary (product.uncurry _.</2))) - (/.install "+" (binary (product.uncurry _.+/2))) - (/.install "-" (binary (product.uncurry _.-/2))) - (/.install "*" (binary (product.uncurry _.*/2))) - (/.install "/" (binary (product.uncurry _.//2))) - (/.install "%" (binary (product.uncurry _.remainder/2))) + (/.install "=" (binary (product.uncurried _.=/2))) + (/.install "<" (binary (product.uncurried _.</2))) + (/.install "+" (binary (product.uncurried _.+/2))) + (/.install "-" (binary (product.uncurried _.-/2))) + (/.install "*" (binary (product.uncurried _.*/2))) + (/.install "/" (binary (product.uncurried _.//2))) + (/.install "%" (binary (product.uncurried _.remainder/2))) (/.install "i64" (unary _.truncate/1)) (/.install "encode" (unary _.number->string/1)) (/.install "decode" (unary //runtime.f64//decode))))) @@ -140,12 +140,12 @@ Bundle (<| (/.prefix "text") (|> /.empty - (/.install "=" (binary (product.uncurry _.string=?/2))) - (/.install "<" (binary (product.uncurry _.string<?/2))) - (/.install "concat" (binary (product.uncurry _.string_append/2))) + (/.install "=" (binary (product.uncurried _.string=?/2))) + (/.install "<" (binary (product.uncurried _.string<?/2))) + (/.install "concat" (binary (product.uncurried _.string_append/2))) (/.install "index" (trinary ..text//index)) (/.install "size" (unary _.string_length/1)) - (/.install "char" (binary (product.uncurry //runtime.text//char))) + (/.install "char" (binary (product.uncurried //runtime.text//char))) (/.install "clip" (trinary ..text//clip)) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux index 6cd07080a..c4b5b3764 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux @@ -26,7 +26,7 @@ (def: lux_procs Bundle (|> bundle.empty - (bundle.install "is" (binary (product.uncurry _.eq))) + (bundle.install "is" (binary (product.uncurried _.eq))) (bundle.install "try" (unary ///runtime.lux//try)))) (def: (i64//left_shifted [paramG subjectG]) @@ -46,19 +46,19 @@ Bundle (<| (bundle.prefix "i64") (|> bundle.empty - (bundle.install "and" (binary (product.uncurry _.logand))) - (bundle.install "or" (binary (product.uncurry _.logior))) - (bundle.install "xor" (binary (product.uncurry _.logxor))) + (bundle.install "and" (binary (product.uncurried _.logand))) + (bundle.install "or" (binary (product.uncurried _.logior))) + (bundle.install "xor" (binary (product.uncurried _.logxor))) (bundle.install "left-shift" (binary i64//left_shifted)) (bundle.install "logical-right-shift" (binary i64//logic_right_shifted)) (bundle.install "arithmetic-right-shift" (binary i64//arithmetic_right_shifted)) - (bundle.install "=" (binary (product.uncurry _.=))) - (bundle.install "<" (binary (product.uncurry _.<))) - (bundle.install "+" (binary (product.uncurry _.+))) - (bundle.install "-" (binary (product.uncurry _.-))) - (bundle.install "*" (binary (product.uncurry _.*))) - (bundle.install "/" (binary (product.uncurry _.floor))) - (bundle.install "%" (binary (product.uncurry _.rem))) + (bundle.install "=" (binary (product.uncurried _.=))) + (bundle.install "<" (binary (product.uncurried _.<))) + (bundle.install "+" (binary (product.uncurried _.+))) + (bundle.install "-" (binary (product.uncurried _.-))) + (bundle.install "*" (binary (product.uncurried _.*))) + (bundle.install "/" (binary (product.uncurried _.floor))) + (bundle.install "%" (binary (product.uncurried _.rem))) (bundle.install "f64" (unary (function (_ value) (_.coerce/2 [value (_.symbol "double-float")])))) (bundle.install "char" (unary (|>> _.code_char/1 _.string/1))) @@ -68,13 +68,13 @@ Bundle (<| (bundle.prefix "f64") (|> bundle.empty - (bundle.install "+" (binary (product.uncurry _.+))) - (bundle.install "-" (binary (product.uncurry _.-))) - (bundle.install "*" (binary (product.uncurry _.*))) - (bundle.install "/" (binary (product.uncurry _./))) - (bundle.install "%" (binary (product.uncurry _.mod))) - (bundle.install "=" (binary (product.uncurry _.=))) - (bundle.install "<" (binary (product.uncurry _.<))) + (bundle.install "+" (binary (product.uncurried _.+))) + (bundle.install "-" (binary (product.uncurried _.-))) + (bundle.install "*" (binary (product.uncurried _.*))) + (bundle.install "/" (binary (product.uncurried _./))) + (bundle.install "%" (binary (product.uncurried _.mod))) + (bundle.install "=" (binary (product.uncurried _.=))) + (bundle.install "<" (binary (product.uncurried _.<))) (bundle.install "i64" (unary _.floor/1)) (bundle.install "encode" (unary _.write_to_string/1)) (bundle.install "decode" (unary (let [@temp (_.var "temp")] @@ -103,7 +103,7 @@ Bundle (<| (bundle.prefix "text") (|> bundle.empty - (bundle.install "=" (binary (product.uncurry _.string=))) + (bundle.install "=" (binary (product.uncurried _.string=))) (bundle.install "<" (binary text//<)) (bundle.install "concat" (binary _.concatenate/2|string)) (bundle.install "index" (trinary text//index)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux index 9731cb94c..ce6b2bdc6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux @@ -48,7 +48,7 @@ _ (do {! ///////phase.monad} - [@closure (\ ! map _.var (/////generation.gensym "closure"))] + [@closure (\ ! map _.var (/////generation.identifier "closure"))] (in (_.labels (list [@closure [(|> (list.enumeration inits) (list\map (|>> product.left ..capture)) _.args) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux index 32b090ae1..172a4d13c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux @@ -105,7 +105,7 @@ code) (do meta.monad [runtime_id meta.seed] - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux index 5d8406d48..aeeb17528 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux @@ -10,7 +10,7 @@ [collection ["." list ("#\." functor)]]] ["." meta] - ["." macro (#+ with_gensyms) + ["." macro (#+ with_identifiers) ["." code] [syntax (#+ syntax:)]]]] ["." /// #_ @@ -31,9 +31,9 @@ (type: .public (Variadic of) (-> (List of) of)) (syntax: (arity: {arity s.nat} {name s.local_identifier} type) - (with_gensyms [g!_ g!extension g!name g!phase g!archive g!inputs g!of g!anchor g!expression g!directive] + (with_identifiers [g!_ g!extension g!name g!phase g!archive g!inputs g!of g!anchor g!expression g!directive] (do {! meta.monad} - [g!input+ (monad.seq ! (list.repeated arity (macro.gensym "input")))] + [g!input+ (monad.seq ! (list.repeated arity (macro.identifier "input")))] (in (list (` (def: .public ((~ (code.local_identifier name)) (~ g!extension)) (All [(~ g!anchor) (~ g!expression) (~ g!directive)] (-> ((~ type) (~ g!expression)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux index 6671f1e3f..12bce545f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux @@ -3,8 +3,9 @@ [lux (#- case let if) [abstract ["." monad (#+ do)]] + [control + ["." maybe]] [data - ["." maybe] ["." text] [collection ["." list ("#\." functor fold)]]] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux index 815ee4a36..84e546a41 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux @@ -101,7 +101,7 @@ (<code>.form (<>.and <code>.local_identifier (<>.some <code>.local_identifier))))} code) - (macro.with_gensyms [g!_ runtime] + (macro.with_identifiers [g!_ runtime] (let [runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration (#.Left name) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux index 7a8dd2860..095c973b4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux @@ -111,7 +111,7 @@ fields methods (row.row))) - .let [bytecode (format.run class.writer class)] + .let [bytecode (format.result class.writer class)] _ (generation.execute! [function_class bytecode]) _ (generation.save! function_class #.None [function_class bytecode])] (in instance))) @@ -124,7 +124,7 @@ (in ($_ _.compose abstractionG (|> inputsG - (list.chunk /arity.maximum) + (list.sub /arity.maximum) (monad.map _.monad (function (_ batchG) ($_ _.compose diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux index c3d119ec4..4db70e828 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux @@ -113,27 +113,27 @@ (_.putstatic (type.class bytecode_name (list)) ..value::field ..value::type) _.return)))) (row.row))] - (io.run (do {! (try.with io.monad)} - [bytecode (\ ! map (format.run class.writer) - (io.io bytecode)) - _ (loader.store eval_class bytecode library) - class (loader.load eval_class loader) - value (\ io.monad in (class_value eval_class class))] - (in [value - [eval_class bytecode]]))))) + (io.run! (do {! (try.with io.monad)} + [bytecode (\ ! map (format.result class.writer) + (io.io bytecode)) + _ (loader.store eval_class bytecode library) + class (loader.load eval_class loader) + value (\ io.monad in (class_value eval_class class))] + (in [value + [eval_class bytecode]]))))) (def: (execute! library loader temp_label [class_name class_bytecode]) (-> Library java/lang/ClassLoader Text Definition (Try Any)) - (io.run (do (try.with io.monad) - [existing_class? (|> (atom.read! library) - (\ io.monad map (function (_ library) - (dictionary.key? library class_name))) - (try.lift io.monad) - (: (IO (Try Bit)))) - _ (if existing_class? - (in []) - (loader.store class_name class_bytecode library))] - (loader.load class_name loader)))) + (io.run! (do (try.with io.monad) + [existing_class? (|> (atom.read! library) + (\ io.monad map (function (_ library) + (dictionary.key? library class_name))) + (try.lift io.monad) + (: (IO (Try Bit)))) + _ (if existing_class? + (in []) + (loader.store class_name class_bytecode library))] + (loader.load class_name loader)))) (def: (define! library loader [module name] valueG) (-> Library java/lang/ClassLoader Name (Bytecode Any) (Try [Text Any Definition])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux index 0a749f337..f7ba0eb93 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux @@ -139,7 +139,7 @@ ..run_io _.return)))] [..class - (<| (format.run class.writer) + (<| (format.result class.writer) try.assumed (class.class version.v6_0 ..program::modifier diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux index dff909982..8fcd70360 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux @@ -515,7 +515,7 @@ ($_ modifier\compose class.public class.final)) - bytecode (<| (format.run class.writer) + bytecode (<| (format.result class.writer) try.assumed (class.class jvm/version.v6_0 modifier @@ -583,7 +583,7 @@ //function/count.field //function/count.type (row.row))) - bytecode (<| (format.run class.writer) + bytecode (<| (format.result class.writer) try.assumed (class.class jvm/version.v6_0 modifier diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux index bfb1ab115..5ba5d0f5e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux @@ -123,12 +123,12 @@ code) (do meta.monad [runtime_id meta.seed] - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration (#.Left name) - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) Var @@ -141,7 +141,7 @@ (_.set (~ g!name) (~ code)))))))))) (#.Right [name inputs]) - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name) inputsC (list\map code.local_identifier inputs) inputs_typesC (list\map (function.constant (` _.Expression)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux index 9b99a1ca6..bfc75d6ca 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux @@ -257,10 +257,6 @@ iteration!) (_.throw (_.new (_.constant "Exception") (list (_.string ////synthesis/case.pattern_matching_error)))))))) -(def: (gensym prefix) - (-> Text (Operation Text)) - (\ ///////phase.monad map (|>> %.nat (format prefix)) /////generation.next)) - (def: .public dependencies (-> Path (List Var)) (|>> ////synthesis/case.storage diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux index a630b31c3..c236c3f75 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux @@ -27,32 +27,32 @@ (def: lux_procs Bundle (|> bundle.empty - (bundle.install "is" (binary (product.uncurry _.=))) + (bundle.install "is" (binary (product.uncurried _.=))) (bundle.install "try" (unary ///runtime.lux//try)))) (def: i64_procs Bundle (<| (bundle.prefix "i64") (|> bundle.empty - (bundle.install "and" (binary (product.uncurry _.bit_and))) - (bundle.install "or" (binary (product.uncurry _.bit_or))) - (bundle.install "xor" (binary (product.uncurry _.bit_xor))) - (bundle.install "left-shift" (binary (product.uncurry _.bit_shl))) - (bundle.install "logical-right-shift" (binary (product.uncurry ///runtime.i64//logic_right_shift))) - (bundle.install "arithmetic-right-shift" (binary (product.uncurry _.bit_shr))) - (bundle.install "=" (binary (product.uncurry _.=))) - (bundle.install "+" (binary (product.uncurry _.+))) - (bundle.install "-" (binary (product.uncurry _.-))) + (bundle.install "and" (binary (product.uncurried _.bit_and))) + (bundle.install "or" (binary (product.uncurried _.bit_or))) + (bundle.install "xor" (binary (product.uncurried _.bit_xor))) + (bundle.install "left-shift" (binary (product.uncurried _.bit_shl))) + (bundle.install "logical-right-shift" (binary (product.uncurried ///runtime.i64//logic_right_shift))) + (bundle.install "arithmetic-right-shift" (binary (product.uncurried _.bit_shr))) + (bundle.install "=" (binary (product.uncurried _.=))) + (bundle.install "+" (binary (product.uncurried _.+))) + (bundle.install "-" (binary (product.uncurried _.-))) ))) (def: int_procs Bundle (<| (bundle.prefix "int") (|> bundle.empty - (bundle.install "<" (binary (product.uncurry _.<))) - (bundle.install "*" (binary (product.uncurry _.*))) - (bundle.install "/" (binary (product.uncurry _./))) - (bundle.install "%" (binary (product.uncurry _.%))) + (bundle.install "<" (binary (product.uncurried _.<))) + (bundle.install "*" (binary (product.uncurried _.*))) + (bundle.install "/" (binary (product.uncurried _./))) + (bundle.install "%" (binary (product.uncurried _.%))) (bundle.install "frac" (unary _.floatval/1)) (bundle.install "char" (unary _.chr/1))))) @@ -60,13 +60,13 @@ Bundle (<| (bundle.prefix "frac") (|> bundle.empty - (bundle.install "+" (binary (product.uncurry _.+))) - (bundle.install "-" (binary (product.uncurry _.-))) - (bundle.install "*" (binary (product.uncurry _.*))) - (bundle.install "/" (binary (product.uncurry _./))) - (bundle.install "%" (binary (product.uncurry _.%))) - (bundle.install "=" (binary (product.uncurry _.=))) - (bundle.install "<" (binary (product.uncurry _.<))) + (bundle.install "+" (binary (product.uncurried _.+))) + (bundle.install "-" (binary (product.uncurried _.-))) + (bundle.install "*" (binary (product.uncurried _.*))) + (bundle.install "/" (binary (product.uncurried _./))) + (bundle.install "%" (binary (product.uncurried _.%))) + (bundle.install "=" (binary (product.uncurried _.=))) + (bundle.install "<" (binary (product.uncurried _.<))) (bundle.install "int" (unary _.intval/1)) (bundle.install "encode" (unary _.strval/1)) (bundle.install "decode" (unary (|>> _.floatval/1 ///runtime.some))) @@ -80,9 +80,9 @@ Bundle (<| (bundle.prefix "text") (|> bundle.empty - (bundle.install "=" (binary (product.uncurry _.=))) - (bundle.install "<" (binary (product.uncurry _.<))) - (bundle.install "concat" (binary (product.uncurry _.concat))) + (bundle.install "=" (binary (product.uncurried _.=))) + (bundle.install "<" (binary (product.uncurried _.<))) + (bundle.install "concat" (binary (product.uncurried _.concat))) (bundle.install "index" (trinary text//index)) (bundle.install "size" (unary _.strlen/1)) (bundle.install "char" (binary (function (text//char [text idx]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux index f1c4c0eb6..62238c960 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux @@ -91,12 +91,12 @@ code) (do meta.monad [runtime_id meta.seed] - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.constant (~ (code.text (%.code runtime)))))] (case declaration (#.Left name) - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) Var @@ -109,7 +109,7 @@ (_.define (~ g!name) (~ code)))))))))) (#.Right [name inputs]) - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name) inputsC (list\map code.local_identifier inputs) inputs_typesC (list\map (function.constant (` _.Expression)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux index 137623c8a..b00d65682 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux @@ -34,7 +34,7 @@ [meta [archive (#+ Archive)]]]]]]]) -(def: .public (gensym prefix) +(def: .public (identifier prefix) (-> Text (Operation SVar)) (///////phase\map (|>> %.nat (format prefix) _.var) /////generation.next)) @@ -279,7 +279,7 @@ (do ! [pre! (recur preP) post! (recur postP) - g!once (..gensym "once")] + g!once (..identifier "once")] (in (..alternation in_closure? g!once pre! post!))) _ @@ -289,7 +289,7 @@ (-> Bit Phase! Phase Archive Path (Operation (Statement Any))) (do ///////phase.monad [pattern_matching! (pattern_matching' in_closure? statement expression archive pathP) - g!once (..gensym "once")] + g!once (..identifier "once")] (in ($_ _.then (..with_looping in_closure? g!once pattern_matching!) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux index 4332539e5..6739e6ec5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux @@ -110,7 +110,7 @@ (Generator! (List Synthesis)) (do {! ///////phase.monad} [offset /////generation.anchor - @temp (//case.gensym "lux_recur_values") + @temp (//case.identifier "lux_recur_values") argsO+ (monad.map ! (expression archive) argsS+) .let [re_binds (|> argsO+ list.enumeration diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux index 2cd100ce9..360d33002 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux @@ -127,7 +127,7 @@ code) (case declaration (#.Left name) - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [nameC (code.local_identifier name) code_nameC (code.local_identifier (format "@" name)) runtime_nameC (` (runtime_name (~ (code.text name))))] @@ -139,7 +139,7 @@ (_.set (list (~ g!_)) (~ code)))))))))) (#.Right [name inputs]) - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [nameC (code.local_identifier name) code_nameC (code.local_identifier (format "@" name)) runtime_nameC (` (runtime_name (~ (code.text name)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux index cdbaf6e1f..859744980 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux @@ -43,7 +43,7 @@ ... true loop _ (do {! ///////phase.monad} - [$scope (\ ! map _.var (/////generation.gensym "loop_scope")) + [$scope (\ ! map _.var (/////generation.identifier "loop_scope")) initsO+ (monad.map ! (expression archive) initsS+) bodyO (/////generation.with_anchor $scope (expression archive bodyS))] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux index c257a2c0c..18de8ffef 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux @@ -10,7 +10,7 @@ [number] (coll [list "list/" Functor<List>] (dictionary ["dict" unordered #+ Dict]))) - [macro #+ with_gensyms] + [macro #+ with_identifiers] (macro [code] ["s" syntax #+ syntax:]) [host]) @@ -63,9 +63,9 @@ " Actual: " (|> actual .int %i))) (syntax: (arity: {name s.local_identifier} {arity s.nat}) - (with_gensyms [g!_ g!proc g!name g!translate g!inputs] + (with_identifiers [g!_ g!proc g!name g!translate g!inputs] (do {@ macro.monad} - [g!input+ (monad.seq @ (list.repeated arity (macro.gensym "input")))] + [g!input+ (monad.seq @ (list.repeated arity (macro.identifier "input")))] (in (list (` (def: .public ((~ (code.local_identifier name)) (~ g!proc)) (-> (-> (..Vector (~ (code.nat arity)) Expression) Expression) (-> Text ..Proc)) @@ -123,7 +123,7 @@ (-> Text Proc) (function (_ proc_name) (function (_ translate inputsS) - (case (s.run inputsS ($_ p.seq s.nat (s.tuple (p.many s.any)) s.any)) + (case (s.result inputsS ($_ p.seq s.nat (s.tuple (p.many s.any)) s.any)) (#e.Success [offset initsS+ bodyS]) (loopT.translate_loop translate offset initsS+ bodyS) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux index b416fc128..1bcb51d73 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux @@ -94,7 +94,7 @@ code) (do meta.monad [runtime_id meta.seed] - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux index 253bec114..dbdb0b1d0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux @@ -36,7 +36,7 @@ [meta [archive (#+ Archive)]]]]]]]) -(def: .public (gensym prefix) +(def: .public (identifier prefix) (-> Text (Operation LVar)) (///////phase\map (|>> %.nat (format prefix) _.local) /////generation.next)) @@ -322,8 +322,8 @@ (do ///////phase.monad [pre! (recur preP) post! (recur postP) - g!once (..gensym "once") - g!continue? (..gensym "continue")] + g!once (..identifier "once") + g!continue? (..identifier "continue")] (in (..alternation in_closure? g!once g!continue? pre! post!))) _ @@ -333,8 +333,8 @@ (-> Bit (Generator! Path)) (do ///////phase.monad [pattern_matching! (pattern_matching' in_closure? statement expression archive pathP) - g!once (..gensym "once") - g!continue? (..gensym "continue")] + g!once (..identifier "once") + g!continue? (..identifier "continue")] (in ($_ _.then (..with_looping in_closure? g!once g!continue? pattern_matching!) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux index 9e2a43500..9fe46c86d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux @@ -84,7 +84,7 @@ (Generator! (List Synthesis)) (do {! ///////phase.monad} [offset /////generation.anchor - @temp (//case.gensym "lux_recur_values") + @temp (//case.identifier "lux_recur_values") argsO+ (monad.map ! (expression archive) argsS+) .let [re_binds (|> argsO+ list.enumeration diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux index 9de984f61..424d8b14b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux @@ -92,12 +92,12 @@ code) (do meta.monad [runtime_id meta.seed] - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.local (~ (code.text (%.code runtime)))))] (case declaration (#.Left name) - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) LVar (~ runtime_name))) (` (def: (~ (code.local_identifier (format "@" name))) @@ -107,7 +107,7 @@ (_.set (list (~ g!name)) (~ code)))))))))) (#.Right [name inputs]) - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name) inputsC (list\map code.local_identifier inputs) inputs_typesC (list\map (function.constant (` _.Expression)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux index 95e2f1edb..c6d6f4da8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux @@ -15,7 +15,7 @@ [collection ["." list ("#\." functor)] ["dict" dictionary (#+ Dictionary)]]] - ["." macro (#+ with_gensyms) + ["." macro (#+ with_identifiers) ["." code] [syntax (#+ syntax:)]] [target @@ -38,9 +38,9 @@ (type: .public Variadic (-> (List Expression) Computation)) (syntax: (arity: {name s.local_identifier} {arity s.nat}) - (with_gensyms [g!_ g!extension g!name g!phase g!inputs] + (with_identifiers [g!_ g!extension g!name g!phase g!inputs] (do {! macro.monad} - [g!input+ (monad.seq ! (list.repeated arity (macro.gensym "input")))] + [g!input+ (monad.seq ! (list.repeated arity (macro.identifier "input")))] (in (list (` (def: .public ((~ (code.local_identifier name)) (~ g!extension)) (-> (-> (..Vector (~ (code.nat arity)) Expression) Computation) Handler) @@ -73,7 +73,7 @@ (def: bundle::lux Bundle (|> bundle.empty - (bundle.install "is?" (binary (product.uncurry _.eq?/2))) + (bundle.install "is?" (binary (product.uncurried _.eq?/2))) (bundle.install "try" (unary ///runtime.lux//try)))) (template [<name> <op>] @@ -189,7 +189,7 @@ (|> bundle.empty (bundle.install "=" (binary text::=)) (bundle.install "<" (binary text::<)) - (bundle.install "concat" (binary (product.uncurry _.string_append/2))) + (bundle.install "concat" (binary (product.uncurried _.string_append/2))) (bundle.install "size" (unary _.string_length/1)) (bundle.install "char" (binary text::char)) (bundle.install "clip" (trinary text::clip))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux index e61519d16..f5f293f92 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux @@ -76,7 +76,7 @@ code) (do meta.monad [runtime_id meta.seed] - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux index 4adb10f57..2b9202239 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux @@ -7,7 +7,6 @@ [pipe (#+ case>)] ["." try]] [data - ["." maybe] [collection ["." list ("#\." functor)] ["." dictionary (#+ Dictionary)]]]]] @@ -86,7 +85,7 @@ (/.with_currying? false (function (_ state) (|> (//extension.apply archive optimization [name args]) - (phase.run' state) + (phase.result' state) (case> (#try.Success output) (#try.Success output) @@ -94,7 +93,7 @@ (|> args (monad.map phase.monad optimization') (phase\map (|>> [name] #/.Extension)) - (phase.run' state)))))) + (phase.result' state)))))) ))) (def: .public (phase archive analysis) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux index 46189fb26..875b2ca60 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -227,7 +227,7 @@ (-> Phase Archive Synthesis Match (Operation Synthesis)) (do {! ///.monad} [headSP (path archive synthesize headP headA) - tailSP+ (monad.map ! (product.uncurry (path archive synthesize)) tailPA+)] + tailSP+ (monad.map ! (product.uncurried (path archive synthesize)) tailPA+)] (in (/.branch/case [input (list\fold weave headSP tailSP+)])))) (template: (!masking <variable> <output>) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 83822639e..7becfbe4d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -6,9 +6,9 @@ ["." enum]] [control [pipe (#+ case>)] + ["." maybe ("#\." functor)] ["." exception (#+ exception:)]] [data - ["." maybe ("#\." functor)] ["." text ["%" format (#+ format)]] [collection diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux index 23227e4df..d9890dbc9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux @@ -3,8 +3,9 @@ [lux #* [abstract ["." monad (#+ do)]] + [control + ["." maybe ("#\." monad)]] [data - ["." maybe ("#\." monad)] [collection ["." list]]] [math diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux index 6ba15c700..41d618cc3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux @@ -4,11 +4,11 @@ [abstract ["." monad (#+ do)]] [control + ["." maybe ("#\." functor)] ["." try (#+ Try)] ["." exception (#+ exception:)]] [data ["." product] - ["." maybe ("#\." functor)] ["." text ["%" format]] [collection @@ -312,7 +312,7 @@ (list\map product.left))]] (in [(list\fold dictionary.remove redundancy (set.list bindings)) (|> redundants - (list.sort n.>) + (list.sorted n.>) (list\fold (..remove_local_from_path ..remove_local) (#/.Seq pre post)))])) (#/.Then then) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux index af17d9e15..365f9e804 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux @@ -4,11 +4,11 @@ [abstract ["." monad (#+ do)]] [control + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)]] [data ["." product] - ["." maybe] [text ["%" format (#+ format)]] [collection diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux index 6615d49a9..6db98721b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -31,11 +31,11 @@ [abstract monad] [control + ["." maybe] ["." exception (#+ exception:)] [parser [text (#+ Offset)]]] [data - ["." maybe] ["." text ["%" format (#+ format)]] [collection diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux index 0f02d37be..806fdc3c9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -7,11 +7,11 @@ [hash (#+ Hash)]] [control [pipe (#+ case>)] + ["." maybe] ["." exception (#+ exception:)]] [data ["." sum] ["." product] - ["." maybe] ["." bit ("#\." equivalence)] ["." text ("#\." equivalence) ["%" format (#+ Format format)]] diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index e42b2d2c5..348a7ced9 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -239,7 +239,7 @@ (#.Some _) (#.Some [module id]) #.None #.None))) [version next] - (binary.run ..writer)))) + (binary.result ..writer)))) (exception: .public (version_mismatch {expected Version} {actual Version}) (exception.report @@ -272,7 +272,7 @@ (def: .public (import expected binary) (-> Version Binary (Try Archive)) (do try.monad - [[actual next reservations] (<binary>.run ..reader binary) + [[actual next reservations] (<binary>.result ..reader binary) _ (exception.assertion ..version_mismatch [expected actual] (n\= expected actual)) _ (exception.assertion ..corrupt_data [] diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux index 4a9773f6c..66a903ca1 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux @@ -4,12 +4,12 @@ [abstract ["." monad (#+ do)]] [control + ["." maybe ("#\." functor)] ["." try (#+ Try)] ["." state] ["." function ["." memo (#+ Memo)]]] [data - ["." maybe ("#\." functor)] ["." text ["%" format (#+ format)]] [collection @@ -87,7 +87,7 @@ (let [ancestry (..ancestry archive)] (|> ancestry dictionary.keys - (list.sort (..dependency? ancestry)) + (list.sorted (..dependency? ancestry)) (monad.map try.monad (function (_ module) (do try.monad diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux index 21d657352..a87c3840b 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -412,7 +412,7 @@ (monad.map ! (function (_ [module_name module_id]) (do ! [data (..read_module_descriptor fs static module_id) - [descriptor document] (async\in (<binary>.run ..parser data))] + [descriptor document] (async\in (<binary>.result ..parser data))] (if (text\= archive.runtime_module module_name) (in [true [module_name [module_id [descriptor document]]]]) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux index a36b2fda0..993b2264d 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -5,10 +5,10 @@ [abstract ["." monad (#+ Monad do)]] [control + ["." maybe ("#\." functor)] ["." try (#+ Try)]] [data ["." binary (#+ Binary)] - ["." maybe ("#\." functor)] ["." text ["%" format (#+ format)]] [collection @@ -162,7 +162,7 @@ (def: (read_jar_entry_with_unknown_size input) (-> java/util/jar/JarInputStream [Nat Binary]) - (let [chunk (binary.create ..mebi_byte) + (let [chunk (binary.empty ..mebi_byte) chunk_size (.int ..mebi_byte) buffer (java/io/ByteArrayOutputStream::new chunk_size)] (loop [so_far 0] @@ -178,7 +178,7 @@ (def: (read_jar_entry_with_known_size expected_size input) (-> Nat java/util/jar/JarInputStream [Nat Binary]) - (let [buffer (binary.create expected_size)] + (let [buffer (binary.empty expected_size)] (loop [so_far 0] (let [so_far' (|> input (java/io/InputStream::read buffer (.int so_far) (.int (n.- so_far expected_size))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux index f3bfea5b0..42a1a378c 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux @@ -129,4 +129,4 @@ entries (monad.map ! (..write_module now mapping) order)] (in (|> entries row.of_list - (binary.run tar.writer)))))) + (binary.result tar.writer)))))) diff --git a/stdlib/source/library/lux/tool/compiler/phase.lux b/stdlib/source/library/lux/tool/compiler/phase.lux index 73aef8bcd..5bfdac402 100644 --- a/stdlib/source/library/lux/tool/compiler/phase.lux +++ b/stdlib/source/library/lux/tool/compiler/phase.lux @@ -34,12 +34,12 @@ (type: .public (Phase s i o) (-> Archive i (Operation s o))) -(def: .public (run' state operation) +(def: .public (result' state operation) (All [s o] (-> s (Operation s o) (Try [s o]))) (operation state)) -(def: .public (run state operation) +(def: .public (result state operation) (All [s o] (-> s (Operation s o) (Try o))) (|> state @@ -107,10 +107,10 @@ (-> Name Text (Operation s a) (Operation s a))) (do ..monad [_ (in []) - .let [pre (io.run instant.now)] + .let [pre (io.run! instant.now)] output operation .let [_ (|> instant.now - io.run + io.run! instant.relative (duration.difference (instant.relative pre)) %.duration diff --git a/stdlib/source/library/lux/tool/interpreter.lux b/stdlib/source/library/lux/tool/interpreter.lux index 4631daec4..14f53e927 100644 --- a/stdlib/source/library/lux/tool/interpreter.lux +++ b/stdlib/source/library/lux/tool/interpreter.lux @@ -83,7 +83,7 @@ #.Interpreter state)) [state _] (\ (get@ #platform.file_system platform) - lift (phase.run' state enter_module)) + lift (phase.result' state enter_module)) _ (\ Console<!> write ..welcome_message)] (in state))) @@ -128,7 +128,7 @@ (All [anchor expression directive] (-> Configuration Code <Interpretation>)) (function (_ state) - (case (<| (phase.run' state) + (case (<| (phase.result' state) (:sharing [anchor expression directive] {(State+ anchor expression directive) state} @@ -139,7 +139,7 @@ (#try.Failure error) (if (ex.match? total.not_a_directive error) - (<| (phase.run' state) + (<| (phase.result' state) (:sharing [anchor expression directive] {(State+ anchor expression directive) state} @@ -179,7 +179,7 @@ context} {(State+ anchor expression directive) (get@ #state context)})] - (<| (phase.run' state) + (<| (phase.result' state) ... TODO: Simplify ASAP (:sharing [anchor expression directive] {<Context> @@ -191,7 +191,7 @@ (set@ #source source')) representation])))) -(def: .public (run Monad<!> Console<!> platform configuration generation_bundle) +(def: .public (run! Monad<!> Console<!> platform configuration generation_bundle) (All [! anchor expression directive] (-> (Monad !) (Console !) (Platform ! anchor expression directive) diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index ba0384442..7a93c29dd 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -8,12 +8,12 @@ [monad (#+ Monad do)]] [control ["." function] + ["." maybe] ["." exception (#+ exception:)] ["<>" parser ["<.>" code (#+ Parser)]]] [data ["." product] - ["." maybe] ["." text ("#\." monoid equivalence)] ["." name ("#\." equivalence codec)] [collection @@ -96,7 +96,7 @@ (|> (<flat> type) (list\map format) list.reversed - (list.interpose " ") + (list.interposed " ") (list\fold text\compose "")) <close>)]) ([#.Sum "(Or " ")" flat_variant] @@ -108,7 +108,7 @@ (|> ins (list\map format) list.reversed - (list.interpose " ") + (list.interposed " ") (list\fold text\compose "")) " " (format out) ")")) @@ -123,7 +123,7 @@ (#.Apply param fun) (let [[type_func type_args] (flat_application type)] - ($_ text\compose "(" (format type_func) " " (|> type_args (list\map format) list.reversed (list.interpose " ") (list\fold text\compose "")) ")")) + ($_ text\compose "(" (format type_func) " " (|> type_args (list\map format) list.reversed (list.interposed " ") (list\fold text\compose "")) ")")) (^template [<tag> <desc>] [(<tag> env body) @@ -160,7 +160,7 @@ [#.ExQ]) (#.Parameter idx) - (maybe.else (error! ($_ text\compose + (maybe.else (panic! ($_ text\compose "Unknown type parameter" text.new_line " Index: " (n\encode idx) text.new_line "Environment: " (|> env @@ -381,7 +381,7 @@ (n.> 0))) (syntax: (new_secret_marker) - (macro.with_gensyms [g!_secret_marker_] + (macro.with_identifiers [g!_secret_marker_] (in (list g!_secret_marker_)))) (def: secret_marker @@ -409,7 +409,7 @@ (in (list (code.identifier valueN)))) (#.Right valueC) - (macro.with_gensyms [g!value] + (macro.with_identifiers [g!value] (in (list (` (.let [(~ g!value) (~ valueC)] (..:log! (~ valueC) (~ (code.identifier ..secret_marker)) (~ g!value))))))))) @@ -443,7 +443,7 @@ (syntax: .public (:sharing {type_vars ..type_parameters} {exemplar ..typed} {computation ..typed}) - (macro.with_gensyms [g!_] + (macro.with_identifiers [g!_] (let [shareC (` (: (All [(~+ (list\map code.local_identifier type_vars))] (-> (~ (get@ #type exemplar)) (~ (get@ #type computation)))) diff --git a/stdlib/source/library/lux/type/abstract.lux b/stdlib/source/library/lux/type/abstract.lux index 79c5ecb41..84a2b2942 100644 --- a/stdlib/source/library/lux/type/abstract.lux +++ b/stdlib/source/library/lux/type/abstract.lux @@ -35,7 +35,7 @@ list.tail) (type: .public Frame - {#.doc (doc "Meta-data about an abstract/nominal type in a stack of them.")} + {#.doc (example "Meta-data about an abstract/nominal type in a stack of them.")} {#name Text #type_vars (List Code) #abstraction Code @@ -93,12 +93,12 @@ (exception.except ..no_active_frames []))))) (def: .public current - {#.doc (doc "The currently-being-defined abstract/nominal type.")} + {#.doc (example "The currently-being-defined abstract/nominal type.")} (Meta Frame) (..peek! #.None)) (def: .public (specific name) - {#.doc (doc "A specific abstract/nominal type still being defined somewhere in the scope.")} + {#.doc (example "A specific abstract/nominal type still being defined somewhere in the scope.")} (-> Text (Meta Frame)) (..peek! (#.Some name))) @@ -179,10 +179,10 @@ (template [<name> <from> <to>] [(syntax: .public (<name> {[frame value] ..cast}) - {#.doc (doc "Type-casting macro for abstract/nominal types." - (: <to> - (<name> (: <from> - value))))} + {#.doc (example "Type-casting macro for abstract/nominal types." + (: <to> + (<name> (: <from> + value))))} (do meta.monad [[name type_vars abstraction representation] (peek! frame)] (in (list (` ((~! :cast) [(~+ type_vars)] (~ <from>) (~ <to>) @@ -229,84 +229,84 @@ (syntax: .public (abstract: {[export_policy [name type_vars] annotations representation_type primitives] ..abstract}) - {#.doc (doc "Define abstract/nominal types which hide their representation details." - "You can convert between the abstraction and its representation selectively to access the value, while hiding it from others." - (abstract: String - {#.doc "An opaque text."} + {#.doc (example "Define abstract/nominal types which hide their representation details." + "You can convert between the abstraction and its representation selectively to access the value, while hiding it from others." + (abstract: String + {#.doc "An opaque text."} - Text + Text - (def: (string value) - (-> Text String) - (:abstraction value)) + (def: (string value) + (-> Text String) + (:abstraction value)) - (def: (text value) - (-> String Text) - (:representation value))) + (def: (text value) + (-> String Text) + (:representation value))) - "Type-parameters are optional." - (abstract: (Duplicate a) - {} + "Type-parameters are optional." + (abstract: (Duplicate a) + {} - [a a] + [a a] - (def: (duplicate value) - (All [a] (-> a (Duplicate a))) - (:abstraction [value value]))) + (def: (duplicate value) + (All [a] (-> a (Duplicate a))) + (:abstraction [value value]))) - "Definitions can be nested." - (abstract: (Single a) - {} + "Definitions can be nested." + (abstract: (Single a) + {} - a + a - (def: (single value) - (All [a] (-> a (Single a))) - (:abstraction value)) + (def: (single value) + (All [a] (-> a (Single a))) + (:abstraction value)) - (abstract: (Double a) - {} + (abstract: (Double a) + {} - [a a] + [a a] - (def: (double value) - (All [a] (-> a (Double a))) - (:abstraction [value value])) + (def: (double value) + (All [a] (-> a (Double a))) + (:abstraction [value value])) - (def: (single' value) - (All [a] (-> a (Single a))) - (:abstraction Single [value value])) + (def: (single' value) + (All [a] (-> a (Single a))) + (:abstraction Single [value value])) - (let [value 0123] - (is? value - (|> value - single' - (:representation Single) - double - :representation))))) + (let [value 0123] + (is? value + (|> value + single' + (:representation Single) + double + :representation))))) - "Type-parameters do not necessarily have to be used in the representation type." - "If they are not used, they become phantom types and can be used to customize types without changing the representation." - (abstract: (JavaScript a) - {} + "Type-parameters do not necessarily have to be used in the representation type." + "If they are not used, they become phantom types and can be used to customize types without changing the representation." + (abstract: (JavaScript a) + {} - Text + Text - (abstract: Expression {} Any) - (abstract: Statement {} Any) + (abstract: Expression {} Any) + (abstract: Statement {} Any) - (def: (+ x y) - (-> (JavaScript Expression) (JavaScript Expression) (JavaScript Expression)) - (:abstraction - (format "(" (:representation x) "+" (:representation y) ")"))) + (def: (+ x y) + (-> (JavaScript Expression) (JavaScript Expression) (JavaScript Expression)) + (:abstraction + (format "(" (:representation x) "+" (:representation y) ")"))) - (def: (while test body) - (-> (JavaScript Expression) (JavaScript Statement) (JavaScript Statement)) - (:abstraction - (format "while(" (:representation test) ") {" - (:representation body) - "}")))) - )} + (def: (while test body) + (-> (JavaScript Expression) (JavaScript Statement) (JavaScript Statement)) + (:abstraction + (format "while(" (:representation test) ") {" + (:representation body) + "}")))) + )} (do meta.monad [current_module meta.current_module_name .let [type_varsC (list\map code.local_identifier type_vars) @@ -337,22 +337,22 @@ parser)) (syntax: .public (:transmutation {selection (..selection <code>.any)}) - {#.doc (doc "Transmutes an abstract/nominal type's phantom types." - (abstract: (JavaScript a) - {} + {#.doc (example "Transmutes an abstract/nominal type's phantom types." + (abstract: (JavaScript a) + {} - Text + Text - (abstract: Expression {} Any) - (abstract: Statement {} Any) + (abstract: Expression {} Any) + (abstract: Statement {} Any) - (def: (statement expression) - (-> (JavaScript Expression) (JavaScript Statement)) - (:transmutation expression)) + (def: (statement expression) + (-> (JavaScript Expression) (JavaScript Statement)) + (:transmutation expression)) - (def: (statement' expression) - (-> (JavaScript Expression) (JavaScript Statement)) - (:transmutation JavaScript expression))))} + (def: (statement' expression) + (-> (JavaScript Expression) (JavaScript Statement)) + (:transmutation JavaScript expression))))} (case selection (#Specific specific value) (in (list (` (.|> (~ value) @@ -365,11 +365,11 @@ (syntax: .public (^:representation {selection (<code>.form (..selection <code>.local_identifier))} body {branches (<>.some <code>.any)}) - {#.doc (doc "Pattern-matching macro to easily extract a representation." - (def: (computation abstraction) - (All [a] (-> (Abstract a) ???)) - (let [(^:representation value) abstraction] - (foo (bar (baz value))))))} + {#.doc (example "Pattern-matching macro to easily extract a representation." + (def: (computation abstraction) + (All [a] (-> (Abstract a) ???)) + (let [(^:representation value) abstraction] + (foo (bar (baz value))))))} (case selection (#Specific specific name) (let [g!var (code.local_identifier name)] diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index 1c04d9482..10fe700e8 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -8,10 +8,10 @@ [apply (#+ Apply)] ["." monad (#+ Monad do)]] [control + ["." maybe] ["." try (#+ Try)] ["." exception (#+ Exception exception:)]] [data - ["." maybe] ["." product] ["." text ("#\." monoid equivalence)] [collection @@ -53,14 +53,14 @@ ["Actual" (//.format actual)])) (type: .public Var - {#.doc (doc "The ID for a type-variable in a type-checking context.")} + {#.doc (example "The ID for a type-variable in a type-checking context.")} Nat) (type: Assumption [Type Type]) (type: .public (Check a) - {#.doc (doc "A type-checking computation which may fail or yield a value.")} + {#.doc (example "A type-checking computation which may fail or yield a value.")} (-> Type_Context (Try [Type_Context a]))) (type: (Checker a) @@ -159,7 +159,7 @@ (#.Item [var_id var_type] (var::put id value plist'))))) -(def: .public (run context proc) +(def: .public (result context proc) (All [a] (-> Type_Context (Check a) (Try a))) (case (proc context) (#try.Success [context' output]) @@ -236,8 +236,8 @@ (exception.except ..unknown_type_var id)))) (def: .public (bind type id) - {#.doc (doc "Attemmpts to buy a type-variable." - "Fails if the variable has been bound already.")} + {#.doc (example "Attemmpts to buy a type-variable." + "Fails if the variable has been bound already.")} (-> Type Var (Check Any)) (function (_ context) (case (|> context (get@ #.var_bindings) (var::get id)) @@ -263,7 +263,7 @@ (exception.except ..unknown_type_var id)))) (def: .public var - {#.doc (doc "A brand-new (unbound) type-variable.")} + {#.doc (example "A brand-new (unbound) type-variable.")} (Check [Var Type]) (function (_ context) (let [id (get@ #.var_counter context)] @@ -329,7 +329,7 @@ (exception.except ..unknown_type_var current))))) (def: .public fresh_context - {#.doc (doc "An empty/un-used type-checking context.")} + {#.doc (example "An empty/un-used type-checking context.")} Type_Context {#.var_counter 0 #.ex_counter 0 @@ -675,10 +675,10 @@ (-> Type Type (Check Any)) (check' (list) expected actual)) -(def: .public (checks? expected actual) +(def: .public (subsumes? expected actual) {#.doc "A simple type-checking function that just returns a yes/no answer."} (-> Type Type Bit) - (case (..run ..fresh_context (..check' (list) expected actual)) + (case (..result ..fresh_context (..check' (list) expected actual)) (#try.Failure _) false @@ -686,13 +686,13 @@ true)) (def: .public context - {#.doc (doc "The current state of the type-checking context.")} + {#.doc (example "The current state of the type-checking context.")} (Check Type_Context) (function (_ context) (#try.Success [context context]))) (def: .public (clean inputT) - {#.doc (doc "Resolves every bound type-variable to yield a new type that is as resolved as possible.")} + {#.doc (example "Resolves every bound type-variable to yield a new type that is as resolved as possible.")} (-> Type (Check Type)) (case inputT (#.Primitive name paramsT+) diff --git a/stdlib/source/library/lux/type/dynamic.lux b/stdlib/source/library/lux/type/dynamic.lux index 8b4780d1f..db594d293 100644 --- a/stdlib/source/library/lux/type/dynamic.lux +++ b/stdlib/source/library/lux/type/dynamic.lux @@ -8,7 +8,7 @@ [data [text ["%" format]]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) ["." syntax (#+ syntax:)]] ["." type abstract]]]) @@ -27,16 +27,16 @@ (def: representation (-> Dynamic [Type Any]) (|>> :representation)) (syntax: .public (:dynamic value) - {#.doc (doc (: Dynamic - (:dynamic 123)))} - (with_gensyms [g!value] + {#.doc (example (: Dynamic + (:dynamic 123)))} + (with_identifiers [g!value] (in (list (` (let [(~ g!value) (~ value)] ((~! ..abstraction) [(:of (~ g!value)) (~ g!value)]))))))) (syntax: .public (:static type value) - {#.doc (doc (: (try.Try Nat) - (:static Nat (:dynamic 123))))} - (with_gensyms [g!type g!value] + {#.doc (example (: (try.Try Nat) + (:static Nat (:dynamic 123))))} + (with_identifiers [g!type g!value] (in (list (` (let [[(~ g!type) (~ g!value)] ((~! ..representation) (~ value))] (: ((~! try.Try) (~ type)) (if (\ (~! type.equivalence) (~' =) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index 74853320d..d9e962ba2 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -5,12 +5,12 @@ ["." monad (#+ do)] ["." equivalence]] [control + ["." maybe] ["." try] ["<>" parser ["<.>" code (#+ Parser)]]] [data ["." product] - ["." maybe] ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection @@ -212,14 +212,14 @@ [compiler meta.get_compiler] (case (|> alts (list\map (function (_ [alt_name alt_type]) - (case (check.run context - (do {! check.monad} - [[tvars alt_type] (concrete_type alt_type) - .let [[deps alt_type] (type.flat_function alt_type)] - _ (check.check dep alt_type) - context' check.context - =deps (monad.map ! (provision compiler context') deps)] - (in =deps))) + (case (check.result context + (do {! check.monad} + [[tvars alt_type] (concrete_type alt_type) + .let [[deps alt_type] (type.flat_function alt_type)] + _ (check.check dep alt_type) + context' check.context + =deps (monad.map ! (provision compiler context') deps)] + (in =deps))) (#.Left error) (list) @@ -234,11 +234,11 @@ (def: (provision compiler context dep) (-> Lux Type_Context Type (Check Instance)) - (case (meta.run compiler - ($_ meta.either - (do meta.monad [alts ..local_env] (..candidate_provision provision context dep alts)) - (do meta.monad [alts ..local_structs] (..candidate_provision provision context dep alts)) - (do meta.monad [alts ..imported_structs] (..candidate_provision provision context dep alts)))) + (case (meta.result compiler + ($_ meta.either + (do meta.monad [alts ..local_env] (..candidate_provision provision context dep alts)) + (do meta.monad [alts ..local_structs] (..candidate_provision provision context dep alts)) + (do meta.monad [alts ..imported_structs] (..candidate_provision provision context dep alts)))) (#.Left error) (check.failure error) @@ -261,7 +261,7 @@ context meta.type_context] (case (|> alts (list\map (function (_ [alt_name alt_type]) - (case (<| (check.run context) + (case (<| (check.result context) (do {! check.monad} [[tvars alt_type] (concrete_type alt_type) .let [[deps alt_type] (type.flat_function alt_type)] @@ -317,29 +317,29 @@ {member <code>.identifier} {args (<>.or (<>.and (<>.some <code>.identifier) <code>.end!) (<>.and (<>.some <code>.any) <code>.end!))}) - {#.doc (doc "Automatic implementation selection (for type-class style polymorphism)." - "This feature layers type-class style polymorphism on top of Lux's signatures and implementations." - "When calling a polymorphic function, or using a polymorphic constant," - "this macro will check the types of the arguments, and the expected type for the whole expression" - "and it will search in the local scope, the module's scope and the imports' scope" - "in order to find suitable implementations to satisfy those requirements." - "If a single alternative is found, that one will be used automatically." - "If no alternative is found, or if more than one alternative is found (ambiguity)" - "a compile-time error will be raised, to alert the user." - "Examples:" - "Nat equivalence" - (\ number.equivalence = x y) - (\\ = x y) - "Can optionally add the prefix of the module where the signature was defined." - (\\ equivalence.= x y) - "(List Nat) equivalence" - (\\ = - (list.indices 10) - (list.indices 10)) - "(Functor List) map" - (\\ map inc (list.indices 10)) - "Caveat emptor: You need to make sure to import the module of any implementation you want to use." - "Otherwise, this macro will not find it.")} + {#.doc (example "Automatic implementation selection (for type-class style polymorphism)." + "This feature layers type-class style polymorphism on top of Lux's signatures and implementations." + "When calling a polymorphic function, or using a polymorphic constant," + "this macro will check the types of the arguments, and the expected type for the whole expression" + "and it will search in the local scope, the module's scope and the imports' scope" + "in order to find suitable implementations to satisfy those requirements." + "If a single alternative is found, that one will be used automatically." + "If no alternative is found, or if more than one alternative is found (ambiguity)" + "a compile-time error will be raised, to alert the user." + "Examples:" + "Nat equivalence" + (\ number.equivalence = x y) + (\\ = x y) + "Can optionally add the prefix of the module where the signature was defined." + (\\ equivalence.= x y) + "(List Nat) equivalence" + (\\ = + (list.indices 10) + (list.indices 10)) + "(Functor List) map" + (\\ map inc (list.indices 10)) + "Caveat emptor: You need to make sure to import the module of any implementation you want to use." + "Otherwise, this macro will not find it.")} (case args (#.Left [args _]) (do {! meta.monad} @@ -365,14 +365,14 @@ (#.Right [args _]) (do {! meta.monad} - [labels (|> (macro.gensym "") (list.repeated (list.size args)) (monad.seq !))] + [labels (|> (macro.identifier "") (list.repeated (list.size args)) (monad.seq !))] (in (list (` (let [(~+ (|> args (list.zipped/2 labels) (list\map ..pair_list) list\join))] (..\\ (~ (code.identifier member)) (~+ labels))))))) )) (def: (implicit_bindings amount) (-> Nat (Meta (List Code))) - (|> (macro.gensym "g!implicit") + (|> (macro.identifier "g!implicit") (list.repeated amount) (monad.seq meta.monad))) @@ -381,10 +381,10 @@ (<code>.tuple (<>.many <code>.any))) (syntax: .public (with {implementations ..implicits} body) - {#.doc (doc "Establish lexical bindings for implementations that will be prioritized over non-lexically-bound implementations." - (with [n.addition] - (n.= (\ n.addition compose left right) - (\\ compose left right))))} + {#.doc (example "Establish lexical bindings for implementations that will be prioritized over non-lexically-bound implementations." + (with [n.addition] + (n.= (\ n.addition compose left right) + (\\ compose left right))))} (do meta.monad [g!implicit+ (implicit_bindings (list.size implementations))] (in (list (` (let [(~+ (|> (list.zipped/2 g!implicit+ implementations) @@ -394,11 +394,11 @@ (~ body))))))) (syntax: .public (implicit: {implementations ..implicits}) - {#.doc (doc "Establish local definitions for implementations that will be prioritized over foreign definitions." - (implicit: [n.multiplication]) - - (n.= (\ n.multiplication compose left right) - (\\ compose left right)))} + {#.doc (example "Establish local definitions for implementations that will be prioritized over foreign definitions." + (implicit: [n.multiplication]) + + (n.= (\ n.multiplication compose left right) + (\\ compose left right)))} (do meta.monad [g!implicit+ (implicit_bindings (list.size implementations))] (in (|> (list.zipped/2 g!implicit+ implementations) diff --git a/stdlib/source/library/lux/type/quotient.lux b/stdlib/source/library/lux/type/quotient.lux index f68a1c099..a2ac468af 100644 --- a/stdlib/source/library/lux/type/quotient.lux +++ b/stdlib/source/library/lux/type/quotient.lux @@ -3,13 +3,13 @@ [lux (#- type) [abstract [equivalence (#+ Equivalence)]] - [macro (#+ with_gensyms) + [macro (#+ with_identifiers) [syntax (#+ syntax:)]] ["." type abstract]]]) (abstract: .public (Class t c %) - {#.doc (doc "The class knows how to classify/label values that are meant to be equivalent to one another.")} + {#.doc (example "The class knows how to classify/label values that are meant to be equivalent to one another.")} (-> t c) @@ -20,9 +20,9 @@ (|>> :abstraction)) (abstract: .public (Quotient t c %) - {#.doc (doc "A quotient value has been labeled with a class." - "All equivalent values will belong to the same class." - "This means all equivalent values possess the same label.")} + {#.doc (example "A quotient value has been labeled with a class." + "All equivalent values will belong to the same class." + "This means all equivalent values possess the same label.")} {#value t #label c} @@ -46,17 +46,17 @@ ) (syntax: .public (type class) - {#.doc (doc "The Quotient type associated with a Class type." - (def: even - (class even?)) + {#.doc (example "The Quotient type associated with a Class type." + (def: even + (class even?)) - (def: Even - Type - (type even)) + (def: Even + Type + (type even)) - (: Even - (quotient even 123)))} - (with_gensyms [g!t g!c g!%] + (: Even + (quotient even 123)))} + (with_identifiers [g!t g!c g!%] (in (list (` ((~! type.:by_example) [(~ g!t) (~ g!c) (~ g!%)] diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux index 0ea7bf75c..78e289e4a 100644 --- a/stdlib/source/library/lux/type/refinement.lux +++ b/stdlib/source/library/lux/type/refinement.lux @@ -15,7 +15,7 @@ #predicate (Predicate t)} (type: .public (Refiner t %) - {#.doc (doc "A selection mechanism for refined instances of a type.")} + {#.doc (example "A selection mechanism for refined instances of a type.")} (-> t (Maybe (Refined t %)))) (def: .public (refiner predicate) @@ -38,8 +38,8 @@ ) (def: .public (lift transform) - {#.doc (doc "Yields a function that can work on refined values." - "Respects the constraints of the refinement.")} + {#.doc (example "Yields a function that can work on refined values." + "Respects the constraints of the refinement.")} (All [t %] (-> (-> t t) (-> (Refined t %) (Maybe (Refined t %))))) @@ -68,7 +68,7 @@ (only refiner tail)))) (def: .public (partition refiner values) - {#.doc (doc "Separates refined values from the un-refined ones.")} + {#.doc (example "Separates refined values from the un-refined ones.")} (All [t %] (-> (Refiner t %) (List t) [(List (Refined t %)) (List t)])) (case values @@ -87,17 +87,17 @@ (#.Item head no)])))) (syntax: .public (type refiner) - {#.doc (doc "The Refined type associated with a Refiner type." - (def: even - (refiner even?)) + {#.doc (example "The Refined type associated with a Refiner type." + (def: even + (refiner even?)) - (def: Even - Type - (type even)) + (def: Even + Type + (type even)) - (: (Maybe Even) - (even 123)))} - (macro.with_gensyms [g!t g!%] + (: (Maybe Even) + (even 123)))} + (macro.with_identifiers [g!t g!%] (in (list (` ((~! type.:by_example) [(~ g!t) (~ g!%)] (..Refiner (~ g!t) (~ g!%)) (~ refiner) diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux index 8d389b11e..9ecd67608 100644 --- a/stdlib/source/library/lux/type/resource.lux +++ b/stdlib/source/library/lux/type/resource.lux @@ -6,11 +6,11 @@ ["." monad (#+ Monad do) [indexed (#+ IxMonad)]]] [control + ["." maybe] ["." exception (#+ exception:)] ["<>" parser ["<.>" code (#+ Parser)]]] [data - ["." maybe] [text ["%" format (#+ format)]] [collection @@ -26,25 +26,25 @@ abstract]]]) (type: .public (Procedure monad input output value) - {#.doc (doc "A computation that takes a sequence of resource access rights as inputs and yields a different sequence as outputs." - "A procedure yields a result value." - "A procedure can make use of monadic effects.")} + {#.doc (example "A computation that takes a sequence of resource access rights as inputs and yields a different sequence as outputs." + "A procedure yields a result value." + "A procedure can make use of monadic effects.")} (-> input (monad [output value]))) (type: .public (Linear monad value) - {#.doc (doc "A procedure that is constant with regards to resource access rights." - "This means no additional resources will be available after the computation is over." - "This also means no previously available resources will have been consumed.")} + {#.doc (example "A procedure that is constant with regards to resource access rights." + "This means no additional resources will be available after the computation is over." + "This also means no previously available resources will have been consumed.")} (All [keys] (Procedure monad keys keys value))) (type: .public (Affine monad permissions value) - {#.doc (doc "A procedure which expands the number of available resources.")} + {#.doc (example "A procedure which expands the number of available resources.")} (All [keys] (Procedure monad keys [permissions keys] value))) (type: .public (Relevant monad permissions value) - {#.doc (doc "A procedure which reduces the number of available resources.")} + {#.doc (example "A procedure which reduces the number of available resources.")} (All [keys] (Procedure monad [permissions keys] keys value))) @@ -61,7 +61,7 @@ [[keysT value] (input keysI)] ((f value) keysT))))) -(def: .public (run monad procedure) +(def: .public (run! monad procedure) (All [! v] (-> (Monad !) (Linear ! v) (! v))) (do monad [[_ output] (procedure [])] @@ -75,16 +75,16 @@ (in [keys output])))) (abstract: .public Ordered - {#.doc (doc "The mode of keys which CANNOT be swapped, and for whom order of release/consumption matters.")} + {#.doc (example "The mode of keys which CANNOT be swapped, and for whom order of release/consumption matters.")} Any) (abstract: .public Commutative - {#.doc (doc "The mode of keys which CAN be swapped, and for whom order of release/consumption DOES NOT matters.")} + {#.doc (example "The mode of keys which CAN be swapped, and for whom order of release/consumption DOES NOT matters.")} Any) (abstract: .public (Key mode key) - {#.doc (doc "The access right for a resource." - "Without the key for a resource existing somewhere among the available ambient rights, one cannot use a resource.")} + {#.doc (example "The access right for a resource." + "Without the key for a resource existing somewhere among the available ambient rights, one cannot use a resource.")} Any @@ -98,14 +98,14 @@ )) (abstract: .public (Res key value) - {#.doc (doc "A resource locked by a key." - "The 'key' represents the right to access/consume a resource.")} + {#.doc (example "A resource locked by a key." + "The 'key' represents the right to access/consume a resource.")} value (template [<name> <mode> <key>] [(def: .public (<name> monad value) - {#.doc (doc "Makes a value into a resource and adds the key/access-right to it to the ambient keyring for future use.")} + {#.doc (example "Makes a value into a resource and adds the key/access-right to it to the ambient keyring for future use.")} (All [! v] (Ex [k] (-> (Monad !) v (Affine ! (Key <mode> k) (Res k v))))) (function (_ keys) (\ monad in [[(<key> []) keys] (:abstraction value)])))] @@ -115,7 +115,7 @@ ) (def: .public (read monad resource) - {#.doc (doc "Access the value of a resource, so long as its key is available.")} + {#.doc (example "Access the value of a resource, so long as its key is available.")} (All [! v k m] (-> (Monad !) (Res k v) (Relevant ! (Key m k) v))) (function (_ [key keys]) @@ -148,17 +148,17 @@ (\ monad in [context []]))) (syntax: .public (exchange {swaps ..indices}) - {#.doc (doc "A function that can exchange the keys for resource, so long as they are commutative." - "This keys will be placed at the front of the keyring in the order they are specified." - "The specific keys must be specified based of their index into the current keyring." - (do (..monad !) - [res|left (/.commutative ! pre) - res|right (/.commutative ! post) - _ ((/.exchange [1 0]) !) - left (/.read ! res|left) - right (/.read ! res|right)] - (in (format left right))))} - (macro.with_gensyms [g!_ g!context g!!] + {#.doc (example "A function that can exchange the keys for resource, so long as they are commutative." + "This keys will be placed at the front of the keyring in the order they are specified." + "The specific keys must be specified based of their index into the current keyring." + (do (..monad !) + [res|left (/.commutative ! pre) + res|right (/.commutative ! post) + _ ((/.exchange [1 0]) !) + left (/.read ! res|left) + right (/.read ! res|right)] + (in (format left right))))} + (macro.with_identifiers [g!_ g!context g!!] (case swaps #.End (in (list (` (~! no_op)))) @@ -166,7 +166,7 @@ (#.Item head tail) (do {! meta.monad} [.let [max_idx (list\fold n.max head tail)] - g!inputs (<| (monad.seq !) (list.repeated (inc max_idx)) (macro.gensym "input")) + g!inputs (<| (monad.seq !) (list.repeated (inc max_idx)) (macro.identifier "input")) .let [g!outputs (|> (monad.fold maybe.monad (function (_ from to) (do maybe.monad @@ -197,18 +197,18 @@ (template [<name> <from> <to>] [(syntax: .public (<name> {amount ..amount}) - {#.doc (doc "Group/un-group keys in the keyring into/out-of tuples." - (do (..monad !) - [res|left (/.commutative ! pre) - res|right (/.commutative ! post) - _ ((/.group 2) !) - _ ((/.un_group 2) !) - right (/.read ! res|right) - left (/.read ! res|left)] - (in (format left right))))} - (macro.with_gensyms [g!_ g!context g!!] + {#.doc (example "Group/un-group keys in the keyring into/out-of tuples." + (do (..monad !) + [res|left (/.commutative ! pre) + res|right (/.commutative ! post) + _ ((/.group 2) !) + _ ((/.un_group 2) !) + right (/.read ! res|right) + left (/.read ! res|left)] + (in (format left right))))} + (macro.with_identifiers [g!_ g!context g!!] (do {! meta.monad} - [g!keys (|> (macro.gensym "keys") + [g!keys (|> (macro.identifier "keys") (list.repeated amount) (monad.seq !))] (in (list (` (: (All [(~ g!!) (~+ g!keys) (~ g!context)] diff --git a/stdlib/source/library/lux/type/unit.lux b/stdlib/source/library/lux/type/unit.lux index 35d0c66c8..511bbbb33 100644 --- a/stdlib/source/library/lux/type/unit.lux +++ b/stdlib/source/library/lux/type/unit.lux @@ -28,7 +28,7 @@ abstract]]]) (abstract: .public (Qty unit) - {#.doc (doc "A quantity with an associated unit of measurement.")} + {#.doc (example "A quantity with an associated unit of measurement.")} Int @@ -62,14 +62,14 @@ ) (interface: .public (Unit a) - {#.doc (doc "A unit of measurement, to qualify numbers with.")} + {#.doc (example "A unit of measurement, to qualify numbers with.")} (: (-> Int (Qty a)) in) (: (-> (Qty a) Int) out)) (interface: .public (Scale s) - {#.doc (doc "A scale of magnitude.")} + {#.doc (example "A scale of magnitude.")} (: (All [u] (-> (Qty u) (Qty (s u)))) scale) (: (All [u] (-> (Qty (s u)) (Qty u))) @@ -78,7 +78,7 @@ ratio)) (type: .public Pure - {#.doc (doc "A pure, unit-less quantity.")} + {#.doc (example "A pure, unit-less quantity.")} (Qty Any)) (def: .public pure @@ -95,10 +95,10 @@ <code>.local_identifier <code>.local_identifier (<>.else |annotations|.empty |annotations|.parser)))}) - {#.doc (doc "Define a unit of measurement." - "Both the name of the type, and the name of the Unit implementation must be specified." - (unit: .public Feet feet - {#.doc (doc "Optional annotations.")}))} + {#.doc (example "Define a unit of measurement." + "Both the name of the type, and the name of the Unit implementation must be specified." + (unit: .public Feet feet + {#.doc (example "Optional annotations.")}))} (do meta.monad [@ meta.current_module_name .let [g!type (code.local_identifier type_name)]] @@ -131,10 +131,10 @@ <code>.local_identifier ..scale (<>.else |annotations|.empty |annotations|.parser)))}) - {#.doc (doc "Define a scale of magnitude." - (scale: .public Bajillion bajillion - [1 1,234,567,890] - {#.doc (doc "Optional annotations.")}))} + {#.doc (example "Define a scale of magnitude." + (scale: .public Bajillion bajillion + [1 1,234,567,890] + {#.doc (example "Optional annotations.")}))} (do meta.monad [.let [(^slots [#ratio.numerator #ratio.denominator]) ratio] @ meta.current_module_name @@ -177,7 +177,7 @@ [(`` (scale: .public <type> (~~ (implementation_name <type>)) [<from> <to>] - {#.doc (doc (~~ (template.text ["'" <type> "' scale from " <from> " to " <to> "."])))}))] + {#.doc (example (~~ (template.text ["'" <type> "' scale from " <from> " to " <to> "."])))}))] [Kilo 1 1,000] [Mega 1 1,000,000] @@ -191,7 +191,7 @@ (template [<type>] [(`` (unit: .public <type> (~~ (implementation_name <type>)) - {#.doc (doc (~~ (template.text ["'" <type> "' unit of meaurement."])))}))] + {#.doc (example (~~ (template.text ["'" <type> "' unit of meaurement."])))}))] [Gram] [Meter] diff --git a/stdlib/source/library/lux/type/variance.lux b/stdlib/source/library/lux/type/variance.lux index 8755777b9..8502ec6fa 100644 --- a/stdlib/source/library/lux/type/variance.lux +++ b/stdlib/source/library/lux/type/variance.lux @@ -3,13 +3,13 @@ [lux #*]]) (type: .public (Co t) - {#.doc (doc "A constraint for covariant types.")} + {#.doc (example "A constraint for covariant types.")} (-> Any t)) (type: .public (Contra t) - {#.doc (doc "A constraint for contravariant types.")} + {#.doc (example "A constraint for contravariant types.")} (-> t Any)) (type: .public (In t) - {#.doc (doc "A constraint for invariant types.")} + {#.doc (example "A constraint for invariant types.")} (-> t t)) diff --git a/stdlib/source/library/lux/world/console.lux b/stdlib/source/library/lux/world/console.lux index 83b83145d..80e8eaebb 100644 --- a/stdlib/source/library/lux/world/console.lux +++ b/stdlib/source/library/lux/world/console.lux @@ -17,6 +17,8 @@ ["%" format (#+ format)]]]]]) (interface: .public (Console !) + {#.doc (example "An interface to console/terminal I/O.")} + (: (-> [] (! (Try Char))) read) (: (-> [] (! (Try Text))) @@ -99,10 +101,14 @@ (as_is))) (def: .public (write_line message console) + {#.doc (example "Writes the message on the console and appends a new-line/line-feed at the end.")} (All [!] (-> Text (Console !) (! (Try Any)))) (\ console write (format message text.new_line))) (interface: .public (Mock s) + {#.doc (example "A mock/simulation of a console." + "Useful for testing.")} + (: (-> s (Try [s Char])) on_read) (: (-> s (Try [s Text])) diff --git a/stdlib/source/library/lux/world/db/jdbc.lux b/stdlib/source/library/lux/world/db/jdbc.lux index 5ee34d9f7..2906cebeb 100644 --- a/stdlib/source/library/lux/world/db/jdbc.lux +++ b/stdlib/source/library/lux/world/db/jdbc.lux @@ -172,5 +172,5 @@ (do (try.with async.monad) [db (async.future (..connect creds)) result (action (..async db)) - _ (async\in (io.run (!.use (\ db close) [])))] + _ (async\in (io.run! (!.use (\ db close) [])))] (in result))) diff --git a/stdlib/source/library/lux/world/db/sql.lux b/stdlib/source/library/lux/world/db/sql.lux index e7ebd8acf..eb368954b 100644 --- a/stdlib/source/library/lux/world/db/sql.lux +++ b/stdlib/source/library/lux/world/db/sql.lux @@ -97,8 +97,8 @@ (def: Any_Query (.type (Query Any Any Any Any Any Any))) (def: .public read - {#.doc (doc "Only use this function for debugging purposes." - "Do not use this function to actually execute SQL code.")} + {#.doc (example "Only use this function for debugging purposes." + "Do not use this function to actually execute SQL code.")} (-> (SQL Any) Text) (|>> :representation)) diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 8e2adf93b..19dde66f4 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -7,6 +7,7 @@ ["." monad (#+ Monad do)]] [control [pipe (#+ case>)] + ["." maybe ("#\." functor)] ["." try (#+ Try) ("#\." functor)] ["." exception (#+ exception:)] ["." io (#+ IO) ("#\." functor)] @@ -17,7 +18,6 @@ [data ["." bit ("#\." equivalence)] ["." product] - ["." maybe ("#\." functor)] ["." binary (#+ Binary)] ["." text ("#\." equivalence) ["%" format (#+ format)]] @@ -36,9 +36,12 @@ ["." duration]]]]) (type: .public Path + {#.doc (example "A path to a file or a directory in a file-system.")} Text) (`` (interface: .public (System !) + {#.doc (example "An interface to a file-system.")} + (: Text separator) @@ -90,12 +93,14 @@ (in [parent child]))))) (def: .public (parent fs path) + {#.doc (example "If a path represents a nested file/directory, extracts its parent directory.")} (All [!] (-> (System !) Path (Maybe Path))) (|> path (..un_rooted fs) (maybe\map product.left))) (def: .public (name fs path) + {#.doc (example "The un-nested name of a file/directory.")} (All [!] (-> (System !) Path Text)) (|> path (..un_rooted fs) @@ -137,6 +142,7 @@ ))) (def: .public (rooted fs parent child) + {#.doc (example "A nested path for a file/directory, given a root/parent path and a file/directory name within it.")} (All [!] (-> (System !) Path Text Path)) (format parent (\ fs separator) child)) @@ -260,7 +266,7 @@ (do (try.with io.monad) [.let [file (java/io/File::new path)] size (java/io/File::length file) - .let [data (binary.create (.nat size))] + .let [data (binary.empty (.nat size))] stream (java/io/FileInputStream::new file) bytes_read (java/io/InputStream::read data stream) _ (java/lang/AutoCloseable::close stream)] @@ -349,7 +355,7 @@ (def: (any_callback write!) (-> (async.Resolver (Try Any)) ffi.Function) (<| (ffi.closure [error]) - io.run + io.run! write! (if (ffi.null? error) (#try.Success []) @@ -358,7 +364,7 @@ (def: (value_callback write!) (All [a] (-> (async.Resolver (Try a)) ffi.Function)) (<| (ffi.closure [error datum]) - io.run + io.run! write! (if (ffi.null? error) (#try.Success (:assume datum)) @@ -963,7 +969,7 @@ ... (def: (make_file path) ... (do {! (try.with io.monad)} - ... [verdict (..touch [path (|> instant.now io.run instant.relative duration.millis (i./ +1,000))])] + ... [verdict (..touch [path (|> instant.now io.run! instant.relative duration.millis (i./ +1,000))])] ... (\ io.monad in ... (if verdict ... (#try.Success (..file path)) @@ -985,6 +991,7 @@ (as_is))) (def: .public (exists? monad fs path) + {#.doc (example "Checks if either a file or a directory exists at the given path.")} (All [!] (-> (Monad !) (System !) Path (! Bit))) (do monad [verdict (\ fs file? path)] @@ -1170,6 +1177,8 @@ (recur sub_directory tail))))))) (def: .public (mock separator) + {#.doc (example "A purely in-memory simulation of a file-system." + "Useful for testing.")} (-> Text (System Async)) (let [store (stm.var ..empty_mock)] (`` (implementation @@ -1318,6 +1327,8 @@ (\ fs make_directory path)))) (def: .public (make_directories monad fs path) + {#.doc (example "Creates the directory specified by the given path." + "Also, creates every super-directory necessary to make the given path valid.")} (All [!] (-> (Monad !) (System !) Path (! (Try Any)))) (let [rooted? (text.starts_with? (\ fs separator) path) segments (text.split_all_with (\ fs separator) path)] @@ -1350,6 +1361,7 @@ (in (#try.Failure error))))))))) (def: .public (make_file monad fs content path) + {#.doc (example "Creates a new file with the given content if-and-only-if the file does not already exist.")} (All [!] (-> (Monad !) (System !) Binary Path (! (Try Any)))) (do monad [? (\ fs file? path)] diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index f9229b17c..e3d26e30c 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -8,6 +8,7 @@ ["." monad (#+ do)]] [control ["." io (#+ IO)] + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)] [concurrency @@ -15,7 +16,6 @@ ["." stm (#+ STM Var)]]] [data ["." product] - ["." maybe] ["." text ["%" format (#+ format)]] [collection @@ -33,7 +33,7 @@ ["." //]) (abstract: .public Concern - {} + {#.doc (example "A particular concern to watch-out for.")} {#create Bit #modify Bit @@ -83,6 +83,8 @@ ) (interface: .public (Watcher !) + {#.doc (example "Machinery for watching a file-system for changes to files and directories.")} + (: (-> Concern //.Path (! (Try Any))) start) (: (-> //.Path (! (Try Concern))) @@ -185,6 +187,8 @@ deletions]]))) (def: .public (polling fs) + {#.doc (example "A simple watcher that works for any file-system." + "Polls files and directories to detect changes.")} (-> (//.System Async) (Watcher Async)) (let [tracker (: (Var Directory_Tracker) (stm.var (dictionary.empty text.hash)))] @@ -257,6 +261,8 @@ ))) (def: .public (mock separator) + {#.doc (example "A fake/emulated watcher." + "Must be given a path separator for the file-system.")} (-> Text [(//.System Async) (Watcher Async)]) (let [fs (//.mock separator)] [fs @@ -408,6 +414,7 @@ )) (def: .public default + {#.doc (example "The default watcher for the default file-system.")} (IO (Try (Watcher Async))) (do (try.with io.monad) [watcher (java/nio/file/FileSystem::newWatchService diff --git a/stdlib/source/library/lux/world/input/keyboard.lux b/stdlib/source/library/lux/world/input/keyboard.lux index 38e93e56c..4b3127c18 100644 --- a/stdlib/source/library/lux/world/input/keyboard.lux +++ b/stdlib/source/library/lux/world/input/keyboard.lux @@ -3,6 +3,7 @@ [lux #*]]) (type: .public Key + {#.doc (example "A key from a keyboard, identify by a numeric ID.")} Nat) (template [<code> <name>] @@ -98,6 +99,7 @@ ) (type: .public Press + {#.doc (example "A key-press for a key.")} {#pressed? Bit #input Key}) diff --git a/stdlib/source/library/lux/world/net.lux b/stdlib/source/library/lux/world/net.lux index 76b85d499..d1acb1f01 100644 --- a/stdlib/source/library/lux/world/net.lux +++ b/stdlib/source/library/lux/world/net.lux @@ -2,11 +2,17 @@ [library [lux (#- Location)]]) -(type: .public Address Text) +(type: .public Address + {#.doc (example "A TCP/IP address.")} + Text) -(type: .public Port Nat) +(type: .public Port + {#.doc (example "A TCP/IP port.")} + Nat) -(type: .public URL Text) +(type: .public URL + {#.doc (example "A Uniform Resource Locator.")} + Text) (type: .public Location {#address Address diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux index 8055dce6e..6b2d9eb99 100644 --- a/stdlib/source/library/lux/world/net/http/client.lux +++ b/stdlib/source/library/lux/world/net/http/client.lux @@ -8,15 +8,21 @@ [control [pipe (#+ case>)] ["." io (#+ IO)] + ["." maybe ("#\." functor)] ["." try (#+ Try)] [concurrency - ["." async (#+ Async)]]] + ["." async (#+ Async)]] + [parser + ["<.>" code]]] [data ["." binary (#+ Binary)] - ["." maybe ("#\." functor)] ["." text] [collection ["." dictionary]]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]] [math [number ["n" nat] @@ -25,26 +31,38 @@ [// (#+ URL)]]) (interface: .public (Client !) + {#.doc (example "A HTTP client capable of issuing requests to a HTTP server.")} + (: (-> //.Method URL //.Headers (Maybe Binary) (! (Try (//.Response !)))) request)) -(template [<name> <method>] - [(def: .public (<name> url headers data client) - (All [!] - (-> URL //.Headers (Maybe Binary) (Client !) - (! (Try (//.Response !))))) - (\ client request <method> url headers data))] - - [post #//.Post] - [get #//.Get] - [put #//.Put] - [patch #//.Patch] - [delete #//.Delete] - [head #//.Head] - [connect #//.Connect] - [options #//.Options] - [trace #//.Trace] +(syntax: (method_name {[_ name] <code>.tag}) + (in (list (code.text (text.upper_cased name))))) + +(syntax: (method_function {[_ name] <code>.tag}) + (in (list (code.local_identifier (text.lower_cased name))))) + +(template [<method>] + [(with_expansions [<name> (method_function <method>) + <method_name> (method_name <method>) + <documentation> (template.text ["A " <method_name> " request."])] + (def: .public (<name> url headers data client) + {#.doc (example <documentation>)} + (All [!] + (-> URL //.Headers (Maybe Binary) (Client !) + (! (Try (//.Response !))))) + (\ client request <method> url headers data)))] + + [#//.Post] + [#//.Get] + [#//.Put] + [#//.Patch] + [#//.Delete] + [#//.Head] + [#//.Connect] + [#//.Options] + [#//.Trace] ) (def: default_buffer_size @@ -52,7 +70,7 @@ (def: empty_body [Nat Binary] - [0 (binary.create 0)]) + [0 (binary.empty 0)]) (def: (body_of data) (-> Binary [Nat Binary]) @@ -117,7 +135,7 @@ (in ..empty_body)) [partial? buffer_size] - (let [buffer (binary.create buffer_size)] + (let [buffer (binary.empty buffer_size)] (if partial? (loop [so_far +0] (do {! (try.with io.monad)} diff --git a/stdlib/source/library/lux/world/net/http/cookie.lux b/stdlib/source/library/lux/world/net/http/cookie.lux index 07437df10..a138f556c 100644 --- a/stdlib/source/library/lux/world/net/http/cookie.lux +++ b/stdlib/source/library/lux/world/net/http/cookie.lux @@ -86,4 +86,4 @@ (def: .public (get header) (-> Text (Try Context)) - (l.run header (..cookies context.empty))) + (l.result header (..cookies context.empty))) diff --git a/stdlib/source/library/lux/world/net/http/query.lux b/stdlib/source/library/lux/world/net/http/query.lux index 1beb1a06f..86ee79c2b 100644 --- a/stdlib/source/library/lux/world/net/http/query.lux +++ b/stdlib/source/library/lux/world/net/http/query.lux @@ -62,4 +62,4 @@ (def: .public (parameters raw) (-> Text (Try Context)) - (l.run raw (..form context.empty))) + (l.result raw (..form context.empty))) diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index 8ab9265cb..b934e01d5 100644 --- a/stdlib/source/library/lux/world/net/http/request.lux +++ b/stdlib/source/library/lux/world/net/http/request.lux @@ -4,6 +4,7 @@ [control pipe ["." monad (#+ do)] + ["." maybe] ["." try (#+ Try)] [concurrency ["." async (#+ Async)] @@ -11,7 +12,6 @@ [parser ["<.>" json]]] [data - ["." maybe] ["." number ["n" nat]] ["." text @@ -40,7 +40,7 @@ [0 (|> inputs (list\map binary.size) (list\fold n.+ 0) - binary.create)] + binary.empty)] inputs))] output)) @@ -60,7 +60,7 @@ (case (do try.monad [raw ?raw content (\ json.codec decode raw)] - (json.run content reader)) + (json.result content reader)) (#try.Success input) (server input request) @@ -88,7 +88,7 @@ (maybe.else [full ""]))] (case (do try.monad [query (//query.parameters query) - input (context.run query property)] + input (context.result query property)] (in [[identification protocol (set@ #//.uri uri resource) message] input])) (#try.Success [request input]) @@ -105,7 +105,7 @@ (case (do try.monad [body ?body form (//query.parameters body)] - (context.run form property)) + (context.result form property)) (#try.Success input) (server input request) @@ -120,7 +120,7 @@ (dictionary.get "Cookie") (maybe.else "") //cookie.get)] - (context.run cookies property)) + (context.result cookies property)) (#try.Success input) (server input request) diff --git a/stdlib/source/library/lux/world/net/http/route.lux b/stdlib/source/library/lux/world/net/http/route.lux index 15f89bb99..d9519a95d 100644 --- a/stdlib/source/library/lux/world/net/http/route.lux +++ b/stdlib/source/library/lux/world/net/http/route.lux @@ -3,10 +3,10 @@ [lux (#- or) [control [monad (#+ do)] + ["." maybe] [concurrency ["." async]]] [data - ["." maybe] ["." text] [number ["n" nat]]]]] diff --git a/stdlib/source/library/lux/world/net/http/status.lux b/stdlib/source/library/lux/world/net/http/status.lux index e7810c7fa..57a88ef09 100644 --- a/stdlib/source/library/lux/world/net/http/status.lux +++ b/stdlib/source/library/lux/world/net/http/status.lux @@ -1,13 +1,28 @@ (.module: [library - [lux #*]] + [lux #* + [control + [parser + ["<.>" code]]] + [data + ["." text]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]]]] [// (#+ Status)]) +(syntax: (status_description {name <code>.local_identifier}) + (in (list (code.text (text.replaced "_" " " name))))) + ... https://en.wikipedia.org/wiki/List_of_HTTP_status_codes (template [<status> <name>] - [(def: .public <name> - Status - <status>)] + [(with_expansions [<description> (status_description <name>) + <documentation> (template.text [<status> ": " <description>])] + (def: .public <name> + {#.doc <documentation>} + Status + <status>))] ... 1xx Informational response [100 continue] diff --git a/stdlib/source/library/lux/world/net/uri.lux b/stdlib/source/library/lux/world/net/uri.lux index 275c1539d..84df2b716 100644 --- a/stdlib/source/library/lux/world/net/uri.lux +++ b/stdlib/source/library/lux/world/net/uri.lux @@ -2,8 +2,11 @@ [library [lux #*]]) +... https://en.wikipedia.org/wiki/Uniform_Resource_Identifier (type: .public URI + {#.doc (example "A Uniform Resource Identifier.")} Text) (def: .public separator + {#.doc (example "A separator for the pieces of a URI.")} "/") diff --git a/stdlib/source/library/lux/world/output/video/resolution.lux b/stdlib/source/library/lux/world/output/video/resolution.lux index 4ad3813d3..bbe7bdd74 100644 --- a/stdlib/source/library/lux/world/output/video/resolution.lux +++ b/stdlib/source/library/lux/world/output/video/resolution.lux @@ -4,13 +4,22 @@ [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)]] + [control + [parser + ["<.>" code]]] [data - ["." product]] + ["." product] + ["." text]] + [macro + [syntax (#+ syntax:)] + ["." code] + ["." template]] [math [number ["." nat]]]]]) (type: .public Resolution + {#.doc (example "A screen resolution.")} {#width Nat #height Nat}) @@ -22,12 +31,22 @@ (Equivalence Resolution) (\ ..hash &equivalence)) +(syntax: (description {name <code>.local_identifier}) + (in (list (|> name + (text.replaced "/" " ") + (text.replaced "_" " ") + text.upper_cased + code.text)))) + ... https://en.wikipedia.org/wiki/Display_resolution#Common_display_resolutions (template [<name> <width> <height>] - [(def: .public <name> - Resolution - {#width <width> - #height <height>})] + [(with_expansions [<description> (..description <name>) + <documentation> (template.text [<description> " resolution: " <width> "x" <height> "."])] + (def: .public <name> + {#.doc <documentation>} + Resolution + {#width <width> + #height <height>}))] [svga 800 600] [wsvga 1024 600] diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index 3216c6b93..ea1ecc83b 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -8,6 +8,7 @@ [control ["." function] ["." io (#+ IO)] + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)] [concurrency @@ -17,7 +18,6 @@ ["." environment (#+ Environment)]]] [data ["." bit ("#\." equivalence)] - ["." maybe] ["." text ["%" format (#+ format)]] [collection @@ -105,8 +105,8 @@ home) (def: directory directory) - (def: (exit code) - (io.io (error! (%.int code))))))) + (def: exit + (|>> %.int panic! io.io))))) ... Do not trust the values of environment variables ... https://wiki.sei.cmu.edu/confluence/display/java/ENV02-J.+Do+not+trust+the+values+of+environment+variables @@ -144,7 +144,7 @@ @.jvm (as_is <jvm>) @.js (as_is (def: default_exit! (-> Exit (IO Nothing)) - (|>> %.int error! io.io)) + (|>> %.int panic! io.io)) (import: NodeJs_Process ["#::." @@ -376,7 +376,7 @@ })))) (def: home - (io.run + (io.run! (with_expansions [<default> (io.io "~") <jvm> (io.io (maybe.else "" (java/lang/System::getProperty "user.home")))] (for {@.old <jvm> @@ -399,7 +399,7 @@ <default>)))) (def: directory - (io.run + (io.run! (with_expansions [<default> "." <jvm> (io.io (maybe.else "" (java/lang/System::getProperty "user.dir")))] (for {@.old <jvm> diff --git a/stdlib/source/poly/lux/abstract/equivalence.lux b/stdlib/source/poly/lux/abstract/equivalence.lux index 797caaf12..895c8d1a5 100644 --- a/stdlib/source/poly/lux/abstract/equivalence.lux +++ b/stdlib/source/poly/lux/abstract/equivalence.lux @@ -4,12 +4,12 @@ [abstract [monad (#+ Monad do)]] [control + ["." maybe] ["<>" parser ["<.>" type]]] [data ["." product] ["." bit] - ["." maybe] ["." text ("#\." monoid) ["%" format (#+ format)]] [collection diff --git a/stdlib/source/poly/lux/data/format/json.lux b/stdlib/source/poly/lux/data/format/json.lux index 5ee07e1d1..5b48aa34b 100644 --- a/stdlib/source/poly/lux/data/format/json.lux +++ b/stdlib/source/poly/lux/data/format/json.lux @@ -62,12 +62,12 @@ (#/.Array (row (|> high .int int.frac #/.Number) (|> low .int int.frac #/.Number))))) (def: decode - (</>.run (</>.array - (do <>.monad - [high </>.number - low </>.number] - (in (n.+ (|> high frac.int .nat (i64.left_shifted 32)) - (|> low frac.int .nat)))))))) + (</>.result (</>.array + (do <>.monad + [high </>.number + low </>.number] + (in (n.+ (|> high frac.int .nat (i64.left_shifted 32)) + (|> low frac.int .nat)))))))) (implementation: int_codec (codec.Codec JSON Int) @@ -322,27 +322,28 @@ )))) (syntax: .public (codec inputT) - {#.doc (doc "A macro for automatically producing JSON codecs." - (type: Variant - (#Bit Bit) - (#Text Text) - (#Frac Frac)) + {#.doc (example "A macro for automatically producing JSON codecs." + (type: Variant + (#Bit Bit) + (#Text Text) + (#Frac Frac)) - (type: Record - {#bit Bit - #frac Frac - #text Text - #maybe (Maybe Frac) - #list (List Frac) - #variant Variant - #tuple [Bit Frac Text] - #dictionary (Dictionary Text Frac)}) + (type: Record + {#bit Bit + #frac Frac + #text Text + #maybe (Maybe Frac) + #list (List Frac) + #variant Variant + #tuple [Bit Frac Text] + #dictionary (Dictionary Text Frac)}) - (derived: (..codec Record)))} + (derived: codec + (..codec Record)))} (in (.list (` (: (codec.Codec /.JSON (~ inputT)) (implementation (def: (~' encode) ((~! ..encode) (~ inputT))) (def: (~' decode) - ((~! </>.run) ((~! ..decode) (~ inputT)))) + ((~! </>.result) ((~! ..decode) (~ inputT)))) )))))) diff --git a/stdlib/source/program/aedifex/artifact/versioning.lux b/stdlib/source/program/aedifex/artifact/versioning.lux index 9e6ff8244..9f9963731 100644 --- a/stdlib/source/program/aedifex/artifact/versioning.lux +++ b/stdlib/source/program/aedifex/artifact/versioning.lux @@ -11,7 +11,6 @@ ["<.>" text]]] [data ["." product] - ["." maybe] ["." text ["%" format]] [format diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index 00380e59b..58df179e2 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -13,7 +13,6 @@ ["." async (#+ Async) ("#\." monad)]]] [data ["." product] - ["." maybe] ["." text ("#\." order) ["%" format (#+ format)]] [collection @@ -218,7 +217,7 @@ (async.upon! recur (\ process <capability> [])))) (console.write_line line console))))) - io.run)] + io.run!)] read!))] [log_output! read] @@ -232,7 +231,7 @@ (def: windows? Bit (|> (java/lang/System::getProperty "os.name") - io.run + io.run! (try.else "") text.lower_cased (text.starts_with? "windows"))) diff --git a/stdlib/source/program/aedifex/command/deploy.lux b/stdlib/source/program/aedifex/command/deploy.lux index 2ff5ca8fb..cbddc9b27 100644 --- a/stdlib/source/program/aedifex/command/deploy.lux +++ b/stdlib/source/program/aedifex/command/deploy.lux @@ -63,7 +63,7 @@ (get@ #/.sources) set.list (export.library fs) - (\ ! map (binary.run tar.writer))) + (\ ! map (binary.result tar.writer))) pom (\ async.monad in (///pom.write profile)) _ (///dependency/deployment.one repository diff --git a/stdlib/source/program/aedifex/command/deps.lux b/stdlib/source/program/aedifex/command/deps.lux index 9dbabbfca..185bd6229 100644 --- a/stdlib/source/program/aedifex/command/deps.lux +++ b/stdlib/source/program/aedifex/command/deps.lux @@ -59,19 +59,19 @@ (///dependency/deployment.all local)) _ (console.write_line (exception.report ["Local successes" (|> local_successes - (list.sort (\ ///dependency.order <)) + (list.sorted (\ ///dependency.order <)) (exception.listing ..format))] ["Local failures" (|> local_failures - (list.sort (\ ///dependency.order <)) + (list.sorted (\ ///dependency.order <)) (exception.listing ..format))] ["Remote successes" (|> remote_successes (set.of_list ///dependency.hash) (set.difference (set.of_list ///dependency.hash local_successes)) set.list - (list.sort (\ ///dependency.order <)) + (list.sorted (\ ///dependency.order <)) (exception.listing ..format))] ["Remote failures" (|> remote_failures - (list.sort (\ ///dependency.order <)) + (list.sorted (\ ///dependency.order <)) (exception.listing ..format))]) console)] (in resolution)))) diff --git a/stdlib/source/program/aedifex/command/install.lux b/stdlib/source/program/aedifex/command/install.lux index c86400b6a..9b06daaec 100644 --- a/stdlib/source/program/aedifex/command/install.lux +++ b/stdlib/source/program/aedifex/command/install.lux @@ -67,7 +67,7 @@ (\ xml.codec encode) (\ utf8.codec encode))] {#///package.origin (#///origin.Local "") - #///package.library (let [library (binary.run tar.writer package)] + #///package.library (let [library (binary.result tar.writer package)] [library (///dependency/status.verified library)]) #///package.pom [pom pom_data diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux index ed4303ac5..d86bef56b 100644 --- a/stdlib/source/program/aedifex/dependency/resolution.lux +++ b/stdlib/source/program/aedifex/dependency/resolution.lux @@ -8,6 +8,7 @@ [equivalence (#+ Equivalence)] [monad (#+ do)]] [control + ["." maybe] ["." try (#+ Try) ("#\." functor)] ["." exception (#+ Exception exception:)] ["<>" parser @@ -17,7 +18,6 @@ [data ["." binary (#+ Binary)] ["." name] - ["." maybe] ["." text ["%" format (#+ format)] [encoding @@ -138,7 +138,7 @@ (do try.monad [pom (\ utf8.codec decode pom_data) pom (\ xml.codec decode pom) - profile (<xml>.run ///pom.parser (list pom))] + profile (<xml>.result ///pom.parser (list pom))] (in {#///package.origin (#///repository/origin.Remote "") #///package.library library_&_status #///package.pom [pom pom_data pom_status]})))))) diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index 2e46286ea..46a6fc67a 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -121,7 +121,7 @@ (if (n.= size hash_size) (loop [input encoded chunk 0 - output (binary.create hash_size)] + output (binary.empty hash_size)] (let [index (n.* chunk i64.bytes_per_i64)] (case (text.split ..hex_per_chunk input) (#.Some [head tail]) diff --git a/stdlib/source/program/aedifex/input.lux b/stdlib/source/program/aedifex/input.lux index 6a635589e..58f37e252 100644 --- a/stdlib/source/program/aedifex/input.lux +++ b/stdlib/source/program/aedifex/input.lux @@ -44,7 +44,7 @@ (|>> (do> try.monad [(\ utf8.codec decode)] [..lux_parser] - [(list) (<code>.run //parser.project)]))) + [(list) (<code>.result //parser.project)]))) (def: .public (read monad fs profile) (All [!] (-> (Monad !) (file.System !) Text (! (Try Profile)))) diff --git a/stdlib/source/program/aedifex/metadata/artifact.lux b/stdlib/source/program/aedifex/metadata/artifact.lux index 0bd6d4a12..f4971546f 100644 --- a/stdlib/source/program/aedifex/metadata/artifact.lux +++ b/stdlib/source/program/aedifex/metadata/artifact.lux @@ -182,7 +182,7 @@ (do> try.monad [(\ utf8.codec decode)] [(\ xml.codec decode)] - [list (<xml>.run ..parser)]))) + [list (<xml>.result ..parser)]))) (#try.Failure error) (in (#try.Success diff --git a/stdlib/source/program/aedifex/metadata/snapshot.lux b/stdlib/source/program/aedifex/metadata/snapshot.lux index 69e3432fa..90fa9bb86 100644 --- a/stdlib/source/program/aedifex/metadata/snapshot.lux +++ b/stdlib/source/program/aedifex/metadata/snapshot.lux @@ -132,7 +132,7 @@ (do> try.monad [(\ utf8.codec decode)] [(\ xml.codec decode)] - [list (<xml>.run ..parser)]))) + [list (<xml>.result ..parser)]))) (#try.Failure error) (in (#try.Success diff --git a/stdlib/source/program/aedifex/package.lux b/stdlib/source/program/aedifex/package.lux index ea9c2a6d8..6b65a936d 100644 --- a/stdlib/source/program/aedifex/package.lux +++ b/stdlib/source/program/aedifex/package.lux @@ -64,7 +64,7 @@ (|>> (get@ #pom) product.left list - (<xml>.run //pom.parser) + (<xml>.result //pom.parser) (try\map (get@ #/.dependencies)))) (def: .public repositories @@ -72,7 +72,7 @@ (|>> (get@ #pom) product.left list - (<xml>.run //pom.parser) + (<xml>.result //pom.parser) (try\map (get@ #/.repositories)))) (def: .public equivalence diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux index e2ad11079..d18bd9209 100644 --- a/stdlib/source/program/aedifex/pom.lux +++ b/stdlib/source/program/aedifex/pom.lux @@ -5,13 +5,13 @@ [monad (#+ do)]] [control [pipe (#+ case>)] + ["." maybe ("#\." functor)] ["." try (#+ Try)] ["." exception] ["<>" parser ["<.>" xml (#+ Parser)]]] [data ["." name] - ["." maybe ("#\." functor)] ["." text] [format ["_" xml (#+ Tag XML)]] @@ -223,7 +223,7 @@ repositories (|> ..repositories_parser <xml>.somewhere (<>.else (list))) - _ (<>.some <xml>.ignore)] + _ (<>.some <xml>.any)] (in (|> (\ /.monoid identity) (update@ #/.dependencies (function (_ empty) (list\fold set.add empty dependencies))) diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux index ffd549c06..2ff458967 100644 --- a/stdlib/source/program/aedifex/profile.lux +++ b/stdlib/source/program/aedifex/profile.lux @@ -5,10 +5,10 @@ [monoid (#+ Monoid)] [equivalence (#+ Equivalence)]] [control + ["." maybe ("#\." monoid)] ["." exception (#+ exception:)]] [data ["." product] - ["." maybe ("#\." monoid)] ["." text ("#\." equivalence)] [collection ["." dictionary (#+ Dictionary)] diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index f19575859..a88eb93a5 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -67,7 +67,7 @@ (exec (debug.log! (format text.new_line failure_description text.new_line error text.new_line)) - (io.run (\ world/program.default exit +1))) + (io.run! (\ world/program.default exit +1))) (#try.Success output) (in output)))) @@ -76,9 +76,9 @@ (All [a] (-> (Async (Try a)) (Async (Try a)))) (do async.monad - [.let [start (io.run instant.now)] + [.let [start (io.run! instant.now)] output process - .let [_ ("lux io log" (|> (io.run instant.now) + .let [_ ("lux io log" (|> (io.run! instant.now) (instant.span start) %.duration (format "Duration: ")))]] @@ -179,5 +179,5 @@ ... [console (|> console.default ... async.future ... (\ ! map (|>> try.assumed console.async)))] - ... (interpreter.run (try.with async.monad) console platform interpretation generation_bundle))) + ... (interpreter.run! (try.with async.monad) console platform interpretation generation_bundle))) )))) diff --git a/stdlib/source/program/compositor/export.lux b/stdlib/source/program/compositor/export.lux index b229b36ba..309678908 100644 --- a/stdlib/source/program/compositor/export.lux +++ b/stdlib/source/program/compositor/export.lux @@ -65,7 +65,7 @@ (def: .public (export fs [sources target]) (-> (file.System Async) Export (Async (Try Any))) (do {! (try.with async.monad)} - [tar (\ ! map (binary.run tar.writer) + [tar (\ ! map (binary.result tar.writer) (..library fs sources))] (|> ..file (format target (\ fs separator)) diff --git a/stdlib/source/program/compositor/import.lux b/stdlib/source/program/compositor/import.lux index a96f722d9..ca72f9749 100644 --- a/stdlib/source/program/compositor/import.lux +++ b/stdlib/source/program/compositor/import.lux @@ -48,7 +48,7 @@ (|> library (\ system read) (\ ! map (let [! try.monad] - (|>> (\ ! map (<binary>.run tar.parser)) + (|>> (\ ! map (<binary>.result tar.parser)) (\ ! join) (\ ! map (|>> row.list (monad.fold ! (function (_ entry import) diff --git a/stdlib/source/program/scriptum.lux b/stdlib/source/program/scriptum.lux index b18ce7bff..9128fdc60 100644 --- a/stdlib/source/program/scriptum.lux +++ b/stdlib/source/program/scriptum.lux @@ -9,12 +9,12 @@ ["." enum]] [control [pipe (#+ when> new>)] + ["." maybe] ["." try (#+ Try)] ["." exception (#+ exception:)] ["." io (#+ IO io)] ["." function]] [data - ["." maybe] ["." product] [format ["md" markdown (#+ Markdown Span Block)]] @@ -214,20 +214,20 @@ (format "(primitive " (%.text name) ")") _ - (format "(primitive " (%.text name) " " (|> params (list\map (pprint_type level type_func_name module)) (list.interpose " ") (text.join_with "")) ")")) + (format "(primitive " (%.text name) " " (|> params (list\map (pprint_type level type_func_name module)) (list.interposed " ") (text.join_with "")) ")")) (#.Sum _) (let [members (type.flat_variant type)] - (format "(Or " (|> members (list\map (pprint_type level type_func_name module)) (list.interpose " ") (text.join_with "")) ")")) + (format "(Or " (|> members (list\map (pprint_type level type_func_name module)) (list.interposed " ") (text.join_with "")) ")")) (#.Product _) (let [members (type.flat_tuple type)] - (format "[" (|> members (list\map (pprint_type level type_func_name module)) (list.interpose " ") (text.join_with "")) "]")) + (format "[" (|> members (list\map (pprint_type level type_func_name module)) (list.interposed " ") (text.join_with "")) "]")) (#.Function input output) (let [[ins out] (type.flat_function type)] (format "(-> " - (|> ins (list\map (pprint_type level type_func_name module)) (list.interpose " ") (text.join_with "")) + (|> ins (list\map (pprint_type level type_func_name module)) (list.interposed " ") (text.join_with "")) " " (pprint_type level type_func_name module out) ")")) @@ -246,7 +246,7 @@ (let [[level' body] (<flat> type) args (level_parameters level level') body_doc (pprint_type (n.+ level level') type_func_name module body)] - (format "(" <name> " " "[" (|> args (list.interpose " ") (text.join_with "")) "]" + (format "(" <name> " " "[" (|> args (list.interposed " ") (text.join_with "")) "]" (format " " body_doc) ")"))]) ([#.UnivQ "All" type.flat_univ_q] @@ -254,7 +254,7 @@ (#.Apply param fun) (let [[type_func type_arguments] (type.flat_application type)] - (format "(" (pprint_type level type_func_name module type_func) " " (|> type_arguments (list\map (pprint_type level type_func_name module)) (list.interpose " ") (text.join_with "")) ")")) + (format "(" (pprint_type level type_func_name module type_func) " " (|> type_arguments (list\map (pprint_type level type_func_name module)) (list.interposed " ") (text.join_with "")) ")")) (#.Named [_module _name] type) (if (text\= module _module) @@ -319,10 +319,10 @@ #implementations (list) #values (list)}] (|> (list\fold add_definition init defs) - (update@ #types (list.sort name_sort)) - (update@ #macros (list.sort name_sort)) - (update@ #implementations (list.sort name_sort)) - (update@ #values (list.sort name_sort))))) + (update@ #types (list.sorted name_sort)) + (update@ #macros (list.sorted name_sort)) + (update@ #implementations (list.sorted name_sort)) + (update@ #values (list.sorted name_sort))))) (def: (unravel_type_func level type) (-> Nat Type Type) @@ -506,13 +506,13 @@ [all_modules meta.modules .let [lux_modules (|> all_modules (list.only (function.compose lux_module? product.left)) - (list.sort name_sort))] + (list.sorted name_sort))] lux_exports (monad.map ! (function.compose meta.exports product.left) lux_modules) module_documentation (|> (list\map organize_definitions lux_exports) (list.zipped/2 lux_modules) (monad.map ! document_module)) - .let [_ (io.run (monad.map io.monad save_documentation! module_documentation))]] + .let [_ (io.run! (monad.map io.monad save_documentation! module_documentation))]] (in (list)))) (gen_documentation!) diff --git a/stdlib/source/specification/compositor.lux b/stdlib/source/specification/compositor.lux index 7c7d620f1..cf7008b76 100644 --- a/stdlib/source/specification/compositor.lux +++ b/stdlib/source/specification/compositor.lux @@ -50,7 +50,7 @@ Test)) (do r.monad [_ (in []) - .let [?state,runner,definer (<| io.run + .let [?state,runner,definer (<| io.run! (do io.monad [platform platform]) (/common.executors platform diff --git a/stdlib/source/specification/compositor/analysis/type.lux b/stdlib/source/specification/compositor/analysis/type.lux index 6e3c4dba7..662748677 100644 --- a/stdlib/source/specification/compositor/analysis/type.lux +++ b/stdlib/source/specification/compositor/analysis/type.lux @@ -25,7 +25,7 @@ (|> (analysis/scope.with_scope "" (analysis/type.with_type output_type (analysis.phase expander (` ((~ (code.text extension)) (~+ params)))))) - (phase.run state) + (phase.result state) (case> (#try.Success _) true diff --git a/stdlib/source/specification/compositor/common.lux b/stdlib/source/specification/compositor/common.lux index 2c83cbd9e..3a7f70731 100644 --- a/stdlib/source/specification/compositor/common.lux +++ b/stdlib/source/specification/compositor/common.lux @@ -35,7 +35,7 @@ (Instancer Runner) (function (_ evaluation_name expressionS) (do try.monad - [expressionG (<| (phase.run state) + [expressionG (<| (phase.result state) generation.with_buffer (do phase.monad [_ runtime] @@ -47,7 +47,7 @@ (Instancer Definer) (function (_ lux_name expressionS) (do try.monad - [definitionG (<| (phase.run state) + [definitionG (<| (phase.result state) generation.with_buffer (do phase.monad [_ runtime diff --git a/stdlib/source/specification/compositor/generation/case.lux b/stdlib/source/specification/compositor/generation/case.lux index 81042846f..bca682a9e 100644 --- a/stdlib/source/specification/compositor/generation/case.lux +++ b/stdlib/source/specification/compositor/generation/case.lux @@ -232,8 +232,8 @@ Path ($_ synthesis.path/alt (<| try.assumed - (phase.run [extension/synthesis.bundle - synthesis.init]) + (phase.result [extension/synthesis.bundle + synthesis.init]) (case.path phase/synthesis.phase special_pattern) (analysis.bit #1)) diff --git a/stdlib/source/specification/compositor/generation/function.lux b/stdlib/source/specification/compositor/generation/function.lux index a9845081b..ad90dbfa0 100644 --- a/stdlib/source/specification/compositor/generation/function.lux +++ b/stdlib/source/specification/compositor/generation/function.lux @@ -5,9 +5,9 @@ [monad (#+ do)] ["." enum]] [control - [pipe (#+ case>)]] + [pipe (#+ case>)] + ["." maybe]] [data - ["." maybe] [number ["n" nat]] [collection diff --git a/stdlib/source/specification/compositor/generation/structure.lux b/stdlib/source/specification/compositor/generation/structure.lux index 4feea793f..0b4bfe4fe 100644 --- a/stdlib/source/specification/compositor/generation/structure.lux +++ b/stdlib/source/specification/compositor/generation/structure.lux @@ -5,9 +5,9 @@ [monad (#+ do)]] [control [pipe (#+ case>)] + ["." maybe] ["." try]] [data - ["." maybe] [number ["n" nat] ["i" int]] diff --git a/stdlib/source/specification/lux/world/file.lux b/stdlib/source/specification/lux/world/file.lux index b74a83fd6..971e312de 100644 --- a/stdlib/source/specification/lux/world/file.lux +++ b/stdlib/source/specification/lux/world/file.lux @@ -8,12 +8,12 @@ [control [pipe (#+ case>)] [io (#+ IO)] + ["." maybe ("#\." functor)] ["." try ("#\." functor)] ["." exception] [concurrency ["." async (#+ Async)]]] [data - ["." maybe ("#\." functor)] ["." text ("#\." equivalence) ["%" format (#+ format)] [encoding diff --git a/stdlib/source/test/aedifex/artifact/snapshot.lux b/stdlib/source/test/aedifex/artifact/snapshot.lux index f196586ac..c4ebdfc66 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot.lux @@ -39,7 +39,7 @@ (|> expected /.format list - (<xml>.run /.parser) + (<xml>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false)))) diff --git a/stdlib/source/test/aedifex/artifact/snapshot/build.lux b/stdlib/source/test/aedifex/artifact/snapshot/build.lux index e613c2f92..d207053c9 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/build.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/build.lux @@ -33,7 +33,7 @@ (|> expected /.format list - (<xml>.run /.parser) + (<xml>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false)))) )))) diff --git a/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux b/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux index 2a2c19e4f..ed77767cb 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux @@ -40,7 +40,7 @@ (_.cover [/.format /.parser] (|> expected /.format - (<xml>.run /.parser) + (<xml>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false)))) ))) diff --git a/stdlib/source/test/aedifex/artifact/snapshot/time.lux b/stdlib/source/test/aedifex/artifact/snapshot/time.lux index a658d3e29..7f33a9e86 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/time.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/time.lux @@ -35,7 +35,7 @@ (_.cover [/.format /.parser] (|> expected /.format - (<text>.run /.parser) + (<text>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false))) )) diff --git a/stdlib/source/test/aedifex/artifact/snapshot/version.lux b/stdlib/source/test/aedifex/artifact/snapshot/version.lux index c5ec63398..3976d7054 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/version.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/version.lux @@ -42,7 +42,7 @@ (|> expected /.format list - (<xml>.run /.parser) + (<xml>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false)))) diff --git a/stdlib/source/test/aedifex/artifact/time.lux b/stdlib/source/test/aedifex/artifact/time.lux index ed60f6389..8270969fd 100644 --- a/stdlib/source/test/aedifex/artifact/time.lux +++ b/stdlib/source/test/aedifex/artifact/time.lux @@ -42,7 +42,7 @@ (_.cover [/.format /.parser] (|> expected /.format - (<text>.run /.parser) + (<text>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false)))) (do random.monad diff --git a/stdlib/source/test/aedifex/artifact/time/date.lux b/stdlib/source/test/aedifex/artifact/time/date.lux index e58ed00f9..212aa01dd 100644 --- a/stdlib/source/test/aedifex/artifact/time/date.lux +++ b/stdlib/source/test/aedifex/artifact/time/date.lux @@ -48,7 +48,7 @@ (_.cover [/.format /.parser] (|> expected /.format - (<text>.run /.parser) + (<text>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false))) (_.cover [/.value /.date] diff --git a/stdlib/source/test/aedifex/artifact/time/time.lux b/stdlib/source/test/aedifex/artifact/time/time.lux index 9358e7bab..4dcdac3cc 100644 --- a/stdlib/source/test/aedifex/artifact/time/time.lux +++ b/stdlib/source/test/aedifex/artifact/time/time.lux @@ -32,7 +32,7 @@ (_.cover [/.format /.parser] (|> expected /.format - (<text>.run /.parser) + (<text>.result /.parser) (try\map (\ time.equivalence = expected)) (try.else false)))) ))) diff --git a/stdlib/source/test/aedifex/artifact/versioning.lux b/stdlib/source/test/aedifex/artifact/versioning.lux index 5a0b2df20..aa90619cb 100644 --- a/stdlib/source/test/aedifex/artifact/versioning.lux +++ b/stdlib/source/test/aedifex/artifact/versioning.lux @@ -41,14 +41,14 @@ (|> expected /.format list - (<xml>.run /.parser) + (<xml>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false)))) (_.cover [/.init] (|> /.init /.format list - (<xml>.run /.parser) + (<xml>.result /.parser) (try\map (\ /.equivalence = /.init)) (try.else false))) ))) diff --git a/stdlib/source/test/aedifex/cli.lux b/stdlib/source/test/aedifex/cli.lux index 4b5e79ac5..45ec92f4e 100644 --- a/stdlib/source/test/aedifex/cli.lux +++ b/stdlib/source/test/aedifex/cli.lux @@ -73,7 +73,7 @@ (_.test "Without profile." (|> expected ..format - (cli.run /.command) + (cli.result /.command) (case> (#try.Success [name actual]) (and (text\= //.default name) (\ /.equivalence = expected actual)) @@ -90,7 +90,7 @@ (|> expected_command ..format (list& "with" expected_profile) - (cli.run /.command) + (cli.result /.command) (case> (#try.Success [actual_profile actual_command]) (and (text\= expected_profile actual_profile) (\ /.equivalence = expected_command actual_command)) diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index 074eeab5e..934810e0c 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -98,7 +98,7 @@ (in (do async.monad [verdict (do ///action.monad [_ (\ fs make_directory source) - _ (\ fs write (binary.create 0) dummy_path) + _ (\ fs write (binary.empty 0) dummy_path) .let [[@runs command] (..command expected_runs end_signal fs dummy_path)] _ (\ watcher poll [])] (do {! async.monad} diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index 4bdbafd59..4d11234bd 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -5,13 +5,13 @@ [abstract [monad (#+ do)]] [control + ["." maybe] ["." try (#+ Try)] [concurrency ["." async (#+ Async)]] [parser ["." environment]]] [data - ["." maybe] ["." binary ("#\." equivalence)] ["." text ("#\." equivalence) ["%" format (#+ format)] @@ -84,7 +84,7 @@ (get@ #///.sources) set.list (export.library fs) - (\ ! map (format.run tar.writer))) + (\ ! map (format.result tar.writer))) actual_pom (\ repository download (///repository/remote.uri (get@ #///artifact.version artifact) artifact ///artifact/extension.pom)) actual_library (\ repository download (///repository/remote.uri (get@ #///artifact.version artifact) artifact ///artifact/extension.lux_library)) diff --git a/stdlib/source/test/aedifex/command/install.lux b/stdlib/source/test/aedifex/command/install.lux index a3cd99edd..86fe5ebea 100644 --- a/stdlib/source/test/aedifex/command/install.lux +++ b/stdlib/source/test/aedifex/command/install.lux @@ -50,7 +50,7 @@ [_ (: (Async (Try Any)) (file.make_directories async.monad fs head))] (: (Async (Try Any)) - (file.make_file async.monad fs (binary.create 0) (format head / head ".lux"))))))))) + (file.make_file async.monad fs (binary.empty 0) (format head / head ".lux"))))))))) (def: (execute! program fs sample) (-> (Program Async) (file.System Async) ///.Profile (Async (Try Text))) diff --git a/stdlib/source/test/aedifex/command/version.lux b/stdlib/source/test/aedifex/command/version.lux index f1c424289..0400cbc58 100644 --- a/stdlib/source/test/aedifex/command/version.lux +++ b/stdlib/source/test/aedifex/command/version.lux @@ -5,12 +5,12 @@ [abstract [monad (#+ do)]] [control + ["." maybe] ["." try] ["." exception (#+ exception:)] [concurrency ["." async (#+ Async)]]] [data - ["." maybe] ["." text ("#\." equivalence) ["%" format (#+ format)]]] [math diff --git a/stdlib/source/test/aedifex/dependency/deployment.lux b/stdlib/source/test/aedifex/dependency/deployment.lux index 0add3a487..7352de63a 100644 --- a/stdlib/source/test/aedifex/dependency/deployment.lux +++ b/stdlib/source/test/aedifex/dependency/deployment.lux @@ -7,13 +7,13 @@ ["." hash (#+ Hash)]] [control ["." io (#+ IO)] + ["." maybe ("#\." functor)] ["." try ("#\." functor)] [concurrency ["." atom (#+ Atom)] ["." async]]] [data ["." product] - ["." maybe ("#\." functor)] ["." binary (#+ Binary) ("#\." equivalence)] ["." text ["%" format (#+ format)]] @@ -54,7 +54,7 @@ [http/status.created {#@http.headers (http.headers (list)) #@http.body (function (_ _) - (|> [0 (binary.create 0)] + (|> [0 (binary.empty 0)] #try.Success io.io))}]) diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux index 2e6a8e10f..7bcb0bd91 100644 --- a/stdlib/source/test/aedifex/metadata/artifact.lux +++ b/stdlib/source/test/aedifex/metadata/artifact.lux @@ -7,6 +7,7 @@ [\\specification ["$." equivalence]]] [control + ["." maybe] ["." try ("#\." functor)] [parser ["." environment] @@ -14,7 +15,6 @@ [concurrency ["." async]]] [data - ["." maybe] ["." text ("#\." equivalence)] [collection ["." list]]] @@ -88,7 +88,7 @@ (|> expected /.format list - (<xml>.run /.parser) + (<xml>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false)))) (_.cover [/.uri] diff --git a/stdlib/source/test/aedifex/metadata/snapshot.lux b/stdlib/source/test/aedifex/metadata/snapshot.lux index 7b375d42c..5683178c4 100644 --- a/stdlib/source/test/aedifex/metadata/snapshot.lux +++ b/stdlib/source/test/aedifex/metadata/snapshot.lux @@ -7,6 +7,7 @@ [\\specification ["$." equivalence]]] [control + ["." maybe] ["." try ("#\." functor)] [parser ["." environment] @@ -14,7 +15,6 @@ [concurrency ["." async]]] [data - ["." maybe] ["." text ("#\." equivalence)] [collection ["." list]]] @@ -100,7 +100,7 @@ (|> expected /.format list - (<xml>.run /.parser) + (<xml>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false))) (_.cover [/.uri] diff --git a/stdlib/source/test/aedifex/parser.lux b/stdlib/source/test/aedifex/parser.lux index 4c882ea4a..354352d6a 100644 --- a/stdlib/source/test/aedifex/parser.lux +++ b/stdlib/source/test/aedifex/parser.lux @@ -74,7 +74,7 @@ (|> expected //format.profile list - (<code>.run /.project) + (<code>.result /.project) (case> (#try.Success actual) (|> expected ..with_default_sources @@ -99,7 +99,7 @@ (|> expected //format.project list - (<code>.run /.project) + (<code>.result /.project) (case> (#try.Success actual) (|> expected ..with_empty_profile diff --git a/stdlib/source/test/aedifex/pom.lux b/stdlib/source/test/aedifex/pom.lux index 657c6192d..f51ac9abc 100644 --- a/stdlib/source/test/aedifex/pom.lux +++ b/stdlib/source/test/aedifex/pom.lux @@ -37,7 +37,7 @@ (get@ #//.identity expected)] [(#try.Success pom) (#.Some _)] - (case (<xml>.run /.parser (list pom)) + (case (<xml>.result /.parser (list pom)) (#try.Success actual) (\ //.equivalence = (|> (\ //.monoid identity) diff --git a/stdlib/source/test/aedifex/repository.lux b/stdlib/source/test/aedifex/repository.lux index 478f02d7e..33f719efc 100644 --- a/stdlib/source/test/aedifex/repository.lux +++ b/stdlib/source/test/aedifex/repository.lux @@ -98,7 +98,7 @@ (dictionary.put (remote.uri ..invalid_version (..artifact ..invalid_version) //artifact/extension.lux_library) - (binary.create 0))))))) + (binary.empty 0))))))) /identity.test /origin.test diff --git a/stdlib/source/test/aedifex/repository/remote.lux b/stdlib/source/test/aedifex/repository/remote.lux index 0ff764bdd..8cca4aee8 100644 --- a/stdlib/source/test/aedifex/repository/remote.lux +++ b/stdlib/source/test/aedifex/repository/remote.lux @@ -6,12 +6,12 @@ [monad (#+ do)]] [control ["." io (#+ IO)] + ["." maybe ("#\." functor)] ["." try ("#\." monad)] ["." exception] ["." function]] [data ["." binary ("#\." equivalence)] - ["." maybe ("#\." functor)] ["." text ("#\." equivalence) ["%" format (#+ format)] [encoding @@ -99,20 +99,20 @@ #//identity.password password}) address)] (and (|> (\ repo download uri) - io.run + io.run! (try\map (\ utf8.codec decode)) try\join (try\map (text\= (format address uri))) (try.else false)) (|> (\ repo upload uri content) - io.run + io.run! (try\map (function.constant true)) (try.else false))))) (_.cover [/.upload_failure] (let [repo (/.repository (..good_http user password) #.None address)] - (case (io.run (\ repo upload uri content)) + (case (io.run! (\ repo upload uri content)) (#try.Failure error) (exception.match? /.upload_failure error) @@ -122,7 +122,7 @@ (let [repo (/.repository ..bad_http #.None address)] - (case (io.run (\ repo download uri)) + (case (io.run! (\ repo download uri)) (#try.Failure error) (exception.match? /.download_failure error) diff --git a/stdlib/source/test/aedifex/runtime.lux b/stdlib/source/test/aedifex/runtime.lux index 7508239ad..c9e61b017 100644 --- a/stdlib/source/test/aedifex/runtime.lux +++ b/stdlib/source/test/aedifex/runtime.lux @@ -6,8 +6,9 @@ [monad (#+ do)] [\\specification ["$." equivalence]]] + [control + ["." maybe ("#\." functor)]] [data - ["." maybe ("#\." functor)] ["." text ("#\." equivalence)] [collection ["." list ("#\." functor)] diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index a659b6523..e8af74a92 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -179,8 +179,8 @@ (#.Right _) false)) - (_.cover [/.error!] - (case (/.try (/.error! expected_error)) + (_.cover [/.panic!] + (case (/.try (/.panic! expected_error)) (#.Left actual_error) (text.contains? expected_error actual_error) @@ -287,7 +287,7 @@ ((/.<<| (n.* factor) inc) start))) ))) -(def: example "YOLO") +(def: example_identifier "YOLO") (def: i8 8) (def: current_module @@ -305,12 +305,12 @@ (code\= (code.rev .2) (/.' .2)) (code\= (code.frac +3.4) (/.' +3.4)) (code\= (code.text "5") (/.' "5")) - (code\= (code.identifier ["" "example"]) - (/.' example)) - (code\= (code.identifier [/.prelude_module "example"]) - (/.' .example)) - (code\= (code.identifier [..current_module "example"]) - (/.' ..example)) + (code\= (code.identifier ["" "example_identifier"]) + (/.' example_identifier)) + (code\= (code.identifier [/.prelude_module "example_identifier"]) + (/.' .example_identifier)) + (code\= (code.identifier [..current_module "example_identifier"]) + (/.' ..example_identifier)) (code\= (code.tag ["" "example"]) (/.' #example)) (code\= (code.tag [/.prelude_module "example"]) @@ -340,12 +340,12 @@ (code\= (code.rev .2) (/.` .2)) (code\= (code.frac +3.4) (/.` +3.4)) (code\= (code.text "5") (/.` "5")) - (code\= (code.identifier [..current_module "example"]) - (/.` example)) - (code\= (code.identifier [/.prelude_module "example"]) - (/.` .example)) - (code\= (code.identifier [..current_module "example"]) - (/.` ..example)) + (code\= (code.identifier [..current_module "example_identifier"]) + (/.` example_identifier)) + (code\= (code.identifier [/.prelude_module "example_identifier"]) + (/.` .example_identifier)) + (code\= (code.identifier [..current_module "example_identifier"]) + (/.` ..example_identifier)) (code\= (code.tag [..current_module "example"]) (/.` #example)) (code\= (code.tag [/.prelude_module "example"]) @@ -374,12 +374,12 @@ (code\= (code.rev .2) (/.`' .2)) (code\= (code.frac +3.4) (/.`' +3.4)) (code\= (code.text "5") (/.`' "5")) - (code\= (code.identifier ["" "example"]) - (/.`' example)) - (code\= (code.identifier [/.prelude_module "example"]) - (/.`' .example)) - (code\= (code.identifier [..current_module "example"]) - (/.`' ..example)) + (code\= (code.identifier ["" "example_identifier"]) + (/.`' example_identifier)) + (code\= (code.identifier [/.prelude_module "example_identifier"]) + (/.`' .example_identifier)) + (code\= (code.identifier [..current_module "example_identifier"]) + (/.`' ..example_identifier)) (code\= (code.tag ["" "example"]) (/.`' #example)) (code\= (code.tag [/.prelude_module "example"]) @@ -1007,10 +1007,10 @@ post (random.only (|>> (n.= pre) not) random.nat) .let [box (atom.atom pre)]] (_.cover [/.exec] - (and (is? pre (io.run (atom.read! box))) + (and (is? pre (io.run! (atom.read! box))) (/.exec - (io.run (atom.write! post box)) - (is? post (io.run (atom.read! box))))))) + (io.run! (atom.write! post box)) + (is? post (io.run! (atom.read! box))))))) )) (def: identity/constant diff --git a/stdlib/source/test/lux/abstract/apply.lux b/stdlib/source/test/lux/abstract/apply.lux index 7a940adb3..26bb2cc7e 100644 --- a/stdlib/source/test/lux/abstract/apply.lux +++ b/stdlib/source/test/lux/abstract/apply.lux @@ -3,8 +3,9 @@ [lux #* [abstract [monad (#+ do)]] + [control + ["." maybe]] [data - ["." maybe] [collection ["." list]]] [math diff --git a/stdlib/source/test/lux/abstract/enum.lux b/stdlib/source/test/lux/abstract/enum.lux index 8de8d659f..88d4cc732 100644 --- a/stdlib/source/test/lux/abstract/enum.lux +++ b/stdlib/source/test/lux/abstract/enum.lux @@ -4,9 +4,10 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)]] + [control + ["." maybe ("#\." functor)]] [data ["." product] - ["." maybe ("#\." functor)] [collection ["." list ("#\." fold)]]] [math diff --git a/stdlib/source/test/lux/abstract/functor.lux b/stdlib/source/test/lux/abstract/functor.lux index 178f33273..252e9b999 100644 --- a/stdlib/source/test/lux/abstract/functor.lux +++ b/stdlib/source/test/lux/abstract/functor.lux @@ -4,8 +4,9 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)]] + [control + ["." maybe]] [data - ["." maybe] [collection ["." list]]] [math diff --git a/stdlib/source/test/lux/abstract/interval.lux b/stdlib/source/test/lux/abstract/interval.lux index 2b588f309..76b45ddce 100644 --- a/stdlib/source/test/lux/abstract/interval.lux +++ b/stdlib/source/test/lux/abstract/interval.lux @@ -140,7 +140,7 @@ (do {! random.monad} [[l m r] (|> (random.set n.hash 3 random.nat) (\ ! map (|>> set.list - (list.sort n.<) + (list.sorted n.<) (case> (^ (list b t1 t2)) [b t1 t2] @@ -162,7 +162,7 @@ (do {! random.monad} [[b t1 t2] (|> (random.set n.hash 3 random.nat) (\ ! map (|>> set.list - (list.sort n.<) + (list.sorted n.<) (case> (^ (list b t1 t2)) [b t1 t2] @@ -189,7 +189,7 @@ [some_interval ..interval [x0 x1 x2 x3] (|> (random.set n.hash 4 random.nat) (\ ! map (|>> set.list - (list.sort n.<) + (list.sorted n.<) (case> (^ (list x0 x1 x2 x3)) [x0 x1 x2 x3] @@ -222,7 +222,7 @@ [some_interval ..interval [x0 x1 x2 x3] (|> (random.set n.hash 4 random.nat) (\ ! map (|>> set.list - (list.sort n.<) + (list.sorted n.<) (case> (^ (list x0 x1 x2 x3)) [x0 x1 x2 x3] diff --git a/stdlib/source/test/lux/control.lux b/stdlib/source/test/lux/control.lux index 4ac09ca39..1c7f71963 100644 --- a/stdlib/source/test/lux/control.lux +++ b/stdlib/source/test/lux/control.lux @@ -16,6 +16,8 @@ ["#." exception] ["#." function] ["#." io] + ["#." lazy] + ["#." maybe] ["#." parser] ["#." pipe] ["#." reader] @@ -57,6 +59,8 @@ /exception.test /function.test /io.test + /lazy.test + /maybe.test /parser.test /pipe.test /reader.test diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux index b97f6498f..b7458e8c8 100644 --- a/stdlib/source/test/lux/control/concurrency/actor.lux +++ b/stdlib/source/test/lux/control/concurrency/actor.lux @@ -61,26 +61,26 @@ (_.for [/.Actor]) ($_ _.and (_.cover [/.alive?] - (io.run (do io.monad - [actor (/.spawn! /.default 0)] - (/.alive? actor)))) + (io.run! (do io.monad + [actor (/.spawn! /.default 0)] + (/.alive? actor)))) (_.cover [/.poison!] (let [poisoned_actors_die! - (io.run (do io.monad - [actor (/.spawn! /.default 0) - poisoned? (/.poison! actor) - alive? (/.alive? actor)] - (in (and (..mailed? poisoned?) - (not alive?))))) + (io.run! (do io.monad + [actor (/.spawn! /.default 0) + poisoned? (/.poison! actor) + alive? (/.alive? actor)] + (in (and (..mailed? poisoned?) + (not alive?))))) cannot_poison_more_than_once! - (io.run (do io.monad - [actor (/.spawn! /.default 0) - first_time? (/.poison! actor) - second_time? (/.poison! actor)] - (in (and (..mailed? first_time?) - (not (..mailed? second_time?))))))] + (io.run! (do io.monad + [actor (/.spawn! /.default 0) + first_time? (/.poison! actor) + second_time? (/.poison! actor)] + (in (and (..mailed? first_time?) + (not (..mailed? second_time?))))))] (and poisoned_actors_die! cannot_poison_more_than_once!))) diff --git a/stdlib/source/test/lux/control/concurrency/async.lux b/stdlib/source/test/lux/control/concurrency/async.lux index f4353bc4f..23cb61056 100644 --- a/stdlib/source/test/lux/control/concurrency/async.lux +++ b/stdlib/source/test/lux/control/concurrency/async.lux @@ -33,7 +33,7 @@ (def: comparison (Comparison /.Async) (function (_ == left right) - (io.run + (io.run! (do io.monad [?left (/.poll left) ?right (/.poll right)] diff --git a/stdlib/source/test/lux/control/concurrency/atom.lux b/stdlib/source/test/lux/control/concurrency/atom.lux index e3c5a9b89..939fe7d9f 100644 --- a/stdlib/source/test/lux/control/concurrency/atom.lux +++ b/stdlib/source/test/lux/control/concurrency/atom.lux @@ -21,7 +21,7 @@ [expected random.nat .let [box (/.atom expected)]] (_.cover [/.Atom /.atom /.read!] - (io.run + (io.run! (do io.monad [actual (/.read! box)] (in (is? expected actual)))))) @@ -31,7 +31,7 @@ expected random.nat .let [box (/.atom target)]] (_.cover [/.compare_and_swap!] - (io.run + (io.run! (do io.monad [swapped_unknown? (/.compare_and_swap! unknown expected box) swapped_target? (/.compare_and_swap! target expected box) @@ -44,7 +44,7 @@ shift random.nat .let [box (/.atom init)]] (_.cover [/.update!] - (io.run + (io.run! (do io.monad [[pre post] (/.update! (n.+ shift) box)] (in (and (is? init pre) @@ -55,7 +55,7 @@ post random.nat .let [box (/.atom pre)]] (_.cover [/.write!] - (io.run + (io.run! (do io.monad [old (/.write! post box) new (/.read! box)] diff --git a/stdlib/source/test/lux/control/concurrency/frp.lux b/stdlib/source/test/lux/control/concurrency/frp.lux index 675eabfa3..8bb5a33fd 100644 --- a/stdlib/source/test/lux/control/concurrency/frp.lux +++ b/stdlib/source/test/lux/control/concurrency/frp.lux @@ -34,7 +34,7 @@ (def: comparison (Comparison /.Channel) (function (_ == left right) - (io.run + (io.run! (do io.monad [?left (async.poll left) ?right (async.poll right)] @@ -84,14 +84,14 @@ ($monad.spec ..injection ..comparison /.monad)) (_.cover [/.Channel /.Sink /.channel] - (case (io.run + (case (io.run! (do (try.with io.monad) [.let [[channel sink] (/.channel [])] _ (\ sink feed sample) _ (\ sink close)] (in channel))) (#try.Success channel) - (io.run + (io.run! (do io.monad [?actual (async.poll channel)] (in (case ?actual @@ -104,7 +104,7 @@ (#try.Failure error) false)) (_.cover [/.channel_is_already_closed] - (case (io.run + (case (io.run! (do (try.with io.monad) [.let [[channel sink] (/.channel [])] _ (\ sink close)] diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index 58492c733..94017a803 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -8,13 +8,13 @@ ["." enum]] [control ["." io] + ["." maybe] ["." try] ["." exception (#+ exception:)] [concurrency ["." async (#+ Async)] ["." atom (#+ Atom)]]] [data - ["." maybe] ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection @@ -122,7 +122,7 @@ (in (do async.monad [_ processA _ processB - .let [outcome (io.run (atom.read! resource))]] + .let [outcome (io.run! (atom.read! resource))]] (_.cover' [/.mutex /.synchronize] (or (text\= (format expected_As expected_Bs) outcome) @@ -166,10 +166,11 @@ expected_ids (enum.range n.enum 0 (dec limit))] _ (|> expected_ids (list\map (function (_ id) - (exec (io.run (atom.update! (|>> (format suffix)) resource)) + (exec + (io.run! (atom.update! (|>> (format suffix)) resource)) (waiter resource barrier id)))) (monad.seq !)) - .let [outcome (io.run (atom.read! resource))]] + .let [outcome (io.run! (atom.read! resource))]] (_.cover' [/.barrier /.block] (and (text.ends_with? expected_ending outcome) (list.every? (function (_ id) diff --git a/stdlib/source/test/lux/control/concurrency/stm.lux b/stdlib/source/test/lux/control/concurrency/stm.lux index 7c9b3137d..3b0b5cf72 100644 --- a/stdlib/source/test/lux/control/concurrency/stm.lux +++ b/stdlib/source/test/lux/control/concurrency/stm.lux @@ -81,7 +81,7 @@ output)))) (in (do async.monad [.let [box (/.var dummy) - [follower sink] (io.run (/.follow box))] + [follower sink] (io.run! (/.follow box))] _ (/.commit (/.write expected box)) _ (/.commit (/.update (n.* 2) box)) _ (async.future (\ sink close)) diff --git a/stdlib/source/test/lux/control/continuation.lux b/stdlib/source/test/lux/control/continuation.lux index a0dcec237..357c87d61 100644 --- a/stdlib/source/test/lux/control/continuation.lux +++ b/stdlib/source/test/lux/control/continuation.lux @@ -25,7 +25,7 @@ (def: comparison (Comparison /.Cont) (function (_ == left right) - (== (/.run left) (/.run right)))) + (== (/.result left) (/.result right)))) (def: .public test Test @@ -44,27 +44,27 @@ (_.for [/.monad] ($monad.spec ..injection ..comparison /.monad)) - (_.cover [/.run] - (n.= sample (/.run (_\in sample)))) + (_.cover [/.result] + (n.= sample (/.result (_\in sample)))) (_.cover [/.call/cc] (n.= (n.* 2 sample) - (/.run (do {! /.monad} - [value (/.call/cc - (function (_ k) - (do ! - [temp (k sample)] - ... If this code where to run, - ... the output would be - ... (n.* 4 sample) - (k temp))))] - (in (n.* 2 value)))))) + (/.result (do {! /.monad} + [value (/.call/cc + (function (_ k) + (do ! + [temp (k sample)] + ... If this code where to run, + ... the output would be + ... (n.* 4 sample) + (k temp))))] + (in (n.* 2 value)))))) (_.cover [/.portal] (n.= (n.+ 100 sample) - (/.run (do /.monad - [[restart [output idx]] (/.portal [sample 0])] - (if (n.< 10 idx) - (restart [(n.+ 10 output) (inc idx)]) - (in output)))))) + (/.result (do /.monad + [[restart [output idx]] (/.portal [sample 0])] + (if (n.< 10 idx) + (restart [(n.+ 10 output) (inc idx)]) + (in output)))))) (_.cover [/.shift /.reset] (let [(^open "_\.") /.monad (^open "list\.") (list.equivalence n.equivalence) @@ -83,7 +83,7 @@ (in (#.Item x tail)))))] (visit output)))))] (list\= elems - (/.run (/.reset (visit elems)))))) + (/.result (/.reset (visit elems)))))) (_.cover [/.continue] (/.continue (is? sample) (: (/.Cont Nat Bit) diff --git a/stdlib/source/test/lux/control/function/memo.lux b/stdlib/source/test/lux/control/function/memo.lux index b5bea4224..a91f2a69a 100644 --- a/stdlib/source/test/lux/control/function/memo.lux +++ b/stdlib/source/test/lux/control/function/memo.lux @@ -62,7 +62,7 @@ (_.for [/.Memo]) ($_ _.and (_.cover [/.closed /.none] - (io.run + (io.run! (do io.monad [.let [slow (/.none n.hash ..fibonacci) fast (/.closed n.hash fibonacci)] @@ -78,7 +78,7 @@ (in (and same_output! memo_is_faster!))))) (_.cover [/.open] - (io.run + (io.run! (do io.monad [.let [none (/.none n.hash ..fibonacci) memory (dictionary.empty n.hash) @@ -102,7 +102,7 @@ incrementalism_is_faster!))))) (_.cover [/.memoization] (let [memo (<| //.mixin - (//.inherit /.memoization) + (//.with /.memoization) (: (//.Mixin Nat (State (Dictionary Nat Nat) Nat)) (function (factorial delegate recur input) (case input @@ -114,7 +114,7 @@ (list\map inc) (list\fold n.* 1)) actual (|> (memo input) - (state.run (dictionary.empty n.hash)) + (state.result (dictionary.empty n.hash)) product.right)] (n.= expected actual))) ))) diff --git a/stdlib/source/test/lux/control/function/mixin.lux b/stdlib/source/test/lux/control/function/mixin.lux index 5cd283eaa..19e67b7aa 100644 --- a/stdlib/source/test/lux/control/function/mixin.lux +++ b/stdlib/source/test/lux/control/function/mixin.lux @@ -55,7 +55,7 @@ _ (n.* input (recur (dec input))))))] (n.= expected (factorial input)))) - (_.cover [/.inherit] + (_.cover [/.with] (let [bottom (: (/.Mixin Nat Nat) (function (_ delegate recur input) (case input @@ -64,7 +64,7 @@ multiplication (: (/.Mixin Nat Nat) (function (_ delegate recur input) (n.* input (recur (dec input))))) - factorial (/.mixin (/.inherit bottom multiplication))] + factorial (/.mixin (/.with bottom multiplication))] (n.= expected (factorial input)))) (_.cover [/.nothing] @@ -73,8 +73,8 @@ (case input (^or 0 1) 1 _ (n.* input (delegate (dec input)))))) - left (/.mixin (/.inherit /.nothing loop)) - right (/.mixin (/.inherit loop /.nothing))] + left (/.mixin (/.with /.nothing loop)) + right (/.mixin (/.with loop /.nothing))] (and (n.= expected (left input)) (n.= expected @@ -91,8 +91,8 @@ multiplication (: (/.Mixin Nat Nat) (function (_ delegate recur input) (n.* input (recur (dec input))))) - factorial (/.mixin (/.inherit (/.advice bottom? bottom) - multiplication))] + factorial (/.mixin (/.with (/.advice bottom? bottom) + multiplication))] (n.= expected (factorial input)))) (_.cover [/.before] @@ -104,10 +104,10 @@ (function (_ delegate recur input) (function (_ state) [state (n.+ state input)]))) - function (/.mixin (/.inherit (/.before state.monad implant) - meld))] + function (/.mixin (/.with (/.before state.monad implant) + meld))] (n.= (n.+ shift input) - (|> input function (state.run dummy) product.right)))) + (|> input function (state.result dummy) product.right)))) (_.cover [/.after] (let [implant (: (-> Nat Nat (State Nat [])) (function (_ input output) @@ -117,10 +117,10 @@ (function (_ delegate recur input) (function (_ state) [state (n.+ state input)]))) - function (/.mixin (/.inherit (/.after state.monad implant) - meld))] + function (/.mixin (/.with (/.after state.monad implant) + meld))] (n.= (n.+ dummy input) - (|> input function (state.run dummy) product.right)))) + (|> input function (state.result dummy) product.right)))) )) (_.for [/.Recursive] (_.cover [/.of_recursive] diff --git a/stdlib/source/test/lux/control/io.lux b/stdlib/source/test/lux/control/io.lux index 43d891a61..51b5864ae 100644 --- a/stdlib/source/test/lux/control/io.lux +++ b/stdlib/source/test/lux/control/io.lux @@ -24,7 +24,7 @@ (def: comparison (Comparison IO) (function (_ == left right) - (== (/.run left) (/.run right)))) + (== (/.run! left) (/.run! right)))) (def: .public test Test @@ -41,7 +41,7 @@ (_.for [/.monad] ($monad.spec ..injection ..comparison /.monad)) - (_.cover [/.run /.io] + (_.cover [/.run! /.io] (n.= sample - (/.run (/.io sample)))) + (/.run! (/.io sample)))) )))) diff --git a/stdlib/source/test/lux/data/lazy.lux b/stdlib/source/test/lux/control/lazy.lux index c9de9cb25..c9de9cb25 100644 --- a/stdlib/source/test/lux/data/lazy.lux +++ b/stdlib/source/test/lux/control/lazy.lux diff --git a/stdlib/source/test/lux/data/maybe.lux b/stdlib/source/test/lux/control/maybe.lux index dd32c20db..a2a85eae1 100644 --- a/stdlib/source/test/lux/data/maybe.lux +++ b/stdlib/source/test/lux/control/maybe.lux @@ -51,10 +51,10 @@ .let [expected (n.+ left right)]] (let [lift (/.lift io.monad)] (_.cover [/.with /.lift] - (|> (io.run (do (/.with io.monad) - [a (lift (io\in left)) - b (in right)] - (in (n.+ a b)))) + (|> (io.run! (do (/.with io.monad) + [a (lift (io\in left)) + b (in right)] + (in (n.+ a b)))) (case> (#.Some actual) (n.= expected actual) diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index 7b183db51..224943369 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -51,7 +51,7 @@ (def: (enforced? parser input) (All [s] (-> (Parser s Any) s Bit)) - (case (/.run parser input) + (case (/.result parser input) (#try.Success [_ []]) #1 @@ -60,7 +60,7 @@ (def: (found? parser input) (All [s] (-> (Parser s Bit) s Bit)) - (case (/.run parser input) + (case (/.result parser input) (#try.Success [_ #1]) #1 @@ -96,82 +96,82 @@ ($_ _.and (_.cover [/.maybe] (and (|> (list (code.nat expected0)) - (/.run (/.maybe <code>.nat)) + (/.result (/.maybe <code>.nat)) (match (#.Some actual) (n.= expected0 actual))) (|> (list (code.int (.int expected0))) - (/.run (/.maybe <code>.nat)) + (/.result (/.maybe <code>.nat)) (match #.None #1)))) (_.cover [/.some] (and (|> (list\map code.nat expected+) - (/.run (/.some <code>.nat)) + (/.result (/.some <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual))) (|> (list\map (|>> .int code.int) expected+) - (/.run (/.some <code>.nat)) + (/.result (/.some <code>.nat)) (match #.End #1)))) (_.cover [/.many] (and (|> (list\map code.nat expected+) - (/.run (/.many <code>.nat)) + (/.result (/.many <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual))) (|> (list (code.nat expected0)) - (/.run (/.many <code>.nat)) + (/.result (/.many <code>.nat)) (match (list actual) (n.= expected0 actual))) (|> (list\map (|>> .int code.int) expected+) - (/.run (/.many <code>.nat)) + (/.result (/.many <code>.nat)) fails?))) (_.cover [/.only] (and (|> (list (code.nat even0)) - (/.run (/.only n.even? <code>.nat)) + (/.result (/.only n.even? <code>.nat)) (match actual (n.= even0 actual))) (|> (list (code.nat odd0)) - (/.run (/.only n.even? <code>.nat)) + (/.result (/.only n.even? <code>.nat)) fails?))) (_.cover [/.and] (let [even (/.only n.even? <code>.nat) odd (/.only n.odd? <code>.nat)] (and (|> (list (code.nat even0) (code.nat odd0)) - (/.run (/.and even odd)) + (/.result (/.and even odd)) (match [left right] (and (n.= even0 left) (n.= odd0 right)))) (|> (list (code.nat odd0) (code.nat even0)) - (/.run (/.and even odd)) + (/.result (/.and even odd)) fails?)))) (_.cover [/.or] (let [even (/.only n.even? <code>.nat) odd (/.only n.odd? <code>.nat)] (and (|> (list (code.nat even0)) - (/.run (/.or even odd)) + (/.result (/.or even odd)) (match (#.Left actual) (n.= even0 actual))) (|> (list (code.nat odd0)) - (/.run (/.or even odd)) + (/.result (/.or even odd)) (match (#.Right actual) (n.= odd0 actual))) (|> (list (code.bit not0)) - (/.run (/.or even odd)) + (/.result (/.or even odd)) fails?)))) (_.cover [/.either] (let [even (/.only n.even? <code>.nat) odd (/.only n.odd? <code>.nat)] (and (|> (list (code.nat even0)) - (/.run (/.either even odd)) + (/.result (/.either even odd)) (match actual (n.= even0 actual))) (|> (list (code.nat odd0)) - (/.run (/.either even odd)) + (/.result (/.either even odd)) (match actual (n.= odd0 actual))) (|> (list (code.bit not0)) - (/.run (/.either even odd)) + (/.result (/.either even odd)) fails?)))) (_.cover [/.not] (and (|> (list (code.nat expected0)) - (/.run (/.not <code>.nat)) + (/.result (/.not <code>.nat)) fails?) (|> (list (code.bit not0)) - (/.run (/.not <code>.nat)) + (/.result (/.not <code>.nat)) (match [] #1)))) ))) @@ -187,70 +187,70 @@ ($_ _.and (_.cover [/.exactly] (and (|> (list\map code.nat expected+) - (/.run (/.exactly times <code>.nat)) + (/.result (/.exactly times <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = (list.take times expected+) actual))) (|> (list\map code.nat expected+) - (/.run (/.exactly (inc variadic) <code>.nat)) + (/.result (/.exactly (inc variadic) <code>.nat)) fails?))) (_.cover [/.at_least] (and (|> (list\map code.nat expected+) - (/.run (/.at_least times <code>.nat)) + (/.result (/.at_least times <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual))) (|> (list\map code.nat expected+) - (/.run (/.at_least (inc variadic) <code>.nat)) + (/.result (/.at_least (inc variadic) <code>.nat)) fails?))) (_.cover [/.at_most] (and (|> (list\map code.nat expected+) - (/.run (/.at_most times <code>.nat)) + (/.result (/.at_most times <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = (list.take times expected+) actual))) (|> (list\map code.nat expected+) - (/.run (/.at_most (inc variadic) <code>.nat)) + (/.result (/.at_most (inc variadic) <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual))))) (_.cover [/.between] (and (|> (list\map code.nat expected+) - (/.run (/.between times (n.- times variadic) <code>.nat)) + (/.result (/.between times (n.- times variadic) <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual))) (|> (list\map code.nat (list.take times expected+)) - (/.run (/.between times (n.- times variadic) <code>.nat)) + (/.result (/.between times (n.- times variadic) <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = (list.take times expected+) actual))))) (_.cover [/.separated_by] - (|> (list.interpose (code.text separator) (list\map code.nat expected+)) - (/.run (/.separated_by (<code>.this! (code.text separator)) <code>.nat)) + (|> (list.interposed (code.text separator) (list\map code.nat expected+)) + (/.result (/.separated_by (<code>.this! (code.text separator)) <code>.nat)) (match actual (\ (list.equivalence n.equivalence) = expected+ actual)))) (_.cover [/.remaining] (|> (list\map code.nat expected+) - (/.run /.remaining) + (/.result /.remaining) (match actual (\ (list.equivalence code.equivalence) = (list\map code.nat expected+) actual)))) (_.cover [/.else] - (and (|> (/.run (/.else wrong (\ /.monad in expected)) (list)) + (and (|> (/.result (/.else wrong (\ /.monad in expected)) (list)) (match actual (n.= expected actual))) - (|> (/.run (/.else expected (: (Parser (List Code) Nat) - (/.failure "yolo"))) - (list)) + (|> (/.result (/.else expected (: (Parser (List Code) Nat) + (/.failure "yolo"))) + (list)) (match actual (n.= expected actual))) )) ))) @@ -273,59 +273,59 @@ level_up (: (-> Code Code) (|>> list code.tuple))] (and (|> (list level_0) - (/.run parser) + (/.result parser) (match actual (n.= expected actual))) (|> (list (level_up level_0)) - (/.run parser) + (/.result parser) (match actual (n.= expected actual))) (|> (list (level_up (level_up level_0))) - (/.run parser) + (/.result parser) (match actual (n.= expected actual)))))) (_.cover [/.after] - (and (|> (/.run (/.after even^ <code>.nat) - (list (code.nat even) (code.nat expected))) + (and (|> (/.result (/.after even^ <code>.nat) + (list (code.nat even) (code.nat expected))) (match actual (n.= expected actual))) - (|> (/.run (/.after even^ <code>.nat) - (list (code.nat odd) (code.nat expected))) + (|> (/.result (/.after even^ <code>.nat) + (list (code.nat odd) (code.nat expected))) fails?))) (_.cover [/.before] - (and (|> (/.run (/.before even^ <code>.nat) - (list (code.nat expected) (code.nat even))) + (and (|> (/.result (/.before even^ <code>.nat) + (list (code.nat expected) (code.nat even))) (match actual (n.= expected actual))) - (|> (/.run (/.before even^ <code>.nat) - (list (code.nat expected) (code.nat odd))) + (|> (/.result (/.before even^ <code>.nat) + (list (code.nat expected) (code.nat odd))) fails?))) (_.cover [/.parses?] - (and (|> (/.run (/.parses? even^) - (list (code.nat even))) + (and (|> (/.result (/.parses? even^) + (list (code.nat even))) (match verdict verdict)) - (|> (/.run (/.parses? even^) - (list (code.nat odd))) + (|> (/.result (/.parses? even^) + (list (code.nat odd))) (match verdict (not verdict))))) (_.cover [/.parses] - (and (|> (/.run (/.parses even^) - (list (code.nat even))) + (and (|> (/.result (/.parses even^) + (list (code.nat even))) (match [] true)) - (|> (/.run (/.parses even^) - (list (code.nat odd))) + (|> (/.result (/.parses even^) + (list (code.nat odd))) fails?))) (_.cover [/.speculative] (let [happy_path! - (|> (/.run (/.and (/.speculative even^) nat^) - (list (code.nat even))) + (|> (/.result (/.and (/.speculative even^) nat^) + (list (code.nat even))) (match [speculation actual] (and (n.= speculation actual) (n.= even actual)))) sad_path! - (|> (/.run (/.and (/.speculative even^) nat^) - (list (code.nat odd))) + (|> (/.result (/.and (/.speculative even^) nat^) + (list (code.nat odd))) fails?)] (and happy_path! sad_path!))) (_.cover [/.codec] - (|> (/.run (/.codec n.decimal <code>.text) - (list (code.text (%.nat expected)))) + (|> (/.result (/.codec n.decimal <code>.text) + (list (code.text (%.nat expected)))) (match actual (n.= expected actual)))) ))) @@ -336,7 +336,7 @@ (def: comparison (Comparison (All [a i] (Parser i a))) (function (_ == left right) - (case [(/.run left []) (/.run right [])] + (case [(/.result left []) (/.result right [])] [(#try.Success [_ left]) (#try.Success [_ right])] (== left right) @@ -359,26 +359,26 @@ (_.for [/.monad] ($monad.spec ..injection ..comparison /.monad)) - (_.cover [/.run] - (|> (/.run (\ /.monad in expected) (list)) + (_.cover [/.result] + (|> (/.result (\ /.monad in expected) (list)) (match actual (n.= expected actual)))) (_.cover [/.failure] (|> (list) - (/.run (/.failure failure)) + (/.result (/.failure failure)) (should_fail failure))) (_.cover [/.lift] (and (|> (list) - (/.run (/.lift (#try.Success expected))) + (/.result (/.lift (#try.Success expected))) (match actual (n.= expected actual))) (|> (list) - (/.run (/.lift (#try.Failure failure))) + (/.result (/.lift (#try.Failure failure))) (should_fail failure)))) (_.cover [/.assertion] (and (|> (list (code.bit #1) (code.int +123)) - (/.run (/.assertion assertion #1)) + (/.result (/.assertion assertion #1)) (match [] true)) (|> (list (code.bit #1) (code.int +123)) - (/.run (/.assertion assertion #0)) + (/.result (/.assertion assertion #0)) fails?))) ..combinators_0 ..combinators_1 diff --git a/stdlib/source/test/lux/control/parser/analysis.lux b/stdlib/source/test/lux/control/parser/analysis.lux index 8b7f6405f..85ab04863 100644 --- a/stdlib/source/test/lux/control/parser/analysis.lux +++ b/stdlib/source/test/lux/control/parser/analysis.lux @@ -54,9 +54,9 @@ (`` ($_ _.and (do {! random.monad} [expected (\ ! map (|>> analysis.bit) random.bit)] - (_.cover [/.run /.any] + (_.cover [/.result /.any] (|> (list expected) - (/.run /.any) + (/.result /.any) (case> (#try.Success actual) (\ analysis.equivalence = expected actual) @@ -67,7 +67,7 @@ [expected <random>] (_.cover [<query>] (|> (list (<analysis> expected)) - (/.run <query>) + (/.result <query>) (case> (#try.Success actual) (<=> expected actual) @@ -77,7 +77,7 @@ [expected <random>] (_.cover [<check>] (|> (list (<analysis> expected)) - (/.run (<check> expected)) + (/.result (<check> expected)) (!expect (#try.Success _)))))] [/.bit /.bit! random.bit analysis.bit bit\=] @@ -94,7 +94,7 @@ [expected random.bit] (_.cover [/.tuple] (|> (list (analysis.tuple (list (analysis.bit expected)))) - (/.run (/.tuple /.bit)) + (/.result (/.tuple /.bit)) (case> (#try.Success actual) (bit\= expected actual) @@ -103,33 +103,33 @@ (do {! random.monad} [dummy random.bit] (_.cover [/.end?] - (and (|> (/.run /.end? (list)) + (and (|> (/.result /.end? (list)) (!expect (#try.Success #1))) - (|> (/.run (do <>.monad - [verdict /.end? - _ /.bit] - (in verdict)) - (list (analysis.bit dummy))) + (|> (/.result (do <>.monad + [verdict /.end? + _ /.bit] + (in verdict)) + (list (analysis.bit dummy))) (!expect (#try.Success #0)))))) (do {! random.monad} [dummy random.bit] (_.cover [/.end!] - (and (|> (/.run /.end! (list)) + (and (|> (/.result /.end! (list)) (!expect (#try.Success _))) - (|> (/.run /.end! (list (analysis.bit dummy))) + (|> (/.result /.end! (list (analysis.bit dummy))) (!expect (#try.Failure _)))))) (do {! random.monad} [expected random.bit] (_.cover [/.cannot_parse] (and (|> (list (analysis.bit expected)) - (/.run /.nat) + (/.result /.nat) (case> (#try.Success _) false (#try.Failure error) (exception.match? /.cannot_parse error))) (|> (list) - (/.run /.bit) + (/.result /.bit) (case> (#try.Success _) false @@ -139,7 +139,7 @@ [expected random.bit] (_.cover [/.unconsumed_input] (|> (list (analysis.bit expected) (analysis.bit expected)) - (/.run /.bit) + (/.result /.bit) (case> (#try.Success _) false diff --git a/stdlib/source/test/lux/control/parser/binary.lux b/stdlib/source/test/lux/control/parser/binary.lux index e86718715..50233ba6e 100644 --- a/stdlib/source/test/lux/control/parser/binary.lux +++ b/stdlib/source/test/lux/control/parser/binary.lux @@ -9,13 +9,13 @@ [monad (#+ do)]] [control [pipe (#+ case>)] - ["<>" parser] + ["." maybe] ["." try] - ["." exception]] + ["." exception] + ["<>" parser]] [data ["." binary] ["." sum] - ["." maybe] ["." bit] ["." name] ["." text ("#\." equivalence) @@ -131,8 +131,8 @@ [expected (\ ! map (i64.and (i64.mask <size>)) random.nat)] (_.cover [<size> <parser> <format>] - (|> (format.run <format> expected) - (/.run <parser>) + (|> (format.result <format> expected) + (/.result <parser>) (!expect (^multi (#try.Success actual) (n.= (.nat expected) (.nat actual)))))))] @@ -150,8 +150,8 @@ [(do {! random.monad} [expected (\ ! map (\ utf8.codec encode) (random.ascii ..segment_size))] (_.cover [<parser> <format>] - (|> (format.run <format> expected) - (/.run <parser>) + (|> (format.result <format> expected) + (/.result <parser>) (!expect (^multi (#try.Success actual) (\ binary.equivalence = expected actual))))))] @@ -168,8 +168,8 @@ [(do {! random.monad} [expected (random.ascii ..segment_size)] (_.cover [<parser> <format>] - (|> (format.run <format> expected) - (/.run <parser>) + (|> (format.result <format> expected) + (/.result <parser>) (!expect (^multi (#try.Success actual) (\ text.equivalence = expected actual))))))] @@ -188,8 +188,8 @@ [expected (random.row ..segment_size random.nat)] (_.cover [<parser> <format>] (|> expected - (format.run (<format> format.nat)) - (/.run (<parser> /.nat)) + (format.result (<format> format.nat)) + (/.result (<parser> /.nat)) (!expect (^multi (#try.Success actual) (\ (row.equivalence n.equivalence) = expected actual))))))] @@ -207,8 +207,8 @@ [expected <random>] (_.cover [<parser> <format>] (|> expected - (format.run <format>) - (/.run <parser>) + (format.result <format>) + (/.result <parser>) (!expect (^multi (#try.Success actual) (\ <equivalence> = expected actual))))))] @@ -220,8 +220,8 @@ [expected random.frac] (_.cover [/.frac format.frac] (|> expected - (format.run format.frac) - (/.run /.frac) + (format.result format.frac) + (/.result /.frac) (!expect (^multi (#try.Success actual) (or (\ frac.equivalence = expected actual) (and (frac.not_a_number? expected) @@ -232,8 +232,8 @@ random.nat)] (_.cover [/.not_a_bit] (|> expected - (format.run format.bits/8) - (/.run /.bit) + (format.result format.bits/8) + (/.result /.bit) (!expect (^multi (#try.Failure error) (exception.match? /.not_a_bit error)))))) ))) @@ -246,8 +246,8 @@ [expected <random>] (_.cover [<parser> <format>] (|> expected - (format.run <format>) - (/.run <parser>) + (format.result <format>) + (/.result <parser>) (!expect (^multi (#try.Success actual) (\ <equivalence> = expected actual))))))] @@ -260,8 +260,8 @@ [expected <random>] (_.cover [<parser_coverage> <coverage_format>] (|> expected - (format.run <format>) - (/.run <parser>) + (format.result <format>) + (/.result <parser>) (!expect (^multi (#try.Success actual) (\ <equivalence> = expected actual))))))] @@ -273,17 +273,17 @@ [expected (\ ! map (list.repeated ..segment_size) random.nat)] (_.cover [/.set_elements_are_not_unique] (|> expected - (format.run (format.list format.nat)) - (/.run (/.set n.hash /.nat)) + (format.result (format.list format.nat)) + (/.result (/.set n.hash /.nat)) (!expect (^multi (#try.Failure error) (exception.match? /.set_elements_are_not_unique error)))))) (do {! random.monad} [expected (random.or random.bit random.nat)] (_.cover [/.or format.or] (|> expected - (format.run (format.or format.bit format.nat)) - (/.run (: (/.Parser (Either Bit Nat)) - (/.or /.bit /.nat))) + (format.result (format.or format.bit format.nat)) + (/.result (: (/.Parser (Either Bit Nat)) + (/.or /.bit /.nat))) (!expect (^multi (#try.Success actual) (\ (sum.equivalence bit.equivalence n.equivalence) = expected @@ -295,23 +295,23 @@ value random.bit] (_.cover [/.invalid_tag] (|> [tag value] - (format.run (format.and format.bits/8 format.bit)) - (/.run (: (/.Parser (Either Bit Nat)) - (/.or /.bit /.nat))) + (format.result (format.and format.bits/8 format.bit)) + (/.result (: (/.Parser (Either Bit Nat)) + (/.or /.bit /.nat))) (!expect (^multi (#try.Failure error) (exception.match? /.invalid_tag error)))))) (do {! random.monad} [expected (random.list ..segment_size random.nat)] (_.cover [/.rec format.rec format.and format.any] (|> expected - (format.run (format.rec (|>> (format.and format.nat) - (format.or format.any)))) - (/.run (: (/.Parser (List Nat)) - (/.rec - (function (_ recur) - (/.or /.any - (<>.and /.nat - recur)))))) + (format.result (format.rec (|>> (format.and format.nat) + (format.or format.any)))) + (/.result (: (/.Parser (List Nat)) + (/.rec + (function (_ recur) + (/.or /.any + (<>.and /.nat + recur)))))) (!expect (^multi (#try.Success actual) (\ (list.equivalence n.equivalence) = expected @@ -323,65 +323,65 @@ (<| (_.covering /._) (_.for [/.Parser]) (`` ($_ _.and - (_.cover [/.run /.any + (_.cover [/.result /.any format.no_op format.instance] (|> (format.instance format.no_op) - (/.run /.any) + (/.result /.any) (!expect (#try.Success _)))) (do {! random.monad} [data (\ ! map (\ utf8.codec encode) (random.ascii ..segment_size))] (_.cover [/.binary_was_not_fully_read] (|> data - (/.run /.any) + (/.result /.any) (!expect (^multi (#try.Failure error) (exception.match? /.binary_was_not_fully_read error)))))) (do {! random.monad} [expected (\ ! map (\ utf8.codec encode) (random.ascii ..segment_size))] - (_.cover [/.segment format.segment format.run] + (_.cover [/.segment format.segment format.result] (|> expected - (format.run (format.segment ..segment_size)) - (/.run (/.segment ..segment_size)) + (format.result (format.segment ..segment_size)) + (/.result (/.segment ..segment_size)) (!expect (^multi (#try.Success actual) (\ binary.equivalence = expected actual)))))) (do {! random.monad} [data (\ ! map (\ utf8.codec encode) (random.ascii ..segment_size))] (_.cover [/.end?] (|> data - (/.run (do <>.monad - [pre /.end? - _ (/.segment ..segment_size) - post /.end?] - (in (and (not pre) - post)))) + (/.result (do <>.monad + [pre /.end? + _ (/.segment ..segment_size) + post /.end?] + (in (and (not pre) + post)))) (!expect (#try.Success #1))))) (do {! random.monad} [to_read (\ ! map (n.% (inc ..segment_size)) random.nat) data (\ ! map (\ utf8.codec encode) (random.ascii ..segment_size))] (_.cover [/.Offset /.offset] (|> data - (/.run (do <>.monad - [start /.offset - _ (/.segment to_read) - offset /.offset - _ (/.segment (n.- to_read ..segment_size)) - nothing_left /.offset] - (in (and (n.= 0 start) - (n.= to_read offset) - (n.= ..segment_size nothing_left))))) + (/.result (do <>.monad + [start /.offset + _ (/.segment to_read) + offset /.offset + _ (/.segment (n.- to_read ..segment_size)) + nothing_left /.offset] + (in (and (n.= 0 start) + (n.= to_read offset) + (n.= ..segment_size nothing_left))))) (!expect (#try.Success #1))))) (do {! random.monad} [to_read (\ ! map (n.% (inc ..segment_size)) random.nat) data (\ ! map (\ utf8.codec encode) (random.ascii ..segment_size))] (_.cover [/.remaining] (|> data - (/.run (do <>.monad - [_ (/.segment to_read) - remaining /.remaining - _ (/.segment (n.- to_read ..segment_size)) - nothing_left /.remaining] - (in (and (n.= ..segment_size - (n.+ to_read remaining)) - (n.= 0 nothing_left))))) + (/.result (do <>.monad + [_ (/.segment to_read) + remaining /.remaining + _ (/.segment (n.- to_read ..segment_size)) + nothing_left /.remaining] + (in (and (n.= ..segment_size + (n.+ to_read remaining)) + (n.= 0 nothing_left))))) (!expect (#try.Success #1))))) ..size ..binary diff --git a/stdlib/source/test/lux/control/parser/cli.lux b/stdlib/source/test/lux/control/parser/cli.lux index 33476e15a..ffe943eb6 100644 --- a/stdlib/source/test/lux/control/parser/cli.lux +++ b/stdlib/source/test/lux/control/parser/cli.lux @@ -40,44 +40,44 @@ pre_ignore (random.list 5 random_dummy) post_ignore (random.list 5 random_dummy)] ($_ _.and - (_.cover [/.run /.any] - (|> (/.run /.any (list expected)) + (_.cover [/.result /.any] + (|> (/.result /.any (list expected)) (!expect (^multi (#try.Success actual) (text\= expected actual))))) (_.cover [/.parse] - (|> (/.run (/.parse n\decode) (list expected)) + (|> (/.result (/.parse n\decode) (list expected)) (!expect (^multi (#try.Success actual) (text\= expected (n\encode actual)))))) (_.cover [/.this] - (and (|> (/.run (/.this expected) (list expected)) + (and (|> (/.result (/.this expected) (list expected)) (!expect (#try.Success _))) - (|> (/.run (/.this expected) (list dummy)) + (|> (/.result (/.this expected) (list dummy)) (!expect (#try.Failure _))))) (_.cover [/.somewhere] - (|> (/.run (|> (/.somewhere (/.this expected)) - (<>.before (<>.some /.any))) - (list.concat (list pre_ignore (list expected) post_ignore))) + (|> (/.result (|> (/.somewhere (/.this expected)) + (<>.before (<>.some /.any))) + (list.concat (list pre_ignore (list expected) post_ignore))) (!expect (#try.Success _)))) (_.cover [/.end] - (and (|> (/.run /.end (list)) + (and (|> (/.result /.end (list)) (!expect (#try.Success _))) - (|> (/.run (<>.not /.end) (list expected)) + (|> (/.result (<>.not /.end) (list expected)) (!expect (#try.Failure _))))) (_.cover [/.named] - (|> (/.run (/.named dummy /.any) (list dummy expected)) + (|> (/.result (/.named dummy /.any) (list dummy expected)) (!expect (^multi (#try.Success actual) (text\= expected actual))))) (_.cover [/.parameter] - (and (|> (/.run (/.parameter [short long] /.any) - (list short expected)) + (and (|> (/.result (/.parameter [short long] /.any) + (list short expected)) (!expect (^multi (#try.Success actual) (text\= expected actual)))) - (|> (/.run (/.parameter [short long] /.any) - (list long expected)) + (|> (/.result (/.parameter [short long] /.any) + (list long expected)) (!expect (^multi (#try.Success actual) (text\= expected actual)))) - (|> (/.run (/.parameter [short long] /.any) - (list dummy expected)) + (|> (/.result (/.parameter [short long] /.any) + (list dummy expected)) (!expect (#try.Failure _))))) )))) diff --git a/stdlib/source/test/lux/control/parser/code.lux b/stdlib/source/test/lux/control/parser/code.lux index d2168122a..b6a3768d4 100644 --- a/stdlib/source/test/lux/control/parser/code.lux +++ b/stdlib/source/test/lux/control/parser/code.lux @@ -46,10 +46,10 @@ (`` ($_ _.and (do {! random.monad} [expected (\ ! map code.bit random.bit)] - (_.cover [/.run] - (and (|> (/.run /.any (list expected)) + (_.cover [/.result] + (and (|> (/.result /.any (list expected)) (!expect (#try.Success _))) - (|> (/.run /.any (list)) + (|> (/.result /.any (list)) (!expect (#try.Failure _)))))) (~~ (template [<query> <check> <random> <code> <equivalence>] [(do {! random.monad} @@ -57,13 +57,13 @@ dummy (|> <random> (random.only (|>> (\ <equivalence> = expected) not)))] ($_ _.and (_.cover [<query>] - (|> (/.run <query> (list (<code> expected))) + (|> (/.result <query> (list (<code> expected))) (!expect (^multi (#try.Success actual) (\ <equivalence> = expected actual))))) (_.cover [<check>] - (and (|> (/.run (<check> expected) (list (<code> expected))) + (and (|> (/.result (<check> expected) (list (<code> expected))) (!expect (#try.Success []))) - (|> (/.run (<check> expected) (list (<code> dummy))) + (|> (/.result (<check> expected) (list (<code> dummy))) (!expect (#try.Failure _))))) ))] @@ -84,9 +84,9 @@ [expected_left random.nat expected_right random.int] (_.cover [<query>] - (|> (/.run (<query> (<>.and /.nat /.int)) - (list (<code> (list (code.nat expected_left) - (code.int expected_right))))) + (|> (/.result (<query> (<>.and /.nat /.int)) + (list (<code> (list (code.nat expected_left) + (code.int expected_right))))) (!expect (^multi (#try.Success [actual_left actual_right]) (and (\ nat.equivalence = expected_left actual_left) (\ int.equivalence = expected_right actual_right)))))))] @@ -98,9 +98,9 @@ [expected_left random.nat expected_right random.int] (_.cover [/.record] - (|> (/.run (/.record (<>.and /.nat /.int)) - (list (code.record (list [(code.nat expected_left) - (code.int expected_right)])))) + (|> (/.result (/.record (<>.and /.nat /.int)) + (list (code.record (list [(code.nat expected_left) + (code.int expected_right)])))) (!expect (^multi (#try.Success [actual_left actual_right]) (and (\ nat.equivalence = expected_left actual_left) (\ int.equivalence = expected_right actual_right))))))) @@ -108,29 +108,29 @@ [expected_local random.nat expected_global random.int] (_.cover [/.local] - (|> (/.run (<>.and (/.local (list (code.nat expected_local)) /.nat) - /.int) - (list (code.int expected_global))) + (|> (/.result (<>.and (/.local (list (code.nat expected_local)) /.nat) + /.int) + (list (code.int expected_global))) (!expect (^multi (#try.Success [actual_local actual_global]) (and (\ nat.equivalence = expected_local actual_local) (\ int.equivalence = expected_global actual_global))))))) (do {! random.monad} [dummy (\ ! map code.bit random.bit)] (_.cover [/.end?] - (|> (/.run (do <>.monad - [pre /.end? - _ /.any - post /.end?] - (in (and (not pre) - post))) - (list dummy)) + (|> (/.result (do <>.monad + [pre /.end? + _ /.any + post /.end?] + (in (and (not pre) + post))) + (list dummy)) (!expect (^multi (#try.Success verdict) verdict))))) (do {! random.monad} [dummy (\ ! map code.bit random.bit)] (_.cover [/.end!] - (and (|> (/.run /.end! (list)) + (and (|> (/.result /.end! (list)) (!expect (#try.Success []))) - (|> (/.run /.end! (list dummy)) + (|> (/.result /.end! (list dummy)) (!expect (#try.Failure _)))))) )))) diff --git a/stdlib/source/test/lux/control/parser/environment.lux b/stdlib/source/test/lux/control/parser/environment.lux index 215213e59..b7a889bbe 100644 --- a/stdlib/source/test/lux/control/parser/environment.lux +++ b/stdlib/source/test/lux/control/parser/environment.lux @@ -28,8 +28,8 @@ (dictionary.empty? /.empty)) (do random.monad [expected random.nat] - (_.cover [/.run] - (|> (/.run (//\in expected) /.empty) + (_.cover [/.result] + (|> (/.result (//\in expected) /.empty) (\ try.functor map (n.= expected)) (try.else false)))) (do random.monad @@ -38,13 +38,13 @@ (_.cover [/.Property /.property] (|> /.empty (dictionary.put property expected) - (/.run (/.property property)) + (/.result (/.property property)) (\ try.functor map (text\= expected)) (try.else false)))) (do random.monad [property (random.ascii/alpha 1)] (_.cover [/.unknown_property] - (case (/.run (/.property property) /.empty) + (case (/.result (/.property property) /.empty) (#try.Success _) false diff --git a/stdlib/source/test/lux/control/parser/json.lux b/stdlib/source/test/lux/control/parser/json.lux index 3a77b3c3e..a87396228 100644 --- a/stdlib/source/test/lux/control/parser/json.lux +++ b/stdlib/source/test/lux/control/parser/json.lux @@ -6,11 +6,11 @@ [monad (#+ do)]] [control [pipe (#+ case>)] + ["." maybe] ["." try] ["." exception] ["<>" parser]] [data - ["." maybe] ["." bit] ["." text] [collection @@ -47,12 +47,12 @@ (`` ($_ _.and (do {! random.monad} [expected (\ ! map (|>> #json.String) (random.unicode 1))] - (_.cover [/.run /.any] - (|> (/.run /.any expected) + (_.cover [/.result /.any] + (|> (/.result /.any expected) (!expect (^multi (#try.Success actual) (\ json.equivalence = expected actual)))))) (_.cover [/.null] - (|> (/.run /.null #json.Null) + (|> (/.result /.null #json.Null) (!expect (#try.Success _)))) (~~ (template [<query> <test> <check> <random> <json> <equivalence>] [(do {! random.monad} @@ -60,18 +60,18 @@ dummy (|> <random> (random.only (|>> (\ <equivalence> = expected) not)))] ($_ _.and (_.cover [<query>] - (|> (/.run <query> (<json> expected)) + (|> (/.result <query> (<json> expected)) (!expect (^multi (#try.Success actual) (\ <equivalence> = expected actual))))) (_.cover [<test>] - (and (|> (/.run (<test> expected) (<json> expected)) + (and (|> (/.result (<test> expected) (<json> expected)) (!expect (#try.Success #1))) - (|> (/.run (<test> expected) (<json> dummy)) + (|> (/.result (<test> expected) (<json> dummy)) (!expect (#try.Success #0))))) (_.cover [<check>] - (and (|> (/.run (<check> expected) (<json> expected)) + (and (|> (/.result (<check> expected) (<json> expected)) (!expect (#try.Success _))) - (|> (/.run (<check> expected) (<json> dummy)) + (|> (/.result (<check> expected) (<json> dummy)) (!expect (#try.Failure _)))))))] [/.boolean /.boolean? /.boolean! random.bit #json.Boolean bit.equivalence] @@ -82,23 +82,23 @@ [expected (random.unicode 1) dummy random.bit] (_.cover [/.unexpected_value] - (|> (/.run /.string (#json.Boolean dummy)) + (|> (/.result /.string (#json.Boolean dummy)) (!expect (^multi (#try.Failure error) (exception.match? /.unexpected_value error)))))) (do {! random.monad} [expected (random.unicode 1) dummy (|> (random.unicode 1) (random.only (|>> (\ text.equivalence = expected) not)))] (_.cover [/.value_mismatch] - (|> (/.run (/.string! expected) (#json.String dummy)) + (|> (/.result (/.string! expected) (#json.String dummy)) (!expect (^multi (#try.Failure error) (exception.match? /.value_mismatch error)))))) (do {! random.monad} [expected (random.unicode 1)] (_.cover [/.nullable] - (and (|> (/.run (/.nullable /.string) #json.Null) + (and (|> (/.result (/.nullable /.string) #json.Null) (!expect (^multi (#try.Success actual) (\ (maybe.equivalence text.equivalence) = #.None actual)))) - (|> (/.run (/.nullable /.string) (#json.String expected)) + (|> (/.result (/.nullable /.string) (#json.String expected)) (!expect (^multi (#try.Success actual) (\ (maybe.equivalence text.equivalence) = (#.Some expected) actual))))))) (do {! random.monad} @@ -107,18 +107,18 @@ (random.list size) (\ ! map row.of_list))] (_.cover [/.array] - (|> (/.run (/.array (<>.some /.string)) - (#json.Array (row\map (|>> #json.String) expected))) + (|> (/.result (/.array (<>.some /.string)) + (#json.Array (row\map (|>> #json.String) expected))) (!expect (^multi (#try.Success actual) (\ (row.equivalence text.equivalence) = expected (row.of_list actual))))))) (do {! random.monad} [expected (\ ! map (|>> #json.String) (random.unicode 1))] (_.cover [/.unconsumed_input] - (|> (/.run (/.array /.any) (#json.Array (row expected expected))) + (|> (/.result (/.array /.any) (#json.Array (row expected expected))) (!expect (^multi (#try.Failure error) (exception.match? /.unconsumed_input error)))))) (_.cover [/.empty_input] - (|> (/.run (/.array /.any) (#json.Array (row))) + (|> (/.result (/.array /.any) (#json.Array (row))) (!expect (^multi (#try.Failure error) (exception.match? /.empty_input error))))) (do {! random.monad} @@ -133,15 +133,15 @@ _ (undefined)))))] (_.cover [/.object /.field] - (|> (/.run (/.object ($_ <>.and - (/.field boolean_field /.boolean) - (/.field number_field /.number) - (/.field string_field /.string))) - (#json.Object - (dictionary.of_list text.hash - (list [boolean_field (#json.Boolean expected_boolean)] - [number_field (#json.Number expected_number)] - [string_field (#json.String expected_string)])))) + (|> (/.result (/.object ($_ <>.and + (/.field boolean_field /.boolean) + (/.field number_field /.number) + (/.field string_field /.string))) + (#json.Object + (dictionary.of_list text.hash + (list [boolean_field (#json.Boolean expected_boolean)] + [number_field (#json.Number expected_number)] + [string_field (#json.String expected_string)])))) (!expect (^multi (#try.Success [actual_boolean actual_number actual_string]) (and (\ bit.equivalence = expected_boolean actual_boolean) (\ frac.equivalence = expected_number actual_number) @@ -152,12 +152,12 @@ values (random.list size (random.unicode 1)) .let [expected (dictionary.of_list text.hash (list.zipped/2 keys values))]] (_.cover [/.dictionary] - (|> (/.run (/.dictionary /.string) - (#json.Object - (|> values - (list\map (|>> #json.String)) - (list.zipped/2 keys) - (dictionary.of_list text.hash)))) + (|> (/.result (/.dictionary /.string) + (#json.Object + (|> values + (list\map (|>> #json.String)) + (list.zipped/2 keys) + (dictionary.of_list text.hash)))) (!expect (^multi (#try.Success actual) (\ (dictionary.equivalence text.equivalence) = expected actual)))))) )))) diff --git a/stdlib/source/test/lux/control/parser/synthesis.lux b/stdlib/source/test/lux/control/parser/synthesis.lux index 753091e27..068ba1235 100644 --- a/stdlib/source/test/lux/control/parser/synthesis.lux +++ b/stdlib/source/test/lux/control/parser/synthesis.lux @@ -67,13 +67,13 @@ dummy (|> <random> (random.only (|>> (\ <equivalence> = expected) not)))] ($_ _.and (_.cover [<query>] - (|> (/.run <query> (list (<synthesis> expected))) + (|> (/.result <query> (list (<synthesis> expected))) (!expect (^multi (#try.Success actual) (\ <equivalence> = expected actual))))) (_.cover [<check>] - (and (|> (/.run (<check> expected) (list (<synthesis> expected))) + (and (|> (/.result (<check> expected) (list (<synthesis> expected))) (!expect (#try.Success _))) - (|> (/.run (<check> expected) (list (<synthesis> dummy))) + (|> (/.result (<check> expected) (list (<synthesis> dummy))) (!expect (^multi (#try.Failure error) (exception.match? /.cannot_parse error)))))) ))] @@ -97,18 +97,18 @@ expected_f64 random.safe_frac expected_text (random.unicode 1)] (_.cover [/.tuple] - (and (|> (/.run (/.tuple ($_ <>.and /.bit /.i64 /.f64 /.text)) - (list (synthesis.tuple (list (synthesis.bit expected_bit) - (synthesis.i64 expected_i64) - (synthesis.f64 expected_f64) - (synthesis.text expected_text))))) + (and (|> (/.result (/.tuple ($_ <>.and /.bit /.i64 /.f64 /.text)) + (list (synthesis.tuple (list (synthesis.bit expected_bit) + (synthesis.i64 expected_i64) + (synthesis.f64 expected_f64) + (synthesis.text expected_text))))) (!expect (^multi (#try.Success [actual_bit actual_i64 actual_f64 actual_text]) (and (\ bit.equivalence = expected_bit actual_bit) (\ i64.equivalence = expected_i64 actual_i64) (\ frac.equivalence = expected_f64 actual_f64) (\ text.equivalence = expected_text actual_text))))) - (|> (/.run (/.tuple ($_ <>.and /.bit /.i64 /.f64 /.text)) - (list (synthesis.text expected_text))) + (|> (/.result (/.tuple ($_ <>.and /.bit /.i64 /.f64 /.text)) + (list (synthesis.text expected_text))) (!expect (^multi (#try.Failure error) (exception.match? /.cannot_parse error))))))) (do {! random.monad} @@ -116,15 +116,15 @@ expected_environment ..random_environment expected_body (random.unicode 1)] (_.cover [/.function] - (and (|> (/.run (/.function arity /.text) - (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)]))) + (and (|> (/.result (/.function arity /.text) + (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)]))) (!expect (^multi (#try.Success [actual_environment actual_body]) (and (\ (list.equivalence synthesis.equivalence) = expected_environment actual_environment) (\ text.equivalence = expected_body actual_body))))) - (|> (/.run (/.function arity /.text) - (list (synthesis.text expected_body))) + (|> (/.result (/.function arity /.text) + (list (synthesis.text expected_body))) (!expect (^multi (#try.Failure error) (exception.match? /.cannot_parse error))))))) (do {! random.monad} @@ -132,8 +132,8 @@ expected_environment ..random_environment expected_body (random.unicode 1)] (_.cover [/.wrong_arity] - (|> (/.run (/.function (inc arity) /.text) - (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)]))) + (|> (/.result (/.function (inc arity) /.text) + (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)]))) (!expect (^multi (#try.Failure error) (exception.match? /.wrong_arity error)))))) (do {! random.monad} @@ -142,18 +142,18 @@ expected_inits (random.list arity random.bit) expected_body (random.unicode 1)] (_.cover [/.loop] - (and (|> (/.run (/.loop (<>.many /.bit) /.text) - (list (synthesis.loop/scope [expected_offset - (list\map (|>> synthesis.bit) expected_inits) - (synthesis.text expected_body)]))) + (and (|> (/.result (/.loop (<>.many /.bit) /.text) + (list (synthesis.loop/scope [expected_offset + (list\map (|>> synthesis.bit) expected_inits) + (synthesis.text expected_body)]))) (!expect (^multi (#try.Success [actual_offset actual_inits actual_body]) (and (\ n.equivalence = expected_offset actual_offset) (\ (list.equivalence bit.equivalence) = expected_inits actual_inits) (\ text.equivalence = expected_body actual_body))))) - (|> (/.run (/.loop (<>.many /.bit) /.text) - (list (synthesis.text expected_body))) + (|> (/.result (/.loop (<>.many /.bit) /.text) + (list (synthesis.text expected_body))) (!expect (^multi (#try.Failure error) (exception.match? /.cannot_parse error))))))) )) @@ -165,34 +165,34 @@ ($_ _.and (do {! random.monad} [expected (\ ! map (|>> synthesis.i64) random.nat)] - (_.cover [/.run /.any] - (|> (/.run /.any (list expected)) + (_.cover [/.result /.any] + (|> (/.result /.any (list expected)) (!expect (^multi (#try.Success actual) (\ synthesis.equivalence = expected actual)))))) (_.cover [/.empty_input] - (|> (/.run /.any (list)) + (|> (/.result /.any (list)) (!expect (^multi (#try.Failure error) (exception.match? /.empty_input error))))) (do {! random.monad} [expected (\ ! map (|>> synthesis.i64) random.nat)] (_.cover [/.unconsumed_input] - (|> (/.run /.any (list expected expected)) + (|> (/.result /.any (list expected expected)) (!expect (^multi (#try.Failure error) (exception.match? /.unconsumed_input error)))))) (do {! random.monad} [dummy (\ ! map (|>> synthesis.i64) random.nat)] (_.cover [/.end! /.expected_empty_input] - (and (|> (/.run /.end! (list)) + (and (|> (/.result /.end! (list)) (!expect (#try.Success _))) - (|> (/.run /.end! (list dummy)) + (|> (/.result /.end! (list dummy)) (!expect (^multi (#try.Failure error) (exception.match? /.expected_empty_input error))))))) (do {! random.monad} [dummy (\ ! map (|>> synthesis.i64) random.nat)] (_.cover [/.end?] - (and (|> (/.run /.end? (list)) + (and (|> (/.result /.end? (list)) (!expect (#try.Success #1))) - (|> (/.run (<>.before /.any /.end?) (list dummy)) + (|> (/.result (<>.before /.any /.end?) (list dummy)) (!expect (#try.Success #0)))))) (_.for [/.cannot_parse] ($_ _.and diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux index 878b82fa9..a7bbfda92 100644 --- a/stdlib/source/test/lux/control/parser/text.lux +++ b/stdlib/source/test/lux/control/parser/text.lux @@ -5,11 +5,11 @@ [abstract [monad (#+ do)]] [control + ["." maybe] ["." try (#+ Try)] ["." exception (#+ Exception)] ["." function]] [data - ["." maybe] ["." text ("#\." equivalence) ["%" format (#+ format)] ["." unicode #_ @@ -41,7 +41,7 @@ (def: (should_fail' sample parser exception) (All [a e] (-> Text (/.Parser a) (Exception e) Bit)) - (case (/.run parser sample) + (case (/.result parser sample) (#try.Failure error) (exception.match? exception error) @@ -50,7 +50,7 @@ (def: (should_fail sample parser) (All [a] (-> Text (/.Parser a) Bit)) - (case (/.run parser sample) + (case (/.result parser sample) (#try.Failure _) true @@ -60,7 +60,7 @@ (def: (should_pass expected parser) (-> Text (/.Parser Text) Bit) (|> expected - (/.run parser) + (/.result parser) (\ try.functor map (text\= expected)) (try.else false))) @@ -298,12 +298,12 @@ ($_ _.and (do {! random.monad} [sample (random.unicode 1)] - (_.cover [/.run /.end!] - (and (|> (/.run /.end! - "") + (_.cover [/.result /.end!] + (and (|> (/.result /.end! + "") (!expect (#try.Success _))) - (|> (/.run /.end! - sample) + (|> (/.result /.end! + sample) (!expect (#try.Failure _)))))) (do {! random.monad} [.let [size 10] @@ -311,16 +311,16 @@ dummy (|> (random.unicode size) (random.only (|>> (text\= expected) not)))] (_.cover [/.this /.cannot_match] - (and (|> (/.run (/.this expected) - expected) + (and (|> (/.result (/.this expected) + expected) (!expect (#try.Success []))) - (|> (/.run (/.this expected) - dummy) + (|> (/.result (/.this expected) + dummy) (!expect (^multi (#try.Failure error) (exception.match? /.cannot_match error))))))) (_.cover [/.Slice /.slice /.cannot_slice] (|> "" - (/.run (/.slice /.any!)) + (/.result (/.slice /.any!)) (!expect (^multi (#try.Failure error) (exception.match? /.cannot_slice error))))) (do {! random.monad} @@ -336,25 +336,25 @@ (_.cover [/.peek /.cannot_parse] (and (..should_pass expected (<>.before /.any /.peek)) (|> "" - (/.run (<>.before /.any /.peek)) + (/.result (<>.before /.any /.peek)) (!expect (^multi (#try.Failure error) (exception.match? /.cannot_parse error))))))) (do {! random.monad} [dummy (random.unicode 1)] (_.cover [/.unconsumed_input] (|> (format dummy dummy) - (/.run /.any) + (/.result /.any) (!expect (^multi (#try.Failure error) (exception.match? /.unconsumed_input error)))))) (do {! random.monad} [sample (random.unicode 1)] (_.cover [/.Offset /.offset] (|> sample - (/.run (do <>.monad - [pre /.offset - _ /.any - post /.offset] - (in [pre post]))) + (/.result (do <>.monad + [pre /.offset + _ /.any + post /.offset] + (in [pre post]))) (!expect (#try.Success [0 1]))))) (do {! random.monad} [left (random.unicode 1) @@ -362,13 +362,13 @@ .let [input (format left right)]] (_.cover [/.remaining] (|> input - (/.run (do <>.monad - [pre /.remaining - _ /.any - post /.remaining - _ /.any] - (in (and (text\= input pre) - (text\= right post))))) + (/.result (do <>.monad + [pre /.remaining + _ /.any + post /.remaining + _ /.any] + (in (and (text\= input pre) + (text\= right post))))) (!expect (#try.Success #1))))) (do {! random.monad} [left (random.unicode 1) @@ -377,22 +377,22 @@ (random.unicode 1))] (_.cover [/.enclosed] (|> (format left expected right) - (/.run (/.enclosed [left right] (/.this expected))) + (/.result (/.enclosed [left right] (/.this expected))) (!expect (#try.Success _))))) (do {! random.monad} [input (random.unicode 1) output (random.unicode 1)] (_.cover [/.local] (|> output - (/.run (do <>.monad - [_ (/.local input (/.this input))] - (/.this output))) + (/.result (do <>.monad + [_ (/.local input (/.this input))] + (/.this output))) (!expect (#try.Success _))))) (do {! random.monad} [expected (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat)] (_.cover [/.then] (|> (list (code.text expected)) - (<c>.run (/.then /.octal <c>.text)) + (<c>.result (/.then /.octal <c>.text)) (!expect (^multi (#try.Success actual) (text\= expected actual)))))) (do {! random.monad} @@ -404,13 +404,13 @@ (_.cover [/.not /.not! /.expected_to_fail] (and (..should_pass (text.of_char expected) (/.not /.upper)) (|> invalid - (/.run (/.not /.upper)) + (/.result (/.not /.upper)) (!expect (^multi (#try.Failure error) (exception.match? /.expected_to_fail error)))) (..should_pass! (text.of_char expected) (/.not! upper!)) (|> invalid - (/.run (/.not! upper!)) + (/.result (/.not! upper!)) (!expect (^multi (#try.Failure error) (exception.match? /.expected_to_fail error))))))) (do {! random.monad} diff --git a/stdlib/source/test/lux/control/parser/tree.lux b/stdlib/source/test/lux/control/parser/tree.lux index 0d1cc090e..996a16aa2 100644 --- a/stdlib/source/test/lux/control/parser/tree.lux +++ b/stdlib/source/test/lux/control/parser/tree.lux @@ -32,8 +32,8 @@ [dummy random.nat expected (|> random.nat (random.only (|>> (n.= dummy) not)))] (_.cover <coverage> - (|> (/.run <parser> - <sample>) + (|> (/.result <parser> + <sample>) (!expect (^multi (#try.Success actual) (n.= expected actual))))))]) @@ -42,10 +42,10 @@ [dummy random.nat expected (|> random.nat (random.only (|>> (n.= dummy) not)))] (_.cover <coverage> - (and (|> (/.run <parser> <sample0>) + (and (|> (/.result <parser> <sample0>) (!expect (^multi (#try.Success actual) (n.= expected actual)))) - (|> (/.run <parser> <sample1>) + (|> (/.result <parser> <sample1>) (!expect (^multi (#try.Success actual) (n.= expected actual)))))))]) @@ -54,14 +54,14 @@ (<| (_.covering /._) (_.for [/.Parser]) ($_ _.and - (!cover [/.run /.value] + (!cover [/.result /.value] /.value (tree.leaf expected)) (do {! random.monad} [expected random.nat] - (_.cover [/.run'] - (|> (/.run' /.value - (zipper.zipper (tree.leaf expected))) + (_.cover [/.result'] + (|> (/.result' /.value + (zipper.zipper (tree.leaf expected))) (!expect (^multi (#try.Success actual) (n.= expected actual)))))) (!cover [/.down] @@ -161,8 +161,8 @@ [dummy random.nat] (_.cover [/.cannot_move_further] (`` (and (~~ (template [<parser>] - [(|> (/.run <parser> - (tree.leaf dummy)) + [(|> (/.result <parser> + (tree.leaf dummy)) (!expect (^multi (#try.Failure error) (exception.match? /.cannot_move_further error))))] diff --git a/stdlib/source/test/lux/control/parser/type.lux b/stdlib/source/test/lux/control/parser/type.lux index 971ccd5db..55398c22e 100644 --- a/stdlib/source/test/lux/control/parser/type.lux +++ b/stdlib/source/test/lux/control/parser/type.lux @@ -43,29 +43,29 @@ ..primitive)]) ($_ _.and (_.cover [/.exactly] - (and (|> (/.run (/.exactly expected) expected) + (and (|> (/.result (/.exactly expected) expected) (!expect (#try.Success []))) - (|> (/.run (/.exactly expected) dummy) + (|> (/.result (/.exactly expected) dummy) (!expect (^multi (#try.Failure error) (exception.match? /.types_do_not_match error)))))) (_.cover [/.sub] - (and (|> (/.run (/.sub expected) expected) + (and (|> (/.result (/.sub expected) expected) (!expect (#try.Success []))) - (|> (/.run (/.sub Any) expected) + (|> (/.result (/.sub Any) expected) (!expect (#try.Success []))) - (|> (/.run (/.sub expected) Nothing) + (|> (/.result (/.sub expected) Nothing) (!expect (#try.Success []))) - (|> (/.run (/.sub expected) dummy) + (|> (/.result (/.sub expected) dummy) (!expect (^multi (#try.Failure error) (exception.match? /.types_do_not_match error)))))) (_.cover [/.super] - (and (|> (/.run (/.super expected) expected) + (and (|> (/.result (/.super expected) expected) (!expect (#try.Success []))) - (|> (/.run (/.super expected) Any) + (|> (/.result (/.super expected) Any) (!expect (#try.Success []))) - (|> (/.run (/.super Nothing) expected) + (|> (/.result (/.super Nothing) expected) (!expect (#try.Success []))) - (|> (/.run (/.super expected) dummy) + (|> (/.result (/.super expected) dummy) (!expect (^multi (#try.Failure error) (exception.match? /.types_do_not_match error)))))) ))) @@ -79,14 +79,14 @@ (`` ($_ _.and (~~ (template [<parser> <exception> <good_constructor> <bad_constructor>] [(_.cover [<parser> <exception>] - (and (|> (/.run (<parser> ($_ //.and /.any /.any /.any)) - (<good_constructor> (list expected_left expected_middle expected_right))) + (and (|> (/.result (<parser> ($_ //.and /.any /.any /.any)) + (<good_constructor> (list expected_left expected_middle expected_right))) (!expect (^multi (#try.Success [actual_left actual_middle actual_right]) (and (type\= expected_left actual_left) (type\= expected_middle actual_middle) (type\= expected_right actual_right))))) - (|> (/.run (<parser> ($_ //.and /.any /.any /.any)) - (<bad_constructor> (list expected_left expected_middle expected_right))) + (|> (/.result (<parser> ($_ //.and /.any /.any /.any)) + (<bad_constructor> (list expected_left expected_middle expected_right))) (!expect (^multi (#try.Failure error) (exception.match? <exception> error))))))] @@ -95,25 +95,25 @@ )) (_.cover [/.function /.not_function] - (and (|> (/.run (/.function ($_ //.and /.any /.any) /.any) - (type.function (list expected_left expected_middle) expected_right)) + (and (|> (/.result (/.function ($_ //.and /.any /.any) /.any) + (type.function (list expected_left expected_middle) expected_right)) (!expect (^multi (#try.Success [[actual_left actual_middle] actual_right]) (and (type\= expected_left actual_left) (type\= expected_middle actual_middle) (type\= expected_right actual_right))))) - (|> (/.run (/.function ($_ //.and /.any /.any) /.any) - (type.variant (list expected_left expected_middle expected_right))) + (|> (/.result (/.function ($_ //.and /.any /.any) /.any) + (type.variant (list expected_left expected_middle expected_right))) (!expect (^multi (#try.Failure error) (exception.match? /.not_function error)))))) (_.cover [/.applied /.not_application] - (and (|> (/.run (/.applied ($_ //.and /.any /.any /.any)) - (type.application (list expected_middle expected_right) expected_left)) + (and (|> (/.result (/.applied ($_ //.and /.any /.any /.any)) + (type.application (list expected_middle expected_right) expected_left)) (!expect (^multi (#try.Success [actual_left actual_middle actual_right]) (and (type\= expected_left actual_left) (type\= expected_middle actual_middle) (type\= expected_right actual_right))))) - (|> (/.run (/.applied ($_ //.and /.any /.any /.any)) - (type.variant (list expected_left expected_middle expected_right))) + (|> (/.result (/.applied ($_ //.and /.any /.any /.any)) + (type.variant (list expected_left expected_middle expected_right))) (!expect (^multi (#try.Failure error) (exception.match? /.not_application error)))))) )))) @@ -127,38 +127,38 @@ parameter random.nat] ($_ _.and (_.cover [/.not_parameter] - (|> (/.run /.parameter not_parameter) + (|> (/.result /.parameter not_parameter) (!expect (^multi (#try.Failure error) (exception.match? /.not_parameter error))))) (_.cover [/.unknown_parameter] - (|> (/.run /.parameter (#.Parameter parameter)) + (|> (/.result /.parameter (#.Parameter parameter)) (!expect (^multi (#try.Failure error) (exception.match? /.unknown_parameter error))))) (_.cover [/.with_extension] - (|> (/.run (<| (/.with_extension quantification) - (/.with_extension argument) - /.any) - not_parameter) + (|> (/.result (<| (/.with_extension quantification) + (/.with_extension argument) + /.any) + not_parameter) (!expect (^multi (#try.Success [quantification\\binding argument\\binding actual]) (is? not_parameter actual))))) (_.cover [/.parameter] - (|> (/.run (<| (/.with_extension quantification) - (/.with_extension argument) - /.parameter) - (#.Parameter 0)) + (|> (/.result (<| (/.with_extension quantification) + (/.with_extension argument) + /.parameter) + (#.Parameter 0)) (!expect (#try.Success [quantification\\binding argument\\binding _])))) (_.cover [/.wrong_parameter] - (|> (/.run (<| (/.with_extension quantification) - (/.with_extension argument) - (/.parameter! 1)) - (#.Parameter 0)) + (|> (/.result (<| (/.with_extension quantification) + (/.with_extension argument) + (/.parameter! 1)) + (#.Parameter 0)) (!expect (^multi (#try.Failure error) (exception.match? /.wrong_parameter error))))) (_.cover [/.parameter!] - (|> (/.run (<| (/.with_extension quantification) - (/.with_extension argument) - (/.parameter! 0)) - (#.Parameter 0)) + (|> (/.result (<| (/.with_extension quantification) + (/.with_extension argument) + (/.parameter! 0)) + (#.Parameter 0)) (!expect (#try.Success [quantification\\binding argument\\binding _])))) ))) @@ -169,17 +169,17 @@ expected_inputs (\ ! map (|>> (n.% 10) inc) random.nat)] ($_ _.and (_.cover [/.not_polymorphic] - (and (|> (/.run (/.polymorphic /.any) - not_polymorphic) + (and (|> (/.result (/.polymorphic /.any) + not_polymorphic) (!expect (^multi (#try.Failure error) (exception.match? /.not_polymorphic error)))) - (|> (/.run (/.polymorphic /.any) - (type.univ_q 0 not_polymorphic)) + (|> (/.result (/.polymorphic /.any) + (type.univ_q 0 not_polymorphic)) (!expect (^multi (#try.Failure error) (exception.match? /.not_polymorphic error)))))) (_.cover [/.polymorphic] - (|> (/.run (/.polymorphic /.any) - (type.univ_q expected_inputs not_polymorphic)) + (|> (/.result (/.polymorphic /.any) + (type.univ_q expected_inputs not_polymorphic)) (!expect (^multi (#try.Success [g!poly actual_inputs bodyT]) (and (n.= expected_inputs (list.size actual_inputs)) (is? not_polymorphic bodyT)))))) @@ -192,31 +192,31 @@ ($_ _.and (do {! random.monad} [expected ..primitive] - (_.cover [/.run /.any] - (|> (/.run /.any expected) + (_.cover [/.result /.any] + (|> (/.result /.any expected) (!expect (^multi (#try.Success actual) (type\= expected actual)))))) (do {! random.monad} [expected ..primitive] (_.cover [/.peek /.unconsumed_input] - (and (|> (/.run (do //.monad - [actual /.peek - _ /.any] - (in actual)) - expected) + (and (|> (/.result (do //.monad + [actual /.peek + _ /.any] + (in actual)) + expected) (!expect (^multi (#try.Success actual) (type\= expected actual)))) - (|> (/.run /.peek expected) + (|> (/.result /.peek expected) (!expect (^multi (#try.Failure error) (exception.match? /.unconsumed_input error))))))) (do {! random.monad} [expected ..primitive] (_.cover [/.empty_input] (`` (and (~~ (template [<parser>] - [(|> (/.run (do //.monad - [_ /.any] - <parser>) - expected) + [(|> (/.result (do //.monad + [_ /.any] + <parser>) + expected) (!expect (^multi (#try.Failure error) (exception.match? /.empty_input error))))] @@ -226,11 +226,11 @@ (do {! random.monad} [expected ..primitive] (_.cover [/.Env /.env /.fresh] - (|> (/.run (do //.monad - [env /.env - _ /.any] - (in env)) - expected) + (|> (/.result (do //.monad + [env /.env + _ /.any] + (in env)) + expected) (!expect (^multi (#try.Success environment) (is? /.fresh environment)))))) (do {! random.monad} @@ -238,18 +238,18 @@ dummy (random.only (|>> (type\= expected) not) ..primitive)] (_.cover [/.local] - (|> (/.run (do //.monad - [_ /.any] - (/.local (list expected) - /.any)) - dummy) + (|> (/.result (do //.monad + [_ /.any] + (/.local (list expected) + /.any)) + dummy) (!expect (^multi (#try.Success actual) (type\= expected actual)))))) (do {! random.monad} [expected random.nat] (_.cover [/.existential /.not_existential] - (|> (/.run /.existential - (#.Ex expected)) + (|> (/.result /.existential + (#.Ex expected)) (!expect (^multi (#try.Success actual) (n.= expected actual)))))) (do {! random.monad} @@ -257,8 +257,8 @@ (random.ascii/alpha_num 1)) expected_type ..primitive] (_.cover [/.named /.not_named] - (|> (/.run /.named - (#.Named expected_name expected_type)) + (|> (/.result /.named + (#.Named expected_name expected_type)) (!expect (^multi (#try.Success [actual_name actual_type]) (and (name\= expected_name actual_name) (type\= expected_type actual_type))))))) diff --git a/stdlib/source/test/lux/control/parser/xml.lux b/stdlib/source/test/lux/control/parser/xml.lux index 81c4da80d..d4cb4c50c 100644 --- a/stdlib/source/test/lux/control/parser/xml.lux +++ b/stdlib/source/test/lux/control/parser/xml.lux @@ -6,13 +6,13 @@ [abstract [monad (#+ do)]] [control - ["." try] + ["." try ("#\." functor)] ["." exception]] [data ["." text ("#\." equivalence)] ["." name ("#\." equivalence)] [format - ["." xml]] + ["." xml ("#\." equivalence)]] [collection ["." dictionary] ["." list]]] @@ -40,7 +40,7 @@ [expected (random.ascii/alpha 1)] (_.cover [<exception>] (`` (and (~~ (template [<parser> <input>] - [(|> (/.run <parser> (list <input>)) + [(|> (/.result <parser> (list <input>)) (!expect (^multi (#try.Failure error) (exception.match? <exception> error))))] @@ -61,32 +61,33 @@ ($_ _.and (do {! random.monad} [expected (random.ascii/alpha 1)] - (_.cover [/.run /.text] - (|> (/.run /.text (list (#xml.Text expected))) + (_.cover [/.result /.text] + (|> (/.result /.text (list (#xml.Text expected))) (!expect (^multi (#try.Success actual) (text\= expected actual)))))) (!failure /.unconsumed_inputs [[(//\in expected) (#xml.Text expected)]]) (do {! random.monad} - [expected (random.ascii/alpha 1)] - (_.cover [/.ignore] - (|> (/.run /.ignore (list (#xml.Text expected))) - (!expect (#try.Success []))))) + [expected (\ ! map (|>> #xml.Text) (random.ascii/alpha 1))] + (_.cover [/.any] + (|> (/.result /.any (list expected)) + (try\map (xml\= expected)) + (try.else false)))) (do {! random.monad} [expected ..random_tag] (_.cover [/.tag] - (|> (/.run (do //.monad - [actual /.tag - _ /.ignore] - (in (name\= expected actual))) - (list (#xml.Node expected (dictionary.empty name.hash) (list)))) + (|> (/.result (do //.monad + [actual /.tag + _ /.any] + (in (name\= expected actual))) + (list (#xml.Node expected (dictionary.empty name.hash) (list)))) (!expect (#try.Success #1))))) (do {! random.monad} [expected ..random_tag] (_.cover [/.node] - (|> (/.run (/.node expected (//\in [])) - (list (#xml.Node expected (dictionary.empty name.hash) (list)))) + (|> (/.result (/.node expected (//\in [])) + (list (#xml.Node expected (dictionary.empty name.hash) (list)))) (!expect (#try.Success []))))) (!failure /.wrong_tag [[(/.node ["" expected] (//\in [])) @@ -96,13 +97,13 @@ expected_attribute ..random_attribute expected_value (random.ascii/alpha 1)] (_.cover [/.attribute] - (|> (/.run (<| (/.node expected_tag) - (//.after (/.attribute expected_attribute)) - (//\in [])) - (list (#xml.Node expected_tag - (|> (dictionary.empty name.hash) - (dictionary.put expected_attribute expected_value)) - (list)))) + (|> (/.result (<| (/.node expected_tag) + (//.after (/.attribute expected_attribute)) + (//\in [])) + (list (#xml.Node expected_tag + (|> (dictionary.empty name.hash) + (dictionary.put expected_attribute expected_value)) + (list)))) (!expect (#try.Success []))))) (!failure /.unknown_attribute [[(/.attribute ["" expected]) @@ -112,22 +113,22 @@ (list))]]) (!failure /.empty_input [[(do //.monad - [_ /.ignore] - /.ignore) + [_ /.any] + /.any) (#xml.Text expected)] [(do //.monad - [_ /.ignore] + [_ /.any] /.text) (#xml.Text expected)] [(do //.monad - [_ /.ignore] + [_ /.any] (/.node [expected expected] (//\in []))) (#xml.Node [expected expected] (dictionary.empty name.hash) (list))] [(do //.monad - [_ /.ignore] + [_ /.any] (/.node [expected expected] (/.attribute [expected expected]))) (#xml.Node [expected expected] @@ -156,21 +157,21 @@ [_ (<| /.somewhere (/.node right) (//\in [])) - _ (//.some /.ignore)] + _ (//.some /.any)] (in [])))] repetitions (\ ! map (n.% 10) random.nat)] ($_ _.and (_.cover [/.somewhere] - (|> (/.run parser - (list (node parent - (list.concat (list (list.repeated repetitions (node wrong (list))) - (list (node right (list))) - (list.repeated repetitions (node wrong (list)))))))) + (|> (/.result parser + (list (node parent + (list.concat (list (list.repeated repetitions (node wrong (list))) + (list (node right (list))) + (list.repeated repetitions (node wrong (list)))))))) (!expect (#try.Success [])))) (_.cover [/.nowhere] - (|> (/.run parser - (list (node parent - (list.repeated repetitions (node wrong (list)))))) + (|> (/.result parser + (list (node parent + (list.repeated repetitions (node wrong (list)))))) (!expect (^multi (#try.Failure error) (exception.match? /.nowhere error))))) )) diff --git a/stdlib/source/test/lux/control/reader.lux b/stdlib/source/test/lux/control/reader.lux index 08d5d82b2..c89d0e3eb 100644 --- a/stdlib/source/test/lux/control/reader.lux +++ b/stdlib/source/test/lux/control/reader.lux @@ -25,7 +25,7 @@ (def: comparison (Comparison (All [a r] (Reader r a))) (function (_ == left right) - (== (/.run [] left) (/.run [] right)))) + (== (/.result [] left) (/.result [] right)))) (def: .public test Test @@ -42,12 +42,12 @@ (_.for [/.monad] ($monad.spec ..injection ..comparison /.monad)) - (_.cover [/.run /.ask] + (_.cover [/.result /.ask] (n.= sample - (/.run sample /.ask))) + (/.result sample /.ask))) (_.cover [/.local] (n.= (n.* factor sample) - (/.run sample (/.local (n.* factor) /.ask)))) + (/.result sample (/.local (n.* factor) /.ask)))) (let [(^open "io\.") io.monad] (_.cover [/.with /.lift] (|> (: (/.Reader Any (IO Nat)) @@ -55,6 +55,6 @@ [a (/.lift (io\in sample)) b (in factor)] (in (n.* b a)))) - (/.run []) - io.run + (/.result []) + io.run! (n.= (n.* factor sample))))))))) diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux index 477f42a47..4fbb71916 100644 --- a/stdlib/source/test/lux/control/region.lux +++ b/stdlib/source/test/lux/control/region.lux @@ -63,13 +63,13 @@ == (Try a) - (thread.run (:assume (/.run thread.monad left)))) + (thread.result (:assume (/.run! thread.monad left)))) (:sharing [a] (Equivalence a) == (Try a) - (thread.run (:assume (/.run thread.monad right))))] + (thread.result (:assume (/.run! thread.monad right))))] [(#try.Success left) (#try.Success right)] (== left right) @@ -96,8 +96,8 @@ (Monad (Region r (thread.Thread !)))) (/.monad thread.monad)))) - (_.cover [/.run] - (thread.run + (_.cover [/.run!] + (thread.result (do {! thread.monad} [clean_up_counter (thread.box 0) .let [//@ ! @@ -105,17 +105,17 @@ (do ! [_ (thread.update inc clean_up_counter)] (in (#try.Success []))))] - outcome (/.run ! - (do {! (/.monad !)} - [_ (monad.map ! (/.acquire //@ count_clean_up) - (enum.range n.enum 1 expected_clean_ups))] - (in []))) + outcome (/.run! ! + (do {! (/.monad !)} + [_ (monad.map ! (/.acquire //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups))] + (in []))) actual_clean_ups (thread.read clean_up_counter)] (in (and (..success? outcome) (n.= expected_clean_ups actual_clean_ups)))))) (_.cover [/.failure] - (thread.run + (thread.result (do {! thread.monad} [clean_up_counter (thread.box 0) .let [//@ ! @@ -123,18 +123,18 @@ (do ! [_ (thread.update inc clean_up_counter)] (in (#try.Success []))))] - outcome (/.run ! - (do {! (/.monad !)} - [_ (monad.map ! (/.acquire //@ count_clean_up) - (enum.range n.enum 1 expected_clean_ups)) - _ (/.failure //@ (exception.error ..oops []))] - (in []))) + outcome (/.run! ! + (do {! (/.monad !)} + [_ (monad.map ! (/.acquire //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups)) + _ (/.failure //@ (exception.error ..oops []))] + (in []))) actual_clean_ups (thread.read clean_up_counter)] (in (and (..throws? ..oops outcome) (n.= expected_clean_ups actual_clean_ups)))))) (_.cover [/.except] - (thread.run + (thread.result (do {! thread.monad} [clean_up_counter (thread.box 0) .let [//@ ! @@ -142,18 +142,18 @@ (do ! [_ (thread.update inc clean_up_counter)] (in (#try.Success []))))] - outcome (/.run ! - (do {! (/.monad !)} - [_ (monad.map ! (/.acquire //@ count_clean_up) - (enum.range n.enum 1 expected_clean_ups)) - _ (/.except //@ ..oops [])] - (in []))) + outcome (/.run! ! + (do {! (/.monad !)} + [_ (monad.map ! (/.acquire //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups)) + _ (/.except //@ ..oops [])] + (in []))) actual_clean_ups (thread.read clean_up_counter)] (in (and (..throws? ..oops outcome) (n.= expected_clean_ups actual_clean_ups)))))) (_.cover [/.acquire /.clean_up_error] - (thread.run + (thread.result (do {! thread.monad} [clean_up_counter (thread.box 0) .let [//@ ! @@ -162,25 +162,25 @@ [_ (thread.update inc clean_up_counter)] (in (: (Try Any) (exception.except ..oops [])))))] - outcome (/.run ! - (do {! (/.monad !)} - [_ (monad.map ! (/.acquire //@ count_clean_up) - (enum.range n.enum 1 expected_clean_ups))] - (in []))) + outcome (/.run! ! + (do {! (/.monad !)} + [_ (monad.map ! (/.acquire //@ count_clean_up) + (enum.range n.enum 1 expected_clean_ups))] + (in []))) actual_clean_ups (thread.read clean_up_counter)] (in (and (or (n.= 0 expected_clean_ups) (..throws? /.clean_up_error outcome)) (n.= expected_clean_ups actual_clean_ups)))))) (_.cover [/.lift] - (thread.run + (thread.result (do {! thread.monad} [clean_up_counter (thread.box 0) .let [//@ !] - outcome (/.run ! - (do (/.monad !) - [_ (/.lift //@ (thread.write expected_clean_ups clean_up_counter))] - (in []))) + outcome (/.run! ! + (do (/.monad !) + [_ (/.lift //@ (thread.write expected_clean_ups clean_up_counter))] + (in []))) actual_clean_ups (thread.read clean_up_counter)] (in (and (..success? outcome) (n.= expected_clean_ups diff --git a/stdlib/source/test/lux/control/remember.lux b/stdlib/source/test/lux/control/remember.lux index 24e483420..33f91e26f 100644 --- a/stdlib/source/test/lux/control/remember.lux +++ b/stdlib/source/test/lux/control/remember.lux @@ -63,14 +63,14 @@ (text.contains? (%.code focus) failure)))) (syntax: (test_macro {macro <c>.identifier} {extra <c>.text}) - (let [now (io.run instant.now) + (let [now (io.run! instant.now) today (instant.date now) yesterday (instant.date (instant.after (duration.inverse duration.week) now)) tomorrow (instant.date (instant.after duration.week now)) prng (random.pcg_32 [(hex "0123456789ABCDEF") (instant.millis now)]) - message (product.right (random.run prng ..message)) - expected (product.right (random.run prng ..focus))] + message (product.right (random.result prng ..message)) + expected (product.right (random.result prng ..focus))] (do meta.monad [should_fail0 (..attempt (macro.expansion (..memory macro yesterday message #.None))) should_fail1 (..attempt (macro.expansion (..memory macro yesterday message (#.Some expected)))) diff --git a/stdlib/source/test/lux/control/state.lux b/stdlib/source/test/lux/control/state.lux index d7555e7aa..3f2123211 100644 --- a/stdlib/source/test/lux/control/state.lux +++ b/stdlib/source/test/lux/control/state.lux @@ -23,7 +23,7 @@ (def: (with_conditions [state output] computation) (-> [Nat Nat] (State Nat Nat) Bit) (|> computation - (/.run state) + (/.result state) product.right (n.= output))) @@ -62,8 +62,8 @@ (def: (comparison init) (All [s] (-> s (Comparison (State s)))) (function (_ == left right) - (== (product.right (/.run init left)) - (product.right (/.run init right))))) + (== (product.right (/.result init left)) + (product.right (/.result init right))))) (def: structures Test @@ -87,14 +87,14 @@ [state /.get] (in (n.< limit state)))]] ($_ _.and - (_.cover [/.while /.run] + (_.cover [/.while /.result] (|> (/.while condition (/.update inc)) - (/.run 0) + (/.result 0) (let> [state' output'] (n.= limit state')))) (_.cover [/.do_while] (|> (/.do_while condition (/.update inc)) - (/.run 0) + (/.result 0) (let> [state' output'] (or (n.= limit state') (and (n.= 0 limit) @@ -108,14 +108,14 @@ left random.nat right random.nat] (let [(^open "io\.") io.monad] - (_.cover [/.+State /.with /.lift /.run'] + (_.cover [/.+State /.with /.lift /.result'] (|> (: (/.+State io.IO Nat Nat) (do (/.with io.monad) [a (/.lift io.monad (io\in left)) b (in right)] (in (n.+ a b)))) - (/.run' state) - io.run + (/.result' state) + io.run! (let> [state' output'] (and (n.= state state') (n.= (n.+ left right) output'))))) diff --git a/stdlib/source/test/lux/control/thread.lux b/stdlib/source/test/lux/control/thread.lux index e396a613f..4f71c7203 100644 --- a/stdlib/source/test/lux/control/thread.lux +++ b/stdlib/source/test/lux/control/thread.lux @@ -24,7 +24,7 @@ (def: comparison (Comparison (All [a !] (Thread ! a))) (function (_ == left right) - (== (/.run left) (/.run right)))) + (== (/.result left) (/.result right)))) (def: .public test Test @@ -35,17 +35,17 @@ ($_ _.and (_.for [/.Thread] ($_ _.and - (_.cover [/.run] + (_.cover [/.result] (n.= sample (|> sample (\ /.monad in) - /.run))) + /.result))) (_.cover [/.io] (n.= sample (|> sample (\ /.monad in) /.io - io.run))) + io.run!))) (_.for [/.functor] ($functor.spec ..injection ..comparison /.functor)) @@ -59,24 +59,24 @@ ($_ _.and (_.cover [/.read] (n.= sample - (/.run (: (All [!] (Thread ! Nat)) - (do /.monad - [box (/.box sample)] - (/.read box)))))) + (/.result (: (All [!] (Thread ! Nat)) + (do /.monad + [box (/.box sample)] + (/.read box)))))) (_.cover [/.write] (n.= factor - (/.run (: (All [!] (Thread ! Nat)) - (do /.monad - [box (/.box sample) - _ (/.write factor box)] - (/.read box)))))) + (/.result (: (All [!] (Thread ! Nat)) + (do /.monad + [box (/.box sample) + _ (/.write factor box)] + (/.read box)))))) (_.cover [/.update] (n.= (n.* factor sample) - (/.run (: (All [!] (Thread ! Nat)) - (do /.monad - [box (/.box sample) - old (/.update (n.* factor) box)] - (/.read box)))))))) + (/.result (: (All [!] (Thread ! Nat)) + (do /.monad + [box (/.box sample) + old (/.update (n.* factor) box)] + (/.read box)))))))) )))) diff --git a/stdlib/source/test/lux/control/try.lux b/stdlib/source/test/lux/control/try.lux index 0e2fa479e..3c030bdcc 100644 --- a/stdlib/source/test/lux/control/try.lux +++ b/stdlib/source/test/lux/control/try.lux @@ -85,7 +85,7 @@ [a (lifted (io\in expected)) b (in alternative)] (in (n.+ a b))) - io.run + io.run! (case> (#/.Success result) (n.= (n.+ expected alternative) result) diff --git a/stdlib/source/test/lux/control/writer.lux b/stdlib/source/test/lux/control/writer.lux index de65f2d47..9d43ef5f8 100644 --- a/stdlib/source/test/lux/control/writer.lux +++ b/stdlib/source/test/lux/control/writer.lux @@ -53,10 +53,11 @@ (_.cover [/.with /.lift] (let [lift (/.lift text.monoid io.monad) (^open "io\.") io.monad] - (|> (io.run (do (/.with text.monoid io.monad) - [a (lift (io\in left)) - b (in right)] - (in (n.+ a b)))) + (|> (do (/.with text.monoid io.monad) + [a (lift (io\in left)) + b (in right)] + (in (n.+ a b))) + io.run! product.right (n.= (n.+ left right))))) )))) diff --git a/stdlib/source/test/lux/data.lux b/stdlib/source/test/lux/data.lux index beb1ee201..71fb38097 100644 --- a/stdlib/source/test/lux/data.lux +++ b/stdlib/source/test/lux/data.lux @@ -12,8 +12,6 @@ ["#." color ["#/." named]] ["#." identity] - ["#." lazy] - ["#." maybe] ["#." name] ["#." product] ["#." sum] @@ -53,8 +51,6 @@ Test ($_ _.and /identity.test - /lazy.test - /maybe.test /name.test)) (def: test/2 diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index b7ae6bba4..3270e17a7 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -33,7 +33,7 @@ (def: .public (random size) (-> Nat (Random Binary)) - (let [output (/.create size)] + (let [output (/.empty size)] (loop [idx 0] (if (n.< size idx) (do random.monad @@ -54,7 +54,7 @@ (def: (binary_io power read write value) (-> Nat (-> Nat Binary (Try Nat)) (-> Nat Nat Binary (Try Any)) Nat Bit) (let [bytes (i64.left_shifted power 1) - binary (/.create bytes) + binary (/.empty bytes) cap (case bytes 8 (dec 0) _ (|> 1 (i64.left_shifted (n.* 8 bytes)) dec)) @@ -96,12 +96,12 @@ (n.= (\ list.fold fold n.+ 0 (..as_list sample)) (/.fold n.+ 0 sample))) - (_.cover [/.create] + (_.cover [/.empty] (\ /.equivalence = - (/.create size) - (/.create size))) + (/.empty size) + (/.empty size))) (_.cover [/.size] - (|> (/.create size) /.size (n.= size))) + (|> (/.empty size) /.size (n.= size))) (_.for [/.index_out_of_bounds] ($_ _.and (_.cover [/.read/8! /.write/8!] @@ -136,7 +136,7 @@ _ verdict)))) (_.cover [/.drop] (and (\ /.equivalence = sample (/.drop 0 sample)) - (\ /.equivalence = (/.create 0) (/.drop size sample)) + (\ /.equivalence = (/.empty 0) (/.drop size sample)) (case (list.reversed (..as_list sample)) #.End false @@ -145,7 +145,7 @@ (n.= (list.fold n.+ 0 tail) (/.fold n.+ 0 (/.drop 1 sample)))))) (_.cover [/.copy] - (and (case (/.copy size 0 sample 0 (/.create size)) + (and (case (/.copy size 0 sample 0 (/.empty size)) (#try.Success output) (and (not (is? sample output)) (\ /.equivalence = sample output)) @@ -155,7 +155,7 @@ (succeed (do try.monad [sample/0 (/.read/8! 0 sample) - copy (/.copy 1 0 sample 0 (/.create 2)) + copy (/.copy 1 0 sample 0 (/.empty 2)) copy/0 (/.read/8! 0 copy) copy/1 (/.read/8! 1 copy)] (in (and (n.= sample/0 copy/0) diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index 9925fccec..64e0f4268 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -9,9 +9,10 @@ ["$." monoid] ["$." fold] ["$." functor (#+ Injection)]]] + [control + ["." maybe]] [data ["." bit] - ["." maybe] [collection ["." list] ["." set]]] diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux index aafa848b4..ad8a63d28 100644 --- a/stdlib/source/test/lux/data/collection/dictionary.lux +++ b/stdlib/source/test/lux/data/collection/dictionary.lux @@ -9,11 +9,11 @@ ["$." equivalence] ["$." functor (#+ Injection)]]] [control + ["." maybe ("#\." functor)] ["." try] ["." exception]] [data ["." product] - ["." maybe ("#\." functor)] [collection ["." list ("#\." functor)] ["." set]]] diff --git a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux index 13971ad88..adce56dc3 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux @@ -8,10 +8,11 @@ [order (#+ Order)] [\\specification ["$." equivalence]]] + [control + ["." maybe ("#\." monad)]] [data ["." product] ["." bit ("#\." equivalence)] - ["." maybe ("#\." monad)] [collection ["." set] ["." list ("#\." functor)]]] @@ -52,9 +53,9 @@ .let [pairs (list.zipped/2 (set.list keys) (set.list values)) sample (/.of_list n.order pairs) - sorted_pairs (list.sort (function (_ [left _] [right _]) - (n.< left right)) - pairs) + sorted_pairs (list.sorted (function (_ [left _] [right _]) + (n.< left right)) + pairs) sorted_values (list\map product.right sorted_pairs) (^open "list\.") (list.equivalence (: (Equivalence [Nat Nat]) (function (_ [kr vr] [ks vs]) diff --git a/stdlib/source/test/lux/data/collection/dictionary/plist.lux b/stdlib/source/test/lux/data/collection/dictionary/plist.lux index fdbcccc06..ad74dc0a0 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/plist.lux @@ -6,9 +6,10 @@ [monad (#+ do)] [\\specification ["$." equivalence]]] + [control + ["." maybe ("#\." monad)]] [data ["." bit ("#\." equivalence)] - ["." maybe ("#\." monad)] ["." text] [collection ["." set] diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index abf61aef3..426b556b8 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -16,11 +16,11 @@ [control pipe ["." io] + ["." maybe] ["." function]] [data ["." bit] ["." product] - ["." maybe] ["." text ("#\." equivalence)] [collection ["." set]]] @@ -72,10 +72,10 @@ (^open "io\.") io.monad expected (n.+ parameter subject)] (_.cover [/.with /.lift] - (|> (io.run (do (/.with io.monad) - [a (lift (io\in parameter)) - b (in subject)] - (in (n.+ a b)))) + (|> (io.run! (do (/.with io.monad) + [a (lift (io\in parameter)) + b (in subject)] + (in (n.+ a b)))) (case> (^ (list actual)) (n.= expected actual) @@ -113,16 +113,16 @@ (if (/.every? n.even? sample) (not (/.any? (bit.complement n.even?) sample)) (/.any? (bit.complement n.even?) sample))) - (_.cover [/.sort] + (_.cover [/.sorted] (let [<<< n.< size_preservation! (n.= (/.size sample) - (/.size (/.sort <<< sample))) + (/.size (/.sorted <<< sample))) symmetry! - (/\= (/.sort <<< sample) - (/.reversed (/.sort (function.flip <<<) sample)))] + (/\= (/.sorted <<< sample) + (/.reversed (/.sorted (function.flip <<<) sample)))] (and size_preservation! symmetry!))) ))) @@ -143,13 +143,13 @@ already_sorted! (/\= indices - (/.sort n.< indices)) + (/.sorted n.< indices)) expected_numbers! (/.every? (n.= (dec size)) (/.zipped_with/2 n.+ indices - (/.sort n.> indices)))] + (/.sorted n.> indices)))] (and expected_amount! already_sorted! expected_numbers!))) @@ -185,7 +185,7 @@ ..random) .let [size (/.size sample)] idx (\ ! map (n.% size) random.nat) - chunk_size (\ ! map (|>> (n.% size) inc) random.nat)] + sub_size (\ ! map (|>> (n.% size) inc) random.nat)] ($_ _.and (_.cover [/.only] (let [positives (/.only n.even? sample) @@ -218,11 +218,11 @@ (/\= sample (/\compose (/.take_while n.even? sample) (/.drop_while n.even? sample)))) - (_.cover [/.chunk] - (let [chunks (/.chunk chunk_size sample)] - (and (/.every? (|>> /.size (n.<= chunk_size)) chunks) + (_.cover [/.sub] + (let [subs (/.sub sub_size sample)] + (and (/.every? (|>> /.size (n.<= sub_size)) subs) (/\= sample - (/.concat chunks))))) + (/.concat subs))))) )))) (def: member @@ -407,9 +407,9 @@ ..grouping ..search - (_.cover [/.interpose] + (_.cover [/.interposed] (or (/.empty? sample) - (let [sample+ (/.interpose separator sample)] + (let [sample+ (/.interposed separator sample)] (and (n.= (|> (/.size sample) (n.* 2) dec) (/.size sample+)) (|> sample+ /.pairs (/.every? (|>> product.right (n.= separator)))))))) diff --git a/stdlib/source/test/lux/data/collection/queue/priority.lux b/stdlib/source/test/lux/data/collection/queue/priority.lux index 42ec9677e..20579c5b6 100644 --- a/stdlib/source/test/lux/data/collection/queue/priority.lux +++ b/stdlib/source/test/lux/data/collection/queue/priority.lux @@ -4,8 +4,9 @@ ["_" test (#+ Test)] [abstract ["." monad (#+ do)]] + [control + ["." maybe ("#\." functor)]] [data - ["." maybe ("#\." functor)] ["." bit ("#\." equivalence)]] [math ["." random (#+ Random)] diff --git a/stdlib/source/test/lux/data/collection/set/ordered.lux b/stdlib/source/test/lux/data/collection/set/ordered.lux index 260d6ee39..d5ff02472 100644 --- a/stdlib/source/test/lux/data/collection/set/ordered.lux +++ b/stdlib/source/test/lux/data/collection/set/ordered.lux @@ -66,7 +66,7 @@ (_.cover [/.list] (\ (list.equivalence n.equivalence) = (/.list (/.of_list n.order listL)) - (list.sort (\ n.order <) listL))) + (list.sorted (\ n.order <) listL))) (_.cover [/.of_list] (|> setL /.list (/.of_list n.order) diff --git a/stdlib/source/test/lux/data/collection/stack.lux b/stdlib/source/test/lux/data/collection/stack.lux index 082609904..1cb75755f 100644 --- a/stdlib/source/test/lux/data/collection/stack.lux +++ b/stdlib/source/test/lux/data/collection/stack.lux @@ -7,8 +7,9 @@ [\\specification ["$." equivalence] ["$." functor (#+ Injection)]]] + [control + ["." maybe]] [data - ["." maybe] ["." bit ("#\." equivalence)]] [math ["." random] diff --git a/stdlib/source/test/lux/data/collection/tree/finger.lux b/stdlib/source/test/lux/data/collection/tree/finger.lux index 79140887d..370a39a53 100644 --- a/stdlib/source/test/lux/data/collection/tree/finger.lux +++ b/stdlib/source/test/lux/data/collection/tree/finger.lux @@ -4,8 +4,9 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)]] + [control + ["." maybe ("#\." functor)]] [data - ["." maybe ("#\." functor)] ["." text ("#\." equivalence monoid)] [collection ["." list ("#\." fold)]]] diff --git a/stdlib/source/test/lux/data/collection/tree/zipper.lux b/stdlib/source/test/lux/data/collection/tree/zipper.lux index 60c18d514..a4e73fb03 100644 --- a/stdlib/source/test/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/test/lux/data/collection/tree/zipper.lux @@ -9,10 +9,10 @@ ["$." functor] ["$." comonad]]] [control - pipe] + pipe + ["." maybe ("#\." functor)]] [data ["." product] - ["." maybe ("#\." functor)] ["." text] [collection ["." list]]] diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux index 6ff253a73..0444588e1 100644 --- a/stdlib/source/test/lux/data/format/json.lux +++ b/stdlib/source/test/lux/data/format/json.lux @@ -58,7 +58,7 @@ (syntax: (string) (do meta.monad - [value (macro.gensym "string")] + [value (macro.identifier "string")] (in (list (code.text (%.code value)))))) (def: .public test diff --git a/stdlib/source/test/lux/data/format/tar.lux b/stdlib/source/test/lux/data/format/tar.lux index c951382ba..0c43ada46 100644 --- a/stdlib/source/test/lux/data/format/tar.lux +++ b/stdlib/source/test/lux/data/format/tar.lux @@ -5,13 +5,13 @@ [abstract [monad (#+ do)]] [control + ["." maybe] ["." try] ["." exception] ["<>" parser ["<b>" binary]]] [data ["." product] - ["." maybe] ["." binary ("#\." equivalence monoid)] ["." text ("#\." equivalence) ["%" format (#+ format)] @@ -172,8 +172,8 @@ (|> (do try.monad [expected_path (/.path expected_path) tar (|> (row.row (<tag> expected_path)) - (format.run /.writer) - (<b>.run /.parser))] + (format.result /.writer) + (<b>.result /.parser))] (in (case (row.list tar) (^ (list (<tag> actual_path))) (text\= (/.from_path expected_path) @@ -201,8 +201,8 @@ #/.group {#/.name /.anonymous #/.id /.no_id}} expected_content])) - (format.run /.writer) - (<b>.run /.parser))] + (format.result /.writer) + (<b>.result /.parser))] (in (case (row.list tar) (^ (list (<tag> [actual_path actual_moment actual_mode actual_ownership actual_content]))) (let [seconds (: (-> Instant Int) @@ -250,7 +250,7 @@ (_.cover [/.and] (|> (do try.monad [path (/.path path) - content (/.content (binary.create 0)) + content (/.content (binary.empty 0)) tar (|> (row.row (#/.Normal [path (instant.of_millis +0) expected_mode @@ -259,8 +259,8 @@ #/.group {#/.name /.anonymous #/.id /.no_id}} content])) - (format.run /.writer) - (<b>.run /.parser))] + (format.result /.writer) + (<b>.result /.parser))] (in (case (row.list tar) (^ (list (#/.Normal [_ _ actual_mode _ _]))) (n.= (/.mode expected_mode) @@ -273,7 +273,7 @@ [(_.cover [<expected_mode>] (|> (do try.monad [path (/.path path) - content (/.content (binary.create 0)) + content (/.content (binary.empty 0)) tar (|> (row.row (#/.Normal [path (instant.of_millis +0) <expected_mode> @@ -282,8 +282,8 @@ #/.group {#/.name /.anonymous #/.id /.no_id}} content])) - (format.run /.writer) - (<b>.run /.parser))] + (format.result /.writer) + (<b>.result /.parser))] (in (case (row.list tar) (^ (list (#/.Normal [_ _ actual_mode _ _]))) (n.= (/.mode <expected_mode>) @@ -339,7 +339,7 @@ (_.cover [/.Name /.name /.from_name] (|> (do try.monad [path (/.path path) - content (/.content (binary.create 0)) + content (/.content (binary.empty 0)) expected (/.name expected) tar (|> (row.row (#/.Normal [path (instant.of_millis +0) @@ -349,8 +349,8 @@ #/.group {#/.name /.anonymous #/.id /.no_id}} content])) - (format.run /.writer) - (<b>.run /.parser))] + (format.result /.writer) + (<b>.result /.parser))] (in (case (row.list tar) (^ (list (#/.Normal [_ _ _ actual_ownership _]))) (and (text\= (/.from_name expected) @@ -364,7 +364,7 @@ (_.cover [/.anonymous /.no_id] (|> (do try.monad [path (/.path path) - content (/.content (binary.create 0)) + content (/.content (binary.empty 0)) tar (|> (row.row (#/.Normal [path (instant.of_millis +0) /.none @@ -373,8 +373,8 @@ #/.group {#/.name /.anonymous #/.id /.no_id}} content])) - (format.run /.writer) - (<b>.run /.parser))] + (format.result /.writer) + (<b>.result /.parser))] (in (case (row.list tar) (^ (list (#/.Normal [_ _ _ actual_ownership _]))) (and (text\= (/.from_name /.anonymous) @@ -400,13 +400,13 @@ ($_ _.and (_.cover [/.writer /.parser] (|> row.empty - (format.run /.writer) - (<b>.run /.parser) + (format.result /.writer) + (<b>.result /.parser) (\ try.monad map row.empty?) (try.else false))) (_.cover [/.invalid_end_of_archive] - (let [dump (format.run /.writer row.empty)] - (case (<b>.run /.parser (binary\compose dump dump)) + (let [dump (format.result /.writer row.empty)] + (case (<b>.result /.parser (binary\compose dump dump)) (#try.Success _) false diff --git a/stdlib/source/test/lux/data/format/xml.lux b/stdlib/source/test/lux/data/format/xml.lux index 3ec5618a3..4fef01a10 100644 --- a/stdlib/source/test/lux/data/format/xml.lux +++ b/stdlib/source/test/lux/data/format/xml.lux @@ -9,12 +9,12 @@ ["$." codec]]] [control pipe + ["." maybe] ["." try] ["p" parser ["</>" xml]]] [data ["." name] - ["." maybe] ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection diff --git a/stdlib/source/test/lux/data/product.lux b/stdlib/source/test/lux/data/product.lux index 3b846940f..9d9b9e248 100644 --- a/stdlib/source/test/lux/data/product.lux +++ b/stdlib/source/test/lux/data/product.lux @@ -50,18 +50,18 @@ [left random.nat right random.nat] ($_ _.and - (<| (_.cover [/.swap]) + (<| (_.cover [/.swapped]) (let [pair [left right]] (and (n.= (/.left pair) - (/.right (/.swap pair))) + (/.right (/.swapped pair))) (n.= (/.right pair) - (/.left (/.swap pair)))))) - (<| (_.cover [/.uncurry]) + (/.left (/.swapped pair)))))) + (<| (_.cover [/.uncurried]) (n.= (n.+ left right) - ((/.uncurry n.+) [left right]))) - (<| (_.cover [/.curry]) + ((/.uncurried n.+) [left right]))) + (<| (_.cover [/.curried]) (n.= (n.+ left right) - ((/.curry (/.uncurry n.+)) left right))) + ((/.curried (/.uncurried n.+)) left right))) (<| (_.cover [/.apply]) (let [[left' right'] (/.apply (n.+ shift) (n.- shift) [left right])] (and (n.= (n.+ shift left) left') diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index 4ff904116..3c70075d1 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -10,9 +10,9 @@ ["$." order] ["$." monoid]]] [control - pipe] + pipe + ["." maybe]] [data - ["." maybe] [collection ["." list] ["." set]]] @@ -323,8 +323,8 @@ .let [part_gen (|> (random.text normal_char_gen sizeP) (random.only (|>> (/.contains? sep1) not)))] parts (random.list sizeL part_gen) - .let [sample1 (/.concat (list.interpose sep1 parts)) - sample2 (/.concat (list.interpose sep2 parts)) + .let [sample1 (/.concat (list.interposed sep1 parts)) + sample2 (/.concat (list.interposed sep2 parts)) (^open "/\.") /.equivalence]] (_.cover [/.replaced] (/\= sample2 diff --git a/stdlib/source/test/lux/data/text/encoding.lux b/stdlib/source/test/lux/data/text/encoding.lux index 662643d3c..126cb6556 100644 --- a/stdlib/source/test/lux/data/text/encoding.lux +++ b/stdlib/source/test/lux/data/text/encoding.lux @@ -7,9 +7,9 @@ [\\specification ["$." codec]]] [control + ["." maybe] ["." try]] [data - ["." maybe] ["." text ("#\." equivalence)] [collection ["." list ("#\." fold)] @@ -29,7 +29,7 @@ [/.ascii]] [all/ibm<700 - [/.ibm_37 + [/.ibm_037 /.ibm_273 /.ibm_277 /.ibm_278 diff --git a/stdlib/source/test/lux/data/text/escape.lux b/stdlib/source/test/lux/data/text/escape.lux index 35dfaf1cf..8e8c4b1df 100644 --- a/stdlib/source/test/lux/data/text/escape.lux +++ b/stdlib/source/test/lux/data/text/escape.lux @@ -72,8 +72,8 @@ (syntax: (static_sample) (do meta.monad [seed meta.seed - .let [[_ expected] (random.run (random.pcg_32 [seed seed]) - (random.ascii 10))]] + .let [[_ expected] (random.result (random.pcg_32 [seed seed]) + (random.ascii 10))]] (in (list (code.text expected))))) (syntax: (static_escaped {un_escaped <code>.text}) diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux index 263c6cb50..c0b1f9183 100644 --- a/stdlib/source/test/lux/data/text/regex.lux +++ b/stdlib/source/test/lux/data/text/regex.lux @@ -24,7 +24,7 @@ (def: (should_pass regex input) (-> (Parser Text) Text Bit) (|> input - (<text>.run regex) + (<text>.result regex) (case> (#try.Success parsed) (text\= parsed input) @@ -34,7 +34,7 @@ (def: (text_should_pass test regex input) (-> Text (Parser Text) Text Bit) (|> input - (<text>.run regex) + (<text>.result regex) (case> (#try.Success parsed) (text\= test parsed) @@ -44,7 +44,7 @@ (def: (should_fail regex input) (All [a] (-> (Parser a) Text Bit)) (|> input - (<text>.run regex) + (<text>.result regex) (case> (#try.Failure _) true @@ -52,9 +52,9 @@ false))) (syntax: (should_check pattern regex input) - (macro.with_gensyms [g!message g!_] + (macro.with_identifiers [g!message g!_] (in (list (` (|> (~ input) - (<text>.run (~ regex)) + (<text>.result (~ regex)) (case> (^ (#try.Success (~ pattern))) true diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index 6b03ebc15..e49e08476 100644 --- a/stdlib/source/test/lux/ffi.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -59,7 +59,7 @@ (syntax: (macro_error expression) (function (_ lux) (|> (macro.single_expansion expression) - (meta.run lux) + (meta.result lux) (case> (#try.Success expansion) (#try.Failure "OOPS!") @@ -280,7 +280,7 @@ java/lang/Long #throws [java/lang/Throwable] (if (:as Bit throw?) - (error! "YOLO") + (panic! "YOLO") (:as java/lang/Long expected)))) example/1! @@ -361,7 +361,7 @@ ... Methods (test/TestInterface1 [] (actual1 self {throw? java/lang/Boolean}) java/lang/Long #throws [java/lang/Throwable] (if (:as Bit throw?) - (error! "YOLO") + (panic! "YOLO") ::value))) (/.import: test/TestClass1 @@ -576,7 +576,7 @@ (syntax: (expands? expression) (function (_ lux) (|> (macro.single_expansion expression) - (meta.run lux) + (meta.result lux) (case> (#try.Success expansion) true diff --git a/stdlib/source/test/lux/ffi.lua.lux b/stdlib/source/test/lux/ffi.lua.lux index 43757eedf..9b81d303b 100644 --- a/stdlib/source/test/lux/ffi.lua.lux +++ b/stdlib/source/test/lux/ffi.lua.lux @@ -53,7 +53,7 @@ (: (Ex [a] (/.Object a)))) true)) (_.cover [/.import:] - (case (io.run (..os/getenv string)) + (case (io.run! (..os/getenv string)) (#.Some _) true #.None true)) ))))) diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux index d40c628c7..dacff0557 100644 --- a/stdlib/source/test/lux/locale/language.lux +++ b/stdlib/source/test/lux/locale/language.lux @@ -7,8 +7,9 @@ [hash (#+ Hash)] [\\specification ["$." hash]]] + [control + ["." maybe]] [data - ["." maybe] ["." text] [collection ["." set (#+ Set)] diff --git a/stdlib/source/test/lux/locale/territory.lux b/stdlib/source/test/lux/locale/territory.lux index a5b5c4f61..1dec09208 100644 --- a/stdlib/source/test/lux/locale/territory.lux +++ b/stdlib/source/test/lux/locale/territory.lux @@ -7,8 +7,9 @@ [hash (#+ Hash)] [\\specification ["$." hash]]] + [control + ["." maybe]] [data - ["." maybe] ["." text] [collection ["." set (#+ Set)] diff --git a/stdlib/source/test/lux/macro.lux b/stdlib/source/test/lux/macro.lux index 7ff37ea43..73a725528 100644 --- a/stdlib/source/test/lux/macro.lux +++ b/stdlib/source/test/lux/macro.lux @@ -53,18 +53,18 @@ (syntax: (fresh_identifier) (do meta.monad - [g!fresh (/.gensym "fresh")] + [g!fresh (/.identifier "fresh")] (in (list g!fresh)))) (def: random_lux (Random [Nat Text .Lux]) (do {! random.monad} [seed random.nat - gensym_prefix (random.ascii/upper 1) + identifier_prefix (random.ascii/upper 1) .let [macro_module (name.module (name_of /._)) current_module (name.module (name_of .._))]] (in [seed - gensym_prefix + identifier_prefix {#.info {#.target "" #.version "" #.mode #.Build} @@ -108,7 +108,7 @@ (def: expander Test (do {! random.monad} - [[seed gensym_prefix lux] ..random_lux + [[seed identifier_prefix lux] ..random_lux pow/1 (\ ! map code.nat random.nat) @@ -122,18 +122,18 @@ (~~ (template [<expander> <logger> <expansion>] [(_.cover [<expander>] (|> (<expander> (` (..pow/4 (~ pow/1)))) - (meta.run lux) + (meta.result lux) (try\map (\ (list.equivalence code.equivalence) = (list <expansion>))) (try.else false))) (_.cover [<logger>] (and (|> (/.single_expansion (` (<logger> (~' #omit) (..pow/4 (~ pow/1))))) - (meta.run lux) + (meta.result lux) (try\map (\ (list.equivalence code.equivalence) = (list))) (try.else false)) (|> (/.single_expansion (` (<logger> (..pow/4 (~ pow/1))))) - (meta.run lux) + (meta.result lux) (try\map (\ (list.equivalence code.equivalence) = (list <expansion>))) (try.else false))))] @@ -144,7 +144,7 @@ (_.cover [/.one_expansion] (bit\= (not (nat.= 1 repetitions)) (|> (/.one_expansion (` (..repeated (~ (code.nat repetitions)) (~ pow/1)))) - (meta.run lux) + (meta.result lux) (!expect (#try.Failure _))))) )))) @@ -153,26 +153,26 @@ (<| (_.covering /._) ($_ _.and (do {! random.monad} - [[seed gensym_prefix lux] ..random_lux] + [[seed identifier_prefix lux] ..random_lux] ($_ _.and - (_.cover [/.gensym] - (|> (/.gensym gensym_prefix) + (_.cover [/.identifier] + (|> (/.identifier identifier_prefix) (\ meta.monad map %.code) - (meta.run lux) - (!expect (^multi (#try.Success actual_gensym) - (and (text.contains? gensym_prefix actual_gensym) - (text.contains? (%.nat seed) actual_gensym)))))) + (meta.result lux) + (!expect (^multi (#try.Success actual_identifier) + (and (text.contains? identifier_prefix actual_identifier) + (text.contains? (%.nat seed) actual_identifier)))))) (_.cover [/.wrong_syntax_error] (|> (/.single_expansion (` (/.log_single_expansion!))) - (meta.run lux) + (meta.result lux) (!expect (^multi (#try.Failure error) (text.contains? (/.wrong_syntax_error (name_of /.log_single_expansion!)) error))))) - (_.cover [/.with_gensyms] + (_.cover [/.with_identifiers] (with_expansions [<expected> (fresh_identifier)] - (|> (/.with_gensyms [<expected>] + (|> (/.with_identifiers [<expected>] (\ meta.monad in <expected>)) - (meta.run lux) + (meta.result lux) (!expect (^multi (#try.Success [_ (#.Identifier ["" actual])]) (text.contains? (template.text [<expected>]) actual)))))) diff --git a/stdlib/source/test/lux/macro/local.lux b/stdlib/source/test/lux/macro/local.lux index 6102295d4..38f25c013 100644 --- a/stdlib/source/test/lux/macro/local.lux +++ b/stdlib/source/test/lux/macro/local.lux @@ -46,7 +46,7 @@ constant {pre_remove <code>.bit} body) - (macro.with_gensyms [g!output] + (macro.with_identifiers [g!output] (do meta.monad [pop! (/.push (list [name (..constant constant)])) [module short] (meta.normal name) diff --git a/stdlib/source/test/lux/macro/poly.lux b/stdlib/source/test/lux/macro/poly.lux index 41eb81b4f..1ffe2cf61 100644 --- a/stdlib/source/test/lux/macro/poly.lux +++ b/stdlib/source/test/lux/macro/poly.lux @@ -12,6 +12,7 @@ (def: .public test Test (<| (_.covering /._) + (_.for [/.poly: /.derived: /.code]) ($_ _.and /equivalence.test /functor.test diff --git a/stdlib/source/test/lux/macro/poly/equivalence.lux b/stdlib/source/test/lux/macro/poly/equivalence.lux index 6bad7436a..6de4e4019 100644 --- a/stdlib/source/test/lux/macro/poly/equivalence.lux +++ b/stdlib/source/test/lux/macro/poly/equivalence.lux @@ -10,9 +10,10 @@ ["." /]]] [\\specification ["$." equivalence]]] + [control + ["." maybe]] [data ["." bit] - ["." maybe] ["." text] [collection ["." list]]] diff --git a/stdlib/source/test/lux/macro/poly/json.lux b/stdlib/source/test/lux/macro/poly/json.lux index b1b9883cb..d99b3364e 100644 --- a/stdlib/source/test/lux/macro/poly/json.lux +++ b/stdlib/source/test/lux/macro/poly/json.lux @@ -19,7 +19,6 @@ [json (#+)]]] [data ["." bit] - ["." maybe] ["." text ["%" format (#+ format)]] [format diff --git a/stdlib/source/test/lux/macro/syntax/annotations.lux b/stdlib/source/test/lux/macro/syntax/annotations.lux index be74194b9..3fd71b7a3 100644 --- a/stdlib/source/test/lux/macro/syntax/annotations.lux +++ b/stdlib/source/test/lux/macro/syntax/annotations.lux @@ -43,8 +43,8 @@ (do random.monad [expected ..random] (_.cover [/.format /.parser] - (case (<code>.run /.parser - (list (/.format expected))) + (case (|> (list (/.format expected)) + (<code>.result /.parser)) (#try.Failure _) false diff --git a/stdlib/source/test/lux/macro/syntax/check.lux b/stdlib/source/test/lux/macro/syntax/check.lux index e5f3e310e..f9cbab99e 100644 --- a/stdlib/source/test/lux/macro/syntax/check.lux +++ b/stdlib/source/test/lux/macro/syntax/check.lux @@ -37,9 +37,9 @@ (do random.monad [[type value] ..random] (_.cover [/.format /.parser] - (case (<code>.run /.parser - (list (/.format {#/.type type - #/.value value}))) + (case (<code>.result /.parser + (list (/.format {#/.type type + #/.value value}))) (#try.Failure _) false diff --git a/stdlib/source/test/lux/macro/syntax/declaration.lux b/stdlib/source/test/lux/macro/syntax/declaration.lux index a260f84be..8301899bd 100644 --- a/stdlib/source/test/lux/macro/syntax/declaration.lux +++ b/stdlib/source/test/lux/macro/syntax/declaration.lux @@ -38,8 +38,8 @@ (do random.monad [expected ..random] (_.cover [/.format /.parser] - (case (<code>.run /.parser - (list (/.format expected))) + (case (<code>.result /.parser + (list (/.format expected))) (#try.Failure _) false diff --git a/stdlib/source/test/lux/macro/syntax/definition.lux b/stdlib/source/test/lux/macro/syntax/definition.lux index 855a44545..ae7d5d3e5 100644 --- a/stdlib/source/test/lux/macro/syntax/definition.lux +++ b/stdlib/source/test/lux/macro/syntax/definition.lux @@ -68,8 +68,8 @@ untyped_value $///code.random] ($_ _.and (_.cover [/.format /.parser] - (case (<code>.run (/.parser compiler) - (list (/.format expected))) + (case (<code>.result (/.parser compiler) + (list (/.format expected))) (#try.Failure error) false @@ -77,8 +77,8 @@ (\ /.equivalence = expected actual))) (_.cover [/.typed] (let [expected (set@ #/.value (#.Left [type untyped_value]) expected)] - (case (<code>.run (/.typed compiler) - (list (/.format expected))) + (case (<code>.result (/.typed compiler) + (list (/.format expected))) (#try.Failure error) false @@ -86,8 +86,8 @@ (\ /.equivalence = expected actual)))) (_.cover [/.lacks_type!] (let [expected (set@ #/.value (#.Right untyped_value) expected)] - (case (<code>.run (/.typed compiler) - (list (/.format expected))) + (case (<code>.result (/.typed compiler) + (list (/.format expected))) (#try.Failure error) (exception.match? /.lacks_type! error) diff --git a/stdlib/source/test/lux/macro/syntax/export.lux b/stdlib/source/test/lux/macro/syntax/export.lux index 58d8b50a5..1653dc4b4 100644 --- a/stdlib/source/test/lux/macro/syntax/export.lux +++ b/stdlib/source/test/lux/macro/syntax/export.lux @@ -5,11 +5,10 @@ [abstract [monad (#+ do)]] [control + ["." maybe] ["." try ("#\." functor)] [parser ["<.>" code]]] - [data - ["." maybe]] [macro ["." code ("#\." equivalence)]] [math @@ -39,7 +38,7 @@ #.None (list (code.nat expected_un_exported))) - (<code>.run (/.parser <code>.nat)) + (<code>.result (/.parser <code>.nat)) (try\map (function (_ [actual_export_policy actual_un_exported]) (|> expected_export_policy (maybe.else /.default_policy) diff --git a/stdlib/source/test/lux/macro/syntax/input.lux b/stdlib/source/test/lux/macro/syntax/input.lux index fe01ab496..77fd87b58 100644 --- a/stdlib/source/test/lux/macro/syntax/input.lux +++ b/stdlib/source/test/lux/macro/syntax/input.lux @@ -37,8 +37,8 @@ (do random.monad [expected ..random] (_.cover [/.format /.parser] - (case (<code>.run /.parser - (list (/.format expected))) + (case (<code>.result /.parser + (list (/.format expected))) (#try.Failure _) false diff --git a/stdlib/source/test/lux/macro/syntax/type/variable.lux b/stdlib/source/test/lux/macro/syntax/type/variable.lux index af57cc222..cf8d65157 100644 --- a/stdlib/source/test/lux/macro/syntax/type/variable.lux +++ b/stdlib/source/test/lux/macro/syntax/type/variable.lux @@ -31,7 +31,7 @@ [expected ..random] (_.cover [/.format /.parser] (|> (list (/.format expected)) - (<code>.run /.parser) + (<code>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false)))) ))) diff --git a/stdlib/source/test/lux/math/logic/fuzzy.lux b/stdlib/source/test/lux/math/logic/fuzzy.lux index f97ffb24f..4b1a6919a 100644 --- a/stdlib/source/test/lux/math/logic/fuzzy.lux +++ b/stdlib/source/test/lux/math/logic/fuzzy.lux @@ -89,7 +89,7 @@ [bottom middle_bottom middle_top top] (|> random.rev (random.set r.hash 4) - (\ ! map (|>> set.list (list.sort r.<))) + (\ ! map (|>> set.list (list.sorted r.<))) (random.one (function (_ thresholds) (case thresholds (^ (list threshold_0 threshold_1 threshold_2 threshold_3)) @@ -173,7 +173,7 @@ [bottom middle_bottom middle_top top] (|> random.rev (random.set r.hash 4) - (\ ! map (|>> set.list (list.sort r.<))) + (\ ! map (|>> set.list (list.sorted r.<))) (random.one (function (_ thresholds) (case thresholds (^ (list threshold_0 threshold_1 threshold_2 threshold_3)) diff --git a/stdlib/source/test/lux/math/number/i64.lux b/stdlib/source/test/lux/math/number/i64.lux index 9e9228ab6..5eedd7f9d 100644 --- a/stdlib/source/test/lux/math/number/i64.lux +++ b/stdlib/source/test/lux/math/number/i64.lux @@ -173,12 +173,12 @@ (n.= /.bits_per_byte (n./ /.bytes_per_i64 /.width)))) (_.cover [/.false] - (n.= 0 (/.count /.false))) + (n.= 0 (/.ones /.false))) (_.cover [/.or] (and (\= /.true (/.or /.true pattern)) (\= pattern (/.or /.false pattern)))) (_.cover [/.true] - (n.= /.width (/.count /.true))) + (n.= /.width (/.ones /.true))) (_.cover [/.and] (and (\= pattern (/.and /.true pattern)) (\= /.false (/.and /.false pattern)))) @@ -196,16 +196,16 @@ (\= /.false (/.xor pattern pattern)))) - (_.cover [/.count] + (_.cover [/.ones] (let [clear&set! (if (/.set? idx pattern) - (n.= (dec (/.count pattern)) (/.count (/.clear idx pattern))) - (n.= (inc (/.count pattern)) (/.count (/.set idx pattern)))) + (n.= (dec (/.ones pattern)) (/.ones (/.clear idx pattern))) + (n.= (inc (/.ones pattern)) (/.ones (/.set idx pattern)))) complementarity! (n.= /.width - (n.+ (/.count pattern) - (/.count (/.not pattern))))] + (n.+ (/.ones pattern) + (/.ones (/.not pattern))))] (and clear&set! complementarity!))) (_.cover [/.left_rotated /.right_rotated] diff --git a/stdlib/source/test/lux/math/number/ratio.lux b/stdlib/source/test/lux/math/number/ratio.lux index baf9f23a1..27da768f8 100644 --- a/stdlib/source/test/lux/math/number/ratio.lux +++ b/stdlib/source/test/lux/math/number/ratio.lux @@ -9,9 +9,10 @@ ["$." order] ["$." monoid] ["$." codec]]] - [data - ["." bit ("#\." equivalence)] + [control ["." maybe ("#\." functor)]] + [data + ["." bit ("#\." equivalence)]] [math ["." random (#+ Random)]]]] [\\library diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index 9684fd3f6..2d7198c46 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -11,10 +11,10 @@ ["$." apply] ["$." monad]]] [control + ["." maybe] ["." try (#+ Try) ("#\." functor)]] [data ["." product] - ["." maybe] ["." bit ("#\." equivalence)] ["." name ("#\." equivalence)] ["." text ("#\." equivalence) @@ -67,20 +67,20 @@ #.extensions [] #.host []}]] ($_ _.and - (_.cover [/.run] + (_.cover [/.result] (|> (\ /.monad in expected) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual) (n.= expected actual))))) - (_.cover [/.run'] + (_.cover [/.result'] (|> (\ /.monad in expected) - (/.run' expected_lux) + (/.result' expected_lux) (!expect (^multi (#try.Success [actual_lux actual]) (and (is? expected_lux actual_lux) (n.= expected actual)))))) (_.cover [/.get_compiler] (|> /.get_compiler - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_lux) (is? expected_lux actual_lux))))) ))) @@ -117,43 +117,43 @@ (_.cover [/.failure] (|> (/.failure expected_error) (: (Meta Any)) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Failure actual_error) (text\= (location.with location.dummy expected_error) actual_error))))) (_.cover [/.assertion] (and (|> (/.assertion expected_error true) (: (Meta Any)) - (/.run expected_lux) + (/.result expected_lux) (!expect (#try.Success []))) (|> (/.assertion expected_error false) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Failure actual_error) (text\= expected_error actual_error)))))) (_.cover [/.either] (and (|> (/.either (\ /.monad in expected) (: (Meta Nat) (/.failure expected_error))) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual) (n.= expected actual)))) (|> (/.either (: (Meta Nat) (/.failure expected_error)) (\ /.monad in expected)) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual) (n.= expected actual)))) (|> (/.either (: (Meta Nat) (/.failure expected_error)) (: (Meta Nat) (/.failure expected_error))) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Failure actual_error) (text\= (location.with location.dummy expected_error) actual_error)))) (|> (/.either (\ /.monad in expected) (\ /.monad in dummy)) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual) (n.= expected actual)))) )) @@ -217,58 +217,58 @@ ($_ _.and (_.cover [/.current_module_name] (|> /.current_module_name - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_current_module) (text\= expected_current_module actual_current_module))))) (_.cover [/.current_module] (|> /.current_module - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_module) (is? expected_module actual_module))))) (_.cover [/.module] (|> (/.module expected_current_module) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_module) (is? expected_module actual_module))))) (_.cover [/.module_exists?] (and (|> (/.module_exists? expected_current_module) - (/.run expected_lux) + (/.result expected_lux) (!expect (#try.Success #1))) (|> (/.module_exists? dummy_module) - (/.run expected_lux) + (/.result expected_lux) (!expect (#try.Success #0))))) (_.cover [/.modules] (|> /.modules - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_modules) (is? expected_modules actual_modules))))) (_.cover [/.imported_modules] (and (|> (/.imported_modules expected_current_module) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ (list.equivalence text.equivalence) = (list imported_module_name))) (try.else false)) (|> (/.imported_modules imported_module_name) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ (list.equivalence text.equivalence) = (list))) (try.else false)))) (_.cover [/.imported_by?] (|> (/.imported_by? imported_module_name expected_current_module) - (/.run expected_lux) + (/.result expected_lux) (try.else false))) (_.cover [/.imported?] (|> (/.imported? imported_module_name) - (/.run expected_lux) + (/.result expected_lux) (try.else false))) (_.cover [/.normal] (and (|> (/.normal ["" expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success [actual_module actual_short]) (and (text\= expected_current_module actual_module) (is? expected_short actual_short))))) (|> (/.normal [dummy_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success [actual_module actual_short]) (and (text\= dummy_module actual_module) (is? expected_short actual_short))))))) @@ -317,23 +317,23 @@ [pre /.seed post /.seed] (in [pre post])) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success [actual_pre actual_post]) (and (n.= expected_seed actual_pre) (n.= (inc expected_seed) actual_post)))))) (_.cover [/.location] (|> /.location - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_location) (is? expected_location actual_location))))) (_.cover [/.expected_type] (|> /.expected_type - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_type) (is? expected_type actual_type))))) (_.cover [.Type_Context /.type_context] (|> /.type_context - (/.run expected_lux) + (/.result expected_lux) (try\map (is? type_context)) (try.else false))) ))) @@ -409,13 +409,13 @@ current_globals! (|> (/.globals expected_current_module) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_globals) (is? current_globals actual_globals)))) macro_globals! (|> (/.globals expected_macro_module) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_globals) (is? macro_globals actual_globals))))] (and current_globals! @@ -424,11 +424,11 @@ (let [[current_globals macro_globals expected_lux] (expected_lux true (#.Some .Macro))] (and (|> (/.definitions expected_current_module) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_definitions) (n.= 0 (list.size actual_definitions))))) (|> (/.definitions expected_macro_module) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_definitions) (n.= 1 (list.size actual_definitions))))) ))) @@ -436,22 +436,22 @@ (and (let [[current_globals macro_globals expected_lux] (expected_lux true (#.Some .Macro))] (and (|> (/.exports expected_current_module) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_definitions) (n.= 0 (list.size actual_definitions))))) (|> (/.exports expected_macro_module) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_definitions) (n.= 1 (list.size actual_definitions))))) )) (let [[current_globals macro_globals expected_lux] (expected_lux false (#.Some .Macro))] (and (|> (/.exports expected_current_module) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_definitions) (n.= 0 (list.size actual_definitions))))) (|> (/.exports expected_macro_module) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_definitions) (n.= 0 (list.size actual_definitions))))) )))) @@ -528,19 +528,19 @@ (and (let [[current_globals macro_globals expected_lux] (expected_lux true (#.Some expected_type))] (|> (/.export [expected_macro_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (#try.Success _)))) (let [[current_globals macro_globals expected_lux] (expected_lux false (#.Some expected_type))] (|> (/.export [expected_macro_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (#try.Failure _)))))) (_.cover [/.macro] (let [same_module! (let [[current_globals macro_globals expected_lux] (expected_lux true (#.Some .Macro))] (|> (/.macro [expected_macro_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success (#.Some actual_value)) (is? expected_value actual_value))))) @@ -548,21 +548,21 @@ (let [[current_globals macro_globals expected_lux] (expected_lux true (#.Some expected_type))] (|> (/.macro [expected_macro_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (#try.Success #.None)))) not_found! (let [[current_globals macro_globals expected_lux] (expected_lux true #.None)] (|> (/.macro [expected_macro_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (#try.Success #.None)))) aliasing! (let [[current_globals macro_globals expected_lux] (expected_lux true (#.Some .Macro))] (|> (/.macro [expected_current_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success (#.Some actual_value)) (is? expected_value actual_value)))))] (and same_module! @@ -573,11 +573,11 @@ (let [[current_globals macro_globals expected_lux] (expected_lux true (#.Some .Macro))] (and (|> (/.de_aliased [expected_macro_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (try\map (name\= [expected_macro_module expected_short])) (try.else false)) (|> (/.de_aliased [expected_current_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (try\map (name\= [expected_macro_module expected_short])) (try.else false))))) (_.cover [/.definition] @@ -586,7 +586,7 @@ definition! (|> (/.definition [expected_macro_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success (#.Definition [actual_exported? actual_type actual_annotations actual_value])) (and (bit\= expected_exported? actual_exported?) (is? expected_type actual_type) @@ -595,7 +595,7 @@ alias! (|> (/.definition [expected_current_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success (#.Alias [actual_module actual_short])) (and (is? expected_macro_module actual_module) (is? expected_short actual_short)))))] @@ -607,13 +607,13 @@ definition! (|> (/.definition_type [expected_macro_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_type) (is? expected_type actual_type)))) alias! (|> (/.definition_type [expected_current_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_type) (is? expected_type actual_type))))] (and definition! @@ -624,13 +624,13 @@ definition! (|> (/.type_definition [expected_macro_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_value) (is? (:as .Type expected_value) actual_value)))) alias! (|> (/.type_definition [expected_current_module expected_short]) - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual_value) (is? (:as .Type expected_value) actual_value))))] (and definition! @@ -711,12 +711,12 @@ (list.equivalence name.equivalence) type.equivalence))] (|> (/.tag_lists tag_module) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ equivalence = (list [tags_1 type_1]))) (try.else false)))) (_.cover [/.tags_of] (|> (/.tags_of [tag_module name_1]) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ (maybe.equivalence (list.equivalence name.equivalence)) = (#.Some tags_1))) (try.else false))) (_.cover [/.tag] @@ -725,7 +725,7 @@ (list.every? (function (_ [expected_index tag]) (|> tag /.tag - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (^ (#try.Success [actual_index actual_tags actual_type])) (let [correct_index! (n.= expected_index @@ -822,51 +822,51 @@ text.equivalence type.equivalence))))] (|> /.locals - (/.run expected_lux) + (/.result expected_lux) (try\map (\ equivalence = (list (list [name_3 type_3]) (list [name_1 type_1] [name_2 type_2])))) (try.else false)))) (_.cover [/.var_type] (and (|> (/.var_type name_0) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ type.equivalence = type_0)) (try.else false)) (|> (/.var_type name_1) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ type.equivalence = type_1)) (try.else false)) (|> (/.var_type name_2) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ type.equivalence = type_2)) (try.else false)) (|> (/.var_type name_3) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ type.equivalence = type_3)) (try.else false)))) (_.cover [/.type] (and (|> (/.type ["" name_0]) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ type.equivalence = type_0)) (try.else false)) (|> (/.type ["" name_1]) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ type.equivalence = type_1)) (try.else false)) (|> (/.type ["" name_2]) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ type.equivalence = type_2)) (try.else false)) (|> (/.type ["" name_3]) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ type.equivalence = type_3)) (try.else false)) (|> (/.type [current_module name_4]) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ type.equivalence = type_4)) (try.else false)) (|> (/.type ["" name_4]) - (/.run expected_lux) + (/.result expected_lux) (try\map (\ type.equivalence = type_4)) (try.else false)))) ))) @@ -878,8 +878,8 @@ (def: (comparison init) (-> Lux (Comparison Meta)) (function (_ == left right) - (case [(/.run init left) - (/.run init right)] + (case [(/.result init left) + (/.result init right)] [(#try.Success left) (#try.Success right)] (== left right) @@ -935,7 +935,7 @@ #try.Failure (: (Try Nat)) /.lift - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Failure actual) (text\= (location.with expected_location expected_error) actual)))) @@ -943,7 +943,7 @@ #try.Success (: (Try Nat)) /.lift - (/.run expected_lux) + (/.result expected_lux) (!expect (^multi (#try.Success actual) (is? expected_value actual))))))) diff --git a/stdlib/source/test/lux/program.lux b/stdlib/source/test/lux/program.lux index df55e17f4..0321a5441 100644 --- a/stdlib/source/test/lux/program.lux +++ b/stdlib/source/test/lux/program.lux @@ -38,21 +38,21 @@ (let [outcome ((: (-> (List Text) (io.IO Any)) (..actual_program <program>)) inputs)] - (is? (: Any inputs) (io.run outcome)))) + (is? (: Any inputs) (io.run! outcome)))) (with_expansions [<program> (/.program: [arg/0 arg/1 arg/2 arg/3 arg/4] (io.io (list arg/4 arg/3 arg/2 arg/1 arg/0)))] (let [outcome ((: (-> (List Text) (io.IO Any)) (..actual_program <program>)) inputs)] (list\= (list.reversed inputs) - (:as (List Text) (io.run outcome))))) + (:as (List Text) (io.run! outcome))))) (with_expansions [<program> (/.program: [{all_arguments (<>.many <cli>.any)}] (io.io all_arguments))] (let [outcome ((: (-> (List Text) (io.IO Any)) (..actual_program <program>)) inputs)] (list\= inputs - (:as (List Text) (io.run outcome))))) + (:as (List Text) (io.run! outcome))))) (with_expansions [<program> (/.program: [arg/0 arg/1 arg/2 arg/3] (io.io []))] (case (try ((: (-> (List Text) (io.IO Any)) diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index dfe6180ab..f503c8779 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -8,11 +8,11 @@ [control ["." function] ["." io] + ["." maybe] ["." try] [concurrency ["." atom]]] [data - ["." maybe] ["." bit ("#\." equivalence)] ["." text ("#\." equivalence) ["%" format (#+ format)]] @@ -121,10 +121,10 @@ [_ bytecode] /.areturn)))) (row.row)) - .let [bytecode (format.run /class.writer class) + .let [bytecode (format.result /class.writer class) loader (/loader.memory (/loader.new_library []))] _ (/loader.define class_name bytecode loader) - class (io.run (/loader.load class_name loader)) + class (io.run! (/loader.load class_name loader)) method (try (get_method method_name class))] (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)) (#try.Success actual) @@ -887,12 +887,12 @@ /.areturn)))) (row.row)) try.assumed - (format.run /class.writer)) + (format.result /class.writer)) loader (/loader.memory (/loader.new_library []))]] (_.test "PUTSTATIC & PUTFIELD & GETFIELD & GETSTATIC" (case (do try.monad [_ (/loader.define class_name bytecode loader) - class (io.run (/loader.load class_name loader)) + class (io.run! (/loader.load class_name loader)) method (try (get_method static_method class)) output (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)] (in (:as Int output))) @@ -1354,10 +1354,10 @@ _ (get@ #wrap primitive)] /.areturn)))) (row.row)) - .let [bytecode (format.run /class.writer class) + .let [bytecode (format.result /class.writer class) loader (/loader.memory (/loader.new_library []))] _ (/loader.define class_name bytecode loader) - class (io.run (/loader.load class_name loader)) + class (io.run! (/loader.load class_name loader)) method (try (get_method object_method_name class))] (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)) (#try.Success actual) @@ -1635,7 +1635,7 @@ interface_method method::type (list) #.None)) (row.row)) try.assumed - (format.run /class.writer)) + (format.result /class.writer)) abstract_bytecode (|> (/class.class /version.v6_0 ($_ /modifier\compose /class.public /class.abstract) (/name.internal abstract_class) (/name.internal "java.lang.Object") @@ -1655,7 +1655,7 @@ abstract_method method::type (list) #.None)) (row.row)) try.assumed - (format.run /class.writer)) + (format.result /class.writer)) invoke (: (-> (Type Class) Text (Bytecode Any)) (function (_ class method) (do /.monad @@ -1702,14 +1702,14 @@ /.areturn)))) (row.row)) try.assumed - (format.run /class.writer)) + (format.result /class.writer)) loader (/loader.memory (/loader.new_library []))]] (_.test "Class & interface inheritance" (case (do try.monad [_ (/loader.define abstract_class abstract_bytecode loader) _ (/loader.define interface_class interface_bytecode loader) _ (/loader.define concrete_class concrete_bytecode loader) - class (io.run (/loader.load concrete_class loader)) + class (io.run! (/loader.load concrete_class loader)) method (try (get_method static_method class)) output (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)] (in (:as Int output))) diff --git a/stdlib/source/test/lux/test.lux b/stdlib/source/test/lux/test.lux index 0df2e43d3..fe60e832c 100644 --- a/stdlib/source/test/lux/test.lux +++ b/stdlib/source/test/lux/test.lux @@ -70,7 +70,7 @@ pre (<| (/.seed seed) (do ! [sample random.nat - .let [wrote? (io.run (write sample))]] + .let [wrote? (io.run! (write sample))]] (/.test "" wrote?))) post (<| (/.seed seed) (do ! @@ -105,7 +105,7 @@ times_assertion (<| (/.times expected) (do ! [_ (in []) - .let [_ (io.run (atom.update! inc counter))]] + .let [_ (io.run! (atom.update! inc counter))]] (/.test "" true)))] (in (do async.monad [[tally error] times_assertion @@ -128,7 +128,7 @@ (: /.Test) (do ! [_ (in []) - .let [_ (io.run (atom.update! inc counter))]] + .let [_ (io.run! (atom.update! inc counter))]] (/.test "" true)))] (in (do async.monad [[tally error] assertion @@ -147,7 +147,7 @@ (do ! [_ (in []) .let [_ (undefined) - _ (io.run (atom.update! inc counter))]] + _ (io.run! (atom.update! inc counter))]] (/.test "" true)))] (in (do async.monad [[tally error] assertion diff --git a/stdlib/source/test/lux/time.lux b/stdlib/source/test/lux/time.lux index e87761302..671afe39d 100644 --- a/stdlib/source/test/lux/time.lux +++ b/stdlib/source/test/lux/time.lux @@ -139,7 +139,7 @@ (_.cover [/.parser] (|> expected (\ /.codec encode) - (<text>.run /.parser) + (<text>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false))) ..for_ranges diff --git a/stdlib/source/test/lux/time/date.lux b/stdlib/source/test/lux/time/date.lux index 10c44e678..872e7f2ce 100644 --- a/stdlib/source/test/lux/time/date.lux +++ b/stdlib/source/test/lux/time/date.lux @@ -73,7 +73,7 @@ [expected random.date] (_.cover [/.parser] (|> (\ /.codec encode expected) - (<text>.run /.parser) + (<text>.result /.parser) (try\map (\ /.equivalence = expected)) (try.else false)))) (do {! random.monad} @@ -87,7 +87,7 @@ "-" (%.nat month) "-" (%.nat day))]] (_.cover [/.invalid_month] - (case (<text>.run /.parser input) + (case (<text>.result /.parser input) (#try.Failure error) (exception.match? /.invalid_month error) diff --git a/stdlib/source/test/lux/time/instant.lux b/stdlib/source/test/lux/time/instant.lux index 6e7c90821..a7659421a 100644 --- a/stdlib/source/test/lux/time/instant.lux +++ b/stdlib/source/test/lux/time/instant.lux @@ -97,7 +97,7 @@ (apply duration.inverse day\pred 6) (apply duration.inverse day\pred 7))))) (_.cover [/.now] - (case (try (io.run /.now)) + (case (try (io.run! /.now)) (#try.Success _) true diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux index ac408d71d..beaf1169e 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux @@ -8,10 +8,10 @@ ["r" math/random (#+ Random) ("#\." monad)] ["_" test (#+ Test)] [control - pipe] + pipe + ["." maybe]] [data ["." product] - ["." maybe] ["." text ("#\." equivalence)] [number ["n" nat]] @@ -196,7 +196,7 @@ (|> (analyse_pm redundant_branchesC) _structure.check_fails))) (do ! - [[heterogeneousT heterogeneousC] (r.only (|>> product.left (check.checks? outputT) not) + [[heterogeneousT heterogeneousC] (r.only (|>> product.left (check.subsumes? outputT) not) _primitive.primitive) heterogeneous_idx (|> r.nat (\ ! map (n.% (list.size exhaustive_patterns)))) .let [heterogeneous_branchesC (list.concat (list (list.take heterogeneous_idx exhaustive_branchesC) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux index 7981f1422..3e97c0dbd 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux @@ -9,9 +9,9 @@ ["_" test (#+ Test)] [control pipe + ["." maybe] ["." try]] [data - ["." maybe] ["." product] ["." text ("#\." equivalence)] [number @@ -42,7 +42,7 @@ (-> Type Nat (Operation Analysis) Bit) (|> analysis (//type.with_type expectedT) - (phase.run _primitive.state) + (phase.result _primitive.state) (case> (#try.Success applyA) (let [[funcA argsA] (////analysis.application applyA)] (n.= num_args (list.size argsA))) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/primitive.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/primitive.lux index 3b93ae562..8df54a276 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/primitive.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/primitive.lux @@ -74,7 +74,7 @@ (-> Type (Operation Analysis) (Try Analysis)) (|> analysis //type.with_inference - (phase.run ..state) + (phase.result ..state) (case> (#try.Success [inferred_type output]) (if (is? expected_type inferred_type) (#try.Success output) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux index 2d1a34d1b..ef7be9dcd 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux @@ -59,7 +59,7 @@ (in []))] (//type.with_inference (_primitive.phase archive.empty (code.identifier [def_module var_name])))))) - (phase.run _primitive.state) + (phase.result _primitive.state) check!)) (def: .public test @@ -77,7 +77,7 @@ (//scope.with_local [var_name expectedT] (//type.with_inference (_primitive.phase archive.empty (code.local_identifier var_name))))) - (phase.run _primitive.state) + (phase.result _primitive.state) (case> (^ (#try.Success [inferredT (#////analysis.Reference (////reference.local var))])) (and (type\= expectedT inferredT) (n.= 0 var)) @@ -91,7 +91,7 @@ (//type.with_inference (_primitive.phase archive.empty (code.identifier def_name)))) (//module.with_module 0 def_module) - (phase.run _primitive.state) + (phase.result _primitive.state) (case> (^ (#try.Success [_ inferredT (#////analysis.Reference (////reference.constant constant_name))])) (and (type\= expectedT inferredT) (name\= def_name constant_name)) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux index 9bc61107b..fcb23d771 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux @@ -8,11 +8,11 @@ ["_" test (#+ Test)] [control pipe + ["." maybe] ["." try]] [data ["." bit ("#\." equivalence)] ["." product] - ["." maybe] ["." text] [number ["n" nat]] @@ -41,7 +41,7 @@ (template [<name> <on_success> <on_error>] [(def: .public <name> (All [a] (-> (Operation a) Bit)) - (|>> (phase.run _primitive.state) + (|>> (phase.result _primitive.state) (case> (#try.Success _) <on_success> @@ -69,7 +69,7 @@ (-> Type Tag Nat (Operation Analysis) Bit) (|> analysis (//type.with_type type) - (phase.run _primitive.state) + (phase.result _primitive.state) (case> (^ (#try.Success (////analysis.variant variant))) (check_sum' tag size variant) @@ -87,7 +87,7 @@ (|> analysis (with_tags module tags variantT) (//type.with_type expectedT) - (phase.run _primitive.state) + (phase.result _primitive.state) (case> (^ (#try.Success [_ (////analysis.variant variant)])) (check_sum' tag (list.size tags) variant) @@ -109,7 +109,7 @@ (|> analysis (with_tags module tags recordT) (//type.with_type expectedT) - (phase.run _primitive.state) + (phase.result _primitive.state) (case> (#try.Success [_ productA]) (correct_size? size productA) @@ -143,7 +143,7 @@ (check.check varT variantT))] (//type.with_type varT (/.sum _primitive.phase choice archive.empty valueC))) - (phase.run _primitive.state) + (phase.result _primitive.state) (case> (^ (#try.Success (////analysis.variant variant))) (check_sum' choice size variant) @@ -185,7 +185,7 @@ (_.test "Can analyse." (|> (//type.with_type tupleT (/.product archive.empty _primitive.phase (list\map product.right primitives))) - (phase.run _primitive.state) + (phase.result _primitive.state) (case> (#try.Success tupleA) (correct_size? size tupleA) @@ -194,9 +194,9 @@ (_.test "Can infer." (|> (//type.with_inference (/.product archive.empty _primitive.phase (list\map product.right primitives))) - (phase.run _primitive.state) + (phase.result _primitive.state) (case> (#try.Success [_type tupleA]) - (and (check.checks? tupleT _type) + (and (check.subsumes? tupleT _type) (correct_size? size tupleA)) _ @@ -212,7 +212,7 @@ (check.check varT (type.tuple (list\map product.left primitives))))] (//type.with_type varT (/.product archive.empty _primitive.phase (list\map product.right primitives)))) - (phase.run _primitive.state) + (phase.result _primitive.state) (case> (#try.Success tupleA) (correct_size? size tupleA) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux index 508eed47f..30ad64e34 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux @@ -38,7 +38,7 @@ (|> (////scope.with_scope "" (////type.with_type output_type (_primitive.phase archive.empty (` ((~ (code.text procedure)) (~+ params)))))) - (phase.run _primitive.state) + (phase.result _primitive.state) (case> (#try.Success _) <success> diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux index 6d83f1fa7..224349569 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -52,7 +52,7 @@ (_.cover [/.synthesize_masking] (|> maskA (//.phase archive.empty) - (phase.run [///bundle.empty synthesis.init]) + (phase.result [///bundle.empty synthesis.init]) (try\map (//primitive.corresponds? maskedA)) (try.default false))))) @@ -70,7 +70,7 @@ (_.cover [/.synthesize_let] (|> letA (//.phase archive.empty) - (phase.run [///bundle.empty synthesis.init]) + (phase.result [///bundle.empty synthesis.init]) (case> (^ (#try.Success (synthesis.branch/let [inputS registerS outputS]))) (and (n.= registerA registerS) (//primitive.corresponds? inputA inputS) @@ -98,7 +98,7 @@ (_.cover [/.synthesize_if] (|> ifA (//.phase archive.empty) - (phase.run [///bundle.empty synthesis.init]) + (phase.result [///bundle.empty synthesis.init]) (case> (^ (#try.Success (synthesis.branch/if [inputS thenS elseS]))) (and (//primitive.corresponds? inputA inputS) (//primitive.corresponds? thenA thenS) @@ -157,7 +157,7 @@ (_.cover [/.synthesize_get] (|> getA (//.phase archive.empty) - (phase.run [///bundle.empty synthesis.init]) + (phase.result [///bundle.empty synthesis.init]) (case> (^ (#try.Success (synthesis.branch/get [pathS recordS]))) (and (\ (list.equivalence (sum.equivalence n.= n.=)) = pathA pathS) (//primitive.corresponds? recordA recordS)) @@ -332,7 +332,7 @@ [expected_path match] ..random_case] (_.cover [/.synthesize_case] (|> (/.synthesize_case //.phase archive.empty expected_input match) - (phase.run [///bundle.empty synthesis.init]) + (phase.result [///bundle.empty synthesis.init]) (case> (^ (#try.Success (synthesis.branch/case [actual_input actual_path]))) (and (\ synthesis.equivalence = expected_input actual_input) (\ synthesis.path_equivalence = expected_path actual_path)) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 31e5e3422..692a2fab9 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -7,7 +7,6 @@ ["." try]] [data ["." product] - ["." maybe] ["." text ["%" format (#+ format)]] [number @@ -431,7 +430,7 @@ (_.cover [/.abstraction] (|> input (//.phase archive.empty) - (phase.run [///bundle.empty synthesis.init]) + (phase.result [///bundle.empty synthesis.init]) (!expect (^multi (#try.Success actual) (\ synthesis.equivalence = expected actual))))))) @@ -444,14 +443,14 @@ (_.cover [/.apply] (and (|> (analysis.apply [funcA argsA]) (//.phase archive.empty) - (phase.run [///bundle.empty synthesis.init]) + (phase.result [///bundle.empty synthesis.init]) (!expect (^multi (^ (#try.Success (synthesis.function/apply [funcS argsS]))) (and (//primitive.corresponds? funcA funcS) - (list.every? (product.uncurry //primitive.corresponds?) + (list.every? (product.uncurried //primitive.corresponds?) (list.zipped/2 argsA argsS)))))) (|> (analysis.apply [funcA (list)]) (//.phase archive.empty) - (phase.run [///bundle.empty synthesis.init]) + (phase.result [///bundle.empty synthesis.init]) (!expect (^multi (#try.Success funcS) (//primitive.corresponds? funcA funcS)))))))) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux index 25524e590..529db21df 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux @@ -80,7 +80,7 @@ (_.test (%.name (name_of <synthesis>)) (|> (#////analysis.Primitive (<analysis> expected)) (//.phase archive.empty) - (phase.run [///bundle.empty ////synthesis.init]) + (phase.result [///bundle.empty ////synthesis.init]) (case> (#try.Success (#////synthesis.Primitive (<synthesis> actual))) (is? expected actual) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux index 4db00f1f2..a7fa786fb 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux @@ -45,7 +45,7 @@ (_.test "Can synthesize variants." (|> (////analysis.variant [lefts right? memberA]) (//.phase archive.empty) - (phase.run [///bundle.empty ////synthesis.init]) + (phase.result [///bundle.empty ////synthesis.init]) (case> (^ (#try.Success (////synthesis.variant [leftsS right?S valueS]))) (let [tagS (if right?S (inc leftsS) leftsS)] (and (n.= tagA tagS) @@ -63,10 +63,10 @@ (_.test "Can synthesize tuple." (|> (////analysis.tuple membersA) (//.phase archive.empty) - (phase.run [///bundle.empty ////synthesis.init]) + (phase.result [///bundle.empty ////synthesis.init]) (case> (^ (#try.Success (////synthesis.tuple membersS))) (and (n.= size (list.size membersS)) - (list.every? (product.uncurry //primitive.corresponds?) + (list.every? (product.uncurried //primitive.corresponds?) (list.zipped/2 membersA membersS))) _ diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux index 5b2327dc4..46adc6884 100644 --- a/stdlib/source/test/lux/type.lux +++ b/stdlib/source/test/lux/type.lux @@ -7,9 +7,9 @@ [\\specification ["$." equivalence]]] [control - [pipe (#+ case>)]] + [pipe (#+ case>)] + ["." maybe]] [data - ["." maybe] ["." bit ("#\." equivalence)] ["." text ("#\." equivalence)] [collection diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux index 57df78e84..ef086d142 100644 --- a/stdlib/source/test/lux/type/check.lux +++ b/stdlib/source/test/lux/type/check.lux @@ -16,7 +16,6 @@ [data ["." bit ("#\." equivalence)] ["." product] - ["." maybe] ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection @@ -96,7 +95,7 @@ (def: comparison (Comparison (All [a] (/.Check a))) (function (_ == left right) - (case [(/.run /.fresh_context left) (/.run /.fresh_context right)] + (case [(/.result /.fresh_context left) (/.result /.fresh_context right)] [(#try.Success left) (#try.Success right)] (== left right) @@ -122,26 +121,26 @@ (do random.monad [expected (random.ascii/upper 10)] (_.cover [/.failure] - (case (/.run /.fresh_context - (: (/.Check Any) - (/.failure expected))) + (case (/.result /.fresh_context + (: (/.Check Any) + (/.failure expected))) (#try.Success _) false (#try.Failure actual) (is? expected actual)))) (do random.monad [expected (random.ascii/upper 10)] (_.cover [/.assertion] - (and (case (/.run /.fresh_context - (: (/.Check Any) - (/.assertion expected true))) + (and (case (/.result /.fresh_context + (: (/.Check Any) + (/.assertion expected true))) (#try.Success _) true (#try.Failure actual) false) - (case (/.run /.fresh_context (/.assertion expected false)) + (case (/.result /.fresh_context (/.assertion expected false)) (#try.Success _) false (#try.Failure actual) (is? expected actual))))) (_.cover [/.except] - (case (/.run /.fresh_context - (: (/.Check Any) - (/.except ..yolo []))) + (case (/.result /.fresh_context + (: (/.Check Any) + (/.except ..yolo []))) (#try.Success _) false (#try.Failure error) (exception.match? ..yolo error))) )) @@ -151,21 +150,21 @@ (<| (_.for [/.Var]) ($_ _.and (_.cover [/.var] - (case (/.run /.fresh_context - (do /.monad - [[var_id var_type] /.var] - (in (type\= var_type (#.Var var_id))))) + (case (/.result /.fresh_context + (do /.monad + [[var_id var_type] /.var] + (in (type\= var_type (#.Var var_id))))) (#try.Success verdict) verdict (#try.Failure error) false)) (do random.monad [nominal (random.ascii/upper 10)] (_.cover [/.bind] - (case (/.run /.fresh_context - (do /.monad - [[var_id var_type] /.var - _ (/.bind (#.Primitive nominal (list)) - var_id)] - (in true))) + (case (/.result /.fresh_context + (do /.monad + [[var_id var_type] /.var + _ (/.bind (#.Primitive nominal (list)) + var_id)] + (in true))) (#try.Success _) true (#try.Failure error) false))) (do random.monad @@ -179,7 +178,7 @@ post (/.bound? var_id)] (in (and (not pre) post))) - (/.run /.fresh_context) + (/.result /.fresh_context) (try.else false)) (|> (do /.monad [[var_id var/0] /.var @@ -189,18 +188,18 @@ post (/.bound? var_id)] (in (and (not pre) (not post)))) - (/.run /.fresh_context) + (/.result /.fresh_context) (try.else false))))) (do random.monad [nominal (random.ascii/upper 10)] (_.cover [/.cannot_rebind_var] - (case (/.run /.fresh_context - (do /.monad - [[var_id var_type] /.var - _ (/.bind (#.Primitive nominal (list)) - var_id)] - (/.bind (#.Primitive nominal (list)) - var_id))) + (case (/.result /.fresh_context + (do /.monad + [[var_id var_type] /.var + _ (/.bind (#.Primitive nominal (list)) + var_id)] + (/.bind (#.Primitive nominal (list)) + var_id))) (#try.Success _) false @@ -210,9 +209,9 @@ [nominal (random.ascii/upper 10) var_id random.nat] (_.cover [/.unknown_type_var] - (case (/.run /.fresh_context - (/.bind (#.Primitive nominal (list)) - var_id)) + (case (/.result /.fresh_context + (/.bind (#.Primitive nominal (list)) + var_id)) (#try.Success _) false @@ -225,7 +224,7 @@ (and (|> (do /.monad [[var_id var_type] /.var] (/.read var_id)) - (/.run /.fresh_context) + (/.result /.fresh_context) (case> (#try.Success #.None) true _ false)) (|> (do /.monad @@ -233,14 +232,14 @@ [_ var/1] /.var _ (/.check var/0 var/1)] (/.read var_id)) - (/.run /.fresh_context) + (/.result /.fresh_context) (case> (#try.Success #.None) true _ false)) (|> (do /.monad [[var_id var_type] /.var _ (/.bind expected var_id)] (/.read var_id)) - (/.run /.fresh_context) + (/.result /.fresh_context) (case> (#try.Success (#.Some actual)) (is? expected actual) @@ -250,11 +249,11 @@ [nominal (random.ascii/upper 10) .let [expected (#.Primitive nominal (list))]] (_.cover [/.read!] - (case (/.run /.fresh_context - (do /.monad - [[var_id var_type] /.var - _ (/.bind expected var_id)] - (/.read! var_id))) + (case (/.result /.fresh_context + (do /.monad + [[var_id var_type] /.var + _ (/.bind expected var_id)] + (/.read! var_id))) (#try.Success actual) (is? expected actual) @@ -264,10 +263,10 @@ [nominal (random.ascii/upper 10) .let [expected (#.Primitive nominal (list))]] (_.cover [/.unbound_type_var] - (case (/.run /.fresh_context - (do /.monad - [[var_id var_type] /.var] - (/.read! var_id))) + (case (/.result /.fresh_context + (do /.monad + [[var_id var_type] /.var] + (/.read! var_id))) (#try.Failure error) (exception.match? /.unbound_type_var error) @@ -283,16 +282,16 @@ (n.= 0 (get@ #.ex_counter /.fresh_context)) (list.empty? (get@ #.var_bindings /.fresh_context)))) (_.cover [/.context] - (and (case (/.run /.fresh_context /.context) + (and (case (/.result /.fresh_context /.context) (#try.Success actual) (is? /.fresh_context actual) (#try.Failure error) false) - (case (/.run /.fresh_context - (do /.monad - [_ /.var] - /.context)) + (case (/.result /.fresh_context + (do /.monad + [_ /.var] + /.context)) (#try.Success actual) (and (n.= 1 (get@ #.var_counter actual)) (n.= 0 (get@ #.ex_counter actual)) @@ -301,10 +300,10 @@ (#try.Failure error) false))) (_.cover [/.existential] - (case (/.run /.fresh_context - (do /.monad - [_ /.existential] - /.context)) + (case (/.result /.fresh_context + (do /.monad + [_ /.existential] + /.context)) (#try.Success actual) (and (n.= 0 (get@ #.var_counter actual)) (n.= 1 (get@ #.ex_counter actual)) @@ -316,7 +315,7 @@ (def: succeeds? (All [a] (-> (/.Check a) Bit)) - (|>> (/.run /.fresh_context) + (|>> (/.result /.fresh_context) (case> (#try.Success _) true @@ -687,7 +686,7 @@ cleanedT (/.clean (type_shape varT))] (in (type\= (type_shape varT) cleanedT))) - (/.run /.fresh_context) + (/.result /.fresh_context) (try.else false)) (|> (do /.monad [[var_id varT] /.var @@ -696,7 +695,7 @@ cleanedT (/.clean (type_shape varT))] (in (type\= (type_shape replacementT) cleanedT))) - (/.run /.fresh_context) + (/.result /.fresh_context) (try.else false)) )))) @@ -708,9 +707,9 @@ ..polymorphism (do random.monad [expected random.nat] - (_.cover [/.run] - (case (/.run /.fresh_context - (\ /.monad in expected)) + (_.cover [/.result] + (case (/.result /.fresh_context + (\ /.monad in expected)) (#try.Success actual) (is? expected actual) (#try.Failure error) false))) ..error_handling diff --git a/stdlib/source/test/lux/type/refinement.lux b/stdlib/source/test/lux/type/refinement.lux index 2c99f3163..369a2de9a 100644 --- a/stdlib/source/test/lux/type/refinement.lux +++ b/stdlib/source/test/lux/type/refinement.lux @@ -5,8 +5,9 @@ [abstract [predicate (#+ Predicate)] [monad (#+ do)]] + [control + ["." maybe ("#\." monad)]] [data - ["." maybe ("#\." monad)] [collection ["." list ("#\." functor)]]] [math diff --git a/stdlib/source/test/lux/type/resource.lux b/stdlib/source/test/lux/type/resource.lux index 18ee0164d..df66d6f74 100644 --- a/stdlib/source/test/lux/type/resource.lux +++ b/stdlib/source/test/lux/type/resource.lux @@ -32,13 +32,13 @@ [pre (\ ! map %.nat random.nat) post (\ ! map %.nat random.nat) .let [! identity.monad]] - (_.for [/.Linear /.run /.monad] + (_.for [/.Linear /.run! /.monad] (`` ($_ _.and (~~ (template [<coverage> <bindings>] [(_.cover <coverage> (<| (text\= (format pre post)) (: (Identity Text)) - (/.run !) + (/.run! !) (do (/.monad !) <bindings> (in (format left right)))))] @@ -74,14 +74,14 @@ [pre (\ ! map %.nat random.nat) post (\ ! map %.nat random.nat) .let [! io.monad]] - (_.for [/.Linear /.run /.monad] + (_.for [/.Linear /.run! /.monad] (`` ($_ _.and (~~ (template [<coverage> <bindings>] [(_.cover <coverage> (<| (text\= (format pre post)) - io.run + io.run! (: (IO Text)) - (/.run !) + (/.run! !) (do (/.monad !) <bindings> (in (format left right)))))] @@ -117,12 +117,12 @@ [pre (\ ! map %.nat random.nat) post (\ ! map %.nat random.nat) .let [! async.monad]] - (_.for [/.Linear /.run /.monad] + (_.for [/.Linear /.run! /.monad] (`` ($_ _.and (~~ (template [<coverage> <bindings>] [(in (monad.do ! [outcome (<| (: (Async Text)) - (/.run !) + (/.run! !) (do (/.monad !) <bindings> (in (format left right))))] diff --git a/stdlib/source/test/lux/type/variance.lux b/stdlib/source/test/lux/type/variance.lux index e683b1f64..b2a16a221 100644 --- a/stdlib/source/test/lux/type/variance.lux +++ b/stdlib/source/test/lux/type/variance.lux @@ -22,14 +22,14 @@ (<| (_.covering /._) ($_ _.and (_.cover [/.Co] - (and (//check.checks? (type (/.Co Super)) (type (/.Co Sub))) - (not (//check.checks? (type (/.Co Sub)) (type (/.Co Super)))))) + (and (//check.subsumes? (type (/.Co Super)) (type (/.Co Sub))) + (not (//check.subsumes? (type (/.Co Sub)) (type (/.Co Super)))))) (_.cover [/.Contra] - (and (//check.checks? (type (/.Contra Sub)) (type (/.Contra Super))) - (not (//check.checks? (type (/.Contra Super)) (type (/.Contra Sub)))))) + (and (//check.subsumes? (type (/.Contra Sub)) (type (/.Contra Super))) + (not (//check.subsumes? (type (/.Contra Super)) (type (/.Contra Sub)))))) (_.cover [/.In] - (and (//check.checks? (type (/.In Super)) (type (/.In Super))) - (//check.checks? (type (/.In Sub)) (type (/.In Sub))) - (not (//check.checks? (type (/.In Sub)) (type (/.In Super)))) - (not (//check.checks? (type (/.In Super)) (type (/.In Sub)))))) + (and (//check.subsumes? (type (/.In Super)) (type (/.In Super))) + (//check.subsumes? (type (/.In Sub)) (type (/.In Sub))) + (not (//check.subsumes? (type (/.In Sub)) (type (/.In Super)))) + (not (//check.subsumes? (type (/.In Super)) (type (/.In Sub)))))) ))) diff --git a/stdlib/source/test/lux/world/console.lux b/stdlib/source/test/lux/world/console.lux index c358ca699..945dfc352 100644 --- a/stdlib/source/test/lux/world/console.lux +++ b/stdlib/source/test/lux/world/console.lux @@ -58,7 +58,7 @@ [expected (random.ascii/alpha 10) .let [console (/.mock ..mock [false ""])]] (_.cover [/.write_line] - (io.run + (io.run! (do io.monad [?_ (/.write_line expected console) ?actual (\ console read_line [])] diff --git a/stdlib/source/test/lux/world/file/watch.lux b/stdlib/source/test/lux/world/file/watch.lux index f3e0d7968..98f589439 100644 --- a/stdlib/source/test/lux/world/file/watch.lux +++ b/stdlib/source/test/lux/world/file/watch.lux @@ -101,7 +101,7 @@ (-> (//.System Async) (/.Watcher Async) //.Path (Async (Try Bit))) (do (try.with async.monad) [_ (: (Async (Try Any)) - (//.make_file async.monad fs (binary.create 0) expected_path)) + (//.make_file async.monad fs (binary.empty 0) expected_path)) poll/pre (\ watcher poll []) poll/post (\ watcher poll [])] (in (and (case poll/pre diff --git a/stdlib/source/test/lux/world/input/keyboard.lux b/stdlib/source/test/lux/world/input/keyboard.lux index c9c6cfee3..28c2849be 100644 --- a/stdlib/source/test/lux/world/input/keyboard.lux +++ b/stdlib/source/test/lux/world/input/keyboard.lux @@ -4,9 +4,10 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)]] + [control + ["." maybe]] [data ["." bit ("#\." equivalence)] - ["." maybe] [collection ["." list] ["." set (#+ Set)]]] diff --git a/stdlib/source/test/lux/world/net/http/client.lux b/stdlib/source/test/lux/world/net/http/client.lux index d1726c7e0..24ece9d1e 100644 --- a/stdlib/source/test/lux/world/net/http/client.lux +++ b/stdlib/source/test/lux/world/net/http/client.lux @@ -69,8 +69,8 @@ [(_.cover [<definition>] (|> (<definition> "" //.empty #.None mock) (do> try.monad - [io.run] - [product.right (get@ #//.body) (function.apply #.None) io.run] + [io.run!] + [product.right (get@ #//.body) (function.apply #.None) io.run!] [product.right (\ utf8.codec decode)] [(\ nat.decimal decode)] [(nat.= <expected>) in]) diff --git a/stdlib/source/test/lux/world/output/video/resolution.lux b/stdlib/source/test/lux/world/output/video/resolution.lux index 0775b263e..543dcb3f7 100644 --- a/stdlib/source/test/lux/world/output/video/resolution.lux +++ b/stdlib/source/test/lux/world/output/video/resolution.lux @@ -7,8 +7,9 @@ [\\specification ["$." equivalence] ["$." hash]]] + [control + ["." maybe]] [data - ["." maybe] [collection ["." list] ["." set (#+ Set)]]] diff --git a/stdlib/source/test/lux/world/program.lux b/stdlib/source/test/lux/world/program.lux index 50e1b4ffd..f2643a3b7 100644 --- a/stdlib/source/test/lux/world/program.lux +++ b/stdlib/source/test/lux/world/program.lux @@ -7,12 +7,12 @@ [control [pipe (#+ case>)] ["." io] + ["." maybe ("#\." functor)] ["." try] ["." exception] [parser [environment (#+ Environment)]]] [data - ["." maybe ("#\." functor)] ["." text ("#\." equivalence)] [collection ["." dictionary] @@ -53,7 +53,7 @@ ($/.spec (/.async (/.mock environment home directory)))) (_.cover [/.environment] (let [program (/.mock environment home directory)] - (io.run + (io.run! (do io.monad [actual (/.environment io.monad program)] (in (and (n.= (dictionary.size environment) @@ -69,7 +69,7 @@ (let [program (/.mock environment home directory)] (|> unknown (\ program variable) - io.run + io.run! (case> (#try.Success _) false |