diff options
author | Eduardo Julian | 2021-08-24 05:23:45 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-08-24 05:23:45 -0400 |
commit | 36303d6cb2ce3ab9e36d045b9516c997bd461862 (patch) | |
tree | b9d2f1495143054d61d9af129f36833624db9dac /stdlib/source/library | |
parent | ec1f31b5a1492d5e0ab260397291d4449483bbd9 (diff) |
Outsourced the syntax for labelled type definitions to macros.
Diffstat (limited to '')
326 files changed, 5209 insertions, 5098 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index ffe7daf46..9770f131c 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -837,7 +837,7 @@ _ (failure "Wrong syntax for let''")} tokens))) - (record$ #.End) + (record$ #End) #0) ("lux def" function'' @@ -874,7 +874,7 @@ _ (failure "Wrong syntax for function''")} tokens))) - (record$ #.End) + (record$ #End) #0) ("lux def" location_code @@ -959,7 +959,7 @@ _ (failure "Wrong syntax for def''")} tokens))) - (record$ #.End) + (record$ #End) #0) ("lux def" macro:' @@ -984,7 +984,7 @@ _ (failure "Wrong syntax for macro:'")} tokens))) - (record$ #.End) + (record$ #End) #0) (macro:' .public (comment tokens) @@ -1012,7 +1012,7 @@ (failure "Wrong syntax for $'")} tokens)) -(def:'' .private (list\map f xs) +(def:'' .private (list\each f xs) #End (#UnivQ #End (#UnivQ #End @@ -1023,7 +1023,7 @@ #End (#Item x xs') - (#Item (f x) (list\map f xs'))} + (#Item (f x) (list\each f xs'))} xs)) (def:'' .private Replacement_Environment @@ -1073,25 +1073,25 @@ (..replacement name reps)) [meta (#Form parts)] - [meta (#Form (list\map (with_replacements reps) parts))] + [meta (#Form (list\each (with_replacements reps) parts))] [meta (#Tuple members)] - [meta (#Tuple (list\map (with_replacements reps) members))] + [meta (#Tuple (list\each (with_replacements reps) members))] [meta (#Record slots)] - [meta (#Record (list\map ("lux type check" (#Function (#Product Code Code) (#Product Code Code)) - (function'' [slot] - ({[k v] - [(with_replacements reps k) (with_replacements reps v)]} - slot))) - slots))] + [meta (#Record (list\each ("lux type check" (#Function (#Product Code Code) (#Product Code Code)) + (function'' [slot] + ({[k v] + [(with_replacements reps k) (with_replacements reps v)]} + slot))) + slots))] _ syntax} syntax)) (def:'' .private (n/* param subject) - #.End + #End (#Function Nat (#Function Nat Nat)) ("lux type as" Nat ("lux i64 *" @@ -1102,20 +1102,20 @@ #End (#Function Code Code) ({[_ (#Tuple members)] - (tuple$ (list\map nested_quantification members)) + (tuple$ (list\each nested_quantification members)) [_ (#Record pairs)] - (record$ (list\map ("lux type check" (#Function (#Product Code Code) (#Product Code Code)) - (function'' [pair] - (let'' [name val] pair - [name (nested_quantification val)]))) - pairs)) + (record$ (list\each ("lux type check" (#Function (#Product Code Code) (#Product Code Code)) + (function'' [pair] + (let'' [name val] pair + [name (nested_quantification val)]))) + pairs)) [_ (#Form (#Item [_ (#Tag "library/lux" "Parameter")] (#Item [_ (#Nat idx)] #End)))] (form$ (#Item (tag$ ["library/lux" "Parameter"]) (#Item (nat$ ("lux i64 +" 2 idx)) #End))) [_ (#Form members)] - (form$ (list\map nested_quantification members)) + (form$ (list\each nested_quantification members)) _ code} @@ -1173,7 +1173,7 @@ ("lux text concat" "(All [a] (-> a a))" __paragraph) ("lux text concat" ("lux text concat" "... A name can be provided, to specify a recursive type." __paragraph) - "(All List [a] (Variant Any [a (List a)]))"))))] + "(All List [a] (Union Any [a (List a)]))"))))] #End) (let'' [self_name tokens] ({(#Item [_ (#Identifier "" self_name)] tokens) [self_name tokens] @@ -1315,15 +1315,15 @@ (failure "Wrong syntax for list&")} (list\reversed xs))) -(macro:' .public (Variant tokens) +(macro:' .public (Union tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" - ("lux text concat" "... Variant types:" __paragraph) + ("lux text concat" "... Union types:" __paragraph) ("lux text concat" - ("lux text concat" "(Variant Text Int Bit)" __paragraph) + ("lux text concat" "(Union Text Int Bit)" __paragraph) ("lux text concat" ("lux text concat" "... Nothing." __paragraph) - "(Variant)"))))] + "(Union)"))))] #End) ({#End (in_meta (list (identifier$ ["library/lux" "Nothing"]))) @@ -1413,10 +1413,10 @@ (def:''' .public Or (#Item [(tag$ ["library/lux" "doc"]) - (text$ "An alias for the Variant type constructor.")] + (text$ "An alias for the Union type constructor.")] #End) Macro - ..Variant) + ..Union) (def:''' .public And (#Item [(tag$ ["library/lux" "doc"]) @@ -1479,11 +1479,11 @@ (_ann (#Form (list (_ann (#Tag ["library/lux" "Item"])) token (untemplated_list tokens'))))} tokens)) -(def:''' .private (list\compose xs ys) +(def:''' .private (list\composite xs ys) #End (All [a] (-> ($' List a) ($' List a) ($' List a))) ({(#Item x xs') - (#Item x (list\compose xs' ys)) + (#Item x (list\composite xs' ys)) #End ys} @@ -1493,7 +1493,7 @@ #End (-> Code Code Code Code) ({[_ (#Form parts)] - (form$ (list\compose parts (list a1 a2))) + (form$ (list\composite parts (list a1 a2))) _ (form$ (list op a1 a2))} @@ -1511,10 +1511,10 @@ (text$ ("lux text concat" ("lux text concat" "... Left-association for the application of binary functions over variadic arguments." ..\n) ("lux text concat" - ("lux text concat" "(_$ text\compose ''Hello, '' name ''. How are you?'')" ..\n) + ("lux text concat" "(_$ text\composite ''Hello, '' name ''. How are you?'')" ..\n) ("lux text concat" ("lux text concat" "... =>" ..\n) - "(text\compose (text\compose ''Hello, '' name) ''. How are you?'')"))))] + "(text\composite (text\composite ''Hello, '' name) ''. How are you?'')"))))] #End) ({(#Item op tokens') ({(#Item first nexts) @@ -1533,10 +1533,10 @@ (text$ ("lux text concat" ("lux text concat" "... Right-association for the application of binary functions over variadic arguments." ..\n) ("lux text concat" - ("lux text concat" "($_ text\compose ''Hello, '' name ''. How are you?'')" ..\n) + ("lux text concat" "($_ text\composite ''Hello, '' name ''. How are you?'')" ..\n) ("lux text concat" ("lux text concat" "... =>" ..\n) - "(text\compose ''Hello, '' (text\compose name ''. How are you?''))"))))] + "(text\composite ''Hello, '' (text\composite name ''. How are you?''))"))))] #End) ({(#Item op tokens') ({(#Item last prevs) @@ -1629,7 +1629,7 @@ (failure "Wrong syntax for do")} tokens)) -(def:''' .private (monad\map m f xs) +(def:''' .private (monad\each m f xs) #End ... (All [m a b] ... (-> (Monad m) (-> a (m b)) (List a) (m (List b)))) @@ -1645,7 +1645,7 @@ (#Item x xs') (do m [y (f x) - ys (monad\map m f xs')] + ys (monad\each m f xs')] (in (#Item y ys)))} xs))) @@ -1702,7 +1702,7 @@ #None} plist)) -(def:''' .private (text\compose x y) +(def:''' .private (text\composite x y) #End (-> Text Text Text) ("lux text concat" x y)) @@ -1712,7 +1712,7 @@ (-> Name Text) (let' [[module name] full_name] ({"" name - _ ($_ text\compose module "." name)} + _ ($_ text\composite module "." name)} module))) (def:''' .private (global_identifier full_name state) @@ -1733,11 +1733,11 @@ constant) #None - (#Left ($_ text\compose "Unknown definition: " (name\encoded full_name)))} + (#Left ($_ text\composite "Unknown definition: " (name\encoded full_name)))} (plist\value name definitions)) #None - (#Left ($_ text\compose "Unknown module: " module " @ " (name\encoded full_name)))} + (#Left ($_ text\composite "Unknown module: " module " @ " (name\encoded full_name)))} (plist\value module modules)))) (def:''' .private (code_list expression) @@ -1771,7 +1771,7 @@ ({[_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))] (let' [g!in-module (form$ (list (text$ "lux in-module") (text$ "library/lux") - (identifier$ ["library/lux" "list\compose"])))] + (identifier$ ["library/lux" "list\composite"])))] (in (form$ (list g!in-module (code_list spliced) rightO)))) _ @@ -1784,7 +1784,7 @@ (list\reversed elems)) #0 (do meta_monad - [=elems (monad\map meta_monad untemplated elems)] + [=elems (monad\each meta_monad untemplated elems)] (in (untemplated_list =elems)))} replace?)) @@ -1872,15 +1872,15 @@ [_ [_ (#Record fields)]] (do meta_monad - [=fields (monad\map meta_monad - ("lux type check" (-> (Tuple Code Code) ($' Meta Code)) - (function' [kv] - (let' [[k v] kv] - (do meta_monad - [=k (untemplated replace? subst k) - =v (untemplated replace? subst v)] - (in (tuple$ (list =k =v))))))) - fields)] + [=fields (monad\each meta_monad + ("lux type check" (-> (Tuple Code Code) ($' Meta Code)) + (function' [kv] + (let' [[k v] kv] + (do meta_monad + [=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))))))} [replace? token])) @@ -1965,17 +1965,17 @@ (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "... Piping macro." __paragraph - "(|> elems (list\map int\encoded) (interposed '' '') (mix text\compose ''''))" __paragraph + "(|> elems (list\each int\encoded) (interposed '' '') (mix text\composite ''''))" __paragraph "... =>" __paragraph - "(mix text\compose '''' (interposed '' '' (list\map int\encoded elems)))"))]) + "(mix text\composite '''' (interposed '' '' (list\each int\encoded elems)))"))]) ({(#Item [init apps]) (in_meta (list (list\mix ("lux type check" (-> Code Code Code) (function' [app acc] ({[_ (#Tuple parts)] - (tuple$ (list\compose parts (list acc))) + (tuple$ (list\composite parts (list acc))) [_ (#Form parts)] - (form$ (list\compose parts (list acc))) + (form$ (list\composite parts (list acc))) _ (` ((~ app) (~ acc)))} @@ -1991,17 +1991,17 @@ (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "... Reverse piping macro." __paragraph - "(<| (mix text\compose '''') (interposed '' '') (list\map int\encoded) elems)" __paragraph + "(<| (mix text\composite '''') (interposed '' '') (list\each int\encoded) elems)" __paragraph "... =>" __paragraph - "(mix text\compose '''' (interposed '' '' (list\map int\encoded elems)))"))]) + "(mix text\composite '''' (interposed '' '' (list\each int\encoded elems)))"))]) ({(#Item [init apps]) (in_meta (list (list\mix ("lux type check" (-> Code Code Code) (function' [app acc] ({[_ (#Tuple parts)] - (tuple$ (list\compose parts (list acc))) + (tuple$ (list\composite parts (list acc))) [_ (#Form parts)] - (form$ (list\compose parts (list acc))) + (form$ (list\composite parts (list acc))) _ (` ((~ app) (~ acc)))} @@ -2072,17 +2072,17 @@ (..replacement sname env)) [meta (#Tuple elems)] - [meta (#Tuple (list\map (realized_template env) elems))] + [meta (#Tuple (list\each (realized_template env) elems))] [meta (#Form elems)] - [meta (#Form (list\map (realized_template env) elems))] + [meta (#Form (list\each (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] - [(realized_template env slot) (realized_template env value)]))) - members))] + [meta (#Record (list\each ("lux type check" (-> (Tuple Code Code) (Tuple Code Code)) + (function' [kv] + (let' [[slot value] kv] + [(realized_template env slot) (realized_template env value)]))) + members))] _ template} @@ -2129,11 +2129,11 @@ #1 ("lux i64 =" reference sample))) -(def:''' .private (list\joined xs) +(def:''' .private (list\conjoint xs) #End (All [a] (-> ($' List ($' List a)) ($' List a))) - (list\mix list\compose #End (list\reversed xs))) + (list\mix list\composite #End (list\reversed xs))) (macro:' .public (template tokens) (list [(tag$ ["library/lux" "doc"]) @@ -2146,20 +2146,20 @@ ({(#Item [[_ (#Tuple bindings)] (#Item [[_ (#Tuple templates)] data])]) ({[(#Some bindings') (#Some data')] (let' [apply ("lux type check" (-> Replacement_Environment ($' List Code)) - (function' [env] (list\map (realized_template env) templates))) + (function' [env] (list\each (realized_template env) templates))) num_bindings (list\size bindings')] (if (every? (function' [size] ("lux i64 =" num_bindings size)) - (list\map list\size data')) + (list\each list\size data')) (|> data' - (list\map (function\composite apply (replacement_environment bindings'))) - list\joined + (list\each (function\composite apply (replacement_environment bindings'))) + list\conjoint in_meta) (failure "Irregular arguments tuples for template."))) _ (failure "Wrong syntax for template")} - [(monad\map maybe_monad identifier_short bindings) - (monad\map maybe_monad tuple_list data)]) + [(monad\each maybe_monad identifier_short bindings) + (monad\each maybe_monad tuple_list data)]) _ (failure "Wrong syntax for template")} @@ -2226,8 +2226,8 @@ (if ("lux i64 =" 0 input) output (recur (n// 10 input) - (text\compose (|> input (n/% 10) digit::format) - output)))))] + (text\composite (|> input (n/% 10) digit::format) + output)))))] (loop value ""))} value)) @@ -2249,10 +2249,10 @@ (("lux type check" (-> Int Text Text) (function' recur [input output] (if ("lux i64 =" +0 input) - (text\compose sign output) + (text\composite sign output) (recur ("lux i64 /" +10 input) - (text\compose (|> input ("lux i64 %" +10) ("lux type as" Nat) digit::format) - output))))) + (text\composite (|> input ("lux i64 %" +10) ("lux type as" Nat) digit::format) + output))))) (|> value ("lux i64 /" +10) int\abs) (|> value ("lux i64 %" +10) int\abs ("lux type as" Nat) digit::format))))) @@ -2386,8 +2386,8 @@ ({(#Some macro) (do meta_monad [top_level_expansion (("lux type as" Macro' macro) args) - recursive_expansion (monad\map meta_monad expansion top_level_expansion)] - (in (list\joined recursive_expansion))) + recursive_expansion (monad\each meta_monad expansion top_level_expansion)] + (in (list\conjoint recursive_expansion))) #None (in_meta (list token))} @@ -2407,53 +2407,112 @@ ({(#Some macro) (do meta_monad [expansion (("lux type as" Macro' macro) args) - expansion' (monad\map meta_monad full_expansion expansion)] - (in (list\joined expansion'))) + expansion' (monad\each meta_monad full_expansion expansion)] + (in (list\conjoint expansion'))) #None (do meta_monad - [args' (monad\map meta_monad full_expansion args)] - (in (list (form$ (#Item (identifier$ name) (list\joined args'))))))} + [args' (monad\each meta_monad full_expansion args)] + (in (list (form$ (#Item (identifier$ name) (list\conjoint args'))))))} ?macro)) [_ (#Form members)] (do meta_monad - [members' (monad\map meta_monad full_expansion members)] - (in (list (form$ (list\joined members'))))) + [members' (monad\each meta_monad full_expansion members)] + (in (list (form$ (list\conjoint members'))))) [_ (#Tuple members)] (do meta_monad - [members' (monad\map meta_monad full_expansion members)] - (in (list (tuple$ (list\joined members'))))) + [members' (monad\each meta_monad full_expansion members)] + (in (list (tuple$ (list\conjoint members'))))) [_ (#Record pairs)] (do meta_monad - [pairs' (monad\map meta_monad - (function' [kv] - (let' [[key val] kv] - (do meta_monad - [val' (full_expansion val)] - ({(#Item val'' #End) - (in_meta [key val'']) + [pairs' (monad\each meta_monad + (function' [kv] + (let' [[key val] kv] + (do meta_monad + [val' (full_expansion val)] + ({(#Item val'' #End) + (in_meta [key val'']) - _ - (failure "The value-part of a KV-pair in a record must macro-expand to a single Code.")} - val')))) - pairs)] + _ + (failure "The value-part of a KV-pair in a record must macro-expand to a single Code.")} + val')))) + pairs)] (in (list (record$ pairs')))) _ (in_meta (list syntax))} syntax)) +(def:''' .private (text\encoded original) + #End + (-> Text Text) + ($_ text\composite ..double_quote original ..double_quote)) + +(def:''' .private (code\encoded code) + #End + (-> Code Text) + ({[_ (#Bit value)] + (bit\encoded value) + + [_ (#Nat value)] + (nat\encoded value) + + [_ (#Int value)] + (int\encoded value) + + [_ (#Rev value)] + ("lux io error" "@code\encoded Undefined behavior.") + + [_ (#Frac value)] + (frac\encoded value) + + [_ (#Text value)] + (text\encoded value) + + [_ (#Identifier [module name])] + (if (text\= "" module) + name + ($_ text\composite module "." name)) + + [_ (#Tag [module name])] + (if (text\= "" module) + ($_ text\composite "#" name) + ($_ text\composite "#" module "." name)) + + [_ (#Form xs)] + ($_ text\composite "(" (|> xs + (list\each code\encoded) + (list\interposed " ") + list\reversed + (list\mix text\composite "")) ")") + + [_ (#Tuple xs)] + ($_ text\composite "[" (|> xs + (list\each code\encoded) + (list\interposed " ") + list\reversed + (list\mix text\composite "")) "]") + + [_ (#Record kvs)] + ($_ text\composite "{" (|> kvs + (list\each (function' [kv] ({[k v] ($_ text\composite (code\encoded k) " " (code\encoded v))} + kv))) + (list\interposed " ") + list\reversed + (list\mix text\composite "")) "}")} + code)) + (def:''' .private (normal_type type) #End (-> Code Code) ({[_ (#Form (#Item [_ (#Tag tag)] parts))] - (form$ (#Item [(tag$ tag) (list\map normal_type parts)])) + (form$ (#Item (tag$ tag) (list\each normal_type parts))) [_ (#Tuple members)] - (` (Tuple (~+ (list\map normal_type members)))) + (` (Tuple (~+ (list\each normal_type members)))) [_ (#Form (#Item [_ (#Text "lux in-module")] (#Item [_ (#Text module)] @@ -2468,8 +2527,8 @@ (list\mix ("lux type check" (-> Code Code Code) (function' [arg type_fn] (` (#.Apply (~ arg) (~ type_fn))))) (normal_type type_fn) - (list\map normal_type args)) - + (list\each normal_type args)) + _ type} type)) @@ -2484,7 +2543,7 @@ [type+ (full_expansion type)] ({(#Item type' #End) (in (list (normal_type type'))) - + _ (failure "The expansion of the type-syntax had to yield a single element.")} type+)) @@ -2534,60 +2593,6 @@ [product\left a x] [product\right b y]) -(def:''' .private (type_declaration type_codes) - #End - (-> ($' List Code) ($' Meta (Tuple Code ($' Maybe ($' List Text))))) - ({(#Item [_ (#Record pairs)] #End) - (do meta_monad - [members (monad\map meta_monad - (: (-> [Code Code] (Meta [Text Code])) - (function' [pair] - ({[[_ (#Tag "" member_name)] member_type] - (in_meta [member_name member_type]) - - _ - (failure "Wrong syntax for variant case.")} - pair))) - pairs)] - (in_meta [(` (Tuple (~+ (list\map product\right members)))) - (#Some (list\map product\left members))])) - - (#Item type #End) - ({[_ (#Tag "" member_name)] - (in_meta [(` .Any) (#Some (list member_name))]) - - [_ (#Form (#Item [_ (#Tag "" member_name)] member_types))] - (in_meta [(` (Tuple (~+ member_types))) (#Some (list member_name))]) - - _ - (in_meta [type #None])} - type) - - (#Item case cases) - (do meta_monad - [members (monad\map meta_monad - (: (-> Code (Meta [Text Code])) - (function' [case] - ({[_ (#Tag "" member_name)] - (in_meta [member_name (` .Any)]) - - [_ (#Form (#Item [_ (#Tag "" member_name)] (#Item member_type #End)))] - (in_meta [member_name member_type]) - - [_ (#Form (#Item [_ (#Tag "" member_name)] member_types))] - (in_meta [member_name (` (Tuple (~+ member_types)))]) - - _ - (failure "Wrong syntax for variant case.")} - case))) - (list& case cases))] - (in_meta [(` (..Variant (~+ (list\map product\right members)))) - (#Some (list\map product\left members))])) - - _ - (failure "Improper type-definition syntax")} - type_codes)) - (def:''' .private (identifier prefix state) #End (-> Text ($' Meta Code)) @@ -2601,7 +2606,7 @@ #seed ("lux i64 +" 1 seed) #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars #eval _eval} - (local_identifier$ ($_ text\compose "__gensym__" prefix (nat\encoded seed))))} + (local_identifier$ ($_ text\composite "__gensym__" prefix (nat\encoded seed))))} state)) (macro:' .public (Rec tokens) @@ -2681,63 +2686,6 @@ (failure "Wrong syntax for def'")} parts))) -(def:' .private (text\encoded original) - (-> Text Text) - ($_ text\compose ..double_quote original ..double_quote)) - -(def:' .private (code\encoded code) - (-> Code Text) - ({[_ (#Bit value)] - (bit\encoded value) - - [_ (#Nat value)] - (nat\encoded value) - - [_ (#Int value)] - (int\encoded value) - - [_ (#Rev value)] - ("lux io error" "@code\encoded Undefined behavior.") - - [_ (#Frac value)] - (frac\encoded value) - - [_ (#Text value)] - (text\encoded value) - - [_ (#Identifier [module name])] - (if (text\= "" module) - name - ($_ text\compose module "." name)) - - [_ (#Tag [module name])] - (if (text\= "" module) - ($_ text\compose "#" name) - ($_ text\compose "#" module "." name)) - - [_ (#Form xs)] - ($_ text\compose "(" (|> xs - (list\map code\encoded) - (list\interposed " ") - list\reversed - (list\mix text\compose "")) ")") - - [_ (#Tuple xs)] - ($_ text\compose "[" (|> xs - (list\map code\encoded) - (list\interposed " ") - list\reversed - (list\mix text\compose "")) "]") - - [_ (#Record kvs)] - ($_ text\compose "{" (|> kvs - (list\map (function' [kv] ({[k v] ($_ text\compose (code\encoded k) " " (code\encoded v))} - kv))) - (list\interposed " ") - list\reversed - (list\mix text\compose "")) "}")} - code)) - (def:' .private (expander branches) (-> (List Code) (Meta (List Code))) ({(#Item [_ (#Form (#Item [_ (#Identifier name)] args))] @@ -2764,11 +2712,11 @@ (do meta_monad [] (in (list))) _ - (failure ($_ text\compose "'lux.case' expects an even number of tokens: " (|> branches - (list\map code\encoded) - (list\interposed " ") - list\reversed - (list\mix text\compose ""))))} + (failure ($_ text\composite "'lux.case' expects an even number of tokens: " (|> branches + (list\each code\encoded) + (list\interposed " ") + list\reversed + (list\mix text\composite ""))))} branches)) (macro:' .public (case tokens) @@ -2838,9 +2786,9 @@ _ (let' [pairs (|> patterns - (list\map (function' [pattern] (list pattern body))) - (list\joined))] - (in_meta (list\compose pairs branches)))) + (list\each (function' [pattern] (list pattern body))) + (list\conjoint))] + (in_meta (list\composite pairs branches)))) _ (failure "Wrong syntax for ^or"))) @@ -2940,27 +2888,27 @@ [_ (#Tuple xs)] (|> xs - (list\map definition_annotation_value) + (list\each definition_annotation_value) untemplated_list (meta_code ["library/lux" "Tuple"])) [_ (#Record kvs)] (|> kvs - (list\map (: (-> [Code Code] Code) - (function (_ [k v]) - (` [(~ (definition_annotation_value k)) - (~ (definition_annotation_value v))])))) + (list\each (: (-> [Code Code] Code) + (function (_ [k v]) + (` [(~ (definition_annotation_value k)) + (~ (definition_annotation_value v))])))) untemplated_list (meta_code ["library/lux" "Record"])) )) (def:' .private (definition_annotations kvs) (-> (List [Code Code]) Code) - (untemplated_list (list\map (: (-> [Code Code] Code) - (function (_ [k v]) - (` [(~ (definition_annotation_value k)) - (~ (definition_annotation_value v))]))) - kvs))) + (untemplated_list (list\each (: (-> [Code Code] Code) + (function (_ [k v]) + (` [(~ (definition_annotation_value k)) + (~ (definition_annotation_value v))]))) + kvs))) (def:' .private (with_function_parameters parameters meta) (-> (List Code) Code Code) @@ -2970,21 +2918,21 @@ _ (` (#.Item [[(~ location_code) (#.Tag ["library/lux" "func_args"])] - [(~ location_code) (#.Tuple (.list (~+ (list\map (function (_ parameter) - (` [(~ location_code) (#.Text (~ (text$ (code\encoded parameter))))])) - parameters))))]] + [(~ location_code) (#.Tuple (.list (~+ (list\each (function (_ parameter) + (` [(~ location_code) (#.Text (~ (text$ (code\encoded parameter))))])) + parameters))))]] (~ meta))))) (def:' .private (with_type_args args) (-> (List Code) Code) - (` {#.type_args [(~+ (list\map (function (_ arg) (text$ (code\encoded arg))) - args))]})) + (` {#.type_args [(~+ (list\each (function (_ arg) (text$ (code\encoded arg))) + args))]})) (def:' .private (endP tokens) (-> (List Code) (Maybe Any)) (case tokens (^ (list)) - (#.Some []) + (#Some []) _ #None)) @@ -2996,7 +2944,7 @@ (#Some [tokens' code]) _ - #.None)) + #None)) (def:' .private (local_identifierP tokens) (-> (List Code) (Maybe [(List Code) Text])) @@ -3005,14 +2953,14 @@ (#Some [tokens' local_identifier]) _ - #.None)) + #None)) (template [<parser> <item_type> <item_parser>] [(def:' .private (<parser> tokens) (-> (List Code) (Maybe (List <item_type>))) (case tokens #End - (#.Some #End) + (#Some #End) _ (do maybe_monad @@ -3264,7 +3212,7 @@ _ (` ("lux macro" - (function ((~ name) (~+ (list\map local_identifier$ args))) (~ body))))) + (function ((~ name) (~+ (list\each local_identifier$ args))) (~ body))))) =annotations (definition_annotations annotations)] (in_meta (list (` ("lux def" (~ name) (~ body) @@ -3272,7 +3220,7 @@ (#Record (~ =annotations))] (~ export_policy)))))) - #.None + #None (failure "Wrong syntax for macro:"))) (def: (list\one f xs) @@ -3496,7 +3444,7 @@ (#Right state module) _ - (#Left ($_ text\compose "Unknown module: " name)))))) + (#Left ($_ text\composite "Unknown module: " name)))))) (def: (type_tag [module name]) (-> Name (Meta [Nat (List Name) Bit Type])) @@ -3508,7 +3456,7 @@ (in_meta output) _ - (failure (text\compose "Unknown tag: " (name\encoded [module name])))))) + (failure (text\composite "Unknown tag: " (name\encoded [module name])))))) (def: (record_slots type) (-> Type (Meta (Maybe [(List Name) (List Type)]))) @@ -3573,7 +3521,7 @@ " (= test subject)))" ..\n " ))"))} (do meta_monad - [tokens' (monad\map meta_monad expansion tokens) + [tokens' (monad\each meta_monad expansion tokens) struct_type ..expected_type tags+type (record_slots struct_type) tags (: (Meta (List Name)) @@ -3584,23 +3532,23 @@ _ (failure "No tags available for type."))) .let [tag_mappings (: (List [Text Code]) - (list\map (function (_ tag) [(product\right tag) (tag$ tag)]) - tags))] - members (monad\map meta_monad - (: (-> Code (Meta [Code Code])) - (function (_ token) - (case token - (^ [_ (#Form (list [_ (#Text "lux def")] [_ (#Identifier "" tag_name)] value meta export_policy))]) - (case (plist\value tag_name tag_mappings) - (#Some tag) - (in [tag value]) + (list\each (function (_ tag) [(product\right tag) (tag$ tag)]) + tags))] + members (monad\each meta_monad + (: (-> Code (Meta [Code Code])) + (function (_ token) + (case token + (^ [_ (#Form (list [_ (#Text "lux def")] [_ (#Identifier "" tag_name)] value meta export_policy))]) + (case (plist\value tag_name tag_mappings) + (#Some tag) + (in [tag value]) - _ - (failure (text\compose "Unknown implementation member: " tag_name))) + _ + (failure (text\composite "Unknown implementation member: " tag_name))) - _ - (failure "Invalid implementation member.")))) - (list\joined tokens'))] + _ + (failure "Invalid implementation member.")))) + (list\conjoint tokens'))] (in (list (record$ members))))) (def: (text\interposed separator parts) @@ -3611,7 +3559,7 @@ (#Item head tail) (list\mix (function (_ right left) - ($_ text\compose left separator right)) + ($_ text\composite left separator right)) head tail))) @@ -3695,6 +3643,83 @@ (All [a] (-> a a)) value) +(def: (everyP itP tokens) + (All [a] (-> (-> (List Code) (Maybe [(List Code) a])) + (-> (List Code) (Maybe (List a))))) + (case tokens + (#Item _) + (do maybe_monad + [% (itP tokens) + .let [[tokens' head] %] + tail (case tokens' + (#Item _) + (everyP itP tokens') + + #End + (in (list)))] + (in (list& head tail))) + + #End + (#Some (list)))) + +(def: (caseP tokens) + (-> (List Code) (Maybe [(List Code) [Text Code]])) + (case tokens + (^ (list& [_ (#Tag ["" niladic])] tokens')) + (#Some [tokens' [niladic (` .Any)]]) + + (^ (list& [_ (#Form (list& [_ (#Tag ["" polyadic])] caseT))] tokens')) + (#Some [tokens' [polyadic (` (..Tuple (~+ caseT)))]]) + + _ + #None)) + +(macro: .public (Variant tokens) + (case (everyP caseP tokens) + (#Some cases) + (in_meta (list (` (..Union (~+ (list\each product\right cases)))) + (tuple$ (list\each (function (_ case) + (text$ (product\left case))) + cases)))) + + #None + (failure "Wrong syntax for Variant"))) + +(def: (slotP tokens) + (-> (List Code) (Maybe [(List Code) [Text Code]])) + (case tokens + (^ (list& [_ (#Tag ["" slot])] type tokens')) + (#Some [tokens' [slot type]]) + + _ + #.None)) + +(def: un_paired + (-> (List [Code Code]) (List Code)) + (let [pair_list (: (-> [Code Code] (List Code)) + (function (_ [left right]) + (list left right)))] + (function (_ it) + (|> it + (list\each pair_list) + list\conjoint)))) + +(macro: .public (Record tokens) + (case tokens + (^ (list [_ (#Record record)])) + (case (everyP slotP (un_paired record)) + (#Some slots) + (in_meta (list (` (..Tuple (~+ (list\each product\right slots)))) + (tuple$ (list\each (function (_ slot) + (text$ (product\left slot))) + slots)))) + + #None + (failure "Wrong syntax for Record")) + + _ + (failure "Wrong syntax for Record"))) + (def: (recP tokens) (-> (List Code) [(List Code) Bit]) (case tokens @@ -3704,49 +3729,90 @@ _ [tokens #0])) -(def:' .private (typeP tokens) - (-> (List Code) (Maybe [Code Bit Text (List Text) (List [Code Code]) (List Code)])) - (|> (do maybe_monad - [% (anyP tokens) - .let' [[tokens export_policy] %] - .let' [[tokens rec?] (recP tokens)] - % (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - tokens (remainderP tokens)] - (in [export_policy rec? name parameters annotations tokens])) - ... (^ (list _export_policy _rec _declaration _annotations _body)) - ... (^ (list _export_policy _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [.let' [[tokens rec?] (recP tokens)] - % (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - tokens (remainderP tokens)] - (in [(` ..private) rec? name parameters annotations tokens]))) - ... (^ (list _rec _declaration _annotations _body)) - ... (^ (list _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [.let' [[tokens rec?] (recP tokens)] - % (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - tokens (remainderP tokens)] - (in [(` ..private) rec? name parameters #End tokens]))) - ... (^ (list _rec _declaration _body)) - ... (^ (list _declaration _body)) - (maybe\else' (do maybe_monad - [% (anyP tokens) - .let' [[tokens export_policy] %] - .let' [[tokens rec?] (recP tokens)] - % (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - tokens (remainderP tokens)] - (in [export_policy rec? name parameters #End tokens]))) - ... (^ (list _export_policy _rec _declaration _body)) - ... (^ (list _export_policy _declaration _body)) - )) +(def: (typeP tokens) + (-> (List Code) (Maybe [Code Bit Text (List Text) (List [Code Code]) Code])) + (|> (do maybe_monad + [% (anyP tokens) + .let' [[tokens export_policy] %] + .let' [[tokens rec?] (recP tokens)] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + % (anyP tokens) + .let' [[tokens definition] %] + _ (endP tokens)] + (in [export_policy rec? name parameters annotations definition])) + ... (^ (list _export_policy _rec _declaration _annotations _body)) + ... (^ (list _export_policy _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [.let' [[tokens rec?] (recP tokens)] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + % (anyP tokens) + .let' [[tokens definition] %] + _ (endP tokens)] + (in [(` ..private) rec? name parameters annotations definition]))) + ... (^ (list _rec _declaration _annotations _body)) + ... (^ (list _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [.let' [[tokens rec?] (recP tokens)] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (anyP tokens) + .let' [[tokens definition] %] + _ (endP tokens)] + (in [(` ..private) rec? name parameters #End definition]))) + ... (^ (list _rec _declaration _body)) + ... (^ (list _declaration _body)) + (maybe\else' (do maybe_monad + [% (anyP tokens) + .let' [[tokens export_policy] %] + .let' [[tokens rec?] (recP tokens)] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (anyP tokens) + .let' [[tokens definition] %] + _ (endP tokens)] + (in [export_policy rec? name parameters #End definition]))) + ... (^ (list _export_policy _rec _declaration _body)) + ... (^ (list _export_policy _declaration _body)) + )) + +(def: (textP tokens) + (-> (List Code) (Maybe [(List Code) Text])) + (case tokens + (^ (list& [_ (#Text it)] tokens')) + (#Some [tokens' it]) + + _ + #None)) + +(def: (type_declaration it) + (-> Code (Meta (Tuple Code (Maybe (List Text))))) + ({[_ (#Form (#Item [_ (#Identifier declarer)] parameters))] + (do meta_monad + [declaration (single_expansion (form$ (list& (identifier$ declarer) parameters)))] + (case declaration + (^ (list type [_ (#Tuple tags)])) + (case (everyP textP tags) + (#Some tags) + (in_meta [type (#Some tags)]) + + #None + (failure "Improper type-definition syntax")) + + (^ (list type)) + (in_meta [it #None]) + + _ + (failure "Improper type-definition syntax"))) + + type + (in_meta [type #None])} + it)) (macro: .public (type: tokens) {#.doc (text$ ($_ "lux text concat" @@ -3759,53 +3825,53 @@ (#Some [export_policy rec? name args meta type_codes]) (do meta_monad [type+tags?? (..type_declaration type_codes) - module_name current_module_name] - (let [type_name (local_identifier$ name) - [type tags??] type+tags?? - type' (: (Maybe Code) - (if rec? - (if (empty? args) - (let [g!param (local_identifier$ "") - prime_name (local_identifier$ name) - type+ (with_replacements (list [name (` ((~ prime_name) .Nothing))]) - type)] - (#Some (` ((All (~ prime_name) [(~ g!param)] (~ type+)) - .Nothing)))) - #None) - (case args - #End - (#Some type) + module_name current_module_name + .let' [type_name (local_identifier$ name) + [type tags??] type+tags?? + type' (: (Maybe Code) + (if rec? + (if (empty? args) + (let [g!param (local_identifier$ "") + prime_name (local_identifier$ name) + type+ (with_replacements (list [name (` ((~ prime_name) .Nothing))]) + type)] + (#Some (` ((All (~ prime_name) [(~ g!param)] (~ type+)) + .Nothing)))) + #None) + (case args + #End + (#Some type) - _ - (#Some (` (.All (~ type_name) [(~+ (list\map local_identifier$ args))] (~ type))))))) - total_meta (let [meta (definition_annotations meta) - meta (if rec? - (` (#.Item (~ (flag_meta "type_rec?")) (~ meta))) - meta)] - (` [(~ location_code) - (#.Record (~ meta))]))] - (case type' - (#Some type'') - (let [typeC (` (#.Named [(~ (text$ module_name)) - (~ (text$ name))] - (.type (~ type''))))] - (in_meta (list (case tags?? - (#Some tags) - (` ("lux def type tagged" (~ type_name) - (~ typeC) - (~ total_meta) - [(~+ (list\map text$ tags))] - (~ export_policy))) - - _ - (` ("lux def" (~ type_name) - ("lux type check type" - (~ typeC)) - (~ total_meta) - (~ export_policy))))))) + _ + (#Some (` (.All (~ type_name) [(~+ (list\each local_identifier$ args))] (~ type))))))) + total_meta (let [meta (definition_annotations meta) + meta (if rec? + (` (#.Item (~ (flag_meta "type_rec?")) (~ meta))) + meta)] + (` [(~ location_code) + (#.Record (~ meta))]))]] + (case type' + (#Some type'') + (let [typeC (` (#.Named [(~ (text$ module_name)) + (~ (text$ name))] + (.type (~ type''))))] + (in_meta (list (case tags?? + (#Some tags) + (` ("lux def type tagged" (~ type_name) + (~ typeC) + (~ total_meta) + [(~+ (list\each text$ tags))] + (~ export_policy))) + + _ + (` ("lux def" (~ type_name) + ("lux type check type" + (~ typeC)) + (~ total_meta) + (~ export_policy))))))) - #None - (failure "Wrong syntax for type:")))) + #None + (failure "Wrong syntax for type:"))) #None (failure "Wrong syntax for type:"))) @@ -3843,32 +3909,34 @@ (case (interfaceP tokens) (#Some [export_policy name args annotations methods]) (do meta_monad - [methods' (monad\map meta_monad expansion methods) + [methods' (monad\each meta_monad expansion methods) members (: (Meta (List [Text Code])) - (monad\map meta_monad - (: (-> Code (Meta [Text Code])) - (function (_ token) - (case token - (^ [_ (#Form (list [_ (#Text "lux type check")] type [_ (#Identifier ["" name])]))]) - (in [name type]) - - _ - (failure "Interfaces require typed members!")))) - (list\joined methods'))) + (monad\each meta_monad + (: (-> Code (Meta [Text Code])) + (function (_ token) + (case token + (^ [_ (#Form (list [_ (#Text "lux type check")] type [_ (#Identifier ["" name])]))]) + (in [name type]) + + _ + (failure "Interfaces require typed members!")))) + (list\conjoint methods'))) .let [def_name (local_identifier$ name) - interface_type (record$ (list\map (: (-> [Text Code] [Code Code]) - (function (_ [module_name m_type]) - [(local_tag$ module_name) m_type])) - members)) - interface_annotations (merged_definition_annotations (` {#.interface? #1}) - (record$ annotations)) + interface_type (` (..Record + (~ (record$ (list\each (: (-> [Text Code] [Code Code]) + (function (_ [module_name m_type]) + [(local_tag$ module_name) m_type])) + members))))) usage (case args #End def_name _ - (` ((~ def_name) (~+ (list\map local_identifier$ args)))))]] - (in_meta (list (` (..type: (~ export_policy) (~ usage) (~ interface_annotations) (~ interface_type)))))) + (` ((~ def_name) (~+ (list\each local_identifier$ args)))))]] + (in_meta (list (` (..type: (~ export_policy) + (~ usage) + (~ (record$ annotations)) + (~ interface_type)))))) #None (failure "Wrong syntax for interface:"))) @@ -3886,36 +3954,39 @@ ) (type: Referrals - #All - (#Only (List Text)) - (#Exclude (List Text)) - #Ignore - #Nothing) + (Variant + #All + (#Only (List Text)) + (#Exclude (List Text)) + #Ignore + #Nothing)) (type: Openings [Text (List Text)]) (type: Refer - {#refer_defs Referrals - #refer_open (List Openings)}) + (Record + {#refer_defs Referrals + #refer_open (List Openings)})) (type: Importation - {#import_name Text - #import_alias (Maybe Text) - #import_refer Refer}) + (Record + {#import_name Text + #import_alias (Maybe Text) + #import_refer Refer})) (def: (referral_references defs) (-> (List Code) (Meta (List Text))) - (monad\map meta_monad - (: (-> Code (Meta Text)) - (function (_ def) - (case def - [_ (#Identifier ["" name])] - (in_meta name) + (monad\each meta_monad + (: (-> Code (Meta Text)) + (function (_ def) + (case def + [_ (#Identifier ["" name])] + (in_meta name) - _ - (failure "#only/#+ and #exclude/#- require identifiers.")))) - defs)) + _ + (failure "#only/#+ and #exclude/#- require identifiers.")))) + defs)) (def: (referrals_parser tokens) (-> (List Code) (Meta [Referrals (List Code)])) @@ -3946,27 +4017,27 @@ (def: (openings_parser parts) (-> (List Code) (Meta [(List Openings) (List Code)])) (case parts - #.End - (in_meta [#.End #.End]) + #End + (in_meta [#End #End]) (^ (list& [_ (#Form (list& [_ (#Text prefix)] structs))] parts')) (do meta_monad - [structs' (monad\map meta_monad - (function (_ struct) - (case struct - [_ (#Identifier ["" struct_name])] - (in_meta struct_name) - - _ - (failure "Expected all implementations of opening form to be identifiers."))) - structs) + [structs' (monad\each meta_monad + (function (_ struct) + (case struct + [_ (#Identifier ["" struct_name])] + (in_meta struct_name) + + _ + (failure "Expected all implementations of opening form to be identifiers."))) + structs) next+remainder (openings_parser parts')] (let [[next remainder] next+remainder] - (in_meta [(#.Item [prefix structs'] next) + (in_meta [(#Item [prefix structs'] next) remainder]))) _ - (in_meta [#.End parts]))) + (in_meta [#End parts]))) (def: (text\split_at' at x) (-> Nat Text [Text Text]) @@ -3986,10 +4057,10 @@ ((: (-> Text Text Text) (function (recur left right) (case (..text\split_by pattern right) - (#.Some [pre post]) + (#Some [pre post]) (recur ($_ "lux text concat" left pre replacement) post) - #.None + #None ("lux text concat" left right)))) "" template)) @@ -4013,23 +4084,23 @@ (-> Text Text Text) (case [(text\split_by ..module_separator hierarchy) (text\split_by ..parallel_hierarchy_sigil root)] - [(#.Some [_ hierarchy']) - (#.Some ["" root'])] + [(#Some [_ hierarchy']) + (#Some ["" root'])] (normal_parallel_path' hierarchy' root') _ (case root "" hierarchy - _ ($_ text\compose root ..module_separator hierarchy)))) + _ ($_ text\composite root ..module_separator hierarchy)))) (def: (normal_parallel_path hierarchy root) (-> Text Text (Maybe Text)) (case (text\split_by ..parallel_hierarchy_sigil root) - (#.Some ["" root']) - (#.Some (normal_parallel_path' hierarchy root')) + (#Some ["" root']) + (#Some (normal_parallel_path' hierarchy root')) _ - #.None)) + #None)) (def: (relative_ups relatives input) (-> Nat Text Nat) @@ -4071,7 +4142,7 @@ clean ("lux text clip" relatives (|> module "lux text size" ("lux i64 -" relatives)) module) output (case ("lux text size" clean) 0 prefix - _ ($_ text\compose prefix ..module_separator clean))] + _ ($_ text\composite prefix ..module_separator clean))] (in_meta output)) (failure ($_ "lux text concat" "Cannot climb the module hierarchy..." ..\n @@ -4081,78 +4152,78 @@ (def: (imports_parser nested? relative_root context_alias imports) (-> Bit Text Text (List Code) (Meta (List Importation))) (do meta_monad - [imports' (monad\map meta_monad - (: (-> Code (Meta (List Importation))) - (function (_ token) - (case token - ... Simple - [_ (#Identifier ["" module_name])] - (do meta_monad - [absolute_module_name (..absolute_module_name nested? relative_root module_name)] - (in (list {#import_name absolute_module_name - #import_alias #None - #import_refer {#refer_defs #All - #refer_open (list)}}))) - - ... Nested - (^ [_ (#Tuple (list& [_ (#Identifier ["" module_name])] extra))]) - (do meta_monad - [absolute_module_name (case (normal_parallel_path relative_root module_name) - (#.Some parallel_path) - (in parallel_path) - - #.None - (..absolute_module_name nested? relative_root module_name)) - referral+extra (referrals_parser extra) - .let [[referral extra] referral+extra] - openings+extra (openings_parser extra) - .let [[openings extra] openings+extra] - sub_imports (imports_parser #1 absolute_module_name context_alias extra)] - (in (case [referral openings] - [#Nothing #End] - sub_imports - - _ - (list& {#import_name absolute_module_name - #import_alias #None - #import_refer {#refer_defs referral - #refer_open openings}} - sub_imports)))) - - (^ [_ (#Tuple (list& [_ (#Text alias)] [_ (#Identifier ["" module_name])] extra))]) - (do meta_monad - [absolute_module_name (case (normal_parallel_path relative_root module_name) - (#.Some parallel_path) - (in parallel_path) - - #.None - (..absolute_module_name nested? relative_root module_name)) - referral+extra (referrals_parser extra) - .let [[referral extra] referral+extra] - openings+extra (openings_parser extra) - .let [[openings extra] openings+extra - module_alias (..module_alias context_alias module_name alias)] - sub_imports (imports_parser #1 absolute_module_name module_alias extra)] - (in (case [referral openings] - [#Ignore #End] - sub_imports - - _ - (list& {#import_name absolute_module_name - #import_alias (#Some module_alias) - #import_refer {#refer_defs referral - #refer_open openings}} - sub_imports)))) - - ... Unrecognized syntax. - _ - (do meta_monad - [current_module current_module_name] - (failure ($_ text\compose - "Wrong syntax for import @ " current_module - ..\n (code\encoded token))))))) - imports)] - (in (list\joined imports')))) + [imports' (monad\each meta_monad + (: (-> Code (Meta (List Importation))) + (function (_ token) + (case token + ... Simple + [_ (#Identifier ["" module_name])] + (do meta_monad + [absolute_module_name (..absolute_module_name nested? relative_root module_name)] + (in (list {#import_name absolute_module_name + #import_alias #None + #import_refer {#refer_defs #All + #refer_open (list)}}))) + + ... Nested + (^ [_ (#Tuple (list& [_ (#Identifier ["" module_name])] extra))]) + (do meta_monad + [absolute_module_name (case (normal_parallel_path relative_root module_name) + (#Some parallel_path) + (in parallel_path) + + #None + (..absolute_module_name nested? relative_root module_name)) + referral+extra (referrals_parser extra) + .let [[referral extra] referral+extra] + openings+extra (openings_parser extra) + .let [[openings extra] openings+extra] + sub_imports (imports_parser #1 absolute_module_name context_alias extra)] + (in (case [referral openings] + [#Nothing #End] + sub_imports + + _ + (list& {#import_name absolute_module_name + #import_alias #None + #import_refer {#refer_defs referral + #refer_open openings}} + sub_imports)))) + + (^ [_ (#Tuple (list& [_ (#Text alias)] [_ (#Identifier ["" module_name])] extra))]) + (do meta_monad + [absolute_module_name (case (normal_parallel_path relative_root module_name) + (#Some parallel_path) + (in parallel_path) + + #None + (..absolute_module_name nested? relative_root module_name)) + referral+extra (referrals_parser extra) + .let [[referral extra] referral+extra] + openings+extra (openings_parser extra) + .let [[openings extra] openings+extra + module_alias (..module_alias context_alias module_name alias)] + sub_imports (imports_parser #1 absolute_module_name module_alias extra)] + (in (case [referral openings] + [#Ignore #End] + sub_imports + + _ + (list& {#import_name absolute_module_name + #import_alias (#Some module_alias) + #import_refer {#refer_defs referral + #refer_open openings}} + sub_imports)))) + + ... Unrecognized syntax. + _ + (do meta_monad + [current_module current_module_name] + (failure ($_ text\composite + "Wrong syntax for import @ " current_module + ..\n (code\encoded token))))))) + imports)] + (in (list\conjoint imports')))) (def: (exported_definitions module state) (-> Text (Meta (List Text))) @@ -4164,23 +4235,23 @@ [current_module modules])] (case (plist\value module modules) (#Some =module) - (let [to_alias (list\map (: (-> [Text Global] - (List Text)) - (function (_ [name definition]) - (case definition - (#Left _) - (list) - - (#Right [exported? def_type def_meta def_value]) - (if exported? - (list name) - (list))))) - (let [{#module_hash _ #module_aliases _ #definitions definitions #imports _ #tags tags #types types #module_annotations _ #module_state _} =module] - definitions))] - (#Right state (list\joined to_alias))) + (let [to_alias (list\each (: (-> [Text Global] + (List Text)) + (function (_ [name definition]) + (case definition + (#Left _) + (list) + + (#Right [exported? def_type def_meta def_value]) + (if exported? + (list name) + (list))))) + (let [{#module_hash _ #module_aliases _ #definitions definitions #imports _ #tags tags #types types #module_annotations _ #module_state _} =module] + definitions))] + (#Right state (list\conjoint to_alias))) #None - (#Left ($_ text\compose + (#Left ($_ text\composite "Unknown module: " (text\encoded module) ..\n "Current module: " (case current_module (#Some current_module) @@ -4189,8 +4260,8 @@ #None "???") ..\n "Known modules: " (|> modules - (list\map (function (_ [name module]) - (text$ name))) + (list\each (function (_ [name module]) + (text$ name))) tuple$ code\encoded)))) )) @@ -4278,12 +4349,12 @@ #scope_type_vars scope_type_vars #eval _eval} state] (case (plist\value v_module modules) #None - (#Left (text\compose "Unknown definition: " (name\encoded name))) + (#Left (text\composite "Unknown definition: " (name\encoded name))) (#Some {#definitions definitions #module_hash _ #module_aliases _ #imports _ #tags tags #types types #module_annotations _ #module_state _}) (case (plist\value v_name definitions) #None - (#Left (text\compose "Unknown definition: " (name\encoded name))) + (#Left (text\composite "Unknown definition: " (name\encoded name))) (#Some definition) (case definition @@ -4321,13 +4392,13 @@ (#Right [compiler struct_type]) _ - (#Left ($_ text\compose "Unknown var: " (name\encoded full_name))))) + (#Left ($_ text\composite "Unknown var: " (name\encoded full_name))))) (case (definition_type full_name compiler) (#Some struct_type) (#Right [compiler struct_type]) _ - (#Left ($_ text\compose "Unknown var: " (name\encoded full_name)))))] + (#Left ($_ text\composite "Unknown var: " (name\encoded full_name)))))] (case temp (#Right [compiler (#Var type_id)]) (let [{#info _ #source _ #current_module _ #modules _ @@ -4369,37 +4440,37 @@ name _ - ($_ text\compose "(" name " " (|> params (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) ")")) + ($_ text\composite "(" name " " (|> params (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")")) (#Sum _) - ($_ text\compose "(Or " (|> (flat_variant type) (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) ")") + ($_ text\composite "(Or " (|> (flat_variant type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")") (#Product _) - ($_ text\compose "[" (|> (flat_tuple type) (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) "]") + ($_ text\composite "[" (|> (flat_tuple type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) "]") (#Function _) - ($_ text\compose "(-> " (|> (flat_lambda type) (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) ")") + ($_ text\composite "(-> " (|> (flat_lambda type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")") (#Parameter id) (nat\encoded id) (#Var id) - ($_ text\compose "⌈v:" (nat\encoded id) "⌋") + ($_ text\composite "⌈v:" (nat\encoded id) "⌋") (#Ex id) - ($_ text\compose "⟨e:" (nat\encoded id) "⟩") + ($_ text\composite "⟨e:" (nat\encoded id) "⟩") (#UnivQ env body) - ($_ text\compose "(All " (type\encoded body) ")") + ($_ text\composite "(All " (type\encoded body) ")") (#ExQ env body) - ($_ text\compose "(Ex " (type\encoded body) ")") + ($_ text\composite "(Ex " (type\encoded body) ")") (#Apply _) (let [[func args] (flat_application type)] - ($_ text\compose + ($_ text\composite "(" (type\encoded func) " " - (|> args (list\map type\encoded) (list\interposed " ") list\reversed (list\mix text\compose "")) + (|> args (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")")) (#Named name _) @@ -4425,16 +4496,16 @@ struct_evidence (record_slots init_type)] (case struct_evidence #None - (failure (text\compose "Can only 'open' structs: " (type\encoded init_type))) + (failure (text\composite "Can only 'open' structs: " (type\encoded init_type))) (#Some tags&members) (do meta_monad [full_body ((: (-> Name [(List Name) (List Type)] Code (Meta Code)) (function (recur source [tags members] target) - (let [locals (list\map (function (_ [t_module t_name]) - ["" (..module_alias "" t_name alias)]) - tags) - pattern (tuple$ (list\map identifier$ locals))] + (let [locals (list\each (function (_ [t_module t_name]) + ["" (..module_alias "" t_name alias)]) + tags) + pattern (tuple$ (list\each identifier$ locals))] (do meta_monad [enhanced_target (monad\mix meta_monad (function (_ [m_local m_type] enhanced_target) @@ -4513,13 +4584,13 @@ g!output (..identifier "")] (case (interface_methods type) (#Some members) - (let [pattern (record$ (list\map (: (-> [Name [Nat Type]] [Code Code]) - (function (_ [[r_module r_name] [r_idx r_type]]) - [(tag$ [r_module r_name]) - (if ("lux i64 =" idx r_idx) - g!output - g!_)])) - (zipped/2 tags (enumeration members))))] + (let [pattern (record$ (list\each (: (-> [Name [Nat Type]] [Code Code]) + (function (_ [[r_module r_name] [r_idx r_type]]) + [(tag$ [r_module r_name]) + (if ("lux i64 =" idx r_idx) + g!output + g!_)])) + (zipped/2 tags (enumeration members))))] (in_meta (list (` ({(~ pattern) (~ g!output)} (~ record)))))) _ @@ -4549,26 +4620,26 @@ .let [g!output (local_identifier$ short) pattern (|> tags enumeration - (list\map (function (_ [tag_idx tag]) - (if ("lux i64 =" my_tag_index tag_idx) - g!output - g!_))) + (list\each (function (_ [tag_idx tag]) + (if ("lux i64 =" my_tag_index tag_idx) + g!output + g!_))) tuple$) source+ (` ({(~ pattern) (~ g!output)} (~ source)))]] (case output (#Some [tags' members']) (do meta_monad - [decls' (monad\map meta_monad - (: (-> [Nat Name Type] (Meta (List Code))) - (function (_ [sub_tag_index sname stype]) - (open_declaration alias tags' sub_tag_index sname source+ stype))) - (enumeration (zipped/2 tags' members')))] - (in_meta (list\joined decls'))) + [decls' (monad\each meta_monad + (: (-> [Nat Name Type] (Meta (List Code))) + (function (_ [sub_tag_index sname stype]) + (open_declaration alias tags' sub_tag_index sname source+ stype))) + (enumeration (zipped/2 tags' members')))] + (in_meta (list\conjoint decls'))) _ (in_meta (list (` ("lux def" (~ (local_identifier$ (..module_alias "" short alias))) (~ source+) - [(~ location_code) (#.Record #End)] + [(~ location_code) (#.Record #.End)] #0))))))) (macro: .public (open: tokens) @@ -4594,20 +4665,20 @@ (case output (#Some [tags members]) (do meta_monad - [decls' (monad\map meta_monad (: (-> [Nat Name Type] (Meta (List Code))) - (function (_ [tag_index sname stype]) - (open_declaration alias tags tag_index sname source stype))) - (enumeration (zipped/2 tags members)))] - (in_meta (list\joined decls'))) + [decls' (monad\each meta_monad (: (-> [Nat Name Type] (Meta (List Code))) + (function (_ [tag_index sname stype]) + (open_declaration alias tags tag_index sname source stype))) + (enumeration (zipped/2 tags members)))] + (in_meta (list\conjoint decls'))) _ - (failure (text\compose "Can only 'open:' structs: " (type\encoded struct_type))))) + (failure (text\composite "Can only 'open:' structs: " (type\encoded struct_type))))) _ (do meta_monad [g!struct (..identifier "struct")] (in_meta (list (` ("lux def" (~ g!struct) (~ struct) - [(~ location_code) (#.Record #End)] + [(~ location_code) (#.Record #.End)] #0)) (` (..open: (~ (text$ alias)) (~ g!struct))))))) @@ -4617,9 +4688,9 @@ (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\encoded) (interposed '' '') (mix text\compose ''''))" ..\n + "(|>> (list\each int\encoded) (interposed '' '') (mix text\composite ''''))" ..\n "... =>" ..\n - "(function (_ <arg>) (mix text\compose '''' (interposed '' '' (list\map int\encoded <arg>))))"))} + "(function (_ <arg>) (mix text\composite '''' (interposed '' '' (list\each int\encoded <arg>))))"))} (do meta_monad [g!_ (..identifier "_") g!arg (..identifier "arg")] @@ -4628,9 +4699,9 @@ (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 - "(<<| (mix text\compose '''') (interposed '' '') (list\map int\encoded))" ..\n + "(<<| (mix text\composite '''') (interposed '' '') (list\each int\encoded))" ..\n "... =>" ..\n - "(function (_ <arg>) (mix text\compose '''' (interposed '' '' (list\map int\encoded <arg>))))"))} + "(function (_ <arg>) (mix text\composite '''' (interposed '' '' (list\each int\encoded <arg>))))"))} (do meta_monad [g!_ (..identifier "_") g!arg (..identifier "arg")] @@ -4657,11 +4728,11 @@ #refer_open openings}) _ - (failure ($_ text\compose "Wrong syntax for refer @ " current_module + (failure ($_ text\composite "Wrong syntax for refer @ " current_module ..\n (|> options - (list\map code\encoded) + (list\each code\encoded) (list\interposed " ") - (list\mix text\compose ""))))))) + (list\mix text\composite ""))))))) (def: (referral_definitions module_name [r_defs r_opens]) (-> Text Refer (Meta (List Code))) @@ -4669,13 +4740,13 @@ [current_module current_module_name .let [test_referrals (: (-> Text (List Text) (List Text) (Meta (List Any))) (function (_ module_name all_defs referred_defs) - (monad\map meta_monad - (: (-> Text (Meta Any)) - (function (_ _def) - (if (is_member? all_defs _def) - (in_meta []) - (failure ($_ text\compose _def " is not defined in module " module_name " @ " current_module))))) - referred_defs)))] + (monad\each meta_monad + (: (-> Text (Meta Any)) + (function (_ _def) + (if (is_member? all_defs _def) + (in_meta []) + (failure ($_ text\composite _def " is not defined in module " module_name " @ " current_module))))) + referred_defs)))] defs' (case r_defs #All (exported_definitions module_name) @@ -4697,18 +4768,18 @@ #Nothing (in (list))) - .let [defs (list\map (: (-> Text Code) - (function (_ def) - (` ("lux def alias" (~ (local_identifier$ def)) (~ (identifier$ [module_name def])))))) - defs') + .let [defs (list\each (: (-> Text Code) + (function (_ def) + (` ("lux def alias" (~ (local_identifier$ def)) (~ (identifier$ [module_name def])))))) + defs') openings (|> r_opens - (list\map (: (-> Openings (List Code)) - (function (_ [alias structs]) - (list\map (function (_ name) - (` (open: (~ (text$ alias)) (~ (identifier$ [module_name name]))))) - structs)))) - list\joined)]] - (in (list\compose defs openings)))) + (list\each (: (-> Openings (List Code)) + (function (_ [alias structs]) + (list\each (function (_ name) + (` (open: (~ (text$ alias)) (~ (identifier$ [module_name name]))))) + structs)))) + list\conjoint)]] + (in (list\composite defs openings)))) (macro: (refer tokens) (case tokens @@ -4729,20 +4800,20 @@ (list (' #*)) (#Only defs) - (list (form$ (list& (' #+) (list\map local_identifier$ defs)))) + (list (form$ (list& (' #+) (list\each local_identifier$ defs)))) (#Exclude defs) - (list (form$ (list& (' #-) (list\map local_identifier$ defs)))) + (list (form$ (list& (' #-) (list\each local_identifier$ defs)))) #Ignore (list) #Nothing (list))) - openings (list\map (function (_ [alias structs]) - (form$ (list& (text$ (..replaced ..contextual_reference module_alias alias)) - (list\map local_identifier$ structs)))) - r_opens)] + openings (list\each (function (_ [alias structs]) + (form$ (list& (text$ (..replaced ..contextual_reference module_alias alias)) + (list\each local_identifier$ structs)))) + r_opens)] (` ((~! ..refer) (~ (text$ module_name)) (~+ localizations) (~+ openings))))) @@ -4776,14 +4847,14 @@ current_module current_module_name imports (imports_parser #0 current_module "" _imports) .let [=imports (|> imports - (list\map (: (-> Importation Code) - (function (_ [module_name m_alias =refer]) - (` [(~ (text$ module_name)) (~ (text$ (..else "" m_alias)))])))) + (list\each (: (-> Importation Code) + (function (_ [module_name m_alias =refer]) + (` [(~ (text$ module_name)) (~ (text$ (..else "" m_alias)))])))) tuple$) - =refers (list\map (: (-> Importation Code) - (function (_ [module_name m_alias =refer]) - (refer_code module_name m_alias =refer))) - imports) + =refers (list\each (: (-> Importation Code) + (function (_ [module_name m_alias =refer]) + (refer_code module_name m_alias =refer))) + imports) =module (` ("lux def module" [(~ location_code) (#.Record (~ (definition_annotations _meta)))] (~ =imports)))]] @@ -4826,25 +4897,25 @@ (case (interface_methods type) (#Some members) (do meta_monad - [pattern' (monad\map meta_monad - (: (-> [Name [Nat Type]] (Meta [Name Nat Code])) - (function (_ [r_slot_name [r_idx r_type]]) - (do meta_monad - [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]) + [pattern' (monad\each meta_monad + (: (-> [Name [Nat Type]] (Meta [Name Nat Code])) + (function (_ [r_slot_name [r_idx r_type]]) + (do meta_monad + [g!slot (..identifier "")] + (in_meta [r_slot_name r_idx g!slot])))) + (zipped/2 tags (enumeration members)))] + (let [pattern (record$ (list\each (: (-> [Name Nat Code] [Code Code]) + (function (_ [r_slot_name r_idx r_var]) + [(tag$ r_slot_name) + r_var])) + pattern')) + output (record$ (list\each (: (-> [Name Nat Code] [Code Code]) (function (_ [r_slot_name r_idx r_var]) [(tag$ r_slot_name) - r_var])) - pattern')) - output (record$ (list\map (: (-> [Name Nat Code] [Code Code]) - (function (_ [r_slot_name r_idx r_var]) - [(tag$ r_slot_name) - (if ("lux i64 =" idx r_idx) - value - r_var)])) - pattern'))] + (if ("lux i64 =" idx r_idx) + value + r_var)])) + pattern'))] (in_meta (list (` ({(~ pattern) (~ output)} (~ record))))))) _ @@ -4857,10 +4928,10 @@ _ (do meta_monad - [bindings (monad\map meta_monad - (: (-> Code (Meta Code)) - (function (_ _) (..identifier "temp"))) - slots) + [bindings (monad\each meta_monad + (: (-> Code (Meta Code)) + (function (_ _) (..identifier "temp"))) + slots) .let [pairs (zipped/2 slots bindings) update_expr (list\mix (: (-> [Code Code] Code Code) (function (_ [s b] v) @@ -4873,7 +4944,7 @@ (#Item (list new_binding old_record) accesses')])) [record (: (List (List Code)) #End)] pairs) - accesses (list\joined (list\reversed accesses'))]] + accesses (list\conjoint (list\reversed accesses'))]] (in (list (` (let [(~+ accesses)] (~ update_expr))))))) @@ -4915,25 +4986,25 @@ (case (interface_methods type) (#Some members) (do meta_monad - [pattern' (monad\map meta_monad - (: (-> [Name [Nat Type]] (Meta [Name Nat Code])) - (function (_ [r_slot_name [r_idx r_type]]) - (do meta_monad - [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]) + [pattern' (monad\each meta_monad + (: (-> [Name [Nat Type]] (Meta [Name Nat Code])) + (function (_ [r_slot_name [r_idx r_type]]) + (do meta_monad + [g!slot (..identifier "")] + (in_meta [r_slot_name r_idx g!slot])))) + (zipped/2 tags (enumeration members)))] + (let [pattern (record$ (list\each (: (-> [Name Nat Code] [Code Code]) + (function (_ [r_slot_name r_idx r_var]) + [(tag$ r_slot_name) + r_var])) + pattern')) + output (record$ (list\each (: (-> [Name Nat Code] [Code Code]) (function (_ [r_slot_name r_idx r_var]) [(tag$ r_slot_name) - r_var])) - pattern')) - output (record$ (list\map (: (-> [Name Nat Code] [Code Code]) - (function (_ [r_slot_name r_idx r_var]) - [(tag$ r_slot_name) - (if ("lux i64 =" idx r_idx) - (` ((~ fun) (~ r_var))) - r_var)])) - pattern'))] + (if ("lux i64 =" idx r_idx) + (` ((~ fun) (~ r_var))) + r_var)])) + pattern'))] (in_meta (list (` ({(~ pattern) (~ output)} (~ record))))))) _ @@ -4977,7 +5048,7 @@ " (-> (List Type) Type Type)" ..\n " (case type" ..\n " (#.Primitive name params)" ..\n - " (#.Primitive name (list\map (reduced env) params))" + " (#.Primitive name (list\each (reduced env) params))" __paragraph " (^template [<tag>]" ..\n " [(<tag> left right)" ..\n @@ -5012,20 +5083,20 @@ branches)) (case (: (Maybe (List Code)) (do maybe_monad - [bindings' (monad\map maybe_monad identifier_short bindings) - data' (monad\map maybe_monad tuple_list data)] + [bindings' (monad\each maybe_monad identifier_short bindings) + data' (monad\each maybe_monad tuple_list data)] (let [num_bindings (list\size bindings')] (if (every? (|>> ("lux i64 =" num_bindings)) - (list\map list\size data')) + (list\each list\size data')) (let [apply (: (-> Replacement_Environment (List Code)) - (function (_ env) (list\map (realized_template env) templates)))] + (function (_ env) (list\each (realized_template env) templates)))] (|> data' - (list\map (function\composite apply (replacement_environment bindings'))) - list\joined + (list\each (function\composite apply (replacement_environment bindings'))) + list\conjoint in)) #None)))) (#Some output) - (in_meta (list\compose output branches)) + (in_meta (list\composite output branches)) #None (failure "Wrong syntax for ^template")) @@ -5050,19 +5121,20 @@ (^template [<tag>] [[[_ _ column] (<tag> parts)] - (list\mix n/min column (list\map baseline_column parts))]) + (list\mix n/min column (list\each baseline_column parts))]) ([#Form] [#Tuple]) [[_ _ column] (#Record pairs)] (list\mix n/min column - (list\compose (list\map (|>> product\left baseline_column) pairs) - (list\map (|>> product\right baseline_column) pairs))) + (list\composite (list\each (|>> product\left baseline_column) pairs) + (list\each (|>> product\right baseline_column) pairs))) )) (type: Documentation_Fragment - (#Documentation_Comment Text) - (#Documentation_Example Code)) + (Variant + (#Documentation_Comment Text) + (#Documentation_Example Code))) (def: (documentation_fragment code) (-> Code Documentation_Fragment) @@ -5085,7 +5157,8 @@ (def: tag\encoded (-> Name Text) - (|>> name\encoded (text\compose "#"))) + (|>> name\encoded + (text\composite "#"))) (def: (repeated n x) (All [a] (-> Int a (List a))) @@ -5099,7 +5172,7 @@ (text\interposed "" (repeated (.int ("lux i64 -" old_column new_column)) " ")) (let [extra_lines (text\interposed "" (repeated (.int ("lux i64 -" old_line new_line)) ..\n)) space_padding (text\interposed "" (repeated (.int ("lux i64 -" baseline new_column)) " "))] - (text\compose extra_lines space_padding)))) + (text\composite extra_lines space_padding)))) (def: (text\size x) (-> Text Nat) @@ -5109,14 +5182,6 @@ (-> Location Text Location) [file line ("lux i64 +" column (text\size code_text))]) -(def: un_paired - (-> (List [Code Code]) (List Code)) - (let [pair_list (: (-> [Code Code] (List Code)) - (function (_ [left right]) - (list left right)))] - (|>> (list\map pair_list) - list\joined))) - (def: (example_documentation prev_location baseline example) (-> Location Nat Code [Location Text]) (case example @@ -5124,8 +5189,8 @@ [[new_location (<tag> value)] (let [as_text (<encoded> value)] [(updated_location new_location as_text) - (text\compose (location_padding baseline prev_location new_location) - as_text)])]) + (text\composite (location_padding baseline prev_location new_location) + as_text)])]) ([#Bit bit\encoded] [#Nat nat\encoded] [#Int int\encoded] @@ -5138,11 +5203,11 @@ [[group_location (<tag> parts)] (let [[group_location' parts_text] (list\mix (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)])) + [part_location (text\composite text_accum part_text)])) [(revised@ #column ++ group_location) ""] (<prep> parts))] [(revised@ #column ++ group_location') - ($_ text\compose (location_padding baseline prev_location group_location) + ($_ text\composite (location_padding baseline prev_location group_location) <open> parts_text <close>)])]) @@ -5160,14 +5225,14 @@ (#Documentation_Comment comment) (|> comment (text\all_split_by ..\n) - (list\map (function (_ line) ($_ text\compose "... " line ..\n))) + (list\each (function (_ line) ($_ text\composite "... " line ..\n))) (text\interposed "")) (#Documentation_Example example) (let [baseline (baseline_column example) [location _] example - [_ text] (..example_documentation (with@ #.column baseline location) baseline example)] - (text\compose text __paragraph)))) + [_ text] (..example_documentation (with@ #column baseline location) baseline example)] + (text\composite text __paragraph)))) (macro: .public (example tokens) {#.doc (text$ ($_ "lux text concat" @@ -5183,7 +5248,7 @@ " x)))"))} (in_meta (list (` [(~ location_code) (#.Text (~ (|> tokens - (list\map (|>> ..documentation_fragment ..fragment_documentation)) + (list\each (|>> ..documentation_fragment ..fragment_documentation)) (text\interposed "") text$)))])))) @@ -5205,7 +5270,7 @@ (-> Type Code) (case type (#Primitive name params) - (` (#.Primitive (~ (text$ name)) (~ (untemplated_list (list\map type_code params))))) + (` (#.Primitive (~ (text$ name)) (~ (untemplated_list (list\each type_code params))))) (^template [<tag>] [(<tag> left right) @@ -5221,7 +5286,7 @@ (^template [<tag>] [(<tag> env type) - (let [env' (untemplated_list (list\map type_code env))] + (let [env' (untemplated_list (list\each type_code env))] (` (<tag> (~ env') (~ (type_code type)))))]) ([#.UnivQ] [#.ExQ]) @@ -5250,43 +5315,43 @@ x)))} (let [?params (case tokens (^ (list name [_ (#Tuple bindings)] body)) - (#.Some [name bindings body]) + (#Some [name bindings body]) (^ (list [_ (#Tuple bindings)] body)) - (#.Some [(local_identifier$ "recur") bindings body]) + (#Some [(local_identifier$ "recur") bindings body]) _ - #.None)] + #None)] (case ?params - (#.Some [name bindings body]) + (#Some [name bindings body]) (let [pairs (pairs bindings) - vars (list\map product\left pairs) - inits (list\map product\right pairs)] + vars (list\each product\left pairs) + inits (list\each product\right pairs)] (if (every? identifier? inits) (do meta_monad [inits' (: (Meta (List Name)) - (case (monad\map maybe_monad identifier_name inits) + (case (monad\each maybe_monad identifier_name inits) (#Some inits') (in_meta inits') #None (failure "Wrong syntax for loop"))) - init_types (monad\map meta_monad type_definition inits') + init_types (monad\each meta_monad type_definition inits') expected ..expected_type] (in_meta (list (` (("lux type check" - (-> (~+ (list\map type_code init_types)) + (-> (~+ (list\each type_code init_types)) (~ (type_code expected))) (function ((~ name) (~+ vars)) (~ body))) (~+ inits)))))) (do meta_monad - [aliases (monad\map meta_monad - (: (-> Code (Meta Code)) - (function (_ _) (..identifier ""))) - inits)] + [aliases (monad\each meta_monad + (: (-> Code (Meta Code)) + (function (_ _) (..identifier ""))) + inits)] (in_meta (list (` (let [(~+ (..interleaved aliases inits))] (.loop (~ name) [(~+ (..interleaved vars aliases))] (~ body))))))))) - #.None + #None (failure "Wrong syntax for loop")))) (macro: .public (^slots tokens) @@ -5301,7 +5366,7 @@ (case (: (Maybe [Name (List Name)]) (do maybe_monad [hslot (..tag_name hslot') - tslots (monad\map maybe_monad ..tag_name tslots')] + tslots (monad\each maybe_monad ..tag_name tslots')] (in [hslot tslots]))) (#Some slots) (in_meta slots) @@ -5310,21 +5375,21 @@ (failure "Wrong syntax for ^slots"))) .let [[hslot tslots] slots] hslot (..normal hslot) - tslots (monad\map meta_monad ..normal tslots) + tslots (monad\each meta_monad ..normal tslots) output (..type_tag hslot) g!_ (..identifier "_") .let [[idx tags exported? type] output - slot_pairings (list\map (: (-> Name [Text Code]) - (function (_ [module name]) - [name (local_identifier$ name)])) - (list& hslot tslots)) - pattern (record$ (list\map (: (-> Name [Code Code]) - (function (_ [module name]) - (let [tag (tag$ [module name])] - (case (plist\value name slot_pairings) - (#Some binding) [tag binding] - #None [tag g!_])))) - tags))]] + slot_pairings (list\each (: (-> Name [Text Code]) + (function (_ [module name]) + [name (local_identifier$ name)])) + (list& hslot tslots)) + pattern (record$ (list\each (: (-> Name [Code Code]) + (function (_ [module name]) + (let [tag (tag$ [module name])] + (case (plist\value name slot_pairings) + (#Some binding) [tag binding] + #None [tag g!_])))) + tags))]] (in_meta (list& pattern body branches))) _ @@ -5345,26 +5410,26 @@ (^template [<tag>] [[location (<tag> elems)] (do maybe_monad - [placements (monad\map maybe_monad (with_expansions' label tokens) elems)] - (in (list [location (<tag> (list\joined placements))])))]) + [placements (monad\each maybe_monad (with_expansions' label tokens) elems)] + (in (list [location (<tag> (list\conjoint placements))])))]) ([#Tuple] [#Form]) [location (#Record pairs)] (do maybe_monad - [=pairs (monad\map maybe_monad - (: (-> [Code Code] (Maybe [Code Code])) - (function (_ [slot value]) - (do maybe_monad - [slot' (with_expansions' label tokens slot) - value' (with_expansions' label tokens value)] - (case [slot' value'] - (^ [(list =slot) (list =value)]) - (in [=slot =value]) - - _ - #None)))) - pairs)] + [=pairs (monad\each maybe_monad + (: (-> [Code Code] (Maybe [Code Code])) + (function (_ [slot value]) + (do maybe_monad + [slot' (with_expansions' label tokens slot) + value' (with_expansions' label tokens value)] + (case [slot' value'] + (^ [(list =slot) (list =value)]) + (in [=slot =value]) + + _ + #None)))) + pairs)] (in (list [location (#Record =pairs)]))))) (macro: .public (with_expansions tokens) @@ -5448,7 +5513,7 @@ ["Text" Text text$]) _ - (failure (text\compose "Cannot anti-quote type: " (name\encoded name)))))) + (failure (text\composite "Cannot anti-quote type: " (name\encoded name)))))) (def: (static_literal token) (-> Code (Meta Code)) @@ -5463,20 +5528,20 @@ (^template [<tag>] [[meta (<tag> parts)] (do meta_monad - [=parts (monad\map meta_monad static_literal parts)] + [=parts (monad\each meta_monad static_literal parts)] (in [meta (<tag> =parts)]))]) ([#Form] [#Tuple]) [meta (#Record pairs)] (do meta_monad - [=pairs (monad\map meta_monad - (: (-> [Code Code] (Meta [Code Code])) - (function (_ [slot value]) - (do meta_monad - [=value (static_literal value)] - (in [slot =value])))) - pairs)] + [=pairs (monad\each meta_monad + (: (-> [Code Code] (Meta [Code Code])) + (function (_ [slot value]) + (do meta_monad + [=value (static_literal value)] + (in [slot =value])))) + pairs)] (in [meta (#Record =pairs)])) _ @@ -5537,14 +5602,14 @@ (#Item init extras) (do meta_monad - [extras' (monad\map meta_monad case_level^ extras)] + [extras' (monad\each meta_monad case_level^ extras)] (in [init extras'])))) (def: (multi_level_case$ g!_ [[init_pattern levels] body]) (-> Code [Multi_Level_Case Code] (List Code)) (let [inner_pattern_body (list\mix (function (_ [calculation pattern] success) (let [bind? (case pattern - [_ (#.Identifier _)] + [_ (#Identifier _)] #1 _ @@ -5565,28 +5630,28 @@ "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']) + (^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']) + (^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 [mlc (multi_level_case^ levels) .let [initial_bind? (case mlc - [[_ (#.Identifier _)] _] + [[_ (#Identifier _)] _] #1 _ @@ -5618,7 +5683,7 @@ (def: wrong_syntax_error (-> Name Text) (|>> name\encoded - (text\compose "Wrong syntax for "))) + (text\composite "Wrong syntax for "))) (macro: .public (name_of tokens) {#.doc (example "Given an identifier or a tag, gives back a 2 tuple with the module and name parts, both as Text." @@ -5662,7 +5727,7 @@ (in (list (` (#Ex (~ (nat$ var_id)))))) #None - (failure (text\compose "Indexed-type does not exist: " (nat\encoded idx))))) + (failure (text\composite "Indexed-type does not exist: " (nat\encoded idx))))) _ (failure (..wrong_syntax_error (name_of ..$))))) @@ -5785,36 +5850,36 @@ _ #None)) -(def:' .private (templateP tokens) - (-> (List Code) (Maybe [Code Text (List Text) (List [Code Code]) (List Code)])) - (|> (do maybe_monad - [% (declarationP tokens) - .let' [[tokens [export_policy name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - % (tupleP tokens) - .let' [[tokens templates] %] - _ (endP tokens)] - (in [export_policy name parameters annotations templates])) - ... (^ (list _export_policy _declaration _annotations _body)) - ... (^ (list _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [% (declarationP tokens) - .let' [[tokens [export_policy name parameters]] %] - % (tupleP tokens) - .let' [[tokens templates] %] - _ (endP tokens)] - (in [export_policy name parameters #End templates]))) - ... (^ (list _export_policy _declaration _body)) - (maybe\else' (do maybe_monad - [% (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (tupleP tokens) - .let' [[tokens templates] %] - _ (endP tokens)] - (in [(` ..private) name parameters #End templates]))) - ... (^ (list _declaration _body)) - )) +(def: (templateP tokens) + (-> (List Code) (Maybe [Code Text (List Text) (List [Code Code]) (List Code)])) + (|> (do maybe_monad + [% (declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + % (tupleP tokens) + .let' [[tokens templates] %] + _ (endP tokens)] + (in [export_policy name parameters annotations templates])) + ... (^ (list _export_policy _declaration _annotations _body)) + ... (^ (list _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [% (declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (tupleP tokens) + .let' [[tokens templates] %] + _ (endP tokens)] + (in [export_policy name parameters #End templates]))) + ... (^ (list _export_policy _declaration _body)) + (maybe\else' (do maybe_monad + [% (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (tupleP tokens) + .let' [[tokens templates] %] + _ (endP tokens)] + (in [(` ..private) name parameters #End templates]))) + ... (^ (list _declaration _body)) + )) (macro: .public (template: tokens) {#.doc (example "Define macros in the style of template and ^template." @@ -5822,30 +5887,30 @@ (template: (square x) (* x x)))} (case (templateP tokens) - (#.Some [export_policy name args anns input_templates]) + (#Some [export_policy name args anns input_templates]) (do meta_monad [g!tokens (..identifier "tokens") g!compiler (..identifier "compiler") g!_ (..identifier "_") - .let [rep_env (list\map (function (_ arg) - [arg (` ((~' ~) (~ (local_identifier$ arg))))]) - args)] + .let [rep_env (list\each (function (_ arg) + [arg (` ((~' ~) (~ (local_identifier$ arg))))]) + args)] this_module current_module_name] (in (list (` (macro: (~ export_policy) ((~ (local_identifier$ name)) (~ g!tokens) (~ g!compiler)) (~ (record$ anns)) (case (~ g!tokens) - (^ (list (~+ (list\map local_identifier$ args)))) + (^ (list (~+ (list\each local_identifier$ args)))) (#.Right [(~ g!compiler) - (list (~+ (list\map (function (_ template) - (` (`' (~ (with_replacements rep_env - template))))) - input_templates)))]) + (list (~+ (list\each (function (_ template) + (` (`' (~ (with_replacements rep_env + template))))) + input_templates)))]) (~ g!_) (#.Left (~ (text$ (..wrong_syntax_error [this_module name])))))))))) - #.None + #None (failure (..wrong_syntax_error (name_of ..template:))))) (macro: .public (as_is tokens compiler) @@ -5896,12 +5961,12 @@ (in (:as ..Text value)) _ - (failure ($_ text\compose + (failure ($_ text\composite "Invalid target platform (must be a value of type Text): " (name\encoded identifier) " : " (..code\encoded (..type_code type)))))) _ - (failure ($_ text\compose + (failure ($_ text\composite "Invalid target platform syntax: " (..code\encoded choice) ..\n "Must be either a text literal or an identifier.")))) @@ -5910,10 +5975,10 @@ (case options #End (case default - #.None - (failure ($_ text\compose "No code for target platform: " target)) + #None + (failure ($_ text\composite "No code for target platform: " target)) - (#.Some default) + (#Some default) (in_meta (list default))) (#Item [key pick] options') @@ -5934,10 +5999,10 @@ [target ..target] (case tokens (^ (list [_ (#Record options)])) - (target_pick target options #.None) + (target_pick target options #None) (^ (list [_ (#Record options)] default)) - (target_pick target options (#.Some default)) + (target_pick target options (#Some default)) _ (failure (..wrong_syntax_error (name_of ..for)))))) @@ -5961,24 +6026,24 @@ (^template [<tag>] [[ann (<tag> parts)] (do meta_monad - [=parts (monad\map meta_monad embedded_expansions parts)] - (in [(list\mix list\compose (list) (list\map left =parts)) - [ann (<tag> (list\map right =parts))]]))]) + [=parts (monad\each meta_monad embedded_expansions parts)] + (in [(list\mix list\composite (list) (list\each left =parts)) + [ann (<tag> (list\each right =parts))]]))]) ([#Form] [#Tuple]) [ann (#Record kvs)] (do meta_monad - [=kvs (monad\map meta_monad - (function (_ [key val]) - (do meta_monad - [=key (embedded_expansions key) - =val (embedded_expansions val) - .let [[key_labels key_labelled] =key - [val_labels val_labelled] =val]] - (in [(list\compose key_labels val_labels) [key_labelled val_labelled]]))) - kvs)] - (in [(list\mix list\compose (list) (list\map left =kvs)) - [ann (#Record (list\map right =kvs))]])) + [=kvs (monad\each meta_monad + (function (_ [key val]) + (do meta_monad + [=key (embedded_expansions key) + =val (embedded_expansions val) + .let [[key_labels key_labelled] =key + [val_labels val_labelled] =val]] + (in [(list\composite key_labels val_labels) [key_labelled val_labelled]]))) + kvs)] + (in [(list\mix list\composite (list) (list\each left =kvs)) + [ann (#Record (list\each right =kvs))]])) _ (in_meta [(list) code]))) @@ -5994,8 +6059,8 @@ [=raw (..embedded_expansions raw) .let [[labels labelled] =raw]] (in (list (` (with_expansions [(~+ (|> labels - (list\map (function (_ [label expansion]) (list label expansion))) - list\joined))] + (list\each (function (_ [label expansion]) (list label expansion))) + list\conjoint))] (~ labelled)))))) _ @@ -6018,13 +6083,13 @@ (-> Code (-> Code (Meta Code)) (-> (List [Code Code]) (Meta Code))) (do meta_monad - [=fields (monad\map meta_monad - (function (_ [key value]) - (do meta_monad - [=key (untemplated_pattern key) - =value (untemplated_pattern value)] - (in (` [(~ =key) (~ =value)])))) - fields)] + [=fields (monad\each meta_monad + (function (_ [key value]) + (do meta_monad + [=key (untemplated_pattern key) + =value (untemplated_pattern value)] + (in (` [(~ =key) (~ =value)])))) + fields)] (in (` [(~ g!meta) (#.Record (~ (untemplated_list =fields)))])))) (template [<tag> <name>] @@ -6035,12 +6100,12 @@ (#Item [_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))] inits) (do meta_monad - [=inits (monad\map meta_monad untemplated_pattern (list\reversed inits))] + [=inits (monad\each meta_monad untemplated_pattern (list\reversed inits))] (in (` [(~ g!meta) (<tag> (~ (untemplated_list& spliced =inits)))]))) _ (do meta_monad - [=elems (monad\map meta_monad untemplated_pattern elems)] + [=elems (monad\each meta_monad untemplated_pattern elems)] (in (` [(~ g!meta) (<tag> (~ (untemplated_list =elems)))])))))] [#.Tuple untemplated_tuple] @@ -6073,8 +6138,8 @@ (^template [<tag> <untemplated>] [[_ (<tag> elems)] (<untemplated> g!meta untemplated_pattern elems)]) - ([#.Tuple ..untemplated_tuple] - [#.Form ..untemplated_form]) + ([#Tuple ..untemplated_tuple] + [#Form ..untemplated_form]) [_ (#Record fields)] (..untemplated_record g!meta untemplated_pattern fields) @@ -6122,9 +6187,9 @@ (if (multiple? 2 (list\size bindings)) (in_meta (list (` (..with_expansions [(~+ (|> bindings ..pairs - (list\map (function (_ [localT valueT]) - (list localT (` (..as_is (~ valueT)))))) - (list\mix list\compose (list))))] + (list\each (function (_ [localT valueT]) + (list localT (` (..as_is (~ valueT)))))) + (list\mix list\composite (list))))] (~ bodyT))))) (..failure ":let requires an even number of parts")) diff --git a/stdlib/source/library/lux/abstract/comonad.lux b/stdlib/source/library/lux/abstract/comonad.lux index 281dc7fc9..6de1b97d0 100644 --- a/stdlib/source/library/lux/abstract/comonad.lux +++ b/stdlib/source/library/lux/abstract/comonad.lux @@ -20,7 +20,7 @@ out) (: (All [a] (-> (w a) (w (w a)))) - split)) + disjoint)) (macro: .public (be tokens state) (case (: (Maybe [(Maybe Text) Code (List Code) Code]) @@ -39,11 +39,11 @@ identifier (: (-> Text Code) (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [location.dummy])) g!_ (identifier "_") - g!map (identifier "map") - g!split (identifier "split") + g!each (identifier "each") + g!disjoint (identifier "disjoint") body' (list\mix (: (-> [Code Code] Code Code) (function (_ binding body') - (with_expansions [<default> (` (|> (~ value) (~ g!split) ((~ g!map) (function ((~ g!_) (~ var)) (~ body')))))] + (with_expansions [<default> (` (|> (~ value) (~ g!disjoint) ((~ g!each) (function ((~ g!_) (~ var)) (~ body')))))] (let [[var value] binding] (case var [_ (#.Identifier ["" _])] @@ -60,13 +60,13 @@ (#.Some name) (let [name [location.dummy (#.Identifier ["" name])]] (` ({(~ name) - ({[(~ g!map) (~' out) (~ g!split)] + ({[(~ g!each) (~' out) (~ g!disjoint)] (~ body')} (~ name))} (~ comonad)))) #.None - (` ({[(~ g!map) (~' out) (~ g!split)] + (` ({[(~ g!each) (~' out) (~ g!disjoint)] (~ body')} (~ comonad)))))])) (#.Left "'be' bindings must have an even number of parts.")) diff --git a/stdlib/source/library/lux/abstract/comonad/cofree.lux b/stdlib/source/library/lux/abstract/comonad/cofree.lux index c5d61dbb4..e7d9cea7f 100644 --- a/stdlib/source/library/lux/abstract/comonad/cofree.lux +++ b/stdlib/source/library/lux/abstract/comonad/cofree.lux @@ -11,8 +11,8 @@ (implementation: .public (functor dsl) (All [F] (-> (Functor F) (Functor (CoFree F)))) - (def: (map f [head tail]) - [(f head) (\ dsl map (map f) tail)])) + (def: (each f [head tail]) + [(f head) (\ dsl each (each f) tail)])) (implementation: .public (comonad dsl) (All [F] (-> (Functor F) (CoMonad (CoFree F)))) @@ -22,6 +22,6 @@ (def: (out [head tail]) head) - (def: (split [head tail]) + (def: (disjoint [head tail]) [[head tail] - (\ dsl map split tail)])) + (\ dsl each disjoint tail)])) diff --git a/stdlib/source/library/lux/abstract/equivalence.lux b/stdlib/source/library/lux/abstract/equivalence.lux index 43598f09e..69f90bb06 100644 --- a/stdlib/source/library/lux/abstract/equivalence.lux +++ b/stdlib/source/library/lux/abstract/equivalence.lux @@ -18,7 +18,7 @@ (implementation: .public functor (contravariant.Functor Equivalence) - (def: (map f equivalence) + (def: (each f equivalence) (implementation (def: (= reference sample) (\ equivalence = (f reference) (f sample)))))) diff --git a/stdlib/source/library/lux/abstract/functor.lux b/stdlib/source/library/lux/abstract/functor.lux index 6f7053018..28e90dbb0 100644 --- a/stdlib/source/library/lux/abstract/functor.lux +++ b/stdlib/source/library/lux/abstract/functor.lux @@ -6,7 +6,7 @@ (: (All [a b] (-> (-> a b) (-> (f a) (f b)))) - map)) + each)) (type: .public (Fix f) (f (Fix f))) @@ -17,13 +17,13 @@ (def: .public (sum (^open "f\.") (^open "g\.")) (All [F G] (-> (Functor F) (Functor G) (Functor (..Or F G)))) (implementation - (def: (map f fa|ga) + (def: (each f fa|ga) (case fa|ga (#.Left fa) - (#.Left (f\map f fa)) + (#.Left (f\each f fa)) (#.Right ga) - (#.Right (g\map f ga)))))) + (#.Right (g\each f ga)))))) (type: .public (And f g) (All [a] (.And (f a) (g a)))) @@ -31,9 +31,9 @@ (def: .public (product (^open "f\.") (^open "g\.")) (All [F G] (-> (Functor F) (Functor G) (Functor (..And F G)))) (implementation - (def: (map f [fa ga]) - [(f\map f fa) - (g\map f ga)]))) + (def: (each f [fa ga]) + [(f\each f fa) + (g\each f ga)]))) (type: .public (Then f g) (All [a] (f (g a)))) @@ -41,5 +41,5 @@ (def: .public (composite (^open "f\.") (^open "g\.")) (All [F G] (-> (Functor F) (Functor G) (Functor (..Then F G)))) (implementation - (def: (map f fga) - (f\map (g\map f) fga)))) + (def: (each f fga) + (f\each (g\each f) fga)))) diff --git a/stdlib/source/library/lux/abstract/functor/contravariant.lux b/stdlib/source/library/lux/abstract/functor/contravariant.lux index 9c5fe673a..ac35b9360 100644 --- a/stdlib/source/library/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/library/lux/abstract/functor/contravariant.lux @@ -6,4 +6,4 @@ (: (All [a b] (-> (-> b a) (-> (f a) (f b)))) - map)) + each)) diff --git a/stdlib/source/library/lux/abstract/hash.lux b/stdlib/source/library/lux/abstract/hash.lux index 3180691f3..48816744a 100644 --- a/stdlib/source/library/lux/abstract/hash.lux +++ b/stdlib/source/library/lux/abstract/hash.lux @@ -15,10 +15,10 @@ (implementation: .public functor (contravariant.Functor Hash) - (def: (map f super) + (def: (each f super) (implementation (def: &equivalence - (\ equivalence.functor map f + (\ equivalence.functor each f (\ super &equivalence))) (def: hash diff --git a/stdlib/source/library/lux/abstract/mix.lux b/stdlib/source/library/lux/abstract/mix.lux index 0788f38d0..07bddfec0 100644 --- a/stdlib/source/library/lux/abstract/mix.lux +++ b/stdlib/source/library/lux/abstract/mix.lux @@ -13,4 +13,4 @@ (All [F a] (-> (Monoid a) (Mix F) (F a) a)) (let [(^open "/\.") monoid] - (mix /\compose /\identity value))) + (mix /\composite /\identity value))) diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index 85159e505..4a1abdc82 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -51,7 +51,7 @@ in) (: (All [a] (-> (m (m a)) (m a))) - join)) + conjoint)) (macro: .public (do tokens state) (case (: (Maybe [(Maybe Text) Code (List Code) Code]) @@ -70,11 +70,11 @@ identifier (: (-> Text Code) (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [location.dummy])) g!_ (identifier "_") - g!map (identifier "map") - g!join (identifier "join") + g!each (identifier "each") + g!conjoint (identifier "conjoint") body' (list\mix (: (-> [Code Code] Code Code) (function (_ binding body') - (with_expansions [<default> (` (|> (~ value) ((~ g!map) (function ((~ g!_) (~ var)) (~ body'))) (~ g!join)))] + (with_expansions [<default> (` (|> (~ value) ((~ g!each) (function ((~ g!_) (~ var)) (~ body'))) (~ g!conjoint)))] (let [[var value] binding] (case var [_ (#.Identifier ["" _])] @@ -91,13 +91,13 @@ (#.Some name) (let [name [location.dummy (#.Identifier ["" name])]] (` ({(~ name) - ({[(~ g!map) (~' in) (~ g!join)] + ({[(~ g!each) (~' in) (~ g!conjoint)] (~ body')} (~ name))} (~ monad)))) #.None - (` ({[(~ g!map) (~' in) (~ g!join)] + (` ({[(~ g!each) (~' in) (~ g!conjoint)] (~ body')} (~ monad)))))])) (#.Left "'do' bindings must have an even number of parts.")) @@ -109,8 +109,8 @@ (All [! a b] (-> (Monad !) (-> a (! b)) (-> (! a) (! b)))) - (|>> (\ monad map f) - (\ monad join))) + (|>> (\ monad each f) + (\ monad conjoint))) (def: .public (all monad) (All [! a] @@ -124,11 +124,11 @@ (#.Item x xs') (|> x - (!\map (function (_ _x) - (!\map (|>> (#.Item _x)) (recur xs')))) - !\join))))) + (!\each (function (_ _x) + (!\each (|>> (#.Item _x)) (recur xs')))) + !\conjoint))))) -(def: .public (map monad f) +(def: .public (each monad f) (All [M a b] (-> (Monad M) (-> a (M b)) (List a) (M (List b)))) @@ -140,9 +140,9 @@ (#.Item x xs') (|> (f x) - (!\map (function (_ _x) - (!\map (|>> (#.Item _x)) (recur xs')))) - !\join))))) + (!\each (function (_ _x) + (!\each (|>> (#.Item _x)) (recur xs')))) + !\conjoint))))) (def: .public (only monad f) (All [! a b] @@ -156,13 +156,13 @@ (#.Item head xs') (|> (f head) - (!\map (function (_ verdict) - (!\map (function (_ tail) - (if verdict - (#.Item head tail) - tail)) - (recur xs')))) - !\join))))) + (!\each (function (_ verdict) + (!\each (function (_ tail) + (if verdict + (#.Item head tail) + tail)) + (recur xs')))) + !\conjoint))))) (def: .public (mix monad f init xs) (All [M a b] diff --git a/stdlib/source/library/lux/abstract/monad/free.lux b/stdlib/source/library/lux/abstract/monad/free.lux index 82b405ccc..101a23d87 100644 --- a/stdlib/source/library/lux/abstract/monad/free.lux +++ b/stdlib/source/library/lux/abstract/monad/free.lux @@ -7,19 +7,20 @@ [monad (#+ Monad)]]) (type: .public (Free F a) - (#Pure a) - (#Effect (F (Free F a)))) + (Variant + (#Pure a) + (#Effect (F (Free F a))))) (implementation: .public (functor dsl) (All [F] (-> (Functor F) (Functor (Free F)))) - (def: (map f ea) + (def: (each f ea) (case ea (#Pure a) (#Pure (f a)) (#Effect value) - (#Effect (\ dsl map (map f) value))))) + (#Effect (\ dsl each (each f) value))))) (implementation: .public (apply dsl) (All [F] (-> (Functor F) (Apply (Free F)))) @@ -33,12 +34,12 @@ (#Pure (f a)) [(#Pure f) (#Effect fa)] - (#Effect (\ dsl map - (\ (..functor dsl) map f) + (#Effect (\ dsl each + (\ (..functor dsl) each f) fa)) [(#Effect ff) _] - (#Effect (\ dsl map (on ea) ff)) + (#Effect (\ dsl each (on ea) ff)) ))) (implementation: .public (monad dsl) @@ -49,7 +50,7 @@ (def: (in a) (#Pure a)) - (def: (join efefa) + (def: (conjoint efefa) (case efefa (#Pure efa) (case efa @@ -60,7 +61,7 @@ (#Effect fa)) (#Effect fefa) - (#Effect (\ dsl map - (\ (monad dsl) join) + (#Effect (\ dsl each + (\ (monad dsl) conjoint) fefa)) ))) diff --git a/stdlib/source/library/lux/abstract/monad/indexed.lux b/stdlib/source/library/lux/abstract/monad/indexed.lux index f255f9727..ad06165f3 100644 --- a/stdlib/source/library/lux/abstract/monad/indexed.lux +++ b/stdlib/source/library/lux/abstract/monad/indexed.lux @@ -31,8 +31,9 @@ (<>.and <code>.any <code>.any)) (type: Context - (#Macro Name Code) - (#Binding Binding)) + (Variant + (#Macro Name Code) + (#Binding Binding))) (def: global_identifier (Parser Name) @@ -53,10 +54,10 @@ (def: named_monad (Parser [(Maybe Text) Code]) - (<>.either (<code>.record (<>.and (\ <>.monad map (|>> #.Some) + (<>.either (<code>.record (<>.and (\ <>.monad each (|>> #.Some) <code>.local_identifier) <code>.any)) - (\ <>.monad map (|>> [#.None]) + (\ <>.monad each (|>> [#.None]) <code>.any))) (syntax: .public (do [[?name monad] ..named_monad diff --git a/stdlib/source/library/lux/abstract/monoid.lux b/stdlib/source/library/lux/abstract/monoid.lux index 01dacde2e..6e8aff164 100644 --- a/stdlib/source/library/lux/abstract/monoid.lux +++ b/stdlib/source/library/lux/abstract/monoid.lux @@ -6,7 +6,7 @@ (: a identity) (: (-> a a a) - compose)) + composite)) (def: .public (and left right) (All [l r] (-> (Monoid l) (Monoid r) (Monoid [l r]))) @@ -14,6 +14,6 @@ (def: identity [(\ left identity) (\ right identity)]) - (def: (compose [lL rL] [lR rR]) - [(\ left compose lL lR) - (\ right compose rL rR)]))) + (def: (composite [lL rL] [lR rR]) + [(\ left composite lL lR) + (\ right composite rL rR)]))) diff --git a/stdlib/source/library/lux/abstract/order.lux b/stdlib/source/library/lux/abstract/order.lux index 279c3beb0..7f055199a 100644 --- a/stdlib/source/library/lux/abstract/order.lux +++ b/stdlib/source/library/lux/abstract/order.lux @@ -47,10 +47,10 @@ (implementation: .public functor (contravariant.Functor Order) - (def: (map f order) + (def: (each f order) (implementation (def: &equivalence - (\ equivalence.functor map f (\ order &equivalence))) + (\ equivalence.functor each f (\ order &equivalence))) (def: (< reference sample) (\ order < (f reference) (f sample)))))) diff --git a/stdlib/source/library/lux/abstract/predicate.lux b/stdlib/source/library/lux/abstract/predicate.lux index 20101f7a9..5c5cde91b 100644 --- a/stdlib/source/library/lux/abstract/predicate.lux +++ b/stdlib/source/library/lux/abstract/predicate.lux @@ -31,7 +31,7 @@ (All [a] (Monoid (Predicate a))) (def: identity <identity>) - (def: compose <composition>))] + (def: composite <composition>))] [union ..none ..or] [intersection ..all ..and] @@ -57,5 +57,5 @@ (implementation: .public functor (contravariant.Functor Predicate) - (def: (map f fb) + (def: (each f fb) (|>> f fb))) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index de474236a..9cc286c29 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -30,8 +30,9 @@ [Text Code]) (type: Stack - {#bottom (Maybe Nat) - #top (List Code)}) + (Record + {#bottom (Maybe Nat) + #top (List Code)})) (def: aliases^ (Parser (List Alias)) @@ -48,7 +49,7 @@ (Parser Stack) (<>.either (<>.and (<>.maybe bottom^) (<code>.tuple (<>.some <code>.any))) - (<>.and (|> bottom^ (<>\map (|>> #.Some))) + (<>.and (|> bottom^ (<>\each (|>> #.Some))) (<>\in (list))))) (def: (stack_mix tops bottom) @@ -68,7 +69,7 @@ _ (meta.failure (format "Cannot expand to more than a single AST/Code node:" text.new_line - (|> expansion (list\map %.code) (text.interposed " "))))))) + (|> expansion (list\each %.code) (text.interposed " "))))))) (syntax: .public (=> [aliases aliases^ inputs stack^ @@ -78,8 +79,8 @@ (code.replaced (code.local_identifier from) to pre)) aliased aliases))] - (case [(|> inputs (value@ #bottom) (maybe\map (|>> code.nat (~) #.Parameter (`)))) - (|> outputs (value@ #bottom) (maybe\map (|>> code.nat (~) #.Parameter (`))))] + (case [(|> inputs (value@ #bottom) (maybe\each (|>> code.nat (~) #.Parameter (`)))) + (|> outputs (value@ #bottom) (maybe\each (|>> code.nat (~) #.Parameter (`))))] [(#.Some bottomI) (#.Some bottomO)] (monad.do meta.monad [inputC (singleton (macro.full_expansion (stack_mix (value@ #top inputs) bottomI))) diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index 0e248ff9b..f7f5644d3 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -56,7 +56,7 @@ [current (async.value read)] (case current (#.Some [head tail]) - (\ ! map (|>> (#.Item head)) + (\ ! each (|>> (#.Item head)) (pending tail)) #.None @@ -65,9 +65,10 @@ (abstract: .public (Actor s) {} - {#obituary [(Async <Obituary>) - (Resolver <Obituary>)] - #mailbox (Atom <Mailbox>)} + (Record + {#obituary [(Async <Obituary>) + (Resolver <Obituary>)] + #mailbox (Atom <Mailbox>)}) (type: .public (Mail s) <Mail>) @@ -76,8 +77,9 @@ <Obituary>) (type: .public (Behavior o s) - {#on_init (-> o s) - #on_mail (-> (Mail s) s (Actor s) (Async (Try s)))}) + (Record + {#on_init (-> o s) + #on_mail (-> (Mail s) s (Actor s) (Async (Try s)))})) (def: .public (spawn! behavior init) (All [o s] (-> (Behavior o s) o (IO (Actor s)))) @@ -112,7 +114,7 @@ (let [[obituary _] (value@ #obituary (:representation actor))] (|> obituary async.value - (\ io.functor map + (\ io.functor each (|>> (case> #.None bit.yes @@ -263,7 +265,7 @@ (do meta.monad [g!type (macro.identifier (format name "_abstract_type")) .let [g!actor (code.local_identifier name) - g!vars (list\map code.local_identifier vars)]] + g!vars (list\each code.local_identifier vars)]] (in (list (` ((~! abstract:) (~ export_policy) ((~ g!type) (~+ g!vars)) {} @@ -288,11 +290,12 @@ (~ init))))))))) (type: Signature - {#vars (List Text) - #name Text - #inputs (List |input|.Input) - #state Text - #self Text}) + (Record + {#vars (List Text) + #name Text + #inputs (List |input|.Input) + #state Text + #self Text})) (def: signature^ (Parser Signature) @@ -326,9 +329,9 @@ .let [g!type (code.local_identifier (value@ #abstract.name actor_scope)) g!message (code.local_identifier (value@ #name signature)) g!actor_vars (value@ #abstract.type_vars actor_scope) - g!all_vars (|> signature (value@ #vars) (list\map code.local_identifier) (list\compose g!actor_vars)) - g!inputsC (|> signature (value@ #inputs) (list\map product.left)) - g!inputsT (|> signature (value@ #inputs) (list\map product.right)) + g!all_vars (|> signature (value@ #vars) (list\each code.local_identifier) (list\composite g!actor_vars)) + g!inputsC (|> signature (value@ #inputs) (list\each product.left)) + g!inputsT (|> signature (value@ #inputs) (list\each product.right)) g!state (|> signature (value@ #state) code.local_identifier) g!self (|> signature (value@ #self) code.local_identifier)]] (in (list (` (def: (~ export_policy) ((~ g!message) (~+ g!inputsC)) @@ -365,6 +368,6 @@ (if continue? (|> actor (..mail! (action event stop)) - (\ ! map try.maybe)) + (\ ! each try.maybe)) (in #.None)))) channel))) diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index bdd852ffc..c996e1dcc 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -42,8 +42,8 @@ succeeded? (atom.compare_and_swap! old new async)] (if succeeded? (do ! - [_ (monad.map ! (function (_ f) (f value)) - _observers)] + [_ (monad.each ! (function (_ f) (f value)) + _observers)] (in #1)) (resolve value)))))))) @@ -60,7 +60,7 @@ (All [a] (-> (Async a) (IO (Maybe a)))) (|>> :representation atom.read! - (\ io.functor map product.left))) + (\ io.functor each product.left))) (def: .public (upon! f async) (All [a] (-> (-> a (IO Any)) (Async a) (IO Any))) @@ -83,7 +83,7 @@ (def: .public resolved? (All [a] (-> (Async a) (IO Bit))) (|>> ..value - (\ io.functor map + (\ io.functor each (|>> (case> #.None #0 @@ -93,7 +93,7 @@ (implementation: .public functor (Functor Async) - (def: (map f fa) + (def: (each f fa) (let [[fb resolve] (..async [])] (exec (io.run! (..upon! (|>> f resolve) fa)) @@ -119,7 +119,7 @@ (def: in ..resolved) - (def: (join mma) + (def: (conjoint mma) (let [[ma resolve] (async [])] (exec (io.run! (..upon! (..upon! resolve) mma)) diff --git a/stdlib/source/library/lux/control/concurrency/atom.lux b/stdlib/source/library/lux/control/concurrency/atom.lux index b6d9461f0..5be4a9059 100644 --- a/stdlib/source/library/lux/control/concurrency/atom.lux +++ b/stdlib/source/library/lux/control/concurrency/atom.lux @@ -95,4 +95,4 @@ (All [a] (-> a (Atom a) (IO a))) (|> atom (..update! (function.constant value)) - (io\map product.left))) + (io\each product.left))) diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index 1e447ef17..df0ef8160 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -85,11 +85,11 @@ (implementation: .public functor (Functor Channel) - (def: (map f) - (async\map - (maybe\map + (def: (each f) + (async\each + (maybe\each (function (_ [head tail]) - [(f head) (map f tail)]))))) + [(f head) (each f tail)]))))) (implementation: .public apply (Apply Channel) @@ -119,7 +119,7 @@ (def: (in a) (async.resolved (#.Some [a ..empty]))) - (def: (join mma) + (def: (conjoint mma) (let [[output sink] (channel [])] (exec (: (Async Any) @@ -185,9 +185,9 @@ (def: .public (of_async async) (All [a] (-> (Async a) (Channel a))) - (async\map (function (_ value) - (#.Some [value ..empty])) - async)) + (async\each (function (_ value) + (#.Some [value ..empty])) + async)) (def: .public (mix f init channel) (All [a b] @@ -276,7 +276,7 @@ [item channel] (case item (#.Some [head tail]) - (\ ! map (|>> (#.Item head)) + (\ ! each (|>> (#.Item head)) (list tail)) #.None diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index e2cdb2aca..8f2378d3d 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -25,9 +25,10 @@ ["." async (#+ Async Resolver)]]) (type: State - {#max_positions Nat - #open_positions Int - #waiting_list (Queue (Resolver Any))}) + (Record + {#max_positions Nat + #open_positions Int + #waiting_list (Queue (Resolver Any))})) (abstract: .public Semaphore {} @@ -130,10 +131,11 @@ (abstract: .public Barrier {} - {#limit Limit - #count (Atom Nat) - #start_turnstile Semaphore - #end_turnstile Semaphore} + (Record + {#limit Limit + #count (Atom Nat) + #start_turnstile Semaphore + #end_turnstile Semaphore}) (def: .public (barrier limit) (-> Limit Barrier) diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux index 5e9759bdb..cb6a1e702 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -52,16 +52,16 @@ succeeded? (atom.compare_and_swap! old [new_value observers] var')] (if succeeded? (do ! - [_ (monad.map ! (function (_ sink) - (do ! - [result (\ sink feed new_value)] - (case result - (#try.Success _) - (in []) - - (#try.Failure _) - (un_follow! sink var)))) - observers)] + [_ (monad.each ! (function (_ sink) + (do ! + [result (\ sink feed new_value)] + (case result + (#try.Success _) + (in []) + + (#try.Failure _) + (un_follow! sink var)))) + observers)] (in [])) (write! new_value var)))) @@ -76,9 +76,10 @@ ) (type: (Tx_Frame a) - {#var (Var a) - #original a - #current a}) + (Record + {#var (Var a) + #original a + #current a})) (type: Tx (List (Ex [a] (Tx_Frame a)))) @@ -92,8 +93,8 @@ (list.example (function (_ [_var _original _current]) (same? (:as (Var Any) var) (:as (Var Any) _var)))) - (\ maybe.monad map (function (_ [_var _original _current]) - _current)) + (\ maybe.monad each (function (_ [_var _original _current]) + _current)) :expected)) (def: .public (read var) @@ -141,7 +142,7 @@ (implementation: .public functor (Functor STM) - (def: (map f fa) + (def: (each f fa) (function (_ tx) (let [[tx' a] (fa tx)] [tx' (f a)])))) @@ -166,7 +167,7 @@ (function (_ tx) [tx a])) - (def: (join mma) + (def: (conjoint mma) (function (_ tx) (let [[tx' ma] (mma tx)] (ma tx'))))) @@ -233,7 +234,7 @@ [finished_tx value] (stm_proc fresh_tx)] (if (can_commit? finished_tx) (do {! io.monad} - [_ (monad.map ! ..commit_var! finished_tx)] + [_ (monad.each ! ..commit_var! finished_tx)] (resolve value)) (..issue_commit! commit)))) diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index 1011da5bb..d618d7270 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -59,9 +59,10 @@ ... Default (type: Thread - {#creation Nat - #delay Nat - #action (IO Any)}) + (Record + {#creation Nat + #delay Nat + #action (IO Any)})) )) (def: .public parallelism @@ -127,7 +128,7 @@ ... Default (do {! io.monad} - [now (\ ! map (|>> instant.millis .nat) instant.now) + [now (\ ! each (|>> instant.millis .nat) instant.now) _ (atom.update! (|>> (#.Item {#creation now #delay milli_seconds #action action})) @@ -156,7 +157,7 @@ _ (do ! - [now (\ ! map (|>> instant.millis .nat) instant.now) + [now (\ ! each (|>> instant.millis .nat) instant.now) .let [[ready pending] (list.partition (function (_ thread) (|> (value@ #creation thread) (n.+ (value@ #delay thread)) @@ -165,7 +166,7 @@ swapped? (atom.compare_and_swap! threads pending ..runner)] (if swapped? (do ! - [_ (monad.map ! (|>> (value@ #action) ..execute! io.io) ready)] + [_ (monad.each ! (|>> (value@ #action) ..execute! io.io) ready)] (recur [])) (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 15fdc16d1..f56d127c7 100644 --- a/stdlib/source/library/lux/control/continuation.lux +++ b/stdlib/source/library/lux/control/continuation.lux @@ -54,7 +54,7 @@ (implementation: .public functor (All [o] (Functor (All [i] (Cont i o)))) - (def: (map f fv) + (def: (each f fv) (function (_ k) (fv (function.composite k f))))) @@ -77,7 +77,7 @@ (def: (in value) (function (_ k) (k value))) - (def: (join ffa) + (def: (conjoint ffa) (function (_ k) (ffa (continued k))))) diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index c59767584..cf00522fa 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -27,8 +27,9 @@ ["//" try (#+ Try)]]) (type: .public (Exception a) - {#label Text - #constructor (-> a Text)}) + (Record + {#label Text + #constructor (-> a Text)})) (def: .public (match? exception error) (All [e] (-> (Exception e) Text Bit)) @@ -93,16 +94,16 @@ (macro.with_identifiers [g!descriptor] (do meta.monad [current_module meta.current_module_name - .let [descriptor ($_ text\compose "{" current_module "." name "}" text.new_line) + .let [descriptor ($_ text\composite "{" current_module "." name "}" text.new_line) g!self (code.local_identifier name)]] (in (list (` (def: (~ export_policy) (~ g!self) - (All [(~+ (list\map |type_variable|.format t_vars))] - (..Exception [(~+ (list\map (value@ #|input|.type) inputs))])) + (All [(~+ (list\each |type_variable|.format t_vars))] + (..Exception [(~+ (list\each (value@ #|input|.type) inputs))])) (let [(~ g!descriptor) (~ (code.text descriptor))] {#..label (~ g!descriptor) - #..constructor (function ((~ g!self) [(~+ (list\map (value@ #|input|.binding) inputs))]) - ((~! text\compose) (~ g!descriptor) + #..constructor (function ((~ g!self) [(~+ (list\each (value@ #|input|.binding) inputs))]) + ((~! text\composite) (~ g!descriptor) (~ (maybe.else (' "") body))))})))))))) (def: (report' entries) @@ -116,7 +117,7 @@ (list.repeated (n.+ (text.size header_separator) largest_header_size)) text.together - (text\compose text.new_line)) + (text\composite text.new_line)) on_entry (: (-> [Text Text] Text) (function (_ [header message]) (let [padding (|> " " @@ -125,21 +126,21 @@ text.together)] (|> message (text.replaced text.new_line on_new_line) - ($_ text\compose padding header header_separator)))))] + ($_ text\composite padding header header_separator)))))] (case entries #.End "" (#.Item head tail) (list\mix (function (_ post pre) - ($_ text\compose pre text.new_line (on_entry post))) + ($_ text\composite pre text.new_line (on_entry post))) (on_entry head) tail)))) (syntax: .public (report [entries (<>.many (<code>.tuple (<>.and <code>.any <code>.any)))]) (in (list (` ((~! report') (list (~+ (|> entries - (list\map (function (_ [header message]) - (` [(~ header) (~ message)]))))))))))) + (list\each (function (_ [header message]) + (` [(~ header) (~ message)]))))))))))) (def: .public (listing format entries) (All [a] diff --git a/stdlib/source/library/lux/control/function.lux b/stdlib/source/library/lux/control/function.lux index 11cc82e62..3bbcd1bce 100644 --- a/stdlib/source/library/lux/control/function.lux +++ b/stdlib/source/library/lux/control/function.lux @@ -31,4 +31,4 @@ (All [a] (Monoid (-> a a))) (def: identity ..identity) - (def: compose ..composite)) + (def: composite ..composite)) diff --git a/stdlib/source/library/lux/control/function/mixin.lux b/stdlib/source/library/lux/control/function/mixin.lux index 98009b21d..4f5013f77 100644 --- a/stdlib/source/library/lux/control/function/mixin.lux +++ b/stdlib/source/library/lux/control/function/mixin.lux @@ -31,7 +31,7 @@ (All [i o] (Monoid (Mixin i o))) (def: identity ..nothing) - (def: compose ..with)) + (def: composite ..with)) (def: .public (advice when then) (All [i o] (-> (Predicate i) (Mixin i o) (Mixin i o))) diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index dd647ce41..3d26dedd1 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -25,9 +25,10 @@ ["." //]) (type: Mutual - {#declaration Declaration - #type Code - #body Code}) + (Record + {#declaration Declaration + #type Code + #body Code})) (.def: mutual (Parser [Declaration Code Code]) @@ -68,35 +69,36 @@ (macro.with_identifiers [g!context g!output] (do {! meta.monad} [here_name meta.current_module_name - 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 - functions)) - context_types (list\map (function (_ mutual) - (` (-> (~ g!context) (~ (value@ #type mutual))))) - functions) - user_names (list\map (|>> (value@ [#declaration #declaration.name]) code.local_identifier) - functions)] - g!pop (local.push (list\map (function (_ [g!name mutual]) - [[here_name (value@ [#declaration #declaration.name] mutual)] - (..macro g!context g!name)]) - (list.zipped/2 hidden_names - functions)))] + hidden_names (monad.each ! (//.constant (macro.identifier "mutual_function#")) + functions) + .let [definitions (list\each (..mutual_definition hidden_names g!context) + (list.zipped/2 hidden_names + functions)) + context_types (list\each (function (_ mutual) + (` (-> (~ g!context) (~ (value@ #type mutual))))) + functions) + user_names (list\each (|>> (value@ [#declaration #declaration.name]) code.local_identifier) + functions)] + g!pop (local.push (list\each (function (_ [g!name mutual]) + [[here_name (value@ [#declaration #declaration.name] mutual)] + (..macro g!context g!name)]) + (list.zipped/2 hidden_names + functions)))] (in (list (` (.let [(~ g!context) (: (Rec (~ g!context) [(~+ context_types)]) [(~+ definitions)]) [(~+ user_names)] (.let [[(~+ user_names)] (~ g!context)] - [(~+ (list\map (function (_ g!name) - (` ((~ g!name) (~ g!context)))) - user_names))]) + [(~+ (list\each (function (_ g!name) + (` ((~ g!name) (~ g!context)))) + user_names))]) (~ g!output) (~ body)] (exec (~ g!pop) (~ g!output)))))))))) (type: Definition - {#export_policy Code - #mutual Mutual}) + (Record + {#export_policy Code + #mutual Mutual})) (.def: definition (Parser Definition) @@ -119,37 +121,37 @@ (macro.with_identifiers [g!context g!output] (do {! meta.monad} [here_name meta.current_module_name - 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 - (list\map (value@ #mutual) functions))) - context_types (list\map (function (_ mutual) - (` (-> (~ g!context) (~ (value@ [#mutual #type] mutual))))) - functions) - user_names (list\map (|>> (value@ [#mutual #declaration #declaration.name]) code.local_identifier) - functions)] - g!pop (local.push (list\map (function (_ [g!name mutual]) - [[here_name (value@ [#mutual #declaration #declaration.name] mutual)] - (..macro g!context g!name)]) - (list.zipped/2 hidden_names - functions)))] + hidden_names (monad.each ! (//.constant (macro.identifier "mutual_function#")) + functions) + .let [definitions (list\each (..mutual_definition hidden_names g!context) + (list.zipped/2 hidden_names + (list\each (value@ #mutual) functions))) + context_types (list\each (function (_ mutual) + (` (-> (~ g!context) (~ (value@ [#mutual #type] mutual))))) + functions) + user_names (list\each (|>> (value@ [#mutual #declaration #declaration.name]) code.local_identifier) + functions)] + g!pop (local.push (list\each (function (_ [g!name mutual]) + [[here_name (value@ [#mutual #declaration #declaration.name] mutual)] + (..macro g!context g!name)]) + (list.zipped/2 hidden_names + functions)))] (in (list& (` (.def: (~ g!context) - [(~+ (list\map (value@ [#mutual #type]) functions))] + [(~+ (list\each (value@ [#mutual #type]) functions))] (.let [(~ g!context) (: (Rec (~ g!context) [(~+ context_types)]) [(~+ definitions)]) [(~+ user_names)] (~ g!context)] - [(~+ (list\map (function (_ g!name) - (` ((~ g!name) (~ g!context)))) - user_names))]))) + [(~+ (list\each (function (_ g!name) + (` ((~ g!name) (~ g!context)))) + user_names))]))) g!pop - (list\map (function (_ mutual) - (.let [g!name (|> mutual (value@ [#mutual #declaration #declaration.name]) code.local_identifier)] - (` (.def: - (~ (value@ #export_policy mutual)) - (~ g!name) - (~ (value@ [#mutual #type] mutual)) - (.let [[(~+ user_names)] (~ g!context)] - (~ g!name)))))) - functions))))))) + (list\each (function (_ mutual) + (.let [g!name (|> mutual (value@ [#mutual #declaration #declaration.name]) code.local_identifier)] + (` (.def: + (~ (value@ #export_policy mutual)) + (~ g!name) + (~ (value@ [#mutual #type] mutual)) + (.let [[(~+ user_names)] (~ g!context)] + (~ g!name)))))) + functions))))))) diff --git a/stdlib/source/library/lux/control/io.lux b/stdlib/source/library/lux/control/io.lux index 4666dfb8a..4f051e604 100644 --- a/stdlib/source/library/lux/control/io.lux +++ b/stdlib/source/library/lux/control/io.lux @@ -44,7 +44,7 @@ (implementation: .public functor (Functor IO) - (def: (map f) + (def: (each f) (|>> run!' f !io))) (implementation: .public apply @@ -60,7 +60,9 @@ (def: &functor ..functor) - (def: in (|>> !io)) + (def: in + (|>> !io)) - (def: join (|>> run!' run!' !io))) + (def: conjoint + (|>> run!' run!' !io))) ) diff --git a/stdlib/source/library/lux/control/lazy.lux b/stdlib/source/library/lux/control/lazy.lux index 58cf7a526..e12de5bb9 100644 --- a/stdlib/source/library/lux/control/lazy.lux +++ b/stdlib/source/library/lux/control/lazy.lux @@ -54,7 +54,7 @@ (implementation: .public functor (Functor Lazy) - (def: (map f fa) + (def: (each f fa) (lazy (f (value fa))))) (implementation: .public apply @@ -69,4 +69,4 @@ (def: &functor ..functor) (def: in (|>> lazy)) - (def: join value)) + (def: conjoint ..value)) diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 854ef0402..6fbc4b294 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -20,7 +20,7 @@ (def: identity #.None) - (def: (compose mx my) + (def: (composite mx my) (case mx #.None my @@ -31,7 +31,7 @@ (implementation: .public functor (Functor Maybe) - (def: (map f ma) + (def: (each f ma) (case ma #.None #.None (#.Some a) (#.Some (f a))))) @@ -57,7 +57,7 @@ (def: (in x) (#.Some x)) - (def: (join mma) + (def: (conjoint mma) (case mma #.None #.None @@ -102,7 +102,7 @@ (def: in (|>> (\ ..monad in) (\ monad in))) - (def: (join MmMma) + (def: (conjoint MmMma) (do monad [mMma MmMma] (case mMma @@ -114,7 +114,7 @@ (def: .public (lifted monad) (All [M a] (-> (Monad M) (-> (M a) (M (Maybe a))))) - (\ monad map (\ ..monad in))) + (\ monad each (\ ..monad in))) (macro: .public (else tokens state) (case tokens diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index 30c728cd2..4d32c8df6 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -22,7 +22,7 @@ (implementation: .public functor (All [s] (Functor (Parser s))) - (def: (map f ma) + (def: (each f ma) (function (_ input) (case (ma input) (#try.Failure msg) @@ -59,7 +59,7 @@ (function (_ input) (#try.Success [input x]))) - (def: (join mma) + (def: (conjoint mma) (function (_ input) (case (mma input) (#try.Failure msg) @@ -96,7 +96,7 @@ (-> (Parser s a) (Parser s b) (Parser s [a b]))) (do {! ..monad} [head first] - (\ ! map (|>> [head]) second))) + (\ ! each (|>> [head]) second))) (def: .public (or left right) (All [s a b] @@ -134,7 +134,7 @@ (#try.Success [input (list)]) (#try.Success [input' head]) - (..result (\ ..monad map (|>> (list& head)) + (..result (\ ..monad each (|>> (list& head)) (some parser)) input')))) @@ -143,7 +143,7 @@ (-> (Parser s a) (Parser s (List a)))) (|> (..some parser) (..and parser) - (\ ..monad map (|>> #.Item)))) + (\ ..monad each (|>> #.Item)))) (def: .public (exactly amount parser) (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) @@ -153,13 +153,13 @@ [x parser] (|> parser (exactly (-- amount)) - (\ ! map (|>> (#.Item x))))))) + (\ ! each (|>> (#.Item x))))))) (def: .public (at_least amount parser) (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) (do {! ..monad} [minimum (..exactly amount parser)] - (\ ! map (list\compose minimum) (..some parser)))) + (\ ! each (list\composite minimum) (..some parser)))) (def: .public (at_most amount parser) (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) @@ -171,7 +171,7 @@ (#try.Success [input (list)]) (#try.Success [input' x]) - (..result (\ ..monad map (|>> (#.Item x)) + (..result (\ ..monad each (|>> (#.Item x)) (at_most (-- amount) parser)) input'))))) @@ -181,7 +181,7 @@ [minimum (..exactly minimum parser)] (case additional 0 (in minimum) - _ (\ ! map (list\compose minimum) + _ (\ ! each (list\composite minimum) (..at_most additional parser))))) (def: .public (separated_by separator parser) @@ -196,7 +196,7 @@ (|> parser (..and separator) ..some - (\ ! map (|>> (list\map product.right) (#.Item x))))))) + (\ ! each (|>> (list\each product.right) (#.Item x))))))) (def: .public (not parser) (All [s a] (-> (Parser s a) (Parser s Any))) diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/library/lux/control/parser/analysis.lux index 42bffc310..27caea2af 100644 --- a/stdlib/source/library/lux/control/parser/analysis.lux +++ b/stdlib/source/library/lux/control/parser/analysis.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Variant Tuple nat int rev local) + [lux (#- Tuple Variant nat int rev local) [abstract [monad (#+ do)]] [control @@ -36,7 +36,7 @@ (-> (List Analysis) Text) (format text.new_line "Remaining input: " (|> asts - (list\map /.%analysis) + (list\each /.%analysis) (text.interposed " ")))) (exception: .public (cannot_parse {input (List Analysis)}) diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index 4fd9d15f5..220dd5ea2 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -99,7 +99,7 @@ (def: .public frac (Parser Frac) - (//\map frac.of_bits ..bits/64)) + (//\each frac.of_bits ..bits/64)) (exception: .public (invalid_tag {range Nat} {byte Nat}) (exception.report @@ -112,7 +112,7 @@ ..bits/8)] (`` (case flag (^template [<number> <tag> <parser>] - [<number> (\ ! map (|>> <tag>) <parser>)]) + [<number> (\ ! each (|>> <tag>) <parser>)]) ((~~ (template.spliced <case>+))) _ (//.lifted (exception.except ..invalid_tag [(~~ (template.amount <case>+)) flag])))))]) @@ -153,13 +153,13 @@ 0 (#try.Success [[offset binary] (/.empty 0)]) _ (|> binary (/.slice offset size) - (\ try.monad map (|>> [[(n.+ size offset) binary]])))))) + (\ try.monad each (|>> [[(n.+ size offset) binary]])))))) (template [<size> <name> <bits>] [(`` (def: .public <name> (Parser Binary) (do //.monad - [size (//\map .nat <bits>)] + [size (//\each .nat <bits>)] (..segment size))))] [08 binary/8 ..bits/8] diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index 1a3bbc5a7..9b83d835a 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -32,9 +32,9 @@ (def: remaining_inputs (-> (List Code) Text) - (|>> (list\map code.format) + (|>> (list\each code.format) (text.interposed " ") - ($_ text\compose text.new_line "Remaining input: "))) + ($_ text\composite text.new_line "Remaining input: "))) (def: .public any (Parser Code) @@ -47,7 +47,7 @@ (#try.Success [tokens' t])))) (template [<query> <check> <type> <tag> <eq> <desc>] - [(with_expansions [<failure> (as_is (#try.Failure ($_ text\compose "Cannot parse " <desc> (remaining_inputs tokens))))] + [(with_expansions [<failure> (as_is (#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))))] (def: .public <query> (Parser <type>) (function (_ tokens) @@ -87,14 +87,14 @@ (#.Item [token tokens']) (if (code\= code token) (#try.Success [tokens' []]) - (#try.Failure ($_ text\compose "Expected a " (code.format code) " but instead got " (code.format token) + (#try.Failure ($_ text\composite "Expected a " (code.format code) " but instead got " (code.format token) (remaining_inputs tokens)))) _ (#try.Failure "There are no tokens to parse!")))) (template [<query> <check> <tag> <eq> <desc>] - [(with_expansions [<failure> (as_is (#try.Failure ($_ text\compose "Cannot parse " <desc> (remaining_inputs tokens))))] + [(with_expansions [<failure> (as_is (#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))))] (def: .public <query> (Parser Text) (function (_ tokens) @@ -130,10 +130,10 @@ (#.Item [[_ (<tag> members)] tokens']) (case (p members) (#try.Success [#.End x]) (#try.Success [tokens' x]) - _ (#try.Failure ($_ text\compose "Parser was expected to fully consume " <desc> (remaining_inputs tokens)))) + _ (#try.Failure ($_ text\composite "Parser was expected to fully consume " <desc> (remaining_inputs tokens)))) _ - (#try.Failure ($_ text\compose "Cannot parse " <desc> (remaining_inputs tokens))))))] + (#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))))))] [ form #.Form "form"] [tuple #.Tuple "tuple"] @@ -147,17 +147,17 @@ (#.Item [[_ (#.Record pairs)] tokens']) (case (p (un_paired pairs)) (#try.Success [#.End x]) (#try.Success [tokens' x]) - _ (#try.Failure ($_ text\compose "Parser was expected to fully consume record" (remaining_inputs tokens)))) + _ (#try.Failure ($_ text\composite "Parser was expected to fully consume record" (remaining_inputs tokens)))) _ - (#try.Failure ($_ text\compose "Cannot parse record" (remaining_inputs tokens)))))) + (#try.Failure ($_ text\composite "Cannot parse record" (remaining_inputs tokens)))))) (def: .public end! (Parser Any) (function (_ tokens) (case tokens #.End (#try.Success [tokens []]) - _ (#try.Failure ($_ text\compose "Expected list of tokens to be empty!" (remaining_inputs tokens)))))) + _ (#try.Failure ($_ text\composite "Expected list of tokens to be empty!" (remaining_inputs tokens)))))) (def: .public end? (Parser Bit) @@ -179,9 +179,9 @@ _ (#try.Failure (|> unconsumed - (list\map code.format) + (list\each code.format) (text.interposed ", ") - (text\compose "Unconsumed inputs: ")))))) + (text\composite "Unconsumed inputs: ")))))) (def: .public (local inputs parser) (All [a] (-> (List Code) (Parser a) (Parser a))) diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index f084a838d..fbb7335f5 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -41,4 +41,4 @@ (def: .public (result parser environment) (All [a] (-> (Parser a) Environment (Try a))) - (\ try.monad map product.right (parser environment))) + (\ try.monad each 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 1348b92b4..dcbda6f71 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -146,8 +146,8 @@ (#/.Object kvs) (case (|> kvs dictionary.entries - (list\map (function (_ [key value]) - (list (#/.String key) value))) + (list\each (function (_ [key value]) + (list (#/.String key) value))) list.together (//.result parser)) (#try.Failure error) @@ -195,4 +195,4 @@ (|>> (//.and ..string) //.some ..object - (//\map (dictionary.of_list text.hash)))) + (//\each (dictionary.of_list text.hash)))) diff --git a/stdlib/source/library/lux/control/parser/synthesis.lux b/stdlib/source/library/lux/control/parser/synthesis.lux index df28b3df1..d6c6fbeca 100644 --- a/stdlib/source/library/lux/control/parser/synthesis.lux +++ b/stdlib/source/library/lux/control/parser/synthesis.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Variant Tuple function loop i64 local) + [lux (#- Tuple Variant function loop i64 local) [abstract [monad (#+ do)]] [control diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux index 0e9724a15..24a2f9e3c 100644 --- a/stdlib/source/library/lux/control/parser/text.lux +++ b/stdlib/source/library/lux/control/parser/text.lux @@ -31,8 +31,9 @@ (//.Parser [Offset Text])) (type: .public Slice - {#basis Offset - #distance Offset}) + (Record + {#basis Offset + #distance Offset})) (def: (remaining' offset tape) (-> Offset Text Text) @@ -161,7 +162,7 @@ (do //.monad [char any .let [char' (maybe.trusted (/.char 0 char))] - _ (//.assertion ($_ /\compose "Character is not within range: " (/.of_char bottom) "-" (/.of_char top)) + _ (//.assertion ($_ /\composite "Character is not within range: " (/.of_char bottom) "-" (/.of_char top)) (.and (n.>= bottom char') (n.<= top char')))] (in char))) @@ -265,7 +266,7 @@ (do //.monad [=left left =right right] - (in ($_ /\compose =left =right)))) + (in ($_ /\composite =left =right)))) (def: .public (and! left right) (-> (Parser Slice) (Parser Slice) (Parser Slice)) @@ -277,7 +278,7 @@ (template [<name> <base> <doc_modifier>] [(def: .public (<name> parser) (-> (Parser Text) (Parser Text)) - (|> parser <base> (\ //.monad map /.together)))] + (|> parser <base> (\ //.monad each /.together)))] [some //.some "some"] [many //.many "many"] @@ -297,7 +298,7 @@ (-> Nat (Parser Text) (Parser Text)) (|> parser (<base> amount) - (\ //.monad map /.together)))] + (\ //.monad each /.together)))] [exactly //.exactly "exactly"] [at_most //.at_most "at most"] @@ -319,7 +320,7 @@ (-> Nat Nat (Parser Text) (Parser Text)) (|> parser (//.between minimum additional) - (\ //.monad map /.together))) + (\ //.monad each /.together))) (def: .public (between! minimum additional parser) (-> Nat Nat (Parser Slice) (Parser Slice)) diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 0b726282a..d51ebc152 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -54,7 +54,7 @@ (exception: .public (unconsumed_input {remaining (List Type)}) (exception.report ["Types" (|> remaining - (list\map (|>> %.type (format text.new_line "* "))) + (list\each (|>> %.type (format text.new_line "* "))) (text.interposed ""))])) (type: .public Env @@ -132,7 +132,7 @@ (def: (label idx) (-> Nat Code) - (code.local_identifier ($_ text\compose "label" text.tab (n\encoded idx)))) + (code.local_identifier ($_ text\composite "label" text.tab (n\encoded idx)))) (def: .public (with_extension type poly) (All [a] (-> Type (Parser a) (Parser [Code a]))) @@ -175,7 +175,7 @@ (All [a] (-> (Parser a) (Parser [Code (List Code) a]))) (do {! //.monad} [headT any - funcI (\ ! map dictionary.size ..env) + funcI (\ ! each dictionary.size ..env) [num_args non_poly] (local (list headT) ..polymorphic') env ..env .let [funcL (label funcI) @@ -194,7 +194,7 @@ partial_varI (++ partialI) partial_varL (label partial_varI) partialC (` ((~ funcL) (~+ (|> (list.indices num_args) - (list\map (|>> (n.* 2) ++ (n.+ funcI) label)) + (list\each (|>> (n.* 2) ++ (n.+ funcI) label)) list.reversed))))] (recur (++ current_arg) (|> env' @@ -344,6 +344,6 @@ _ (local (list funcT) (..parameter! 0)) allC (let [allT (list& funcT argsT)] (|> allT - (monad.map ! (function.constant ..parameter)) + (monad.each ! (function.constant ..parameter)) (local allT)))] (in (` ((~+ allC)))))) diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/library/lux/control/parser/xml.lux index 2e982ad45..6be4241d0 100644 --- a/stdlib/source/library/lux/control/parser/xml.lux +++ b/stdlib/source/library/lux/control/parser/xml.lux @@ -108,7 +108,7 @@ (if (name\= expected actual) (|> children (..result' parser attrs') - (try\map (|>> [[attrs tail]]))) + (try\each (|>> [[attrs tail]]))) (exception.except ..wrong_tag [expected actual])))))) (def: .public any diff --git a/stdlib/source/library/lux/control/pipe.lux b/stdlib/source/library/lux/control/pipe.lux index 8fda36325..760dfb143 100644 --- a/stdlib/source/library/lux/control/pipe.lux +++ b/stdlib/source/library/lux/control/pipe.lux @@ -104,11 +104,12 @@ prev <code>.any]) (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ prev)] - [(~+ (list\map (function (_ body) (` (|> (~ g!temp) (~+ body)))) - paths))])))))) + [(~+ (list\each (function (_ body) (` (|> (~ g!temp) (~+ body)))) + paths))])))))) (syntax: .public (case> [branches (<>.many (<>.and <code>.any <code>.any)) prev <code>.any]) (in (list (` (case (~ prev) - (~+ (list\join (list\map (function (_ [pattern body]) (list pattern body)) - branches)))))))) + (~+ (|> branches + (list\each (function (_ [pattern body]) (list pattern body))) + list\conjoint))))))) diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index 7d6462858..b5b6c3e6e 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -24,7 +24,7 @@ (implementation: .public functor (All [r] (Functor (Reader r))) - (def: (map f fa) + (def: (each f fa) (function (_ env) (f (fa env))))) @@ -45,7 +45,7 @@ (def: (in x) (function (_ env) x)) - (def: (join mma) + (def: (conjoint mma) (function (_ env) (mma env env)))) @@ -58,7 +58,7 @@ (def: in (|>> (\ monad in) (\ ..monad in))) - (def: (join eMeMa) + (def: (conjoint eMeMa) (function (_ env) (do monad [eMa (result env eMeMa)] diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index 1ca544ca6..a8a30cfd2 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -58,8 +58,8 @@ (do {! monad} [[cleaners output] (computation [[] (list)])] (|> cleaners - (monad.map ! (function (_ cleaner) (cleaner []))) - (\ ! map (list\mix clean output))))) + (monad.each ! (function (_ cleaner) (cleaner []))) + (\ ! each (list\mix clean output))))) (def: .public (acquire! monad cleaner value) (All [! a] (-> (Monad !) (-> a (! (Try Any))) a @@ -74,10 +74,10 @@ (-> (Functor !) (All [r] (Functor (Region r !))))) - (def: (map f) + (def: (each f) (function (_ fa) (function (_ region+cleaners) - (\ super map + (\ super each (function (_ [cleaners' temp]) [cleaners' (case temp (#try.Success value) @@ -124,7 +124,7 @@ (function (_ [region cleaners]) (\ super in [cleaners (#try.Success value)]))) - (def: (join ffa) + (def: (conjoint ffa) (function (_ [region cleaners]) (do super [[cleaners efa] (ffa [region cleaners])] @@ -153,6 +153,6 @@ (-> (Monad !) (! a) (All [r] (Region r ! a)))) (function (_ [region cleaners]) - (\ monad map + (\ monad each (|>> #try.Success [cleaners]) operation))) diff --git a/stdlib/source/library/lux/control/remember.lux b/stdlib/source/library/lux/control/remember.lux index eaba75049..8ba79f6a7 100644 --- a/stdlib/source/library/lux/control/remember.lux +++ b/stdlib/source/library/lux/control/remember.lux @@ -36,8 +36,8 @@ (def: deadline (Parser Date) ($_ <>.either - (<>\map (|>> instant.of_millis instant.date) - <c>.int) + (<>\each (|>> instant.of_millis instant.date) + <c>.int) (do <>.monad [raw <c>.text] (case (\ date.codec decoded raw) diff --git a/stdlib/source/library/lux/control/security/capability.lux b/stdlib/source/library/lux/control/security/capability.lux index 45b2bd083..ec84db916 100644 --- a/stdlib/source/library/lux/control/security/capability.lux +++ b/stdlib/source/library/lux/control/security/capability.lux @@ -51,14 +51,14 @@ (do {! meta.monad} [this_module meta.current_module_name .let [[name vars] declaration] - g!brand (\ ! map (|>> %.code code.text) + g!brand (\ ! each (|>> %.code code.text) (macro.identifier (format (%.name [this_module name])))) .let [capability (` (..Capability (.primitive (~ g!brand)) (~ input) (~ output)))]] (in (list (` (type: (~ export_policy) (~ (|declaration|.format declaration)) (~ capability))) (` (def: (~ (code.local_identifier forger)) - (All [(~+ (list\map code.local_identifier vars))] + (All [(~+ (list\each code.local_identifier vars))] (-> (-> (~ input) (~ output)) (~ capability))) (~! ..capability))) diff --git a/stdlib/source/library/lux/control/security/policy.lux b/stdlib/source/library/lux/control/security/policy.lux index 497e250ff..1087cf751 100644 --- a/stdlib/source/library/lux/control/security/policy.lux +++ b/stdlib/source/library/lux/control/security/policy.lux @@ -20,8 +20,9 @@ (-> (Policy brand value label) value)) (type: .public (Privilege brand label) - {#can_upgrade (Can_Upgrade brand label) - #can_downgrade (Can_Downgrade brand label)}) + (Record + {#can_upgrade (Can_Upgrade brand label) + #can_downgrade (Can_Downgrade brand label)})) (type: .public (Delegation brand from to) (All [value] @@ -58,7 +59,7 @@ (implementation: .public functor (:~ (..of_policy Functor)) - (def: (map f fa) + (def: (each f fa) (|> fa :representation f :abstraction))) (implementation: .public apply @@ -74,7 +75,7 @@ (def: &functor ..functor) (def: in (|>> :abstraction)) - (def: join (|>> :representation))) + (def: conjoint (|>> :representation))) ) (template [<brand> <value> <upgrade> <downgrade>] diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index 586cb652c..4b3a64a08 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -42,7 +42,7 @@ (implementation: .public functor (All [s] (Functor (State s))) - (def: (map f ma) + (def: (each f ma) (function (_ state) (let [[state' a] (ma state)] [state' (f a)])))) @@ -67,7 +67,7 @@ (function (_ state) [state a])) - (def: (join mma) + (def: (conjoint mma) (function (_ state) (let [[state' ma] (mma state)] (ma state'))))) @@ -91,9 +91,9 @@ (implementation: (with//functor functor) (All [M s] (-> (Functor M) (Functor (All [a] (-> s (M [s a])))))) - (def: (map f sfa) + (def: (each f sfa) (function (_ state) - (\ functor map (function (_ [s a]) [s (f a)]) + (\ functor each (function (_ [s a]) [s (f a)]) (sfa state))))) (implementation: (with//apply monad) @@ -124,7 +124,7 @@ (function (_ state) (\ monad in [state a]))) - (def: (join sMsMa) + (def: (conjoint sMsMa) (function (_ state) (do monad [[state' sMa] (sMsMa state)] diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux index 8366b2efc..a7acf841e 100644 --- a/stdlib/source/library/lux/control/thread.lux +++ b/stdlib/source/library/lux/control/thread.lux @@ -71,7 +71,7 @@ (implementation: .public functor (All [!] (Functor (Thread !))) - (def: (map f) + (def: (each f) (function (_ fa) (function (_ !) (f (fa !)))))) @@ -94,7 +94,7 @@ (function (_ !) value)) - (def: (join ffa) + (def: (conjoint ffa) (function (_ !) ((ffa !) !)))) diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 2a1fce570..48ee21443 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -10,13 +10,14 @@ ["." location]]]]) (type: .public (Try a) - (#Failure Text) - (#Success a)) + (Variant + (#Failure Text) + (#Success a))) (implementation: .public functor (Functor Try) - (def: (map f ma) + (def: (each f ma) (case ma (#Failure msg) (#Failure msg) @@ -50,7 +51,7 @@ (def: (in a) (#Success a)) - (def: (join mma) + (def: (conjoint mma) (case mma (#Failure msg) (#Failure msg) @@ -69,7 +70,7 @@ (|>> (\ ..monad in) (\ monad in))) - (def: (join MeMea) + (def: (conjoint MeMea) (do monad [eMea MeMea] (case eMea @@ -81,7 +82,7 @@ (def: .public (lifted monad) (All [! a] (-> (Monad !) (-> (! a) (! (Try a))))) - (\ monad map (\ ..monad in))) + (\ monad each (\ ..monad in))) (implementation: .public (equivalence (^open "_\.")) (All [a] (-> (Equivalence a) (Equivalence (Try a)))) diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index d42e57780..825700d8f 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -9,8 +9,9 @@ ["." monad (#+ Monad do)]]]]) (type: .public (Writer log value) - {#log log - #value value}) + (Record + {#log log + #value value})) (def: .public (write message) (All [log] (-> log (Writer log Any))) @@ -20,7 +21,7 @@ (All [l] (Functor (Writer l))) - (def: (map f fa) + (def: (each f fa) (let [[log datum] fa] [log (f datum)]))) @@ -33,7 +34,7 @@ (def: (on fa ff) (let [[log1 f] ff [log2 a] fa] - [(\ monoid compose log1 log2) (f a)]))) + [(\ monoid composite log1 log2) (f a)]))) (implementation: .public (monad monoid) (All [l] @@ -44,9 +45,9 @@ (def: in (|>> [(\ monoid identity)])) - (def: (join mma) + (def: (conjoint mma) (let [[log1 [log2 a]] mma] - [(\ monoid compose log1 log2) a]))) + [(\ monoid composite log1 log2) a]))) (implementation: .public (with monoid monad) (All [l M] (-> (Monoid l) (Monad M) (Monad (All [a] (M (Writer l a)))))) @@ -59,7 +60,7 @@ (let [writer (..monad monoid)] (|>> (\ writer in) (\ monad in)))) - (def: (join MlMla) + (def: (conjoint MlMla) (do monad [[l1 Mla] (for {@.old (: ((:parameter 1) (Writer (:parameter 0) ((:parameter 1) (Writer (:parameter 0) (:parameter 2))))) @@ -67,10 +68,10 @@ ... On new compiler MlMla) [l2 a] Mla] - (in [(\ monoid compose l1 l2) a])))) + (in [(\ monoid composite l1 l2) a])))) (def: .public (lifted monoid monad) (All [l M a] (-> (Monoid l) (Monad M) (-> (M a) (M (Writer l a))))) - (\ monad map (|>> [(\ monoid identity)]))) + (\ monad each (|>> [(\ monoid identity)]))) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index 6028c1a68..ada9bc855 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -359,7 +359,7 @@ (def: identity (..empty 0)) - (def: (compose left right) + (def: (composite left right) (let [sizeL (!size left) sizeR (!size right) output (..empty (n.+ sizeL sizeR))] diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux index 38f7b5f8d..6efecceb7 100644 --- a/stdlib/source/library/lux/data/bit.lux +++ b/stdlib/source/library/lux/data/bit.lux @@ -40,7 +40,7 @@ (Monoid Bit) (def: identity <identity>) - (def: (compose x y) (<op> x y)))] + (def: (composite x y) (<op> x y)))] [disjunction #0 or] [conjunction #1 and] diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 4ec5d1612..3ae79571c 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -331,7 +331,7 @@ (def: identity (empty 0)) - (def: (compose xs ys) + (def: (composite xs ys) (let [sxs (size xs) sxy (size ys)] (|> (empty (n.+ sxy sxs)) @@ -341,7 +341,7 @@ (implementation: .public functor (Functor Array) - (def: (map f ma) + (def: (each f ma) (let [arr_size (size ma)] (if (n.= 0 arr_size) (empty arr_size) diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index afc1cd356..e06983307 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -57,11 +57,12 @@ ... Nodes for the tree data-structure that organizes the data inside ... Dictionaries. (type: (Node k v) - (#Hierarchy Nat (Array (Node k v))) - (#Base Bit_Map - (Array (Either (Node k v) - [k v]))) - (#Collisions Hash_Code (Array [k v]))) + (Variant + (#Hierarchy Nat (Array (Node k v))) + (#Base Bit_Map + (Array (Either (Node k v) + [k v]))) + (#Collisions Hash_Code (Array [k v])))) ... #Hierarchy nodes are meant to point down only to lower-level nodes. (type: (Hierarchy k v) @@ -225,7 +226,7 @@ ... Produces the index of a KV-pair within a #Collisions node. (def: (collision_index key_hash key colls) (All [k v] (-> (Hash k) k (Collisions k v) (Maybe Index))) - (\ maybe.monad map product.left + (\ maybe.monad each product.left (array.example+ (function (_ idx [key' val']) (\ key_hash = key key')) colls))) @@ -509,7 +510,7 @@ ... For #Collisions nodes, do a linear scan of all the known KV-pairs. (#Collisions _hash _colls) - (\ maybe.monad map product.right + (\ maybe.monad each product.right (array.example (|>> product.left (\ key_hash = key)) _colls)) )) @@ -518,14 +519,14 @@ (All [k v] (-> (Node k v) Nat)) (case node (#Hierarchy _size hierarchy) - (array\mix n.+ 0 (array\map size' hierarchy)) + (array\mix n.+ 0 (array\each size' hierarchy)) (#Base _ base) - (array\mix n.+ 0 (array\map (function (_ sub_node') - (case sub_node' - (#.Left sub_node) (size' sub_node) - (#.Right _) 1)) - base)) + (array\mix n.+ 0 (array\each (function (_ sub_node') + (case sub_node' + (#.Left sub_node) (size' sub_node) + (#.Right _) 1)) + base)) (#Collisions hash colls) (array.size colls) @@ -535,7 +536,7 @@ (All [k v] (-> (Node k v) (List [k v]))) (case node (#Hierarchy _size hierarchy) - (array\mix (function (_ sub_node tail) (list\compose (entries' sub_node) tail)) + (array\mix (function (_ sub_node tail) (list\composite (entries' sub_node) tail)) #.End hierarchy) @@ -543,7 +544,7 @@ (array\mix (function (_ branch tail) (case branch (#.Left sub_node) - (list\compose (entries' sub_node) tail) + (list\composite (entries' sub_node) tail) (#.Right [key' val']) (#.Item [key' val'] tail))) @@ -556,8 +557,9 @@ colls))) (type: .public (Dictionary k v) - {#hash (Hash k) - #root (Node k v)}) + (Record + {#hash (Hash k) + #root (Node k v)})) (def: .public key_hash (All [k v] (-> (Dictionary k v) (Hash k))) @@ -701,28 +703,28 @@ (implementation: functor' (All [k] (Functor (Node k))) - (def: (map f fa) + (def: (each f fa) (case fa (#Hierarchy size hierarchy) - (#Hierarchy size (array\map (map f) hierarchy)) + (#Hierarchy size (array\each (each f) hierarchy)) (#Base bitmap base) - (#Base bitmap (array\map (function (_ either) - (case either - (#.Left fa') - (#.Left (map f fa')) - - (#.Right [k v]) - (#.Right [k (f v)]))) - base)) + (#Base bitmap (array\each (function (_ either) + (case either + (#.Left fa') + (#.Left (each f fa')) + + (#.Right [k v]) + (#.Right [k (f v)]))) + base)) (#Collisions hash collisions) - (#Collisions hash (array\map (function (_ [k v]) - [k (f v)]) - collisions))))) + (#Collisions hash (array\each (function (_ [k v]) + [k (f v)]) + collisions))))) (implementation: .public functor (All [k] (Functor (Dictionary k))) - (def: (map f fa) - (revised@ #root (\ ..functor' map f) fa))) + (def: (each f fa) + (revised@ #root (\ ..functor' each f) fa))) diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index 49d4068d5..ef9e53973 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -19,15 +19,17 @@ "Invariant violation") (type: Color - #Red - #Black) + (Variant + #Red + #Black)) (type: (Node k v) - {#color Color - #key k - #value v - #left (Maybe (Node k v)) - #right (Maybe (Node k v))}) + (Record + {#color Color + #key k + #value v + #left (Maybe (Node k v)) + #right (Maybe (Node k v))})) (template [<create> <color>] [(def: (<create> key value left right) @@ -43,8 +45,9 @@ ) (type: .public (Dictionary k v) - {#&order (Order k) - #root (Maybe (Node k v))}) + (Record + {#&order (Order k) + #root (Maybe (Node k v))})) (def: .public (empty order) (All [k v] (-> (Order k) (Dictionary k v))) @@ -352,7 +355,7 @@ (#.Some (right_balanced (value@ #key right) (value@ #value right) (value@ #right right>>left) - (\ maybe.functor map reddened (value@ #right right))))) + (\ maybe.functor each reddened (value@ #right right))))) _ (panic! error_message)) @@ -379,7 +382,7 @@ (value@ #value left>>right) (#.Some (left_balanced (value@ #key left) (value@ #value left) - (\ maybe.functor map reddened (value@ #left left)) + (\ maybe.functor each reddened (value@ #left left)) (value@ #left left>>right))) (#.Some (black key value (value@ #right left>>right) ?right))) @@ -547,7 +550,7 @@ (list) (#.Some node') - ($_ list\compose + ($_ list\composite (recur (value@ #left node')) (list <output>) (recur (value@ #right node'))))))] diff --git a/stdlib/source/library/lux/data/collection/dictionary/plist.lux b/stdlib/source/library/lux/data/collection/dictionary/plist.lux index e98a2c51b..df834ae4c 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux @@ -42,7 +42,7 @@ (template [<name> <type> <access>] [(def: .public <name> (All [a] (-> (PList a) (List <type>))) - (list\map <access>))] + (list\each <access>))] [keys Text product.left] [values a product.right] diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index 98a3224e4..b40e94669 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -312,26 +312,26 @@ (All [a] (Monoid (List a))) (def: identity #.End) - (def: (compose xs ys) + (def: (composite xs ys) (case xs #.End ys (#.Item x xs') - (#.Item x (compose xs' ys))))) + (#.Item x (composite xs' ys))))) (open: "." ..monoid) (implementation: .public functor (Functor List) - (def: (map f ma) + (def: (each f ma) (case ma #.End #.End (#.Item a ma') - (#.Item (f a) (map f ma'))))) + (#.Item (f a) (each f ma'))))) (open: "." ..functor) @@ -348,7 +348,7 @@ (#.Item f ff') (|> ff' (on fa) - (compose (map f fa)))))) + (composite (each f fa)))))) (implementation: .public monad (Monad List) @@ -358,8 +358,8 @@ (def: (in a) (#.Item a #.End)) - (def: join - (|>> reversed (mix compose identity)))) + (def: conjoint + (|>> reversed (mix composite identity)))) (def: .public (sorted < xs) (All [a] (-> (-> a a Bit) (List a) (List a))) @@ -374,7 +374,7 @@ [pre (#.Item x' post)])) [(list) (list)] xs')] - ($_ compose (sorted < pre) (list x) (sorted < post))))) + ($_ composite (sorted < pre) (list x) (sorted < post))))) (def: .public (empty? xs) (All [a] (Predicate (List a))) @@ -447,27 +447,27 @@ (if (n.> 0 num_lists) (let [(^open ".") ..functor indices (..indices num_lists) - type_vars (: (List Code) (map (|>> nat\encoded identifier$) indices)) + type_vars (: (List Code) (each (|>> nat\encoded identifier$) indices)) zipped_type (` (All [(~+ type_vars)] - (-> (~+ (map (: (-> Code Code) (function (_ var) (` (List (~ var))))) - type_vars)) + (-> (~+ (each (: (-> Code Code) (function (_ var) (` (List (~ var))))) + type_vars)) (List [(~+ type_vars)])))) vars+lists (|> indices - (map ++) - (map (function (_ idx) - (let [base (nat\encoded idx)] - [(identifier$ base) - (identifier$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (map (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) - vars+lists))]) + (each ++) + (each (function (_ idx) + (let [base (nat\encoded idx)] + [(identifier$ base) + (identifier$ ("lux text concat" base "'"))])))) + pattern (` [(~+ (each (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) + vars+lists))]) g!step (identifier$ "0step0") g!blank (identifier$ "0,0") - list_vars (map product.right vars+lists) + list_vars (each product.right vars+lists) code (` (: (~ zipped_type) (function ((~ g!step) (~+ list_vars)) (case [(~+ list_vars)] (~ pattern) - (#.Item [(~+ (map product.left vars+lists))] + (#.Item [(~+ (each product.left vars+lists))] ((~ g!step) (~+ list_vars))) (~ g!blank) @@ -489,28 +489,28 @@ indices (..indices num_lists) g!return_type (identifier$ "0return_type0") g!func (identifier$ "0func0") - type_vars (: (List Code) (map (|>> nat\encoded identifier$) indices)) + type_vars (: (List Code) (each (|>> nat\encoded identifier$) indices)) zipped_type (` (All [(~+ type_vars) (~ g!return_type)] (-> (-> (~+ type_vars) (~ g!return_type)) - (~+ (map (: (-> Code Code) (function (_ var) (` (List (~ var))))) - type_vars)) + (~+ (each (: (-> Code Code) (function (_ var) (` (List (~ var))))) + type_vars)) (List (~ g!return_type))))) vars+lists (|> indices - (map ++) - (map (function (_ idx) - (let [base (nat\encoded idx)] - [(identifier$ base) - (identifier$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (map (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) - vars+lists))]) + (each ++) + (each (function (_ idx) + (let [base (nat\encoded idx)] + [(identifier$ base) + (identifier$ ("lux text concat" base "'"))])))) + pattern (` [(~+ (each (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) + vars+lists))]) g!step (identifier$ "0step0") g!blank (identifier$ "0,0") - list_vars (map product.right vars+lists) + list_vars (each product.right vars+lists) code (` (: (~ zipped_type) (function ((~ g!step) (~ g!func) (~+ list_vars)) (case [(~+ list_vars)] (~ pattern) - (#.Item ((~ g!func) (~+ (map product.left vars+lists))) + (#.Item ((~ g!func) (~+ (each product.left vars+lists))) ((~ g!step) (~ g!func) (~+ list_vars))) (~ g!blank) @@ -556,7 +556,7 @@ (def: .public together (All [a] (-> (List (List a)) (List a))) - (\ ..monad join)) + (\ ..monad conjoint)) (implementation: .public (with monad) (All [M] (-> (Monad M) (Monad (All [a] (M (List a)))))) @@ -568,7 +568,7 @@ (def: in (|>> (\ ..monad in) (\ monad in))) - (def: (join MlMla) + (def: (conjoint MlMla) (do {! monad} [lMla MlMla ... TODO: Remove this version ASAP and use one below. @@ -580,7 +580,7 @@ (def: .public (lifted monad) (All [M a] (-> (Monad M) (-> (M a) (M (List a))))) - (\ monad map (\ ..monad in))) + (\ monad each (\ ..monad in))) (def: .public (enumeration xs) (All [a] (-> (List a) (List [Nat a]))) diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index e8caf83f7..ca41352b6 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -12,8 +12,9 @@ ["n" nat]]]]]) (type: .public (Queue a) - {#front (List a) - #rear (List a)}) + (Record + {#front (List a) + #rear (List a)})) (def: .public empty Queue @@ -28,7 +29,7 @@ (def: .public (list queue) (All [a] (-> (Queue a) (List a))) (let [(^slots [#front #rear]) queue] - (list\compose front (list.reversed rear)))) + (list\composite front (list.reversed rear)))) (def: .public front (All [a] (-> (Queue a) (Maybe a))) @@ -88,6 +89,6 @@ (implementation: .public functor (Functor Queue) - (def: (map f fa) - {#front (|> fa (value@ #front) (list\map f)) - #rear (|> fa (value@ #rear) (list\map f))})) + (def: (each f fa) + {#front (|> fa (value@ #front) (list\each f)) + #rear (|> fa (value@ #rear) (list\each f))})) diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index d7a792cdc..6cba59b62 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -33,15 +33,21 @@ ["." i64]]]]]) (type: (Node a) - (#Base (Array a)) - (#Hierarchy (Array (Node a)))) + (Variant + (#Base (Array a)) + (#Hierarchy (Array (Node a))))) -(type: (Base a) (Array a)) -(type: (Hierarchy a) (Array (Node a))) +(type: (Base a) + (Array a)) -(type: Level Nat) +(type: (Hierarchy a) + (Array (Node a))) -(type: Index Nat) +(type: Level + Nat) + +(type: Index + Nat) (def: branching_exponent Nat @@ -179,14 +185,15 @@ (|> hierarchy array.list list.reversed - (list\mix (function (_ sub acc) (list\compose (list' sub) acc)) + (list\mix (function (_ sub acc) (list\composite (list' sub) acc)) #.End)))) (type: .public (Row a) - {#level Level - #size Nat - #root (Hierarchy a) - #tail (Base a)}) + (Record + {#level Level + #size Nat + #root (Hierarchy a) + #tail (Base a)})) (def: .public empty Row @@ -341,8 +348,8 @@ (def: .public (list row) (All [a] (-> (Row a) (List a))) - (list\compose (list' (#Hierarchy (value@ #root row))) - (list' (#Base (value@ #tail row))))) + (list\composite (list' (#Hierarchy (value@ #root row))) + (list' (#Base (value@ #tail row))))) (def: .public of_list (All [a] (-> (List a) (Row a))) @@ -413,28 +420,28 @@ (def: identity ..empty) - (def: (compose xs ys) + (def: (composite xs ys) (list\mix suffix xs (..list ys)))) (implementation: node_functor (Functor Node) - (def: (map f xs) + (def: (each f xs) (case xs (#Base base) - (#Base (array\map f base)) + (#Base (array\each f base)) (#Hierarchy hierarchy) - (#Hierarchy (array\map (map f) hierarchy))))) + (#Hierarchy (array\each (each f) hierarchy))))) (implementation: .public functor (Functor Row) - (def: (map f xs) + (def: (each f xs) {#level (value@ #level xs) #size (value@ #size xs) - #root (|> xs (value@ #root) (array\map (\ node_functor map f))) - #tail (|> xs (value@ #tail) (array\map f))})) + #root (|> xs (value@ #root) (array\each (\ node_functor each f))) + #tail (|> xs (value@ #tail) (array\each f))})) (implementation: .public apply (Apply Row) @@ -445,21 +452,22 @@ (let [(^open ".") ..functor (^open ".") ..mix (^open ".") ..monoid - results (map (function (_ f) (map f fa)) - ff)] - (mix compose identity results)))) + results (each (function (_ f) (each f fa)) + ff)] + (mix composite identity results)))) (implementation: .public monad (Monad Row) (def: &functor ..functor) - (def: in (|>> row)) + (def: in + (|>> row)) - (def: join + (def: conjoint (let [(^open ".") ..mix (^open ".") ..monoid] - (mix (function (_ post pre) (compose pre post)) identity)))) + (mix (function (_ post pre) (composite pre post)) identity)))) (def: .public reversed (All [a] (-> (Row a) (Row a))) diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index 2bed3b721..8efb47cce 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -112,9 +112,9 @@ (implementation: .public functor (Functor Sequence) - (def: (map f fa) + (def: (each f fa) (let [[head tail] (//.result fa)] - (//.pending [(f head) (map f tail)])))) + (//.pending [(f head) (each f tail)])))) (implementation: .public comonad (CoMonad Sequence) @@ -123,17 +123,18 @@ (def: out head) - (def: (split wa) + (def: (disjoint wa) (let [[head tail] (//.result wa)] - (//.pending [wa (split tail)])))) + (//.pending [wa (disjoint tail)])))) (syntax: .public (^sequence& [patterns (<code>.form (<>.many <code>.any)) body <code>.any branches (<>.some <code>.any)]) (with_identifiers [g!sequence] - (let [body+ (` (let [(~+ (list\join (list\map (function (_ pattern) - (list (` [(~ pattern) (~ g!sequence)]) - (` ((~! //.result) (~ g!sequence))))) - patterns)))] + (let [body+ (` (let [(~+ (|> patterns + (list\each (function (_ pattern) + (list (` [(~ pattern) (~ g!sequence)]) + (` ((~! //.result) (~ g!sequence)))))) + list\conjoint))] (~ 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 00edc5a47..d9c18877b 100644 --- a/stdlib/source/library/lux/data/collection/set.lux +++ b/stdlib/source/library/lux/data/collection/set.lux @@ -82,7 +82,7 @@ (All [a] (-> (Hash a) (Monoid (Set a)))) (def: identity (..empty hash)) - (def: compose ..union)) + (def: composite ..union)) (def: .public empty? (All [a] (-> (Set a) Bit)) diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index f176dc46a..73964bc7a 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -19,7 +19,7 @@ ["." dictionary (#+ Dictionary)]]]) (abstract: .public (Set a) - {#.doc (example "A set that keeps track of repetition in its entries.")} + {} (Dictionary a Nat) @@ -63,13 +63,13 @@ (|>> :representation dictionary.entries (list\mix (function (_ [elem multiplicity] output) - (list\compose (list.repeated multiplicity elem) output)) + (list\composite (list.repeated multiplicity elem) output)) #.End))) - (template [<name> <compose>] + (template [<name> <composite>] [(def: .public (<name> parameter subject) (All [a] (-> (Set a) (Set a) (Set a))) - (:abstraction (dictionary.merged_with <compose> (:representation parameter) (:representation subject))))] + (:abstraction (dictionary.merged_with <composite> (:representation parameter) (:representation subject))))] [union n.max] [sum n.+] @@ -95,7 +95,6 @@ subject))) (def: .public (sub? reference subject) - {#.doc (example "Is 'subject' a sub-set of 'reference'?")} (All [a] (-> (Set a) (Set a) Bit)) (|> subject :representation @@ -106,7 +105,6 @@ (n.>= multiplicity)))))) (def: .public (support set) - {#.doc (example "A set of the unique (non repeated) members.")} (All [a] (-> (Set a) (//.Set a))) (let [(^@ set [hash _]) (:representation set)] (|> set @@ -157,6 +155,5 @@ (//.list subject))) (def: .public super? - {#.doc (example "Is 'subject' a super-set of 'reference'?")} (All [a] (-> (Set a) (Set a) Bit)) (function.flipped sub?)) diff --git a/stdlib/source/library/lux/data/collection/set/ordered.lux b/stdlib/source/library/lux/data/collection/set/ordered.lux index d6d532d02..eeb66fa5e 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 (example "A set with ordered entries.")} + {} (/.Dictionary a a) @@ -77,13 +77,11 @@ ) (def: .public (sub? super sub) - {#.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 (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 2b9cbc2e4..549450cbd 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 (example "A first-in, last-out sequential data-structure.")} + {} (List a) @@ -28,7 +28,6 @@ (|>> :representation //.empty?)) (def: .public (value stack) - {#.doc (example "Yields the top value in the stack, if any.")} (All [a] (-> (Stack a) (Maybe a))) (case (:representation stack) #.End @@ -61,9 +60,9 @@ (implementation: .public functor (Functor Stack) - (def: (map f value) + (def: (each f value) (|> value :representation - (\ //.functor map f) + (\ //.functor each f) :abstraction))) ) diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux index bdf10e85b..d3222b959 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -17,17 +17,16 @@ ["." code]]]]) (type: .public (Tree a) - {#.doc (example "A generic tree data-structure.")} - {#value a - #children (List (Tree a))}) + (Record + {#value a + #children (List (Tree a))})) (def: .public (flat tree) - {#.doc (example "All the leaf values of the tree, in order.")} (All [a] (-> (Tree a) (List a))) (|> tree (value@ #children) - (list\map flat) - list\join + (list\each flat) + list\conjoint (#.Item (value@ #value tree)))) (def: .public (leaf value) @@ -55,15 +54,9 @@ (<>.and <code>.any))) (syntax: .public (tree [root tree^]) - {#.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)))}))))))) + #children (list (~+ (list\each recur children)))}))))))) (implementation: .public (equivalence super) (All [a] (-> (Equivalence a) (Equivalence (Tree a)))) @@ -75,10 +68,10 @@ (implementation: .public functor (Functor Tree) - (def: (map f fa) + (def: (each f fa) {#value (f (value@ #value fa)) - #children (list\map (map f) - (value@ #children fa))})) + #children (list\each (each f) + (value@ #children fa))})) (implementation: .public mix (Mix Tree) diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index 588cb4e5a..b0dcece05 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -12,15 +12,15 @@ ... https://en.wikipedia.org/wiki/Finger_tree (abstract: .public (Tree @ t v) - {#.doc (example "A finger tree.")} + {} - {#monoid (Monoid t) - #tag t - #root (Or v - [(Tree @ t v) (Tree @ t v)])} + (Record + {#monoid (Monoid t) + #tag t + #root (Or v + [(Tree @ t v) (Tree @ t v)])}) (interface: .public (Builder @ t) - {#.doc (example "A builder for finter tree structures.")} (: (All [v] (-> t v (Tree @ t v))) leaf) @@ -40,7 +40,6 @@ ) (implementation: .public (builder monoid) - {#.doc (example "A new builder using the given monoid.")} (All [t] (Ex [@] (-> (Monoid t) (Builder @ t)))) (def: (leaf tag value) @@ -52,7 +51,7 @@ (def: (branch left right) (:abstraction {#monoid monoid - #tag (\ monoid compose (..tag left) (..tag right)) + #tag (\ monoid composite (..tag left) (..tag right)) #root (0 #1 [left right])}))) (def: .public (value tree) @@ -71,8 +70,8 @@ (list (value@ #tag (:representation tree))) (0 #1 [left right]) - (list\compose (tags left) - (tags right)))) + (list\composite (tags left) + (tags right)))) (def: .public (values tree) (All [@ t v] (-> (Tree @ t v) (List v))) @@ -81,11 +80,10 @@ (list value) (0 #1 [left right]) - (list\compose (values left) - (values right)))) + (list\composite (values left) + (values right)))) (def: .public (one predicate tree) - {#.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) @@ -97,7 +95,7 @@ (#.Some value) (0 #1 [left right]) - (let [shifted_tag (tag//compose _tag (..tag left))] + (let [shifted_tag (tag//composite _tag (..tag left))] (if (predicate shifted_tag) (recur _tag (value@ #root (:representation left))) (recur shifted_tag (value@ #root (:representation right)))))))) @@ -105,7 +103,6 @@ ) (def: .public (exists? predicate tree) - {#.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 1c99353bc..cec25e125 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -18,15 +18,16 @@ ["." // (#+ Tree) ("#\." functor)]) (type: (Family Zipper a) - {#parent (Zipper a) - #lefts (List (Tree a)) - #rights (List (Tree a))}) + (Record + {#parent (Zipper a) + #lefts (List (Tree a)) + #rights (List (Tree a))})) ... https://en.wikipedia.org/wiki/Zipper_(data_structure) (type: .public (Zipper a) - {#.doc "Tree zippers, for easy navigation and editing of trees."} - {#family (Maybe (Family Zipper a)) - #node (Tree a)}) + (Record + {#family (Maybe (Family Zipper a)) + #node (Tree a)})) (implementation: .public (equivalence super) (All [a] @@ -105,14 +106,14 @@ (for {@.old (revised@ #node (: (-> (Tree (:parameter 0)) (Tree (:parameter 0))) - (with@ #//.children (list\compose (list.reversed lefts) - (#.Item (value@ #node zipper) - rights)))) + (with@ #//.children (list\composite (list.reversed lefts) + (#.Item (value@ #node zipper) + rights)))) parent)} (with@ [#node #//.children] - (list\compose (list.reversed lefts) - (#.Item (value@ #node zipper) - rights)) + (list\composite (list.reversed lefts) + (#.Item (value@ #node zipper) + rights)) parent)))))) (template [<one> <all> <side> <op_side>] @@ -155,13 +156,13 @@ (#.Some (for {@.old {#family (#.Some (|> family (with@ <side> #.End) (revised@ <op_side> (|>> (#.Item (value@ #node zipper)) - (list\compose prevs))))) + (list\composite prevs))))) #node last}} (let [move (: (All [a] (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ prevs zipper) (|>> (with@ <side> #.End) (revised@ <op_side> (|>> (#.Item (value@ #node zipper)) - (list\compose prevs))))))] + (list\composite prevs))))))] {#family (#.Some (move prevs zipper family)) #node last}))))))] @@ -291,13 +292,13 @@ (implementation: .public functor (Functor Zipper) - (def: (map f (^slots [#family #node])) - {#family (maybe\map (function (_ (^slots [#parent #lefts #rights])) - {#parent (map f parent) - #lefts (list\map (//\map f) lefts) - #rights (list\map (//\map f) rights)}) - family) - #node (//\map f node)})) + (def: (each f (^slots [#family #node])) + {#family (maybe\each (function (_ (^slots [#parent #lefts #rights])) + {#parent (each f parent) + #lefts (list\each (//\each f) lefts) + #rights (list\each (//\each f) rights)}) + family) + #node (//\each f node)})) (implementation: .public comonad (CoMonad Zipper) @@ -306,16 +307,16 @@ (def: out (value@ [#node #//.value])) - (def: (split (^slots [#family #node])) + (def: (disjoint (^slots [#family #node])) (let [tree_splitter (: (All [a] (-> (Tree a) (Tree (Zipper a)))) (function (tree_splitter tree) {#//.value (..zipper tree) #//.children (|> tree (value@ #//.children) - (list\map tree_splitter))}))] - {#family (maybe\map (function (_ (^slots [#parent #lefts #rights])) - {#parent (split parent) - #lefts (list\map tree_splitter lefts) - #rights (list\map tree_splitter rights)}) - family) + (list\each tree_splitter))}))] + {#family (maybe\each (function (_ (^slots [#parent #lefts #rights])) + {#parent (disjoint parent) + #lefts (list\each tree_splitter lefts) + #rights (list\each tree_splitter rights)}) + family) #node (tree_splitter node)}))) diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux index fb67c971f..3cf8fa6d5 100644 --- a/stdlib/source/library/lux/data/color.lux +++ b/stdlib/source/library/lux/data/color.lux @@ -36,18 +36,20 @@ (|>> (f.* rgb_factor) f.int .nat)) (type: .public RGB - {#red Nat - #green Nat - #blue Nat}) + (Record + {#red Nat + #green Nat + #blue Nat})) (type: .public HSL [Frac Frac Frac]) (type: .public CMYK - {#cyan Frac - #magenta Frac - #yellow Frac - #key Frac}) + (Record + {#cyan Frac + #magenta Frac + #yellow Frac + #key Frac})) (type: .public HSB [Frac Frac Frac]) @@ -106,7 +108,7 @@ (def: identity ..black) - (def: (compose left right) + (def: (composite left right) (let [[lR lG lB] (:representation left) [rR rG rB] (:representation right)] (:abstraction {#red (n.max lR rR) @@ -129,7 +131,7 @@ (def: identity ..white) - (def: (compose left right) + (def: (composite left right) (let [[lR lG lB] (:representation (..complement left)) [rR rG rB] (:representation right)] (:abstraction {#red (n.min lR rR) @@ -395,23 +397,23 @@ Palette (let [[hue saturation brightness] (hsb color) spread (..normal spread)] - (list\map (function (_ idx) - (of_hsb [(|> idx ++ .int int.frac (f.* spread) (f.+ hue) ..normal) - saturation - brightness])) - (list.indices variations))))) + (list\each (function (_ idx) + (of_hsb [(|> idx ++ .int int.frac (f.* spread) (f.+ hue) ..normal) + saturation + brightness])) + (list.indices variations))))) (`` (def: .public (monochromatic spread variations color) Palette (let [[hue saturation brightness] (hsb color) spread (..normal spread)] (|> (list.indices variations) - (list\map (|>> ++ .int int.frac - (f.* spread) - (f.+ brightness) - ..normal - [hue saturation] - of_hsb)))))) + (list\each (|>> ++ .int int.frac + (f.* spread) + (f.+ brightness) + ..normal + [hue saturation] + of_hsb)))))) (type: .public Alpha Rev) @@ -429,5 +431,6 @@ rev\top) (type: .public Pigment - {#color Color - #alpha Alpha}) + (Record + {#color Color + #alpha Alpha})) diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux index 85eb0534d..1e0ca5937 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -52,7 +52,7 @@ (def: identity ..no_op) - (def: (compose [sizeL mutL] [sizeR mutR]) + (def: (composite [sizeL mutL] [sizeR mutR]) [(n.+ sizeL sizeR) (|>> mutL mutR)])) @@ -101,7 +101,7 @@ (def: .public (and pre post) (All [a b] (-> (Writer a) (Writer b) (Writer [a b]))) (function (_ [preV postV]) - (\ ..monoid compose (pre preV) (post postV)))) + (\ ..monoid composite (pre preV) (post postV)))) (def: .public (rec body) (All [a] (-> (-> (Writer a) (Writer a)) (Writer a))) @@ -187,10 +187,10 @@ (|> value row.list (list.first capped_count) row.of_list)) (^open "specification\.") ..monoid [size mutation] (|> value - (row\map valueW) + (row\each valueW) (\ row.mix mix (function (_ post pre) - (specification\compose pre post)) + (specification\composite pre post)) specification\identity))] [(n.+ <size> size) (function (_ [offset binary]) diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux index 75e886e0d..57a7d33de 100644 --- a/stdlib/source/library/lux/data/format/css.lux +++ b/stdlib/source/library/lux/data/format/css.lux @@ -65,8 +65,8 @@ ["font-style" (|> font (value@ #/font.style) (maybe.else /value.normal_style) /value.value)] ["font-weight" (|> font (value@ #/font.weight) (maybe.else /value.normal_weight) /value.value)] with_unicode) - (list\map (function (_ [property value]) - (format property ": " value ";"))) + (list\each (function (_ [property value]) + (format property ": " value ";"))) (text.interposed /style.separator) (text.enclosed ["{" "}"]) (format "@font-face") @@ -87,41 +87,42 @@ text.new_line) (type: .public Frame - {#when Percentage - #what Style}) + (Record + {#when Percentage + #what Style})) (def: .public (key_frames animation frames) (-> (Value Animation) (List Frame) (CSS Special)) (:abstraction (format "@keyframes " (/value.value animation) " {" (|> frames - (list\map (function (_ frame) - (format (/value.percentage (value@ #when frame)) " {" - (/style.inline (value@ #what frame)) - "}"))) + (list\each (function (_ frame) + (format (/value.percentage (value@ #when frame)) " {" + (/style.inline (value@ #what frame)) + "}"))) (text.interposed ..css_separator)) "}"))) - (template: (!compose <pre> <post>) + (template: (!composite <pre> <post>) (:abstraction (format (:representation <pre>) ..css_separator (:representation <post>)))) (def: .public (and pre post) (-> (CSS Any) (CSS Any) (CSS Any)) - (!compose pre post)) + (!composite pre post)) (def: .public (alter combinator selector css) (-> Combinator (Selector Any) (CSS Common) (CSS Common)) (|> css :representation (text.all_split_by ..css_separator) - (list\map (|>> (format (/selector.selector (|> selector (combinator (/selector.tag ""))))))) + (list\each (|>> (format (/selector.selector (|> selector (combinator (/selector.tag ""))))))) (text.interposed ..css_separator) :abstraction)) (def: .public (dependent combinator selector style inner) (-> Combinator (Selector Any) Style (CSS Common) (CSS Common)) - (!compose (..rule selector style) - (..alter combinator selector inner))) + (!composite (..rule selector style) + (..alter combinator selector inner))) (template [<name> <combinator>] [(def: .public <name> diff --git a/stdlib/source/library/lux/data/format/css/font.lux b/stdlib/source/library/lux/data/format/css/font.lux index 9149bf899..2ebe6644d 100644 --- a/stdlib/source/library/lux/data/format/css/font.lux +++ b/stdlib/source/library/lux/data/format/css/font.lux @@ -14,13 +14,15 @@ ["#." value (#+ Value Font_Stretch Font_Style Font_Weight)]]) (type: .public Unicode_Range - {#start Nat - #end Nat}) + (Record + {#start Nat + #end Nat})) (type: .public Font - {#family Text - #source URL - #stretch (Maybe (Value Font_Stretch)) - #style (Maybe (Value Font_Style)) - #weight (Maybe (Value Font_Weight)) - #unicode_range (Maybe Unicode_Range)}) + (Record + {#family Text + #source URL + #stretch (Maybe (Value Font_Stretch)) + #style (Maybe (Value Font_Style)) + #weight (Maybe (Value Font_Weight)) + #unicode_range (Maybe Unicode_Range)})) diff --git a/stdlib/source/library/lux/data/format/css/selector.lux b/stdlib/source/library/lux/data/format/css/selector.lux index 1bee5183d..a1f801779 100644 --- a/stdlib/source/library/lux/data/format/css/selector.lux +++ b/stdlib/source/library/lux/data/format/css/selector.lux @@ -181,8 +181,9 @@ ) (type: .public Formula - {#constant Int - #variable Int}) + (Record + {#constant Int + #variable Int})) (def: .public (formula input) (-> Formula Index) diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index 54de6d97a..20b15f0eb 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -804,7 +804,7 @@ (def: .public (cubic_bezier p0 p1 p2 p3) (-> Frac Frac Frac Frac (Value Timing)) (|> (list p0 p1 p2 p3) - (list\map %number) + (list\each %number) (..apply "cubic-bezier"))) (template [<name> <brand>] @@ -972,7 +972,7 @@ (let [[now after] next] (..apply <function> (list& (:representation Angle angle) (with_hint now) - (list\map with_hint after)))))] + (list\each with_hint after)))))] [linear_gradient "linear-gradient"] [repeating_linear_gradient "repeating-linear-gradient"] @@ -1099,7 +1099,7 @@ [now after] next] (..apply <function> (list& (..shape shape) (with_hint now) - (list\map with_hint after)))))] + (list\each with_hint after)))))] [radial_gradient "radial-gradient"] [repeating_radial_gradient "repeating-radial-gradient"] @@ -1123,10 +1123,11 @@ :abstraction))) (type: .public Rectangle - {#top (Value Length) - #right (Value Length) - #bottom (Value Length) - #left (Value Length)}) + (Record + {#top (Value Length) + #right (Value Length) + #bottom (Value Length) + #left (Value Length)})) (def: .public (clip rectangle) (-> Rectangle (Value Clip)) @@ -1171,7 +1172,7 @@ (case options (#.Item _) (|> options - (list\map ..font_name) + (list\each ..font_name) (text.interposed ",") (:abstraction Value)) @@ -1210,10 +1211,10 @@ (-> (List (List (Maybe (Value Grid)))) (Value Grid_Template)) (let [empty (: (Value Grid) (:abstraction "."))] - (|>> (list\map (|>> (list\map (|>> (maybe.else empty) - :representation)) - (text.interposed ..grid_column_separator) - (text.enclosed ["'" "'"]))) + (|>> (list\each (|>> (list\each (|>> (maybe.else empty) + :representation)) + (text.interposed ..grid_column_separator) + (text.enclosed ["'" "'"]))) (text.interposed ..grid_row_separator) :abstraction))) @@ -1247,7 +1248,7 @@ (def: .public (quotes [left0 right0] [left1 right1]) (-> [Quote Quote] [Quote Quote] (Value Quotes)) (|> (list left0 right0 left1 right1) - (list\map (|>> ..quote_text %.text)) + (list\each (|>> ..quote_text %.text)) (text.interposed ..quote_separator) :abstraction)) @@ -1257,7 +1258,7 @@ [Frac Frac] (Value Transform)) (|> (list a b c d tx ty) - (list\map %number) + (list\each %number) (..apply "matrix"))) (def: .public (matrix_3d [a0 b0 c0 d0] [a1 b1 c1 d1] [a2 b2 c2 d2] [a3 b3 c3 d3]) @@ -1267,14 +1268,14 @@ [Frac Frac Frac Frac] (Value Transform)) (|> (list a0 b0 c0 d0 a1 b1 c1 d1 a2 b2 c2 d2 a3 b3 c3 d3) - (list\map %number) + (list\each %number) (..apply "matrix3d"))) (template [<name> <function> <input_types> <input_values>] [(`` (def: .public (<name> [(~~ (template.spliced <input_values>))]) (-> [(~~ (template.spliced <input_types>))] (Value Transform)) (|> (list (~~ (template.spliced <input_values>))) - (list\map %number) + (list\each %number) (..apply <function>))))] [translate_2d "translate" [Frac Frac] [x y]] @@ -1296,7 +1297,7 @@ [(`` (def: .public (<name> [(~~ (template.spliced <input_values>))]) (-> [(~~ (template.spliced <input_types>))] (Value Transform)) (|> (list (~~ (template.spliced <input_values>))) - (list\map ..angle) + (list\each ..angle) (..apply <function>))))] [rotate_2d "rotate" [Angle] [angle]] diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index 5bb422c0d..ffd4ab75a 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -32,14 +32,16 @@ {#.doc "Attributes for an HTML tag."} (List [Text Text])) -(type: .public Script js.Statement) +(type: .public Script + js.Statement) (type: .public Target - #Blank - #Parent - #Self - #Top - (#Frame Text)) + (Variant + #Blank + #Parent + #Self + #Top + (#Frame Text))) (def: (target value) (-> Target Text) @@ -62,8 +64,8 @@ (def: attributes (-> Attributes Text) - (|>> (list\map (function (_ [key val]) - (format key "=" text.double_quote (..safe val) text.double_quote))) + (|>> (list\each (function (_ [key val]) + (format key "=" text.double_quote (..safe val) text.double_quote))) (text.interposed " "))) (def: (open tag attributes) @@ -190,7 +192,7 @@ (def: .public (script attributes inline) (-> Attributes (Maybe Script) Meta) (|> inline - (maybe\map js.code) + (maybe\each js.code) (maybe.else "") (..raw "script" attributes))) @@ -223,8 +225,9 @@ (..raw "svg" attributes))) (type: .public Coord - {#horizontal Nat - #vertical Nat}) + (Record + {#horizontal Nat + #vertical Nat})) (def: metric_separator ",") (def: coord_separator ",") @@ -234,18 +237,21 @@ (format (%.nat horizontal) ..metric_separator (%.nat vertical))) (type: .public Rectangle - {#start Coord - #end Coord}) + (Record + {#start Coord + #end Coord})) (type: .public Circle - {#center Coord - #radius Nat}) + (Record + {#center Coord + #radius Nat})) (type: .public Polygon - {#first Coord - #second Coord - #third Coord - #extra (List Coord)}) + (Record + {#first Coord + #second Coord + #third Coord + #extra (List Coord)})) (def: (%rectangle [start end]) (Format Rectangle) @@ -258,13 +264,14 @@ (def: (%polygon [first second third extra]) (Format Polygon) (|> (list& first second third extra) - (list\map %coord) + (list\each %coord) (text.interposed ..coord_separator))) (type: .public Shape - (#Rectangle Rectangle) - (#Circle Circle) - (#Polygon Polygon)) + (Variant + (#Rectangle Rectangle) + (#Circle Circle) + (#Polygon Polygon))) (template [<name> <shape> <type> <format>] [(def: (<name> attributes shape) @@ -290,11 +297,11 @@ (#Polygon polygon) (..polygon attributes polygon))) - (def: .public (map attributes areas for) + (def: .public (each attributes areas for) (-> Attributes (List [Attributes Shape]) Image Image) ($_ ..and for - (case (list\map (product.uncurried ..area) areas) + (case (list\each (product.uncurried ..area) areas) #.End (..empty "map" attributes) @@ -367,7 +374,8 @@ [iframe "iframe" Element] ) - (type: .public Phrase (-> Attributes Content Element)) + (type: .public Phrase + (-> Attributes Content Element)) (template [<name> <tag>] [(def: .public <name> @@ -455,11 +463,11 @@ (def: .public (description_list attributes descriptions) (-> Attributes (List [Content Element]) Element) - (case (list\map (function (_ [term description]) - ($_ ..and - (..term term) - (..description description))) - descriptions) + (case (list\each (function (_ [term description]) + ($_ ..and + (..term term) + (..description description))) + descriptions) #.End (..empty "dl" attributes) @@ -517,7 +525,7 @@ (def: .public (table attributes caption columns headers rows footer) (-> Attributes (Maybe Content) (Maybe Column) Header (List Cell) (Maybe Cell) Element) (let [head (..table_head (..table_row headers)) - content (case (list\map table_row rows) + content (case (list\each table_row rows) #.End head diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index bcfd44f80..6582b7402 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -41,12 +41,13 @@ ) (type: .public #rec JSON - (#Null Null) - (#Boolean Boolean) - (#Number Number) - (#String String) - (#Array (Row JSON)) - (#Object (Dictionary String JSON))) + (Variant + (#Null Null) + (#Boolean Boolean) + (#Number Number) + (#String String) + (#Array (Row JSON)) + (#Object (Dictionary String JSON)))) (template [<name> <type>] [(type: .public <name> @@ -80,19 +81,19 @@ (in (list (` (: JSON #..Null)))) [_ (#.Tuple members)] - (in (list (` (: JSON (#..Array ((~! row) (~+ (list\map wrapper members)))))))) + (in (list (` (: JSON (#..Array ((~! row) (~+ (list\each wrapper members)))))))) [_ (#.Record pairs)] (do {! ..monad} - [pairs' (monad.map ! - (function (_ [slot value]) - (case slot - [_ (#.Text key_name)] - (in (` [(~ (code.text key_name)) (~ (wrapper value))])) - - _ - (meta.failure "Wrong syntax for JSON object."))) - pairs)] + [pairs' (monad.each ! + (function (_ [slot value]) + (case slot + [_ (#.Text key_name)] + (in (` [(~ (code.text key_name)) (~ (wrapper value))])) + + _ + (meta.failure "Wrong syntax for JSON object."))) + pairs)] (in (list (` (: JSON (#..Object ((~! dictionary.of_list) (~! text.hash) (list (~+ pairs'))))))))) @@ -107,7 +108,7 @@ (#try.Success (dictionary.keys obj)) _ - (#try.Failure ($_ text\compose "Cannot get the fields of a non-object.")))) + (#try.Failure ($_ text\composite "Cannot get the fields of a non-object.")))) (def: .public (field key json) (-> String JSON (Try JSON)) @@ -118,10 +119,10 @@ (#try.Success value) #.None - (#try.Failure ($_ text\compose "Missing field '" key "' on object."))) + (#try.Failure ($_ text\composite "Missing field '" key "' on object."))) _ - (#try.Failure ($_ text\compose "Cannot get field '" key "' on a non-object.")))) + (#try.Failure ($_ text\composite "Cannot get field '" key "' on a non-object.")))) (def: .public (has key value json) (-> String JSON JSON (Try JSON)) @@ -130,7 +131,7 @@ (#try.Success (#Object (dictionary.has key value obj))) _ - (#try.Failure ($_ text\compose "Cannot set field '" key "' on a non-object.")))) + (#try.Failure ($_ text\composite "Cannot set field '" key "' on a non-object.")))) (template [<name> <tag> <type>] [(def: .public (<name> key json) @@ -140,7 +141,7 @@ (#try.Success value) (#try.Success _) - (#try.Failure ($_ text\compose "Wrong value type at key: " key)) + (#try.Failure ($_ text\composite "Wrong value type at key: " key)) (#try.Failure error) (#try.Failure error)))] @@ -216,7 +217,7 @@ (|> raw (text.split_at 1) maybe.trusted product.right)))))) (def: escape "\") -(def: escaped_dq (text\compose ..escape text.double_quote)) +(def: escaped_dq (text\composite ..escape text.double_quote)) (def: string_format (-> String Text) @@ -240,14 +241,14 @@ (def: (array_format format) (-> (-> JSON Text) (-> Array Text)) - (|>> (row\map format) + (|>> (row\each format) row.list (text.interposed ..value_separator) (text.enclosed [..array_start ..array_end]))) (def: (kv_format format [key value]) (-> (-> JSON Text) (-> [String JSON] Text)) - ($_ text\compose + ($_ text\composite (..string_format key) ..entry_separator (format value) @@ -256,7 +257,7 @@ (def: (object_format format) (-> (-> JSON Text) (-> Object Text)) (|>> dictionary.entries - (list\map (..kv_format format)) + (list\each (..kv_format format)) (text.interposed ..value_separator) (text.enclosed [..object_start ..object_end]))) @@ -326,8 +327,8 @@ [mark (<text>.one_of "eE") signed?' (<>.parses? (<text>.this "-")) offset (<text>.many <text>.decimal)] - (in ($_ text\compose mark (if signed?' "-" "") offset))))] - (case (f\decoded ($_ text\compose (if signed? "-" "") digits "." decimals exp)) + (in ($_ text\composite mark (if signed?' "-" "") offset))))] + (case (f\decoded ($_ text\composite (if signed? "-" "") digits "." decimals exp)) (#try.Failure message) (<>.failure message) @@ -347,7 +348,7 @@ (<>\in text.carriage_return)) (<>.after (<text>.this "\f") (<>\in text.form_feed)) - (<>.after (<text>.this (text\compose "\" text.double_quote)) + (<>.after (<text>.this (text\composite "\" text.double_quote)) (<>\in text.double_quote)) (<>.after (<text>.this "\\") (<>\in "\")))) @@ -357,13 +358,13 @@ (<| (<text>.enclosed [text.double_quote text.double_quote]) (loop [_ []]) (do {! <>.monad} - [chars (<text>.some (<text>.none_of (text\compose "\" text.double_quote))) + [chars (<text>.some (<text>.none_of (text\composite "\" text.double_quote))) stop <text>.next]) (if (text\= "\" stop) (do ! [escaped escaped_parser next_chars (recur [])] - (in ($_ text\compose chars escaped next_chars))) + (in ($_ text\composite chars escaped next_chars))) (in chars)))) (def: (kv_parser json_parser) diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux index 11254a92c..fdbfd4b69 100644 --- a/stdlib/source/library/lux/data/format/markdown.lux +++ b/stdlib/source/library/lux/data/format/markdown.lux @@ -89,10 +89,10 @@ (def: (prefix with) (-> Text (-> Text Text)) (|>> (text.all_split_by text.new_line) - (list\map (function (_ line) - (if (text.empty? line) - line - (format with line)))) + (list\each (function (_ line) + (if (text.empty? line) + line + (format with line)))) (text.interposed text.new_line))) (def: indent @@ -109,36 +109,36 @@ (-> (List [(Markdown Span) (Maybe (Markdown Block))]) (Markdown Block)) (|>> list.enumeration - (list\map (function (_ [idx [summary detail]]) - (format "1. " (:representation summary) - (case detail - (#.Some detail) - (|> detail - :representation - ..indent - (text.enclosed [text.new_line text.new_line]) - (format text.new_line)) - - #.None - "")))) + (list\each (function (_ [idx [summary detail]]) + (format "1. " (:representation summary) + (case detail + (#.Some detail) + (|> detail + :representation + ..indent + (text.enclosed [text.new_line text.new_line]) + (format text.new_line)) + + #.None + "")))) (text.interposed text.new_line) ..block)) (def: .public bullet_list (-> (List [(Markdown Span) (Maybe (Markdown Block))]) (Markdown Block)) - (|>> (list\map (function (_ [summary detail]) - (format "* " (:representation summary) - (case detail - (#.Some detail) - (|> detail - :representation - ..indent - (text.enclosed [text.new_line text.new_line]) - (format text.new_line)) - - #.None - "")))) + (|>> (list\each (function (_ [summary detail]) + (format "* " (:representation summary) + (case detail + (#.Some detail) + (|> detail + :representation + ..indent + (text.enclosed [text.new_line text.new_line]) + (format text.new_line)) + + #.None + "")))) (text.interposed text.new_line) ..block)) diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index f452a2693..745acf38d 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -332,7 +332,7 @@ _ (<>.assertion (exception.error ..wrong_character [expected end]) (n.= expected end))] (<>.lifted - (\ try.monad map (|>> :abstraction) + (\ try.monad each (|>> :abstraction) (\ utf8.codec decoded string))))) ) @@ -518,7 +518,7 @@ (def: mode_parser (Parser Mode) (do {! <>.monad} - [value (\ ! map ..from_small ..small_parser)] + [value (\ ! each ..from_small ..small_parser)] (if (n.<= (:representation ..maximum_mode) value) (in (:abstraction value)) @@ -560,12 +560,14 @@ (..as_small 0)) (type: .public Owner - {#name Name - #id ID}) + (Record + {#name Name + #id ID})) (type: .public Ownership - {#user Owner - #group Owner}) + (Record + {#user Owner + #group Owner})) (type: .public File [Path Instant Mode Ownership Content]) @@ -576,10 +578,11 @@ (type: .public Contiguous File) (type: .public Entry - (#Normal ..Normal) - (#Symbolic_Link ..Symbolic_Link) - (#Directory ..Directory) - (#Contiguous ..Contiguous)) + (Variant + (#Normal ..Normal) + (#Symbolic_Link ..Symbolic_Link) + (#Directory ..Directory) + (#Contiguous ..Contiguous))) (type: Device Small) @@ -605,20 +608,21 @@ (n.* ..block_size))) (type: Header - {#path Path - #mode Mode - #user_id ID - #group_id ID - #size Big - #modification_time Big - #checksum Checksum - #link_flag Link_Flag - #link_name Path - #magic Magic - #user_name Name - #group_name Name - #major_device Device - #minor_device Device}) + (Record + {#path Path + #mode Mode + #user_id ID + #group_id ID + #size Big + #modification_time Big + #checksum Checksum + #link_flag Link_Flag + #link_name Path + #magic Magic + #user_name Name + #group_name Name + #major_device Device + #minor_device Device})) (def: header_writer' (Writer Header) @@ -739,11 +743,11 @@ (Writer Tar) (let [end_of_archive (binary.empty ..end_of_archive_size)] (function (_ tar) - (format\compose (row\mix (function (_ next total) - (format\compose total (..entry_writer next))) - format\identity - tar) - (format.segment ..end_of_archive_size end_of_archive))))) + (format\composite (row\mix (function (_ next total) + (format\composite total (..entry_writer next))) + format\identity + tar) + (format.segment ..end_of_archive_size end_of_archive))))) (exception: .public (wrong_checksum {expected Nat} {actual Nat}) (exception.report @@ -851,14 +855,14 @@ (def: entry_parser (Parser Entry) ($_ <>.either - (\ <>.monad map (|>> #..Normal) + (\ <>.monad each (|>> #..Normal) (<>.either (..file_parser ..normal) (..file_parser ..old_normal))) - (\ <>.monad map (|>> #..Symbolic_Link) + (\ <>.monad each (|>> #..Symbolic_Link) (..file_name_parser ..symbolic_link (value@ #link_name))) - (\ <>.monad map (|>> #..Directory) + (\ <>.monad each (|>> #..Directory) (..file_name_parser ..directory (value@ #path))) - (\ <>.monad map (|>> #..Contiguous) + (\ <>.monad each (|>> #..Contiguous) (..file_parser ..contiguous)))) ... It's safe to implement the parser this way because the range of values for Nat is 2^64 @@ -886,5 +890,5 @@ (def: .public parser (Parser Tar) (|> (<>.some entry_parser) - (\ <>.monad map row.of_list) + (\ <>.monad each row.of_list) (<>.before ..end_of_archive_parser))) diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index 064476a7f..ef2c8e19a 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -35,8 +35,9 @@ (dictionary.empty name.hash)) (type: .public #rec XML - (#Text Text) - (#Node Tag Attrs (List XML))) + (Variant + (#Text Text) + (#Node Tag Attrs (List XML)))) (def: namespace_separator ":") @@ -72,7 +73,7 @@ (def: xml_char^ (Parser Text) - (<>.either (<text>.none_of ($_ text\compose "<>&" text.double_quote)) + (<>.either (<text>.none_of ($_ text\composite "<>&" text.double_quote)) xml_escape_char^)) (def: xml_identifier @@ -82,7 +83,7 @@ <text>.alpha) tail (<text>.some (<>.either (<text>.one_of "_.-") <text>.alpha_num))] - (in ($_ text\compose head tail)))) + (in ($_ text\composite head tail)))) (def: namespaced_symbol^ (Parser Name) @@ -113,7 +114,7 @@ (def: attrs^ (Parser Attrs) - (<| (\ <>.monad map (dictionary.of_list name.hash)) + (<| (\ <>.monad each (dictionary.of_list name.hash)) <>.some (<>.and (..spaced^ attr_name^)) (<>.after (<text>.this "=")) @@ -126,7 +127,7 @@ ..spaced^ (<>.after (<text>.this "/")) (<text>.enclosed ["<" ">"]))] - (<>.assertion ($_ text\compose "Close tag does not match open tag." text.new_line + (<>.assertion ($_ text\composite "Close tag does not match open tag." text.new_line "Expected: " (name\encoded expected) text.new_line " Actual: " (name\encoded actual) text.new_line) (name\= expected actual)))) @@ -157,7 +158,7 @@ (Parser XML) (|> (..spaced^ (<text>.many xml_char^)) (<>.either cdata^) - (<>\map (|>> #Text)))) + (<>\each (|>> #Text)))) (def: null^ (Parser Any) @@ -209,7 +210,7 @@ (-> Tag Text) (case namespace "" name - _ ($_ text\compose namespace ..namespace_separator name))) + _ ($_ text\composite namespace ..namespace_separator name))) (def: .public attribute (-> Attribute Text) @@ -219,8 +220,8 @@ Text (let [quote (: (-> Text Text) (function (_ value) - ($_ text\compose text.double_quote value text.double_quote)))] - ($_ text\compose + ($_ text\composite text.double_quote value text.double_quote)))] + ($_ text\composite "<?xml" " version=" (quote "1.0") " encoding=" (quote "UTF-8") @@ -234,11 +235,11 @@ (function (_ attrs) (|> attrs dictionary.entries - (list\map (function (_ [key value]) - ($_ text\compose (..attribute key) "=" text.double_quote (sanitize_value value) text.double_quote))) + (list\each (function (_ [key value]) + ($_ text\composite (..attribute key) "=" text.double_quote (sanitize_value value) text.double_quote))) (text.interposed " "))))] (function (_ input) - ($_ text\compose + ($_ text\composite ..xml_header text.new_line (loop [prefix "" input input] @@ -250,8 +251,8 @@ (let [tag (..tag xml_tag) attrs (if (dictionary.empty? xml_attrs) "" - ($_ text\compose " " (attributes xml_attrs)))] - ($_ text\compose + ($_ text\composite " " (attributes xml_attrs)))] + ($_ text\composite prefix "<" tag attrs ">" (sanitize_value value) "</" tag ">")) @@ -260,12 +261,12 @@ (let [tag (..tag xml_tag) attrs (if (dictionary.empty? xml_attrs) "" - ($_ text\compose " " (attributes xml_attrs)))] + ($_ text\composite " " (attributes xml_attrs)))] (if (list.empty? xml_children) - ($_ text\compose prefix "<" tag attrs "/>") - ($_ text\compose prefix "<" tag attrs ">" + ($_ text\composite prefix "<" tag attrs "/>") + ($_ text\composite prefix "<" tag attrs ">" (|> xml_children - (list\map (|>> (recur (text\compose prefix text.tab)) (text\compose text.new_line))) + (list\each (|>> (recur (text\composite prefix text.tab)) (text\composite text.new_line))) text.together) text.new_line prefix "</" tag ">"))))) )))) diff --git a/stdlib/source/library/lux/data/identity.lux b/stdlib/source/library/lux/data/identity.lux index 300c0cd7b..ac82be699 100644 --- a/stdlib/source/library/lux/data/identity.lux +++ b/stdlib/source/library/lux/data/identity.lux @@ -15,7 +15,7 @@ (implementation: .public functor (Functor Identity) - (def: map function.identity)) + (def: each function.identity)) (implementation: .public apply (Apply Identity) @@ -29,11 +29,11 @@ (def: &functor ..functor) (def: in function.identity) - (def: join function.identity)) + (def: conjoint function.identity)) (implementation: .public comonad (CoMonad Identity) (def: &functor ..functor) (def: out function.identity) - (def: split function.identity)) + (def: disjoint function.identity)) diff --git a/stdlib/source/library/lux/data/name.lux b/stdlib/source/library/lux/data/name.lux index 99d158095..bb0216ba5 100644 --- a/stdlib/source/library/lux/data/name.lux +++ b/stdlib/source/library/lux/data/name.lux @@ -48,7 +48,7 @@ (def: (encoded [module short]) (case module "" short - _ ($_ text\compose module ..separator short))) + _ ($_ text\composite module ..separator short))) (def: (decoded input) (case (text.all_split_by ..separator input) @@ -59,4 +59,4 @@ (#.Right [module short]) _ - (#.Left (text\compose "Invalid format for Name: " input))))) + (#.Left (text\composite "Invalid format for Name: " input))))) diff --git a/stdlib/source/library/lux/data/store.lux b/stdlib/source/library/lux/data/store.lux index a25331cd4..5fc594957 100644 --- a/stdlib/source/library/lux/data/store.lux +++ b/stdlib/source/library/lux/data/store.lux @@ -8,8 +8,9 @@ implicit]]]) (type: .public (Store s a) - {#cursor s - #peek (-> s a)}) + (Record + {#cursor s + #peek (-> s a)})) (def: (extend f wa) (All [s a b] (-> (-> (Store s a) b) (Store s a) (Store s b))) @@ -19,7 +20,7 @@ (implementation: .public functor (All [s] (Functor (Store s))) - (def: (map f fa) + (def: (each f fa) (extend (function (_ store) (f (\ store peek (\ store cursor)))) fa))) @@ -27,11 +28,14 @@ (implementation: .public comonad (All [s] (CoMonad (Store s))) - (def: &functor ..functor) + (def: &functor + ..functor) - (def: (out wa) (\\ peek (\\ cursor))) + (def: (out wa) + (\\ peek (\\ cursor))) - (def: split (extend id))) + (def: disjoint + (extend id))) (def: .public (peeks trans store) (All [s a] (-> (-> s s) (Store s a) a)) @@ -39,12 +43,12 @@ (def: .public (seek cursor store) (All [s a] (-> s (Store s a) (Store s a))) - (\ (\\ split store) peek cursor)) + (\ (\\ disjoint store) peek cursor)) (def: .public (seeks change store) (All [s a] (-> (-> s s) (Store s a) (Store s a))) - (|> store (\\ split) (peeks change))) + (|> store (\\ disjoint) (peeks change))) (def: .public (experiment Functor<f> change store) (All [f s a] (-> (Functor f) (-> s (f s)) (Store s a) (f a))) - (\ Functor<f> map (\\ peek) (change (\\ cursor)))) + (\ Functor<f> each (\\ peek) (change (\\ cursor)))) diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index 5a1b8a981..daf951a7d 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -248,7 +248,7 @@ (def: identity "") - (def: (compose left right) + (def: (composite left right) ("lux text concat" left right))) (implementation: .public hash @@ -288,7 +288,7 @@ (-> (List Text) Text) (let [(^open ".") ..monoid] (|>> list.reversed - (list\mix compose identity)))) + (list\mix composite identity)))) (def: .public (interposed separator texts) (-> Text (List Text) Text) diff --git a/stdlib/source/library/lux/data/text/format.lux b/stdlib/source/library/lux/data/text/format.lux index cd953ef05..11d1523e8 100644 --- a/stdlib/source/library/lux/data/text/format.lux +++ b/stdlib/source/library/lux/data/text/format.lux @@ -45,7 +45,7 @@ (implementation: .public functor (contravariant.Functor Format) - (def: (map f fb) + (def: (each f fb) (|>> f fb))) (syntax: .public (format [fragments (<>.many <code>.any)]) @@ -117,7 +117,7 @@ (def: .public (list formatter) (All [a] (-> (Format a) (Format (List a)))) - (|>> (list\map (|>> formatter (format " "))) + (|>> (list\each (|>> formatter (format " "))) text.together (text.enclosed ["(list" ")"]))) diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index fa822c33b..77d4e94e1 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -52,9 +52,9 @@ (-> Text (Parser Text)) (<>.after (<text>.this reference) (<>\in reference))) -(def: join_text^ +(def: together^ (-> (Parser (List Text)) (Parser Text)) - (\ <>.monad map //.together)) + (\ <>.monad each //.together)) (def: name_char^ (Parser Text) @@ -85,9 +85,9 @@ (def: re_range^ (Parser Code) (do {! <>.monad} - [from (|> regex_char^ (\ ! map (|>> (//.char 0) maybe.trusted))) + [from (|> regex_char^ (\ ! each (|>> (//.char 0) maybe.trusted))) _ (<text>.this "-") - to (|> regex_char^ (\ ! map (|>> (//.char 0) maybe.trusted)))] + to (|> regex_char^ (\ ! each (|>> (//.char 0) maybe.trusted)))] (in (` ((~! <text>.range) (~ (code.nat from)) (~ (code.nat to))))))) (def: re_char^ @@ -221,11 +221,11 @@ (in (` ((~! <>.else) "" (~ base)))) "*" - (in (` ((~! join_text^) ((~! <>.some) (~ base))))) + (in (` ((~! together^) ((~! <>.some) (~ base))))) ... "+" _ - (in (` ((~! join_text^) ((~! <>.many) (~ base))))) + (in (` ((~! together^) ((~! <>.many) (~ base))))) ))) (exception: .public (incorrect_quantification {from Nat} {to Nat}) @@ -243,19 +243,19 @@ [[from to] (<>.and number^ (<>.after (<text>.this ",") number^)) _ (<>.assertion (exception.error ..incorrect_quantification [from to]) (n.<= to from))] - (in (` ((~! join_text^) ((~! <>.between) - (~ (code.nat from)) - (~ (code.nat (n.- from to))) - (~ base)))))) + (in (` ((~! together^) ((~! <>.between) + (~ (code.nat from)) + (~ (code.nat (n.- from to))) + (~ base)))))) (do ! [limit (<>.after (<text>.this ",") number^)] - (in (` ((~! join_text^) ((~! <>.at_most) (~ (code.nat limit)) (~ base)))))) + (in (` ((~! together^) ((~! <>.at_most) (~ (code.nat limit)) (~ base)))))) (do ! [limit (<>.before (<text>.this ",") number^)] - (in (` ((~! join_text^) ((~! <>.at_least) (~ (code.nat limit)) (~ base)))))) + (in (` ((~! together^) ((~! <>.at_least) (~ (code.nat limit)) (~ base)))))) (do ! [limit number^] - (in (` ((~! join_text^) ((~! <>.exactly) (~ (code.nat limit)) (~ base)))))))))) + (in (` ((~! together^) ((~! <>.exactly) (~ (code.nat limit)) (~ base)))))))))) (def: (re_quantified^ current_module) (-> Text (Parser Code)) @@ -269,8 +269,9 @@ (re_simple^ current_module))) (type: Re_Group - #Non_Capturing - (#Capturing [(Maybe Text) Nat])) + (Variant + #Non_Capturing + (#Capturing [(Maybe Text) Nat]))) (def: (re_sequential^ capturing? re_scoped^ current_module) (-> Bit @@ -291,7 +292,7 @@ [idx names (list& (list g!temp complex - (` .let) (` [(~ g!total) (\ (~! //.monoid) (~' compose) (~ g!total) (~ g!temp))])) + (` .let) (` [(~ g!total) (\ (~! //.monoid) (~' composite) (~ g!total) (~ g!temp))])) steps)] (#.Right [(#Capturing [?name num_captures]) scoped]) @@ -307,7 +308,7 @@ [idx! (list& name! names) (list& (list name! scoped - (` .let) (` [(~ g!total) (\ (~! //.monoid) (~' compose) (~ g!total) (~ access))])) + (` .let) (` [(~ g!total) (\ (~! //.monoid) (~' composite) (~ g!total) (~ access))])) steps)]) ))) [0 @@ -319,7 +320,7 @@ 0) (` ((~! do) (~! <>.monad) [.let [(~ g!total) ""] - (~+ (|> steps list.reversed list\join))] + (~+ (|> steps list.reversed list\conjoint))] ((~ (' in)) [(~ g!total) (~+ (list.reversed names))])))]) )) @@ -374,12 +375,12 @@ tail (<>.some (<>.after (<text>.this "|") sub^))] (if (list.empty? tail) (in head) - (in [(list\mix n.max (product.left head) (list\map product.left tail)) + (in [(list\mix n.max (product.left head) (list\each product.left tail)) (` ($_ ((~ (if capturing? (` (~! |||^)) (` (~! |||_^))))) (~ (prep_alternative head)) - (~+ (list\map prep_alternative tail))))])))) + (~+ (list\each prep_alternative tail))))])))) (def: (re_scoped^ current_module) (-> Text (Parser [Re_Group Code])) @@ -407,7 +408,7 @@ (def: (regex^ current_module) (-> Text (Parser Code)) - (\ <>.monad map product.right (re_alternative^ #1 re_scoped^ current_module))) + (\ <>.monad each product.right (re_alternative^ #1 re_scoped^ current_module))) (syntax: .public (regex [pattern <code>.text]) (do meta.monad @@ -419,8 +420,7 @@ error)) (#try.Success regex) - (in (list regex)) - ))) + (in (list regex))))) (syntax: .public (^regex [[pattern bindings] (<code>.form (<>.and <code>.text (<>.maybe <code>.any))) body <code>.any diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux index 70087d56a..7c473d64d 100644 --- a/stdlib/source/library/lux/data/text/unicode/block.lux +++ b/stdlib/source/library/lux/data/text/unicode/block.lux @@ -26,7 +26,7 @@ (:abstraction (interval.between n.enum n\top n\bottom))) - (def: (compose left right) + (def: (composite left right) (let [left (:representation left) right (:representation right)] (:abstraction diff --git a/stdlib/source/library/lux/data/trace.lux b/stdlib/source/library/lux/data/trace.lux index 4b5da0b54..f07c533d9 100644 --- a/stdlib/source/library/lux/data/trace.lux +++ b/stdlib/source/library/lux/data/trace.lux @@ -8,28 +8,33 @@ function]]) (type: .public (Trace t a) - {#monoid (Monoid t) - #trace (-> t a)}) + (Record + {#monoid (Monoid t) + #trace (-> t a)})) -(implementation: .public functor (All [t] (Functor (Trace t))) - (def: (map f fa) - (revised@ #trace (compose f) fa))) +(implementation: .public functor + (All [t] (Functor (Trace t))) -(implementation: .public comonad (All [t] (CoMonad (Trace t))) + (def: (each f fa) + (revised@ #trace (composite f) fa))) + +(implementation: .public comonad + (All [t] (CoMonad (Trace t))) + (def: &functor ..functor) (def: (out wa) ((value@ #trace wa) (value@ [#monoid #monoid.identity] wa))) - (def: (split wa) + (def: (disjoint wa) (let [monoid (value@ #monoid wa)] {#monoid monoid #trace (function (_ t1) {#monoid monoid #trace (function (_ t2) ((value@ #trace wa) - (\ monoid compose t1 t2)))})}))) + (\ monoid composite t1 t2)))})}))) (def: .public (result context tracer) (All [t a] (-> t (Trace t a) a)) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index d033bd3f0..96ccfe30e 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -136,7 +136,7 @@ (`` (|>> (:as (array.Array Any)) <adaption> array.list - (list\map inspection) + (list\each inspection) (text.interposed " ") (text.enclosed ["[" "]"]))))) @@ -549,7 +549,7 @@ (<>.either (<>.and <code>.local_identifier (\ <>.monad in #.None)) (<code>.record (<>.and <code>.local_identifier - (\ <>.monad map (|>> #.Some) <code>.any))))) + (\ <>.monad each (|>> #.Some) <code>.any))))) (exception: .public (unknown_local_binding {name Text}) (exception.report @@ -573,25 +573,25 @@ #.End (|> environment dictionary.keys - (list\map (function (_ local) [local #.None])) + (list\each (function (_ local) [local #.None])) in) _ - (monad.map ! (function (_ [name format]) - (if (dictionary.key? environment name) - (in [name format]) - (function.constant (exception.except ..unknown_local_binding [name])))) - targets)))] + (monad.each ! (function (_ [name format]) + (if (dictionary.key? environment name) + (in [name format]) + (function.constant (exception.except ..unknown_local_binding [name])))) + targets)))] (in (list (` (..log! ("lux text concat" (~ (code.text (%.format (%.location location) text.new_line))) ((~! exception.report) - (~+ (list\map (function (_ [name format]) - (let [format (case format - #.None - (` (~! ..inspection)) - - (#.Some format) - format)] - (` [(~ (code.text name)) - ((~ format) (~ (code.local_identifier name)))]))) - targets)))))))))) + (~+ (list\each (function (_ [name format]) + (let [format (case format + #.None + (` (~! ..inspection)) + + (#.Some format) + format)] + (` [(~ (code.text name)) + ((~ format) (~ (code.local_identifier name)))]))) + targets)))))))))) diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index 4768a1975..35cebc0f4 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -33,8 +33,9 @@ ["." syntax]]]]]]]) (type: Fragment - (#Comment Text) - (#Code Code)) + (Variant + (#Comment Text) + (#Code Code))) (def: fragment (Parser Fragment) @@ -59,14 +60,14 @@ (^template [<tag>] [[[_ _ column] (<tag> members)] (|> members - (list\map reference_column) + (list\each reference_column) (list\mix n.min column))]) ([#.Form] [#.Tuple]) [[_ _ column] (#.Record pairs)] - (|> (list\compose (list\map (|>> product.left reference_column) pairs) - (list\map (|>> product.right reference_column) pairs)) + (|> (list\composite (list\each (|>> product.left reference_column) pairs) + (list\each (|>> product.right reference_column) pairs)) (list\mix n.min column)) )) @@ -187,7 +188,7 @@ (def: example_documentation (-> Example Code) - (|>> (list\map ..fragment_documentation) + (|>> (list\each ..fragment_documentation) (list.interposed ..blank_line) (text.interposed "") code.text)) @@ -242,19 +243,21 @@ (list (` (<| ((~! md.code)) ((~! %.format) (~+ (|> examples - (list\map ..example_documentation) + (list\each ..example_documentation) (list.interposed ..example_separator)))))))))) ))))) (type: .public Definition - {#definition Text - #documentation (Markdown Block)}) + (Record + {#definition Text + #documentation (Markdown Block)})) (type: .public #rec Module - {#module Text - #description Text - #expected (Set Text) - #definitions (List Definition)}) + (Record + {#module Text + #description Text + #expected (Set Text) + #definitions (List Definition)})) (syntax: .public (default [name ..qualified_identifier]) (let [[_ short] name] @@ -278,7 +281,7 @@ (|>> (list.sorted (function (_ left right) (text\< (value@ #definition right) (value@ #definition left)))) - (list\map (value@ #documentation)) + (list\each (value@ #documentation)) (list\mix md.then md.empty))) (def: expected_separator @@ -316,10 +319,10 @@ (~ (code.text name)) (~ description) (~ (code.text (|> expected - (list\map product.left) + (list\each product.left) ..expected_format))) ((~! list.together) (list (~+ definitions)))) - ($_ (\ (~! list.monoid) (~' compose)) + ($_ (\ (~! list.monoid) (~' composite)) (: (List Module) (\ (~! list.monoid) (~' identity))) (~+ subs))))))))) @@ -327,9 +330,9 @@ (def: listing (-> (List Text) (Markdown Block)) (|>> (list.sorted text\<) - (list\map (function (_ definition) - [(md.snippet definition) - #.None])) + (list\each (function (_ definition) + [(md.snippet definition) + #.None])) md.numbered_list)) (def: (module_documentation module) @@ -369,7 +372,7 @@ (case (|> module (value@ #definitions) (list.only (|>> (value@ #definition) (set.member? expected) not)) - (list\map (value@ #definition))) + (list\each (value@ #definition))) #.End md.empty @@ -383,7 +386,7 @@ (-> (List Module) Text) (|>> (list.sorted (function (_ left right) (text\< (value@ #module right) (value@ #module left)))) - (list\map ..module_documentation) + (list\each ..module_documentation) (list.interposed md.horizontal_rule) (list\mix md.then (: (Markdown Block) md.empty)) md.markdown)) diff --git a/stdlib/source/library/lux/extension.lux b/stdlib/source/library/lux/extension.lux index acc859dba..b63c91b0c 100644 --- a/stdlib/source/library/lux/extension.lux +++ b/stdlib/source/library/lux/extension.lux @@ -20,11 +20,12 @@ ["." phase]]]]]) (type: Declaration - {#name Code - #label Text - #phase Text - #archive Text - #inputs (List Code)}) + (Record + {#name Code + #label Text + #phase Text + #archive Text + #inputs (List Code)})) (def: (declaration default) (-> Code (Parser Declaration)) diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux index 6d8ed9658..38a207259 100644 --- a/stdlib/source/library/lux/ffi.js.lux +++ b/stdlib/source/library/lux/ffi.js.lux @@ -92,8 +92,9 @@ (type: Virtual_Method Common_Method) (type: Method - (#Static Static_Method) - (#Virtual Virtual_Method)) + (Variant + (#Static Static_Method) + (#Virtual Virtual_Method))) (def: common_method (Parser Common_Method) @@ -114,9 +115,10 @@ ..common_method))) (type: Member - (#Constructor Constructor) - (#Field Field) - (#Method Method)) + (Variant + (#Constructor Constructor) + (#Field Field) + (#Method Method))) (def: member (Parser Member) @@ -129,8 +131,8 @@ (def: input_variables (-> (List Nullable) (List [Bit Code])) (|>> list.enumeration - (list\map (function (_ [idx [nullable? type]]) - [nullable? (|> idx %.nat code.local_identifier)])))) + (list\each (function (_ [idx [nullable? type]]) + [nullable? (|> idx %.nat code.local_identifier)])))) (def: (nullable_type [nullable? type]) (-> Nullable Code) @@ -174,8 +176,9 @@ [Text (List Text)]) (type: Import - (#Class [Class_Declaration Text (List Member)]) - (#Function Static_Method)) + (Variant + (#Class [Class_Declaration Text (List Member)]) + (#Function Static_Method))) (def: class_declaration (Parser Class_Declaration) @@ -220,8 +223,8 @@ (-> Code Code Text (List Nullable) Bit Bit Nullable Code) (let [g!inputs (input_variables inputsT)] (` (def: ((~ g!method) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map nullable_type inputsT))] + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each nullable_type inputsT))] (~ (|> (nullable_type outputT) (try_type try?) (io_type io?)))) @@ -231,7 +234,7 @@ (without_null g!temp outputT) (` ("js apply" ("js constant" (~ (code.text source))) - (~+ (list\map (with_null g!temp) g!inputs))))))))))) + (~+ (list\each (with_null g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) {#.doc (example "Easily import types, methods, functions and constants." @@ -256,71 +259,71 @@ (text.replaced "#" class_name) (text.replaced "." member_name) code.local_identifier))) - class_parameters (list\map code.local_identifier class_parameters) + class_parameters (list\each code.local_identifier class_parameters) declaration (` ((~ (code.local_identifier class_name)) (~+ class_parameters))) real_class (text.replaced "/" "." class_name)] (in (list& (` (type: (~ declaration) (..Object (primitive (~ (code.text real_class)))))) - (list\map (function (_ member) - (case member - (#Constructor inputsT) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify "new")) - [(~+ (list\map product.right g!inputs))]) - (All [(~+ class_parameters)] - (-> [(~+ (list\map nullable_type inputsT))] - (~ declaration))) - (:expected - ("js object new" - ("js constant" (~ (code.text real_class))) - [(~+ (list\map (with_null g!temp) g!inputs))]))))) - - (#Field [static? field fieldT]) - (if static? - (` ((~! syntax:) ((~ (qualify field)) []) - (\ (~! meta.monad) (~' in) - (list (` (.:as (~ (nullable_type fieldT)) - ("js constant" (~ (code.text (%.format real_class "." field)))))))))) - (` (def: ((~ (qualify field)) - (~ g!object)) - (All [(~+ class_parameters)] - (-> (~ declaration) - (~ (nullable_type fieldT)))) - (:expected - (~ (without_null g!temp fieldT (` ("js object get" (~ (code.text field)) (~ g!object))))))))) - - (#Method method) - (case method - (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.else method alias)) - g!temp - (%.format real_class "." method) - inputsT - io? - try? - outputT) - - (#Virtual [method alias inputsT io? try? outputT]) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.else method alias))) - [(~+ (list\map product.right g!inputs))] - (~ g!object)) - (All [(~+ class_parameters)] - (-> [(~+ (list\map nullable_type inputsT))] - (~ declaration) - (~ (|> (nullable_type outputT) - (try_type try?) - (io_type io?))))) - (:expected - (~ (<| (with_io io?) - (with_try try?) - (without_null g!temp outputT) - (` ("js object do" - (~ (code.text method)) - (~ g!object) - [(~+ (list\map (with_null g!temp) g!inputs))]))))))))))) - members))))) + (list\each (function (_ member) + (case member + (#Constructor inputsT) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify "new")) + [(~+ (list\each product.right g!inputs))]) + (All [(~+ class_parameters)] + (-> [(~+ (list\each nullable_type inputsT))] + (~ declaration))) + (:expected + ("js object new" + ("js constant" (~ (code.text real_class))) + [(~+ (list\each (with_null g!temp) g!inputs))]))))) + + (#Field [static? field fieldT]) + (if static? + (` ((~! syntax:) ((~ (qualify field)) []) + (\ (~! meta.monad) (~' in) + (list (` (.:as (~ (nullable_type fieldT)) + ("js constant" (~ (code.text (%.format real_class "." field)))))))))) + (` (def: ((~ (qualify field)) + (~ g!object)) + (All [(~+ class_parameters)] + (-> (~ declaration) + (~ (nullable_type fieldT)))) + (:expected + (~ (without_null g!temp fieldT (` ("js object get" (~ (code.text field)) (~ g!object))))))))) + + (#Method method) + (case method + (#Static [method alias inputsT io? try? outputT]) + (..make_function (qualify (maybe.else method alias)) + g!temp + (%.format real_class "." method) + inputsT + io? + try? + outputT) + + (#Virtual [method alias inputsT io? try? outputT]) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify (maybe.else method alias))) + [(~+ (list\each product.right g!inputs))] + (~ g!object)) + (All [(~+ class_parameters)] + (-> [(~+ (list\each nullable_type inputsT))] + (~ declaration) + (~ (|> (nullable_type outputT) + (try_type try?) + (io_type io?))))) + (:expected + (~ (<| (with_io io?) + (with_try try?) + (without_null g!temp outputT) + (` ("js object do" + (~ (code.text method)) + (~ g!object) + [(~+ (list\each (with_null g!temp) g!inputs))]))))))))))) + members))))) (#Function [name alias inputsT io? try? outputT]) (in (list (..make_function (code.local_identifier (maybe.else name alias)) @@ -365,7 +368,7 @@ (~ g!_) (..constant (~ type) [(~ (code.local_identifier (%.format head "." next))) - (~+ (list\map code.local_identifier tail))]))))))))))) + (~+ (list\each code.local_identifier tail))]))))))))))) (template: (!defined? <constant>) (.case (..constant Any <constant>) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index 16c4887ab..d57bde2b1 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -178,131 +178,150 @@ "<init>") (type: Primitive_Mode - #ManualPrM - #AutoPrM) + (Variant + #ManualPrM + #AutoPrM)) (type: .public Privacy - #PublicP - #PrivateP - #ProtectedP - #DefaultP) + (Variant + #PublicP + #PrivateP + #ProtectedP + #DefaultP)) (type: .public State - #VolatileS - #FinalS - #DefaultS) + (Variant + #VolatileS + #FinalS + #DefaultS)) (type: .public Inheritance - #FinalI - #AbstractI - #DefaultI) + (Variant + #FinalI + #AbstractI + #DefaultI)) (type: Class_Kind - #Class - #Interface) + (Variant + #Class + #Interface)) -(type: StackFrame (primitive "java/lang/StackTraceElement")) -(type: StackTrace (array.Array StackFrame)) +(type: StackFrame + (primitive "java/lang/StackTraceElement")) + +(type: StackTrace + (array.Array StackFrame)) (type: Annotation_Parameter [Text Code]) (type: Annotation - {#ann_name Text - #ann_params (List Annotation_Parameter)}) + (Record + {#ann_name Text + #ann_params (List Annotation_Parameter)})) (type: Member_Declaration - {#member_name Text - #member_privacy Privacy - #member_anns (List Annotation)}) + (Record + {#member_name Text + #member_privacy Privacy + #member_anns (List Annotation)})) (type: FieldDecl - (#ConstantField (Type Value) Code) - (#VariableField State (Type Value))) + (Variant + (#ConstantField (Type Value) Code) + (#VariableField State (Type Value)))) (type: MethodDecl - {#method_tvars (List (Type Var)) - #method_inputs (List (Type Value)) - #method_output (Type Return) - #method_exs (List (Type Class))}) + (Record + {#method_tvars (List (Type Var)) + #method_inputs (List (Type Value)) + #method_output (Type Return) + #method_exs (List (Type Class))})) (type: Method_Definition - (#ConstructorMethod [Bit - (List (Type Var)) - Text - (List Argument) - (List (Typed Code)) - Code - (List (Type Class))]) - (#VirtualMethod [Bit - Bit + (Variant + (#ConstructorMethod [Bit + (List (Type Var)) + Text + (List Argument) + (List (Typed Code)) + Code + (List (Type Class))]) + (#VirtualMethod [Bit + Bit + (List (Type Var)) + Text + (List Argument) + (Type Return) + Code + (List (Type Class))]) + (#OverridenMethod [Bit + (Type Declaration) + (List (Type Var)) + Text + (List Argument) + (Type Return) + Code + (List (Type Class))]) + (#StaticMethod [Bit (List (Type Var)) - Text (List Argument) (Type Return) Code (List (Type Class))]) - (#OverridenMethod [Bit - (Type Declaration) - (List (Type Var)) - Text + (#AbstractMethod [(List (Type Var)) (List Argument) (Type Return) - Code (List (Type Class))]) - (#StaticMethod [Bit - (List (Type Var)) - (List Argument) - (Type Return) - Code - (List (Type Class))]) - (#AbstractMethod [(List (Type Var)) - (List Argument) - (Type Return) - (List (Type Class))]) - (#NativeMethod [(List (Type Var)) - (List Argument) - (Type Return) - (List (Type Class))])) + (#NativeMethod [(List (Type Var)) + (List Argument) + (Type Return) + (List (Type Class))]))) (type: Partial_Call - {#pc_method Name - #pc_args (List Code)}) + (Record + {#pc_method Name + #pc_args (List Code)})) (type: ImportMethodKind - #StaticIMK - #VirtualIMK) + (Variant + #StaticIMK + #VirtualIMK)) (type: ImportMethodCommons - {#import_member_mode Primitive_Mode - #import_member_alias Text - #import_member_kind ImportMethodKind - #import_member_tvars (List (Type Var)) - #import_member_args (List [Bit (Type Value)]) - #import_member_maybe? Bit - #import_member_try? Bit - #import_member_io? Bit}) + (Record + {#import_member_mode Primitive_Mode + #import_member_alias Text + #import_member_kind ImportMethodKind + #import_member_tvars (List (Type Var)) + #import_member_args (List [Bit (Type Value)]) + #import_member_maybe? Bit + #import_member_try? Bit + #import_member_io? Bit})) (type: ImportConstructorDecl - {}) + (Record{})) (type: ImportMethodDecl - {#import_method_name Text - #import_method_return (Type Return)}) + (Record + {#import_method_name Text + #import_method_return (Type Return)})) (type: ImportFieldDecl - {#import_field_mode Primitive_Mode - #import_field_name Text - #import_field_static? Bit - #import_field_maybe? Bit - #import_field_setter? Bit - #import_field_type (Type Value)}) + (Record + {#import_field_mode Primitive_Mode + #import_field_name Text + #import_field_static? Bit + #import_field_maybe? Bit + #import_field_setter? Bit + #import_field_type (Type Value)})) (type: Import_Member_Declaration - (#EnumDecl (List Text)) - (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl]) - (#MethodDecl [ImportMethodCommons ImportMethodDecl]) - (#FieldAccessDecl ImportFieldDecl)) + (Variant + (#EnumDecl (List Text)) + (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl]) + (#MethodDecl [ImportMethodCommons ImportMethodDecl]) + (#FieldAccessDecl ImportFieldDecl))) (def: (primitive_type mode type) (-> Primitive_Mode (Type Primitive) Code) @@ -354,7 +373,7 @@ [parser.upper? limit (parameter_type limit)] [parser.class? [name parameters] (` (.primitive (~ (code.text name)) - [(~+ (list\map parameter_type parameters))]))])) + [(~+ (list\each parameter_type parameters))]))])) ... else (undefined) ))) @@ -415,15 +434,15 @@ (case (f input) (^template [<tag>] [[meta (<tag> parts)] - [meta (<tag> (list\map (replaced f) parts))]]) + [meta (<tag> (list\each (replaced f) parts))]]) ([#.Form] [#.Tuple]) [meta (#.Record pairs)] - [meta (#.Record (list\map (: (-> [Code Code] [Code Code]) - (function (_ [key val]) - [(replaced f key) (replaced f val)])) - pairs))] + [meta (#.Record (list\each (: (-> [Code Code] [Code Code]) + (function (_ [key val]) + [(replaced f key) (replaced f val)])) + pairs))] ast' ast')) @@ -460,8 +479,8 @@ (<code>.tuple (<>.exactly (list.size arguments) <code>.any)))))] (in (` ("jvm member invoke constructor" (~ (code.text class_name)) (~+ (|> args - (list.zipped/2 (list\map product.right arguments)) - (list\map ..decorate_input)))))))) + (list.zipped/2 (list\each product.right arguments)) + (list\each ..decorate_input)))))))) (def: (static_method_parser class_name method_name arguments) (-> Text Text (List Argument) (Parser Code)) @@ -472,8 +491,8 @@ (<code>.tuple (<>.exactly (list.size arguments) <code>.any)))))] (in (` ("jvm member invoke static" (~ (code.text class_name)) (~ (code.text method_name)) (~+ (|> args - (list.zipped/2 (list\map product.right arguments)) - (list\map ..decorate_input)))))))) + (list.zipped/2 (list\each product.right arguments)) + (list\each ..decorate_input)))))))) (template [<name> <jvm_op>] [(def: (<name> class_name method_name arguments self_name) @@ -486,8 +505,8 @@ (in (` (<jvm_op> (~ (code.text class_name)) (~ (code.text method_name)) (~ (code.local_identifier self_name)) (~+ (|> args - (list.zipped/2 (list\map product.right arguments)) - (list\map ..decorate_input))))))))] + (list.zipped/2 (list\each product.right arguments)) + (list\each ..decorate_input))))))))] [special_method_parser "jvm member invoke special"] [virtual_method_parser "jvm member invoke virtual"] @@ -554,7 +573,7 @@ (not (text.contains? name.external_separator name))) _ (..assertion ..class_name_cannot_be_a_type_variable [name type_vars] (not (list.member? text.equivalence - (list\map parser.name type_vars) + (list\each parser.name type_vars) name)))] (in name))) @@ -580,7 +599,7 @@ (do <>.monad [name <code>.local_identifier _ (..assertion ..unexpected_type_variable [name type_vars] - (list.member? text.equivalence (list\map parser.name type_vars) name))] + (list.member? text.equivalence (list\each parser.name type_vars) name))] (in (type.var name)))) (def: wildcard^ @@ -595,7 +614,7 @@ (|>> (<>.after (<code>.this! (' <comparison>))) (<>.after ..wildcard^) <code>.tuple - (\ <>.monad map <constructor>)))] + (\ <>.monad each <constructor>)))] [upper^ < type.upper] [lower^ > type.lower] @@ -638,7 +657,7 @@ (def: array^ (-> (Parser (Type Value)) (Parser (Type Array))) (|>> <code>.tuple - (\ <>.monad map type.array))) + (\ <>.monad each type.array))) (def: (type^ type_vars) (-> (List (Type Var)) (Parser (Type Value))) @@ -663,7 +682,7 @@ (def: var^ (Parser (Type Var)) - (\ <>.monad map type.var <code>.local_identifier)) + (\ <>.monad each type.var <code>.local_identifier)) (def: vars^ (Parser (List (Type Var))) @@ -719,7 +738,7 @@ (-> (List (Type Var)) (Parser [Member_Declaration MethodDecl])) (<code>.form (do <>.monad [tvars (<>.else (list) ..vars^) - .let [total_vars (list\compose tvars type_vars)] + .let [total_vars (list\composite tvars type_vars)] name <code>.local_identifier anns ..annotations^ inputs (<code>.tuple (<>.some (..type^ total_vars))) @@ -777,7 +796,7 @@ [pm privacy_modifier^ strict_fp? (<>.parses? (<code>.this! (' #strict))) method_vars (<>.else (list) ..vars^) - .let [total_vars (list\compose class_vars method_vars)] + .let [total_vars (list\composite class_vars method_vars)] [_ self_name arguments] (<code>.form ($_ <>.and (<code>.this! (' new)) <code>.local_identifier @@ -798,7 +817,7 @@ strict_fp? (<>.parses? (<code>.this! (' #strict))) final? (<>.parses? (<code>.this! (' #final))) method_vars (<>.else (list) ..vars^) - .let [total_vars (list\compose class_vars method_vars)] + .let [total_vars (list\composite class_vars method_vars)] [name self_name arguments] (<code>.form ($_ <>.and <code>.local_identifier <code>.local_identifier @@ -818,8 +837,8 @@ [strict_fp? (<>.parses? (<code>.this! (' #strict))) owner_class ..declaration^ method_vars (<>.else (list) ..vars^) - .let [total_vars (list\compose (product.right (parser.declaration owner_class)) - method_vars)] + .let [total_vars (list\composite (product.right (parser.declaration owner_class)) + method_vars)] [name self_name arguments] (<code>.form ($_ <>.and <code>.local_identifier <code>.local_identifier @@ -944,7 +963,7 @@ [tvars (<>.else (list) ..vars^) _ (<code>.identifier! ["" "new"]) ?alias import_member_alias^ - .let [total_vars (list\compose owner_vars tvars)] + .let [total_vars (list\composite owner_vars tvars)] ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^] @@ -965,7 +984,7 @@ tvars (<>.else (list) ..vars^) name <code>.local_identifier ?alias import_member_alias^ - .let [total_vars (list\compose owner_vars tvars)] + .let [total_vars (list\composite owner_vars tvars)] ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^ @@ -1023,7 +1042,7 @@ (def: (annotation$ [name params]) (-> Annotation Code) - (` ((~ (code.text name)) (~+ (list\map annotation_parameter$ params))))) + (` ((~ (code.text name)) (~+ (list\each annotation_parameter$ params))))) (template [<name> <category>] [(def: <name> @@ -1046,10 +1065,10 @@ (-> [Member_Declaration MethodDecl] Code) (let [(^slots [#method_tvars #method_inputs #method_output #method_exs]) method_decl] (` ((~ (code.text name)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ method_tvars))] - [(~+ (list\map class$ method_exs))] - [(~+ (list\map value$ method_inputs))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ method_tvars))] + [(~+ (list\each class$ method_exs))] + [(~+ (list\each value$ method_inputs))] (~ (return$ method_output)))))) (def: (state_modifier$ sm) @@ -1064,7 +1083,7 @@ (case field (#ConstantField class value) (` ("constant" (~ (code.text name)) - [(~+ (list\map annotation$ anns))] + [(~+ (list\each annotation$ anns))] (~ (value$ class)) (~ value) )) @@ -1073,7 +1092,7 @@ (` ("variable" (~ (code.text name)) (~ (privacy_modifier$ pm)) (~ (state_modifier$ sm)) - [(~+ (list\map annotation$ anns))] + [(~+ (list\each annotation$ anns))] (~ (value$ class)) )) )) @@ -1090,23 +1109,23 @@ (-> External (Parser Code) (Type Class) (List [Member_Declaration FieldDecl]) [Member_Declaration Method_Definition] Code) (case method_def (#ConstructorMethod strict_fp? type_vars self_name arguments constructor_args body exs) - (let [replacer (|> (list\map (field->parser fully_qualified_class_name self_name) fields) + (let [replacer (|> (list\each (field->parser fully_qualified_class_name self_name) fields) (list\mix <>.either method_parser) parser->replacer)] (` ("init" (~ (privacy_modifier$ pm)) (~ (code.bit strict_fp?)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ type_vars))] - [(~+ (list\map class$ exs))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ type_vars))] + [(~+ (list\each class$ exs))] (~ (code.text self_name)) - [(~+ (list\map argument$ arguments))] - [(~+ (list\map constructor_arg$ constructor_args))] + [(~+ (list\each argument$ arguments))] + [(~+ (list\each constructor_arg$ constructor_args))] (~ (replaced replacer body)) ))) (#VirtualMethod final? strict_fp? type_vars self_name arguments return_type body exs) - (let [replacer (|> (list\map (field->parser fully_qualified_class_name self_name) fields) + (let [replacer (|> (list\each (field->parser fully_qualified_class_name self_name) fields) (list\mix <>.either method_parser) parser->replacer)] (` ("virtual" @@ -1114,16 +1133,16 @@ (~ (privacy_modifier$ pm)) (~ (code.bit final?)) (~ (code.bit strict_fp?)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ type_vars))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ type_vars))] (~ (code.text self_name)) - [(~+ (list\map argument$ arguments))] + [(~+ (list\each argument$ arguments))] (~ (return$ return_type)) - [(~+ (list\map class$ exs))] + [(~+ (list\each class$ exs))] (~ (replaced replacer body))))) (#OverridenMethod strict_fp? declaration type_vars self_name arguments return_type body exs) - (let [replacer (|> (list\map (field->parser fully_qualified_class_name self_name) fields) + (let [replacer (|> (list\each (field->parser fully_qualified_class_name self_name) fields) (list\mix <>.either method_parser) parser->replacer) super_replacer (parser->replacer (<code>.form (do <>.monad @@ -1134,18 +1153,18 @@ (~ (code.text name)) (~ (code.local_identifier self_name)) (~+ (|> args - (list.zipped/2 (list\map product.right arguments)) - (list\map ..decorate_input)))))))))] + (list.zipped/2 (list\each product.right arguments)) + (list\each ..decorate_input)))))))))] (` ("override" (~ (declaration$ declaration)) (~ (code.text name)) (~ (code.bit strict_fp?)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ type_vars))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ type_vars))] (~ (code.text self_name)) - [(~+ (list\map argument$ arguments))] + [(~+ (list\each argument$ arguments))] (~ (return$ return_type)) - [(~+ (list\map class$ exs))] + [(~+ (list\each class$ exs))] (~ (|> body (replaced replacer) (replaced super_replacer))) @@ -1157,31 +1176,31 @@ (~ (code.text name)) (~ (privacy_modifier$ pm)) (~ (code.bit strict_fp?)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ type_vars))] - [(~+ (list\map argument$ arguments))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ type_vars))] + [(~+ (list\each argument$ arguments))] (~ (return$ return_type)) - [(~+ (list\map class$ exs))] + [(~+ (list\each class$ exs))] (~ (replaced replacer body))))) (#AbstractMethod type_vars arguments return_type exs) (` ("abstract" (~ (code.text name)) (~ (privacy_modifier$ pm)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ type_vars))] - [(~+ (list\map argument$ arguments))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ type_vars))] + [(~+ (list\each argument$ arguments))] (~ (return$ return_type)) - [(~+ (list\map class$ exs))])) + [(~+ (list\each class$ exs))])) (#NativeMethod type_vars arguments return_type exs) (` ("native" (~ (code.text name)) (~ (privacy_modifier$ pm)) - [(~+ (list\map annotation$ anns))] - [(~+ (list\map var$ type_vars))] - [(~+ (list\map class$ exs))] - [(~+ (list\map argument$ arguments))] + [(~+ (list\each annotation$ anns))] + [(~+ (list\each var$ type_vars))] + [(~+ (list\each class$ exs))] + [(~+ (list\each argument$ arguments))] (~ (return$ return_type)))) )) @@ -1195,7 +1214,7 @@ (syntax: .public (class: [.let [! <>.monad] im inheritance_modifier^ - [full_class_name class_vars] (\ ! map parser.declaration ..declaration^) + [full_class_name class_vars] (\ ! each parser.declaration ..declaration^) super (<>.else $Object (class^ class_vars)) interfaces (<>.else (list) @@ -1207,28 +1226,28 @@ [.let [fully_qualified_class_name full_class_name method_parser (: (Parser Code) (|> methods - (list\map (method->parser fully_qualified_class_name)) + (list\each (method->parser fully_qualified_class_name)) (list\mix <>.either (<>.failure ""))))]] (in (list (` ("jvm class" (~ (declaration$ (type.declaration full_class_name class_vars))) (~ (class$ super)) - [(~+ (list\map class$ interfaces))] + [(~+ (list\each class$ interfaces))] (~ (inheritance_modifier$ im)) - [(~+ (list\map annotation$ annotations))] - [(~+ (list\map field_decl$ fields))] - [(~+ (list\map (method_def$ fully_qualified_class_name method_parser super fields) methods))])))))) + [(~+ (list\each annotation$ annotations))] + [(~+ (list\each field_decl$ fields))] + [(~+ (list\each (method_def$ fully_qualified_class_name method_parser super fields) methods))])))))) (syntax: .public (interface: [.let [! <>.monad] - [full_class_name class_vars] (\ ! map parser.declaration ..declaration^) + [full_class_name class_vars] (\ ! each parser.declaration ..declaration^) supers (<>.else (list) (<code>.tuple (<>.some (class^ class_vars)))) annotations ..annotations^ members (<>.some (..method_decl^ class_vars))]) (in (list (` ("jvm class interface" (~ (declaration$ (type.declaration full_class_name class_vars))) - [(~+ (list\map class$ supers))] - [(~+ (list\map annotation$ annotations))] - (~+ (list\map method_decl$ members))))))) + [(~+ (list\each class$ supers))] + [(~+ (list\each annotation$ annotations))] + (~+ (list\each method_decl$ members))))))) (syntax: .public (object [class_vars ..vars^ super (<>.else $Object @@ -1238,11 +1257,11 @@ constructor_args (..constructor_args^ class_vars) methods (<>.some ..overriden_method_def^)]) (in (list (` ("jvm class anonymous" - [(~+ (list\map var$ class_vars))] + [(~+ (list\each var$ class_vars))] (~ (class$ super)) - [(~+ (list\map class$ interfaces))] - [(~+ (list\map constructor_arg$ constructor_args))] - [(~+ (list\map (method_def$ "" (<>.failure "") super (list)) methods))]))))) + [(~+ (list\each class$ interfaces))] + [(~+ (list\each constructor_arg$ constructor_args))] + [(~+ (list\each (method_def$ "" (<>.failure "") super (list)) methods))]))))) (syntax: .public (null []) (in (list (` ("jvm object null"))))) @@ -1297,14 +1316,14 @@ methods (<>.some partial_call^)]) (with_identifiers [g!obj] (in (list (` (let [(~ g!obj) (~ obj)] - (exec (~+ (list\map (complete_call$ g!obj) methods)) + (exec (~+ (list\each (complete_call$ g!obj) methods)) (~ g!obj)))))))) (def: (class_import$ declaration) (-> (Type Declaration) Code) (let [[full_name params] (parser.declaration declaration) def_name (..internal full_name) - params' (list\map ..var$' params)] + params' (list\each ..var$' params)] (` (def: (~ (code.identifier ["" def_name])) {#..jvm_class (~ (code.text (..internal full_name)))} .Type @@ -1316,7 +1335,7 @@ (-> (List (Type Var)) Import_Member_Declaration (List (Type Var))) (case member (#ConstructorDecl [commons _]) - (list\compose class_tvars (value@ #import_member_tvars commons)) + (list\composite class_tvars (value@ #import_member_tvars commons)) (#MethodDecl [commons _]) (case (value@ #import_member_kind commons) @@ -1324,7 +1343,7 @@ (value@ #import_member_tvars commons) _ - (list\compose class_tvars (value@ #import_member_tvars commons))) + (list\composite class_tvars (value@ #import_member_tvars commons))) _ class_tvars)) @@ -1335,20 +1354,20 @@ (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) (let [(^slots [#import_member_tvars #import_member_args]) commons] (do {! meta.monad} - [arg_inputs (monad.map ! - (: (-> [Bit (Type Value)] (Meta [Bit Code])) - (function (_ [maybe? _]) - (with_identifiers [arg_name] - (in [maybe? arg_name])))) - import_member_args) - .let [input_jvm_types (list\map product.right import_member_args) - arg_types (list\map (: (-> [Bit (Type Value)] Code) - (function (_ [maybe? arg]) - (let [arg_type (value_type (value@ #import_member_mode commons) arg)] - (if maybe? - (` (Maybe (~ arg_type))) - arg_type)))) - import_member_args)]] + [arg_inputs (monad.each ! + (: (-> [Bit (Type Value)] (Meta [Bit Code])) + (function (_ [maybe? _]) + (with_identifiers [arg_name] + (in [maybe? arg_name])))) + import_member_args) + .let [input_jvm_types (list\each product.right import_member_args) + arg_types (list\each (: (-> [Bit (Type Value)] Code) + (function (_ [maybe? arg]) + (let [arg_type (value_type (value@ #import_member_mode commons) arg)] + (if maybe? + (` (Maybe (~ arg_type))) + arg_type)))) + import_member_args)]] (in [arg_inputs input_jvm_types arg_types]))) _ @@ -1467,13 +1486,13 @@ (-> Primitive_Mode (List (Type Value)) (List [Bit Code]) (List Code)) (|> inputs (list.zipped/2 classes) - (list\map (function (_ [class [maybe? input]]) - (|> (if maybe? - (` (: (.primitive (~ (code.text (..reflection class)))) - ((~! !!!) (~ (..un_quoted input))))) - (..un_quoted input)) - [class] - (with_automatic_input_conversion mode)))))) + (list\each (function (_ [class [maybe? input]]) + (|> (if maybe? + (` (: (.primitive (~ (code.text (..reflection class)))) + ((~! !!!) (~ (..un_quoted input))))) + (..un_quoted input)) + [class] + (with_automatic_input_conversion mode)))))) (def: (import_name format class member) (-> Text Text Text Text) @@ -1483,9 +1502,9 @@ (def: syntax_inputs (-> (List Code) (List Code)) - (|>> (list\map (function (_ name) - (list name (` (~! <code>.any))))) - list\join)) + (|>> (list\each (function (_ name) + (list name (` (~! <code>.any))))) + list\conjoint)) (def: (member_def_interop vars kind class [arg_function_inputs input_jvm_types arg_types] member method_prefix import_format) (-> (List (Type Var)) Class_Kind (Type Declaration) [(List [Bit Code]) (List (Type Value)) (List Code)] Import_Member_Declaration Text Text (Meta (List Code))) @@ -1499,7 +1518,7 @@ (` (primitive (~ (code.text full_name)))) _ - (let [=class_tvars (list\map ..var$' class_tvars)] + (let [=class_tvars (list\each ..var$' class_tvars)] (` (All [(~+ =class_tvars)] (primitive (~ (code.text full_name)) [(~+ =class_tvars)])))))) getter_interop (: (-> Text Code) (function (_ name) @@ -1507,7 +1526,7 @@ (` (def: (~ getter_name) (~ enum_type) (~ (get_static_field full_name name)))))))]] - (in (list\map getter_interop enum_members))) + (in (list\each getter_interop enum_members))) (#ConstructorDecl [commons _]) (do meta.monad @@ -1515,17 +1534,17 @@ def_name (code.identifier ["" (..import_name import_format method_prefix (value@ #import_member_alias commons))]) jvm_interop (|> [classT (` ("jvm member invoke constructor" - [(~+ (list\map ..var$ class_tvars))] + [(~+ (list\each ..var$ class_tvars))] (~ (code.text full_name)) - [(~+ (list\map ..var$ (value@ #import_member_tvars commons)))] + [(~+ (list\each ..var$ (value@ #import_member_tvars commons)))] (~+ (|> (jvm_invoke_inputs (value@ #import_member_mode commons) input_jvm_types arg_function_inputs) (list.zipped/2 input_jvm_types) - (list\map ..decorate_input)))))] + (list\each ..decorate_input)))))] (with_automatic_output_conversion (value@ #import_member_mode commons)) (with_return_maybe member true classT) (with_return_try member) (with_return_io member))]] - (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\map product.right arg_function_inputs)))]) + (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\each product.right arg_function_inputs)))]) ((~' in) (.list (.` (~ jvm_interop))))))))) (#MethodDecl [commons method]) @@ -1553,17 +1572,17 @@ method_return (value@ #import_method_return method) callC (: Code (` ((~ (code.text jvm_op)) - [(~+ (list\map ..var$ class_tvars))] + [(~+ (list\each ..var$ class_tvars))] (~ (code.text full_name)) (~ (code.text import_method_name)) - [(~+ (list\map ..var$ (value@ #import_member_tvars commons)))] + [(~+ (list\each ..var$ (value@ #import_member_tvars commons)))] (~+ (|> object_ast - (list\map ..un_quoted) + (list\each ..un_quoted) (list.zipped/2 (list (type.class full_name (list)))) - (list\map (with_automatic_input_conversion (value@ #import_member_mode commons))))) + (list\each (with_automatic_input_conversion (value@ #import_member_mode commons))))) (~+ (|> (jvm_invoke_inputs (value@ #import_member_mode commons) input_jvm_types arg_function_inputs) (list.zipped/2 input_jvm_types) - (list\map ..decorate_input)))))) + (list\each ..decorate_input)))))) jvm_interop (: Code (case (type.void? method_return) (#.Left method_return) @@ -1579,7 +1598,7 @@ (|> callC (with_return_try member) (with_return_io member))))]] - (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\map product.right arg_function_inputs))) + (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\each product.right arg_function_inputs))) (~+ (syntax_inputs object_ast))]) ((~' in) (.list (.` (~ jvm_interop)))))))))) @@ -1669,11 +1688,11 @@ (do {! meta.monad} [kind (class_kind declaration) =members (|> bundles - (list\map (function (_ [import_format members]) - (list\map (|>> [import_format]) members))) + (list\each (function (_ [import_format members]) + (list\each (|>> [import_format]) members))) list.together - (monad.map ! (member_import$ class_type_vars kind declaration)))] - (in (list& (class_import$ declaration) (list\join =members))))) + (monad.each ! (member_import$ class_type_vars kind declaration)))] + (in (list& (class_import$ declaration) (list\conjoint =members))))) (syntax: .public (array [type (..type^ (list)) size <code>.any]) @@ -1748,7 +1767,7 @@ (text\= array.type_name name) (case params (#.Item elementLT #.End) - (\ meta.monad map type.array + (\ meta.monad each type.array (lux_type->jvm_type elementLT)) _ @@ -1758,26 +1777,26 @@ (case params #.End (let [[_ unprefixed] (maybe.trusted (text.split_by descriptor.array_prefix name))] - (\ meta.monad map type.array + (\ meta.monad each type.array (lux_type->jvm_type (#.Primitive unprefixed (list))))) _ <failure>) ... else - (\ meta.monad map (type.class name) + (\ meta.monad each (type.class name) (: (Meta (List (Type Parameter))) - (monad.map meta.monad - (function (_ paramLT) - (do meta.monad - [paramJT (lux_type->jvm_type paramLT)] - (case (parser.parameter? paramJT) - (#.Some paramJT) - (in paramJT) - - #.None - <failure>))) - params))))) + (monad.each meta.monad + (function (_ paramLT) + (do meta.monad + [paramJT (lux_type->jvm_type paramLT)] + (case (parser.parameter? paramJT) + (#.Some paramJT) + (in paramJT) + + #.None + <failure>))) + params))))) (#.Apply A F) (case (lux_type.applied (list A) F) diff --git a/stdlib/source/library/lux/ffi.lua.lux b/stdlib/source/library/lux/ffi.lua.lux index 4d3f5aa26..3d14b554f 100644 --- a/stdlib/source/library/lux/ffi.lua.lux +++ b/stdlib/source/library/lux/ffi.lua.lux @@ -91,8 +91,9 @@ (type: Virtual_Method Common_Method) (type: Method - (#Static Static_Method) - (#Virtual Virtual_Method)) + (Variant + (#Static Static_Method) + (#Virtual Virtual_Method))) (def: common_method (Parser Common_Method) @@ -113,8 +114,9 @@ ..common_method))) (type: Member - (#Field Field) - (#Method Method)) + (Variant + (#Field Field) + (#Method Method))) (def: member (Parser Member) @@ -126,8 +128,8 @@ (def: input_variables (-> (List Nilable) (List [Bit Code])) (|>> list.enumeration - (list\map (function (_ [idx [nilable? type]]) - [nilable? (|> idx %.nat code.local_identifier)])))) + (list\each (function (_ [idx [nilable? type]]) + [nilable? (|> idx %.nat code.local_identifier)])))) (def: (nilable_type [nilable? type]) (-> Nilable Code) @@ -159,9 +161,10 @@ (.panic! "Nil is an invalid value!")))))) (type: Import - (#Class [Text Text (List Member)]) - (#Function Static_Method) - (#Constant Field)) + (Variant + (#Class [Text Text (List Member)]) + (#Function Static_Method) + (#Constant Field))) (def: import ($_ <>.or @@ -201,8 +204,8 @@ (-> Code Code Code (List Nilable) Bit Bit Nilable Code) (let [g!inputs (input_variables inputsT)] (` (def: ((~ g!method) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map nilable_type inputsT))] + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each nilable_type inputsT))] (~ (|> (nilable_type outputT) (try_type try?) (io_type io?)))) @@ -212,7 +215,7 @@ (without_nil g!temp outputT) (` ("lua apply" (:as ..Function (~ source)) - (~+ (list\map (with_nil g!temp) g!inputs))))))))))) + (~+ (list\each (with_nil g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) {#.doc (example "Easily import types, methods, functions and constants." @@ -241,54 +244,54 @@ (` ("lua import" (~ (code.text class)))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text real_class)))))) - (list\map (function (_ member) - (case member - (#Field [static? field fieldT]) - (if static? - (` ((~! syntax:) ((~ (qualify field)) []) - (\ (~! meta.monad) (~' in) - (list (` (.:as (~ (nilable_type fieldT)) - ("lua object get" (~ (code.text field)) - (:as (..Object .Any) (~ imported))))))))) - (` (def: ((~ (qualify field)) - (~ g!object)) - (-> (~ g!type) - (~ (nilable_type fieldT))) - (:expected - (~ (without_nil g!temp fieldT (` ("lua object get" (~ (code.text field)) - (:as (..Object .Any) (~ g!object)))))))))) - - (#Method method) - (case method - (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.else method alias)) - g!temp - (` ("lua object get" (~ (code.text method)) - (:as (..Object .Any) (~ imported)))) - inputsT - io? - try? - outputT) - - (#Virtual [method alias inputsT io? try? outputT]) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.else method alias))) - [(~+ (list\map product.right g!inputs))] - (~ g!object)) - (-> [(~+ (list\map nilable_type inputsT))] - (~ g!type) - (~ (|> (nilable_type outputT) - (try_type try?) - (io_type io?)))) - (:expected - (~ (<| (with_io io?) - (with_try try?) - (without_nil g!temp outputT) - (` ("lua object do" - (~ (code.text method)) - (~ g!object) - (~+ (list\map (with_nil g!temp) g!inputs))))))))))))) - members))))) + (list\each (function (_ member) + (case member + (#Field [static? field fieldT]) + (if static? + (` ((~! syntax:) ((~ (qualify field)) []) + (\ (~! meta.monad) (~' in) + (list (` (.:as (~ (nilable_type fieldT)) + ("lua object get" (~ (code.text field)) + (:as (..Object .Any) (~ imported))))))))) + (` (def: ((~ (qualify field)) + (~ g!object)) + (-> (~ g!type) + (~ (nilable_type fieldT))) + (:expected + (~ (without_nil g!temp fieldT (` ("lua object get" (~ (code.text field)) + (:as (..Object .Any) (~ g!object)))))))))) + + (#Method method) + (case method + (#Static [method alias inputsT io? try? outputT]) + (..make_function (qualify (maybe.else method alias)) + g!temp + (` ("lua object get" (~ (code.text method)) + (:as (..Object .Any) (~ imported)))) + inputsT + io? + try? + outputT) + + (#Virtual [method alias inputsT io? try? outputT]) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify (maybe.else method alias))) + [(~+ (list\each product.right g!inputs))] + (~ g!object)) + (-> [(~+ (list\each nilable_type inputsT))] + (~ g!type) + (~ (|> (nilable_type outputT) + (try_type try?) + (io_type io?)))) + (:expected + (~ (<| (with_io io?) + (with_try try?) + (without_nil g!temp outputT) + (` ("lua object do" + (~ (code.text method)) + (~ g!object) + (~+ (list\each (with_nil g!temp) g!inputs))))))))))))) + members))))) (#Function [name alias inputsT io? try? outputT]) (in (list (..make_function (code.local_identifier (maybe.else name alias)) diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index 9ec503f1b..496b4475c 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -70,161 +70,187 @@ (def: member_separator "::") ... Types -(type: JVM_Code Text) +(type: JVM_Code + Text) (type: BoundKind - #UpperBound - #LowerBound) + (Variant + #UpperBound + #LowerBound)) (type: #rec GenericType - (#GenericTypeVar Text) - (#GenericClass [Text (List GenericType)]) - (#GenericArray GenericType) - (#GenericWildcard (Maybe [BoundKind GenericType]))) + (Variant + (#GenericTypeVar Text) + (#GenericClass [Text (List GenericType)]) + (#GenericArray GenericType) + (#GenericWildcard (Maybe [BoundKind GenericType])))) (type: Type_Parameter [Text (List GenericType)]) (type: Primitive_Mode - #ManualPrM - #AutoPrM) + (Variant + #ManualPrM + #AutoPrM)) (type: .public Privacy - #PublicP - #PrivateP - #ProtectedP - #DefaultP) + (Variant + #PublicP + #PrivateP + #ProtectedP + #DefaultP)) (type: .public State - #VolatileS - #FinalS - #DefaultS) + (Variant + #VolatileS + #FinalS + #DefaultS)) (type: .public Inheritance - #FinalI - #AbstractI - #DefaultI) + (Variant + #FinalI + #AbstractI + #DefaultI)) (type: Class_Kind - #Class - #Interface) + (Variant + #Class + #Interface)) (type: Class_Declaration - {#class_name Text - #class_params (List Type_Parameter)}) + (Record + {#class_name Text + #class_params (List Type_Parameter)})) -(type: StackFrame (primitive "java/lang/StackTraceElement")) -(type: StackTrace (Array StackFrame)) +(type: StackFrame + (primitive "java/lang/StackTraceElement")) + +(type: StackTrace + (Array StackFrame)) (type: Super_Class_Decl - {#super_class_name Text - #super_class_params (List GenericType)}) + (Record + {#super_class_name Text + #super_class_params (List GenericType)})) (type: AnnotationParam [Text Code]) (type: Annotation - {#ann_name Text - #ann_params (List AnnotationParam)}) + (Record + {#ann_name Text + #ann_params (List AnnotationParam)})) (type: Member_Declaration - {#member_name Text - #member_privacy Privacy - #member_anns (List Annotation)}) + (Record + {#member_name Text + #member_privacy Privacy + #member_anns (List Annotation)})) (type: FieldDecl - (#ConstantField GenericType Code) - (#VariableField State GenericType)) + (Variant + (#ConstantField GenericType Code) + (#VariableField State GenericType))) (type: MethodDecl - {#method_tvars (List Type_Parameter) - #method_inputs (List GenericType) - #method_output GenericType - #method_exs (List GenericType)}) + (Record + {#method_tvars (List Type_Parameter) + #method_inputs (List GenericType) + #method_output GenericType + #method_exs (List GenericType)})) (type: ArgDecl - {#arg_name Text - #arg_type GenericType}) + (Record + {#arg_name Text + #arg_type GenericType})) (type: ConstructorArg [GenericType Code]) (type: Method_Definition - (#ConstructorMethod [Bit - (List Type_Parameter) - (List ArgDecl) - (List ConstructorArg) - Code - (List GenericType)]) - (#VirtualMethod [Bit - Bit + (Variant + (#ConstructorMethod [Bit + (List Type_Parameter) + (List ArgDecl) + (List ConstructorArg) + Code + (List GenericType)]) + (#VirtualMethod [Bit + Bit + (List Type_Parameter) + Text + (List ArgDecl) + GenericType + Code + (List GenericType)]) + (#OverridenMethod [Bit + Class_Declaration + (List Type_Parameter) + Text + (List ArgDecl) + GenericType + Code + (List GenericType)]) + (#StaticMethod [Bit (List Type_Parameter) - Text (List ArgDecl) GenericType Code (List GenericType)]) - (#OverridenMethod [Bit - Class_Declaration - (List Type_Parameter) - Text + (#AbstractMethod [(List Type_Parameter) (List ArgDecl) GenericType - Code (List GenericType)]) - (#StaticMethod [Bit - (List Type_Parameter) - (List ArgDecl) - GenericType - Code - (List GenericType)]) - (#AbstractMethod [(List Type_Parameter) - (List ArgDecl) - GenericType - (List GenericType)]) - (#NativeMethod [(List Type_Parameter) - (List ArgDecl) - GenericType - (List GenericType)])) + (#NativeMethod [(List Type_Parameter) + (List ArgDecl) + GenericType + (List GenericType)]))) (type: Partial_Call - {#pc_method Name - #pc_args (List Code)}) + (Record + {#pc_method Name + #pc_args (List Code)})) (type: ImportMethodKind - #StaticIMK - #VirtualIMK) + (Variant + #StaticIMK + #VirtualIMK)) (type: ImportMethodCommons - {#import_member_mode Primitive_Mode - #import_member_alias Text - #import_member_kind ImportMethodKind - #import_member_tvars (List Type_Parameter) - #import_member_args (List [Bit GenericType]) - #import_member_maybe? Bit - #import_member_try? Bit - #import_member_io? Bit}) + (Record + {#import_member_mode Primitive_Mode + #import_member_alias Text + #import_member_kind ImportMethodKind + #import_member_tvars (List Type_Parameter) + #import_member_args (List [Bit GenericType]) + #import_member_maybe? Bit + #import_member_try? Bit + #import_member_io? Bit})) (type: ImportConstructorDecl - {}) + (Record + {})) (type: ImportMethodDecl - {#import_method_name Text - #import_method_return GenericType}) + (Record + {#import_method_name Text + #import_method_return GenericType})) (type: ImportFieldDecl - {#import_field_mode Primitive_Mode - #import_field_name Text - #import_field_static? Bit - #import_field_maybe? Bit - #import_field_setter? Bit - #import_field_type GenericType}) + (Record + {#import_field_mode Primitive_Mode + #import_field_name Text + #import_field_static? Bit + #import_field_maybe? Bit + #import_field_setter? Bit + #import_field_type GenericType})) (type: Import_Member_Declaration - (#EnumDecl (List Text)) - (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl]) - (#MethodDecl [ImportMethodCommons ImportMethodDecl]) - (#FieldAccessDecl ImportFieldDecl)) + (Variant + (#EnumDecl (List Text)) + (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl]) + (#MethodDecl [ImportMethodCommons ImportMethodDecl]) + (#FieldAccessDecl ImportFieldDecl))) ... Utils (def: (manual_primitive_type class) @@ -284,7 +310,7 @@ [[name params] _ _] (let [name (safe name) - =params (list\map (class_type' mode type_params in_array?) params)] + =params (list\each (class_type' mode type_params in_array?) params)] (` (primitive (~ (code.text name)) [(~+ =params)]))))) (def: (class_type' mode type_params in_array? class) @@ -326,15 +352,15 @@ (def: (class_decl_type$ (^slots [#class_name #class_params])) (-> Class_Declaration Code) - (let [=params (list\map (: (-> Type_Parameter Code) - (function (_ [pname pbounds]) - (case pbounds - #.End - (code.identifier ["" pname]) - - (#.Item bound1 _) - (class_type #ManualPrM class_params bound1)))) - class_params)] + (let [=params (list\each (: (-> Type_Parameter Code) + (function (_ [pname pbounds]) + (case pbounds + #.End + (code.identifier ["" pname]) + + (#.Item bound1 _) + (class_type #ManualPrM class_params bound1)))) + class_params)] (` (primitive (~ (code.text (safe class_name))) [(~+ =params)])))) @@ -411,15 +437,15 @@ (case (f input) (^template [<tag>] [[meta (<tag> parts)] - [meta (<tag> (list\map (pre_walk_replace f) parts))]]) + [meta (<tag> (list\each (pre_walk_replace f) parts))]]) ([#.Form] [#.Tuple]) [meta (#.Record pairs)] - [meta (#.Record (list\map (: (-> [Code Code] [Code Code]) - (function (_ [key val]) - [(pre_walk_replace f key) (pre_walk_replace f val)])) - pairs))] + [meta (#.Record (list\each (: (-> [Code Code] [Code Code]) + (function (_ [key val]) + [(pre_walk_replace f key) (pre_walk_replace f val)])) + pairs))] ast' ast')) @@ -450,7 +476,7 @@ [args (: (Parser (List Code)) (<code>.form (<>.after (<code>.this! (' ::new!)) (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) - .let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]] + .let [arg_decls' (: (List Text) (list\each (|>> product.right (simple_class$ params)) arg_decls))]] (in (` ((~ (code.text (format "jvm new" ":" class_name ":" (text.interposed "," arg_decls')))) (~+ args)))))) @@ -461,7 +487,7 @@ args (: (Parser (List Code)) (<code>.form (<>.after (<code>.this! (code.identifier ["" dotted_name])) (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) - .let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]] + .let [arg_decls' (: (List Text) (list\each (|>> product.right (simple_class$ params)) arg_decls))]] (in (`' ((~ (code.text (format "jvm invokestatic" ":" class_name ":" method_name ":" (text.interposed "," arg_decls')))) (~+ args)))))) @@ -473,7 +499,7 @@ args (: (Parser (List Code)) (<code>.form (<>.after (<code>.this! (code.identifier ["" dotted_name])) (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) - .let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]] + .let [arg_decls' (: (List Text) (list\each (|>> product.right (simple_class$ params)) arg_decls))]] (in (`' ((~ (code.text (format <jvm_op> ":" class_name ":" method_name ":" (text.interposed "," arg_decls')))) (~' _jvm_this) (~+ args))))))] @@ -544,7 +570,7 @@ (do <>.monad [name <code>.local_identifier _ (no_periods_assertion name)] - (if (list.member? text.equivalence (list\map product.left type_vars) name) + (if (list.member? text.equivalence (list\each product.left type_vars) name) (in (#GenericTypeVar name)) (in (#GenericClass name (list))))) (<code>.tuple (do <>.monad @@ -569,7 +595,7 @@ _ (no_periods_assertion name) params (<>.some recur^) _ (<>.assertion (format name " cannot be a type-parameter!") - (not (list.member? text.equivalence (list\map product.left type_vars) name)))] + (not (list.member? text.equivalence (list\each product.left type_vars) name)))] (in (#GenericClass name params)))) )))) @@ -713,7 +739,7 @@ [pm privacy_modifier^ strict_fp? (<>.parses? (<code>.this! (' #strict))) method_vars ..type_params^ - .let [total_vars (list\compose class_vars method_vars)] + .let [total_vars (list\composite class_vars method_vars)] [_ arg_decls] (<code>.form (<>.and (<code>.this! (' new)) (..arg_decls^ total_vars))) constructor_args (..constructor_args^ total_vars) @@ -732,7 +758,7 @@ strict_fp? (<>.parses? (<code>.this! (' #strict))) final? (<>.parses? (<code>.this! (' #final))) method_vars ..type_params^ - .let [total_vars (list\compose class_vars method_vars)] + .let [total_vars (list\composite class_vars method_vars)] [name this_name arg_decls] (<code>.form ($_ <>.and <code>.local_identifier <code>.local_identifier @@ -755,7 +781,7 @@ [strict_fp? (<>.parses? (<code>.this! (' #strict))) owner_class ..class_decl^ method_vars ..type_params^ - .let [total_vars (list\compose (product.right owner_class) method_vars)] + .let [total_vars (list\composite (product.right owner_class) method_vars)] [name this_name arg_decls] (<code>.form ($_ <>.and <code>.local_identifier <code>.local_identifier @@ -879,7 +905,7 @@ [tvars ..type_params^ _ (<code>.this! (' new)) ?alias import_member_alias^ - .let [total_vars (list\compose owner_vars tvars)] + .let [total_vars (list\composite owner_vars tvars)] ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^] @@ -900,7 +926,7 @@ tvars ..type_params^ name <code>.local_identifier ?alias import_member_alias^ - .let [total_vars (list\compose owner_vars tvars)] + .let [total_vars (list\composite owner_vars tvars)] ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^ @@ -972,7 +998,7 @@ (def: (annotation$ [name params]) (-> Annotation JVM_Code) - (format "(" name " " "{" (text.interposed text.tab (list\map annotation_param$ params)) "}" ")")) + (format "(" name " " "{" (text.interposed text.tab (list\each annotation_param$ params)) "}" ")")) (def: (bound_kind$ kind) (-> BoundKind JVM_Code) @@ -987,7 +1013,7 @@ name (#GenericClass name params) - (format "(" (safe name) " " (spaced (list\map generic_type$ params)) ")") + (format "(" (safe name) " " (spaced (list\each generic_type$ params)) ")") (#GenericArray param) (format "(" array.type_name " " (generic_type$ param) ")") @@ -1000,25 +1026,25 @@ (def: (type_param$ [name bounds]) (-> Type_Parameter JVM_Code) - (format "(" name " " (spaced (list\map generic_type$ bounds)) ")")) + (format "(" name " " (spaced (list\each generic_type$ bounds)) ")")) (def: (class_decl$ (^open ".")) (-> Class_Declaration JVM_Code) - (format "(" (safe class_name) " " (spaced (list\map type_param$ class_params)) ")")) + (format "(" (safe class_name) " " (spaced (list\each type_param$ class_params)) ")")) (def: (super_class_decl$ (^slots [#super_class_name #super_class_params])) (-> Super_Class_Decl JVM_Code) - (format "(" (safe super_class_name) " " (spaced (list\map generic_type$ super_class_params)) ")")) + (format "(" (safe super_class_name) " " (spaced (list\each generic_type$ super_class_params)) ")")) (def: (method_decl$ [[name pm anns] method_decl]) (-> [Member_Declaration MethodDecl] JVM_Code) (let [(^slots [#method_tvars #method_inputs #method_output #method_exs]) method_decl] (with_parens (spaced (list name - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ method_tvars))) - (with_brackets (spaced (list\map generic_type$ method_exs))) - (with_brackets (spaced (list\map generic_type$ method_inputs))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ method_tvars))) + (with_brackets (spaced (list\each generic_type$ method_exs))) + (with_brackets (spaced (list\each generic_type$ method_inputs))) (generic_type$ method_output)) )))) @@ -1035,7 +1061,7 @@ (#ConstantField class value) (with_parens (spaced (list "constant" name - (with_brackets (spaced (list\map annotation$ anns))) + (with_brackets (spaced (list\each annotation$ anns))) (generic_type$ class) (code.format value)) )) @@ -1045,7 +1071,7 @@ (spaced (list "variable" name (privacy_modifier$ pm) (state_modifier$ sm) - (with_brackets (spaced (list\map annotation$ anns))) + (with_brackets (spaced (list\each annotation$ anns))) (generic_type$ class)) )) )) @@ -1068,11 +1094,11 @@ (spaced (list "init" (privacy_modifier$ pm) (bit\encoded strict_fp?) - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ type_vars))) - (with_brackets (spaced (list\map generic_type$ exs))) - (with_brackets (spaced (list\map arg_decl$ arg_decls))) - (with_brackets (spaced (list\map constructor_arg$ constructor_args))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ type_vars))) + (with_brackets (spaced (list\each generic_type$ exs))) + (with_brackets (spaced (list\each arg_decl$ arg_decls))) + (with_brackets (spaced (list\each constructor_arg$ constructor_args))) (code.format (pre_walk_replace replacer body)) ))) @@ -1083,10 +1109,10 @@ (privacy_modifier$ pm) (bit\encoded final?) (bit\encoded strict_fp?) - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ type_vars))) - (with_brackets (spaced (list\map generic_type$ exs))) - (with_brackets (spaced (list\map arg_decl$ arg_decls))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ type_vars))) + (with_brackets (spaced (list\each generic_type$ exs))) + (with_brackets (spaced (list\each arg_decl$ arg_decls))) (generic_type$ return_type) (code.format (pre_walk_replace replacer (` (let [(~ (code.local_identifier this_name)) (~' _jvm_this)] (~ body)))))))) @@ -1095,8 +1121,8 @@ (let [super_replacer (parser_replacer (<code>.form (do <>.monad [_ (<code>.this! (' ::super!)) args (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any)) - .let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ (list))) - arg_decls))]] + .let [arg_decls' (: (List Text) (list\each (|>> product.right (simple_class$ (list))) + arg_decls))]] (in (`' ((~ (code.text (format "jvm invokespecial" ":" (value@ #super_class_name super_class) ":" name @@ -1107,10 +1133,10 @@ (class_decl$ class_decl) name (bit\encoded strict_fp?) - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ type_vars))) - (with_brackets (spaced (list\map generic_type$ exs))) - (with_brackets (spaced (list\map arg_decl$ arg_decls))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ type_vars))) + (with_brackets (spaced (list\each generic_type$ exs))) + (with_brackets (spaced (list\each arg_decl$ arg_decls))) (generic_type$ return_type) (|> (` (let [(~ (code.local_identifier this_name)) (~' _jvm_this)] (~ body))) @@ -1125,10 +1151,10 @@ name (privacy_modifier$ pm) (bit\encoded strict_fp?) - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ type_vars))) - (with_brackets (spaced (list\map generic_type$ exs))) - (with_brackets (spaced (list\map arg_decl$ arg_decls))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ type_vars))) + (with_brackets (spaced (list\each generic_type$ exs))) + (with_brackets (spaced (list\each arg_decl$ arg_decls))) (generic_type$ return_type) (code.format (pre_walk_replace replacer body))))) @@ -1137,10 +1163,10 @@ (spaced (list "abstract" name (privacy_modifier$ pm) - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ type_vars))) - (with_brackets (spaced (list\map generic_type$ exs))) - (with_brackets (spaced (list\map arg_decl$ arg_decls))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ type_vars))) + (with_brackets (spaced (list\each generic_type$ exs))) + (with_brackets (spaced (list\each arg_decl$ arg_decls))) (generic_type$ return_type)))) (#NativeMethod type_vars arg_decls return_type exs) @@ -1148,10 +1174,10 @@ (spaced (list "native" name (privacy_modifier$ pm) - (with_brackets (spaced (list\map annotation$ anns))) - (with_brackets (spaced (list\map type_param$ type_vars))) - (with_brackets (spaced (list\map generic_type$ exs))) - (with_brackets (spaced (list\map arg_decl$ arg_decls))) + (with_brackets (spaced (list\each annotation$ anns))) + (with_brackets (spaced (list\each type_param$ type_vars))) + (with_brackets (spaced (list\each generic_type$ exs))) + (with_brackets (spaced (list\each arg_decl$ arg_decls))) (generic_type$ return_type)))) )) @@ -1209,19 +1235,19 @@ (do meta.monad [current_module meta.current_module_name .let [fully_qualified_class_name (format (safe current_module) "." full_class_name) - field_parsers (list\map (field_parser fully_qualified_class_name) fields) - method_parsers (list\map (method_parser (product.right class_decl) fully_qualified_class_name) methods) + field_parsers (list\each (field_parser fully_qualified_class_name) fields) + method_parsers (list\each (method_parser (product.right class_decl) fully_qualified_class_name) methods) replacer (parser_replacer (list\mix <>.either (<>.failure "") - (list\compose field_parsers method_parsers))) + (list\composite field_parsers method_parsers))) def_code (format "jvm class:" (spaced (list (class_decl$ class_decl) (super_class_decl$ super) - (with_brackets (spaced (list\map super_class_decl$ interfaces))) + (with_brackets (spaced (list\each super_class_decl$ interfaces))) (inheritance_modifier$ im) - (with_brackets (spaced (list\map annotation$ annotations))) - (with_brackets (spaced (list\map field_decl$ fields))) - (with_brackets (spaced (list\map (method_def$ replacer super) methods))))))]] + (with_brackets (spaced (list\each annotation$ annotations))) + (with_brackets (spaced (list\each field_decl$ fields))) + (with_brackets (spaced (list\each (method_def$ replacer super) methods))))))]] (in (list (` ((~ (code.text def_code)))))))) (syntax: .public (interface: [class_decl ..class_decl^ @@ -1235,9 +1261,9 @@ ([] 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))) - (with_brackets (spaced (list\map annotation$ annotations))) - (spaced (list\map method_decl$ members)))))] + (with_brackets (spaced (list\each super_class_decl$ supers))) + (with_brackets (spaced (list\each annotation$ annotations))) + (spaced (list\each method_decl$ members)))))] (in (list (` ((~ (code.text def_code)))))) )) @@ -1261,9 +1287,9 @@ )} (let [def_code (format "jvm anon-class:" (spaced (list (super_class_decl$ 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$ function.identity super) methods))))))] + (with_brackets (spaced (list\each super_class_decl$ interfaces))) + (with_brackets (spaced (list\each constructor_arg$ constructor_args))) + (with_brackets (spaced (list\each (method_def$ function.identity super) methods))))))] (in (list (` ((~ (code.text def_code)))))))) (syntax: .public (null []) @@ -1351,12 +1377,12 @@ (ClassName::method2 arg3 arg4 arg5)))} (with_identifiers [g!obj] (in (list (` (let [(~ g!obj) (~ obj)] - (exec (~+ (list\map (complete_call$ g!obj) methods)) + (exec (~+ (list\each (complete_call$ g!obj) methods)) (~ g!obj)))))))) (def: (class_import$ [full_name params]) (-> Class_Declaration Code) - (let [params' (list\map (|>> product.left code.local_identifier) params)] + (let [params' (list\each (|>> product.left code.local_identifier) params)] (` (def: (~ (code.identifier ["" full_name])) {#..jvm_class (~ (code.text full_name))} Type @@ -1368,7 +1394,7 @@ (-> (List Type_Parameter) Import_Member_Declaration (List Type_Parameter)) (case member (#ConstructorDecl [commons _]) - (list\compose class_tvars (value@ #import_member_tvars commons)) + (list\composite class_tvars (value@ #import_member_tvars commons)) (#MethodDecl [commons _]) (case (value@ #import_member_kind commons) @@ -1376,7 +1402,7 @@ (value@ #import_member_tvars commons) _ - (list\compose class_tvars (value@ #import_member_tvars commons))) + (list\composite class_tvars (value@ #import_member_tvars commons))) _ class_tvars)) @@ -1387,22 +1413,22 @@ (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) (let [(^slots [#import_member_tvars #import_member_args]) commons] (do {! meta.monad} - [arg_inputs (monad.map ! - (: (-> [Bit GenericType] (Meta [Bit Code])) - (function (_ [maybe? _]) - (with_identifiers [arg_name] - (in [maybe? arg_name])))) - import_member_args) + [arg_inputs (monad.each ! + (: (-> [Bit GenericType] (Meta [Bit Code])) + (function (_ [maybe? _]) + (with_identifiers [arg_name] + (in [maybe? arg_name])))) + import_member_args) .let [arg_classes (: (List Text) - (list\map (|>> product.right (simple_class$ (list\compose type_params import_member_tvars))) - import_member_args)) - arg_types (list\map (: (-> [Bit GenericType] Code) - (function (_ [maybe? arg]) - (let [arg_type (class_type (value@ #import_member_mode commons) type_params arg)] - (if maybe? - (` (Maybe (~ arg_type))) - arg_type)))) - import_member_args)]] + (list\each (|>> product.right (simple_class$ (list\composite type_params import_member_tvars))) + import_member_args)) + arg_types (list\each (: (-> [Bit GenericType] Code) + (function (_ [maybe? arg]) + (let [arg_type (class_type (value@ #import_member_mode commons) type_params arg)] + (if maybe? + (` (Maybe (~ arg_type))) + arg_type)))) + import_member_args)]] (in [arg_inputs arg_classes arg_types]))) _ @@ -1478,12 +1504,12 @@ (def: (jvm_extension_inputs mode classes inputs) (-> Primitive_Mode (List Text) (List [Bit Code]) (List Code)) (|> inputs - (list\map (function (_ [maybe? input]) - (if maybe? - (` ((~! !!!) (~ (un_quote input)))) - (un_quote input)))) + (list\each (function (_ [maybe? input]) + (if maybe? + (` ((~! !!!) (~ (un_quote input)))) + (un_quote input)))) (list.zipped/2 classes) - (list\map (auto_convert_input mode)))) + (list\each (auto_convert_input mode)))) (def: (import_name format class member) (-> Text Text Text Text) @@ -1493,9 +1519,9 @@ (def: syntax_inputs (-> (List Code) (List Code)) - (|>> (list\map (function (_ name) - (list name (` (~! <code>.any))))) - list\join)) + (|>> (list\each (function (_ name) + (list name (` (~! <code>.any))))) + list\conjoint)) (def: (member_def_interop type_params kind class [arg_function_inputs arg_classes arg_types] member method_prefix import_format) (-> (List Type_Parameter) Class_Kind Class_Declaration [(List [Bit Code]) (List Text) (List Code)] Import_Member_Declaration Text Text (Meta (List Code))) @@ -1503,7 +1529,7 @@ full_name (safe full_name) all_params (|> (member_type_vars class_tvars member) (list.only free_type_param?) - (list\map lux_type_parameter))] + (list\each lux_type_parameter))] (case member (#EnumDecl enum_members) (do {! meta.monad} @@ -1515,7 +1541,7 @@ _ (let [=class_tvars (|> class_tvars (list.only free_type_param?) - (list\map lux_type_parameter))] + (list\each lux_type_parameter))] (` (All [(~+ =class_tvars)] (primitive (~ (code.text full_name)) [(~+ =class_tvars)])))))) getter_interop (: (-> Text Code) (function (_ name) @@ -1523,7 +1549,7 @@ (` (def: (~ getter_name) (~ enum_type) ((~ (code.text (format "jvm getstatic" ":" full_name ":" name)))))))))]] - (in (list\map getter_interop enum_members))) + (in (list\each getter_interop enum_members))) (#ConstructorDecl [commons _]) (do meta.monad @@ -1534,7 +1560,7 @@ (decorate_return_maybe class member) (decorate_return_try member) (decorate_return_io member))]] - (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\map product.right arg_function_inputs)))]) + (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\each product.right arg_function_inputs)))]) ((~' in) (.list (.` (~ jvm_interop))))))))) (#MethodDecl [commons method]) @@ -1561,13 +1587,13 @@ ))) jvm_extension (code.text (format "jvm " jvm_op ":" full_name ":" import_method_name ":" (text.interposed "," arg_classes))) jvm_interop (|> [(simple_class$ (list) (value@ #import_method_return method)) - (` ((~ jvm_extension) (~+ (list\map un_quote object_ast)) + (` ((~ jvm_extension) (~+ (list\each un_quote object_ast)) (~+ (jvm_extension_inputs (value@ #import_member_mode commons) arg_classes arg_function_inputs))))] (auto_convert_output (value@ #import_member_mode commons)) (decorate_return_maybe class member) (decorate_return_try member) (decorate_return_io member))]] - (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\map product.right arg_function_inputs))) + (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\each product.right arg_function_inputs))) (~+ (syntax_inputs object_ast))]) ((~' in) (.list (.` (~ jvm_interop)))))))))) @@ -1582,7 +1608,7 @@ tvar_asts (: (List Code) (|> class_tvars (list.only free_type_param?) - (list\map lux_type_parameter))) + (list\each 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_identifiers [g!obj] @@ -1715,11 +1741,11 @@ (do {! meta.monad} [kind (class_kind class_decl) =members (|> bundles - (list\map (function (_ [import_format members]) - (list\map (|>> [import_format]) members))) + (list\each (function (_ [import_format members]) + (list\each (|>> [import_format]) members))) list.together - (monad.map ! (member_import$ (product.right class_decl) kind class_decl)))] - (in (list& (class_import$ class_decl) (list\join =members))))) + (monad.each ! (member_import$ (product.right class_decl) kind class_decl)))] + (in (list& (class_import$ class_decl) (list\conjoint =members))))) (syntax: .public (array [type (..generic_type^ (list)) size <code>.any]) diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux index 453f2c59e..82208f783 100644 --- a/stdlib/source/library/lux/ffi.php.lux +++ b/stdlib/source/library/lux/ffi.php.lux @@ -23,11 +23,11 @@ ["." code] ["." template]]]]) -(abstract: .public (Object brand) Any) +(abstract: .public (Object brand) {} Any) (template [<name>] [(with_expansions [<brand> (template.identifier [<name> "'"])] - (abstract: .public <brand> Any) + (abstract: .public <brand> {} Any) (type: .public <name> (..Object <brand>)))] @@ -97,8 +97,9 @@ (type: Virtual_Method Common_Method) (type: Method - (#Static Static_Method) - (#Virtual Virtual_Method)) + (Variant + (#Static Static_Method) + (#Virtual Virtual_Method))) (def: common_method (Parser Common_Method) @@ -119,8 +120,9 @@ ..common_method))) (type: Member - (#Field Field) - (#Method Method)) + (Variant + (#Field Field) + (#Method Method))) (def: member (Parser Member) @@ -132,8 +134,8 @@ (def: input_variables (-> (List Nullable) (List [Bit Code])) (|>> list.enumeration - (list\map (function (_ [idx [nullable? type]]) - [nullable? (|> idx %.nat code.local_identifier)])))) + (list\each (function (_ [idx [nullable? type]]) + [nullable? (|> idx %.nat code.local_identifier)])))) (def: (nullable_type [nullable? type]) (-> Nullable Code) @@ -165,9 +167,10 @@ (.panic! "Null is an invalid value!")))))) (type: Import - (#Class Text (Maybe Alias) Text (List Member)) - (#Function Static_Method) - (#Constant Field)) + (Variant + (#Class Text (Maybe Alias) Text (List Member)) + (#Function Static_Method) + (#Constant Field))) (def: import (Parser Import) @@ -219,8 +222,8 @@ (-> Code Code Code (List Nullable) Bit Bit Nullable Code) (let [g!inputs (input_variables inputsT)] (` (def: ((~ g!method) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map nullable_type inputsT))] + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each nullable_type inputsT))] (~ (|> (nullable_type outputT) (try_type try?) (io_type io?)))) @@ -230,7 +233,7 @@ (without_null g!temp outputT) (` ("php apply" (:as ..Function (~ source)) - (~+ (list\map (with_null g!temp) g!inputs))))))))))) + (~+ (list\each (with_null g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) (with_identifiers [g!temp] @@ -247,54 +250,54 @@ class_import (` ("php constant" (~ (code.text class))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text class)))))) - (list\map (function (_ member) - (case member - (#Field [static? field alias fieldT]) - (if static? - (` ((~! syntax:) ((~ (qualify (maybe.else field alias))) []) - (\ (~! meta.monad) (~' in) - (list (` (.:as (~ (nullable_type fieldT)) - ("php constant" (~ (code.text (%.format class "::" field)))))))))) - (` (def: ((~ (qualify field)) - (~ g!object)) - (-> (~ g!type) - (~ (nullable_type fieldT))) - (:expected - (~ (without_null g!temp fieldT (` ("php object get" (~ (code.text field)) - (:as (..Object .Any) (~ g!object)))))))))) - - (#Method method) - (case method - (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.else method alias)) - g!temp - (` ("php object get" (~ (code.text method)) - (:as (..Object .Any) - ("php constant" (~ (code.text (%.format class "::" method))))))) - inputsT - io? - try? - outputT) - - (#Virtual [method alias inputsT io? try? outputT]) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.else method alias))) - [(~+ (list\map product.right g!inputs))] - (~ g!object)) - (-> [(~+ (list\map nullable_type inputsT))] - (~ g!type) - (~ (|> (nullable_type outputT) - (try_type try?) - (io_type io?)))) - (:expected - (~ (<| (with_io io?) - (with_try try?) - (without_null g!temp outputT) - (` ("php object do" - (~ (code.text method)) - (~ g!object) - (~+ (list\map (with_null g!temp) g!inputs))))))))))))) - members))))) + (list\each (function (_ member) + (case member + (#Field [static? field alias fieldT]) + (if static? + (` ((~! syntax:) ((~ (qualify (maybe.else field alias))) []) + (\ (~! meta.monad) (~' in) + (list (` (.:as (~ (nullable_type fieldT)) + ("php constant" (~ (code.text (%.format class "::" field)))))))))) + (` (def: ((~ (qualify field)) + (~ g!object)) + (-> (~ g!type) + (~ (nullable_type fieldT))) + (:expected + (~ (without_null g!temp fieldT (` ("php object get" (~ (code.text field)) + (:as (..Object .Any) (~ g!object)))))))))) + + (#Method method) + (case method + (#Static [method alias inputsT io? try? outputT]) + (..make_function (qualify (maybe.else method alias)) + g!temp + (` ("php object get" (~ (code.text method)) + (:as (..Object .Any) + ("php constant" (~ (code.text (%.format class "::" method))))))) + inputsT + io? + try? + outputT) + + (#Virtual [method alias inputsT io? try? outputT]) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify (maybe.else method alias))) + [(~+ (list\each product.right g!inputs))] + (~ g!object)) + (-> [(~+ (list\each nullable_type inputsT))] + (~ g!type) + (~ (|> (nullable_type outputT) + (try_type try?) + (io_type io?)))) + (:expected + (~ (<| (with_io io?) + (with_try try?) + (without_null g!temp outputT) + (` ("php object do" + (~ (code.text method)) + (~ g!object) + (~+ (list\each (with_null g!temp) g!inputs))))))))))))) + members))))) (#Function [name alias inputsT io? try? outputT]) (let [imported (` ("php constant" (~ (code.text name))))] diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux index e3eea52e2..3dbd3cc5a 100644 --- a/stdlib/source/library/lux/ffi.py.lux +++ b/stdlib/source/library/lux/ffi.py.lux @@ -92,8 +92,9 @@ (type: Virtual_Method Common_Method) (type: Method - (#Static Static_Method) - (#Virtual Virtual_Method)) + (Variant + (#Static Static_Method) + (#Virtual Virtual_Method))) (def: common_method (Parser Common_Method) @@ -114,9 +115,10 @@ ..common_method))) (type: Member - (#Constructor Constructor) - (#Field Field) - (#Method Method)) + (Variant + (#Constructor Constructor) + (#Field Field) + (#Method Method))) (def: member (Parser Member) @@ -129,8 +131,8 @@ (def: input_variables (-> (List Noneable) (List [Bit Code])) (|>> list.enumeration - (list\map (function (_ [idx [noneable? type]]) - [noneable? (|> idx %.nat code.local_identifier)])))) + (list\each (function (_ [idx [noneable? type]]) + [noneable? (|> idx %.nat code.local_identifier)])))) (def: (noneable_type [noneable? type]) (-> Noneable Code) @@ -162,8 +164,9 @@ (.panic! "None is an invalid value!")))))) (type: Import - (#Class [Text Text (List Member)]) - (#Function Static_Method)) + (Variant + (#Class [Text Text (List Member)]) + (#Function Static_Method))) (def: import (Parser Import) @@ -201,8 +204,8 @@ (-> Code Code Code (List Noneable) Bit Bit Noneable Code) (let [g!inputs (input_variables inputsT)] (` (def: ((~ g!method) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map noneable_type inputsT))] + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each noneable_type inputsT))] (~ (|> (noneable_type outputT) (try_type try?) (io_type io?)))) @@ -212,7 +215,7 @@ (without_none g!temp outputT) (` ("python apply" (:as ..Function (~ source)) - (~+ (list\map (with_none g!temp) g!inputs))))))))))) + (~+ (list\each (with_none g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) {#.doc (example "Easily import types, methods, functions and constants." @@ -261,65 +264,65 @@ (` ("python import" (~ (code.text class)))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text real_class)))))) - (list\map (function (_ member) - (case member - (#Constructor inputsT) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify "new")) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map noneable_type inputsT))] - (~ g!type)) - (:expected - ("python apply" - (:as ..Function (~ imported)) - (~+ (list\map (with_none g!temp) g!inputs))))))) - - (#Field [static? field fieldT]) - (if static? - (` ((~! syntax:) ((~ (qualify field)) []) - (\ (~! meta.monad) (~' in) - (list (` (.:as (~ (noneable_type fieldT)) - ("python object get" (~ (code.text field)) - (:as (..Object .Any) (~ imported))))))))) - (` (def: ((~ (qualify field)) - (~ g!object)) - (-> (~ g!type) - (~ (noneable_type fieldT))) - (:expected - (~ (without_none g!temp fieldT (` ("python object get" (~ (code.text field)) - (:as (..Object .Any) (~ g!object)))))))))) - - (#Method method) - (case method - (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.else method alias)) - g!temp - (` ("python object get" (~ (code.text method)) - (:as (..Object .Any) (~ imported)))) - inputsT - io? - try? - outputT) - - (#Virtual [method alias inputsT io? try? outputT]) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.else method alias))) - [(~+ (list\map product.right g!inputs))] - (~ g!object)) - (-> [(~+ (list\map noneable_type inputsT))] - (~ g!type) - (~ (|> (noneable_type outputT) - (try_type try?) - (io_type io?)))) - (:expected - (~ (<| (with_io io?) - (with_try try?) - (without_none g!temp outputT) - (` ("python object do" - (~ (code.text method)) - (~ g!object) - (~+ (list\map (with_none g!temp) g!inputs))))))))))))) - members))))) + (list\each (function (_ member) + (case member + (#Constructor inputsT) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify "new")) + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each noneable_type inputsT))] + (~ g!type)) + (:expected + ("python apply" + (:as ..Function (~ imported)) + (~+ (list\each (with_none g!temp) g!inputs))))))) + + (#Field [static? field fieldT]) + (if static? + (` ((~! syntax:) ((~ (qualify field)) []) + (\ (~! meta.monad) (~' in) + (list (` (.:as (~ (noneable_type fieldT)) + ("python object get" (~ (code.text field)) + (:as (..Object .Any) (~ imported))))))))) + (` (def: ((~ (qualify field)) + (~ g!object)) + (-> (~ g!type) + (~ (noneable_type fieldT))) + (:expected + (~ (without_none g!temp fieldT (` ("python object get" (~ (code.text field)) + (:as (..Object .Any) (~ g!object)))))))))) + + (#Method method) + (case method + (#Static [method alias inputsT io? try? outputT]) + (..make_function (qualify (maybe.else method alias)) + g!temp + (` ("python object get" (~ (code.text method)) + (:as (..Object .Any) (~ imported)))) + inputsT + io? + try? + outputT) + + (#Virtual [method alias inputsT io? try? outputT]) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify (maybe.else method alias))) + [(~+ (list\each product.right g!inputs))] + (~ g!object)) + (-> [(~+ (list\each noneable_type inputsT))] + (~ g!type) + (~ (|> (noneable_type outputT) + (try_type try?) + (io_type io?)))) + (:expected + (~ (<| (with_io io?) + (with_try try?) + (without_none g!temp outputT) + (` ("python object do" + (~ (code.text method)) + (~ g!object) + (~+ (list\each (with_none g!temp) g!inputs))))))))))))) + members))))) (#Function [name alias inputsT io? try? outputT]) (in (list (..make_function (code.local_identifier (maybe.else name alias)) diff --git a/stdlib/source/library/lux/ffi.rb.lux b/stdlib/source/library/lux/ffi.rb.lux index c01b88565..2ba821582 100644 --- a/stdlib/source/library/lux/ffi.rb.lux +++ b/stdlib/source/library/lux/ffi.rb.lux @@ -99,8 +99,9 @@ (type: Virtual_Method Common_Method) (type: Method - (#Static Static_Method) - (#Virtual Virtual_Method)) + (Variant + (#Static Static_Method) + (#Virtual Virtual_Method))) (def: common_method (Parser Common_Method) @@ -121,8 +122,9 @@ ..common_method))) (type: Member - (#Field Field) - (#Method Method)) + (Variant + (#Field Field) + (#Method Method))) (def: member (Parser Member) @@ -134,8 +136,8 @@ (def: input_variables (-> (List Nilable) (List [Bit Code])) (|>> list.enumeration - (list\map (function (_ [idx [nilable? type]]) - [nilable? (|> idx %.nat code.local_identifier)])))) + (list\each (function (_ [idx [nilable? type]]) + [nilable? (|> idx %.nat code.local_identifier)])))) (def: (nilable_type [nilable? type]) (-> Nilable Code) @@ -167,9 +169,10 @@ (.panic! "Nil is an invalid value!")))))) (type: Import - (#Class Text (Maybe Alias) Text (List Member)) - (#Function Static_Method) - (#Constant Field)) + (Variant + (#Class Text (Maybe Alias) Text (List Member)) + (#Function Static_Method) + (#Constant Field))) (def: import (Parser [(Maybe Text) Import]) @@ -214,8 +217,8 @@ (-> Code Code Code (List Nilable) Bit Bit Nilable Code) (let [g!inputs (input_variables inputsT)] (` (def: ((~ g!method) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map nilable_type inputsT))] + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each nilable_type inputsT))] (~ (|> (nilable_type outputT) (try_type try?) (io_type io?)))) @@ -225,7 +228,7 @@ (without_nil g!temp outputT) (` ("ruby apply" (:as ..Function (~ source)) - (~+ (list\map (with_nil g!temp) g!inputs))))))))))) + (~+ (list\each (with_nil g!temp) g!inputs))))))))))) (syntax: .public (import: [[?module import] ..import]) {#.doc (example "Easily import types, methods, functions and constants." @@ -268,58 +271,58 @@ class_import (` ("ruby constant" (~ (code.text class))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text class)))))) - (list\map (function (_ member) - (case member - (#Field [static? field alias fieldT]) - (if static? - (` ((~! syntax:) ((~ (qualify (maybe.else field alias))) []) - (\ (~! meta.monad) (~' in) - (list (` (.:as (~ (nilable_type fieldT)) - (.exec - (~+ module_import) - ("ruby constant" (~ (code.text (%.format class "::" field))))))))))) - (` (def: ((~ (qualify field)) - (~ g!object)) - (-> (~ g!type) - (~ (nilable_type fieldT))) - (:expected - (~ (without_nil g!temp fieldT (` ("ruby object get" (~ (code.text field)) - (:as (..Object .Any) (~ g!object)))))))))) - - (#Method method) - (case method - (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.else method alias)) - g!temp - (` ("ruby object get" (~ (code.text method)) - (:as (..Object .Any) - (.exec - (~+ module_import) - ("ruby constant" (~ (code.text (%.format class "::" method)))))))) - inputsT - io? - try? - outputT) - - (#Virtual [method alias inputsT io? try? outputT]) - (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.else method alias))) - [(~+ (list\map product.right g!inputs))] - (~ g!object)) - (-> [(~+ (list\map nilable_type inputsT))] - (~ g!type) - (~ (|> (nilable_type outputT) - (try_type try?) - (io_type io?)))) - (:expected - (~ (<| (with_io io?) - (with_try try?) - (without_nil g!temp outputT) - (` ("ruby object do" - (~ (code.text method)) - (~ g!object) - (~+ (list\map (with_nil g!temp) g!inputs))))))))))))) - members))))) + (list\each (function (_ member) + (case member + (#Field [static? field alias fieldT]) + (if static? + (` ((~! syntax:) ((~ (qualify (maybe.else field alias))) []) + (\ (~! meta.monad) (~' in) + (list (` (.:as (~ (nilable_type fieldT)) + (.exec + (~+ module_import) + ("ruby constant" (~ (code.text (%.format class "::" field))))))))))) + (` (def: ((~ (qualify field)) + (~ g!object)) + (-> (~ g!type) + (~ (nilable_type fieldT))) + (:expected + (~ (without_nil g!temp fieldT (` ("ruby object get" (~ (code.text field)) + (:as (..Object .Any) (~ g!object)))))))))) + + (#Method method) + (case method + (#Static [method alias inputsT io? try? outputT]) + (..make_function (qualify (maybe.else method alias)) + g!temp + (` ("ruby object get" (~ (code.text method)) + (:as (..Object .Any) + (.exec + (~+ module_import) + ("ruby constant" (~ (code.text (%.format class "::" method)))))))) + inputsT + io? + try? + outputT) + + (#Virtual [method alias inputsT io? try? outputT]) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify (maybe.else method alias))) + [(~+ (list\each product.right g!inputs))] + (~ g!object)) + (-> [(~+ (list\each nilable_type inputsT))] + (~ g!type) + (~ (|> (nilable_type outputT) + (try_type try?) + (io_type io?)))) + (:expected + (~ (<| (with_io io?) + (with_try try?) + (without_nil g!temp outputT) + (` ("ruby object do" + (~ (code.text method)) + (~ g!object) + (~+ (list\each (with_nil g!temp) g!inputs))))))))))))) + members))))) (#Function [name alias inputsT io? try? outputT]) (let [imported (` (.exec diff --git a/stdlib/source/library/lux/ffi.scm.lux b/stdlib/source/library/lux/ffi.scm.lux index ab2e6cdff..675aadcd1 100644 --- a/stdlib/source/library/lux/ffi.scm.lux +++ b/stdlib/source/library/lux/ffi.scm.lux @@ -23,11 +23,11 @@ ["." code] ["." template]]]]) -(abstract: .public (Object brand) Any) +(abstract: .public (Object brand) {} Any) (template [<name>] [(with_expansions [<brand> (template.identifier [<name> "'"])] - (abstract: .public <brand> Any) + (abstract: .public <brand> {} Any) (type: .public <name> (..Object <brand>)))] @@ -106,8 +106,8 @@ (def: input_variables (-> (List Nilable) (List [Bit Code])) (|>> list.enumeration - (list\map (function (_ [idx [nilable? type]]) - [nilable? (|> idx %.nat code.local_identifier)])))) + (list\each (function (_ [idx [nilable? type]]) + [nilable? (|> idx %.nat code.local_identifier)])))) (def: (nilable_type [nilable? type]) (-> Nilable Code) @@ -139,8 +139,9 @@ (.panic! "Nil is an invalid value!")))))) (type: Import - (#Function Common_Method) - (#Constant Field)) + (Variant + (#Function Common_Method) + (#Constant Field))) (def: import (Parser Import) @@ -186,8 +187,8 @@ (-> Code Code Code (List Nilable) Bit Bit Nilable Code) (let [g!inputs (input_variables inputsT)] (` (def: ((~ g!method) - [(~+ (list\map product.right g!inputs))]) - (-> [(~+ (list\map nilable_type inputsT))] + [(~+ (list\each product.right g!inputs))]) + (-> [(~+ (list\each nilable_type inputsT))] (~ (|> (nilable_type outputT) (try_type try?) (io_type io?)))) @@ -197,7 +198,7 @@ (without_nil g!temp outputT) (` ("scheme apply" (:as ..Function (~ source)) - (~+ (list\map (with_nil g!temp) g!inputs))))))))))) + (~+ (list\each (with_nil g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) (with_identifiers [g!temp] diff --git a/stdlib/source/library/lux/locale.lux b/stdlib/source/library/lux/locale.lux index 39befd846..ac8c05384 100644 --- a/stdlib/source/library/lux/locale.lux +++ b/stdlib/source/library/lux/locale.lux @@ -28,10 +28,10 @@ (-> Language (Maybe Territory) (Maybe Encoding) Locale) (:abstraction (format (language.code language) (|> territory - (maybe\map (|>> territory.long_code (format ..territory_separator))) + (maybe\each (|>> territory.long_code (format ..territory_separator))) (maybe.else "")) (|> encoding - (maybe\map (|>> encoding.name (format ..encoding_separator))) + (maybe\each (|>> encoding.name (format ..encoding_separator))) (maybe.else ""))))) (def: .public code @@ -40,7 +40,7 @@ (def: .public hash (Hash Locale) - (\ hash.functor map ..code text.hash)) + (\ hash.functor each ..code text.hash)) (def: .public equivalence (Equivalence Locale) diff --git a/stdlib/source/library/lux/locale/language.lux b/stdlib/source/library/lux/locale/language.lux index 1739135aa..cb4314c59 100644 --- a/stdlib/source/library/lux/locale/language.lux +++ b/stdlib/source/library/lux/locale/language.lux @@ -15,8 +15,9 @@ (abstract: .public Language {} - {#name Text - #code Text} + (Record + {#name Text + #code Text}) (template [<name> <tag>] [(def: .public <name> diff --git a/stdlib/source/library/lux/locale/territory.lux b/stdlib/source/library/lux/locale/territory.lux index c4172993a..4b2dfd4b5 100644 --- a/stdlib/source/library/lux/locale/territory.lux +++ b/stdlib/source/library/lux/locale/territory.lux @@ -15,10 +15,11 @@ (abstract: .public Territory {} - {#name Text - #short Text - #long Text - #code Nat} + (Record + {#name Text + #short Text + #long Text + #code Nat}) (template [<name> <field> <type>] [(def: .public <name> diff --git a/stdlib/source/library/lux/macro.lux b/stdlib/source/library/lux/macro.lux index cdd76278b..f98f8c452 100644 --- a/stdlib/source/library/lux/macro.lux +++ b/stdlib/source/library/lux/macro.lux @@ -45,8 +45,8 @@ (do {! //.monad} [top_level_expansion ((:as Macro' macro) args)] (|> top_level_expansion - (monad.map //.monad expansion) - (\ ! map list\join))) + (monad.each //.monad expansion) + (\ ! each list\conjoint))) #.None (\ //.monad in (list syntax)))) @@ -64,39 +64,39 @@ (#.Some macro) (do //.monad [expansion ((:as Macro' macro) args) - expansion' (monad.map //.monad full_expansion expansion)] - (in (list\join expansion'))) + expansion' (monad.each //.monad full_expansion expansion)] + (in (list\conjoint expansion'))) #.None (do //.monad - [parts' (monad.map //.monad full_expansion (list& (code.identifier name) args))] - (in (list (code.form (list\join parts'))))))) + [parts' (monad.each //.monad full_expansion (list& (code.identifier name) args))] + (in (list (code.form (list\conjoint parts'))))))) [_ (#.Form (#.Item [harg targs]))] (do //.monad [harg+ (full_expansion harg) - targs+ (monad.map //.monad full_expansion targs)] - (in (list (code.form (list\compose harg+ (list\join (: (List (List Code)) targs+))))))) + targs+ (monad.each //.monad full_expansion targs)] + (in (list (code.form (list\composite harg+ (list\conjoint (: (List (List Code)) targs+))))))) [_ (#.Tuple members)] (do //.monad - [members' (monad.map //.monad full_expansion members)] - (in (list (code.tuple (list\join members'))))) + [members' (monad.each //.monad full_expansion members)] + (in (list (code.tuple (list\conjoint members'))))) [_ (#.Record members)] (|> members - (monad.map //.monad - (function (_ [left right]) - (do //.monad - [left (full_expansion left) - right (full_expansion right)] - (case [left right] - [(#.Item left #.End) (#.Item right #.End)] - (in [left right]) - - _ - (//.failure "Record members must expand into singletons."))))) - (\ //.monad map (|>> code.record list))) + (monad.each //.monad + (function (_ [left right]) + (do //.monad + [left (full_expansion left) + right (full_expansion right)] + (case [left right] + [(#.Item left #.End) (#.Item right #.End)] + (in [left right]) + + _ + (//.failure "Record members must expand into singletons."))))) + (\ //.monad each (|>> code.record list))) _ (\ //.monad in (list syntax)))) @@ -107,7 +107,7 @@ [id //.seed] (in (|> id (\ nat.decimal encoded) - ($_ text\compose "__gensym__" prefix) + ($_ text\composite "__gensym__" prefix) [""] code.identifier)))) (def: (local_identifier ast) @@ -117,22 +117,22 @@ (\ //.monad in name) _ - (//.failure (text\compose "Code is not a local identifier: " (code.format ast))))) + (//.failure (text\composite "Code is not a local identifier: " (code.format ast))))) (def: .public wrong_syntax_error (-> Name Text) (|>> name\encoded - (text.prefix (text\compose "Wrong syntax for " text.\'')) - (text.suffix (text\compose text.\'' ".")))) + (text.prefix (text\composite "Wrong syntax for " text.\'')) + (text.suffix (text\composite text.\'' ".")))) (macro: .public (with_identifiers tokens) (case tokens (^ (list [_ (#.Tuple identifiers)] body)) (do {! //.monad} - [identifier_names (monad.map ! ..local_identifier identifiers) - .let [identifier_defs (list\join (list\map (: (-> Text (List Code)) - (function (_ name) (list (code.identifier ["" name]) (` (..identifier (~ (code.text name))))))) - identifier_names))]] + [identifier_names (monad.each ! ..local_identifier identifiers) + .let [identifier_defs (list\conjoint (list\each (: (-> Text (List Code)) + (function (_ name) (list (code.identifier ["" name]) (` (..identifier (~ (code.text name))))))) + identifier_names))]] (in (list (` ((~! do) (~! //.monad) [(~+ identifier_defs)] (~ body)))))) @@ -171,9 +171,9 @@ (do //.monad [location //.location output (<func> token) - .let [_ ("lux io log" ($_ text\compose (name\encoded macro_name) " " (location.format location))) - _ (list\map (|>> code.format "lux io log") - output) + .let [_ ("lux io log" ($_ text\composite (name\encoded macro_name) " " (location.format location))) + _ (list\each (|>> code.format "lux io log") + output) _ ("lux io log" "")]] (in (if omit? (list) diff --git a/stdlib/source/library/lux/macro/code.lux b/stdlib/source/library/lux/macro/code.lux index 5de323722..b27e28c8c 100644 --- a/stdlib/source/library/lux/macro/code.lux +++ b/stdlib/source/library/lux/macro/code.lux @@ -108,17 +108,17 @@ (text.format value) [_ (#.Tag name)] - (text\compose "#" (\ name.codec encoded name)) + (text\composite "#" (\ name.codec encoded name)) (^template [<tag> <open> <close>] [[_ (<tag> members)] - ($_ text\compose + ($_ text\composite <open> (list\mix (function (_ next prev) (let [next (format next)] (if (text\= "" prev) next - ($_ text\compose prev " " next)))) + ($_ text\composite prev " " next)))) "" members) <close>)]) @@ -126,13 +126,13 @@ [#.Tuple "[" "]"]) [_ (#.Record pairs)] - ($_ text\compose + ($_ text\composite "{" (list\mix (function (_ [left right] prev) - (let [next ($_ text\compose (format left) " " (format right))] + (let [next ($_ text\composite (format left) " " (format right))] (if (text\= "" prev) next - ($_ text\compose prev " " next)))) + ($_ text\composite prev " " next)))) "" pairs) "}") @@ -145,15 +145,15 @@ (case ast (^template [<tag>] [[location (<tag> parts)] - [location (<tag> (list\map (replaced original substitute) parts))]]) + [location (<tag> (list\each (replaced original substitute) parts))]]) ([#.Form] [#.Tuple]) [location (#.Record parts)] - [location (#.Record (list\map (function (_ [left right]) - [(replaced original substitute left) - (replaced original substitute right)]) - parts))] + [location (#.Record (list\each (function (_ [left right]) + [(replaced original substitute left) + (replaced original substitute right)]) + parts))] _ ast))) diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux index d17ae7728..68e22410e 100644 --- a/stdlib/source/library/lux/macro/local.lux +++ b/stdlib/source/library/lux/macro/local.lux @@ -85,7 +85,7 @@ ("lux macro" (function (_ _) (do {! meta.monad} - [_ (monad.map ! ..pop_one macros) + [_ (monad.each ! ..pop_one macros) _ (..pop_one self) compiler meta.compiler_state] (in (case (value@ #.expected compiler) @@ -98,9 +98,9 @@ (def: .public (push macros) (-> (List [Name Macro]) (Meta Code)) (do meta.monad - [_ (monad.map meta.monad ..push_one macros) + [_ (monad.each meta.monad ..push_one macros) seed meta.seed 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)]))] + (..push_one [g!pop (..pop_all (list\each product.left macros) g!pop)]))] (in (` ((~ g!pop)))))) diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index 4caed5bd7..c77d67feb 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -31,7 +31,7 @@ (#try.Success [tokens output]) (#try.Failure error) - (#try.Failure ($_ text\compose + (#try.Failure ($_ text\composite "Failed to parse: " (code.format binding) text.new_line error))))) @@ -73,22 +73,22 @@ [_ (if (|> args list.size nat.even?) (in []) (meta.failure "Syntax pattern expects pairs of bindings and code-parsers.")) - vars+parsers (monad.map ! - (: (-> [Code Code] (Meta [Code Code])) - (function (_ [var parser]) - (with_expansions [<default> (in [var - (` ((~! ..self_documenting) (' (~ var)) - (~ parser)))])] - (case var - [_ (#.Identifier ["" _])] - <default> + vars+parsers (monad.each ! + (: (-> [Code Code] (Meta [Code Code])) + (function (_ [var parser]) + (with_expansions [<default> (in [var + (` ((~! ..self_documenting) (' (~ var)) + (~ parser)))])] + (case var + [_ (#.Identifier ["" _])] + <default> - [_ (#.Identifier _)] - (in [var parser]) + [_ (#.Identifier _)] + (in [var parser]) - _ - <default>)))) - (list.pairs args)) + _ + <default>)))) + (list.pairs args)) this_module meta.current_module_name .let [g!state (code.identifier ["" "*lux*"]) error_msg (code.text (macro.wrong_syntax_error [this_module name]))]] diff --git a/stdlib/source/library/lux/macro/syntax/annotations.lux b/stdlib/source/library/lux/macro/syntax/annotations.lux index 29ef222c2..acfaabd37 100644 --- a/stdlib/source/library/lux/macro/syntax/annotations.lux +++ b/stdlib/source/library/lux/macro/syntax/annotations.lux @@ -31,7 +31,7 @@ (def: .public format (-> Annotations Code) (let [entry (product.then code.tag function.identity)] - (|>> (list\map entry) + (|>> (list\each entry) code.record))) (def: .public parser diff --git a/stdlib/source/library/lux/macro/syntax/check.lux b/stdlib/source/library/lux/macro/syntax/check.lux index 8c045da18..18b0049ee 100644 --- a/stdlib/source/library/lux/macro/syntax/check.lux +++ b/stdlib/source/library/lux/macro/syntax/check.lux @@ -18,8 +18,9 @@ "lux check") (type: .public Check - {#type Code - #value Code}) + (Record + {#type Code + #value Code})) (def: .public equivalence (Equivalence Check) diff --git a/stdlib/source/library/lux/macro/syntax/declaration.lux b/stdlib/source/library/lux/macro/syntax/declaration.lux index 004398916..ae6ae3ee7 100644 --- a/stdlib/source/library/lux/macro/syntax/declaration.lux +++ b/stdlib/source/library/lux/macro/syntax/declaration.lux @@ -15,8 +15,9 @@ ["." code]]]]) (type: .public Declaration - {#name Text - #arguments (List Text)}) + (Record + {#name Text + #arguments (List Text)})) (def: .public equivalence (Equivalence Declaration) @@ -40,4 +41,4 @@ g!name arguments - (` ((~ g!name) (~+ (list\map code.local_identifier arguments))))))) + (` ((~ g!name) (~+ (list\each code.local_identifier arguments))))))) diff --git a/stdlib/source/library/lux/macro/syntax/definition.lux b/stdlib/source/library/lux/macro/syntax/definition.lux index 601f44283..ee7238603 100644 --- a/stdlib/source/library/lux/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/macro/syntax/definition.lux @@ -26,11 +26,12 @@ ["#." check (#+ Check)]]) (type: .public Definition - {#name Text - #value (Either Check - Code) - #anns Annotations - #export? Bit}) + (Record + {#name Text + #value (Either Check + Code) + #anns Annotations + #export? Bit})) (def: .public equivalence (Equivalence Definition) diff --git a/stdlib/source/library/lux/macro/syntax/input.lux b/stdlib/source/library/lux/macro/syntax/input.lux index 58675bbf7..47bf4d6ac 100644 --- a/stdlib/source/library/lux/macro/syntax/input.lux +++ b/stdlib/source/library/lux/macro/syntax/input.lux @@ -12,8 +12,9 @@ ["." code]]]]) (type: .public Input - {#binding Code - #type Code}) + (Record + {#binding Code + #type Code})) (def: .public equivalence (Equivalence Input) diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index aea5bfb5c..65b4f96ba 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -36,12 +36,12 @@ body <code>.any]) (do {! meta.monad} [g!locals (|> locals - (list\map //.identifier) + (list\each //.identifier) (monad.all !))] (in (list (` (.with_expansions [(~+ (|> (list.zipped/2 locals g!locals) - (list\map (function (_ [name identifier]) - (list (code.local_identifier name) (as_is identifier)))) - list\join))] + (list\each (function (_ [name identifier]) + (list (code.local_identifier name) (as_is identifier)))) + list\conjoint))] (~ body))))))) (def: (name_side module_side? parser) @@ -68,11 +68,11 @@ full_tag (<>.either <code>.local_tag full_tag)) - (<>\map bit\encoded <code>.bit) - (<>\map nat\encoded <code>.nat) - (<>\map int\encoded <code>.int) - (<>\map rev\encoded <code>.rev) - (<>\map frac\encoded <code>.frac) + (<>\each bit\encoded <code>.bit) + (<>\each nat\encoded <code>.nat) + (<>\each int\encoded <code>.int) + (<>\each rev\encoded <code>.rev) + (<>\each frac\encoded <code>.frac) ))) (def: (part module_side?) @@ -113,24 +113,25 @@ (^template [<tag>] [[meta (<tag> elems)] - [meta (<tag> (list\map (applied env) elems))]]) + [meta (<tag> (list\each (applied env) elems))]]) ([#.Tuple] [#.Form]) [meta (#.Record members)] - [meta (#.Record (list\map (: (-> [Code Code] [Code Code]) - (function (_ [key value]) - [(applied env key) - (applied env value)])) - members))] + [meta (#.Record (list\each (: (-> [Code Code] [Code Code]) + (function (_ [key value]) + [(applied env key) + (applied env value)])) + members))] _ template)) (type: Local - {#name Text - #parameters (List Text) - #template (List Code)}) + (Record + {#name Text + #parameters (List Text) + #template (List Code)})) (exception: .public (irregular_arguments {expected Nat} {actual Nat}) (exception.report @@ -147,7 +148,7 @@ (.let [environment (: Environment (|> (list.zipped/2 parameters inputs) (dictionary.of_list text.hash)))] - (#.Right [compiler (list\map (..applied environment) template)])) + (#.Right [compiler (list\each (..applied environment) template)])) (exception.except ..irregular_arguments [parameters_amount inputs_amount])))))) (def: local @@ -172,10 +173,10 @@ (#.Some _) true)]))) - g!pop (local.push (list\map (function (_ local) - [[here_name (value@ #name local)] - (..macro local)]) - locals))] + g!pop (local.push (list\each (function (_ local) + [[here_name (value@ #name local)] + (..macro local)]) + locals))] (if expression? (//.with_identifiers [g!body] (in (list (` (.let [(~ g!body) (~ body)] diff --git a/stdlib/source/library/lux/math/infix.lux b/stdlib/source/library/lux/math/infix.lux index d2a210e7b..c2847d72e 100644 --- a/stdlib/source/library/lux/math/infix.lux +++ b/stdlib/source/library/lux/math/infix.lux @@ -19,22 +19,23 @@ ["i" int]]]]]) (type: #rec Infix - (#Const Code) - (#Call (List Code)) - (#Unary Code Infix) - (#Binary Infix Code Infix)) + (Variant + (#Const Code) + (#Call (List Code)) + (#Unary Code Infix) + (#Binary Infix Code 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))) + (<>\each code.bit <code>.bit) + (<>\each code.nat <code>.nat) + (<>\each code.int <code>.int) + (<>\each code.rev <code>.rev) + (<>\each code.frac <code>.frac) + (<>\each code.text <code>.text) + (<>\each code.identifier <code>.identifier) + (<>\each code.tag <code>.tag))) (def: expression (Parser Infix) diff --git a/stdlib/source/library/lux/math/logic/continuous.lux b/stdlib/source/library/lux/math/logic/continuous.lux index 6f7e4d116..57f3572b5 100644 --- a/stdlib/source/library/lux/math/logic/continuous.lux +++ b/stdlib/source/library/lux/math/logic/continuous.lux @@ -20,7 +20,7 @@ (Monoid Rev) (def: identity <identity>) - (def: compose <name>))] + (def: composite <name>))] [or /.max disjunction ..false] [and /.min conjunction ..true] diff --git a/stdlib/source/library/lux/math/logic/fuzzy.lux b/stdlib/source/library/lux/math/logic/fuzzy.lux index 5a21a6e39..4c3745470 100644 --- a/stdlib/source/library/lux/math/logic/fuzzy.lux +++ b/stdlib/source/library/lux/math/logic/fuzzy.lux @@ -22,7 +22,7 @@ (implementation: .public functor (contravariant.Functor Fuzzy) - (def: (map f fb) + (def: (each f fb) (|>> f fb))) (template [<name> <verdict>] diff --git a/stdlib/source/library/lux/math/modular.lux b/stdlib/source/library/lux/math/modular.lux index 9a94151c4..acfdbab2d 100644 --- a/stdlib/source/library/lux/math/modular.lux +++ b/stdlib/source/library/lux/math/modular.lux @@ -30,8 +30,9 @@ (abstract: .public (Mod m) {} - {#modulus (Modulus m) - #value Int} + (Record + {#modulus (Modulus m) + #value Int}) (def: .public (modular modulus value) (All [%] (-> (Modulus %) Int (Mod %))) @@ -66,7 +67,7 @@ (def: (encoded modular) (let [[_ value] (:representation modular)] - ($_ text\compose + ($_ text\composite (i\encoded value) ..separator (i\encoded (//.divisor expected))))) @@ -125,7 +126,7 @@ (def: identity (..modular modulus <identity>)) - (def: compose + (def: composite <composition>))] [..+ +0 addition] diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux index 324b84d43..b3418da98 100644 --- a/stdlib/source/library/lux/math/number/complex.lux +++ b/stdlib/source/library/lux/math/number/complex.lux @@ -23,8 +23,9 @@ ["." int]]]]]) (type: .public Complex - {#real Frac - #imaginary Frac}) + (Record + {#real Frac + #imaginary Frac})) (syntax: .public (complex [real <code>.any ?imaginary (<>.maybe <code>.any)]) @@ -292,16 +293,16 @@ nth_phi (|> input ..argument (f./ r_nth)) slice (|> math.pi (f.* +2.0) (f./ r_nth))] (|> (list.indices nth) - (list\map (function (_ nth') - (let [inner (|> nth' .int int.frac - (f.* slice) - (f.+ nth_phi)) - real (f.* nth_root_of_abs - (math.cos inner)) - imaginary (f.* nth_root_of_abs - (math.sin inner))] - {#real real - #imaginary imaginary}))))))) + (list\each (function (_ nth') + (let [inner (|> nth' .int int.frac + (f.* slice) + (f.+ nth_phi)) + real (f.* nth_root_of_abs + (math.cos inner)) + imaginary (f.* nth_root_of_abs + (math.sin inner))] + {#real real + #imaginary imaginary}))))))) (def: .public (approximately? margin_of_error standard value) (-> Frac Complex Complex Bit) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index 4e5eee846..7c4f1d8b1 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -150,12 +150,12 @@ (..- f2^-52) (..* f2^+1023)))) -(template [<name> <compose> <identity>] +(template [<name> <composite> <identity>] [(implementation: .public <name> (Monoid Frac) (def: identity <identity>) - (def: compose <compose>))] + (def: composite <composite>))] [addition ..+ +0.0] [multiplication ..* +1.0] diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index 3f02cb4bd..e1706c217 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -130,12 +130,12 @@ (def: hash .nat)) -(template [<monoid> <identity> <compose>] +(template [<monoid> <identity> <composite>] [(implementation: .public <monoid> (All [a] (Monoid (I64 a))) (def: identity <identity>) - (def: compose <compose>))] + (def: composite <composite>))] [disjunction ..false ..or] [conjunction ..true ..and] diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index 657780bd9..91eaa9de4 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -187,12 +187,12 @@ ... -9,223,372,036,854,775,808 (//i64.left_shifted 63 +1))) -(template [<name> <compose> <identity>] +(template [<name> <composite> <identity>] [(implementation: .public <name> (Monoid Int) (def: identity <identity>) - (def: compose <compose>))] + (def: composite <composite>))] [addition ..+ +0] [multiplication ..* +1] @@ -220,13 +220,13 @@ (|> repr ("lux text clip" 1 (-- input_size)) (\ <codec> decoded) - (\ try.functor map .int)) + (\ try.functor each .int)) (^ (static ..-sign)) (|> repr ("lux text clip" 1 (-- input_size)) (\ <codec> decoded) - (\ try.functor map (|>> -- .int ..opposite --))) + (\ try.functor each (|>> -- .int ..opposite --))) _ (#try.Failure <error>)) diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux index 2ec9333b7..0794950b4 100644 --- a/stdlib/source/library/lux/math/number/nat.lux +++ b/stdlib/source/library/lux/math/number/nat.lux @@ -168,12 +168,12 @@ (def: top (-- 0)) (def: bottom 0)) -(template [<name> <compose> <identity>] +(template [<name> <composite> <identity>] [(implementation: .public <name> (Monoid Nat) (def: identity <identity>) - (def: compose <compose>))] + (def: composite <composite>))] [addition ..+ 0] [multiplication ..* 1] diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux index 6ab6d1349..6be8bce44 100644 --- a/stdlib/source/library/lux/math/number/ratio.lux +++ b/stdlib/source/library/lux/math/number/ratio.lux @@ -23,8 +23,9 @@ ["n" nat ("#\." decimal)]]) (type: .public Ratio - {#numerator Nat - #denominator Nat}) + (Record + {#numerator Nat + #denominator Nat})) (def: .public (nat value) (-> Ratio (Maybe Nat)) @@ -131,7 +132,7 @@ (Codec Text Ratio) (def: (encoded (^slots [#numerator #denominator])) - ($_ text\compose (n\encoded numerator) ..separator (n\encoded denominator))) + ($_ text\composite (n\encoded numerator) ..separator (n\encoded denominator))) (def: (decoded input) (case (text.split_by ..separator input) @@ -143,14 +144,14 @@ #denominator denominator}))) #.None - (#.Left (text\compose "Invalid syntax for ratio: " input))))) + (#.Left (text\composite "Invalid syntax for ratio: " input))))) -(template [<identity> <compose> <name>] +(template [<identity> <composite> <name>] [(implementation: .public <name> (Monoid Ratio) (def: identity (..ratio <identity>)) - (def: compose <compose>))] + (def: composite <composite>))] [0 ..+ addition] [1 ..* multiplication] diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index b4bf8bcd2..a65025c0b 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -205,12 +205,12 @@ (def: top (.rev -1)) (def: bottom (.rev 0))) -(template [<name> <compose> <identity>] +(template [<name> <composite> <identity>] [(implementation: .public <name> (Monoid Rev) (def: identity (\ interval <identity>)) - (def: compose <compose>))] + (def: composite <composite>))] [addition ..+ bottom] [maximum ..max bottom] diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index 3e9b14b8c..2f83a8d00 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -46,7 +46,7 @@ (implementation: .public functor (Functor Random) - (def: (map f fa) + (def: (each f fa) (function (_ state) (let [[state' a] (fa state)] [state' (f a)])))) @@ -71,7 +71,7 @@ (function (_ state) [state a])) - (def: (join ffa) + (def: (conjoint ffa) (function (_ state) (let [[state' fa] (ffa state)] (fa state'))))) @@ -125,7 +125,7 @@ (template [<name> <type> <cast>] [(def: .public <name> (Random <type>) - (\ ..monad map <cast> ..i64))] + (\ ..monad each <cast> ..i64))] [nat Nat .nat] [int Int .int] @@ -134,13 +134,13 @@ (def: .public frac (Random Frac) - (\ ..monad map (|>> .i64 f.of_bits) ..nat)) + (\ ..monad each (|>> .i64 f.of_bits) ..nat)) (def: .public safe_frac (Random Frac) (let [mantissa_range (.int (i64.left_shifted 53 1)) mantissa_max (i.frac (-- mantissa_range))] - (\ ..monad map + (\ ..monad each (|>> (i.% mantissa_range) i.frac (f./ mantissa_max)) @@ -154,7 +154,7 @@ in_range (: (-> Char Char) (|>> (n.% size) (n.+ start)))] (|> ..nat - (\ ..monad map in_range) + (\ ..monad each in_range) (..only (unicode.member? set))))) (def: .public (text char_gen size) @@ -164,7 +164,7 @@ (do ..monad [x char_gen xs (text char_gen (-- size))] - (in (text\compose (text.of_char x) xs))))) + (in (text\composite (text.of_char x) xs))))) (template [<name> <set>] [(def: .public <name> @@ -292,19 +292,19 @@ (def: .public instant (Random Instant) - (\ ..monad map instant.of_millis ..int)) + (\ ..monad each instant.of_millis ..int)) (def: .public date (Random Date) - (\ ..monad map instant.date ..instant)) + (\ ..monad each instant.date ..instant)) (def: .public time (Random Time) - (\ ..monad map instant.time ..instant)) + (\ ..monad each instant.time ..instant)) (def: .public duration (Random Duration) - (\ ..monad map duration.of_millis ..int)) + (\ ..monad each duration.of_millis ..int)) (def: .public month (Random Month) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index 13b7d9937..103796a2e 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -31,7 +31,7 @@ (implementation: .public functor (Functor Meta) - (def: (map f fa) + (def: (each f fa) (function (_ lux) (case (fa lux) (#try.Failure msg) @@ -68,7 +68,7 @@ (function (_ lux) (#try.Success [lux x]))) - (def: (join mma) + (def: (conjoint mma) (function (_ lux) (case (mma lux) (#try.Failure msg) @@ -121,7 +121,7 @@ (#try.Success [lux module]) _ - (#try.Failure ($_ text\compose "Unknown module: " name))))) + (#try.Failure ($_ text\composite "Unknown module: " name))))) (def: .public current_module_name (Meta Text) @@ -137,8 +137,8 @@ (Meta Module) (let [(^open "\.") ..monad] (|> ..current_module_name - (\map ..module) - \join))) + (\each ..module) + \conjoint))) (def: (macro_type? type) (-> Type Bit) @@ -265,7 +265,7 @@ ((clean_type var_type) lux) #.None - (#try.Failure ($_ text\compose "Unknown variable: " name)))))) + (#try.Failure ($_ text\composite "Unknown variable: " name)))))) (def: without_lux_runtime (-> (List Text) (List Text)) @@ -275,7 +275,7 @@ (def: listing_separator Text - ($_ text\compose text.new_line " ")) + ($_ text\composite text.new_line " ")) (def: module_listing (-> (List Text) Text) @@ -302,28 +302,28 @@ (let [current_module (|> lux (value@ #.current_module) (maybe.else "???")) all_known_modules (|> lux (value@ #.modules) - (list\map product.left) + (list\each product.left) ..module_listing)] - (#try.Failure ($_ text\compose + (#try.Failure ($_ text\composite "Unknown definition: " (name\encoded name) text.new_line " Current module: " current_module text.new_line (case (plist.value current_module (value@ #.modules lux)) (#.Some this_module) (let [candidates (|> lux (value@ #.modules) - (list\map (function (_ [module_name module]) - (|> module - (value@ #.definitions) - (list.all (function (_ [def_name global]) - (case global - (#.Definition [exported? _ _ _]) - (if (and exported? - (text\= normal_short def_name)) - (#.Some (name\encoded [module_name def_name])) - #.None) - - (#.Alias _) - #.None)))))) + (list\each (function (_ [module_name module]) + (|> module + (value@ #.definitions) + (list.all (function (_ [def_name global]) + (case global + (#.Definition [exported? _ _ _]) + (if (and exported? + (text\= normal_short def_name)) + (#.Some (name\encoded [module_name def_name])) + #.None) + + (#.Alias _) + #.None)))))) list.together (list.sorted text\<) (text.interposed ..listing_separator)) @@ -332,10 +332,10 @@ ..module_listing) aliases (|> this_module (value@ #.module_aliases) - (list\map (function (_ [alias real]) ($_ text\compose alias " => " real))) + (list\each (function (_ [alias real]) ($_ text\composite alias " => " real))) (list.sorted text\<) (text.interposed ..listing_separator))] - ($_ text\compose + ($_ text\composite " Candidates: " candidates text.new_line " Imports: " imports text.new_line " Aliases: " aliases text.new_line)) @@ -350,7 +350,7 @@ [definition (..definition name)] (case definition (#.Left de_aliased) - (failure ($_ text\compose + (failure ($_ text\composite "Aliases are not considered exports: " (name\encoded name))) @@ -358,7 +358,7 @@ (let [[exported? def_type def_data def_value] definition] (if exported? (in definition) - (failure ($_ text\compose "Definition is not an export: " (name\encoded name)))))))) + (failure ($_ text\composite "Definition is not an export: " (name\encoded name)))))))) (def: .public (definition_type name) (-> Name (Meta Type)) @@ -396,21 +396,21 @@ (type_code .Type) (type_code def_type))) (in (:as Type def_value)) - (..failure ($_ text\compose "Definition is not a type: " (name\encoded name)))))))) + (..failure ($_ text\composite "Definition is not a type: " (name\encoded name)))))))) (def: .public (globals module) (-> Text (Meta (List [Text Global]))) (function (_ lux) (case (plist.value module (value@ #.modules lux)) #.None - (#try.Failure ($_ text\compose "Unknown module: " module)) + (#try.Failure ($_ text\composite "Unknown module: " module)) (#.Some module) (#try.Success [lux (value@ #.definitions module)])))) (def: .public (definitions module) (-> Text (Meta (List [Text Definition]))) - (\ ..monad map + (\ ..monad each (list.all (function (_ [name global]) (case global (#.Left de_aliased) @@ -479,7 +479,7 @@ (def: .public (imported? import) (-> Text (Meta Bit)) - (\ ..functor map + (\ ..functor each (|>> (value@ #.imports) (list.any? (text\= import))) ..current_module)) @@ -495,14 +495,14 @@ (if (or (text\= this_module_name module) (and imported! exported?)) (in [idx tag_list type]) - (..failure ($_ text\compose "Cannot access tag: " (name\encoded tag_name) " from module " this_module_name))) + (..failure ($_ text\composite "Cannot access tag: " (name\encoded tag_name) " from module " this_module_name))) _ - (..failure ($_ text\compose + (..failure ($_ text\composite "Unknown tag: " (name\encoded tag_name) text.new_line " Known tags: " (|> =module (value@ #.tags) - (list\map (|>> product.left [module] name\encoded (text.prefix text.new_line))) + (list\each (|>> product.left [module] name\encoded (text.prefix text.new_line))) text.together) ))))) @@ -515,8 +515,8 @@ (list.only (function (_ [type_name [tag_list exported? type]]) (or exported? (text\= this_module_name module)))) - (list\map (function (_ [type_name [tag_list exported? type]]) - [tag_list type])))))) + (list\each (function (_ [type_name [tag_list exported? type]]) + [tag_list type])))))) (def: .public locals (Meta (List (List [Text Type]))) @@ -527,10 +527,10 @@ (#.Some scopes) (#try.Success [lux - (list\map (|>> (value@ [#.locals #.mappings]) - (list\map (function (_ [name [type _]]) - [name type]))) - scopes)])))) + (list\each (|>> (value@ [#.locals #.mappings]) + (list\each (function (_ [name [type _]]) + [name type]))) + scopes)])))) (def: .public (de_aliased def_name) (-> Name (Meta Name)) @@ -565,6 +565,6 @@ (def: .public (eval type code) (-> Type Code (Meta Any)) (do {! ..monad} - [eval (\ ! map (value@ #.eval) + [eval (\ ! each (value@ #.eval) ..compiler_state)] (eval type code))) diff --git a/stdlib/source/library/lux/meta/annotation.lux b/stdlib/source/library/lux/meta/annotation.lux index c73cc9247..292445ea8 100644 --- a/stdlib/source/library/lux/meta/annotation.lux +++ b/stdlib/source/library/lux/meta/annotation.lux @@ -71,7 +71,6 @@ [implementation? #.implementation?] [recursive_type? #.type_rec?] - [interface? #.interface?] ) (def: (text_parser input) @@ -89,7 +88,7 @@ (<| (maybe.else (list)) (do {! maybe.monad} [args (..tuple (name_of <tag>) ann)] - (monad.map ! ..text_parser args))))] + (monad.each ! ..text_parser args))))] [function_arguments #.func_args] [type_arguments #.type_args] diff --git a/stdlib/source/library/lux/program.lux b/stdlib/source/library/lux/program.lux index 87e80b27b..f53788682 100644 --- a/stdlib/source/library/lux/program.lux +++ b/stdlib/source/library/lux/program.lux @@ -20,8 +20,9 @@ ["." code]]]]) (type: Arguments - (#Raw Text) - (#Parsed (List Code))) + (Variant + (#Raw Text) + (#Parsed (List Code)))) (def: arguments^ (<code>.Parser Arguments) diff --git a/stdlib/source/library/lux/static.lux b/stdlib/source/library/lux/static.lux index 0a506ef2d..a332842ed 100644 --- a/stdlib/source/library/lux/static.lux +++ b/stdlib/source/library/lux/static.lux @@ -16,7 +16,7 @@ (template [<name> <type> <format>] [(syntax: .public (<name> [expression <code>.any]) - (\ meta.monad map + (\ meta.monad each (|>> (:as <type>) <format> list) (meta.eval <type> expression)))] diff --git a/stdlib/source/library/lux/target/common_lisp.lux b/stdlib/source/library/lux/target/common_lisp.lux index 3019924da..5a5b10a06 100644 --- a/stdlib/source/library/lux/target/common_lisp.lux +++ b/stdlib/source/library/lux/target/common_lisp.lux @@ -60,8 +60,9 @@ ) (type: .public Lambda - {#input Var/* - #output (Expression Any)}) + (Record + {#input Var/* + #output (Expression Any)})) (def: .public nil Literal @@ -146,7 +147,7 @@ (def: .public args (-> (List Var/1) Var/*) - (|>> (list\map ..code) + (|>> (list\each ..code) (text.interposed " ") ..as_form :abstraction)) @@ -159,7 +160,7 @@ (#.Item _) (|> singles - (list\map ..code) + (list\each ..code) (text.interposed " ") (text.suffix " "))) (format "&rest " (:representation rest)) @@ -168,7 +169,7 @@ (def: form (-> (List (Expression Any)) Expression) - (|>> (list\map ..code) + (|>> (list\each ..code) (text.interposed " ") ..as_form :abstraction)) @@ -189,9 +190,9 @@ (def: .public (labels definitions body) (-> (List [Var/1 Lambda]) (Expression Any) (Computation Any)) (..form (list (..var "labels") - (..form (list\map (function (_ [def_name [def_args def_body]]) - (..form (list def_name (:transmutation def_args) def_body))) - definitions)) + (..form (list\each (function (_ [def_name [def_args def_body]]) + (..form (list def_name (:transmutation def_args) def_body))) + definitions)) body))) (def: .public (destructuring_bind [bindings expression] body) @@ -349,8 +350,8 @@ (-> (List [Var/1 (Expression Any)]) (List (Expression Any)) (Computation Any)) (..form (list& (..var <host_name>) (|> bindings - (list\map (function (_ [name value]) - (..form (list name value)))) + (list\each (function (_ [name value]) + (..form (list name value)))) ..form) body)))] @@ -385,19 +386,20 @@ (..form (list (..var "setf") access value))) (type: .public Handler - {#condition_type (Expression Any) - #condition Var/1 - #body (Expression Any)}) + (Record + {#condition_type (Expression Any) + #condition Var/1 + #body (Expression Any)})) (def: .public (handler_case handlers body) (-> (List Handler) (Expression Any) (Computation Any)) (..form (list& (..var "handler-case") body - (list\map (function (_ [type condition handler]) - (..form (list type - (:transmutation (..args (list condition))) - handler))) - handlers)))) + (list\each (function (_ [type condition handler]) + (..form (list type + (:transmutation (..args (list condition))) + handler))) + handlers)))) (template [<name> <prefix>] [(def: .public (<name> conditions expression) @@ -412,7 +414,7 @@ _ (:abstraction - (format <prefix> (|> conditions (list\map ..symbol) + (format <prefix> (|> conditions (list\each ..symbol) (list& (..symbol "or")) ..form :representation) " " (:representation expression)))))] @@ -439,10 +441,10 @@ (def: .public (cond clauses else) (-> (List [(Expression Any) (Expression Any)]) (Expression Any) (Computation Any)) (..form (list& (..var "cond") - (list\compose (list\map (function (_ [test then]) - (..form (list test then))) - clauses) - (list (..form (list (..bool true) else))))))) + (list\composite (list\each (function (_ [test then]) + (..form (list test then))) + clauses) + (list (..form (list (..bool true) else))))))) (def: .public tag (-> Text Tag) diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux index b2af12ac2..7a1f5b3bc 100644 --- a/stdlib/source/library/lux/target/js.lux +++ b/stdlib/source/library/lux/target/js.lux @@ -119,7 +119,7 @@ (def: .public array (-> (List Expression) Computation) - (|>> (list\map ..code) + (|>> (list\each ..code) (text.interposed ..argument_separator) ..element :abstraction)) @@ -139,7 +139,7 @@ (def: .public (apply/* function inputs) (-> Expression (List Expression) Computation) (|> inputs - (list\map ..code) + (list\each ..code) (text.interposed ..argument_separator) ..expression (format (:representation function)) @@ -151,8 +151,8 @@ (def: .public object (-> (List [Text Expression]) Computation) - (|>> (list\map (.function (_ [key val]) - (format (:representation (..string key)) ..field_separator (:representation val)))) + (|>> (list\each (.function (_ [key val]) + (format (:representation (..string key)) ..field_separator (:representation val)))) (text.interposed ..argument_separator) (text.enclosed ["{" "}"]) ..expression @@ -184,7 +184,7 @@ ..block (format "function " (:representation name) (|> inputs - (list\map ..code) + (list\each ..code) (text.interposed ..argument_separator) ..expression) " ") @@ -203,7 +203,7 @@ ..block (format "function" (|> inputs - (list\map ..code) + (list\each ..code) (text.interposed ..argument_separator) ..expression) " ") @@ -285,7 +285,7 @@ (-> Expression (List Expression) Computation) (|> (format "new " (:representation constructor) (|> inputs - (list\map ..code) + (list\each ..code) (text.interposed ..argument_separator) ..expression)) ..expression @@ -408,11 +408,11 @@ (-> Expression (List [(List Literal) Statement]) (Maybe Statement) Statement) (:abstraction (format "switch (" (:representation input) ") " (|> (format (|> cases - (list\map (.function (_ [when then]) - (format (|> when - (list\map (|>> :representation (text.enclosed ["case " ":"]))) - (text.interposed text.new_line)) - (..nested (:representation then))))) + (list\each (.function (_ [when then]) + (format (|> when + (list\each (|>> :representation (text.enclosed ["case " ":"]))) + (text.interposed text.new_line)) + (..nested (:representation then))))) (text.interposed text.new_line)) text.new_line (case default diff --git a/stdlib/source/library/lux/target/jvm.lux b/stdlib/source/library/lux/target/jvm.lux index 1ada0da04..ce273f401 100644 --- a/stdlib/source/library/lux/target/jvm.lux +++ b/stdlib/source/library/lux/target/jvm.lux @@ -10,275 +10,304 @@ ["." category (#+ Primitive Class Value Method)]]]]]]) (type: .public Literal - (#Boolean Bit) - (#Int Int) - (#Long Int) - (#Double Frac) - (#Char Nat) - (#String Text)) + (Variant + (#Boolean Bit) + (#Int Int) + (#Long Int) + (#Double Frac) + (#Char Nat) + (#String Text))) (type: .public Constant - (#BIPUSH Int) - - (#SIPUSH Int) - - #ICONST_M1 - #ICONST_0 - #ICONST_1 - #ICONST_2 - #ICONST_3 - #ICONST_4 - #ICONST_5 - - #LCONST_0 - #LCONST_1 - - #FCONST_0 - #FCONST_1 - #FCONST_2 - - #DCONST_0 - #DCONST_1 - - #ACONST_NULL - - (#LDC Literal)) + (Variant + (#BIPUSH Int) + + (#SIPUSH Int) + + #ICONST_M1 + #ICONST_0 + #ICONST_1 + #ICONST_2 + #ICONST_3 + #ICONST_4 + #ICONST_5 + + #LCONST_0 + #LCONST_1 + + #FCONST_0 + #FCONST_1 + #FCONST_2 + + #DCONST_0 + #DCONST_1 + + #ACONST_NULL + + (#LDC Literal))) (type: .public Int_Arithmetic - #IADD - #ISUB - #IMUL - #IDIV - #IREM - #INEG) + (Variant + #IADD + #ISUB + #IMUL + #IDIV + #IREM + #INEG)) (type: .public Long_Arithmetic - #LADD - #LSUB - #LMUL - #LDIV - #LREM - #LNEG) + (Variant + #LADD + #LSUB + #LMUL + #LDIV + #LREM + #LNEG)) (type: .public Float_Arithmetic - #FADD - #FSUB - #FMUL - #FDIV - #FREM - #FNEG) + (Variant + #FADD + #FSUB + #FMUL + #FDIV + #FREM + #FNEG)) (type: .public Double_Arithmetic - #DADD - #DSUB - #DMUL - #DDIV - #DREM - #DNEG) + (Variant + #DADD + #DSUB + #DMUL + #DDIV + #DREM + #DNEG)) (type: .public Arithmetic - (#Int_Arithmetic Int_Arithmetic) - (#Long_Arithmetic Long_Arithmetic) - (#Float_Arithmetic Float_Arithmetic) - (#Double_Arithmetic Double_Arithmetic)) + (Variant + (#Int_Arithmetic Int_Arithmetic) + (#Long_Arithmetic Long_Arithmetic) + (#Float_Arithmetic Float_Arithmetic) + (#Double_Arithmetic Double_Arithmetic))) (type: .public Int_Bitwise - #IOR - #IXOR - #IAND - #ISHL - #ISHR - #IUSHR) + (Variant + #IOR + #IXOR + #IAND + #ISHL + #ISHR + #IUSHR)) (type: .public Long_Bitwise - #LOR - #LXOR - #LAND - #LSHL - #LSHR - #LUSHR) + (Variant + #LOR + #LXOR + #LAND + #LSHL + #LSHR + #LUSHR)) (type: .public Bitwise - (#Int_Bitwise Int_Bitwise) - (#Long_Bitwise Long_Bitwise)) + (Variant + (#Int_Bitwise Int_Bitwise) + (#Long_Bitwise Long_Bitwise))) (type: .public Conversion - #I2B - #I2S - #I2L - #I2F - #I2D - #I2C - - #L2I - #L2F - #L2D - - #F2I - #F2L - #F2D - - #D2I - #D2L - #D2F) + (Variant + #I2B + #I2S + #I2L + #I2F + #I2D + #I2C + + #L2I + #L2F + #L2D + + #F2I + #F2L + #F2D + + #D2I + #D2L + #D2F)) (type: .public Array - #ARRAYLENGTH + (Variant + #ARRAYLENGTH - (#NEWARRAY (Type Primitive)) - (#ANEWARRAY (Type category.Object)) + (#NEWARRAY (Type Primitive)) + (#ANEWARRAY (Type category.Object)) - #BALOAD - #BASTORE + #BALOAD + #BASTORE - #SALOAD - #SASTORE + #SALOAD + #SASTORE - #IALOAD - #IASTORE + #IALOAD + #IASTORE - #LALOAD - #LASTORE + #LALOAD + #LASTORE - #FALOAD - #FASTORE + #FALOAD + #FASTORE - #DALOAD - #DASTORE - - #CALOAD - #CASTORE + #DALOAD + #DASTORE + + #CALOAD + #CASTORE - #AALOAD - #AASTORE) + #AALOAD + #AASTORE)) (type: .public Object - (#GETSTATIC (Type Class) Text (Type Value)) - (#PUTSTATIC (Type Class) Text (Type Value)) - - (#NEW (Type Class)) - - (#INSTANCEOF (Type Class)) - (#CHECKCAST (Type category.Object)) - - (#GETFIELD (Type Class) Text (Type Value)) - (#PUTFIELD (Type Class) Text (Type Value)) - - (#INVOKEINTERFACE (Type Class) Text (Type Method)) - (#INVOKESPECIAL (Type Class) Text (Type Method)) - (#INVOKESTATIC (Type Class) Text (Type Method)) - (#INVOKEVIRTUAL (Type Class) Text (Type Method))) - -(type: .public Register Nat) + (Variant + (#GETSTATIC (Type Class) Text (Type Value)) + (#PUTSTATIC (Type Class) Text (Type Value)) + + (#NEW (Type Class)) + + (#INSTANCEOF (Type Class)) + (#CHECKCAST (Type category.Object)) + + (#GETFIELD (Type Class) Text (Type Value)) + (#PUTFIELD (Type Class) Text (Type Value)) + + (#INVOKEINTERFACE (Type Class) Text (Type Method)) + (#INVOKESPECIAL (Type Class) Text (Type Method)) + (#INVOKESTATIC (Type Class) Text (Type Method)) + (#INVOKEVIRTUAL (Type Class) Text (Type Method)))) + +(type: .public Register + Nat) (type: .public Local_Int - (#ILOAD Register) - (#ISTORE Register)) + (Variant + (#ILOAD Register) + (#ISTORE Register))) (type: .public Local_Long - (#LLOAD Register) - (#LSTORE Register)) + (Variant + (#LLOAD Register) + (#LSTORE Register))) (type: .public Local_Float - (#FLOAD Register) - (#FSTORE Register)) + (Variant + (#FLOAD Register) + (#FSTORE Register))) (type: .public Local_Double - (#DLOAD Register) - (#DSTORE Register)) + (Variant + (#DLOAD Register) + (#DSTORE Register))) (type: .public Local_Object - (#ALOAD Register) - (#ASTORE Register)) + (Variant + (#ALOAD Register) + (#ASTORE Register))) (type: .public Local - (#Local_Int Local_Int) - (#IINC Register) - (#Local_Long Local_Long) - (#Local_Float Local_Float) - (#Local_Double Local_Double) - (#Local_Object Local_Object)) + (Variant + (#Local_Int Local_Int) + (#IINC Register) + (#Local_Long Local_Long) + (#Local_Float Local_Float) + (#Local_Double Local_Double) + (#Local_Object Local_Object))) (type: .public Stack - #DUP - #DUP_X1 - #DUP_X2 - #DUP2 - #DUP2_X1 - #DUP2_X2 - #SWAP - #POP - #POP2) + (Variant + #DUP + #DUP_X1 + #DUP_X2 + #DUP2 + #DUP2_X1 + #DUP2_X2 + #SWAP + #POP + #POP2)) (type: .public Comparison - #LCMP - - #FCMPG - #FCMPL + (Variant + #LCMP + + #FCMPG + #FCMPL - #DCMPG - #DCMPL) + #DCMPG + #DCMPL)) -(type: .public Label Nat) +(type: .public Label + Nat) (type: .public (Branching label) - (#IF_ICMPEQ label) - (#IF_ICMPGE label) - (#IF_ICMPGT label) - (#IF_ICMPLE label) - (#IF_ICMPLT label) - (#IF_ICMPNE label) - (#IFEQ label) - (#IFNE label) - (#IFGE label) - (#IFGT label) - (#IFLE label) - (#IFLT label) - - (#TABLESWITCH Int Int label (List label)) - (#LOOKUPSWITCH label (List [Int label])) - - (#IF_ACMPEQ label) - (#IF_ACMPNE label) - (#IFNONNULL label) - (#IFNULL label)) + (Variant + (#IF_ICMPEQ label) + (#IF_ICMPGE label) + (#IF_ICMPGT label) + (#IF_ICMPLE label) + (#IF_ICMPLT label) + (#IF_ICMPNE label) + (#IFEQ label) + (#IFNE label) + (#IFGE label) + (#IFGT label) + (#IFLE label) + (#IFLT label) + + (#TABLESWITCH Int Int label (List label)) + (#LOOKUPSWITCH label (List [Int label])) + + (#IF_ACMPEQ label) + (#IF_ACMPNE label) + (#IFNONNULL label) + (#IFNULL label))) (type: .public (Exception label) - (#Try label label label (Type Class)) - #ATHROW) + (Variant + (#Try label label label (Type Class)) + #ATHROW)) (type: .public Concurrency - #MONITORENTER - #MONITOREXIT) + (Variant + #MONITORENTER + #MONITOREXIT)) (type: .public Return - #RETURN - #IRETURN - #LRETURN - #FRETURN - #DRETURN - #ARETURN) + (Variant + #RETURN + #IRETURN + #LRETURN + #FRETURN + #DRETURN + #ARETURN)) (type: .public (Control label) - (#GOTO label) - (#Branching (Branching label)) - (#Exception (Exception label)) - (#Concurrency Concurrency) - (#Return Return)) + (Variant + (#GOTO label) + (#Branching (Branching label)) + (#Exception (Exception label)) + (#Concurrency Concurrency) + (#Return Return))) (type: .public (Instruction embedded label) - #NOP - (#Constant Constant) - (#Arithmetic Arithmetic) - (#Bitwise Bitwise) - (#Conversion Conversion) - (#Array Array) - (#Object Object) - (#Local Local) - (#Stack Stack) - (#Comparison Comparison) - (#Control (Control label)) - (#Embedded embedded)) + (Variant + #NOP + (#Constant Constant) + (#Arithmetic Arithmetic) + (#Bitwise Bitwise) + (#Conversion Conversion) + (#Array Array) + (#Object Object) + (#Local Local) + (#Stack Stack) + (#Comparison Comparison) + (#Control (Control label)) + (#Embedded embedded))) (type: .public (Bytecode embedded label) (Row (Instruction embedded label))) diff --git a/stdlib/source/library/lux/target/jvm/attribute.lux b/stdlib/source/library/lux/target/jvm/attribute.lux index 1dd3c323e..640ad8683 100644 --- a/stdlib/source/library/lux/target/jvm/attribute.lux +++ b/stdlib/source/library/lux/target/jvm/attribute.lux @@ -26,9 +26,10 @@ ["#." code]]) (type: .public (Info about) - {#name (Index UTF8) - #length U4 - #info about}) + (Record + {#name (Index UTF8) + #length U4 + #info about})) (def: .public (info_equivalence Equivalence<about>) (All [about] @@ -52,8 +53,9 @@ (with_expansions [<Code> (as_is (/code.Code Attribute))] (type: .public #rec Attribute - (#Constant (Info (Constant Any))) - (#Code (Info <Code>))) + (Variant + (#Constant (Info (Constant Any))) + (#Code (Info <Code>)))) (type: .public Code <Code>) diff --git a/stdlib/source/library/lux/target/jvm/attribute/code.lux b/stdlib/source/library/lux/target/jvm/attribute/code.lux index 265c951a2..d63057a68 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code.lux @@ -23,10 +23,11 @@ ["#." exception (#+ Exception)]]) (type: .public (Code Attribute) - {#limit Limit - #code Binary - #exception_table (Row Exception) - #attributes (Row Attribute)}) + (Record + {#limit Limit + #code Binary + #exception_table (Row Exception) + #attributes (Row Attribute)})) (def: .public (length length code) (All [Attribute] (-> (-> Attribute Nat) (Code Attribute) Nat)) @@ -50,7 +51,7 @@ ... attribute_info attributes[attributes_count]; (|> code (value@ #attributes) - (row\map length) + (row\each length) (row\mix n.+ 0)))) (def: .public (equivalence attribute_equivalence) @@ -66,7 +67,7 @@ ... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 (def: .public (writer writer code) (All [Attribute] (-> (Writer Attribute) (Writer (Code Attribute)))) - ($_ binaryF\compose + ($_ binaryF\composite ... u2 max_stack; ... u2 max_locals; (///limit.writer (value@ #limit code)) diff --git a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux index 5ba6db613..a2a4f45c1 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux @@ -20,10 +20,11 @@ ["#." unsigned (#+ U2)]]]]) (type: .public Exception - {#start Address - #end Address - #handler Address - #catch (Index Class)}) + (Record + {#start Address + #end Address + #handler Address + #catch (Index Class)})) (def: .public equivalence (Equivalence Exception) diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 9b16b5be6..7e56004c3 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -51,14 +51,17 @@ ["." reflection] ["." parser]]]]) -(type: .public Label Nat) +(type: .public Label + Nat) -(type: .public Resolver (Dictionary Label [Stack (Maybe Address)])) +(type: .public Resolver + (Dictionary Label [Stack (Maybe Address)])) (type: .public Tracker - {#program_counter Address - #next Label - #known Resolver}) + (Record + {#program_counter Address + #next Label + #known Resolver})) (def: fresh Tracker @@ -82,7 +85,7 @@ (def: identity ..relative_identity) - (def: (compose left right) + (def: (composite left right) (cond (same? ..relative_identity left) right @@ -94,8 +97,8 @@ (do try.monad [[left_exceptions left_instruction] (left resolver) [right_exceptions right_instruction] (right resolver)] - (in [(\ row.monoid compose left_exceptions right_exceptions) - (_\compose left_instruction right_instruction)])))))) + (in [(\ row.monoid composite left_exceptions right_exceptions) + (_\composite left_instruction right_instruction)])))))) (type: .public (Bytecode a) (+State Try [Pool Environment Tracker] (Writer Relative a))) @@ -687,12 +690,14 @@ ["Start" (|> @from /address.value //unsigned.value %.nat)] ["Target" (|> jump //signed.value %.int)])) -(type: Any_Jump (Either Big_Jump Jump)) +(type: Any_Jump + (Either Big_Jump + Jump)) (def: (jump @from @to) (-> Address Address (Try Any_Jump)) (do {! try.monad} - [jump (\ ! map //signed.value + [jump (\ ! each //signed.value (/address.jump @from @to))] (let [big? (n.> (//unsigned.value //unsigned.maximum/2) (.nat (i.* (if (i.>= +0 jump) @@ -700,8 +705,8 @@ -1) jump)))] (if big? - (\ ! map (|>> #.Left) (//signed.s4 jump)) - (\ ! map (|>> #.Right) (//signed.s2 jump)))))) + (\ ! each (|>> #.Left) (//signed.s4 jump)) + (\ ! each (|>> #.Right) (//signed.s2 jump)))))) (exception: .public (unset_label {label Label}) (exception.report @@ -857,15 +862,15 @@ [@default (|> default get (monad.then ! product.right)) @at_minimum (|> at_minimum get (monad.then ! product.right)) @afterwards (|> afterwards - (monad.map ! get) - (monad.then ! (monad.map ! product.right)))] + (monad.each ! get) + (monad.then ! (monad.each ! product.right)))] (in [@default @at_minimum @afterwards])) (#.Some [@default @at_minimum @afterwards]) (do {! try.monad} - [>default (\ ! map ..big_jump (..jump @from @default)) - >at_minimum (\ ! map ..big_jump (..jump @from @at_minimum)) - >afterwards (monad.map ! (|>> (..jump @from) (\ ! map ..big_jump)) - @afterwards)] + [>default (\ ! each ..big_jump (..jump @from @default)) + >at_minimum (\ ! each ..big_jump (..jump @from @at_minimum)) + >afterwards (monad.each ! (|>> (..jump @from) (\ ! each ..big_jump)) + @afterwards)] (in [..no_exceptions (bytecode minimum >default [>at_minimum >afterwards])])) #.None @@ -890,7 +895,7 @@ (in (let [@from (value@ #program_counter tracker)] [[pool environment' - (|> (list\mix (..acknowledge_label actual) tracker (list& default (list\map product.right cases))) + (|> (list\mix (..acknowledge_label actual) tracker (list& default (list\each product.right cases))) (with@ #program_counter program_counter'))] [(function (_ resolver) (let [get (: (-> Label (Maybe [Stack (Maybe Address)])) @@ -899,15 +904,15 @@ (case (do {! maybe.monad} [@default (|> default get (monad.then ! product.right)) @cases (|> cases - (monad.map ! (|>> product.right get)) - (monad.then ! (monad.map ! product.right)))] + (monad.each ! (|>> product.right get)) + (monad.then ! (monad.each ! product.right)))] (in [@default @cases])) (#.Some [@default @cases]) (do {! try.monad} - [>default (\ ! map ..big_jump (..jump @from @default)) + [>default (\ ! each ..big_jump (..jump @from @default)) >cases (|> @cases - (monad.map ! (|>> (..jump @from) (\ ! map ..big_jump))) - (\ ! map (|>> (list.zipped/2 (list\map product.left cases)))))] + (monad.each ! (|>> (..jump @from) (\ ! each ..big_jump))) + (\ ! each (|>> (list.zipped/2 (list\each product.left cases)))))] (in [..no_exceptions (bytecode >default >cases)])) #.None @@ -974,7 +979,7 @@ {#//constant/pool.name method #//constant/pool.descriptor (type.descriptor type)}) .let [consumption (|> inputs - (list\map ..type_size) + (list\each ..type_size) (list\mix n.+ (if <static?> 0 1)) //unsigned.u1 try.trusted) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/address.lux b/stdlib/source/library/lux/target/jvm/bytecode/address.lux index 669b49548..51ab13080 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/address.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/address.lux @@ -40,7 +40,7 @@ (-> U2 (-> Address (Try Address))) (|>> :representation (///unsigned.+/2 distance) - (\ try.functor map (|>> :abstraction)))) + (\ try.functor each (|>> :abstraction)))) (def: with_sign (-> Address (Try S4)) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux index 54c754dc5..ff778621c 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux @@ -18,8 +18,9 @@ [category (#+ Method)]]]]) (type: .public Environment - {#limit Limit - #stack (Maybe Stack)}) + (Record + {#limit Limit + #stack (Maybe Stack)})) (template [<name> <limit>] [(def: .public (<name> type) @@ -41,7 +42,7 @@ (def: identity (|>> #try.Success)) - (def: (compose left right) + (def: (composite left right) (function (_ environment) (do try.monad [environment (left environment)] diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux index d57c07354..515728d71 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux @@ -21,8 +21,9 @@ [category (#+ Method)]]]]) (type: .public Limit - {#stack Stack - #registry Registry}) + (Record + {#stack Stack + #registry Registry})) (template [<name> <registry>] [(def: .public (<name> type) @@ -52,7 +53,7 @@ (def: .public (writer limit) (Writer Limit) - ($_ format\compose + ($_ format\composite (/stack.writer (value@ #stack limit)) (/registry.writer (value@ #registry limit)) )) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux index b1d51e164..04bf00456 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux @@ -22,7 +22,8 @@ [category (#+ Method)] ["#/." parser]]]) -(type: .public Register U1) +(type: .public Register + U1) (def: normal 1) (def: wide 2) @@ -40,11 +41,11 @@ (-> (Type Method) Nat) (let [[type_variables inputs output exceptions] (/////type/parser.method type)] (|> inputs - (list\map (function (_ input) - (if (or (same? /////type.long input) - (same? /////type.double input)) - ..wide - ..normal))) + (list\each (function (_ input) + (if (or (same? /////type.long input) + (same? /////type.double input)) + ..wide + ..normal))) (list\mix n.+ 0)))) (template [<start> <name>] @@ -53,7 +54,7 @@ (|>> ..minimal (n.+ <start>) /////unsigned.u2 - (try\map ..registry)))] + (try\each ..registry)))] [0 static] [1 virtual] @@ -61,7 +62,7 @@ (def: .public equivalence (Equivalence Registry) - (\ equivalence.functor map + (\ equivalence.functor each (|>> :representation) /////unsigned.equivalence)) 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 ac3934f87..13d4b5137 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 @@ -33,7 +33,7 @@ (def: .public equivalence (Equivalence Stack) - (\ equivalence.functor map + (\ equivalence.functor each (|>> :representation) /////unsigned.equivalence)) @@ -50,7 +50,7 @@ (-> U2 (-> Stack (Try Stack))) (|>> :representation (<op> amount) - (\ try.functor map ..stack)))] + (\ try.functor each ..stack)))] [/////unsigned.+/2 push] [/////unsigned.-/2 pop] diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index 2e21d2a8e..bba0c67da 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -36,7 +36,8 @@ [type [category (#+ Value Method)]]]]) -(type: .public Size U2) +(type: .public Size + U2) (type: .public Estimator (-> Address Size)) @@ -56,7 +57,8 @@ (-> Instruction Specification) (function.on format.no_op)) -(type: Opcode Nat) +(type: Opcode + Nat) (template [<name> <size>] [(def: <name> Size (|> <size> ///unsigned.u2 try.trusted))] @@ -608,7 +610,7 @@ tableswitch_size (try.trusted (do {! try.monad} [size (///unsigned.u2 size)] - (\ ! map (|>> estimator ///unsigned.value) + (\ ! each (|>> estimator ///unsigned.value) (//address.move size //address.start)))) tableswitch_mutation (: Mutation (function (_ [offset binary]) @@ -672,7 +674,7 @@ lookupswitch_size (try.trusted (do {! try.monad} [size (///unsigned.u2 size)] - (\ ! map (|>> estimator ///unsigned.value) + (\ ! each (|>> estimator ///unsigned.value) (//address.move size //address.start)))) lookupswitch_mutation (: Mutation (function (_ [offset binary]) @@ -713,5 +715,5 @@ (def: identity ..empty) - (def: (compose left right) + (def: (composite left right) (|>> left right))) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux index 74821d838..4b908d990 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux @@ -10,7 +10,8 @@ [encoding ["#." signed (#+ S2 S4)]]]) -(type: .public Jump S2) +(type: .public Jump + S2) (def: .public equivalence (Equivalence Jump) @@ -20,7 +21,8 @@ (Writer Jump) ///signed.writer/2) -(type: .public Big_Jump S4) +(type: .public Big_Jump + S4) (def: .public lifted (-> Jump Big_Jump) diff --git a/stdlib/source/library/lux/target/jvm/class.lux b/stdlib/source/library/lux/target/jvm/class.lux index 0b792934b..1280b23c4 100644 --- a/stdlib/source/library/lux/target/jvm/class.lux +++ b/stdlib/source/library/lux/target/jvm/class.lux @@ -28,17 +28,18 @@ ["#/." pool (#+ Pool Resource)]]]) (type: .public #rec Class - {#magic Magic - #minor_version Minor - #major_version Major - #constant_pool Pool - #modifier (Modifier Class) - #this (Index //constant.Class) - #super (Index //constant.Class) - #interfaces (Row (Index //constant.Class)) - #fields (Row Field) - #methods (Row Method) - #attributes (Row Attribute)}) + (Record + {#magic Magic + #minor_version Minor + #major_version Major + #constant_pool Pool + #modifier (Modifier Class) + #this (Index //constant.Class) + #super (Index //constant.Class) + #interfaces (Row (Index //constant.Class)) + #fields (Row Field) + #methods (Row Method) + #attributes (Row Attribute)})) (modifiers: Class ["0001" public] @@ -112,7 +113,7 @@ (def: .public (writer class) (Writer Class) - (`` ($_ binaryF\compose + (`` ($_ binaryF\composite (~~ (template [<writer> <slot>] [(<writer> (value@ <slot> class))] diff --git a/stdlib/source/library/lux/target/jvm/constant.lux b/stdlib/source/library/lux/target/jvm/constant.lux index 5916d245d..c2756715e 100644 --- a/stdlib/source/library/lux/target/jvm/constant.lux +++ b/stdlib/source/library/lux/target/jvm/constant.lux @@ -34,7 +34,8 @@ [encoding ["#." unsigned]]]]) -(type: .public UTF8 Text) +(type: .public UTF8 + Text) (def: utf8_writer (Writer UTF8) @@ -55,7 +56,7 @@ (def: .public class_equivalence (Equivalence Class) - (\ equivalence.functor map + (\ equivalence.functor each ..index //index.equivalence)) @@ -97,12 +98,13 @@ (All [kind] (-> (Equivalence kind) (Equivalence (Value kind)))) - (\ equivalence.functor map + (\ equivalence.functor each (|>> :representation) Equivalence<kind>)) (template [<constructor> <type> <marker>] - [(type: .public <type> (Value <marker>)) + [(type: .public <type> + (Value <marker>)) (def: .public <constructor> (-> <marker> <type>) @@ -131,12 +133,14 @@ ) (type: .public (Name_And_Type of) - {#name (Index UTF8) - #descriptor (Index (Descriptor of))}) + (Record + {#name (Index UTF8) + #descriptor (Index (Descriptor of))})) (type: .public (Reference of) - {#class (Index Class) - #name_and_type (Index (Name_And_Type of))}) + (Record + {#class (Index Class) + #name_and_type (Index (Name_And_Type of))})) (template [<type> <equivalence> <writer>] [(def: .public <equivalence> @@ -156,17 +160,18 @@ ) (type: .public Constant - (#UTF8 UTF8) - (#Integer Integer) - (#Float Float) - (#Long Long) - (#Double Double) - (#Class Class) - (#String String) - (#Field (Reference //category.Value)) - (#Method (Reference //category.Method)) - (#Interface_Method (Reference //category.Method)) - (#Name_And_Type (Name_And_Type Any))) + (Variant + (#UTF8 UTF8) + (#Integer Integer) + (#Float Float) + (#Long Long) + (#Double Double) + (#Class Class) + (#String String) + (#Field (Reference //category.Value)) + (#Method (Reference //category.Method)) + (#Interface_Method (Reference //category.Method)) + (#Name_And_Type (Name_And_Type Any)))) (def: .public (size constant) (-> Constant Nat) @@ -244,7 +249,7 @@ (case value (^template [<case> <tag> <writer>] [(<case> value) - (binaryF\compose (/tag.writer <tag>) - (<writer> value))]) + (binaryF\composite (/tag.writer <tag>) + (<writer> value))]) (<constants>) )))) diff --git a/stdlib/source/library/lux/target/jvm/constant/pool.lux b/stdlib/source/library/lux/target/jvm/constant/pool.lux index 99597756d..50872e835 100644 --- a/stdlib/source/library/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/library/lux/target/jvm/constant/pool.lux @@ -35,7 +35,8 @@ [category (#+ Value Method)] ["#." descriptor (#+ Descriptor)]]]]) -(type: .public Pool [Index (Row [Index Constant])]) +(type: .public Pool + [Index (Row [Index Constant])]) (def: .public equivalence (Equivalence Pool) @@ -75,7 +76,7 @@ (|> current //index.value (//unsigned.+/2 @new) - (\ ! map //index.index)))] + (\ ! each //index.index)))] (in [[next (row.suffix [current new] pool)] current]))))))))]) @@ -120,8 +121,9 @@ (!add #//.UTF8 text.equivalence value))) (type: .public (Member of) - {#name UTF8 - #descriptor (Descriptor of)}) + (Record + {#name UTF8 + #descriptor (Descriptor of)})) (def: .public (name_and_type [name descriptor]) (All [of] @@ -148,7 +150,7 @@ (Writer Pool) (function (_ [next pool]) (row\mix (function (_ [_index post] pre) - (specification\compose pre (//.writer post))) + (specification\composite pre (//.writer post))) (format.bits/16 (!index next)) pool))) diff --git a/stdlib/source/library/lux/target/jvm/encoding/name.lux b/stdlib/source/library/lux/target/jvm/encoding/name.lux index 16efc410a..eb232aaba 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/name.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/name.lux @@ -10,7 +10,8 @@ (def: .public internal_separator "/") (def: .public external_separator ".") -(type: .public External Text) +(type: .public External + Text) (abstract: .public Internal {} diff --git a/stdlib/source/library/lux/target/jvm/field.lux b/stdlib/source/library/lux/target/jvm/field.lux index b8d84170d..4ccaf58c4 100644 --- a/stdlib/source/library/lux/target/jvm/field.lux +++ b/stdlib/source/library/lux/target/jvm/field.lux @@ -21,10 +21,11 @@ [descriptor (#+ Descriptor)]]]) (type: .public #rec Field - {#modifier (Modifier Field) - #name (Index UTF8) - #descriptor (Index (Descriptor Value)) - #attributes (Row Attribute)}) + (Record + {#modifier (Modifier Field) + #name (Index UTF8) + #descriptor (Index (Descriptor Value)) + #attributes (Row Attribute)})) (modifiers: Field ["0001" public] @@ -48,7 +49,7 @@ (def: .public (writer field) (Writer Field) - (`` ($_ binaryF\compose + (`` ($_ binaryF\composite (~~ (template [<writer> <slot>] [(<writer> (value@ <slot> field))] diff --git a/stdlib/source/library/lux/target/jvm/index.lux b/stdlib/source/library/lux/target/jvm/index.lux index 66df65314..07ae1e85d 100644 --- a/stdlib/source/library/lux/target/jvm/index.lux +++ b/stdlib/source/library/lux/target/jvm/index.lux @@ -30,7 +30,7 @@ (def: .public equivalence (All [kind] (Equivalence (Index kind))) - (\ equivalence.functor map + (\ equivalence.functor each ..value //unsigned.equivalence)) diff --git a/stdlib/source/library/lux/target/jvm/method.lux b/stdlib/source/library/lux/target/jvm/method.lux index e604eb3c2..38bae94fc 100644 --- a/stdlib/source/library/lux/target/jvm/method.lux +++ b/stdlib/source/library/lux/target/jvm/method.lux @@ -27,10 +27,11 @@ ["#." descriptor (#+ Descriptor)]]]) (type: .public #rec Method - {#modifier (Modifier Method) - #name (Index UTF8) - #descriptor (Index (Descriptor //type/category.Method)) - #attributes (Row Attribute)}) + (Record + {#modifier (Modifier Method) + #name (Index UTF8) + #descriptor (Index (Descriptor //type/category.Method)) + #attributes (Row Attribute)})) (modifiers: Method ["0001" public] @@ -55,7 +56,7 @@ @descriptor (//constant/pool.descriptor (//type.descriptor type)) attributes (|> attributes (monad.all !) - (\ ! map row.of_list)) + (\ ! each row.of_list)) attributes (case code (#.Some code) (do ! @@ -93,7 +94,7 @@ (def: .public (writer field) (Writer Method) - (`` ($_ format\compose + (`` ($_ format\composite (~~ (template [<writer> <slot>] [(<writer> (value@ <slot> field))] diff --git a/stdlib/source/library/lux/target/jvm/modifier.lux b/stdlib/source/library/lux/target/jvm/modifier.lux index c7eb021b2..64359dea1 100644 --- a/stdlib/source/library/lux/target/jvm/modifier.lux +++ b/stdlib/source/library/lux/target/jvm/modifier.lux @@ -64,7 +64,7 @@ (def: identity (!wrap (hex "0000"))) - (def: (compose left right) + (def: (composite left right) (!wrap (i64.or (!unwrap left) (!unwrap right))))) (def: .public empty diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index f23e3c019..3fdf491bc 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -175,7 +175,7 @@ [paramsT (|> reflection java/lang/reflect/ParameterizedType::getActualTypeArguments array.list - (monad.map ! parameter))] + (monad.each ! parameter))] (in (/.class (|> raw (:as (java/lang/Class java/lang/Object)) java/lang/Class::getName) @@ -208,7 +208,7 @@ (#try.Success /.wildcard) _ - (\ try.monad map <kind> (..class' parameter bound)))]) + (\ try.monad each <kind> (..class' parameter bound)))]) ([[_ (#.Some bound)] /.upper] [[(#.Some bound) _] /.lower]) @@ -251,7 +251,7 @@ (|> reflection java/lang/reflect/GenericArrayType::getGenericComponentType type - (\ try.monad map /.array)) + (\ try.monad each /.array)) _) ... else (..parameter reflection))) @@ -303,8 +303,8 @@ (if (text\= class_name name) (if (n.= num_class_params num_type_params) (|> params - (list.zipped/2 (list\map (|>> java/lang/reflect/TypeVariable::getName) - class_params)) + (list.zipped/2 (list\each (|>> java/lang/reflect/TypeVariable::getName) + class_params)) (list\mix (function (_ [name paramT] mapping) (dictionary.has name paramT mapping)) /lux.fresh) @@ -375,8 +375,8 @@ <then?> (|> fieldJ java/lang/reflect/Field::getGenericType ..type - (\ ! map (|>> [(java/lang/reflect/Modifier::isFinal modifiers) - (..deprecated? (java/lang/reflect/Field::getDeclaredAnnotations fieldJ))]))) + (\ ! each (|>> [(java/lang/reflect/Modifier::isFinal modifiers) + (..deprecated? (java/lang/reflect/Field::getDeclaredAnnotations fieldJ))]))) <else?> (exception.except <exception> [field class]))))] [static_field ..not_a_static_field #1 #0] diff --git a/stdlib/source/library/lux/target/jvm/type.lux b/stdlib/source/library/lux/target/jvm/type.lux index e87838ef1..1eeccbe72 100644 --- a/stdlib/source/library/lux/target/jvm/type.lux +++ b/stdlib/source/library/lux/target/jvm/type.lux @@ -37,9 +37,10 @@ [(Type Value) a]) (type: .public Constraint - {#name Text - #super_class (Type Class) - #super_interfaces (List (Type Class))}) + (Record + {#name Text + #super_class (Type Class) + #super_interfaces (List (Type Class))})) (template [<name> <style>] [(def: .public (<name> type) @@ -84,14 +85,14 @@ (def: .public (class name parameters) (-> External (List (Type Parameter)) (Type Class)) (:abstraction - [(/signature.class name (list\map ..signature parameters)) + [(/signature.class name (list\each ..signature parameters)) (/descriptor.class name) (/reflection.class name)])) (def: .public (declaration name variables) (-> External (List (Type Var)) (Type Declaration)) (:abstraction - [(/signature.declaration name (list\map ..signature variables)) + [(/signature.declaration name (list\each ..signature variables)) (/descriptor.declaration name) (/reflection.declaration name)])) @@ -140,11 +141,11 @@ (List (Type Class))] (Type Method)) (:abstraction - [(/signature.method [(list\map ..signature type_variables) - (list\map ..signature inputs) + [(/signature.method [(list\each ..signature type_variables) + (list\each ..signature inputs) (..signature output) - (list\map ..signature exceptions)]) - (/descriptor.method [(list\map ..descriptor inputs) + (list\each ..signature exceptions)]) + (/descriptor.method [(list\each ..descriptor inputs) (..descriptor output)]) (:expected ..void)])) @@ -202,7 +203,7 @@ (n.- suffix_size))] (|> repr (text.clip prefix_size name_size) - (\ maybe.monad map (|>> //name.internal //name.external)))) + (\ maybe.monad each (|>> //name.internal //name.external)))) #.None))) (def: .public format diff --git a/stdlib/source/library/lux/target/jvm/type/alias.lux b/stdlib/source/library/lux/target/jvm/type/alias.lux index 5ba678bf6..20f0b2921 100644 --- a/stdlib/source/library/lux/target/jvm/type/alias.lux +++ b/stdlib/source/library/lux/target/jvm/type/alias.lux @@ -56,7 +56,7 @@ [(def: <name> (-> (Parser (Type Class)) (Parser (Type Parameter))) (|>> (<>.after (<text>.this <prefix>)) - (\ <>.monad map <bound>)))] + (\ <>.monad each <bound>)))] [lower //signature.lower_prefix //.lower ..Lower] [upper //signature.upper_prefix //.upper ..Upper] @@ -112,7 +112,7 @@ (def: (bound_type_var aliasing) (-> Aliasing (Parser (Type Var))) (|> //parser.var_name - (\ <>.monad map //.var) + (\ <>.monad each //.var) (<>.before (<>.many (..bound aliasing))))) (def: .public (method aliasing) diff --git a/stdlib/source/library/lux/target/jvm/type/descriptor.lux b/stdlib/source/library/lux/target/jvm/type/descriptor.lux index 099a68287..c9d622ca0 100644 --- a/stdlib/source/library/lux/target/jvm/type/descriptor.lux +++ b/stdlib/source/library/lux/target/jvm/type/descriptor.lux @@ -97,7 +97,7 @@ (Descriptor Method)) (:abstraction (format (|> inputs - (list\map ..descriptor) + (list\each ..descriptor) text.together (text.enclosed ["(" ")"])) (:representation output)))) @@ -121,6 +121,6 @@ (|> (text.size repr) (n.- prefix_size) (n.- suffix_size))) - (\ maybe.monad map ///name.internal) + (\ maybe.monad each ///name.internal) maybe.trusted)))))) ) diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index 99845fa7e..d7b6f155e 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -112,8 +112,8 @@ (def: wildcard (Parser (Check Type)) (<>.after //parser.wildcard - (<>\in (check\map product.right - check.existential)))) + (<>\in (check\each product.right + check.existential)))) (def: (var mapping) (-> Mapping (Parser (Check Type))) @@ -145,7 +145,7 @@ (-> (Parser (Check Type)) (Parser (Check Type))) (|> (<>.after (<text>.this <prefix>)) ... TODO: Re-enable Lower and Upper, instead of using the simplified limit. - ... (<>\map (check\map (|>> <ctor> .type))) + ... (<>\each (check\each (|>> <ctor> .type))) ))] [lower //signature.lower_prefix ..Lower] @@ -171,25 +171,25 @@ (def: array (-> (Parser (Check Type)) (Parser (Check Type))) - (|>> (<>\map (check\map (function (_ elementT) - (case elementT - (#.Primitive name #.End) - (if (`` (or (~~ (template [<reflection>] - [(text\= (//reflection.reflection <reflection>) name)] - - [//reflection.boolean] - [//reflection.byte] - [//reflection.short] - [//reflection.int] - [//reflection.long] - [//reflection.float] - [//reflection.double] - [//reflection.char])))) - (#.Primitive (|> name //reflection.class //reflection.array //reflection.reflection) #.End) - (|> elementT array.Array .type)) - - _ - (|> elementT array.Array .type))))) + (|>> (<>\each (check\each (function (_ elementT) + (case elementT + (#.Primitive name #.End) + (if (`` (or (~~ (template [<reflection>] + [(text\= (//reflection.reflection <reflection>) name)] + + [//reflection.boolean] + [//reflection.byte] + [//reflection.short] + [//reflection.int] + [//reflection.long] + [//reflection.float] + [//reflection.double] + [//reflection.char])))) + (#.Primitive (|> name //reflection.class //reflection.array //reflection.reflection) #.End) + (|> elementT array.Array .type)) + + _ + (|> elementT array.Array .type))))) (<>.after (<text>.this //descriptor.array_prefix)))) (def: .public (type mapping) diff --git a/stdlib/source/library/lux/target/jvm/type/parser.lux b/stdlib/source/library/lux/target/jvm/type/parser.lux index 2bbbca6ca..cf0064195 100644 --- a/stdlib/source/library/lux/target/jvm/type/parser.lux +++ b/stdlib/source/library/lux/target/jvm/type/parser.lux @@ -68,7 +68,7 @@ (template [<type> <name> <head> <tail> <adapter>] [(def: .public <name> (Parser <type>) - (\ <>.functor map <adapter> + (\ <>.functor each <adapter> (<text>.slice (<text>.and! (<text>.one_of! <head>) (<text>.some! (<text>.one_of! <tail>))))))] @@ -84,7 +84,7 @@ (def: .public var (Parser (Type Var)) - (<>\map //.var ..var')) + (<>\each //.var ..var')) (def: .public var? (-> (Type Value) (Maybe Text)) @@ -104,7 +104,7 @@ [(def: <name> (-> (Parser (Type Class)) (Parser (Type Parameter))) (|>> (<>.after (<text>.this <prefix>)) - (<>\map <constructor>)))] + (<>\each <constructor>)))] [lower //signature.lower_prefix //.lower] [upper //signature.upper_prefix //.upper] @@ -125,7 +125,7 @@ (def: class' (-> (Parser (Type Parameter)) (Parser (Type Class))) (|>> ..class'' - (\ <>.monad map (product.uncurried //.class)))) + (\ <>.monad each (product.uncurried //.class)))) (def: .public parameter (Parser (Type Parameter)) @@ -143,7 +143,7 @@ (def: .public array' (-> (Parser (Type Value)) (Parser (Type Array))) (|>> (<>.after (<text>.this //descriptor.array_prefix)) - (<>\map //.array))) + (<>\each //.array))) (def: .public class (Parser (Type Class)) diff --git a/stdlib/source/library/lux/target/jvm/type/signature.lux b/stdlib/source/library/lux/target/jvm/type/signature.lux index 7195c4918..5e2f5fbdf 100644 --- a/stdlib/source/library/lux/target/jvm/type/signature.lux +++ b/stdlib/source/library/lux/target/jvm/type/signature.lux @@ -98,7 +98,7 @@ _ (format ..parameters_start (|> parameters - (list\map ..signature) + (list\each ..signature) text.together) ..parameters_end)) //descriptor.class_suffix))) @@ -133,19 +133,19 @@ "" _ (|> type_variables - (list\map (|>> ..var_name - (text.suffix ..class_bound))) + (list\each (|>> ..var_name + (text.suffix ..class_bound))) text.together (text.enclosed [..parameters_start ..parameters_end]))) (|> inputs - (list\map ..signature) + (list\each ..signature) text.together (text.enclosed [..arguments_start ..arguments_end])) (:representation output) (|> exceptions - (list\map (|>> :representation (format ..exception_prefix))) + (list\each (|>> :representation (format ..exception_prefix))) text.together)))) (implementation: .public equivalence diff --git a/stdlib/source/library/lux/target/lua.lux b/stdlib/source/library/lux/target/lua.lux index 8bac227eb..7a057f870 100644 --- a/stdlib/source/library/lux/target/lua.lux +++ b/stdlib/source/library/lux/target/lua.lux @@ -140,21 +140,21 @@ (def: .public multi (-> (List Expression) Literal) - (|>> (list\map ..code) + (|>> (list\each ..code) (text.interposed ..input_separator) :abstraction)) (def: .public array (-> (List Expression) Literal) - (|>> (list\map ..code) + (|>> (list\each ..code) (text.interposed ..input_separator) (text.enclosed ["{" "}"]) :abstraction)) (def: .public table (-> (List [Text Expression]) Literal) - (|>> (list\map (.function (_ [key value]) - (format key " = " (:representation value)))) + (|>> (list\each (.function (_ [key value]) + (format key " = " (:representation value)))) (text.interposed ..input_separator) (text.enclosed ["{" "}"]) :abstraction)) @@ -176,7 +176,7 @@ (def: .public (apply/* args func) (-> (List Expression) Expression Computation) (|> args - (list\map ..code) + (list\each ..code) (text.interposed ..input_separator) (text.enclosed ["(" ")"]) (format (:representation func)) @@ -185,7 +185,7 @@ (def: .public (do method args table) (-> Text (List Expression) Expression Computation) (|> args - (list\map ..code) + (list\each ..code) (text.interposed ..input_separator) (text.enclosed ["(" ")"]) (format (:representation table) ":" method) @@ -255,7 +255,7 @@ (def: locations (-> (List Location) Text) - (|>> (list\map ..code) + (|>> (list\each ..code) (text.interposed ..input_separator))) (def: .public (local vars) @@ -305,7 +305,7 @@ (-> (List Var) Expression Statement Statement) (:abstraction (format "for " (|> vars - (list\map ..code) + (list\each ..code) (text.interposed ..input_separator)) " in " (:representation source) " do" (..nested (:representation body!)) @@ -376,7 +376,7 @@ 0 (.list) _ (|> (-- arity) (enum.range n.enum 0) - (list\map (|>> %.nat code.local_identifier)))))) + (list\each (|>> %.nat code.local_identifier)))))) (syntax: (arity_types [arity <code>.nat]) (in (list.repeated arity (` ..Expression)))) diff --git a/stdlib/source/library/lux/target/php.lux b/stdlib/source/library/lux/target/php.lux index 4d9817ae4..031198ffa 100644 --- a/stdlib/source/library/lux/target/php.lux +++ b/stdlib/source/library/lux/target/php.lux @@ -93,8 +93,9 @@ ) (type: .public Argument - {#reference? Bit - #var Var}) + (Record + {#reference? Bit + #var Var})) (def: .public ; (-> Expression Statement) @@ -183,7 +184,7 @@ (def: arguments (-> (List Expression) Text) - (|>> (list\map ..code) (text.interposed ..input_separator) ..group)) + (|>> (list\each ..code) (text.interposed ..input_separator) ..group)) (def: .public (apply/* args func) (-> (List Expression) Expression Computation) @@ -197,10 +198,10 @@ (def: parameters (-> (List Argument) Text) - (|>> (list\map (function (_ [reference? var]) - (.if reference? - (format "&" (:representation var)) - (:representation var)))) + (|>> (list\each (function (_ [reference? var]) + (.if reference? + (format "&" (:representation var)) + (:representation var)))) (text.interposed ..input_separator) ..group)) @@ -232,7 +233,7 @@ 0 (.list) _ (|> (-- arity) (enum.range n.enum 0) - (list\map (|>> %.nat code.local_identifier)))))) + (list\each (|>> %.nat code.local_identifier)))))) (syntax: (arity_types [arity <code>.nat]) (in (list.repeated arity (` ..Expression)))) @@ -309,7 +310,7 @@ (def: .public (array/* values) (-> (List Expression) Literal) (|> values - (list\map ..code) + (list\each ..code) (text.interposed ..input_separator) ..group (format "array") @@ -322,8 +323,8 @@ (def: .public (array/** kvs) (-> (List [Expression Expression]) Literal) (|> kvs - (list\map (function (_ [key value]) - (format (:representation key) " => " (:representation value)))) + (list\each (function (_ [key value]) + (format (:representation key) " => " (:representation value)))) (text.interposed ..input_separator) ..group (format "array") @@ -475,9 +476,10 @@ ") " (..block (:representation body!))))) (type: .public Except - {#class Constant - #exception Var - #handler Statement}) + (Record + {#class Constant + #exception Var + #handler Statement})) (def: (catch except) (-> Except Text) @@ -492,7 +494,7 @@ (format "try " (..block (:representation body!)) text.new_line (|> excepts - (list\map catch) + (list\each catch) (text.interposed text.new_line))))) (template [<name> <keyword>] diff --git a/stdlib/source/library/lux/target/python.lux b/stdlib/source/library/lux/target/python.lux index 47fbc7fdc..b63e24118 100644 --- a/stdlib/source/library/lux/target/python.lux +++ b/stdlib/source/library/lux/target/python.lux @@ -191,7 +191,7 @@ ... ..expression (format left_delimiter (|> entries - (list\map entry_serializer) + (list\each entry_serializer) (text.interposed ", ")) right_delimiter)))) @@ -224,7 +224,7 @@ (-> (Expression Any) (List (Expression Any)) (Computation Any)) (<| :abstraction ... ..expression - (format (:representation func) "(" (text.interposed ", " (list\map ..code args)) ")"))) + (format (:representation func) "(" (text.interposed ", " (list\each ..code args)) ")"))) (template [<name> <brand> <prefix>] [(def: (<name> var) @@ -242,7 +242,7 @@ ... ..expression (format (:representation func) (format "(" (|> args - (list\map (function (_ arg) (format (:representation arg) ", "))) + (list\each (function (_ arg) (format (:representation arg) ", "))) text.together) (<splat> extra) ")"))))] @@ -323,13 +323,13 @@ (-> (List (Var Any)) (Expression Any) (Computation Any)) (<| :abstraction ..expression - (format "lambda " (|> arguments (list\map ..code) (text.interposed ", ")) ": " + (format "lambda " (|> arguments (list\each ..code) (text.interposed ", ")) ": " (:representation body)))) (def: .public (set vars value) (-> (List (Location Any)) (Expression Any) (Statement Any)) (:abstraction - (format (|> vars (list\map ..code) (text.interposed ", ")) + (format (|> vars (list\each ..code) (text.interposed ", ")) " = " (:representation value)))) @@ -395,9 +395,10 @@ (:abstraction "pass")) (type: .public Except - {#classes (List SVar) - #exception SVar - #handler (Statement Any)}) + (Record + {#classes (List SVar) + #exception SVar + #handler (Statement Any)})) (def: .public (try body! excepts) (-> (Statement Any) (List Except) (Statement Any)) @@ -405,10 +406,10 @@ (format "try:" (..nested (:representation body!)) (|> excepts - (list\map (function (_ [classes exception catch!]) - (format text.new_line "except (" (text.interposed ", " (list\map ..code classes)) - ") as " (:representation exception) ":" - (..nested (:representation catch!))))) + (list\each (function (_ [classes exception catch!]) + (format text.new_line "except (" (text.interposed ", " (list\each ..code classes)) + ") as " (:representation exception) ":" + (..nested (:representation catch!))))) text.together)))) (template [<name> <keyword> <pre>] @@ -437,7 +438,7 @@ (-> SVar (List (Ex [k] (Var k))) (Statement Any) (Statement Any)) (:abstraction (format "def " (:representation name) - "(" (|> args (list\map ..code) (text.interposed ", ")) "):" + "(" (|> args (list\each ..code) (text.interposed ", ")) "):" (..nested (:representation body))))) (def: .public (import module_name) @@ -462,7 +463,7 @@ 0 (.list) _ (|> (-- arity) (enum.range n.enum 0) - (list\map (|>> %.nat code.local_identifier)))))) + (list\each (|>> %.nat code.local_identifier)))))) (syntax: (arity_types [arity <code>.nat]) (in (list.repeated arity (` (Expression Any))))) diff --git a/stdlib/source/library/lux/target/r.lux b/stdlib/source/library/lux/target/r.lux index 2b4fcede3..02b192b08 100644 --- a/stdlib/source/library/lux/target/r.lux +++ b/stdlib/source/library/lux/target/r.lux @@ -174,7 +174,7 @@ (:abstraction (format func "(" (|> args - (list\map ..code) + (list\each ..code) (text.interposed (format "," text.new_line)) ..nested) ")")))) @@ -190,8 +190,8 @@ (def: .public named_list (-> (List [Text Expression]) Expression) - (|>> (list\map (.function (_ [key value]) - (:abstraction (format key "=" (:representation value))))) + (|>> (list\each (.function (_ [key value]) + (:abstraction (format key "=" (:representation value))))) ..list)) (def: .public (apply_kw args kw_args func) @@ -199,10 +199,10 @@ (..self_contained (format (:representation func) (format "(" - (text.interposed "," (list\map ..code args)) "," - (text.interposed "," (list\map (.function (_ [key val]) - (format key "=" (:representation val))) - kw_args)) + (text.interposed "," (list\each ..code args)) "," + (text.interposed "," (list\each (.function (_ [key val]) + (format key "=" (:representation val))) + kw_args)) ")")))) (syntax: (arity_inputs [arity <code>.nat]) @@ -210,7 +210,7 @@ 0 (.list) _ (|> arity list.indices - (list\map (|>> %.nat code.local_identifier)))))) + (list\each (|>> %.nat code.local_identifier)))))) (syntax: (arity_types [arity <code>.nat]) (in (list.repeated arity (` ..Expression)))) @@ -328,7 +328,7 @@ (def: .public (function inputs body) (-> (List (Ex [k] (Var k))) Expression Expression) - (let [args (|> inputs (list\map ..code) (text.interposed ", "))] + (let [args (|> inputs (list\each ..code) (text.interposed ", "))] (..self_contained (format "function(" args ") " (.._block (:representation body)))))) @@ -338,7 +338,7 @@ (let [optional (: (-> Text (Maybe Expression) (-> Text Text) Text) (.function (_ parameter value preparation) (|> value - (maybe\map (|>> :representation preparation (format ", " parameter " = "))) + (maybe\each (|>> :representation preparation (format ", " parameter " = "))) (maybe.else ""))))] (..self_contained (format "tryCatch(" diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index a63a15d09..04ddd831c 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -200,15 +200,15 @@ (def: .public array (-> (List Expression) Literal) - (|>> (list\map (|>> :representation)) + (|>> (list\each (|>> :representation)) (text.interposed ..input_separator) (text.enclosed ["[" "]"]) :abstraction)) (def: .public hash (-> (List [Expression Expression]) Literal) - (|>> (list\map (.function (_ [k v]) - (format (:representation k) " => " (:representation v)))) + (|>> (list\each (.function (_ [k v]) + (format (:representation k) " => " (:representation v)))) (text.interposed ..input_separator) (text.enclosed ["{" "}"]) :abstraction)) @@ -216,7 +216,7 @@ (def: .public (apply/* args func) (-> (List Expression) Expression Computation) (|> args - (list\map (|>> :representation)) + (list\each (|>> :representation)) (text.interposed ..input_separator) (text.enclosed ["(" ")"]) (format (:representation func)) @@ -225,7 +225,7 @@ (def: .public (apply_lambda/* args lambda) (-> (List Expression) Expression Computation) (|> args - (list\map (|>> :representation)) + (list\each (|>> :representation)) (text.interposed ..input_separator) (text.enclosed ["[" "]"]) (format (:representation lambda)) @@ -267,7 +267,7 @@ (-> (List Location) Expression Statement) (:abstraction (format (|> vars - (list\map (|>> :representation)) + (list\each (|>> :representation)) (text.interposed ..input_separator)) " = " (:representation value) ..statement_suffix))) @@ -307,9 +307,10 @@ (..nested (:representation iteration!))))) (type: .public Rescue - {#classes (List Text) - #exception LVar - #rescue Statement}) + (Record + {#classes (List Text) + #exception LVar + #rescue Statement})) (def: .public (begin body! rescues) (-> Statement (List Rescue) Statement) @@ -317,10 +318,10 @@ ..block (format "begin" (..nested (:representation body!)) (|> rescues - (list\map (.function (_ [classes exception rescue]) - (format text.new_line "rescue " (text.interposed ..input_separator classes) - " => " (:representation exception) - (..nested (:representation rescue))))) + (list\each (.function (_ [classes exception rescue]) + (format text.new_line "rescue " (text.interposed ..input_separator classes) + " => " (:representation exception) + (..nested (:representation rescue))))) (text.interposed text.new_line))))) (def: .public (catch expectation body!) @@ -356,7 +357,7 @@ ..block (format "def " (:representation name) (|> args - (list\map (|>> :representation)) + (list\each (|>> :representation)) (text.interposed ..input_separator) (text.enclosed ["(" ")"])) (..nested (:representation body!))))) @@ -364,7 +365,7 @@ (def: .public (lambda name args body!) (-> (Maybe LVar) (List Var) Statement Literal) (let [proc (|> (format (|> args - (list\map (|>> :representation)) + (list\each (|>> :representation)) (text.interposed ..input_separator) (text.enclosed' "|")) (..nested (:representation body!))) @@ -438,7 +439,7 @@ 0 (.list) _ (|> (-- arity) (enum.range n.enum 0) - (list\map (|>> %.nat code.local_identifier)))))) + (list\each (|>> %.nat code.local_identifier)))))) (syntax: (arity_types [arity <code>.nat]) (in (list.repeated arity (` ..Expression)))) diff --git a/stdlib/source/library/lux/target/scheme.lux b/stdlib/source/library/lux/target/scheme.lux index c91478519..104e8dda2 100644 --- a/stdlib/source/library/lux/target/scheme.lux +++ b/stdlib/source/library/lux/target/scheme.lux @@ -59,8 +59,9 @@ ) (type: .public Arguments - {#mandatory (List Var) - #rest (Maybe Var)}) + (Record + {#mandatory (List Var) + #rest (Maybe Var)})) (def: .public manual (-> Text Code) @@ -85,14 +86,14 @@ _ (|> (format " . " (:representation rest)) (format (|> mandatory - (list\map ..code) + (list\each ..code) (text.interposed " "))) (text.enclosed ["(" ")"]) :abstraction)) #.None (|> mandatory - (list\map ..code) + (list\each ..code) (text.interposed " ") (text.enclosed ["(" ")"]) :abstraction))) @@ -162,7 +163,7 @@ (#.Item head tail) (|> tail - (list\map (|>> :representation ..nested)) + (list\each (|>> :representation ..nested)) (#.Item (:representation head)) (text.interposed nested_new_line) (text.enclosed ["(" ")"]) @@ -309,9 +310,9 @@ (-> (List [<var> Expression]) Expression Computation) (..form (list (..var <scheme_name>) (|> bindings - (list\map (function (_ [binding/name binding/value]) - (..form (list (|> binding/name <pre>) - binding/value)))) + (list\each (function (_ [binding/name binding/value]) + (..form (list (|> binding/name <pre>) + binding/value)))) ..form) body)))] @@ -374,9 +375,9 @@ (#.Some else) (list (..form (list (..var "else") else)))) - (list\compose (list\map (function (_ [when then]) - (..form (list when then))) - clauses)) + (list\composite (list\each (function (_ [when then]) + (..form (list when then))) + clauses)) (list& variable))) body))) ) diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index 8df92c80a..afe40ea8b 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -1,5 +1,4 @@ (.module: - {#.doc "Tools for unit & property-based/generative testing."} [library [lux (#- and for) ["." meta] @@ -42,11 +41,11 @@ ["." program]]]]) (type: .public Tally - {#.doc (example "A record of successes and failures while executing tests.")} - {#successes Nat - #failures Nat - #expected_coverage (Set Name) - #actual_coverage (Set Name)}) + (Record + {#successes Nat + #failures Nat + #expected_coverage (Set Name) + #actual_coverage (Set Name)})) (def: (total parameter subject) (-> Tally Tally Tally) @@ -74,18 +73,15 @@ ) (type: .public Assertion - {#.doc (example "An asynchronous operation that yields test results.")} (Async [Tally Text])) (type: .public Test - {#.doc (example "A test that relies on random data generation to thoroughly cover different scenarios.")} (Random Assertion)) (def: separator text.new_line) (def: .public (and' left right) - {#.doc "Sequencing combinator (for assertions)."} (-> Assertion Assertion Assertion) (let [[read! write!] (: [(Async [Tally Text]) (async.Resolver [Tally Text])] @@ -100,30 +96,27 @@ read!)) (def: .public (and left right) - {#.doc "Sequencing combinator."} (-> Test Test Test) (do {! random.monad} [left left] - (\ ! map (..and' left) right))) + (\ ! each (..and' left) right))) (def: context_prefix text.tab) (def: .public (context description) - {#.doc (example "Adds a contextual description to a test's documentation.")} (-> Text Test Test) - (random\map (async\map (function (_ [tally documentation]) - [tally (|> documentation - (text.all_split_by ..separator) - (list\map (|>> (format context_prefix))) - (text.interposed ..separator) - (format description ..separator))])))) + (random\each (async\each (function (_ [tally documentation]) + [tally (|> documentation + (text.all_split_by ..separator) + (list\each (|>> (format context_prefix))) + (text.interposed ..separator) + (format description ..separator))])))) (def: failure_prefix "[Failure] ") (def: success_prefix "[Success] ") (def: .public failure - {#.doc (example "A failing test, with a given error message.")} (-> Text Test) (|>> (format ..failure_prefix) [..failure_tally] @@ -131,7 +124,6 @@ random\in)) (def: .public (assertion message condition) - {#.doc "Check that a condition is #1, and fail with the given message otherwise."} (-> Text Bit Assertion) (<| async\in (if condition @@ -139,25 +131,21 @@ [..failure_tally (format ..failure_prefix message)]))) (def: .public (test message condition) - {#.doc "Check that a condition is #1, and fail with the given message otherwise."} (-> Text Bit Test) (random\in (..assertion message condition))) (def: .public (lifted message random) (-> Text (Random Bit) Test) - (random\map (..assertion message) random)) + (random\each (..assertion message) random)) (def: pcg_32_magic_inc Nat (hex "FEDCBA9876543210")) (type: .public Seed - {#.doc "The seed value used for random testing (if that feature is used)."} Nat) (def: .public (seed value test) - {#.doc (example "Execute the given test with a specific seed value." - "This allows you to reproduce a failing test case as many times as you want while debugging.")} (-> Seed Test Test) (function (_ prng) (let [[_ result] (random.result (random.pcg_32 [..pcg_32_magic_inc value]) @@ -176,9 +164,6 @@ (exception: .public must_try_test_at_least_once) (def: .public (times amount test) - {#.doc (example "Allows executing a test several times." - "By doing this, it's possible to thoroughly test code with many different scenarios." - "This assumes that random data generation is being used in tests instead of fixed/constant inputs.")} (-> Nat Test Test) (case amount 0 (..failure (exception.error ..must_try_test_at_least_once [])) @@ -251,8 +236,6 @@ (def: success_exit_code +0) (def: .public (run! test) - {#.doc (example "Executes a test, and exits the program with either a successful or a failing exit code." - "WARNING: This procedure is only meant to be used in (program: ...) forms.")} (-> Test (Async Nothing)) (do async.monad [pre (async.future instant.now) @@ -272,13 +255,13 @@ (def: (|cover'| coverage condition) (-> (List Name) Bit Assertion) (let [message (|> coverage - (list\map %.name) + (list\each %.name) (text.interposed " & ")) coverage (set.of_list name.hash coverage)] (|> (..assertion message condition) - (async\map (function (_ [tally documentation]) - [(revised@ #actual_coverage (set.union coverage) tally) - documentation]))))) + (async\each (function (_ [tally documentation]) + [(revised@ #actual_coverage (set.union coverage) tally) + documentation]))))) (def: (|cover| coverage condition) (-> (List Name) Bit Test) @@ -288,13 +271,13 @@ (def: (|for| coverage test) (-> (List Name) Test Test) (let [context (|> coverage - (list\map %.name) + (list\each %.name) (text.interposed " & ")) coverage (set.of_list name.hash coverage)] - (random\map (async\map (function (_ [tally documentation]) - [(revised@ #actual_coverage (set.union coverage) tally) - documentation])) - (..context context test)))) + (random\each (async\each (function (_ [tally documentation]) + [(revised@ #actual_coverage (set.union coverage) tally) + documentation])) + (..context context test)))) (def: (name_code name) (-> Name Code) @@ -332,14 +315,9 @@ (template [<macro> <function>] [(syntax: .public (<macro> [coverage (<code>.tuple (<>.many <code>.any)) condition <code>.any]) - {#.doc (example "Specifies a test as covering one or more definitions." - "Adds to the test tally information to track which definitions have been tested." - (<macro> [definition/0 definition/1 ,,, definition/N] - (: Bit - (some "computation"))))} - (let [coverage (list\map (function (_ definition) - (` ((~! ..reference) (~ definition)))) - coverage)] + (let [coverage (list\each (function (_ definition) + (` ((~! ..reference) (~ definition)))) + coverage)] (in (list (` ((~! <function>) (: (.List .Name) (.list (~+ coverage))) @@ -351,14 +329,9 @@ (syntax: .public (for [coverage (<code>.tuple (<>.many <code>.any)) test <code>.any]) - {#.doc (example "Specifies a context for tests as covering one or more definitions." - "Adds to the test tally information to track which definitions have been tested." - (for [definition/0 definition/1 ,,, definition/N] - (: Test - some_test)))} - (let [coverage (list\map (function (_ definition) - (` ((~! ..reference) (~ definition)))) - coverage)] + (let [coverage (list\each (function (_ definition) + (` ((~! ..reference) (~ definition)))) + coverage)] (in (list (` ((~! ..|for|) (: (.List .Name) (.list (~+ coverage))) @@ -368,17 +341,12 @@ (-> Text Text Test Test) (let [coverage (..coverage module coverage)] (|> (..context module test) - (random\map (async\map (function (_ [tally documentation]) - [(revised@ #expected_coverage (set.union coverage) tally) - documentation])))))) + (random\each (async\each (function (_ [tally documentation]) + [(revised@ #expected_coverage (set.union coverage) tally) + documentation])))))) (syntax: .public (covering [module <code>.identifier test <code>.any]) - {#.doc (example "Specifies the module being covered by a test." - "Adds tracking information to the tally to know which exported definitions in the module need to be covered." - (covering .._ - (: Test - some_test)))} (do meta.monad [.let [module (name.module module)] definitions (meta.definitions module) @@ -399,7 +367,6 @@ ["Error" (%.text error)])) (def: .public (in_parallel tests) - {#.doc (example "Executes multiple tests in parallel (if the host platform supports it) to take advantage of multiple cores.")} (-> (List Test) Test) (case (list.size tests) 0 @@ -421,28 +388,28 @@ (..assertion (exception.error ..error_during_execution [error]) false)) io.io async.future - async\join)) + async\conjoint)) state (: (Atom (Dictionary Nat [Tally Text])) (atom.atom (dictionary.empty n.order))) [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.has 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\mix ..total ..start)) - (|> assertions - (list\map product.right) - (text.interposed ..separator))])) - (in [])))) - (run! test))) - (list.enumeration tests)))]] + _ (io.run! (monad.each io.monad + (function (_ [index test]) + (async.upon! (function (_ assertion) + (do io.monad + [[_ results] (atom.update! (dictionary.has index assertion) state)] + (if (n.= expected_tests (dictionary.size results)) + (let [assertions (|> results + dictionary.entries + (list\each product.right))] + (write! [(|> assertions + (list\each product.left) + (list\mix ..total ..start)) + (|> assertions + (list\each product.right) + (text.interposed ..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 051012a8d..9b7ce7118 100644 --- a/stdlib/source/library/lux/time.lux +++ b/stdlib/source/library/lux/time.lux @@ -23,20 +23,15 @@ [/ ["." duration (#+ Duration)]]) -(template [<name> <singular> <plural> <doc>] +(template [<name> <singular> <plural>] [(def: .public <name> - {#.doc (example <doc>)} Nat (.nat (duration.ticks <singular> <plural>)))] - [milli_seconds duration.milli_second duration.second - "Number of milli-seconds in a second."] - [seconds duration.second duration.minute - "Number of seconds in a minute."] - [minutes duration.minute duration.hour - "Number of minutes in an hour."] - [hours duration.hour duration.day - "Number of hours in an day."] + [milli_seconds duration.milli_second duration.second] + [seconds duration.second duration.minute] + [minutes duration.minute duration.hour] + [hours duration.hour duration.day] ) (def: limit @@ -82,12 +77,11 @@ ) (abstract: .public Time - {#.doc "Time is defined as milliseconds since the start of the day (00:00:00.000)."} + {} Nat (def: .public midnight - {#.doc "The instant corresponding to the start of the day: 00:00:00.000"} Time (:abstraction 0)) @@ -156,7 +150,7 @@ (def: (padded value) (-> Nat Text) (if (n.< 10 value) - (text\compose "0" (n\encoded value)) + (text\composite "0" (n\encoded value)) (n\encoded value))) (def: (positive space duration) @@ -168,17 +162,17 @@ (def: (millis_format millis) (-> Nat Text) (cond (n.= 0 millis) "" - (n.< 10 millis) ($_ text\compose ".00" (n\encoded millis)) - (n.< 100 millis) ($_ text\compose ".0" (n\encoded millis)) + (n.< 10 millis) ($_ text\composite ".00" (n\encoded millis)) + (n.< 100 millis) ($_ text\composite ".0" (n\encoded millis)) ... (n.< 1,000 millis) - ($_ text\compose "." (n\encoded millis)))) + ($_ text\composite "." (n\encoded millis)))) (type: .public Clock - {#.doc (example "A clock marking the specific hour, minute, second, and milli-second in a day.")} - {#hour Nat - #minute Nat - #second Nat - #milli_second Nat}) + (Record + {#hour Nat + #minute Nat + #second Nat + #milli_second Nat})) (def: .public (clock time) (-> Time Clock) @@ -208,15 +202,13 @@ (def: (format time) (-> Time Text) (let [(^slots [#hour #minute #second #milli_second]) (..clock time)] - ($_ text\compose + ($_ text\composite (..padded hour) ..separator (..padded minute) ..separator (..padded second) (..millis_format milli_second)))) (implementation: .public codec - {#.doc (example "Based on ISO 8601." - "For example: 21:14:51.827")} (Codec Text Time) (def: encoded ..format) diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux index dd2cae8de..7009c54eb 100644 --- a/stdlib/source/library/lux/time/date.lux +++ b/stdlib/source/library/lux/time/date.lux @@ -61,21 +61,21 @@ (-> Nat Text) (let [digits (n\encoded value)] (if (n.< 10 value) - (text\compose "0" digits) + (text\composite "0" digits) digits))) (def: separator "-") (abstract: .public Date - {#.doc (example "A date specified as a year/month/day triplet.")} + {} - {#year Year - #month Month - #day Nat} + (Record + {#year Year + #month Month + #day Nat}) (def: .public (date year month day_of_month) - {#.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 @@ -184,14 +184,12 @@ (def: (format value) (-> Date Text) - ($_ text\compose + ($_ text\composite (\ //year.codec encoded (..year value)) ..separator (..padded (|> value ..month //month.number)) ..separator (..padded (..day_of_month value)))) (implementation: .public codec - {#.doc (example "Based on ISO 8601." - "For example: 2017-01-15")} (Codec Text Date) (def: encoded ..format) diff --git a/stdlib/source/library/lux/time/day.lux b/stdlib/source/library/lux/time/day.lux index e091d2d5b..3286062ea 100644 --- a/stdlib/source/library/lux/time/day.lux +++ b/stdlib/source/library/lux/time/day.lux @@ -19,14 +19,14 @@ ["n" nat]]]]]) (type: .public Day - {#.doc (example "A day of the week.")} - #Sunday - #Monday - #Tuesday - #Wednesday - #Thursday - #Friday - #Saturday) + (Variant + #Sunday + #Monday + #Tuesday + #Wednesday + #Thursday + #Friday + #Saturday)) (implementation: .public equivalence (Equivalence Day) @@ -123,7 +123,6 @@ _ (exception.except ..not_a_day_of_the_week [value])))) (def: .public 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 f36e0dff1..7b2c8e289 100644 --- a/stdlib/source/library/lux/time/duration.lux +++ b/stdlib/source/library/lux/time/duration.lux @@ -24,7 +24,7 @@ ["#." year]]) (abstract: .public Duration - {#.doc "Durations have a resolution of milli-seconds."} + {} Int @@ -112,7 +112,7 @@ (Monoid Duration) (def: identity ..empty) - (def: compose ..merged)) + (def: composite ..merged)) (template [<value> <definition>] [(def: <definition> <value>)] @@ -129,7 +129,7 @@ (def: (encoded duration) (if (\ ..equivalence = ..empty duration) - ($_ text\compose + ($_ text\composite ..positive_sign (nat\encoded 0) ..milli_second_suffix) @@ -145,13 +145,13 @@ [minutes time_left] [(ticks minute time_left) (framed minute time_left)] [seconds time_left] [(ticks second time_left) (framed second time_left)] millis (..millis time_left)] - ($_ text\compose + ($_ text\composite (if signed? ..negative_sign ..positive_sign) - (if (i.= +0 days) "" (text\compose (nat\encoded (.nat days)) ..day_suffix)) - (if (i.= +0 hours) "" (text\compose (nat\encoded (.nat hours)) ..hour_suffix)) - (if (i.= +0 minutes) "" (text\compose (nat\encoded (.nat minutes)) ..minute_suffix)) - (if (i.= +0 seconds) "" (text\compose (nat\encoded (.nat seconds)) ..second_suffix)) - (if (i.= +0 millis) "" (text\compose (nat\encoded (.nat millis)) ..milli_second_suffix)) + (if (i.= +0 days) "" (text\composite (nat\encoded (.nat days)) ..day_suffix)) + (if (i.= +0 hours) "" (text\composite (nat\encoded (.nat hours)) ..hour_suffix)) + (if (i.= +0 minutes) "" (text\composite (nat\encoded (.nat minutes)) ..minute_suffix)) + (if (i.= +0 seconds) "" (text\composite (nat\encoded (.nat seconds)) ..second_suffix)) + (if (i.= +0 millis) "" (text\composite (nat\encoded (.nat millis)) ..milli_second_suffix)) )))) (def: parser diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux index 5b7b0e493..d8a1d0bff 100644 --- a/stdlib/source/library/lux/time/instant.lux +++ b/stdlib/source/library/lux/time/instant.lux @@ -33,7 +33,7 @@ ["." date (#+ Date)]]) (abstract: .public Instant - {#.doc "Instant is defined as milli-seconds since the epoch."} + {} Int @@ -87,7 +87,6 @@ ) (def: .public epoch - {#.doc "The instant corresponding to 1970-01-01T00:00:00Z."} Instant (..of_millis +0)) @@ -128,16 +127,16 @@ (-> Instant Text) (let [[date time] (..date_time instant) time (..clock_time time)] - ($_ text\compose + ($_ text\composite (\ date.codec encoded date) ..date_suffix (\ //.codec encoded time) ..time_suffix))) (def: parser (Parser Instant) (do {! <>.monad} - [days (\ ! map date.days date.parser) + [days (\ ! each date.days date.parser) _ (<text>.this ..date_suffix) - time (\ ! map //.millis //.parser) + time (\ ! each //.millis //.parser) _ (<text>.this ..time_suffix)] (in (|> (if (i.< +0 days) (|> duration.day @@ -148,15 +147,12 @@ ..absolute)))) (implementation: .public codec - {#.doc (example "Based on ISO 8601." - "For example: 2017-01-15T21:14:51.827Z")} (Codec Text Instant) (def: encoded ..format) (def: decoded (<text>.result ..parser))) (def: .public now - {#.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 216365ac8..c7e4af9e9 100644 --- a/stdlib/source/library/lux/time/month.lux +++ b/stdlib/source/library/lux/time/month.lux @@ -19,19 +19,19 @@ ["n" nat]]]]]) (type: .public Month - {#.doc (example "A month of the year.")} - #January - #February - #March - #April - #May - #June - #July - #August - #September - #October - #November - #December) + (Variant + #January + #February + #March + #April + #May + #June + #July + #August + #September + #October + #November + #December)) (implementation: .public equivalence (Equivalence Month) @@ -159,7 +159,6 @@ #January #December))) (def: .public (days month) - {#.doc (example "The amount of days of a month.")} (-> Month Nat) (case month (^template [<days> <month>] @@ -181,14 +180,12 @@ [31 #December]))) (def: .public (leap_year_days month) - {#.doc (example "The amount of days of a month (in a leap year).")} (-> Month Nat) (case month #February (++ (..days month)) _ (..days month))) (def: .public 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 4347aff81..e47b0d465 100644 --- a/stdlib/source/library/lux/time/year.lux +++ b/stdlib/source/library/lux/time/year.lux @@ -36,14 +36,11 @@ ... https://en.wikipedia.org/wiki/Gregorian_calendar (abstract: .public Year - {#.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 (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 +56,10 @@ ) (def: .public days - {#.doc (example "The amount of days in a typical year.")} Nat 365) (type: .public Period - {#.doc (example "An amount of years.")} Nat) (template [<period> <name>] @@ -96,7 +91,6 @@ days))) (def: .public (leaps year) - {#.doc (example "The number of leap years in a period of years.")} (-> Year Int) (let [year (|> year ..value ..internal) limit (if (i.> +0 year) @@ -124,14 +118,12 @@ (do {! <>.monad} [sign (<>.or (<text>.this "-") (in [])) digits (<text>.many <text>.decimal) - raw_year (<>.codec i.decimal (in (text\compose "+" digits)))] + raw_year (<>.codec i.decimal (in (text\composite "+" digits)))] (<>.lifted (..year (case sign (#.Left _) (i.* -1 raw_year) (#.Right _) raw_year))))) (implementation: .public codec - {#.doc (example "Based on ISO 8601." - "For example: 2017")} (Codec Text Year) (def: encoded ..encoded) diff --git a/stdlib/source/library/lux/tool/compiler.lux b/stdlib/source/library/lux/tool/compiler.lux index 10ad0d939..b1408854c 100644 --- a/stdlib/source/library/lux/tool/compiler.lux +++ b/stdlib/source/library/lux/tool/compiler.lux @@ -25,16 +25,18 @@ Text) (type: .public Input - {#module Module - #file Path - #hash Nat - #code Code}) + (Record + {#module Module + #file Path + #hash Nat + #code Code})) (type: .public (Compilation s d o) - {#dependencies (List Module) - #process (-> s Archive - (Try [s (Either (Compilation s d o) - [Descriptor (Document d) Output])]))}) + (Record + {#dependencies (List Module) + #process (-> s Archive + (Try [s (Either (Compilation s d o) + [Descriptor (Document d) Output])]))})) (type: .public (Compiler s d o) (-> Input (Compilation s d o))) diff --git a/stdlib/source/library/lux/tool/compiler/arity.lux b/stdlib/source/library/lux/tool/compiler/arity.lux index e0a3c06aa..5d20220c3 100644 --- a/stdlib/source/library/lux/tool/compiler/arity.lux +++ b/stdlib/source/library/lux/tool/compiler/arity.lux @@ -5,7 +5,8 @@ [number ["n" nat]]]]]) -(type: .public Arity Nat) +(type: .public Arity + Nat) (template [<comparison> <name>] [(def: .public <name> (-> Arity Bit) (<comparison> 1))] diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux index c01a1f6c1..d7e8ca736 100644 --- a/stdlib/source/library/lux/tool/compiler/default/init.lux +++ b/stdlib/source/library/lux/tool/compiler/default/init.lux @@ -130,7 +130,7 @@ (///directive.lifted_analysis (do {! ///phase.monad} [_ (module.create hash module) - _ (monad.map ! module.import dependencies) + _ (monad.each ! module.import dependencies) .let [source (///analysis.source (value@ #///.module input) (value@ #///.code input))] _ (///analysis.set_source_code source)] (in [source [///generation.empty_buffer @@ -259,16 +259,16 @@ (in [state (#.Right [descriptor (document.write key analysis_module) - (row\map (function (_ [artifact_id custom directive]) - [artifact_id custom (write_directive directive)]) - final_buffer)])])) + (row\each (function (_ [artifact_id custom directive]) + [artifact_id custom (write_directive directive)]) + final_buffer)])])) (#.Some [source requirements temporary_payload]) (let [[temporary_buffer temporary_registry] temporary_payload] (in [state (#.Left {#///.dependencies (|> requirements (value@ #///directive.imports) - (list\map product.left)) + (list\each product.left)) #///.process (function (_ state archive) (recur (<| (///phase.result' state) (do {! ///phase.monad} @@ -282,7 +282,7 @@ (///generation.set_registry temporary_registry)) _ (|> requirements (value@ #///directive.referrals) - (monad.map ! (execute! archive))) + (monad.each ! (execute! archive))) temporary_payload (..get_current_payload temporary_payload)] (..iteration wrapper archive expander module source temporary_payload (..module_aliases analysis_module))))))})])) )))))})))) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index 1894359a9..16571b165 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -65,12 +65,13 @@ (with_expansions [<type_vars> (as_is anchor expression directive) <Operation> (as_is ///generation.Operation <type_vars>)] (type: .public (Platform <type_vars>) - {#&file_system (file.System Async) - #host (///generation.Host expression directive) - #phase (///generation.Phase <type_vars>) - #runtime (<Operation> [Registry Output]) - #phase_wrapper (-> Archive (<Operation> ///phase.Wrapper)) - #write (-> directive Binary)}) + (Record + {#&file_system (file.System Async) + #host (///generation.Host expression directive) + #phase (///generation.Phase <type_vars>) + #runtime (<Operation> [Registry Output]) + #phase_wrapper (-> Archive (<Operation> ///phase.Wrapper)) + #write (-> directive Binary)})) ... TODO: Get rid of this (type: (Action a) @@ -103,11 +104,11 @@ _ (for {@.python (|> output row.list (list.sub 128) - (monad.map ! (monad.map ! write_artifact!)) + (monad.each ! (monad.each ! write_artifact!)) (: (Action (List (List Any)))))} (|> output row.list - (monad.map ..monad write_artifact!) + (monad.each ..monad write_artifact!) (: (Action (List Any))))) document (\ async.monad in (document.check $.key document))] @@ -190,7 +191,7 @@ _ (extension.with extender (:expected directives))] (in []))) (///phase.result' state) - (\ try.monad map product.left))) + (\ try.monad each product.left))) (def: (phase_wrapper archive platform state) (All [<type_vars>] @@ -254,8 +255,8 @@ (initialize_state (extender phase_wrapper) (:expected (..complete_extensions host_directive_bundle phase_wrapper (:expected bundles))) analysis_state) - (try\map (|>> (//init.with_default_directives expander host_analysis program anchorT,expressionT,directiveT (extender phase_wrapper)) - [phase_wrapper])))))))]] + (try\each (|>> (//init.with_default_directives expander host_analysis program anchorT,expressionT,directiveT (extender phase_wrapper)) + [phase_wrapper])))))))]] (if (archive.archived? archive archive.runtime_module) (do ! [[phase_wrapper state] (with_missing_extensions platform program state)] @@ -302,8 +303,9 @@ (Dictionary Module (Set Module))) (type: Dependence - {#depends_on Mapping - #depended_by Mapping}) + (Record + {#depends_on Mapping + #depended_by Mapping})) (def: independence Dependence @@ -489,14 +491,14 @@ (All [<type_vars>] (-> Archive <State+> (Try <State+>))) (do {! try.monad} - [modules (monad.map ! (function (_ module) - (do ! - [[descriptor document output] (archive.find module archive) - lux_module (document.read $.key document)] - (in [module lux_module]))) - (archive.archived archive)) + [modules (monad.each ! (function (_ module) + (do ! + [[descriptor document output] (archive.find module archive) + lux_module (document.read $.key document)] + (in [module lux_module]))) + (archive.archived archive)) .let [additions (|> modules - (list\map product.left) + (list\each product.left) (set.of_list text.hash))]] (in (revised@ [#extension.state #///directive.analysis @@ -506,11 +508,11 @@ (|> analysis_state (:as .Lux) (revised@ #.modules (function (_ current) - (list\compose (list.only (|>> product.left - (set.member? additions) - not) - current) - modules))) + (list\composite (list.only (|>> product.left + (set.member? additions) + not) + current) + modules))) :expected)) state)))) @@ -580,10 +582,10 @@ (#.Item _) (do ! [archive,document+ (|> new_dependencies - (list\map (import! module)) + (list\each (import! module)) (monad.all ..monad)) .let [archive (|> archive,document+ - (list\map product.left) + (list\each product.left) (list\mix archive.merged archive))]] (in [archive (try.trusted (..updated_state archive state))]))) 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 6d1f355ba..c8d3e1d9e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Variant Tuple nat int rev) + [lux (#- Tuple Variant nat int rev) [abstract [equivalence (#+ Equivalence)] [hash (#+ Hash)] @@ -35,22 +35,24 @@ ["." reference (#+ Reference) ["." variable (#+ Register Variable)]]]]) -(type: .public #rec Primitive - #Unit - (#Bit Bit) - (#Nat Nat) - (#Int Int) - (#Rev Rev) - (#Frac Frac) - (#Text Text)) +(type: .public Primitive + (.Variant + #Unit + (#Bit Bit) + (#Nat Nat) + (#Int Int) + (#Rev Rev) + (#Frac Frac) + (#Text Text))) (type: .public Tag Nat) (type: .public (Variant a) - {#lefts Nat - #right? Bit - #value a}) + (Record + {#lefts Nat + #right? Bit + #value a})) (def: .public (tag lefts right?) (-> Nat Bit Nat) @@ -74,17 +76,20 @@ (List a)) (type: .public (Composite a) - (#Variant (Variant a)) - (#Tuple (Tuple a))) + (.Variant + (#Variant (Variant a)) + (#Tuple (Tuple a)))) (type: .public #rec Pattern - (#Simple Primitive) - (#Complex (Composite Pattern)) - (#Bind Register)) + (.Variant + (#Simple Primitive) + (#Complex (Composite Pattern)) + (#Bind Register))) (type: .public (Branch' e) - {#when Pattern - #then e}) + (Record + {#when Pattern + #then e})) (type: .public (Match' e) [(Branch' e) (List (Branch' e))]) @@ -93,13 +98,14 @@ (List a)) (type: .public #rec Analysis - (#Primitive Primitive) - (#Structure (Composite Analysis)) - (#Reference Reference) - (#Case Analysis (Match' Analysis)) - (#Function (Environment Analysis) Analysis) - (#Apply Analysis Analysis) - (#Extension (Extension Analysis))) + (.Variant + (#Primitive Primitive) + (#Structure (Composite Analysis)) + (#Reference Reference) + (#Case Analysis (Match' Analysis)) + (#Function (Environment Analysis) Analysis) + (#Apply Analysis Analysis) + (#Extension (Extension Analysis)))) (type: .public Branch (Branch' Analysis)) @@ -354,7 +360,7 @@ (#Tuple members) (|> members - (list\map %analysis) + (list\each %analysis) (text.interposed " ") (text.enclosed ["[" "]"]))) @@ -368,7 +374,7 @@ (|> (%analysis body) (format " ") (format (|> environment - (list\map %analysis) + (list\each %analysis) (text.interposed " ") (text.enclosed ["[" "]"]))) (text.enclosed ["(" ")"])) @@ -377,13 +383,13 @@ (|> analysis ..application #.Item - (list\map %analysis) + (list\each %analysis) (text.interposed " ") (text.enclosed ["(" ")"])) (#Extension name parameters) (|> parameters - (list\map %analysis) + (list\each %analysis) (text.interposed " ") (format (%.text name) " ") (text.enclosed ["(" ")"])))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux index 5f2770068..fa8525f02 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux @@ -21,24 +21,28 @@ [descriptor (#+ Module)]]]]]) (type: .public (Component state phase) - {#state state - #phase phase}) + (Record + {#state state + #phase phase})) (type: .public (State anchor expression directive) - {#analysis (Component analysis.State+ - analysis.Phase) - #synthesis (Component synthesis.State+ - synthesis.Phase) - #generation (Component (generation.State+ anchor expression directive) - (generation.Phase anchor expression directive))}) + (Record + {#analysis (Component analysis.State+ + analysis.Phase) + #synthesis (Component synthesis.State+ + synthesis.Phase) + #generation (Component (generation.State+ anchor expression directive) + (generation.Phase anchor expression directive))})) (type: .public Import - {#module Module - #alias Text}) + (Record + {#module Module + #alias Text})) (type: .public Requirements - {#imports (List Import) - #referrals (List Code)}) + (Record + {#imports (List Import) + #referrals (List Code)})) (def: .public no_requirements Requirements @@ -47,8 +51,8 @@ (def: .public (merge_requirements left right) (-> Requirements Requirements Requirements) - {#imports (list\compose (value@ #imports left) (value@ #imports right)) - #referrals (list\compose (value@ #referrals left) (value@ #referrals right))}) + {#imports (list\composite (value@ #imports left) (value@ #imports right)) + #referrals (list\composite (value@ #referrals left) (value@ #referrals right))}) (template [<special> <general>] [(type: .public (<special> anchor expression directive) 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 aee61ebc7..aab4af121 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux @@ -65,14 +65,15 @@ re_load)) (type: .public (State anchor expression directive) - {#module Module - #anchor (Maybe anchor) - #host (Host expression directive) - #buffer (Maybe (Buffer directive)) - #registry artifact.Registry - #counter Nat - #context (Maybe artifact.ID) - #log (Row Text)}) + (Record + {#module Module + #anchor (Maybe anchor) + #host (Host expression directive) + #buffer (Maybe (Buffer directive)) + #registry artifact.Registry + #counter Nat + #context (Maybe artifact.ID) + #log (Row Text)})) (template [<special> <general>] [(type: .public (<special> anchor expression directive) @@ -176,7 +177,7 @@ (def: .public (identifier prefix) (All [anchor expression directive] (-> Text (Operation anchor expression directive Text))) - (\ phase.monad map (|>> %.nat (format prefix)) ..next)) + (\ phase.monad each (|>> %.nat (format prefix)) ..next)) (def: .public (enter_module module) (All [anchor expression directive] 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 6c31960e4..d5b6529f0 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 @@ -130,7 +130,7 @@ (#.Product _) (|> caseT type.flat_tuple - (list\map (re_quantify envs)) + (list\each (re_quantify envs)) type.tuple (\ ///.monad in)) @@ -314,12 +314,12 @@ [[inputT inputA] (//type.with_inference (analyse archive inputC)) outputH (analyse_pattern #.None inputT patternH (analyse archive bodyH)) - outputT (monad.map ! - (function (_ [patternT bodyT]) - (analyse_pattern #.None inputT patternT (analyse archive bodyT))) - branchesT) + outputT (monad.each ! + (function (_ [patternT bodyT]) + (analyse_pattern #.None inputT patternT (analyse archive bodyT))) + branchesT) outputHC (|> outputH product.left /coverage.determine) - outputTC (monad.map ! (|>> product.left /coverage.determine) outputT) + outputTC (monad.each ! (|>> product.left /coverage.determine) outputT) _ (.case (monad.mix try.monad /coverage.merged outputHC outputTC) (#try.Success coverage) (///.assertion non_exhaustive_pattern_matching [inputC branches coverage] 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 753f6a13e..31ed0f394 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 @@ -78,8 +78,8 @@ (#Variant ?max_cases cases) (|> cases dictionary.entries - (list\map (function (_ [idx coverage]) - (format (%.nat idx) " " (%coverage coverage)))) + (list\each (function (_ [idx coverage]) + (format (%.nat idx) " " (%coverage coverage)))) (text.interposed " ") (text.enclosed ["{" "}"]) (format (%.nat (..cases ?max_cases)) " ") 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 3589b7224..931e27eeb 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 @@ -38,8 +38,8 @@ ["Function" (%.code functionC)] ["Arguments" (|> arguments list.enumeration - (list\map (.function (_ [idx argC]) - (format (%.nat idx) " " (%.code argC)))) + (list\each (.function (_ [idx argC]) + (format (%.nat idx) " " (%.code argC)))) (text.interposed text.new_line))])) (def: .public (function analyse function_name arg_name archive body) @@ -88,10 +88,10 @@ (in functionA)))) (#.Function inputT outputT) - (<| (\ ! map (.function (_ [scope bodyA]) - (#/.Function (list\map (|>> /.variable) - (//scope.environment scope)) - bodyA))) + (<| (\ ! each (.function (_ [scope bodyA]) + (#/.Function (list\each (|>> /.variable) + (//scope.environment scope)) + bodyA))) /.with_scope ... Functions have access not only to their argument, but ... also to themselves, through a local variable. 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 452bf6bc1..36ddce2e2 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 @@ -62,7 +62,7 @@ (-> Nat Type Type Type) (case type (#.Primitive name params) - (#.Primitive name (list\map (replace parameter_idx replacement) params)) + (#.Primitive name (list\each (replace parameter_idx replacement) params)) (^template [<tag>] [(<tag> left right) @@ -80,7 +80,7 @@ (^template [<tag>] [(<tag> env quantified) - (<tag> (list\map (replace parameter_idx replacement) env) + (<tag> (list\each (replace parameter_idx replacement) env) (replace (n.+ 2 parameter_idx) replacement quantified))]) ([#.UnivQ] [#.ExQ]) @@ -184,7 +184,7 @@ (function (recur base) (case base (#.Primitive name parameters) - (#.Primitive name (list\map recur parameters)) + (#.Primitive name (list\each recur parameters)) (^template [<tag>] [(<tag> left right) @@ -198,7 +198,7 @@ (^template [<tag>] [(<tag> environment quantified) - (<tag> (list\map recur environment) quantified)]) + (<tag> (list\each recur environment) quantified)]) ([#.UnivQ] [#.ExQ]) _ @@ -230,7 +230,7 @@ (#.Product _) (let [[lefts right] (list.split_at (-- record_size) (type.flat_tuple inferT))] (///\in (|> inferT - (type.function (list\compose lefts (list (type.tuple right)))) + (type.function (list\composite lefts (list (type.tuple right)))) (substitute_bound target originalT)))) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux index abe4b8df6..1ffb4f787 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux @@ -232,15 +232,15 @@ (-> Text (List Tag) (Operation Any)) (do {! ///.monad} [bindings (..tags module_name) - _ (monad.map ! - (function (_ tag) - (case (plist.value tag bindings) - #.None - (in []) + _ (monad.each ! + (function (_ tag) + (case (plist.value tag bindings) + #.None + (in []) - (#.Some _) - (/.except ..cannot_declare_tag_twice [module_name tag]))) - tags)] + (#.Some _) + (/.except ..cannot_declare_tag_twice [module_name tag]))) + tags)] (in []))) (def: .public (declare_tags tags exported? type) @@ -260,7 +260,7 @@ (function (_ state) (case (|> state (value@ #.modules) (plist.value self_name)) (#.Some module) - (let [namespaced_tags (list\map (|>> [self_name]) tags)] + (let [namespaced_tags (list\each (|>> [self_name]) tags)] (#try.Success [(revised@ #.modules (plist.revised self_name (|>> (revised@ #.tags (function (_ tag_bindings) 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 b859c7528..c66a7b13f 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 @@ -40,8 +40,8 @@ (|> scope (value@ [#.locals #.mappings]) (plist.value name) - (maybe\map (function (_ [type value]) - [type (#variable.Local value)])))) + (maybe\each (function (_ [type value]) + [type (#variable.Local value)])))) (def: (captured? name scope) (-> Text Scope Bit) @@ -101,7 +101,7 @@ (product.right ref+inner))])) [init_ref #.End] (list.reversed inner)) - scopes (list\compose inner' outer)] + scopes (list\composite inner' outer)] (#.Right [(with@ #.scopes scopes state) (#.Some [ref_type ref])])) ))))) @@ -205,4 +205,4 @@ (-> Scope (List Variable)) (|> scope (value@ [#.captured #.mappings]) - (list\map (function (_ [_ [_ ref]]) (ref_variable ref))))) + (list\each (function (_ [_ [_ ref]]) (ref_variable ref))))) 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 b23704981..76781c92a 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 @@ -70,9 +70,9 @@ (template [<name>] [(exception: .public (<name> {key Name} {record (List [Name Code])}) (ex.report ["Tag" (%.code (code.tag key))] - ["Record" (%.code (code.record (list\map (function (_ [keyI valC]) - [(code.tag keyI) valC]) - record)))]))] + ["Record" (%.code (code.record (list\each (function (_ [keyI valC]) + [(code.tag keyI) valC]) + record)))]))] [cannot_repeat_tag] ) @@ -86,8 +86,8 @@ ["Actual" (%.nat actual)] ["Type" (%.type type)] ["Expression" (%.code (|> record - (list\map (function (_ [keyI valueC]) - [(code.tag keyI) valueC])) + (list\each (function (_ [keyI valueC]) + [(code.tag keyI) valueC])) code.record))])) (def: .public (sum analyse lefts right? archive) @@ -176,11 +176,11 @@ (case [membersT+ membersC+] [(#.Item memberT #.End) _] (//type.with_type memberT - (\ ! map (|>> list) (analyse archive (code.tuple membersC+)))) + (\ ! each (|>> list) (analyse archive (code.tuple membersC+)))) [_ (#.Item memberC #.End)] (//type.with_type (type.tuple membersT+) - (\ ! map (|>> list) (analyse archive memberC))) + (\ ! each (|>> list) (analyse archive memberC))) [(#.Item memberT membersT+') (#.Item memberC membersC+')] (do ! @@ -218,12 +218,12 @@ _ ... Must do inference... (do ! - [membersTA (monad.map ! (|>> (analyse archive) //type.with_inference) - membersC) + [membersTA (monad.each ! (|>> (analyse archive) //type.with_inference) + membersC) _ (//type.with_env (check.check expectedT - (type.tuple (list\map product.left membersTA))))] - (in (/.tuple (list\map product.right membersTA)))))) + (type.tuple (list\each product.left membersTA))))] + (in (/.tuple (list\each product.right membersTA)))))) (^template [<tag> <instancer>] [(<tag> _) @@ -285,17 +285,17 @@ ... canonical form (with their corresponding module identified). (def: .public (normal record) (-> (List [Code Code]) (Operation (List [Name Code]))) - (monad.map ///.monad - (function (_ [key val]) - (case key - [_ (#.Tag key)] - (do ///.monad - [key (///extension.lifted (meta.normal key))] - (in [key val])) - - _ - (/.except ..record_keys_must_be_tags [key record]))) - record)) + (monad.each ///.monad + (function (_ [key val]) + (case key + [_ (#.Tag key)] + (do ///.monad + [key (///extension.lifted (meta.normal key))] + (in [key val])) + + _ + (/.except ..record_keys_must_be_tags [key record]))) + record)) ... Lux already possesses the means to analyse tuples, so ... re-implementing the same functionality for records makes no sense. @@ -333,9 +333,9 @@ (: (Dictionary Nat Code) (dictionary.empty n.hash)) record) - .let [ordered_tuple (list\map (function (_ idx) - (maybe.trusted (dictionary.value idx idx->val))) - tuple_range)]] + .let [ordered_tuple (list\each (function (_ idx) + (maybe.trusted (dictionary.value idx idx->val))) + tuple_range)]] (in [size_ts ordered_tuple recordT])) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux index 98163f30d..8db59f655 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux @@ -96,12 +96,12 @@ (case expansion (^ (list& <lux_def_module> referrals)) (|> (recur archive <lux_def_module>) - (\ ! map (revised@ #/.referrals (list\compose referrals)))) + (\ ! each (revised@ #/.referrals (list\composite referrals)))) _ (|> expansion - (monad.map ! (recur archive)) - (\ ! map (list\mix /.merge_requirements /.no_requirements))))) + (monad.each ! (recur archive)) + (\ ! each (list\mix /.merge_requirements /.no_requirements))))) _ (//.except ..not_a_directive code))))))) 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 18da2442f..898766876 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 @@ -51,8 +51,9 @@ (dictionary.empty text.hash)) (type: .public (State s i o) - {#bundle (Bundle s i o) - #state s}) + (Record + {#bundle (Bundle s i o) + #state s})) (type: .public (Operation s i o v) (//.Operation (State s i o) v)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux index 16a8764d5..22c663250 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux @@ -115,7 +115,7 @@ (do {! phase.monad} [constructorA (analysis/type.with_type Any (phase archive constructorC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& constructorA inputsA)))))])) @@ -139,7 +139,7 @@ (do {! phase.monad} [objectA (analysis/type.with_type Any (phase archive objectC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& (analysis.text methodC) objectA @@ -175,7 +175,7 @@ (do {! phase.monad} [abstractionA (analysis/type.with_type Any (phase archive abstractionC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) 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 d4ffdbb2b..b1b57e1ff 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 @@ -231,7 +231,7 @@ ["Class" class] ["Method" method] ["Arguments" (exception.listing ..signature inputsJT)] - ["Hints" (exception.listing %.type (list\map product.left hints))]))] + ["Hints" (exception.listing %.type (list\each product.left hints))]))] [no_candidates] [too_many_candidates] @@ -360,7 +360,7 @@ (/////analysis.except ..non_jvm_type luxT)) (^ (#.Primitive (static array.type_name) (list elemT))) - (phase\map jvm.array (jvm_type elemT)) + (phase\each jvm.array (jvm_type elemT)) (#.Primitive class parametersT) (case (dictionary.value class ..boxes) @@ -375,17 +375,17 @@ #.None (do {! phase.monad} [parametersJT (: (Operation (List (Type Parameter))) - (monad.map ! - (function (_ parameterT) - (do phase.monad - [parameterJT (jvm_type parameterT)] - (case (jvm_parser.parameter? parameterJT) - (#.Some parameterJT) - (in parameterJT) - - #.None - (/////analysis.except ..non_parameter parameterT)))) - parametersT))] + (monad.each ! + (function (_ parameterT) + (do phase.monad + [parameterJT (jvm_type parameterT)] + (case (jvm_parser.parameter? parameterJT) + (#.Some parameterJT) + (in parameterJT) + + #.None + (/////analysis.except ..non_parameter parameterT)))) + parametersT))] (in (jvm.class class parametersJT)))) (#.Ex _) @@ -557,7 +557,7 @@ (text.starts_with? descriptor.array_prefix name) (let [[_ unprefixed] (maybe.trusted (text.split_by descriptor.array_prefix name))] - (\ phase.monad map jvm.array + (\ phase.monad each jvm.array (check_jvm (#.Primitive unprefixed (list))))) ... else @@ -567,11 +567,11 @@ (list elementT))) (|> elementT check_jvm - (phase\map jvm.array)) + (phase\each jvm.array)) (#.Primitive name parameters) (do {! phase.monad} - [parameters (monad.map ! check_parameter parameters)] + [parameters (monad.each ! check_parameter parameters)] (phase\in (jvm.class name parameters))) (#.Named name anonymous) @@ -597,7 +597,7 @@ (def: (check_object objectT) (-> .Type (Operation External)) (do {! phase.monad} - [name (\ ! map ..reflection (check_jvm objectT))] + [name (\ ! each ..reflection (check_jvm objectT))] (if (dictionary.key? ..boxes name) (/////analysis.except ..primitives_are_not_objects [name]) (phase\in name)))) @@ -864,36 +864,36 @@ (do {! phase.monad} [source_class (phase.lifted (reflection!.load class_loader source_name)) mapping (phase.lifted (reflection!.correspond source_class fromT))] - (monad.map ! - (function (_ superJT) - (do ! - [superJT (phase.lifted (reflection!.type superJT)) - .let [super_name (|> superJT ..reflection)] - super_class (phase.lifted (reflection!.load class_loader super_name)) - superT (reflection_type mapping superJT)] - (in [[super_name superT] (java/lang/Class::isAssignableFrom super_class target_class)]))) - (case (java/lang/Class::getGenericSuperclass source_class) - (#.Some super) - (list& super (array.list (java/lang/Class::getGenericInterfaces source_class))) - - #.None - (if (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers source_class)) - (#.Item (:as java/lang/reflect/Type (ffi.class_for java/lang/Object)) - (array.list (java/lang/Class::getGenericInterfaces source_class))) - (array.list (java/lang/Class::getGenericInterfaces source_class))))))) + (monad.each ! + (function (_ superJT) + (do ! + [superJT (phase.lifted (reflection!.type superJT)) + .let [super_name (|> superJT ..reflection)] + super_class (phase.lifted (reflection!.load class_loader super_name)) + superT (reflection_type mapping superJT)] + (in [[super_name superT] (java/lang/Class::isAssignableFrom super_class target_class)]))) + (case (java/lang/Class::getGenericSuperclass source_class) + (#.Some super) + (list& super (array.list (java/lang/Class::getGenericInterfaces source_class))) + + #.None + (if (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers source_class)) + (#.Item (:as java/lang/reflect/Type (ffi.class_for java/lang/Object)) + (array.list (java/lang/Class::getGenericInterfaces source_class))) + (array.list (java/lang/Class::getGenericInterfaces source_class))))))) (def: (inheritance_candidate_parents class_loader fromT target_class toT fromC) (-> java/lang/ClassLoader .Type (java/lang/Class java/lang/Object) .Type Code (Operation (List [[Text .Type] Bit]))) (case fromT (^ (#.Primitive _ (list& self_classT super_classT super_interfacesT+))) - (monad.map phase.monad - (function (_ superT) - (do {! phase.monad} - [super_name (\ ! map ..reflection (check_jvm superT)) - super_class (phase.lifted (reflection!.load class_loader super_name))] - (in [[super_name superT] - (java/lang/Class::isAssignableFrom super_class target_class)]))) - (list& super_classT super_interfacesT+)) + (monad.each phase.monad + (function (_ superT) + (do {! phase.monad} + [super_name (\ ! each ..reflection (check_jvm superT)) + super_class (phase.lifted (reflection!.load class_loader super_name))] + (in [[super_name superT] + (java/lang/Class::isAssignableFrom super_class target_class)]))) + (list& super_classT super_interfacesT+)) _ (/////analysis.except ..cannot_cast [fromT toT fromC]))) @@ -905,10 +905,10 @@ (^ (list fromC)) (do {! phase.monad} [toT (///.lifted meta.expected_type) - target_name (\ ! map ..reflection (check_jvm toT)) + target_name (\ ! each ..reflection (check_jvm toT)) [fromT fromA] (typeA.with_inference (analyse archive fromC)) - source_name (\ ! map ..reflection (check_jvm fromT)) + source_name (\ ! each ..reflection (check_jvm fromT)) can_cast? (: (Operation Bit) (`` (cond (~~ (template [<primitive> <object>] [(let [=primitive (reflection.reflection <primitive>)] @@ -951,7 +951,7 @@ (class_candidate_parents class_loader current_name currentT target_name target_class)))] (case (|> candidate_parents (list.only product.right) - (list\map product.left)) + (list\each product.left)) (#.Item [next_name nextT] _) (recur [next_name nextT]) @@ -1090,7 +1090,7 @@ (do phase.monad [parameters (|> (java/lang/reflect/Method::getGenericParameterTypes method) array.list - (monad.map try.monad reflection!.type) + (monad.each try.monad reflection!.type) phase.lifted) .let [modifiers (java/lang/reflect/Method::getModifiers method) correct_class? (java/lang/Object::equals class (java/lang/reflect/Method::getDeclaringClass method)) @@ -1136,7 +1136,7 @@ (do phase.monad [parameters (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor) array.list - (monad.map try.monad reflection!.type) + (monad.each try.monad reflection!.type) phase.lifted)] (in (and (java/lang/Object::equals class (java/lang/reflect/Constructor::getDeclaringClass constructor)) (n.= (list.size inputsJT) (list.size parameters)) @@ -1159,15 +1159,15 @@ (def: (jvm_type_var_mapping owner_tvars method_tvars) (-> (List Text) (List Text) [(List .Type) Mapping]) - (let [jvm_tvars (list\compose owner_tvars method_tvars) + (let [jvm_tvars (list\composite owner_tvars method_tvars) lux_tvars (|> jvm_tvars list.reversed list.enumeration - (list\map (function (_ [idx name]) - [name (index_parameter idx)])) + (list\each (function (_ [idx name]) + [name (index_parameter idx)])) list.reversed) num_owner_tvars (list.size owner_tvars) - owner_tvarsT (|> lux_tvars (list.first num_owner_tvars) (list\map product.right)) + owner_tvarsT (|> lux_tvars (list.first num_owner_tvars) (list\each product.right)) mapping (dictionary.of_list text.hash lux_tvars)] [owner_tvarsT mapping])) @@ -1181,28 +1181,28 @@ _ (|> (java/lang/Class::getTypeParameters owner) array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName)))) + (list\each (|>> java/lang/reflect/TypeVariable::getName)))) method_tvars (|> (java/lang/reflect/Method::getTypeParameters method) array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName))) + (list\each (|>> java/lang/reflect/TypeVariable::getName))) [owner_tvarsT mapping] (jvm_type_var_mapping owner_tvars method_tvars)] (do {! phase.monad} [inputsT (|> (java/lang/reflect/Method::getGenericParameterTypes method) array.list - (monad.map ! (|>> reflection!.type phase.lifted)) - (phase\map (monad.map ! (..reflection_type mapping))) - phase\join) + (monad.each ! (|>> reflection!.type phase.lifted)) + (phase\each (monad.each ! (..reflection_type mapping))) + phase\conjoint) outputT (|> method java/lang/reflect/Method::getGenericReturnType reflection!.return phase.lifted - (phase\map (..reflection_return mapping)) - phase\join) + (phase\each (..reflection_return mapping)) + phase\conjoint) exceptionsT (|> (java/lang/reflect/Method::getGenericExceptionTypes method) array.list - (monad.map ! (|>> reflection!.type phase.lifted)) - (phase\map (monad.map ! (..reflection_type mapping))) - phase\join) + (monad.each ! (|>> reflection!.type phase.lifted)) + (phase\each (monad.each ! (..reflection_type mapping))) + phase\conjoint) .let [methodT (<| (type.univ_q (dictionary.size mapping)) (type.function (case method_style #Static @@ -1221,22 +1221,22 @@ (let [owner (java/lang/reflect/Constructor::getDeclaringClass constructor) owner_tvars (|> (java/lang/Class::getTypeParameters owner) array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName))) + (list\each (|>> java/lang/reflect/TypeVariable::getName))) method_tvars (|> (java/lang/reflect/Constructor::getTypeParameters constructor) array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName))) + (list\each (|>> java/lang/reflect/TypeVariable::getName))) [owner_tvarsT mapping] (jvm_type_var_mapping owner_tvars method_tvars)] (do {! phase.monad} [inputsT (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor) array.list - (monad.map ! (|>> reflection!.type phase.lifted)) - (phase\map (monad.map ! (reflection_type mapping))) - phase\join) + (monad.each ! (|>> reflection!.type phase.lifted)) + (phase\each (monad.each ! (reflection_type mapping))) + phase\conjoint) exceptionsT (|> (java/lang/reflect/Constructor::getGenericExceptionTypes constructor) array.list - (monad.map ! (|>> reflection!.type phase.lifted)) - (phase\map (monad.map ! (reflection_type mapping))) - phase\join) + (monad.each ! (|>> reflection!.type phase.lifted)) + (phase\each (monad.each ! (reflection_type mapping))) + phase\conjoint) .let [objectT (#.Primitive (java/lang/Class::getName owner) owner_tvarsT) constructorT (<| (type.univ_q (dictionary.size mapping)) (type.function inputsT) @@ -1267,7 +1267,7 @@ (-> <type> (List (Type Var))) (|>> <method> array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName jvm.var))))] + (list\each (|>> java/lang/reflect/TypeVariable::getName jvm.var))))] [class_type_variables (java/lang/Class java/lang/Object) java/lang/Class::getTypeParameters] [constructor_type_variables (java/lang/reflect/Constructor java/lang/Object) java/lang/reflect/Constructor::getTypeParameters] @@ -1276,8 +1276,8 @@ (def: (aliasing expected actual) (-> (List (Type Var)) (List (Type Var)) Aliasing) - (|> (list.zipped/2 (list\map jvm_parser.name actual) - (list\map jvm_parser.name expected)) + (|> (list.zipped/2 (list\each jvm_parser.name actual) + (list\each jvm_parser.name expected)) (dictionary.of_list text.hash))) (def: (method_candidate class_loader actual_class_tvars class_name actual_method_tvars method_name method_style inputsJT) @@ -1289,17 +1289,17 @@ java/lang/Class::getDeclaredMethods array.list (list.only (|>> java/lang/reflect/Method::getName (text\= method_name))) - (monad.map ! (: (-> java/lang/reflect/Method (Operation Evaluation)) - (function (_ method) - (do ! - [.let [expected_method_tvars (method_type_variables method) - aliasing (dictionary.merged (..aliasing expected_class_tvars actual_class_tvars) - (..aliasing expected_method_tvars actual_method_tvars))] - passes? (check_method aliasing class method_name method_style inputsJT method)] - (\ ! map (if passes? - (|>> #Pass) - (|>> #Hint)) - (method_signature method_style method)))))))] + (monad.each ! (: (-> java/lang/reflect/Method (Operation Evaluation)) + (function (_ method) + (do ! + [.let [expected_method_tvars (method_type_variables method) + aliasing (dictionary.merged (..aliasing expected_class_tvars actual_class_tvars) + (..aliasing expected_method_tvars actual_method_tvars))] + passes? (check_method aliasing class method_name method_style inputsJT method)] + (\ ! each (if passes? + (|>> #Pass) + (|>> #Hint)) + (method_signature method_style method)))))))] (case (list.all pass! candidates) (#.Item method #.End) (in method) @@ -1321,15 +1321,15 @@ candidates (|> class java/lang/Class::getConstructors array.list - (monad.map ! (function (_ constructor) - (do ! - [.let [expected_method_tvars (constructor_type_variables constructor) - aliasing (dictionary.merged (..aliasing expected_class_tvars actual_class_tvars) - (..aliasing expected_method_tvars actual_method_tvars))] - passes? (check_constructor aliasing class inputsJT constructor)] - (\ ! map - (if passes? (|>> #Pass) (|>> #Hint)) - (constructor_signature constructor))))))] + (monad.each ! (function (_ constructor) + (do ! + [.let [expected_method_tvars (constructor_type_variables constructor) + aliasing (dictionary.merged (..aliasing expected_class_tvars actual_class_tvars) + (..aliasing expected_method_tvars actual_method_tvars))] + passes? (check_constructor aliasing class inputsJT constructor)] + (\ ! each + (if passes? (|>> #Pass) (|>> #Hint)) + (constructor_signature constructor))))))] (case (list.all pass! candidates) (#.Item constructor #.End) (in constructor) @@ -1358,9 +1358,9 @@ (def: (decorate_inputs typesT inputsA) (-> (List (Type Value)) (List Analysis) (List Analysis)) (|> inputsA - (list.zipped/2 (list\map (|>> ..signature /////analysis.text) typesT)) - (list\map (function (_ [type value]) - (/////analysis.tuple (list type value)))))) + (list.zipped/2 (list\each (|>> ..signature /////analysis.text) typesT)) + (list\each (function (_ [type value]) + (/////analysis.tuple (list type value)))))) (def: type_vars (<code>.tuple (<>.some ..var))) @@ -1372,11 +1372,11 @@ (function (_ extension_name analyse archive [class_tvars [class method] method_tvars argsTC]) (do phase.monad [_ (..ensure_fresh_class! class_loader class) - .let [argsT (list\map product.left argsTC)] + .let [argsT (list\each product.left argsTC)] [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method #Static argsT) _ (phase.assertion ..deprecated_method [class method methodT] (not deprecated?)) - [outputT argsA] (inferenceA.general archive analyse methodT (list\map product.right argsTC)) + [outputT argsA] (inferenceA.general archive analyse methodT (list\each product.right argsTC)) outputJT (check_return outputT)] (in (#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) @@ -1390,11 +1390,11 @@ (function (_ extension_name analyse archive [class_tvars [class method] method_tvars objectC argsTC]) (do phase.monad [_ (..ensure_fresh_class! class_loader class) - .let [argsT (list\map product.left argsTC)] + .let [argsT (list\each product.left argsTC)] [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method #Virtual argsT) _ (phase.assertion ..deprecated_method [class method methodT] (not deprecated?)) - [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\map product.right argsTC))) + [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\each product.right argsTC))) .let [[objectA argsA] (case allA (#.Item objectA argsA) [objectA argsA] @@ -1415,11 +1415,11 @@ (function (_ extension_name analyse archive [class_tvars [class method] method_tvars objectC argsTC]) (do phase.monad [_ (..ensure_fresh_class! class_loader class) - .let [argsT (list\map product.left argsTC)] + .let [argsT (list\each product.left argsTC)] [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method #Special argsT) _ (phase.assertion ..deprecated_method [class method methodT] (not deprecated?)) - [outputT argsA] (inferenceA.general archive analyse methodT (list& objectC (list\map product.right argsTC))) + [outputT argsA] (inferenceA.general archive analyse methodT (list& objectC (list\each product.right argsTC))) outputJT (check_return outputT)] (in (#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) @@ -1433,14 +1433,14 @@ (function (_ extension_name analyse archive [class_tvars [class_name method] method_tvars objectC argsTC]) (do phase.monad [_ (..ensure_fresh_class! class_loader class_name) - .let [argsT (list\map product.left argsTC)] + .let [argsT (list\each product.left argsTC)] class (phase.lifted (reflection!.load class_loader class_name)) _ (phase.assertion non_interface class_name (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers class))) [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class_name method_tvars method #Interface argsT) _ (phase.assertion ..deprecated_method [class_name method methodT] (not deprecated?)) - [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\map product.right argsTC))) + [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\each product.right argsTC))) .let [[objectA argsA] (case allA (#.Item objectA argsA) [objectA argsA] @@ -1462,11 +1462,11 @@ (function (_ extension_name analyse archive [class_tvars class method_tvars argsTC]) (do phase.monad [_ (..ensure_fresh_class! class_loader class) - .let [argsT (list\map product.left argsTC)] + .let [argsT (list\each product.left argsTC)] [methodT deprecated? exceptionsT] (..constructor_candidate class_loader class_tvars class method_tvars argsT) _ (phase.assertion ..deprecated_method [class ..constructor_method methodT] (not deprecated?)) - [outputT argsA] (inferenceA.general archive analyse methodT (list\map product.right argsTC))] + [outputT argsA] (inferenceA.general archive analyse methodT (list\each product.right argsTC))] (in (#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (decorate_inputs argsT argsA))))))])) @@ -1517,7 +1517,7 @@ (def: (annotation_analysis [name parameters]) (-> (Annotation Analysis) Analysis) (/////analysis.tuple (list& (/////analysis.text name) - (list\map annotation_parameter_analysis parameters)))) + (list\each annotation_parameter_analysis parameters)))) (template [<name> <category>] [(def: <name> @@ -1547,24 +1547,24 @@ (|>> java/lang/Class::getDeclaredMethods array.list <only> - (monad.map try.monad - (function (_ method) - (do {! try.monad} - [.let [type_variables (|> (java/lang/reflect/Method::getTypeParameters method) - array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName - jvm.var)))] - inputs (|> (java/lang/reflect/Method::getGenericParameterTypes method) - array.list - (monad.map ! reflection!.type)) - return (|> method - java/lang/reflect/Method::getGenericReturnType - reflection!.return) - exceptions (|> (java/lang/reflect/Method::getGenericExceptionTypes method) - array.list - (monad.map ! reflection!.class))] - (in [(java/lang/reflect/Method::getName method) - (jvm.method [type_variables inputs return exceptions])]))))))] + (monad.each try.monad + (function (_ method) + (do {! try.monad} + [.let [type_variables (|> (java/lang/reflect/Method::getTypeParameters method) + array.list + (list\each (|>> java/lang/reflect/TypeVariable::getName + jvm.var)))] + inputs (|> (java/lang/reflect/Method::getGenericParameterTypes method) + array.list + (monad.each ! reflection!.type)) + return (|> method + java/lang/reflect/Method::getGenericReturnType + reflection!.return) + exceptions (|> (java/lang/reflect/Method::getGenericExceptionTypes method) + array.list + (monad.each ! reflection!.class))] + (in [(java/lang/reflect/Method::getName method) + (jvm.method [type_variables inputs return exceptions])]))))))] [abstract_methods (list.only (|>> java/lang/reflect/Method::getModifiers java/lang/reflect/Modifier::isAbstract))] [methods (<|)] @@ -1575,10 +1575,10 @@ (template [<name> <methods>] [(def: (<name> class_loader) (-> java/lang/ClassLoader (List (Type Class)) (Try (List [Text (Type Method)]))) - (|>> (monad.map try.monad (|>> ..reflection (reflection!.load class_loader))) - (try\map (monad.map try.monad <methods>)) - try\join - (try\map list\join)))] + (|>> (monad.each try.monad (|>> ..reflection (reflection!.load class_loader))) + (try\each (monad.each try.monad <methods>)) + try\conjoint + (try\each list\conjoint)))] [all_abstract_methods ..abstract_methods] [all_methods ..methods] @@ -1660,28 +1660,28 @@ annotations vars exceptions self_name arguments super_arguments body] method] (do {! phase.monad} - [annotationsA (monad.map ! (function (_ [name parameters]) - (do ! - [parametersA (monad.map ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) - super_arguments (monad.map ! (function (_ [jvmT super_argC]) - (do ! - [luxT (reflection_type mapping jvmT) - super_argA (typeA.with_type luxT - (analyse archive super_argC))] - (in [jvmT super_argA]))) - super_arguments) - arguments' (monad.map ! - (function (_ [name jvmT]) - (do ! - [luxT (boxed_reflection_type mapping jvmT)] - (in [name luxT]))) - arguments) + [annotationsA (monad.each ! (function (_ [name parameters]) + (do ! + [parametersA (monad.each ! (function (_ [name value]) + (do ! + [valueA (analyse archive value)] + (in [name valueA]))) + parameters)] + (in [name parametersA]))) + annotations) + super_arguments (monad.each ! (function (_ [jvmT super_argC]) + (do ! + [luxT (reflection_type mapping jvmT) + super_argA (typeA.with_type luxT + (analyse archive super_argC))] + (in [jvmT super_argA]))) + super_arguments) + arguments' (monad.each ! + (function (_ [name jvmT]) + (do ! + [luxT (boxed_reflection_type mapping jvmT)] + (in [name luxT]))) + arguments) [scope bodyA] (|> arguments' (#.Item [self_name selfT]) list.reversed @@ -1691,15 +1691,15 @@ (in (/////analysis.tuple (list (/////analysis.text ..constructor_tag) (visibility_analysis visibility) (/////analysis.bit strict_fp?) - (/////analysis.tuple (list\map annotation_analysis annotationsA)) - (/////analysis.tuple (list\map var_analysis vars)) + (/////analysis.tuple (list\each annotation_analysis annotationsA)) + (/////analysis.tuple (list\each var_analysis vars)) (/////analysis.text self_name) - (/////analysis.tuple (list\map ..argument_analysis arguments)) - (/////analysis.tuple (list\map class_analysis exceptions)) - (/////analysis.tuple (list\map typed_analysis super_arguments)) + (/////analysis.tuple (list\each ..argument_analysis arguments)) + (/////analysis.tuple (list\each class_analysis exceptions)) + (/////analysis.tuple (list\each typed_analysis super_arguments)) (#/////analysis.Function - (list\map (|>> /////analysis.variable) - (scope.environment scope)) + (list\each (|>> /////analysis.variable) + (scope.environment scope)) (/////analysis.tuple (list bodyA))) )))))) @@ -1742,22 +1742,22 @@ self_name arguments return exceptions body] method] (do {! phase.monad} - [annotationsA (monad.map ! (function (_ [name parameters]) - (do ! - [parametersA (monad.map ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) + [annotationsA (monad.each ! (function (_ [name parameters]) + (do ! + [parametersA (monad.each ! (function (_ [name value]) + (do ! + [valueA (analyse archive value)] + (in [name valueA]))) + parameters)] + (in [name parametersA]))) + annotations) returnT (reflection_return mapping return) - arguments' (monad.map ! - (function (_ [name jvmT]) - (do ! - [luxT (boxed_reflection_type mapping jvmT)] - (in [name luxT]))) - arguments) + arguments' (monad.each ! + (function (_ [name jvmT]) + (do ! + [luxT (boxed_reflection_type mapping jvmT)] + (in [name luxT]))) + arguments) [scope bodyA] (|> arguments' (#.Item [self_name selfT]) list.reversed @@ -1769,15 +1769,15 @@ (visibility_analysis visibility) (/////analysis.bit final?) (/////analysis.bit strict_fp?) - (/////analysis.tuple (list\map annotation_analysis annotationsA)) - (/////analysis.tuple (list\map var_analysis vars)) + (/////analysis.tuple (list\each annotation_analysis annotationsA)) + (/////analysis.tuple (list\each var_analysis vars)) (/////analysis.text self_name) - (/////analysis.tuple (list\map ..argument_analysis arguments)) + (/////analysis.tuple (list\each ..argument_analysis arguments)) (return_analysis return) - (/////analysis.tuple (list\map class_analysis exceptions)) + (/////analysis.tuple (list\each class_analysis exceptions)) (#/////analysis.Function - (list\map (|>> /////analysis.variable) - (scope.environment scope)) + (list\each (|>> /////analysis.variable) + (scope.environment scope)) (/////analysis.tuple (list bodyA))) )))))) @@ -1816,22 +1816,22 @@ arguments return body] method] (do {! phase.monad} - [annotationsA (monad.map ! (function (_ [name parameters]) - (do ! - [parametersA (monad.map ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) + [annotationsA (monad.each ! (function (_ [name parameters]) + (do ! + [parametersA (monad.each ! (function (_ [name value]) + (do ! + [valueA (analyse archive value)] + (in [name valueA]))) + parameters)] + (in [name parametersA]))) + annotations) returnT (reflection_return mapping return) - arguments' (monad.map ! - (function (_ [name jvmT]) - (do ! - [luxT (boxed_reflection_type mapping jvmT)] - (in [name luxT]))) - arguments) + arguments' (monad.each ! + (function (_ [name jvmT]) + (do ! + [luxT (boxed_reflection_type mapping jvmT)] + (in [name luxT]))) + arguments) [scope bodyA] (|> arguments' list.reversed (list\mix scope.with_local (analyse archive body)) @@ -1841,15 +1841,15 @@ (/////analysis.text method_name) (visibility_analysis visibility) (/////analysis.bit strict_fp?) - (/////analysis.tuple (list\map annotation_analysis annotationsA)) - (/////analysis.tuple (list\map var_analysis vars)) - (/////analysis.tuple (list\map ..argument_analysis arguments)) + (/////analysis.tuple (list\each annotation_analysis annotationsA)) + (/////analysis.tuple (list\each var_analysis vars)) + (/////analysis.tuple (list\each ..argument_analysis arguments)) (return_analysis return) - (/////analysis.tuple (list\map class_analysis - exceptions)) + (/////analysis.tuple (list\each class_analysis + exceptions)) (#/////analysis.Function - (list\map (|>> /////analysis.variable) - (scope.environment scope)) + (list\each (|>> /////analysis.variable) + (scope.environment scope)) (/////analysis.tuple (list bodyA))) )))))) @@ -1910,12 +1910,12 @@ (if (n.= expected_count actual_count) (do {! phase.monad} [parent_parameters (|> parent_parameters - (monad.map maybe.monad jvm_parser.var?) + (monad.each maybe.monad jvm_parser.var?) try.of_maybe phase.lifted)] (|> super_parameters - (monad.map ! (..reflection_type mapping)) - (\ ! map (|>> (list.zipped/2 parent_parameters))))) + (monad.each ! (..reflection_type mapping)) + (\ ! each (|>> (list.zipped/2 parent_parameters))))) (phase.lifted (exception.except ..mismatched_super_parameters [parent_name expected_count actual_count])))) #.None @@ -1924,12 +1924,12 @@ (def: .public (with_fresh_type_vars vars mapping) (-> (List (Type Var)) Mapping (Operation Mapping)) (do {! phase.monad} - [pairings (monad.map ! (function (_ var) - (do ! - [[_ exT] (typeA.with_env - check.existential)] - (in [var exT]))) - vars)] + [pairings (monad.each ! (function (_ var) + (do ! + [[_ exT] (typeA.with_env + check.existential)] + (in [var exT]))) + vars)] (in (list\mix (function (_ [varJ varT] mapping) (dictionary.has (jvm_parser.name varJ) varT mapping)) mapping @@ -1967,7 +1967,7 @@ (#/////analysis.Complex (#/////analysis.Tuple (|> arity list.indices - (list\map (|>> (n.+ 2) #/////analysis.Bind))))) + (list\each (|>> (n.+ 2) #/////analysis.Bind))))) #/////analysis.then bodyA} @@ -1982,21 +1982,21 @@ (do {! phase.monad} [mapping (..with_override_mapping supers parent_type mapping) mapping (..with_fresh_type_vars vars mapping) - annotationsA (monad.map ! (function (_ [name parameters]) - (do ! - [parametersA (monad.map ! (function (_ [name value]) - (do ! - [valueA (analyse archive value)] - (in [name valueA]))) - parameters)] - (in [name parametersA]))) - annotations) - arguments' (monad.map ! - (function (_ [name jvmT]) - (do ! - [luxT (boxed_reflection_type mapping jvmT)] - (in [name luxT]))) - arguments) + annotationsA (monad.each ! (function (_ [name parameters]) + (do ! + [parametersA (monad.each ! (function (_ [name value]) + (do ! + [valueA (analyse archive value)] + (in [name valueA]))) + parameters)] + (in [name parametersA]))) + annotations) + arguments' (monad.each ! + (function (_ [name jvmT]) + (do ! + [luxT (boxed_reflection_type mapping jvmT)] + (in [name luxT]))) + arguments) returnT (boxed_reflection_return mapping return) [scope bodyA] (|> arguments' (#.Item [self_name selfT]) @@ -2008,16 +2008,16 @@ (class_analysis parent_type) (/////analysis.text method_name) (/////analysis.bit strict_fp?) - (/////analysis.tuple (list\map annotation_analysis annotationsA)) - (/////analysis.tuple (list\map var_analysis vars)) + (/////analysis.tuple (list\each annotation_analysis annotationsA)) + (/////analysis.tuple (list\each var_analysis vars)) (/////analysis.text self_name) - (/////analysis.tuple (list\map ..argument_analysis arguments)) + (/////analysis.tuple (list\each ..argument_analysis arguments)) (return_analysis return) - (/////analysis.tuple (list\map class_analysis - exceptions)) + (/////analysis.tuple (list\each class_analysis + exceptions)) (#/////analysis.Function - (list\map (|>> /////analysis.variable) - (scope.environment scope)) + (list\each (|>> /////analysis.variable) + (scope.environment scope)) (..hide_method_body (list.size arguments) bodyA)) )))))) @@ -2026,11 +2026,11 @@ (def: .public parameter_types (-> (List (Type Var)) (Check (List [(Type Var) .Type]))) - (monad.map check.monad - (function (_ parameterJ) - (do check.monad - [[_ parameterT] check.existential] - (in [parameterJ parameterT]))))) + (monad.each check.monad + (function (_ parameterJ) + (do check.monad + [[_ parameterT] check.existential] + (in [parameterJ parameterT]))))) (def: (mismatched_methods super_set sub_set) (-> (List [Text (Type Method)]) @@ -2061,7 +2061,7 @@ class (phase.lifted (reflection!.load class_loader name)) .let [expected_parameters (|> (java/lang/Class::getTypeParameters class) array.list - (list\map (|>> java/lang/reflect/TypeVariable::getName)))] + (list\each (|>> java/lang/reflect/TypeVariable::getName)))] _ (phase.assertion ..class_parameter_mismatch [expected_parameters actual_parameters] (n.= (list.size expected_parameters) (list.size actual_parameters)))] @@ -2086,18 +2086,18 @@ (do {! phase.monad} [required_abstract_methods (phase.lifted (all_abstract_methods class_loader supers)) available_methods (phase.lifted (all_methods class_loader supers)) - overriden_methods (monad.map ! (function (_ [parent_type method_name - strict_fp? annotations type_vars - self_name arguments return exceptions - body]) - (do ! - [aliasing (super_aliasing class_loader parent_type)] - (in [method_name (|> (jvm.method [type_vars - (list\map product.right arguments) - return - exceptions]) - (jvm_alias.method aliasing))]))) - methods) + overriden_methods (monad.each ! (function (_ [parent_type method_name + strict_fp? annotations type_vars + self_name arguments return exceptions + body]) + (do ! + [aliasing (super_aliasing class_loader parent_type)] + (in [method_name (|> (jvm.method [type_vars + (list\each product.right arguments) + return + exceptions]) + (jvm_alias.method aliasing))]))) + methods) .let [missing_abstract_methods (mismatched_methods overriden_methods required_abstract_methods) invalid_overriden_methods (mismatched_methods available_methods overriden_methods)] _ (phase.assertion ..missing_abstract_methods missing_abstract_methods @@ -2122,7 +2122,7 @@ methods]) (do {! phase.monad} [_ (..ensure_fresh_class! class_loader (..reflection super_class)) - _ (monad.map ! (|>> ..reflection (..ensure_fresh_class! class_loader)) super_interfaces) + _ (monad.each ! (|>> ..reflection (..ensure_fresh_class! class_loader)) super_interfaces) parameters (typeA.with_env (..parameter_types parameters)) .let [mapping (list\mix (function (_ [parameterJ parameterT] mapping) @@ -2134,9 +2134,9 @@ super_classT (typeA.with_env (luxT.check (luxT.class mapping) (..signature super_class))) super_interfaceT+ (typeA.with_env - (monad.map check.monad - (|>> ..signature (luxT.check (luxT.class mapping))) - super_interfaces)) + (monad.each check.monad + (|>> ..signature (luxT.check (luxT.class mapping))) + super_interfaces)) selfT (///.lifted (do meta.monad [where meta.current_module_name id meta.seed] @@ -2144,20 +2144,20 @@ super_classT super_interfaceT+)))) _ (typeA.infer selfT) - constructor_argsA+ (monad.map ! (function (_ [type term]) - (do ! - [argT (reflection_type mapping type) - termA (typeA.with_type argT - (analyse archive term))] - (in [type termA]))) - constructor_args) + constructor_argsA+ (monad.each ! (function (_ [type term]) + (do ! + [argT (reflection_type mapping type) + termA (typeA.with_type argT + (analyse archive term))] + (in [type termA]))) + constructor_args) .let [supers (#.Item super_class super_interfaces)] _ (..require_complete_method_concretion class_loader supers methods) - methodsA (monad.map ! (analyse_overriden_method analyse archive selfT mapping supers) methods)] + methodsA (monad.each ! (analyse_overriden_method analyse archive selfT mapping supers) methods)] (in (#/////analysis.Extension extension_name (list (class_analysis super_class) - (/////analysis.tuple (list\map class_analysis super_interfaces)) - (/////analysis.tuple (list\map typed_analysis constructor_argsA+)) + (/////analysis.tuple (list\each class_analysis super_interfaces)) + (/////analysis.tuple (list\each typed_analysis constructor_argsA+)) (/////analysis.tuple methodsA))))))])) (def: (bundle::class class_loader) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux index 9428404aa..7cfd9eed6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux @@ -139,7 +139,7 @@ (do {! phase.monad} [objectA (analysis/type.with_type ..Object (phase archive objectC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& (analysis.text methodC) objectA @@ -196,7 +196,7 @@ (do {! phase.monad} [abstractionA (analysis/type.with_type ..Function (phase archive abstractionC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) 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 e56a48572..827edf300 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 @@ -55,11 +55,11 @@ (if (n.= num_expected num_actual) (do {! ////.monad} [_ (typeA.infer outputT) - argsA (monad.map ! - (function (_ [argT argC]) - (typeA.with_type argT - (analyse archive argC))) - (list.zipped/2 inputsT+ args))] + argsA (monad.each ! + (function (_ [argT argC]) + (typeA.with_type argT + (analyse archive argC))) + (list.zipped/2 inputsT+ args))] (in (#////analysis.Extension extension_name argsA))) (////analysis.except ///.incorrect_arity [extension_name num_expected num_actual])))))) @@ -105,19 +105,19 @@ [input (typeA.with_type text.Char (phase archive input)) expectedT (///.lifted meta.expected_type) - conditionals (monad.map ! (function (_ [cases branch]) - (do ! - [branch (typeA.with_type expectedT - (phase archive branch))] - (in [cases branch]))) - conditionals) + conditionals (monad.each ! (function (_ [cases branch]) + (do ! + [branch (typeA.with_type expectedT + (phase archive branch))] + (in [cases branch]))) + conditionals) else (typeA.with_type expectedT (phase archive else))] (in (|> conditionals - (list\map (function (_ [cases branch]) - (////analysis.tuple - (list (////analysis.tuple (list\map (|>> ////analysis.nat) cases)) - branch)))) + (list\each (function (_ [cases branch]) + (////analysis.tuple + (list (////analysis.tuple (list\each (|>> ////analysis.nat) cases)) + branch)))) (list& input else) (#////analysis.Extension extension_name)))))]))) @@ -164,7 +164,7 @@ (case args (^ (list typeC valueC)) (do {! ////.monad} - [actualT (\ ! map (|>> (:as Type)) + [actualT (\ ! each (|>> (:as Type)) (eval archive Type typeC)) _ (typeA.infer actualT)] (typeA.with_type actualT @@ -179,7 +179,7 @@ (case args (^ (list typeC valueC)) (do {! ////.monad} - [actualT (\ ! map (|>> (:as Type)) + [actualT (\ ! each (|>> (:as Type)) (eval archive Type typeC)) _ (typeA.infer actualT) [valueT valueA] (typeA.with_inference diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux index 306eb960e..02cb8bbb7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux @@ -125,7 +125,7 @@ [($_ <>.and <c>.text (<>.some <c>.any)) (function (_ extension phase archive [constructor inputsC]) (do {! phase.monad} - [inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + [inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& (analysis.text constructor) inputsA)))))])) @@ -149,7 +149,7 @@ (do {! phase.monad} [objectA (analysis/type.with_type ..Object (phase archive objectC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& (analysis.text methodC) objectA @@ -183,7 +183,7 @@ (do {! phase.monad} [abstractionA (analysis/type.with_type ..Function (phase archive abstractionC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux index 5fb859b4a..85b9124ce 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux @@ -144,7 +144,7 @@ (do {! phase.monad} [objectA (analysis/type.with_type ..Object (phase archive objectC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& (analysis.text methodC) objectA @@ -186,7 +186,7 @@ (do {! phase.monad} [abstractionA (analysis/type.with_type ..Function (phase archive abstractionC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux index 1cc151f14..2f5ef9cbb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux @@ -139,7 +139,7 @@ (do {! phase.monad} [objectA (analysis/type.with_type ..Object (phase archive objectC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] (in (#analysis.Extension extension (list& (analysis.text methodC) objectA @@ -172,7 +172,7 @@ (do {! phase.monad} [abstractionA (analysis/type.with_type ..Function (phase archive abstractionC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux index 2d729e701..e29c99177 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux @@ -141,7 +141,7 @@ (do {! phase.monad} [abstractionA (analysis/type.with_type ..Function (phase archive abstractionC)) - inputsA (monad.map ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) + inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux index 3e6c7a0ef..d9621c994 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux @@ -25,5 +25,5 @@ (All [s i o] (-> Text (-> (Bundle s i o) (Bundle s i o)))) (|>> dictionary.entries - (list\map (function (_ [key val]) [(format prefix " " key) val])) + (list\each (function (_ [key val]) [(format prefix " " key) val])) (dictionary.of_list text.hash))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux index 29de45227..02037b6b0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux @@ -177,7 +177,7 @@ (def: constant::modifier (Modifier field.Field) - ($_ modifier\compose + ($_ modifier\composite field.public field.static field.final)) @@ -211,7 +211,7 @@ ... TODO: Handle annotations. (#Variable [name visibility state annotations type]) - (field.field (modifier\compose visibility state) + (field.field (modifier\composite visibility state) name type (row.row)))) (def: (method_definition [mapping selfT] [analyse synthesize generate]) @@ -272,26 +272,26 @@ (luxT.check (luxT.class mapping) (..signature super_class)))) super_interfaceT+ (directive.lifted_analysis (typeA.with_env - (monad.map check.monad - (|>> ..signature (luxT.check (luxT.class mapping))) - super_interfaces))) - .let [selfT (jvm.inheritance_relationship_type (#.Primitive name (list\map product.right parameters)) + (monad.each check.monad + (|>> ..signature (luxT.check (luxT.class mapping))) + super_interfaces))) + .let [selfT (jvm.inheritance_relationship_type (#.Primitive name (list\each product.right parameters)) super_classT super_interfaceT+)] state (extension.lifted phase.get_state) .let [analyse (value@ [#directive.analysis #directive.phase] state) synthesize (value@ [#directive.synthesis #directive.phase] state) generate (value@ [#directive.generation #directive.phase] state)] - methods (monad.map ! (..method_definition [mapping selfT] [analyse synthesize generate]) - methods) + methods (monad.each ! (..method_definition [mapping selfT] [analyse synthesize generate]) + methods) ... _ (directive.lifted_generation ... (generation.save! true ["" name] ... [name ... (class.class version.v6_0 - ... (modifier\compose class.public inheritance) - ... (name.internal name) (list\map (|>> product.left parser.name ..constraint) parameters) + ... (modifier\composite class.public inheritance) + ... (name.internal name) (list\each (|>> product.left parser.name ..constraint) parameters) ... super_class super_interfaces - ... (list\map ..field_definition fields) + ... (list\each ..field_definition fields) ... (list) ... TODO: Add methods ... (row.row))])) _ (directive.lifted_generation 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 c5f410370..7a3ccaf26 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 @@ -240,9 +240,9 @@ (All [anchor expression directive] (-> (List Text) Type (Operation anchor expression directive (List Any)))) (/////directive.lifted_generation - (monad.map phase.monad (function (_ tag) - (/////generation.log! (format "#" tag " : Tag of " (%.type owner)))) - tags))) + (monad.each phase.monad (function (_ tag) + (/////generation.log! (format "#" tag " : Tag of " (%.type owner)))) + tags))) (def: (def::type_tagged expander host_analysis) (-> Expander /////analysis.Bundle Handler) @@ -283,13 +283,13 @@ .let [annotationsV (:as Code annotationsV)] _ (/////directive.lifted_analysis (do ! - [_ (monad.map ! (function (_ [module alias]) - (do ! - [_ (module.import module)] - (case alias - "" (in []) - _ (module.alias alias module)))) - imports)] + [_ (monad.each ! (function (_ [module alias]) + (do ! + [_ (module.import module)] + (case alias + "" (in []) + _ (module.alias alias module)))) + imports)] (module.set_annotations annotationsV)))] (in {#/////directive.imports imports #/////directive.referrals (list)})))])) 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 49b696138..bebec6929 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 @@ -64,14 +64,14 @@ ... <s>.any)))) ... (function (_ extension_name phase archive [input else conditionals]) ... (do {! /////.monad} -... [@input (\ ! map _.var (generation.identifier "input")) +... [@input (\ ! each _.var (generation.identifier "input")) ... inputG (phase archive input) ... elseG (phase archive else) ... conditionalsG (: (Operation (List [Expression Expression])) -... (monad.map ! (function (_ [chars branch]) +... (monad.each ! (function (_ [chars branch]) ... (do ! ... [branchG (phase archive branch)] -... (in [(|> chars (list\map (|>> .int _.int (_.=/2 @input))) _.or) +... (in [(|> chars (list\each (|>> .int _.int (_.=/2 @input))) _.or) ... branchG]))) ... conditionals))] ... (in (_.let (list [@input inputG]) 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 50b60d954..00da05b89 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 @@ -105,12 +105,12 @@ elseG (phase archive else) conditionalsG (: (Operation (List [(List Literal) Statement])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch)] - (in [(list\map (|>> .int _.int) chars) - (_.return branchG)]))) - conditionals))] + (monad.each ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch)] + (in [(list\each (|>> .int _.int) chars) + (_.return branchG)]))) + conditionals))] (in (_.apply/* (_.closure (list) (_.switch (_.the //runtime.i64_low_field inputG) conditionalsG 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 9e681c65d..546085ce4 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 @@ -68,7 +68,7 @@ (function (_ extension phase archive [constructorS inputsS]) (do {! ////////phase.monad} [constructorG (phase archive constructorS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.new constructorG inputsG))))])) (def: object::get @@ -87,7 +87,7 @@ (function (_ extension phase archive [methodS objectS inputsS]) (do {! ////////phase.monad} [objectG (phase archive objectS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template [<!> <?> <unit>] @@ -123,7 +123,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply/* abstractionG inputsG))))])) (def: js::function @@ -134,9 +134,9 @@ [abstractionG (phase archive abstractionS) .let [variable (: (-> Text (Operation Var)) (|>> generation.identifier - (\ ! map _.var)))] - g!inputs (monad.map ! (function (_ _) (variable "input")) - (list.repeated (.nat arity) [])) + (\ ! each _.var)))] + g!inputs (monad.each ! (function (_ _) (variable "input")) + (list.repeated (.nat arity) [])) g!abstraction (variable "abstraction")] (in (_.closure g!inputs ($_ _.then 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 e18b6d356..759b2ad63 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 @@ -111,23 +111,23 @@ elseG (phase archive elseS) conditionalsG+ (: (Operation (List [(List [S4 Label]) (Bytecode Any)])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch) - @branch ///runtime.forge_label] - (in [(list\map (function (_ char) - [(try.trusted (signed.s4 (.int char))) @branch]) - chars) - ($_ _.composite - (_.set_label @branch) - branchG - (_.goto @end))]))) - conditionalsS)) + (monad.each ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch) + @branch ///runtime.forge_label] + (in [(list\each (function (_ char) + [(try.trusted (signed.s4 (.int char))) @branch]) + chars) + ($_ _.composite + (_.set_label @branch) + branchG + (_.goto @end))]))) + conditionalsS)) .let [table (|> conditionalsG+ - (list\map product.left) - list\join) + (list\each product.left) + list\conjoint) conditionalsG (|> conditionalsG+ - (list\map product.right) + (list\each product.right) (monad.all _.monad))]] (in (do _.monad [@else _.new_label] 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 be90b8876..e176bcda7 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 @@ -752,10 +752,10 @@ [($_ <>.and ..class <s>.text ..return (<>.some ..input)) (function (_ extension_name generate archive [class method outputT inputsTS]) (do {! //////.monad} - [inputsTG (monad.map ! (generate_input generate archive) inputsTS)] + [inputsTG (monad.each ! (generate_input generate archive) inputsTS)] (in ($_ _.composite - (monad.map _.monad product.right inputsTG) - (_.invokestatic class method (type.method [(list\map product.left inputsTG) outputT (list)])) + (monad.each _.monad product.right inputsTG) + (_.invokestatic class method (type.method [(list\each product.left inputsTG) outputT (list)])) (prepare_output outputT)))))])) (template [<name> <invoke>] @@ -766,12 +766,12 @@ (function (_ extension_name generate archive [class method outputT objectS inputsTS]) (do {! //////.monad} [objectG (generate archive objectS) - inputsTG (monad.map ! (generate_input generate archive) inputsTS)] + inputsTG (monad.each ! (generate_input generate archive) inputsTS)] (in ($_ _.composite objectG (_.checkcast class) - (monad.map _.monad product.right inputsTG) - (<invoke> class method (type.method [(list\map product.left inputsTG) outputT (list)])) + (monad.each _.monad product.right inputsTG) + (<invoke> class method (type.method [(list\each product.left inputsTG) outputT (list)])) (prepare_output outputT)))))]))] [invoke::virtual _.invokevirtual] @@ -785,12 +785,12 @@ [($_ <>.and ..class (<>.some ..input)) (function (_ extension_name generate archive [class inputsTS]) (do {! //////.monad} - [inputsTG (monad.map ! (generate_input generate archive) inputsTS)] + [inputsTG (monad.each ! (generate_input generate archive) inputsTS)] (in ($_ _.composite (_.new class) _.dup - (monad.map _.monad product.right inputsTG) - (_.invokespecial class "<init>" (type.method [(list\map product.left inputsTG) type.void (list)]))))))])) + (monad.each _.monad product.right inputsTG) + (_.invokespecial class "<init>" (type.method [(list\each product.left inputsTG) type.void (list)]))))))])) (def: bundle::member Bundle @@ -884,7 +884,7 @@ (//////synthesis.variant [lefts right? (recur sub)]) (^ (//////synthesis.tuple members)) - (//////synthesis.tuple (list\map recur members)) + (//////synthesis.tuple (list\each recur members)) (^ (//////synthesis.variable var)) (|> mapping @@ -905,31 +905,31 @@ (//////synthesis.branch/get [path (recur recordS)]) (^ (//////synthesis.loop/scope [offset initsS+ bodyS])) - (//////synthesis.loop/scope [offset (list\map recur initsS+) (recur bodyS)]) + (//////synthesis.loop/scope [offset (list\each recur initsS+) (recur bodyS)]) (^ (//////synthesis.loop/recur updatesS+)) - (//////synthesis.loop/recur (list\map recur updatesS+)) + (//////synthesis.loop/recur (list\each recur updatesS+)) (^ (//////synthesis.function/abstraction [environment arity bodyS])) - (//////synthesis.function/abstraction [(list\map (function (_ local) - (case local - (^ (//////synthesis.variable local)) - (|> mapping - (dictionary.value local) - (maybe.else local) - //////synthesis.variable) - - _ - local)) - environment) + (//////synthesis.function/abstraction [(list\each (function (_ local) + (case local + (^ (//////synthesis.variable local)) + (|> mapping + (dictionary.value local) + (maybe.else local) + //////synthesis.variable) + + _ + local)) + environment) arity bodyS]) (^ (//////synthesis.function/apply [functionS inputsS+])) - (//////synthesis.function/apply [(recur functionS) (list\map recur inputsS+)]) + (//////synthesis.function/apply [(recur functionS) (list\each recur inputsS+)]) (#//////synthesis.Extension [name inputsS+]) - (#//////synthesis.Extension [name (list\map recur inputsS+)])))) + (#//////synthesis.Extension [name (list\each recur inputsS+)])))) (def: $Object (type.class "java.lang.Object" (list))) @@ -945,24 +945,24 @@ (let [store_capturedG (|> env list.size list.indices - (monad.map _.monad (.function (_ register) - ($_ _.composite - (_.aload 0) - (_.aload (++ register)) - (_.putfield class (///reference.foreign_name register) $Object)))))] + (monad.each _.monad (.function (_ register) + ($_ _.composite + (_.aload 0) + (_.aload (++ register)) + (_.putfield class (///reference.foreign_name register) $Object)))))] (method.method method.public "<init>" (anonymous_init_method env) (list) (#.Some ($_ _.composite (_.aload 0) - (monad.map _.monad product.right inputsTG) - (_.invokespecial super_class "<init>" (type.method [(list\map product.left inputsTG) type.void (list)])) + (monad.each _.monad product.right inputsTG) + (_.invokespecial super_class "<init>" (type.method [(list\each product.left inputsTG) type.void (list)])) store_capturedG _.return))))) (def: (anonymous_instance generate archive class env) (-> Phase Archive (Type category.Class) (Environment Synthesis) (Operation (Bytecode Any))) (do {! //////.monad} - [captureG+ (monad.map ! (generate archive) env)] + [captureG+ (monad.each ! (generate archive) env)] (in ($_ _.composite (_.new class) _.dup @@ -1017,65 +1017,65 @@ class (type.class anonymous_class_name (list)) total_environment (|> overriden_methods ... Get all the environments. - (list\map product.left) + (list\each product.left) ... Combine them. - list\join + list\conjoint ... Remove duplicates. (set.from_list //////synthesis.hash) set.list) global_mapping (|> total_environment ... Give them names as "foreign" variables. list.enumeration - (list\map (function (_ [id capture]) - [capture (#//////variable.Foreign id)])) + (list\each (function (_ [id capture]) + [capture (#//////variable.Foreign id)])) (dictionary.from_list //////variable.hash)) - normalized_methods (list\map (function (_ [environment - [ownerT name - strict_fp? annotations vars - self_name arguments returnT exceptionsT - body]]) - (let [local_mapping (|> environment - list.enumeration - (list\map (function (_ [foreign_id capture]) - [(#//////variable.Foreign foreign_id) - (|> global_mapping - (dictionary.value capture) - maybe.trusted)])) - (dictionary.from_list //////variable.hash))] - [ownerT name - strict_fp? annotations vars - self_name arguments returnT exceptionsT - (normalize_method_body local_mapping body)])) - overriden_methods)] - inputsTI (monad.map ! (generate_input generate archive) inputsTS) - method_definitions (monad.map ! (function (_ [ownerT name - strict_fp? annotations vars - self_name arguments returnT exceptionsT - bodyS]) - (do ! - [bodyG (//////generation.with_context artifact_id - (generate archive bodyS))] - (in (method.method ($_ modifier\compose - method.public - method.final - (if strict_fp? - method.strict - modifier\identity)) - name - (type.method [(list\map product.right arguments) - returnT - exceptionsT]) - (list) - (#.Some ($_ _.composite - bodyG - (returnG returnT))))))) - normalized_methods) - bytecode (<| (\ ! map (format.result class.writer)) + normalized_methods (list\each (function (_ [environment + [ownerT name + strict_fp? annotations vars + self_name arguments returnT exceptionsT + body]]) + (let [local_mapping (|> environment + list.enumeration + (list\each (function (_ [foreign_id capture]) + [(#//////variable.Foreign foreign_id) + (|> global_mapping + (dictionary.value capture) + maybe.trusted)])) + (dictionary.from_list //////variable.hash))] + [ownerT name + strict_fp? annotations vars + self_name arguments returnT exceptionsT + (normalize_method_body local_mapping body)])) + overriden_methods)] + inputsTI (monad.each ! (generate_input generate archive) inputsTS) + method_definitions (monad.each ! (function (_ [ownerT name + strict_fp? annotations vars + self_name arguments returnT exceptionsT + bodyS]) + (do ! + [bodyG (//////generation.with_context artifact_id + (generate archive bodyS))] + (in (method.method ($_ modifier\composite + method.public + method.final + (if strict_fp? + method.strict + modifier\identity)) + name + (type.method [(list\each product.right arguments) + returnT + exceptionsT]) + (list) + (#.Some ($_ _.composite + bodyG + (returnG returnT))))))) + normalized_methods) + bytecode (<| (\ ! each (format.result class.writer)) //////.lifted - (class.class version.v6_0 ($_ modifier\compose class.public class.final) + (class.class version.v6_0 ($_ modifier\composite class.public class.final) (name.internal anonymous_class_name) (name.internal (..reflection super_class)) - (list\map (|>> ..reflection name.internal) super_interfaces) + (list\each (|>> ..reflection name.internal) super_interfaces) (foreign.variables total_environment) (list& (..with_anonymous_init class total_environment super_class inputsTI) method_definitions) 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 142691489..11605c1d5 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 @@ -63,20 +63,20 @@ (do {! /////.monad} [inputG (phase archive input) elseG (phase archive else) - @input (\ ! map _.var (generation.identifier "input")) + @input (\ ! each _.var (generation.identifier "input")) conditionalsG (: (Operation (List [Expression Expression])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch)] - (in [(|> chars - (list\map (|>> .int _.int (_.= @input))) - (list\mix (function (_ clause total) - (if (same? _.nil total) - clause - (_.or clause total))) - _.nil)) - branchG]))) - conditionals)) + (monad.each ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch)] + (in [(|> chars + (list\each (|>> .int _.int (_.= @input))) + (list\mix (function (_ clause total) + (if (same? _.nil total) + clause + (_.or clause total))) + _.nil)) + branchG]))) + conditionals)) .let [closure (_.closure (list @input) (list\mix (function (_ [test then] else) (_.if test (_.return then) else)) 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 f3525e411..a1bffe3cf 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 @@ -80,7 +80,7 @@ (function (_ extension phase archive [methodS objectS inputsS]) (do {! ////////phase.monad} [objectG (phase archive objectS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template [<!> <?> <unit>] @@ -145,7 +145,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply/* inputsG abstractionG))))])) (def: lua::power @@ -172,10 +172,10 @@ [abstractionG (phase archive abstractionS) .let [variable (: (-> Text (Operation Var)) (|>> generation.identifier - (\ ! map _.var)))] - g!inputs (monad.map ! (function (_ _) - (variable "input")) - (list.repeated (.nat arity) []))] + (\ ! each _.var)))] + g!inputs (monad.each ! (function (_ _) + (variable "input")) + (list.repeated (.nat arity) []))] (in (<| (_.closure g!inputs) _.statement (case (.nat arity) 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 3acac79be..f22dc34f1 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 @@ -67,28 +67,28 @@ [inputG (phase archive input) [[context_module context_artifact] elseG] (generation.with_new_context archive (phase archive else)) - @input (\ ! map _.var (generation.identifier "input")) + @input (\ ! each _.var (generation.identifier "input")) conditionalsG (: (Operation (List [Expression Expression])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch)] - (in [(|> chars - (list\map (|>> .int _.int (_.=== @input))) - (list\mix (function (_ clause total) - (if (same? _.null total) - clause - (_.or clause total))) - _.null)) - branchG]))) - conditionals)) + (monad.each ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch)] + (in [(|> chars + (list\each (|>> .int _.int (_.=== @input))) + (list\mix (function (_ clause total) + (if (same? _.null total) + clause + (_.or clause total))) + _.null)) + branchG]))) + conditionals)) .let [foreigns (|> conditionals - (list\map (|>> product.right synthesis.path/then //case.dependencies)) + (list\each (|>> product.right synthesis.path/then //case.dependencies)) (list& (//case.dependencies (synthesis.path/then else))) list.together (set.of_list _.hash) set.list) @expression (_.constant (reference.artifact [context_module context_artifact])) - directive (_.define_function @expression (list& (_.parameter @input) (list\map _.reference foreigns)) + directive (_.define_function @expression (list& (_.parameter @input) (list\each _.reference foreigns)) (list\mix (function (_ [test then] else) (_.if test (_.return then) else)) (_.return elseG) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux index 3a294d06e..e391dba46 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux @@ -65,7 +65,7 @@ [($_ <>.and <s>.text (<>.some <s>.any)) (function (_ extension phase archive [constructor inputsS]) (do {! ////////phase.monad} - [inputsG (monad.map ! (phase archive) inputsS)] + [inputsG (monad.each ! (phase archive) inputsS)] (in (_.new (_.constant constructor) inputsG))))])) (def: object::get @@ -84,7 +84,7 @@ (function (_ extension phase archive [methodS objectS inputsS]) (do {! ////////phase.monad} [objectG (phase archive objectS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template [<!> <?> <unit>] @@ -117,7 +117,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply/* inputsG abstractionG))))])) (def: php::pack 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 6f51e40f1..78e4d7a4a 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 @@ -54,7 +54,7 @@ (^template [<tag>] [(^ (<tag> value)) - (/////\map _.return (expression archive synthesis))]) + (/////\each _.return (expression archive synthesis))]) ([synthesis.bit] [synthesis.i64] [synthesis.f64] @@ -78,7 +78,7 @@ [synthesis.loop/recur //loop.recur!]) (^ (synthesis.function/abstraction abstraction)) - (/////\map _.return (//function.function statement expression archive abstraction)) + (/////\each _.return (//function.function statement expression archive abstraction)) )) (def: .public (custom [parser handler]) @@ -106,26 +106,26 @@ (do {! /////.monad} [inputG (phase archive input) else! (..statement phase archive else) - @input (\ ! map _.var (generation.identifier "input")) + @input (\ ! each _.var (generation.identifier "input")) conditionals! (: (Operation (List [(Expression Any) (Statement Any)])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branch! (..statement phase archive branch)] - (in [(|> chars - (list\map (|>> .int _.int (_.= @input))) - (list\mix (function (_ clause total) - (if (same? _.none total) - clause - (_.or clause total))) - _.none)) - branch!]))) - conditionals)) + (monad.each ! (function (_ [chars branch]) + (do ! + [branch! (..statement phase archive branch)] + (in [(|> chars + (list\each (|>> .int _.int (_.= @input))) + (list\mix (function (_ clause total) + (if (same? _.none total) + clause + (_.or clause total))) + _.none)) + branch!]))) + conditionals)) ... .let [dependencies (//case.dependencies (list\mix (function (_ right left) ... (synthesis.path/seq left right)) ... (synthesis.path/then input) ... (#.Item (synthesis.path/then else) - ... (list\map (|>> product.right + ... (list\each (|>> product.right ... synthesis.path/then) ... conditionals)))) ... @closure (_.var (reference.artifact artifact_id)) 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 8db4b2ffd..c5b2d8abf 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 @@ -79,7 +79,7 @@ (function (_ extension phase archive [methodS objectS inputsS]) (do {! ////////phase.monad} [objectG (phase archive objectS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template [<!> <?> <unit>] @@ -121,7 +121,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply/* abstractionG inputsG))))])) (def: python::function @@ -132,9 +132,9 @@ [abstractionG (phase archive abstractionS) .let [variable (: (-> Text (Operation SVar)) (|>> generation.identifier - (\ ! map _.var)))] - g!inputs (monad.map ! (function (_ _) (variable "input")) - (list.repeated (.nat arity) []))] + (\ ! each _.var)))] + g!inputs (monad.each ! (function (_ _) (variable "input")) + (list.repeated (.nat arity) []))] (in (_.lambda g!inputs (case (.nat arity) 0 (_.apply/1 abstractionG //runtime.unit) 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 3cc7cf91c..1593d7a25 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 @@ -64,14 +64,14 @@ ... ... <s>.any)))) ... ... (function (_ extension_name phase archive [input else conditionals]) ... ... (do {! /////.monad} -... ... [@input (\ ! map _.var (generation.identifier "input")) +... ... [@input (\ ! each _.var (generation.identifier "input")) ... ... inputG (phase archive input) ... ... elseG (phase archive else) ... ... conditionalsG (: (Operation (List [Expression Expression])) -... ... (monad.map ! (function (_ [chars branch]) +... ... (monad.each ! (function (_ [chars branch]) ... ... (do ! ... ... [branchG (phase archive branch)] -... ... (in [(|> chars (list\map (|>> .int _.int (_.=/2 @input))) _.or) +... ... (in [(|> chars (list\each (|>> .int _.int (_.=/2 @input))) _.or) ... ... branchG]))) ... ... conditionals))] ... ... (in (_.let (list [@input inputG]) 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 253b342e8..83791324e 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 @@ -60,20 +60,20 @@ (do {! /////.monad} [inputG (phase archive input) elseG (phase archive else) - @input (\ ! map _.local (generation.identifier "input")) + @input (\ ! each _.local (generation.identifier "input")) conditionalsG (: (Operation (List [Expression Expression])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch)] - (in [(|> chars - (list\map (|>> .int _.int (_.= @input))) - (list\mix (function (_ clause total) - (if (same? _.nil total) - clause - (_.or clause total))) - _.nil)) - branchG]))) - conditionals)) + (monad.each ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch)] + (in [(|> chars + (list\each (|>> .int _.int (_.= @input))) + (list\mix (function (_ clause total) + (if (same? _.nil total) + clause + (_.or clause total))) + _.nil)) + branchG]))) + conditionals)) .let [closure (_.lambda #.None (list @input) (list\mix (function (_ [test then] else) (_.if test (_.return then) else)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux index 25d29d1a8..98edb6d30 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux @@ -80,7 +80,7 @@ (function (_ extension phase archive [methodS objectS inputsS]) (do {! ////////phase.monad} [objectG (phase archive objectS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.do methodS inputsG objectG))))])) (template [<!> <?> <unit>] @@ -112,7 +112,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply/* inputsG abstractionG))))])) (def: ruby::import 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 79c3cce7b..3b3e87e30 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 @@ -64,16 +64,16 @@ <s>.any)))) (function (_ extension_name phase archive [input else conditionals]) (do {! /////.monad} - [@input (\ ! map _.var (generation.identifier "input")) + [@input (\ ! each _.var (generation.identifier "input")) inputG (phase archive input) elseG (phase archive else) conditionalsG (: (Operation (List [Expression Expression])) - (monad.map ! (function (_ [chars branch]) - (do ! - [branchG (phase archive branch)] - (in [(|> chars (list\map (|>> .int _.int (_.=/2 @input))) _.or) - branchG]))) - conditionals))] + (monad.each ! (function (_ [chars branch]) + (do ! + [branchG (phase archive branch)] + (in [(|> chars (list\each (|>> .int _.int (_.=/2 @input))) _.or) + branchG]))) + conditionals))] (in (_.let (list [@input inputG]) (list\mix (function (_ [test then] else) (_.if test then else)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux index 680cec039..cd2b46e13 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux @@ -93,7 +93,7 @@ (function (_ extension phase archive [abstractionS inputsS]) (do {! ////////phase.monad} [abstractionG (phase archive abstractionS) - inputsG (monad.map ! (phase archive) inputsS)] + inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply/* inputsG abstractionG))))])) (def: .public bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux index 982b48475..8577bb82a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux @@ -129,7 +129,7 @@ (def: (alternation @otherwise pre! post!) (-> _.Tag (Expression Any) (Expression Any) (Expression Any)) - (_.tagbody ($_ list\compose + (_.tagbody ($_ list\composite (list ..save! pre! @otherwise) @@ -141,7 +141,7 @@ (function (recur [$output @done @fail pathP]) (.case pathP (^ (/////synthesis.path/then bodyS)) - (\ ///////phase.monad map + (\ ///////phase.monad each (function (_ outputV) (_.progn (list (_.setq $output outputV) (_.go @done)))) @@ -173,13 +173,13 @@ (^template [<tag> <format> <=>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (do ! - [then! (recur [$output @done @fail then])] - (in [(<=> [(|> match <format>) - ..peek]) - then!]))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (do ! + [then! (recur [$output @done @fail then])] + (in [(<=> [(|> match <format>) + ..peek]) + then!]))) + (#.Item item))] (in (list\mix (function (_ [when then] else) (_.if when then else)) (_.go @fail) @@ -195,7 +195,7 @@ (^ (<simple> idx nextP)) (|> nextP [$output @done @fail] recur - (\ ///////phase.monad map (|>> #.Some (<choice> @fail true idx))))]) + (\ ///////phase.monad each (|>> #.Some (<choice> @fail true idx))))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) @@ -217,7 +217,7 @@ (^ (/////synthesis.path/alt preP postP)) (do {! ///////phase.monad} - [@otherwise (\ ! map (|>> %.nat (format "lux_case_otherwise") _.tag) /////generation.next) + [@otherwise (\ ! each (|>> %.nat (format "lux_case_otherwise") _.tag) /////generation.next) pre! (recur [$output @done @otherwise preP]) post! (recur [$output @done @fail postP])] (in (..alternation @otherwise pre! post!))) @@ -231,8 +231,8 @@ (def: (pattern_matching $output expression archive pathP) (-> Var/1 (Generator Path)) (do {! ///////phase.monad} - [@done (\ ! map (|>> %.nat (format "lux_case_done") _.tag) /////generation.next) - @fail (\ ! map (|>> %.nat (format "lux_case_fail") _.tag) /////generation.next) + [@done (\ ! each (|>> %.nat (format "lux_case_done") _.tag) /////generation.next) + @fail (\ ! each (|>> %.nat (format "lux_case_fail") _.tag) /////generation.next) pattern_matching! (pattern_matching' expression archive [$output @done @fail pathP])] (in (_.tagbody (list pattern_matching! @@ -244,15 +244,15 @@ (Generator [Synthesis Path]) (do {! ///////phase.monad} [initG (expression archive valueS) - $output (\ ! map (|>> %.nat (format "lux_case_output") _.var) /////generation.next) + $output (\ ! each (|>> %.nat (format "lux_case_output") _.var) /////generation.next) pattern_matching! (pattern_matching $output expression archive pathP) .let [storage (|> pathP ////synthesis/case.storage (value@ #////synthesis/case.bindings) set.list - (list\map (function (_ register) - [(..register register) - _.nil])))]] + (list\each (function (_ register) + [(..register register) + _.nil])))]] (in (_.let (list& [@cursor (_.list/* (list initG))] [@savepoint (_.list/* (list))] [@temp _.nil] 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 c54bae779..9a2b543d9 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 @@ -33,7 +33,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionG (expression archive functionS) - argsG+ (monad.map ! (expression archive) argsS+)] + argsG+ (monad.each ! (expression archive) argsS+)] (in (_.funcall/+ [functionG argsG+])))) (def: capture @@ -48,9 +48,9 @@ _ (do {! ///////phase.monad} - [@closure (\ ! map _.var (/////generation.identifier "closure"))] + [@closure (\ ! each _.var (/////generation.identifier "closure"))] (in (_.labels (list [@closure [(|> (list.enumeration inits) - (list\map (|>> product.left ..capture)) + (list\each (|>> product.left ..capture)) _.args) function_definition]]) (_.funcall/+ [(_.function/1 @closure) inits])))))) @@ -61,12 +61,12 @@ (def: .public (function expression archive [environment arity bodyS]) (Generator (Abstraction Synthesis)) (do {! ///////phase.monad} - [@scope (\ ! map (|>> %.nat (format "function_scope") _.tag) /////generation.next) - @output (\ ! map (|>> %.nat (format "loop_output") _.var) /////generation.next) + [@scope (\ ! each (|>> %.nat (format "function_scope") _.tag) /////generation.next) + @output (\ ! each (|>> %.nat (format "loop_output") _.var) /////generation.next) [function_name bodyG] (/////generation.with_new_context archive (/////generation.with_anchor [@scope 1] (expression archive bodyS))) - closureG+ (monad.map ! (expression archive) environment) + closureG+ (monad.each ! (expression archive) environment) .let [@curried (_.var "curried") @missing (_.var "missing") arityG (|> arity .int _.int) @@ -74,7 +74,7 @@ @self (_.var (///reference.artifact function_name)) initialize_self! [(//case.register 0) (_.function/1 @self)] initialize! [(|> (list.indices arity) - (list\map ..input) + (list\each ..input) _.args) @curried]]] (with_closure closureG+ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux index 7258dc416..592733e5e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux @@ -42,16 +42,16 @@ ... true loop _ (do {! ///////phase.monad} - [@scope (\ ! map (|>> %.nat (format "loop_scope") _.tag) /////generation.next) - @output (\ ! map (|>> %.nat (format "loop_output") _.var) /////generation.next) - initsG+ (monad.map ! (expression archive) initsS+) + [@scope (\ ! each (|>> %.nat (format "loop_scope") _.tag) /////generation.next) + @output (\ ! each (|>> %.nat (format "loop_output") _.var) /////generation.next) + initsG+ (monad.each ! (expression archive) initsS+) bodyG (/////generation.with_anchor [@scope start] (expression archive bodyS))] (in (_.let (|> initsG+ list.enumeration - (list\map (function (_ [idx init]) - [(|> idx (n.+ start) //case.register) - init])) + (list\each (function (_ [idx init]) + [(|> idx (n.+ start) //case.register) + init])) (list& [@output _.nil])) (list (_.tagbody (list @scope (_.setq @output bodyG))) @@ -61,10 +61,10 @@ (Generator (List Synthesis)) (do {! ///////phase.monad} [[tag offset] /////generation.anchor - argsO+ (monad.map ! (expression archive) argsS+) + argsO+ (monad.each ! (expression archive) argsS+) .let [bindings (|> argsO+ list.enumeration - (list\map (|>> product.left (n.+ offset) //case.register)) + (list\each (|>> product.left (n.+ offset) //case.register)) _.args)]] (in (_.progn (list (_.multiple_value_setq bindings (_.values/* argsO+)) (_.go tag)))))) 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 0b2328715..c478118de 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 @@ -93,9 +93,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -124,9 +124,9 @@ (let [g!name (code.local_identifier name) code_nameC (code.local_identifier (format "@" name)) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` (_.Expression Any))) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` (_.Expression Any))) + inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) (_.Computation Any)) (_.call/* (~ runtime_name) (list (~+ inputsC))))) @@ -272,7 +272,7 @@ (list @io//exit)) (def: runtime - (_.progn ($_ list\compose + (_.progn ($_ list\composite runtime//adt runtime//lux runtime//i64 diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux index 6755b8f33..c8f9230a3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux @@ -25,13 +25,13 @@ _ (|> elemsS+ - (monad.map ///////phase.monad (expression archive)) - (///////phase\map _.vector/*)))) + (monad.each ///////phase.monad (expression archive)) + (///////phase\each _.vector/*)))) (def: .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (|>> [tag right?] //runtime.variant) - (expression archive valueS)))) + (///////phase\each (|>> [tag right?] //runtime.variant) + (expression archive valueS)))) 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 3802776c8..c7b2eba9d 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 @@ -46,8 +46,8 @@ (^ (list (~+ g!input+))) (do ///.monad [(~+ (|> g!input+ - (list\map (function (_ g!input) - (list g!input (` ((~ g!phase) (~ g!archive) (~ g!input)))))) + (list\each (function (_ g!input) + (list g!input (` ((~ g!phase) (~ g!archive) (~ g!input)))))) list.together))] ((~' in) ((~ g!extension) [(~+ g!input+)]))) @@ -65,5 +65,5 @@ (function (_ extension_name) (function (_ phase archive inputsS) (do {! ///.monad} - [inputsI (monad.map ! (phase archive) inputsS)] + [inputsI (monad.each ! (phase archive) inputsS)] (in (extension inputsI)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux index 608217f8f..61119e473 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux @@ -32,7 +32,7 @@ (case synthesis (^template [<tag>] [(^ (<tag> value)) - (//////phase\map _.return (expression archive synthesis))]) + (//////phase\each _.return (expression archive synthesis))]) ([synthesis.bit] [synthesis.i64] [synthesis.f64] @@ -60,7 +60,7 @@ (/loop.recur! statement expression archive updates) (^ (synthesis.function/abstraction abstraction)) - (//////phase\map _.return (/function.function statement expression archive abstraction)) + (//////phase\each _.return (/function.function statement expression archive abstraction)) )) (exception: .public cannot_recur_as_an_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 edce73735..2b80bcc35 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 @@ -166,7 +166,7 @@ [(^ (<simple> idx nextP)) (|> nextP recur - (\ ///////phase.monad map (|>> (_.then (<choice> true idx)) #.Some)))]) + (\ ///////phase.monad each (|>> (_.then (<choice> true idx)) #.Some)))]) ([/////synthesis.simple_left_side ..left_choice] [/////synthesis.simple_right_side ..right_choice]) @@ -254,21 +254,21 @@ (#/////synthesis.I64_Fork item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (do ! - [then! (recur then)] - (in [(//runtime.i64//= (//primitive.i64 (.int match)) - ..peek_cursor) - then!]))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (do ! + [then! (recur then)] + (in [(//runtime.i64//= (//primitive.i64 (.int match)) + ..peek_cursor) + then!]))) + (#.Item item))] (in (_.cond clauses ..fail_pm!))) (^template [<tag> <format>] [(<tag> item) (do {! ///////phase.monad} - [cases (monad.map ! (function (_ [match then]) - (\ ! map (|>> [(list (<format> match))]) (recur then))) - (#.Item item))] + [cases (monad.each ! (function (_ [match then]) + (\ ! each (|>> [(list (<format> match))]) (recur then))) + (#.Item item))] (in (_.switch ..peek_cursor cases (#.Some ..fail_pm!))))]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux index 90f1cca9a..078cc797d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux @@ -31,7 +31,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionO (expression archive functionS) - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply/* functionO argsO+)))) (def: capture @@ -48,7 +48,7 @@ _ [(_.function! @self (|> (list.enumeration inits) - (list\map (|>> product.left ..capture))) + (list\each (|>> product.left ..capture))) (_.return (_.function @self (list) body!))) (_.apply/* @self inits)])) @@ -70,7 +70,7 @@ (do {! ///////phase.monad} [[function_name body!] (/////generation.with_new_context archive (do ! - [scope (\ ! map ..@scope + [scope (\ ! each ..@scope (/////generation.context archive))] (/////generation.with_anchor [1 scope] (statement expression archive bodyS)))) @@ -87,7 +87,7 @@ (_.define (..input post) (_.at (_.i32 (.int post)) @@arguments)))) initialize_self! (list.indices arity))] - environment (monad.map ! (expression archive) environment) + environment (monad.each ! (expression archive) environment) .let [[definition instantiation] (with_closure @self environment ($_ _.then (_.define @num_args (_.the "length" @@arguments)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux index 8c3762238..7946e7b12 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux @@ -33,11 +33,11 @@ (-> Bit Register (List Expression) Statement Statement) (|> bindings list.enumeration - (list\map (function (_ [register value]) - (let [variable (//case.register (n.+ offset register))] - (if initial? - (_.define variable value) - (_.set variable value))))) + (list\each (function (_ [register value]) + (let [variable (//case.register (n.+ offset register))] + (if initial? + (_.define variable value) + (_.set variable value))))) list.reversed (list\mix _.then body))) @@ -51,8 +51,8 @@ ... true loop _ (do {! ///////phase.monad} - [@scope (\ ! map ..@scope /////generation.next) - initsO+ (monad.map ! (expression archive) initsS+) + [@scope (\ ! each ..@scope /////generation.next) + initsO+ (monad.each ! (expression archive) initsS+) body! (/////generation.with_anchor [start @scope] (statement expression archive bodyS))] (in (..setup true start initsO+ @@ -80,12 +80,12 @@ (Generator! (List Synthesis)) (do {! ///////phase.monad} [[offset @scope] /////generation.anchor - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in ($_ _.then (_.define @temp (_.array argsO+)) (..setup false offset (|> argsO+ list.enumeration - (list\map (function (_ [idx _]) - (_.at (_.i32 (.int idx)) @temp)))) + (list\each (function (_ [idx _]) + (_.at (_.i32 (.int idx)) @temp)))) (_.continue_at (_.label @scope))))))) 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 3ea974987..6579de615 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 @@ -91,9 +91,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -118,8 +118,8 @@ (#.Right [name inputs]) (let [g!name (code.local_identifier name) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` _.Expression)) inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` _.Expression)) inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply/* (~ runtime_name) (list (~+ inputsC))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux index 6253b38b5..3788b7f6d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux @@ -25,7 +25,7 @@ _ (do {! ///////phase.monad} - [elemsT+ (monad.map ! (generate archive) elemsS+)] + [elemsT+ (monad.each ! (generate archive) elemsS+)] (in (_.array elemsT+))))) (def: .public (variant generate archive [lefts right? valueS]) @@ -33,6 +33,6 @@ (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (//runtime.variant (_.i32 (.int tag)) - (//runtime.flag right?)) - (generate archive valueS)))) + (///////phase\each (//runtime.variant (_.i32 (.int tag)) + (//runtime.flag right?)) + (generate archive valueS)))) 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 5eafc6556..afa615823 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 @@ -66,15 +66,15 @@ (let [classT (type.class class (list)) fields (: (List (Resource Field)) (list& /arity.constant - (list\compose (/foreign.variables environment) - (/partial.variables arity)))) + (list\composite (/foreign.variables environment) + (/partial.variables arity)))) methods (: (List (Resource Method)) (list& (/init.method classT environment arity) (/reset.method classT environment arity) (if (arity.multiary? arity) (|> (n.min arity /arity.maximum) list.indices - (list\map (|>> ++ (/apply.method classT environment arity @begin body))) + (list\each (|>> ++ (/apply.method classT environment arity @begin body))) (list& (/implementation.method arity @begin body))) (list (/implementation.method' //runtime.apply::name arity @begin body)))))] (do phase.monad @@ -83,7 +83,7 @@ (def: modifier (Modifier Class) - ($_ modifier\compose + ($_ modifier\composite class.public class.final)) @@ -120,16 +120,16 @@ (Generator Apply) (do {! phase.monad} [abstractionG (generate archive abstractionS) - inputsG (monad.map ! (generate archive) inputsS)] + inputsG (monad.each ! (generate archive) inputsS)] (in ($_ _.composite abstractionG (|> inputsG (list.sub /arity.maximum) - (monad.map _.monad - (function (_ batchG) - ($_ _.composite - (_.checkcast /abstract.class) - (monad.all _.monad batchG) - (_.invokevirtual /abstract.class //runtime.apply::name (//runtime.apply::type (list.size batchG))) - )))) + (monad.each _.monad + (function (_ batchG) + ($_ _.composite + (_.checkcast /abstract.class) + (monad.all _.monad batchG) + (_.invokevirtual /abstract.class //runtime.apply::name (//runtime.apply::type (list.size batchG))) + )))) )))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux index 53d058584..47ab7df90 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux @@ -15,7 +15,7 @@ (def: modifier (Modifier Field) - ($_ modifier\compose + ($_ modifier\composite field.public field.static field.final diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux index ba69187b8..b843aa13a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux @@ -39,7 +39,7 @@ (def: modifier (Modifier Field) - ($_ modifier\compose + ($_ modifier\composite field.private field.final )) @@ -52,5 +52,5 @@ (-> (-> Register Text) Nat (List (Resource Field))) (|> amount list.indices - (list\map (function (_ register) - (..variable (naming register) ..type))))) + (list\each (function (_ register) + (..variable (naming register) ..type))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux index 4dbadacb0..802592b0d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux @@ -8,7 +8,7 @@ (def: .public modifier (Modifier Method) - ($_ modifier\compose + ($_ modifier\composite method.public method.strict )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux index 1addefe99..0114ef23c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux @@ -58,7 +58,7 @@ ($_ _.composite (|> amount list.indices - (monad.map _.monad (|>> (n.+ offset) _.aload))) + (monad.each _.monad (|>> (n.+ offset) _.aload))) (_\in []) )) @@ -97,59 +97,59 @@ @labelsT (|> _.new_label (list.repeated (-- num_partials)) (monad.all _.monad)) - .let [cases (|> (list\compose (#.Item [@labelsH @labelsT]) - (list @default)) + .let [cases (|> (list\composite (#.Item [@labelsH @labelsT]) + (list @default)) list.enumeration - (list\map (function (_ [stage @case]) - (let [current_partials (|> (list.indices stage) - (list\map (///partial.get class)) - (monad.all _.monad)) - already_partial? (n.> 0 stage) - exact_match? (i.= over_extent (.int stage)) - has_more_than_necessary? (i.> over_extent (.int stage))] - ($_ _.composite - (_.set_label @case) - (cond exact_match? - ($_ _.composite - ////reference.this - (if already_partial? - (_.invokevirtual class //reset.name (//reset.type class)) - (_\in [])) - current_partials - (..inputs ..this_offset apply_arity) - (_.invokevirtual class //implementation.name (//implementation.type function_arity)) - _.areturn) - - has_more_than_necessary? - (let [arity_inputs (|> function_arity (n.- stage)) - additional_inputs (|> apply_arity (n.- arity_inputs))] - ($_ _.composite - ////reference.this - (_.invokevirtual class //reset.name (//reset.type class)) - current_partials - (..inputs ..this_offset arity_inputs) - (_.invokevirtual class //implementation.name (//implementation.type function_arity)) - (apply (n.+ ..this_offset arity_inputs) additional_inputs) - _.areturn)) + (list\each (function (_ [stage @case]) + (let [current_partials (|> (list.indices stage) + (list\each (///partial.get class)) + (monad.all _.monad)) + already_partial? (n.> 0 stage) + exact_match? (i.= over_extent (.int stage)) + has_more_than_necessary? (i.> over_extent (.int stage))] + ($_ _.composite + (_.set_label @case) + (cond exact_match? + ($_ _.composite + ////reference.this + (if already_partial? + (_.invokevirtual class //reset.name (//reset.type class)) + (_\in [])) + current_partials + (..inputs ..this_offset apply_arity) + (_.invokevirtual class //implementation.name (//implementation.type function_arity)) + _.areturn) + + has_more_than_necessary? + (let [arity_inputs (|> function_arity (n.- stage)) + additional_inputs (|> apply_arity (n.- arity_inputs))] + ($_ _.composite + ////reference.this + (_.invokevirtual class //reset.name (//reset.type class)) + current_partials + (..inputs ..this_offset arity_inputs) + (_.invokevirtual class //implementation.name (//implementation.type function_arity)) + (apply (n.+ ..this_offset arity_inputs) additional_inputs) + _.areturn)) - ... (i.< over_extent (.int stage)) - (let [current_environment (|> (list.indices (list.size environment)) - (list\map (///foreign.get class)) - (monad.all _.monad)) - missing_partials (|> _.aconst_null - (list.repeated (|> num_partials (n.- apply_arity) (n.- stage))) - (monad.all _.monad))] - ($_ _.composite - (_.new class) - _.dup - current_environment - ///partial/count.value - (..increment apply_arity) - current_partials - (..inputs ..this_offset apply_arity) - missing_partials - (_.invokevirtual class //init.name (//init.type environment function_arity)) - _.areturn))))))) + ... (i.< over_extent (.int stage)) + (let [current_environment (|> (list.indices (list.size environment)) + (list\each (///foreign.get class)) + (monad.all _.monad)) + missing_partials (|> _.aconst_null + (list.repeated (|> num_partials (n.- apply_arity) (n.- stage))) + (monad.all _.monad))] + ($_ _.composite + (_.new class) + _.dup + current_environment + ///partial/count.value + (..increment apply_arity) + current_partials + (..inputs ..this_offset apply_arity) + missing_partials + (_.invokevirtual class //init.name (//init.type environment function_arity)) + _.areturn))))))) (monad.all _.monad))]] ($_ _.composite ///partial/count.value diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux index 3c1922063..a9dc55525 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux @@ -49,10 +49,10 @@ (def: .public (type environment arity) (-> (Environment Synthesis) Arity (Type category.Method)) - (type.method [(list\compose (///foreign.closure environment) - (if (arity.multiary? arity) - (list& ///arity.type (..partials arity)) - (list))) + (type.method [(list\composite (///foreign.closure environment) + (if (arity.multiary? arity) + (list& ///arity.type (..partials arity)) + (list))) type.void (list)])) @@ -77,9 +77,9 @@ (-> Register Register) (Bytecode Any)) (|> (list.indices amount) - (list\map (function (_ register) - (put register - (_.aload (offset register))))) + (list\each (function (_ register) + (put register + (_.aload (offset register))))) (monad.all _.monad))) (def: .public (method class environment arity) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux index c126f0296..e155c518b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux @@ -54,7 +54,7 @@ (def: .public (instance generate archive class environment arity) (-> Phase Archive (Type Class) (Environment Synthesis) Arity (Operation (Bytecode Any))) (do {! phase.monad} - [foreign* (monad.map ! (generate archive) environment)] + [foreign* (monad.each ! (generate archive) environment)] (in (instance' foreign* class environment arity)))) (def: .public (method class environment arity) @@ -72,10 +72,10 @@ (#.Some ($_ _.composite ////reference.this (//init.super environment_size arity) - (monad.map _.monad (function (_ register) - (///foreign.put class register (_.aload (after_this register)))) - (list.indices environment_size)) - (monad.map _.monad (function (_ register) - (///partial.put class register (_.aload (after_arity register)))) - (list.indices (n.- ///arity.minimum arity))) + (monad.each _.monad (function (_ register) + (///foreign.put class register (_.aload (after_this register)))) + (list.indices environment_size)) + (monad.each _.monad (function (_ register) + (///partial.put class register (_.aload (after_arity register)))) + (list.indices (n.- ///arity.minimum arity))) _.areturn))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux index d787bf16e..ea526c674 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux @@ -36,7 +36,7 @@ (-> (Type Class) (Environment Synthesis) (List (Bytecode Any))) (|>> list.size list.indices - (list\map (///foreign.get class)))) + (list\each (///foreign.get class)))) (def: .public (method class environment arity) (-> (Type Class) (Environment Synthesis) Arity (Resource Method)) 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 4915e010a..832fce239 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 @@ -55,10 +55,10 @@ (def: value::field "value") (def: value::type (type.class "java.lang.Object" (list))) -(def: value::modifier ($_ modifier\compose field.public field.final field.static)) +(def: value::modifier ($_ modifier\composite field.public field.final field.static)) (def: init::type (type.method [(list) type.void (list)])) -(def: init::modifier ($_ modifier\compose method.public method.static method.strict)) +(def: init::modifier ($_ modifier\composite method.public method.static method.strict)) (exception: .public (cannot_load {class Text} {error Text}) (exception.report @@ -114,7 +114,7 @@ _.return)))) (row.row))] (io.run! (do {! (try.with io.monad)} - [bytecode (\ ! map (format.result class.writer) + [bytecode (\ ! each (format.result class.writer) (io.io bytecode)) _ (loader.store eval_class bytecode library) class (loader.load eval_class loader) @@ -126,8 +126,8 @@ (-> 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))) + (\ io.monad each (function (_ library) + (dictionary.key? library class_name))) (try.lifted io.monad) (: (IO (Try Bit)))) _ (if existing_class? @@ -152,7 +152,7 @@ (implementation (def: (evaluate! temp_label valueG) (let [eval_class (|> temp_label name.normal (text.replaced " " "$"))] - (\ try.monad map product.left + (\ try.monad each product.left (..evaluate! library loader eval_class valueG)))) (def: execute! diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux index 9b69ffbae..b7e934447 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux @@ -43,16 +43,16 @@ [[@begin offset] generation.anchor updatesG (|> updatesS list.enumeration - (list\map (function (_ [index updateS]) - [(n.+ offset index) updateS])) - (monad.map ! (function (_ [register updateS]) - (if (invariant? register updateS) - (in [..no_op - ..no_op]) - (do ! - [fetchG (translate archive updateS) - .let [storeG (_.astore register)]] - (in [fetchG storeG]))))))] + (list\each (function (_ [index updateS]) + [(n.+ offset index) updateS])) + (monad.each ! (function (_ [register updateS]) + (if (invariant? register updateS) + (in [..no_op + ..no_op]) + (do ! + [fetchG (translate archive updateS) + .let [storeG (_.astore register)]] + (in [fetchG storeG]))))))] (in ($_ _.composite ... It may look weird that first I fetch all the values separately, ... and then I store them all. @@ -63,11 +63,11 @@ ... will refer to the new value of X, instead of the old value, as ... should be the case. (|> updatesG - (list\map product.left) + (list\each product.left) (monad.all _.monad)) (|> updatesG list.reversed - (list\map product.right) + (list\each product.right) (monad.all _.monad)) (_.goto @begin))))) @@ -75,14 +75,14 @@ (Generator [Nat (List Synthesis) Synthesis]) (do {! phase.monad} [@begin //runtime.forge_label - initsI+ (monad.map ! (translate archive) initsS+) + initsI+ (monad.each ! (translate archive) initsS+) iterationG (generation.with_anchor [@begin offset] (translate archive iterationS)) .let [initializationG (|> (list.enumeration initsI+) - (list\map (function (_ [index initG]) - ($_ _.composite - initG - (_.astore (n.+ offset index))))) + (list\each (function (_ [index initG]) + ($_ _.composite + initG + (_.astore (n.+ offset index))))) (monad.all _.monad))]] (in ($_ _.composite initializationG 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 419c4eac9..3b1a602da 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 @@ -41,7 +41,7 @@ (def: main::modifier (Modifier Method) - ($_ modifier\compose + ($_ modifier\composite method.public method.static method.strict @@ -49,7 +49,7 @@ (def: program::modifier (Modifier Class) - ($_ modifier\compose + ($_ modifier\composite class.public class.final )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux index 3dafea811..fb134924a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux @@ -42,7 +42,7 @@ (def: (foreign archive variable) (-> Archive Register (Operation (Bytecode Any))) (do {! ////.monad} - [bytecode_name (\ ! map //runtime.class_name + [bytecode_name (\ ! each //runtime.class_name (generation.context archive))] (in ($_ _.composite ..this @@ -62,6 +62,6 @@ (def: .public (constant archive name) (-> Archive Name (Operation (Bytecode Any))) (do {! ////.monad} - [bytecode_name (\ ! map //runtime.class_name + [bytecode_name (\ ! each //runtime.class_name (generation.remember archive name))] (in (_.getstatic (type.class bytecode_name (list)) //value.field //type.value)))) 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 1d414ab77..469ab0e89 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 @@ -103,7 +103,7 @@ (def: modifier (Modifier Method) - ($_ modifier\compose + ($_ modifier\composite method.public method.static method.strict @@ -514,7 +514,7 @@ (Operation Any) (let [class (..reflection ..class) modifier (: (Modifier Class) - ($_ modifier\compose + ($_ modifier\composite class.public class.final)) bytecode (<| (format.result class.writer) @@ -546,21 +546,21 @@ (let [apply::method+ (|> (enum.range n.enum (++ //function/arity.minimum) //function/arity.maximum) - (list\map (function (_ arity) - (method.method method.public ..apply::name (..apply::type arity) - (list) - (#.Some - (let [previous_inputs (|> arity - list.indices - (monad.map _.monad _.aload))] - ($_ _.composite - previous_inputs - (_.invokevirtual //function.class ..apply::name (..apply::type (-- arity))) - (_.checkcast //function.class) - (_.aload arity) - (_.invokevirtual //function.class ..apply::name (..apply::type //function/arity.minimum)) - _.areturn)))))) - (list& (method.method (modifier\compose method.public method.abstract) + (list\each (function (_ arity) + (method.method method.public ..apply::name (..apply::type arity) + (list) + (#.Some + (let [previous_inputs (|> arity + list.indices + (monad.each _.monad _.aload))] + ($_ _.composite + previous_inputs + (_.invokevirtual //function.class ..apply::name (..apply::type (-- arity))) + (_.checkcast //function.class) + (_.aload arity) + (_.invokevirtual //function.class ..apply::name (..apply::type //function/arity.minimum)) + _.areturn)))))) + (list& (method.method (modifier\composite method.public method.abstract) ..apply::name (..apply::type //function/arity.minimum) (list) #.None))) @@ -576,12 +576,12 @@ (_.putfield //function.class //function/count.field //function/count.type) _.return)))) modifier (: (Modifier Class) - ($_ modifier\compose + ($_ modifier\composite class.public class.abstract)) class (..reflection //function.class) partial_count (: (Resource Field) - (field.field (modifier\compose field.public field.final) + (field.field (modifier\composite field.public field.final) //function/count.field //function/count.type (row.row))) @@ -610,4 +610,4 @@ ... This shift is done to avoid the possibility of forged labels ... to be in the range of the labels that are generated automatically ... during the evaluation of Bytecode expressions. - (\ ////.monad map (i64.left_shifted shift) generation.next))) + (\ ////.monad each (i64.left_shifted shift) generation.next))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux index 815c4fca0..d260cca20 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux @@ -39,14 +39,14 @@ (do {! phase.monad} [membersI (|> membersS list.enumeration - (monad.map ! (function (_ [idx member]) - (do ! - [memberI (generate archive member)] - (in (do _.monad - [_ _.dup - _ (_.int (.i64 idx)) - _ memberI] - _.aastore))))))] + (monad.each ! (function (_ [idx member]) + (do ! + [memberI (generate archive member)] + (in (do _.monad + [_ _.dup + _ (_.int (.i64 idx)) + _ memberI] + _.aastore))))))] (in (do {! _.monad} [_ (_.int (.i64 (list.size membersS))) _ (_.anewarray $Object)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux index 56860a588..59dc82f3c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux @@ -32,7 +32,7 @@ (case synthesis (^template [<tag>] [(^ (<tag> value)) - (//////phase\map _.return (expression archive synthesis))]) + (//////phase\each _.return (expression archive synthesis))]) ([synthesis.bit] [synthesis.i64] [synthesis.f64] @@ -62,7 +62,7 @@ (/loop.recur! statement expression archive updates) (^ (synthesis.function/abstraction abstraction)) - (//////phase\map _.return (/function.function statement expression archive abstraction)) + (//////phase\each _.return (/function.function statement expression archive abstraction)) )) (exception: .public cannot_recur_as_an_expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux index 67c156db0..c894606cf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux @@ -192,13 +192,13 @@ (^template [<tag> <format>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (do ! - [then! (recur then)] - (in [(_.= (|> match <format>) - ..peek) - then!]))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (do ! + [then! (recur then)] + (in [(_.= (|> match <format>) + ..peek) + then!]))) + (#.Item item))] (in (_.cond clauses ..fail!)))]) ([#/////synthesis.I64_Fork (<| _.int .int)] [#/////synthesis.F64_Fork _.float] @@ -209,7 +209,7 @@ (///////phase\in (<choice> false idx)) (^ (<simple> idx nextP)) - (///////phase\map (_.then (<choice> true idx)) (recur nextP))]) + (///////phase\each (_.then (<choice> true idx)) (recur nextP))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) @@ -252,13 +252,13 @@ (|>> ////synthesis/case.storage (value@ #////synthesis/case.dependencies) set.list - (list\map (function (_ variable) - (.case variable - (#///////variable.Local register) - (..register register) - - (#///////variable.Foreign register) - (..capture register)))))) + (list\each (function (_ variable) + (.case variable + (#///////variable.Local register) + (..register register) + + (#///////variable.Foreign register) + (..capture register)))))) (def: .public (case! statement expression archive [valueS pathP]) (Generator! [Synthesis Path]) @@ -275,6 +275,6 @@ (-> Phase! (Generator [Synthesis Path])) (|> [valueS pathP] (..case! statement expression archive) - (\ ///////phase.monad map + (\ ///////phase.monad each (|>> (_.closure (list)) (_.apply/* (list)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux index 88f59675d..0d96c3150 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux @@ -33,7 +33,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionO (expression archive functionS) - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply/* argsO+ functionO)))) (def: capture @@ -49,7 +49,7 @@ _ (let [@inits (|> (list.enumeration inits) - (list\map (|>> product.left ..capture)))] + (list\each (|>> product.left ..capture)))] [(_.function @self @inits ($_ _.then (_.local_function @self @args body!) @@ -68,11 +68,11 @@ (do {! ///////phase.monad} [[function_name body!] (/////generation.with_new_context archive (do ! - [@scope (\ ! map ..@scope + [@scope (\ ! each ..@scope (/////generation.context archive))] (/////generation.with_anchor [1 @scope] (statement expression archive bodyS)))) - closureO+ (monad.map ! (expression archive) environment) + closureO+ (monad.each ! (expression archive) environment) .let [@curried (_.var "curried") arityO (|> arity .int _.int) @num_args (_.var "num_args") diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux index ddc716045..eb8ff0322 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux @@ -38,7 +38,7 @@ (-> Bit Register (List Expression) Bit Statement Statement) (let [variables (|> bindings list.enumeration - (list\map (|>> product.left (n.+ offset) //case.register)))] + (list\each (|>> product.left (n.+ offset) //case.register)))] (if as_expression? body ($_ _.then @@ -56,13 +56,13 @@ #.End (|> bodyS (statement expression archive) - (\ ///////phase.monad map (|>> [(list)]))) + (\ ///////phase.monad each (|>> [(list)]))) ... true loop _ (do {! ///////phase.monad} - [@scope (\ ! map ..@scope /////generation.next) - initsO+ (monad.map ! (expression archive) initsS+) + [@scope (\ ! each ..@scope /////generation.next) + initsO+ (monad.each ! (expression archive) initsS+) body! (/////generation.with_anchor [start @scope] (statement expression archive bodyS))] (in [initsO+ @@ -86,7 +86,7 @@ .let [@loop (_.var (///reference.artifact [artifact_module artifact_id])) locals (|> initsO+ list.enumeration - (list\map (|>> product.left (n.+ start) //case.register))) + (list\each (|>> product.left (n.+ start) //case.register))) [directive instantiation] (: [Statement Expression] (case (|> (synthesis.path/then bodyS) //case.dependencies @@ -115,5 +115,5 @@ (Generator! (List Synthesis)) (do {! ///////phase.monad} [[offset @scope] /////generation.anchor - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (..setup false offset argsO+ false (_.go_to @scope))))) 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 997030d05..0a8cbd859 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 @@ -108,9 +108,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -143,9 +143,9 @@ (#.Right [name inputs]) (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)) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` _.Expression)) + inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply/* (list (~+ inputsC)) (~ runtime_name)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux index 6bbd167eb..59d70ae69 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux @@ -25,13 +25,13 @@ _ (|> elemsS+ - (monad.map ///////phase.monad (generate archive)) - (///////phase\map _.array)))) + (monad.each ///////phase.monad (generate archive)) + (///////phase\each _.array)))) (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (//runtime.variant tag right?) - (generate archive valueS)))) + (///////phase\each (//runtime.variant tag right?) + (generate archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux index 1366ae632..4364995c7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux @@ -32,7 +32,7 @@ (case synthesis (^template [<tag>] [(^ (<tag> value)) - (//////phase\map _.return (expression archive synthesis))]) + (//////phase\each _.return (expression archive synthesis))]) ([////synthesis.bit] [////synthesis.i64] [////synthesis.f64] @@ -56,7 +56,7 @@ [////synthesis.loop/recur /loop.recur!]) (^ (////synthesis.function/abstraction abstraction)) - (//////phase\map _.return (/function.function statement expression archive abstraction)) + (//////phase\each _.return (/function.function statement expression archive abstraction)) )) (exception: .public cannot_recur_as_an_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 ccea519f2..dcd9a3c12 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 @@ -192,13 +192,13 @@ (^template [<tag> <format>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (do ! - [then! (recur then)] - (in [(_.=== (|> match <format>) - ..peek) - then!]))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (do ! + [then! (recur then)] + (in [(_.=== (|> match <format>) + ..peek) + then!]))) + (#.Item item))] (in (_.cond clauses ..fail!)))]) ([#/////synthesis.I64_Fork //primitive.i64] [#/////synthesis.F64_Fork //primitive.f64] @@ -211,7 +211,7 @@ (^ (<simple> idx nextP)) (|> nextP recur - (\ ///////phase.monad map (_.then (<choice> true idx))))]) + (\ ///////phase.monad each (_.then (<choice> true idx))))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) @@ -262,13 +262,13 @@ (|>> ////synthesis/case.storage (value@ #////synthesis/case.dependencies) set.list - (list\map (function (_ variable) - (.case variable - (#///////variable.Local register) - (..register register) - - (#///////variable.Foreign register) - (..capture register)))))) + (list\each (function (_ variable) + (.case variable + (#///////variable.Local register) + (..register register) + + (#///////variable.Foreign register) + (..capture register)))))) (def: .public (case! statement expression archive [valueS pathP]) (Generator! [Synthesis Path]) @@ -288,7 +288,7 @@ .let [@case (_.constant (///reference.artifact [case_module case_artifact])) @dependencies+ (..dependencies (/////synthesis.path/seq (/////synthesis.path/then valueS) pathP)) - directive (_.define_function @case (list\map _.parameter @dependencies+) case!)] + directive (_.define_function @case (list\each _.parameter @dependencies+) case!)] _ (/////generation.execute! directive) _ (/////generation.save! case_artifact directive)] (in (_.apply/* @dependencies+ @case)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux index c749c30f2..b68f9a404 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux @@ -33,7 +33,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionG (expression archive functionS) - argsG+ (monad.map ! (expression archive) argsS+)] + argsG+ (monad.each ! (expression archive) argsS+)] (in (_.apply/*' argsG+ functionG)))) (def: capture @@ -58,10 +58,10 @@ _ (let [@inits (|> (list.enumeration inits) - (list\map (|>> product.left ..capture)))] - [(_.set! @selfG (_.closure (list) (list\map _.parameter @inits) + (list\each (|>> product.left ..capture)))] + [(_.set! @selfG (_.closure (list) (list\each _.parameter @inits) ($_ _.then - (_.set! @selfL (_.closure (list& (_.reference @selfL) (list\map _.reference @inits)) + (_.set! @selfL (_.closure (list& (_.reference @selfL) (list\each _.reference @inits)) (list) body!)) (_.return @selfL)))) @@ -72,11 +72,11 @@ (do {! ///////phase.monad} [[function_name body!] (/////generation.with_new_context archive (do ! - [@scope (\ ! map ..@scope + [@scope (\ ! each ..@scope (/////generation.context archive))] (/////generation.with_anchor [1 @scope] (statement expression archive bodyS)))) - closureG+ (monad.map ! (expression archive) environment) + closureG+ (monad.each ! (expression archive) environment) .let [@curried (_.var "curried") arityG (|> arity .int _.int) @num_args (_.var "num_args") diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux index 8baa09008..e513411b3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux @@ -41,9 +41,9 @@ (-> Register (List Expression) Statement Statement) (|> bindings list.enumeration - (list\map (function (_ [register value]) - (let [variable (//case.register (n.+ offset register))] - (_.set! variable value)))) + (list\each (function (_ [register value]) + (let [variable (//case.register (n.+ offset register))] + (_.set! variable value)))) list.reversed (list\mix _.then body))) @@ -57,8 +57,8 @@ ... true loop _ (do {! ///////phase.monad} - [@scope (\ ! map ..@scope /////generation.next) - initsO+ (monad.map ! (expression archive) initsS+) + [@scope (\ ! each ..@scope /////generation.next) + initsO+ (monad.each ! (expression archive) initsS+) body! (/////generation.with_anchor [start @scope] (statement expression archive bodyS))] (in (..setup start initsO+ @@ -80,15 +80,15 @@ (..scope! statement expression archive [start initsS+ bodyS])) .let [locals (|> initsS+ list.enumeration - (list\map (|>> product.left (n.+ start) //case.register _.parameter))) + (list\each (|>> product.left (n.+ start) //case.register _.parameter))) @loop (_.constant (///reference.artifact [loop_module loop_artifact])) - loop_variables (set.of_list _.hash (list\map product.right locals)) + loop_variables (set.of_list _.hash (list\each product.right locals)) referenced_variables (: (-> Synthesis (Set Var)) (|>> synthesis.path/then //case.dependencies (set.of_list _.hash))) [directive instantiation] (: [Statement Expression] - (case (|> (list\map referenced_variables initsS+) + (case (|> (list\each referenced_variables initsS+) (list\mix set.union (referenced_variables bodyS)) (set.difference loop_variables) set.list) @@ -97,8 +97,8 @@ @loop] foreigns - [(<| (_.define_function @loop (list\map _.parameter foreigns)) - (_.return (_.closure (list\map _.parameter foreigns) (list) scope!))) + [(<| (_.define_function @loop (list\each _.parameter foreigns)) + (_.return (_.closure (list\each _.parameter foreigns) (list) scope!))) (_.apply/* foreigns @loop)]))] _ (/////generation.execute! directive) _ (/////generation.save! loop_artifact directive)] @@ -111,12 +111,12 @@ (Generator! (List Synthesis)) (do {! ///////phase.monad} [[offset @scope] /////generation.anchor - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in ($_ _.then (_.set! @temp (_.array/* argsO+)) (..setup offset (|> argsO+ list.enumeration - (list\map (function (_ [idx _]) - (_.item (_.int (.int idx)) @temp)))) + (list\each (function (_ [idx _]) + (_.item (_.int (.int idx)) @temp)))) (_.go_to @scope)))))) 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 8dfb51dd7..f5bde1d64 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 @@ -76,9 +76,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -111,9 +111,9 @@ (#.Right [name inputs]) (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)) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` _.Expression)) + inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply/* (list (~+ inputsC)) (~ runtime_name)))) @@ -124,7 +124,7 @@ (function ((~ g!_) (~ g!_)) (..with_vars [(~+ inputsC)] (_.define_function (~ g!_) - (list (~+ (list\map (|>> (~) [false] (`)) inputsC))) + (list (~+ (list\each (|>> (~) [false] (`)) inputsC))) (~ code)))))))))))))))) (runtime: (io//log! message) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux index a7fe22f6d..4d73dcec5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux @@ -29,14 +29,14 @@ _ (let [size (_.int (.int (list.size elemsS+)))] (|> elemsS+ - (monad.map ///////phase.monad (expression archive)) - (///////phase\map (|>> _.array/* - (//runtime.tuple//make size))))))) + (monad.each ///////phase.monad (expression archive)) + (///////phase\each (|>> _.array/* + (//runtime.tuple//make size))))))) (def: .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (//runtime.variant tag right?) - (expression archive valueS)))) + (///////phase\each (//runtime.variant tag right?) + (expression archive valueS)))) 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 6262f0104..e0385c419 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 @@ -36,8 +36,8 @@ (def: .public (identifier prefix) (-> Text (Operation SVar)) - (///////phase\map (|>> %.nat (format prefix) _.var) - /////generation.next)) + (///////phase\each (|>> %.nat (format prefix) _.var) + /////generation.next)) (def: .public register (-> Register SVar) @@ -199,12 +199,12 @@ (^template [<tag> <format>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (\ ! map - (|>> [(_.= (|> match <format>) - ..peek)]) - (recur then))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (\ ! each + (|>> [(_.= (|> match <format>) + ..peek)]) + (recur then))) + (#.Item item))] (in (#.Some (_.cond clauses ..fail_pm!))))]) ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] @@ -241,7 +241,7 @@ (^ (<simple> idx nextP)) (|> nextP recur - (///////phase\map (_.then (<choice> true idx))))]) + (///////phase\each (_.then (<choice> true idx))))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) @@ -300,13 +300,13 @@ (|>> case.storage (value@ #case.dependencies) set.list - (list\map (function (_ variable) - (.case variable - (#///////variable.Local register) - (..register register) - - (#///////variable.Foreign register) - (..capture register)))))) + (list\each (function (_ variable) + (.case variable + (#///////variable.Local register) + (..register register) + + (#///////variable.Foreign register) + (..capture register)))))) (def: .public (case! in_closure? statement expression archive [valueS pathP]) (-> Bit (Generator! [Synthesis Path])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux index f4b31f61d..bd8bd4047 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux @@ -35,7 +35,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionO (expression archive functionS) - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply/* functionO argsO+)))) (def: .public capture @@ -55,7 +55,7 @@ (do {! ///////phase.monad} [.let [directive (_.def @function (|> (list.enumeration inits) - (list\map (|>> product.left ..capture))) + (list\each (|>> product.left ..capture))) ($_ _.then function_definition (_.return @function)))] @@ -72,7 +72,7 @@ [[[function_module function_artifact] body!] (/////generation.with_new_context archive (/////generation.with_anchor 1 (statement expression archive bodyS))) - environment (monad.map ! (expression archive) environment) + environment (monad.each ! (expression archive) environment) .let [@curried (_.var "curried") arityO (|> arity .int _.int) @num_args (_.var "num_args") 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 50469f64e..670480f8e 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 @@ -35,9 +35,9 @@ (-> Register (List (Expression Any)) (Statement Any) (Statement Any)) (|> bindings list.enumeration - (list\map (function (_ [register value]) - (_.set (list (//case.register (n.+ offset register))) - value))) + (list\each (function (_ [register value]) + (_.set (list (//case.register (n.+ offset register))) + value))) list.reversed (list\mix _.then body))) @@ -57,7 +57,7 @@ ... true loop _ (do {! ///////phase.monad} - [initsO+ (monad.map ! (expression archive) initsS+) + [initsO+ (monad.each ! (expression archive) initsS+) body! (/////generation.with_anchor start (statement expression archive bodyS))] (in (<| (..setup start initsO+) @@ -74,14 +74,14 @@ ... true loop _ (do {! ///////phase.monad} - [initsO+ (monad.map ! (expression archive) initsS+) + [initsO+ (monad.each ! (expression archive) initsS+) [[loop_module loop_artifact] body!] (/////generation.with_new_context archive (/////generation.with_anchor start (statement expression archive bodyS))) .let [@loop (_.var (///reference.artifact [loop_module loop_artifact])) locals (|> initsS+ list.enumeration - (list\map (|>> product.left (n.+ start) //case.register))) + (list\each (|>> product.left (n.+ start) //case.register))) actual_loop (<| (_.def @loop locals) ..set_scope body!) @@ -111,11 +111,11 @@ (do {! ///////phase.monad} [offset /////generation.anchor @temp (//case.identifier "lux_recur_values") - argsO+ (monad.map ! (expression archive) argsS+) + argsO+ (monad.each ! (expression archive) argsS+) .let [re_binds (|> argsO+ list.enumeration - (list\map (function (_ [idx _]) - (_.item (_.int (.int idx)) @temp))))]] + (list\each (function (_ [idx _]) + (_.item (_.int (.int idx)) @temp))))]] (in ($_ _.then (_.set (list @temp) (_.list argsO+)) (..setup offset re_binds 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 9952ea02d..fafc59235 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 @@ -115,9 +115,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -143,9 +143,9 @@ (let [nameC (code.local_identifier name) code_nameC (code.local_identifier (format "@" name)) runtime_nameC (` (runtime_name (~ (code.text name)))) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` (_.Expression Any))) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` (_.Expression Any))) + inputs)] (in (list (` (def: .public ((~ nameC) (~+ inputsC)) (-> (~+ inputs_typesC) (Computation Any)) (_.apply/* (~ runtime_nameC) (list (~+ inputsC))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux index 756e3f00d..85dc6218c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux @@ -25,13 +25,13 @@ _ (|> elemsS+ - (monad.map ///////phase.monad (generate archive)) - (///////phase\map _.list)))) + (monad.each ///////phase.monad (generate archive)) + (///////phase\each _.list)))) (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (//runtime.variant tag right?) - (generate archive valueS)))) + (///////phase\each (//runtime.variant tag right?) + (generate archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux index e751e412b..86f376beb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux @@ -164,13 +164,13 @@ (^template [<tag> <format> <=>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (do ! - [then! (recur then)] - (in [(<=> (|> match <format>) - ..peek) - then!]))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (do ! + [then! (recur then)] + (in [(<=> (|> match <format>) + ..peek) + then!]))) + (#.Item item))] (in (list\mix (function (_ [when then] else) (_.if when then else)) ..fail! @@ -233,8 +233,8 @@ (Generator [Synthesis Path]) (do {! ///////phase.monad} [valueO (expression archive valueS)] - (<| (\ ! map (|>> ($_ _.then - (_.set! $cursor (_.list (list valueO))) - (_.set! $savepoint (_.list (list)))) - _.block)) + (<| (\ ! each (|>> ($_ _.then + (_.set! $cursor (_.list (list valueO))) + (_.set! $savepoint (_.list (list)))) + _.block)) (pattern_matching expression archive pathP)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux index f2335374c..5a4914c31 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux @@ -36,7 +36,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionO (expression archive functionS) - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ functionO)))) (def: (with_closure function_id $function inits function_definition) @@ -55,7 +55,7 @@ (_.function (|> inits list.size list.indices - (list\map //case.capture)) + (list\each //case.capture)) ($_ _.then function_definition $function)))] @@ -76,11 +76,11 @@ (do {! ///////phase.monad} [[[function_module function_artifact] bodyO] (/////generation.with_new_context archive (do ! - [$self (\ ! map (|>> ///reference.artifact _.var) + [$self (\ ! each (|>> ///reference.artifact _.var) (/////generation.context archive))] (/////generation.with_anchor $self (expression archive bodyS)))) - closureO+ (monad.map ! (expression archive) environment) + closureO+ (monad.each ! (expression archive) environment) .let [arityO (|> arity .int _.int) $num_args (_.var "num_args") $self (_.var (///reference.artifact [function_module function_artifact])) @@ -96,7 +96,7 @@ (_.set! (//case.register 0) $self) (|> arity list.indices - (list\map input_declaration) + (list\each input_declaration) (list\mix _.then bodyO)))] [(|> $num_args (_.> arityO)) (let [arity_args (_.slice (_.int +1) arityO $curried) 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 28ac47ffb..82b97c26a 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,8 +43,8 @@ ... true loop _ (do {! ///////phase.monad} - [$scope (\ ! map _.var (/////generation.identifier "loop_scope")) - initsO+ (monad.map ! (expression archive) initsS+) + [$scope (\ ! each _.var (/////generation.identifier "loop_scope")) + initsO+ (monad.each ! (expression archive) initsS+) bodyO (/////generation.with_anchor $scope (expression archive bodyS))] (in (_.block @@ -53,7 +53,7 @@ (_.function (|> initsS+ list.size list.indices - (list\map (|>> (n.+ offset) //case.register))) + (list\each (|>> (n.+ offset) //case.register))) bodyO)) (_.apply initsO+ $scope))))))) @@ -61,5 +61,5 @@ (Generator (List Synthesis)) (do {! ///////phase.monad} [$scope /////generation.anchor - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ $scope)))) 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 624826639..e528b33a0 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 @@ -54,7 +54,7 @@ (-> Text Bundle Bundle) (|> bundle dict.entries - (list/map (function (_ [key val]) [(format prefix " " key) val])) + (list/each (function (_ [key val]) [(format prefix " " key) val])) (dict.from_list text.Hash<Text>))) (def: (wrong_arity proc expected actual) @@ -69,21 +69,21 @@ (do {@ macro.monad} [g!input+ (monad.all @ (list.repeated arity (macro.identifier "input")))] (in (list (` (def: .public ((~ (code.local_identifier name)) (~ g!proc)) - (-> (-> (..Vector (~ (code.nat arity)) Expression) Expression) - (-> Text ..Proc)) - (function ((~ g!_) (~ g!name)) - (function ((~ g!_) (~ g!translate) (~ g!inputs)) - (case (~ g!inputs) - (^ (list (~+ g!input+))) - (do macro.Monad<Meta> - [(~+ (|> g!input+ - (list/map (function (_ g!input) - (list g!input (` ((~ g!translate) (~ g!input)))))) - list.together))] - ((~' in) ((~ g!proc) [(~+ g!input+)]))) - - (~' _) - (macro.failure (wrong_arity (~ g!name) +1 (list.size (~ g!inputs)))))))))))))) + (-> (-> (..Vector (~ (code.nat arity)) Expression) Expression) + (-> Text ..Proc)) + (function ((~ g!_) (~ g!name)) + (function ((~ g!_) (~ g!translate) (~ g!inputs)) + (case (~ g!inputs) + (^ (list (~+ g!input+))) + (do macro.Monad<Meta> + [(~+ (|> g!input+ + (list/each (function (_ g!input) + (list g!input (` ((~ g!translate) (~ g!input)))))) + list.together))] + ((~' in) ((~ g!proc) [(~+ g!input+)]))) + + (~' _) + (macro.failure (wrong_arity (~ g!name) +1 (list.size (~ g!inputs)))))))))))))) (arity: nullary +0) (arity: unary +1) @@ -95,7 +95,7 @@ (function (_ proc_name) (function (_ translate inputsS) (do {@ macro.Monad<Meta>} - [inputsI (monad.map @ translate inputsS)] + [inputsI (monad.each @ translate inputsS)] (in (proc inputsI)))))) ... [Procedures] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux index db45a04fc..b810862e2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux @@ -39,7 +39,7 @@ ... (^ (list& functionS argsS+)) ... (do {@ macro.Monad<Meta>} ... [functionO (translate functionS) -... argsO+ (monad.map @ translate argsS+)] +... argsO+ (monad.each @ translate argsS+)] ... (in (lua.apply functionO argsO+))) ... _ @@ -59,7 +59,7 @@ ... (^ (list& tableS [_ (#.Text field)] argsS+)) ... (do {@ macro.Monad<Meta>} ... [tableO (translate tableS) -... argsO+ (monad.map @ translate argsS+)] +... argsO+ (monad.each @ translate argsS+)] ... (in (lua.method field tableO argsO+))) ... _ 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 f0ea2c3fb..5d91dbde7 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 @@ -82,9 +82,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -110,9 +110,9 @@ (#.Right [name inputs]) (let [g!name (code.local_identifier name) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` _.Expression)) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` _.Expression)) + inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) _.Expression) (_.apply (list (~+ inputsC)) (~ runtime_name)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux index 748f56955..2a69cfb08 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux @@ -28,13 +28,13 @@ _ (|> elemsS+ - (monad.map ///////phase.monad (expression archive)) - (///////phase\map _.list)))) + (monad.each ///////phase.monad (expression archive)) + (///////phase\each _.list)))) (def: .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (|>> (//runtime.variant tag right?)) - (expression archive valueS)))) + (///////phase\each (|>> (//runtime.variant tag right?)) + (expression archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux index 26ccf116d..9259c0ef1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux @@ -54,8 +54,8 @@ (All [anchor expression directive] (-> (System expression) Archive Name (////generation.Operation anchor expression directive expression))) - (phase\map (|>> ..artifact (\ system constant)) - (////generation.remember archive name))) + (phase\each (|>> ..artifact (\ system constant)) + (////generation.remember archive name))) (template [<sigil> <name>] [(def: .public (<name> system) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux index 0c56f55b1..e963dad17 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux @@ -32,7 +32,7 @@ (case synthesis (^template [<tag>] [(^ (<tag> value)) - (//////phase\map _.return (expression archive synthesis))]) + (//////phase\each _.return (expression archive synthesis))]) ([////synthesis.bit] [////synthesis.i64] [////synthesis.f64] @@ -56,7 +56,7 @@ [////synthesis.loop/recur /loop.recur!]) (^ (////synthesis.function/abstraction abstraction)) - (//////phase\map _.return (/function.function statement expression archive abstraction)) + (//////phase\each _.return (/function.function statement expression archive abstraction)) )) (exception: .public cannot_recur_as_an_expression) 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 df08d8a21..276716fef 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 @@ -38,7 +38,7 @@ (def: .public (identifier prefix) (-> Text (Operation LVar)) - (///////phase\map (|>> %.nat (format prefix) _.local) /////generation.next)) + (///////phase\each (|>> %.nat (format prefix) _.local) /////generation.next)) (def: .public register (-> Register LVar) @@ -208,12 +208,12 @@ (^template [<tag> <format>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (\ ! map - (|>> [(_.= (|> match <format>) - ..peek)]) - (recur then))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (\ ! each + (|>> [(_.= (|> match <format>) + ..peek)]) + (recur then))) + (#.Item item))] (in (#.Some (_.cond clauses ..fail!))))]) ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] @@ -263,12 +263,12 @@ (^template [<tag> <format>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (\ ! map - (|>> [(_.= (|> match <format>) - ..peek)]) - (recur then))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (\ ! each + (|>> [(_.= (|> match <format>) + ..peek)]) + (recur then))) + (#.Item item))] (in (_.cond clauses ..fail!)))]) ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] @@ -282,7 +282,7 @@ (^ (<simple> idx nextP)) (|> nextP recur - (///////phase\map (_.then (<choice> true idx))))]) + (///////phase\each (_.then (<choice> true idx))))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) @@ -355,6 +355,6 @@ (-> Phase! (Generator [Synthesis Path])) (|> case (case! true statement expression archive) - (\ ///////phase.monad map + (\ ///////phase.monad each (|>> (_.lambda #.None (list)) (_.apply_lambda/* (list)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux index efc132065..768d4a928 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux @@ -35,7 +35,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionO (expression archive functionS) - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply_lambda/* argsO+ functionO)))) (def: .public capture @@ -54,7 +54,7 @@ (let [@self (_.local self)] [(_.function @self (|> (list.enumeration inits) - (list\map (|>> product.left ..capture))) + (list\each (|>> product.left ..capture))) ($_ _.then (_.set (list @self) function_definition) (_.return @self))) @@ -69,7 +69,7 @@ [[[function_module function_artifact] body!] (/////generation.with_new_context archive (/////generation.with_anchor 1 (statement expression archive bodyS))) - closureO+ (monad.map ! (expression archive) environment) + closureO+ (monad.each ! (expression archive) environment) .let [function_name (///reference.artifact [function_module function_artifact]) @curried (_.local "curried") arityO (|> arity .int _.int) 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 caf3afb78..2c6f7dbe9 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 @@ -35,9 +35,9 @@ (-> Register (List Expression) Statement Statement) (|> bindings list.enumeration - (list\map (function (_ [register value]) - (_.set (list (//case.register (n.+ offset register))) - value))) + (list\each (function (_ [register value]) + (_.set (list (//case.register (n.+ offset register))) + value))) list.reversed (list\mix _.then body))) @@ -58,7 +58,7 @@ ... true loop _ (do {! ///////phase.monad} - [initsO+ (monad.map ! (expression archive) initsS+) + [initsO+ (monad.each ! (expression archive) initsS+) body! (/////generation.with_anchor start (statement expression archive bodyS))] (in (<| (..setup start initsO+) @@ -85,11 +85,11 @@ (do {! ///////phase.monad} [offset /////generation.anchor @temp (//case.identifier "lux_recur_values") - argsO+ (monad.map ! (expression archive) argsS+) + argsO+ (monad.each ! (expression archive) argsS+) .let [re_binds (|> argsO+ list.enumeration - (list\map (function (_ [idx _]) - (_.item (_.int (.int idx)) @temp))))]] + (list\each (function (_ [idx _]) + (_.item (_.int (.int idx)) @temp))))]] (in ($_ _.then (_.set (list @temp) (_.array argsO+)) (..setup offset re_binds 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 b083c0a67..c4d57ef09 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 @@ -77,9 +77,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.local (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.local (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -109,9 +109,9 @@ (#.Right [name inputs]) (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)) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` _.Expression)) + inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply/* (list (~+ inputsC)) (~ runtime_name)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux index 57861f7d4..a5ac11d83 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux @@ -25,13 +25,13 @@ _ (|> elemsS+ - (monad.map ///////phase.monad (generate archive)) - (///////phase\map _.array)))) + (monad.each ///////phase.monad (generate archive)) + (///////phase\each _.array)))) (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (//runtime.variant tag right?) - (generate archive valueS)))) + (///////phase\each (//runtime.variant tag right?) + (generate archive valueS)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux index e68b23464..de65969b2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux @@ -158,13 +158,13 @@ (^template [<tag> <format> <=>] [(<tag> item) (do {! ///////phase.monad} - [clauses (monad.map ! (function (_ [match then]) - (do ! - [then! (recur then)] - (in [(<=> (|> match <format>) - ..peek) - then!]))) - (#.Item item))] + [clauses (monad.each ! (function (_ [match then]) + (do ! + [then! (recur then)] + (in [(<=> (|> match <format>) + ..peek) + then!]))) + (#.Item item))] (in (list\mix (function (_ [when then] else) (_.if when then else)) ..fail! @@ -210,7 +210,7 @@ (def: (pattern_matching expression archive pathP) (Generator Path) - (\ ///////phase.monad map + (\ ///////phase.monad each (try_pm (_.raise/1 (_.string "Invalid expression for pattern-matching."))) (pattern_matching' expression archive pathP))) @@ -218,6 +218,6 @@ (Generator [Synthesis Path]) (do {! ///////phase.monad} [valueO (expression archive valueS)] - (<| (\ ! map (_.let (list [@cursor (_.list/* (list valueO))] - [@savepoint (_.list/* (list))]))) + (<| (\ ! each (_.let (list [@cursor (_.list/* (list valueO))] + [@savepoint (_.list/* (list))]))) (pattern_matching expression archive pathP)))) 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 dc3c75d98..b46b2e0b5 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 @@ -51,8 +51,8 @@ (^ (list (~+ g!input+))) (do /////.monad [(~+ (|> g!input+ - (list\map (function (_ g!input) - (list g!input (` ((~ g!phase) (~ g!input)))))) + (list\each (function (_ g!input) + (list g!input (` ((~ g!phase) (~ g!input)))))) list.together))] ((~' in) ((~ g!extension) [(~+ g!input+)]))) @@ -69,7 +69,7 @@ (function (_ extension_name) (function (_ phase inputsS) (do {! /////.monad} - [inputsI (monad.map ! phase inputsS)] + [inputsI (monad.each ! phase inputsS)] (in (extension inputsI)))))) (def: bundle::lux diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux index cfb345097..c7d8dbcd4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux @@ -33,7 +33,7 @@ (Generator (Application Synthesis)) (do {! ///////phase.monad} [functionO (expression archive functionS) - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply/* argsO+ functionO)))) (def: capture @@ -50,7 +50,7 @@ _ (|> function_definition (_.lambda [(|> (list.enumeration inits) - (list\map (|>> product.left ..capture))) + (list\each (|>> product.left ..capture))) #.None]) (_.apply/* inits))))) @@ -65,11 +65,11 @@ (do {! ///////phase.monad} [[function_name bodyO] (/////generation.with_new_context archive (do ! - [@self (\ ! map (|>> ///reference.artifact _.var) + [@self (\ ! each (|>> ///reference.artifact _.var) (/////generation.context archive))] (/////generation.with_anchor @self (expression archive bodyS)))) - closureO+ (monad.map ! (expression archive) environment) + closureO+ (monad.each ! (expression archive) environment) .let [arityO (|> arity .int _.int) apply_poly (.function (_ args func) (_.apply/2 (_.var "apply") func args)) @@ -81,7 +81,7 @@ (<| (_.if (|> @num_args (_.=/2 arityO)) (<| (_.let (list [(//case.register 0) @self])) (_.let_values (list [[(|> (list.indices arity) - (list\map ..input)) + (list\each ..input)) #.None] (_.apply/2 (_.var "apply") (_.var "values") @curried)])) bodyO)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux index 87ddc4929..d0610fdfa 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux @@ -46,12 +46,12 @@ ... true loop _ (do {! ///////phase.monad} - [initsO+ (monad.map ! (expression archive) initsS+) + [initsO+ (monad.each ! (expression archive) initsS+) bodyO (/////generation.with_anchor @scope (expression archive bodyS))] (in (_.letrec (list [@scope (_.lambda [(|> initsS+ list.enumeration - (list\map (|>> product.left (n.+ start) //case.register))) + (list\each (|>> product.left (n.+ start) //case.register))) #.None] bodyO)]) (_.apply/* initsO+ @scope)))))) @@ -60,5 +60,5 @@ (Generator (List Synthesis)) (do {! ///////phase.monad} [@scope /////generation.anchor - argsO+ (monad.map ! (expression archive) argsS+)] + argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply/* argsO+ @scope)))) 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 221ee6d88..fefd850ce 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 @@ -64,9 +64,9 @@ [ids (monad.all ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) - (list\map (function (_ [id var]) - (list (code.local_identifier var) - (` (_.var (~ (code.text (format "v" (%.nat id))))))))) + (list\each (function (_ [id var]) + (list (code.local_identifier var) + (` (_.var (~ (code.text (format "v" (%.nat id))))))))) list.together))] (~ body))))))) @@ -92,9 +92,9 @@ (#.Right [name inputs]) (let [g!name (code.local_identifier name) - inputsC (list\map code.local_identifier inputs) - inputs_typesC (list\map (function.constant (` _.Expression)) - inputs)] + inputsC (list\each code.local_identifier inputs) + inputs_typesC (list\each (function.constant (` _.Expression)) + inputs)] (in (list (` (def: .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) _.Computation) (_.apply/* (list (~+ inputsC)) (~ runtime_name)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux index 3c21b5e17..0e5d70dbf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux @@ -28,13 +28,13 @@ _ (|> elemsS+ - (monad.map ///////phase.monad (expression archive)) - (///////phase\map _.vector/*)))) + (monad.each ///////phase.monad (expression archive)) + (///////phase\each _.vector/*)))) (def: .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) lefts)] - (///////phase\map (|>> [tag right?] //runtime.variant) - (expression archive valueS)))) + (///////phase\each (|>> [tag right?] //runtime.variant) + (expression archive valueS)))) 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 9e80130aa..f71e89b0c 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 @@ -64,8 +64,8 @@ (#///analysis.Tuple tuple) (|> tuple - (monad.map phase.monad optimization') - (phase\map (|>> /.tuple))))) + (monad.each phase.monad optimization') + (phase\each (|>> /.tuple))))) (#///analysis.Case inputA branchesAB+) (/.with_currying? false @@ -91,8 +91,8 @@ (#try.Failure _) (|> args - (monad.map phase.monad optimization') - (phase\map (|>> [name] #/.Extension)) + (monad.each phase.monad optimization') + (phase\each (|>> [name] #/.Extension)) (phase.result' state)))))) ))) 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 d2bf439da..75e27d5bf 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 @@ -42,15 +42,15 @@ thenC (#///analysis.Bit when) - (///\map (function (_ then) - (#/.Bit_Fork when then #.None)) - thenC) + (///\each (function (_ then) + (#/.Bit_Fork when then #.None)) + thenC) (^template [<from> <to> <conversion>] [(<from> test) - (///\map (function (_ then) - (<to> [(<conversion> test) then] (list))) - thenC)]) + (///\each (function (_ then) + (<to> [(<conversion> test) then] (list))) + thenC)]) ([#///analysis.Nat #/.I64_Fork .i64] [#///analysis.Int #/.I64_Fork .i64] [#///analysis.Rev #/.I64_Fork .i64] @@ -58,16 +58,16 @@ [#///analysis.Text #/.Text_Fork |>])) (#///analysis.Bind register) - (<| (\ ///.monad map (|>> (#/.Seq (#/.Bind register)))) + (<| (\ ///.monad each (|>> (#/.Seq (#/.Bind register)))) /.with_new_local thenC) (#///analysis.Complex (#///analysis.Variant [lefts right? value_pattern])) - (<| (///\map (|>> (#/.Seq (#/.Access (#/.Side (if right? - (#.Right lefts) - (#.Left lefts))))))) + (<| (///\each (|>> (#/.Seq (#/.Access (#/.Side (if right? + (#.Right lefts) + (#.Left lefts))))))) (path' value_pattern end?) - (when> [(new> (not end?) [])] [(///\map ..clean_up)]) + (when> [(new> (not end?) [])] [(///\each ..clean_up)]) thenC) (#///analysis.Complex (#///analysis.Tuple tuple)) @@ -80,11 +80,11 @@ _ (let [right? (n.= tuple::last tuple::lefts) end?' (and end? right?)] - (<| (///\map (|>> (#/.Seq (#/.Access (#/.Member (if right? - (#.Right (-- tuple::lefts)) - (#.Left tuple::lefts))))))) + (<| (///\each (|>> (#/.Seq (#/.Access (#/.Member (if right? + (#.Right (-- tuple::lefts)) + (#.Left tuple::lefts))))))) (path' tuple::member end?') - (when> [(new> (not end?') [])] [(///\map ..clean_up)]) + (when> [(new> (not end?') [])] [(///\each ..clean_up)]) nextC)))) thenC (list.reversed (list.enumeration tuple)))) @@ -92,7 +92,7 @@ (def: (path archive synthesize pattern bodyA) (-> Archive Phase Pattern Analysis (Operation Path)) - (path' pattern true (///\map (|>> #/.Then) (synthesize archive bodyA)))) + (path' pattern true (///\each (|>> #/.Then) (synthesize archive bodyA)))) (def: (weave_branch weave equivalence [new_test new_then] [[old_test old_then] old_tail]) (All [a] (-> (-> Path Path Path) (Equivalence a) [a Path] (/.Fork a Path) @@ -227,7 +227,7 @@ (-> Phase Archive Synthesis Match (Operation Synthesis)) (do {! ///.monad} [headSP (path archive synthesize headP headA) - tailSP+ (monad.map ! (product.uncurried (path archive synthesize)) tailPA+)] + tailSP+ (monad.each ! (product.uncurried (path archive synthesize)) tailPA+)] (in (/.branch/case [input (list\mix weave headSP tailSP+)])))) (template: (!masking <variable> <output>) @@ -269,7 +269,7 @@ path (case input (^ (/.branch/get [sub_path sub_input])) - (///\in (/.branch/get [(list\compose path sub_path) sub_input])) + (///\in (/.branch/get [(list\composite path sub_path) sub_input])) _ (///\in (/.branch/get [path input]))))) @@ -357,7 +357,7 @@ (#/.F64_Fork forks) (#/.Text_Fork forks)) (|> (#.Item forks) - (list\map product.right) + (list\each product.right) (list\mix for_path path_storage)) (^or (^ (/.path/seq left right)) @@ -413,7 +413,7 @@ (set.union (|> synthesis_storage (revised@ #bindings (set.union (|> initsS+ list.enumeration - (list\map (|>> product.left (n.+ start))) + (list\each (|>> product.left (n.+ start))) (set.of_list n.hash)))) (for_synthesis iterationS) (value@ #dependencies))) 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 2aeacc78d..84d91d48d 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 @@ -36,7 +36,7 @@ (-> Arity (List Synthesis)) (|>> -- (enum.range n.enum 1) - (list\map (|>> /.variable/local)))) + (list\each (|>> /.variable/local)))) (template: .public (self_reference) [(/.variable/local 0)]) @@ -51,7 +51,7 @@ (let [[funcA argsA] (////analysis.application exprA)] (do {! phase.monad} [funcS (phase archive funcA) - argsS (monad.map ! (phase archive) argsA)] + argsS (monad.each ! (phase archive) argsA)] (with_expansions [<apply> (as_is (/.function/apply [funcS argsS]))] (case funcS (^ (/.function/abstraction functionS)) @@ -61,22 +61,22 @@ [locals /.locals] (in (|> functionS (//loop.optimization true locals argsS) - (maybe\map (: (-> [Nat (List Synthesis) Synthesis] Synthesis) - (function (_ [start inits iteration]) - (case iteration - (^ (/.loop/scope [start' inits' output])) - (if (and (n.= start start') - (list.empty? inits')) - (/.loop/scope [start inits output]) - (/.loop/scope [start inits iteration])) + (maybe\each (: (-> [Nat (List Synthesis) Synthesis] Synthesis) + (function (_ [start inits iteration]) + (case iteration + (^ (/.loop/scope [start' inits' output])) + (if (and (n.= start start') + (list.empty? inits')) + (/.loop/scope [start inits output]) + (/.loop/scope [start inits iteration])) - _ - (/.loop/scope [start inits iteration]))))) + _ + (/.loop/scope [start inits iteration]))))) (maybe.else <apply>)))) (in <apply>)) (^ (/.function/apply [funcS' argsS'])) - (in (/.function/apply [funcS' (list\compose argsS' argsS)])) + (in (/.function/apply [funcS' (list\composite argsS' argsS)])) _ (in <apply>))))))) @@ -109,7 +109,7 @@ [then (grow_path grow then) else (case else (#.Some else) - (\ ! map (|>> #.Some) (grow_path grow else)) + (\ ! each (|>> #.Some) (grow_path grow else)) #.None (in #.None))] @@ -119,11 +119,11 @@ [(<tag> [[test then] elses]) (do {! phase.monad} [then (grow_path grow then) - elses (monad.map ! (function (_ [else_test else_then]) - (do ! - [else_then (grow_path grow else_then)] - (in [else_test else_then]))) - elses)] + elses (monad.each ! (function (_ [else_test else_then]) + (do ! + [else_then (grow_path grow else_then)] + (in [else_test else_then]))) + elses)] (in (<tag> [[test then] elses])))]) ([#/.I64_Fork] [#/.F64_Fork] @@ -132,7 +132,7 @@ (#/.Then thenS) (|> thenS grow - (phase\map (|>> #/.Then))) + (phase\each (|>> #/.Then))) _ (phase\in path))) @@ -145,12 +145,12 @@ (#////analysis.Variant [lefts right? subS]) (|> subS (grow environment) - (phase\map (|>> [lefts right?] /.variant))) + (phase\each (|>> [lefts right?] /.variant))) (#////analysis.Tuple membersS+) (|> membersS+ - (monad.map phase.monad (grow environment)) - (phase\map (|>> /.tuple)))) + (monad.each phase.monad (grow environment)) + (phase\each (|>> /.tuple)))) (^ (..self_reference)) (phase\in (/.function/apply [expression (list (/.variable/local 1))])) @@ -200,36 +200,36 @@ (case loop (#/.Scope [start initsS+ iterationS]) (do {! phase.monad} - [initsS+' (monad.map ! (grow environment) initsS+) + [initsS+' (monad.each ! (grow environment) initsS+) iterationS' (grow environment iterationS)] (in (/.loop/scope [(++ start) initsS+' iterationS']))) (#/.Recur argumentsS+) (|> argumentsS+ - (monad.map phase.monad (grow environment)) - (phase\map (|>> /.loop/recur)))) + (monad.each phase.monad (grow environment)) + (phase\each (|>> /.loop/recur)))) (#/.Function function) (case function (#/.Abstraction [_env _arity _body]) (do {! phase.monad} - [_env' (monad.map ! - (|>> (case> (#/.Reference (#////reference.Variable (#////reference/variable.Foreign register))) - (..find_foreign environment register) + [_env' (monad.each ! + (|>> (case> (#/.Reference (#////reference.Variable (#////reference/variable.Foreign register))) + (..find_foreign environment register) - captured - (grow environment captured))) - _env)] + captured + (grow environment captured))) + _env)] (in (/.function/abstraction [_env' _arity _body]))) (#/.Apply funcS argsS+) (do {! phase.monad} [funcS (grow environment funcS) - argsS+ (monad.map ! (grow environment) argsS+)] + argsS+ (monad.each ! (grow environment) argsS+)] (in (/.function/apply (case funcS (^ (/.function/apply [(..self_reference) pre_argsS+])) [(..self_reference) - (list\compose pre_argsS+ argsS+)] + (list\composite pre_argsS+ argsS+)] _ [funcS @@ -237,8 +237,8 @@ (#/.Extension name argumentsS+) (|> argumentsS+ - (monad.map phase.monad (grow environment)) - (phase\map (|>> (#/.Extension name)))) + (monad.each phase.monad (grow environment)) + (phase\each (|>> (#/.Extension name)))) (#/.Primitive _) (phase\in expression))) @@ -247,7 +247,7 @@ (-> Phase (Environment Analysis) Phase) (do {! phase.monad} [currying? /.currying? - environment (monad.map ! (phase archive) environment) + environment (monad.each ! (phase archive) environment) bodyS (/.with_currying? true (/.with_locals 2 (phase archive bodyA))) @@ -256,10 +256,10 @@ (^ (/.function/abstraction [env' down_arity' bodyS'])) (|> bodyS' (grow env') - (\ ! map (function (_ body) - {#/.environment environment - #/.arity (++ down_arity') - #/.body body}))) + (\ ! each (function (_ body) + {#/.environment environment + #/.arity (++ down_arity') + #/.body body}))) _ (in {#/.environment environment 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 bba61a90f..882a8c5d6 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 @@ -46,7 +46,7 @@ [then (recur then) else (case else (#.Some else) - (\ ! map (|>> #.Some) (recur else)) + (\ ! each (|>> #.Some) (recur else)) #.None (in #.None))] @@ -56,11 +56,11 @@ [(<tag> [[test then] elses]) (do {! maybe.monad} [then (recur then) - elses (monad.map ! (function (_ [else_test else_then]) - (do ! - [else_then (recur else_then)] - (in [else_test else_then]))) - elses)] + elses (monad.each ! (function (_ [else_test else_then]) + (do ! + [else_then (recur else_then)] + (in [else_test else_then]))) + elses)] (in (<tag> [[test then] elses])))]) ([#/.I64_Fork] [#/.F64_Fork] @@ -69,7 +69,7 @@ (#/.Then body) (|> body body_optimization - (maybe\map (|>> #/.Then))) + (maybe\each (|>> #/.Then))) _ (#.Some path)))) @@ -93,8 +93,8 @@ (#analysis.Tuple tuple) (|> tuple - (monad.map maybe.monad (recur false)) - (maybe\map (|>> /.tuple)))) + (monad.each maybe.monad (recur false)) + (maybe\each (|>> /.tuple)))) (#/.Reference reference) (case reference @@ -142,7 +142,7 @@ (do {! maybe.monad} [inits' (|> scope (value@ #/.inits) - (monad.map ! (recur false))) + (monad.each ! (recur false))) iteration' (recur return? (value@ #/.iteration scope))] (in (/.loop/scope {#/.start (|> scope (value@ #/.start) (register_optimization offset)) #/.inits inits' @@ -150,17 +150,17 @@ (^ (/.loop/recur args)) (|> args - (monad.map maybe.monad (recur false)) - (maybe\map (|>> /.loop/recur))) + (monad.each maybe.monad (recur false)) + (maybe\each (|>> /.loop/recur))) (^ (/.function/abstraction [environment arity body])) (do {! maybe.monad} - [environment' (monad.map ! (recur false) environment)] + [environment' (monad.each ! (recur false) environment)] (in (/.function/abstraction [environment' arity body]))) (^ (/.function/apply [abstraction arguments])) (do {! maybe.monad} - [arguments' (monad.map ! (recur false) arguments)] + [arguments' (monad.each ! (recur false) arguments)] (with_expansions [<application> (as_is (do ! [abstraction' (recur false abstraction)] (in (/.function/apply [abstraction' arguments']))))] @@ -181,29 +181,29 @@ (if return? (do {! maybe.monad} [input (recur false input) - matches (monad.map ! - (function (_ match) - (case match - (^ (#/.Structure (#analysis.Tuple (list when then)))) - (do ! - [when (recur false when) - then (recur return? then)] - (in (#/.Structure (#analysis.Tuple (list when then))))) - - _ - (recur false match))) - matches) + matches (monad.each ! + (function (_ match) + (case match + (^ (#/.Structure (#analysis.Tuple (list when then)))) + (do ! + [when (recur false when) + then (recur return? then)] + (in (#/.Structure (#analysis.Tuple (list when then))))) + + _ + (recur false match))) + matches) else (recur return? else)] (in (#/.Extension ["lux syntax char case!" (list& input else matches)]))) #.None) (#/.Extension [name args]) (|> args - (monad.map maybe.monad (recur false)) - (maybe\map (|>> [name] #/.Extension)))))) + (monad.each maybe.monad (recur false)) + (maybe\each (|>> [name] #/.Extension)))))) (def: .public (optimization true_loop? offset inits functionS) (-> Bit Register (List Synthesis) Abstraction (Maybe [Register (List Synthesis) Synthesis])) (|> (value@ #/.body functionS) (body_optimization true_loop? offset (value@ #/.environment functionS) (value@ #/.arity functionS)) - (maybe\map (|>> [offset inits])))) + (maybe\each (|>> [offset inits])))) 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 88b2d3f1f..212a2a0a2 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 @@ -71,14 +71,14 @@ [#/.Alt]) (#/.Bit_Fork when then else) - (#/.Bit_Fork when (recur then) (maybe\map recur else)) + (#/.Bit_Fork when (recur then) (maybe\each recur else)) (^template [<tag>] [(<tag> [[test then] tail]) (<tag> [[test (recur then)] - (list\map (function (_ [test' then']) - [test' (recur then')]) - tail)])]) + (list\each (function (_ [test' then']) + [test' (recur then')]) + tail)])]) ([#/.I64_Fork] [#/.F64_Fork] [#/.Text_Fork]) @@ -116,7 +116,7 @@ (#analysis.Variant [lefts right (recur value)]) (#analysis.Tuple tuple) - (#analysis.Tuple (list\map recur tuple)))) + (#analysis.Tuple (list\each recur tuple)))) (#/.Reference reference) (case reference @@ -148,24 +148,24 @@ (#/.Loop (case loop (#/.Scope [start inits iteration]) (#/.Scope [(..prune redundant start) - (list\map recur inits) + (list\each recur inits) (recur iteration)]) (#/.Recur resets) - (#/.Recur (list\map recur resets)))) + (#/.Recur (list\each recur resets)))) (#/.Function function) (#/.Function (case function (#/.Abstraction [environment arity body]) - (#/.Abstraction [(list\map recur environment) + (#/.Abstraction [(list\each recur environment) arity body]) (#/.Apply abstraction inputs) - (#/.Apply (recur abstraction) (list\map recur inputs)))))) + (#/.Apply (recur abstraction) (list\each recur inputs)))))) (#/.Extension name inputs) - (#/.Extension name (list\map recur inputs))))) + (#/.Extension name (list\each recur inputs))))) (type: Redundancy (Dictionary Register Bit)) @@ -179,7 +179,7 @@ (def: (extended offset amount redundancy) (-> Register Nat Redundancy [(List Register) Redundancy]) - (let [extension (|> amount list.indices (list\map (n.+ offset)))] + (let [extension (|> amount list.indices (list\each (n.+ offset)))] [extension (list\mix (function (_ register redundancy) (dictionary.has register ..necessary! redundancy)) @@ -239,8 +239,8 @@ (%.Format Redundancy) (|> redundancy dictionary.entries - (list\map (function (_ [register redundant?]) - (%.format (%.nat register) ": " (%.bit redundant?)))) + (list\each (function (_ [register redundant?]) + (%.format (%.nat register) ": " (%.bit redundant?)))) (text.interposed ", "))) (def: (path_optimization optimization) @@ -257,7 +257,7 @@ [[redundancy then] (recur [redundancy then]) [redundancy else] (case else (#.Some else) - (\ ! map + (\ ! each (function (_ [redundancy else]) [redundancy (#.Some else)]) (recur [redundancy else])) @@ -309,7 +309,7 @@ (list.only (function (_ [register redundant?]) (and (set.member? bindings register) redundant?))) - (list\map product.left))]] + (list\each product.left))]] (in [(list\mix dictionary.lacks redundancy (set.list bindings)) (|> redundants (list.sorted n.>) @@ -440,4 +440,4 @@ (-> Synthesis (Try Synthesis)) (|>> [..initial] optimization' - (\ try.monad map product.right))) + (\ try.monad each product.right))) 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 f181fd077..047565e77 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux @@ -37,12 +37,12 @@ (do {! try.monad} [registries (|> archive archive.archived - (monad.map ! - (function (_ module) - (do ! - [id (archive.id module archive) - [descriptor document] (archive.find module archive)] - (in [[module id] (value@ #descriptor.registry descriptor)])))))] + (monad.each ! + (function (_ module) + (do ! + [id (archive.id module archive) + [descriptor document] (archive.find module archive)] + (in [[module id] (value@ #descriptor.registry descriptor)])))))] (case (list.one (function (_ [[module module_id] registry]) (do maybe.monad [program_id (artifact.remember ..name registry)] @@ -53,5 +53,5 @@ #.None (|> registries - (list\map (|>> product.left product.left)) + (list\each (|>> product.left product.left)) (exception.except ..cannot_find_program))))) 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 7f7d205c3..dc555b85d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -38,9 +38,10 @@ (Dictionary Variable Variable)) (type: .public State - {#locals Nat - ... https://en.wikipedia.org/wiki/Currying - #currying? Bit}) + (Record + {#locals Nat + ... https://en.wikipedia.org/wiki/Currying + #currying? Bit})) (def: .public fresh_resolver Resolver @@ -52,10 +53,11 @@ #currying? false}) (type: .public Primitive - (#Bit Bit) - (#I64 (I64 Any)) - (#F64 Frac) - (#Text Text)) + (Variant + (#Bit Bit) + (#I64 (I64 Any)) + (#F64 Frac) + (#Text Text))) (type: .public Side (Either Nat Nat)) @@ -64,63 +66,73 @@ (Either Nat Nat)) (type: .public Access - (#Side Side) - (#Member Member)) + (Variant + (#Side Side) + (#Member Member))) (type: .public (Fork value next) [[value next] (List [value next])]) (type: .public (Path' s) - #Pop - (#Access Access) - (#Bind Register) - (#Bit_Fork Bit (Path' s) (Maybe (Path' s))) - (#I64_Fork (Fork (I64 Any) (Path' s))) - (#F64_Fork (Fork Frac (Path' s))) - (#Text_Fork (Fork Text (Path' s))) - (#Alt (Path' s) (Path' s)) - (#Seq (Path' s) (Path' s)) - (#Then s)) + (Variant + #Pop + (#Access Access) + (#Bind Register) + (#Bit_Fork Bit (Path' s) (Maybe (Path' s))) + (#I64_Fork (Fork (I64 Any) (Path' s))) + (#F64_Fork (Fork Frac (Path' s))) + (#Text_Fork (Fork Text (Path' s))) + (#Alt (Path' s) (Path' s)) + (#Seq (Path' s) (Path' s)) + (#Then s))) (type: .public (Abstraction' s) - {#environment (Environment s) - #arity Arity - #body s}) + (Record + {#environment (Environment s) + #arity Arity + #body s})) (type: .public (Apply' s) - {#function s - #arguments (List s)}) + (Record + {#function s + #arguments (List s)})) (type: .public (Branch s) - (#Let s Register s) - (#If s s s) - (#Get (List Member) s) - (#Case s (Path' s))) + (Variant + (#Let s Register s) + (#If s s s) + (#Get (List Member) s) + (#Case s (Path' s)))) (type: .public (Scope s) - {#start Register - #inits (List s) - #iteration s}) + (Record + {#start Register + #inits (List s) + #iteration s})) (type: .public (Loop s) - (#Scope (Scope s)) - (#Recur (List s))) + (Variant + (#Scope (Scope s)) + (#Recur (List s)))) (type: .public (Function s) - (#Abstraction (Abstraction' s)) - (#Apply s (List s))) + (Variant + (#Abstraction (Abstraction' s)) + (#Apply s (List s)))) (type: .public (Control s) - (#Branch (Branch s)) - (#Loop (Loop s)) - (#Function (Function s))) + (Variant + (#Branch (Branch s)) + (#Loop (Loop s)) + (#Function (Function s)))) (type: .public #rec Synthesis - (#Primitive Primitive) - (#Structure (Composite Synthesis)) - (#Reference Reference) - (#Control (Control Synthesis)) - (#Extension (Extension Synthesis))) + (Variant + (#Primitive Primitive) + (#Structure (Composite Synthesis)) + (#Reference Reference) + (#Control (Control Synthesis)) + (#Extension (Extension Synthesis)))) (template [<special> <general>] [(type: .public <special> @@ -277,8 +289,8 @@ (^template [<tag> <format>] [(<tag> item) (|> (#.Item item) - (list\map (function (_ [test then]) - (format (<format> test) " " (%path' %then then)))) + (list\each (function (_ [test then]) + (format (<format> test) " " (%path' %then then)))) (text.interposed " ") (text.enclosed ["(? " ")"]))]) ([#I64_Fork (|>> .int %.int)] @@ -340,7 +352,7 @@ (#analysis.Tuple members) (|> members - (list\map %synthesis) + (list\each %synthesis) (text.interposed " ") (text.enclosed ["[" "]"]))) @@ -353,7 +365,7 @@ (case function (#Abstraction [environment arity body]) (let [environment' (|> environment - (list\map %synthesis) + (list\each %synthesis) (text.interposed " ") (text.enclosed ["[" "]"]))] (|> (format environment' " " (%.nat arity) " " (%synthesis body)) @@ -361,7 +373,7 @@ (#Apply func args) (|> args - (list\map %synthesis) + (list\each %synthesis) (text.interposed " ") (format (%synthesis func) " ") (text.enclosed ["(" ")"]))) @@ -378,7 +390,7 @@ (#Get members record) (|> (format (%.list (%path' %synthesis) - (list\map (|>> #Member #Access) members)) + (list\each (|>> #Member #Access) members)) " " (%synthesis record)) (text.enclosed ["(#get " ")"])) @@ -391,7 +403,7 @@ (#Scope scope) (|> (format (%.nat (value@ #start scope)) " " (|> (value@ #inits scope) - (list\map %synthesis) + (list\each %synthesis) (text.interposed " ") (text.enclosed ["[" "]"])) " " (%synthesis (value@ #iteration scope))) @@ -399,12 +411,12 @@ (#Recur args) (|> args - (list\map %synthesis) + (list\each %synthesis) (text.interposed " ") (text.enclosed ["(#recur " ")"])))) (#Extension [name args]) - (|> (list\map %synthesis args) + (|> (list\each %synthesis args) (text.interposed " ") (format (%.text name) " ") (text.enclosed ["(" ")"])))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index e1ea19e37..d326a2bbb 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -77,8 +77,9 @@ (abstract: .public Archive {} - {#next ID - #resolver (Dictionary Module [ID (Maybe [Descriptor (Document Any) Output])])} + (Record + {#next ID + #resolver (Dictionary Module [ID (Maybe [Descriptor (Document Any) Output])])}) (def: next (-> Archive ID) @@ -188,8 +189,8 @@ (|>> :representation (value@ #resolver) dictionary.entries - (list\map (function (_ [module [id _]]) - [module id])))) + (list\each (function (_ [module [id _]]) + [module id])))) (def: .public (merged additions archive) (-> Archive Archive Archive) @@ -252,7 +253,7 @@ (-> (List Reservation) Bit) (n.= (list.size reservations) (|> reservations - (list\map product.left) + (list\each product.left) (set.of_list text.hash) set.size))) @@ -260,7 +261,7 @@ (-> (List Reservation) Bit) (n.= (list.size reservations) (|> reservations - (list\map product.right) + (list\each product.right) (set.of_list n.hash) set.size))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux index af69bbdc9..7a2d25b1a 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux @@ -25,23 +25,26 @@ Nat) (type: .public Category - #Anonymous - (#Definition Text) - (#Analyser Text) - (#Synthesizer Text) - (#Generator Text) - (#Directive Text) - (#Custom Text)) + (Variant + #Anonymous + (#Definition Text) + (#Analyser Text) + (#Synthesizer Text) + (#Generator Text) + (#Directive Text) + (#Custom Text))) (type: .public Artifact - {#id ID - #category Category}) + (Record + {#id ID + #category Category})) (abstract: .public Registry {} - {#artifacts (Row Artifact) - #resolver (Dictionary Text ID)} + (Record + {#artifacts (Row Artifact) + #resolver (Dictionary Text ID)}) (def: .public empty Registry @@ -120,7 +123,7 @@ (binary.row/64 category))] (|>> :representation (value@ #artifacts) - (row\map (value@ #category)) + (row\each (value@ #category)) artifacts))) (exception: .public (invalid_category {tag Nat}) @@ -134,7 +137,7 @@ [tag <binary>.nat] (case tag (^template [<nat> <tag> <parser>] - [<nat> (\ ! map (|>> <tag>) <parser>)]) + [<nat> (\ ! each (|>> <tag>) <parser>)]) ([0 #Anonymous <binary>.any] [1 #Definition <binary>.text] [2 #Analyser <binary>.text] @@ -145,21 +148,21 @@ _ (<>.failure (exception.error ..invalid_category [tag])))))] (|> (<binary>.row/64 category) - (\ <>.monad map (row\mix (function (_ artifact registry) - (product.right - (case artifact - #Anonymous - (..resource registry) - - (^template [<tag> <create>] - [(<tag> name) - (<create> name registry)]) - ([#Definition ..definition] - [#Analyser ..analyser] - [#Synthesizer ..synthesizer] - [#Generator ..generator] - [#Directive ..directive] - [#Custom ..custom]) - ))) - ..empty))))) + (\ <>.monad each (row\mix (function (_ artifact registry) + (product.right + (case artifact + #Anonymous + (..resource registry) + + (^template [<tag> <create>] + [(<tag> name) + (<create> name registry)]) + ([#Definition ..definition] + [#Analyser ..analyser] + [#Synthesizer ..synthesizer] + [#Generator ..generator] + [#Directive ..directive] + [#Custom ..custom]) + ))) + ..empty))))) ) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux index 59f1981bc..5a30c2c50 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux @@ -19,12 +19,13 @@ Text) (type: .public Descriptor - {#name Module - #file Path - #hash Nat - #state Module_State - #references (Set Module) - #registry Registry}) + (Record + {#name Module + #file Path + #hash Nat + #state Module_State + #references (Set Module) + #registry Registry})) (def: .public writer (Writer Descriptor) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux index a14d708d5..8858eefa3 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux @@ -28,8 +28,9 @@ (abstract: .public (Document d) {} - {#signature Signature - #content d} + (Record + {#signature Signature + #content d}) (def: .public (read key document) (All [d] (-> (Key d) (Document Any) (Try d))) @@ -70,5 +71,5 @@ (def: .public parser (All [d] (-> (Parser d) (Parser (Document d)))) (|>> (<>.and signature.parser) - (\ <>.monad map (|>> :abstraction)))) + (\ <>.monad each (|>> :abstraction)))) ) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux index 8b4dfedb8..ebe18755a 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux @@ -20,8 +20,9 @@ [version (#+ Version)]]) (type: .public Signature - {#name Name - #version Version}) + (Record + {#name Name + #version Version})) (def: .public equivalence (Equivalence Signature) 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 e2a3ef238..9796bdcfb 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux @@ -41,8 +41,9 @@ dictionary.keys) (type: Dependency - {#module Module - #imports Ancestry}) + (Record + {#module Module + #imports Ancestry})) (def: .public graph (-> (List Dependency) Graph) @@ -61,7 +62,7 @@ (#try.Failure error) ..fresh)] - ancestors (monad.map ! recur (set.list parents))] + ancestors (monad.each ! recur (set.list parents))] (in (list\mix set.union parents ancestors))))) ancestry (memo.open memo)] (list\mix (function (_ module memory) @@ -88,10 +89,10 @@ (|> ancestry dictionary.keys (list.sorted (..dependency? ancestry)) - (monad.map try.monad - (function (_ module) - (do try.monad - [module_id (archive.id module archive) - [descriptor document output] (archive.find module archive) - document (document.check key document)] - (in [module [module_id [descriptor document output]]]))))))) + (monad.each try.monad + (function (_ module) + (do try.monad + [module_id (archive.id module archive) + [descriptor document output] (archive.find module archive) + document (document.check key document)] + (in [module [module_id [descriptor document output]]]))))))) 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 45f489e8b..efb13c9e8 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -110,13 +110,13 @@ _ (ensure_directory fs (..versioned_lux_archive fs static))] (|> module (\ fs make_directory) - (\ ! map (|>> (case> (#try.Success output) - (#try.Success []) + (\ ! each (|>> (case> (#try.Success output) + (#try.Success []) - (#try.Failure error) - (exception.except ..cannot_prepare [(..archive fs static) - module_id - error]))))))))) + (#try.Failure error) + (exception.except ..cannot_prepare [(..archive fs static) + module_id + error]))))))))) (def: .public (write fs static module_id artifact_id content) (-> (file.System Async) Static archive.ID artifact.ID Binary (Async (Try Any))) @@ -168,12 +168,12 @@ (-> Target Archive (Try .Lux)) (do {! try.monad} [modules (: (Try (List [Module .Module])) - (monad.map ! (function (_ module) - (do ! - [[descriptor document output] (archive.find module archive) - content (document.read $.key document)] - (in [module content]))) - (archive.archived archive)))] + (monad.each ! (function (_ module) + (do ! + [[descriptor document output] (archive.find module archive) + content (document.read $.key document)] + (in [module content]))) + (archive.archived archive)))] (in (with@ #.modules modules (fresh_analysis_state host))))) (def: (cached_artifacts fs static module_id) @@ -181,15 +181,15 @@ (let [! (try.with async.monad)] (|> (..module fs static module_id) (\ fs directory_files) - (\ ! map (|>> (list\map (function (_ file) - [(file.name fs file) file])) - (list.only (|>> product.left (text\= ..module_descriptor_file) not)) - (monad.map ! (function (_ [name path]) - (|> path - (\ fs read) - (\ ! map (|>> [name]))))) - (\ ! map (dictionary.of_list text.hash)))) - (\ ! join)))) + (\ ! each (|>> (list\each (function (_ file) + [(file.name fs file) file])) + (list.only (|>> product.left (text\= ..module_descriptor_file) not)) + (monad.each ! (function (_ [name path]) + (|> path + (\ fs read) + (\ ! each (|>> [name]))))) + (\ ! each (dictionary.of_list text.hash)))) + (\ ! conjoint)))) (type: Definitions (Dictionary Text Any)) (type: Analysers (Dictionary Text analysis.Handler)) @@ -321,19 +321,19 @@ #.End (#try.Success [definitions bundles output]))))) content (document.read $.key document) - definitions (monad.map ! (function (_ [def_name def_global]) - (case def_global - (#.Alias alias) - (in [def_name (#.Alias alias)]) - - (#.Definition [exported? type annotations _]) - (|> definitions - (dictionary.value def_name) - try.of_maybe - (\ ! map (|>> [exported? type annotations] - #.Definition - [def_name]))))) - (value@ #.definitions content))] + definitions (monad.each ! (function (_ [def_name def_global]) + (case def_global + (#.Alias alias) + (in [def_name (#.Alias alias)]) + + (#.Definition [exported? type annotations _]) + (|> definitions + (dictionary.value def_name) + try.of_maybe + (\ ! each (|>> [exported? type annotations] + #.Definition + [def_name]))))) + (value@ #.definitions content))] (in [(document.write $.key (with@ #.definitions definitions content)) bundles]))) @@ -355,8 +355,8 @@ [.let [cache (..module fs static module_id)] _ (|> cache (\ fs directory_files) - (\ ! map (monad.map ! (\ fs delete))) - (\ ! join))] + (\ ! each (monad.each ! (\ fs delete))) + (\ ! conjoint))] (\ fs delete cache))) (def: (valid_cache? expected actual) @@ -409,37 +409,37 @@ (do {! (try.with async.monad)} [pre_loaded_caches (|> archive archive.reservations - (monad.map ! (function (_ [module_name module_id]) - (do ! - [data (..read_module_descriptor fs static module_id) - [descriptor document] (async\in (<binary>.result ..parser data))] - (if (text\= archive.runtime_module module_name) - (in [true - [module_name [module_id [descriptor document]]]]) - (do ! - [input (//context.read fs ..pseudo_module import contexts (value@ #static.host_module_extension static) module_name)] - (in [(..valid_cache? descriptor input) - [module_name [module_id [descriptor document]]]]))))))) + (monad.each ! (function (_ [module_name module_id]) + (do ! + [data (..read_module_descriptor fs static module_id) + [descriptor document] (async\in (<binary>.result ..parser data))] + (if (text\= archive.runtime_module module_name) + (in [true + [module_name [module_id [descriptor document]]]]) + (do ! + [input (//context.read fs ..pseudo_module import contexts (value@ #static.host_module_extension static) module_name)] + (in [(..valid_cache? descriptor input) + [module_name [module_id [descriptor document]]]]))))))) load_order (|> pre_loaded_caches - (list\map product.right) + (list\each product.right) (monad.mix try.monad (function (_ [module [module_id [descriptor document]]] archive) (archive.has module [descriptor document (: Output row.empty)] archive)) archive) - (\ try.monad map (dependency.load_order $.key)) - (\ try.monad join) + (\ try.monad each (dependency.load_order $.key)) + (\ try.monad conjoint) async\in) .let [purge (..full_purge pre_loaded_caches load_order)] _ (|> purge dictionary.entries - (monad.map ! (..purge! fs static))) + (monad.each ! (..purge! fs static))) loaded_caches (|> load_order (list.only (|>> product.left (dictionary.key? purge) not)) - (monad.map ! (function (_ [module_name [module_id [descriptor document _]]]) - (do ! - [[descriptor,document,output bundles] (..load_definitions fs static module_id host_environment descriptor document)] - (in [[module_name descriptor,document,output] - bundles])))))] + (monad.each ! (function (_ [module_name [module_id [descriptor document _]]]) + (do ! + [[descriptor,document,output bundles] (..load_definitions fs static module_id host_environment descriptor document)] + (in [[module_name descriptor,document,output] + bundles])))))] (async\in (do {! try.monad} [archive (monad.mix ! diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux index 74d5aab33..fe83f0fb3 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux @@ -83,14 +83,14 @@ (#try.Success path) (|> path (\ fs read) - (\ (try.with !) map (|>> [path]))) + (\ (try.with !) each (|>> [path]))) (#try.Failure _) (do {! (try.with !)} [path (..find_source_file fs importer contexts module ..lux_extension)] (|> path (\ fs read) - (\ ! map (|>> [path]))))))) + (\ ! each (|>> [path]))))))) (def: (find_library_source_file importer import partial_host_extension module) (-> Module Import Extension Module (Try [file.Path Binary])) @@ -145,18 +145,18 @@ (do {! (try.with async.monad)} [enumeration (|> directory (\ fs directory_files) - (\ ! map (monad.mix ! (function (_ file enumeration) - (if (text.ends_with? ..lux_extension file) - (do ! - [source_code (\ fs read file)] - (async\in (dictionary.has' (text.replaced context "" file) source_code enumeration))) - (in enumeration))) - enumeration)) - (\ ! join))] + (\ ! each (monad.mix ! (function (_ file enumeration) + (if (text.ends_with? ..lux_extension file) + (do ! + [source_code (\ fs read file)] + (async\in (dictionary.has' (text.replaced context "" file) source_code enumeration))) + (in enumeration))) + enumeration)) + (\ ! conjoint))] (|> directory (\ fs sub_directories) - (\ ! map (monad.mix ! (context_listing fs context) enumeration)) - (\ ! join)))) + (\ ! each (monad.mix ! (context_listing fs context) enumeration)) + (\ ! conjoint)))) (def: Action (type (All [a] (Async (Try a))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager.lux b/stdlib/source/library/lux/tool/compiler/meta/packager.lux index 744d0ecb9..f846a28a8 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager.lux @@ -33,10 +33,10 @@ (def: .public order (-> dependency.Order Order) - (list\map (function (_ [module [module_id [descriptor document]]]) - (|> descriptor - (value@ #descriptor.registry) - artifact.artifacts - row.list - (list\map (|>> (value@ #artifact.id))) - [module_id])))) + (list\each (function (_ [module [module_id [descriptor document]]]) + (|> descriptor + (value@ #descriptor.registry) + artifact.artifacts + row.list + (list\each (|>> (value@ #artifact.id))) + [module_id])))) 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 ffee37de6..832c6f8f6 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -141,7 +141,7 @@ (-> Static archive.ID artifact.ID (Maybe Text) Binary java/util/jar/JarOutputStream (Try java/util/jar/JarOutputStream)) (let [class_path (|> custom - (maybe\map (|>> name.internal name.read)) + (maybe\each (|>> name.internal name.read)) (maybe.else (runtime.class_name [module artifact])) (text.suffix (value@ #static.artifact_extension static)))] (do try.monad @@ -249,8 +249,8 @@ [order (dependency.load_order $.key archive) .let [buffer (java/io/ByteArrayOutputStream::new (.int ..mebi_byte))] sink (|> order - (list\map (function (_ [module [module_id [descriptor document output]]]) - [module_id output])) + (list\each (function (_ [module [module_id [descriptor document output]]]) + [module_id output])) (monad.mix ! (..write_module static) (java/util/jar/JarOutputStream::new buffer (..manifest program)))) [entries duplicates sink] (|> host_dependencies 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 f888e6975..c1fdd9d5d 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux @@ -57,12 +57,12 @@ (def: bundle_module (-> Output (Try _.Expression)) (|>> row.list - (list\map product.right) + (list\each product.right) (monad.mix try.monad (function (_ content so_far) (|> content (\ encoding.utf8 decoded) - (\ try.monad map + (\ try.monad each (|>> :expected (:sharing [directive] directive @@ -107,7 +107,7 @@ (value@ #descriptor.references) set.list (list.all (function (_ module) (dictionary.value module mapping))) - (list\map (|>> ..module_file _.string _.load_relative/1)) + (list\each (|>> ..module_file _.string _.load_relative/1)) (list\mix ..then bundle) (: _.Expression) _.code @@ -122,11 +122,11 @@ (do {! try.monad} [order (dependency.load_order $.key archive) .let [mapping (|> order - (list\map (function (_ [module [module_id [descriptor document output]]]) - [module module_id])) + (list\each (function (_ [module [module_id [descriptor document output]]]) + [module module_id])) (dictionary.of_list text.hash) (: (Dictionary Module archive.ID)))] - entries (monad.map ! (..write_module now mapping) order)] + entries (monad.each ! (..write_module now mapping) order)] (in (|> entries row.of_list (binary.result tar.writer)))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux index 9b49232e3..0beeffa1c 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux @@ -39,12 +39,12 @@ (Try directive))) (|> output row.list - (list\map (|>> product.right product.right)) + (list\each (|>> product.right product.right)) (monad.mix try.monad (function (_ content so_far) (|> content (\ utf8.codec decoded) - (\ try.monad map + (\ try.monad each (|>> :expected (:sharing [directive] directive @@ -65,7 +65,7 @@ (do {! try.monad} [order (dependency.load_order $.key archive)] (|> order - (list\map (function (_ [module [module_id [descriptor document output]]]) - [module_id output])) + (list\each (function (_ [module [module_id [descriptor document output]]]) + [module_id output])) (monad.mix ! (..write_module sequence) header) - (\ ! map (|>> scope code (\ utf8.codec encoded))))))) + (\ ! each (|>> scope code (\ utf8.codec encoded))))))) diff --git a/stdlib/source/library/lux/tool/compiler/phase.lux b/stdlib/source/library/lux/tool/compiler/phase.lux index 7e137387e..22362318a 100644 --- a/stdlib/source/library/lux/tool/compiler/phase.lux +++ b/stdlib/source/library/lux/tool/compiler/phase.lux @@ -47,7 +47,7 @@ (-> s (Operation s o) (Try o))) (|> state operation - (\ try.monad map product.right))) + (\ try.monad each product.right))) (def: .public get_state (All [s o] @@ -82,7 +82,7 @@ (def: .public (lifted error) (All [s a] (-> (Try a) (Operation s a))) (function (_ state) - (try\map (|>> [state]) error))) + (try\each (|>> [state]) error))) (syntax: .public (assertion [exception <code>.any message <code>.any diff --git a/stdlib/source/library/lux/tool/compiler/reference.lux b/stdlib/source/library/lux/tool/compiler/reference.lux index e8714bb2a..c90aa41f6 100644 --- a/stdlib/source/library/lux/tool/compiler/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/reference.lux @@ -20,8 +20,9 @@ Name) (type: .public Reference - (#Variable Variable) - (#Constant Constant)) + (Variant + (#Variable Variable) + (#Constant Constant))) (implementation: .public equivalence (Equivalence Reference) diff --git a/stdlib/source/library/lux/tool/compiler/reference/variable.lux b/stdlib/source/library/lux/tool/compiler/reference/variable.lux index c45c5239b..0c0eaad22 100644 --- a/stdlib/source/library/lux/tool/compiler/reference/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/reference/variable.lux @@ -18,8 +18,9 @@ Nat) (type: .public Variable - (#Local Register) - (#Foreign Register)) + (Variant + (#Local Register) + (#Foreign Register))) (implementation: .public equivalence (Equivalence Variable) diff --git a/stdlib/source/library/lux/tool/interpreter.lux b/stdlib/source/library/lux/tool/interpreter.lux index ee02eacc9..c26e9b789 100644 --- a/stdlib/source/library/lux/tool/interpreter.lux +++ b/stdlib/source/library/lux/tool/interpreter.lux @@ -162,9 +162,10 @@ codeV)))) (type: (Context anchor expression directive) - {#configuration Configuration - #state (State+ anchor expression directive) - #source Source}) + (Record + {#configuration Configuration + #state (State+ anchor expression directive) + #source Source})) (with_expansions [<Context> (as_is (Context anchor expression directive))] (def: (read_eval_print context) diff --git a/stdlib/source/library/lux/tool/mediator.lux b/stdlib/source/library/lux/tool/mediator.lux index 9357999f4..f46d2f486 100644 --- a/stdlib/source/library/lux/tool/mediator.lux +++ b/stdlib/source/library/lux/tool/mediator.lux @@ -3,14 +3,15 @@ [lux (#- Source Module) [world ["." binary (#+ Binary)] - ["." file (#+ File)]]]] + ["." file (#+ Path)]]]] [// [compiler (#+ Compiler) [meta ["." archive (#+ Archive) [descriptor (#+ Module)]]]]]) -(type: .public Source File) +(type: .public Source + Path) (type: .public (Mediator !) (-> Archive Module (! Archive))) diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index e1e42c28c..fb2baf861 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -62,7 +62,7 @@ (case type (#.Apply arg func') (let [[func args] (flat_application func')] - [func (list\compose args (list arg))]) + [func (list\composite args (list arg))]) _ [type (list)])) @@ -87,57 +87,57 @@ (-> Type Text) (case type (#.Primitive name params) - ($_ text\compose + ($_ text\composite "(primitive " (text.enclosed' text.double_quote name) (|> params - (list\map (|>> format (text\compose " "))) - (list\mix (function.flipped text\compose) "")) + (list\each (|>> format (text\composite " "))) + (list\mix (function.flipped text\composite) "")) ")") (^template [<tag> <open> <close> <flat>] [(<tag> _) - ($_ text\compose <open> + ($_ text\composite <open> (|> (<flat> type) - (list\map format) + (list\each format) list.reversed (list.interposed " ") - (list\mix text\compose "")) + (list\mix text\composite "")) <close>)]) ([#.Sum "(Or " ")" flat_variant] [#.Product "[" "]" flat_tuple]) (#.Function input output) (let [[ins out] (flat_function type)] - ($_ text\compose "(-> " + ($_ text\composite "(-> " (|> ins - (list\map format) + (list\each format) list.reversed (list.interposed " ") - (list\mix text\compose "")) + (list\mix text\composite "")) " " (format out) ")")) (#.Parameter idx) (n\encoded idx) (#.Var id) - ($_ text\compose "⌈v:" (n\encoded id) "⌋") + ($_ text\composite "⌈v:" (n\encoded id) "⌋") (#.Ex id) - ($_ text\compose "⟨e:" (n\encoded id) "⟩") + ($_ text\composite "⟨e:" (n\encoded id) "⟩") (#.Apply param fun) (let [[type_func type_args] (flat_application type)] - ($_ text\compose "(" (format type_func) " " (|> type_args (list\map format) list.reversed (list.interposed " ") (list\mix text\compose "")) ")")) + ($_ text\composite "(" (format type_func) " " (|> type_args (list\each format) list.reversed (list.interposed " ") (list\mix text\composite "")) ")")) (^template [<tag> <desc>] [(<tag> env body) - ($_ text\compose "(" <desc> " {" (|> env (list\map format) (text.interposed " ")) "} " (format body) ")")]) + ($_ text\composite "(" <desc> " {" (|> env (list\each format) (text.interposed " ")) "} " (format body) ")")]) ([#.UnivQ "All"] [#.ExQ "Ex"]) (#.Named [module name] type) - ($_ text\compose module "." name) + ($_ text\composite module "." name) )) ... https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction @@ -145,7 +145,7 @@ (-> (List Type) Type Type) (case type (#.Primitive name params) - (#.Primitive name (list\map (reduced env) params)) + (#.Primitive name (list\each (reduced env) params)) (^template [<tag>] [(<tag> left right) @@ -160,21 +160,21 @@ (<tag> env def) _ - (<tag> (list\map (reduced env) old_env) def))]) + (<tag> (list\each (reduced env) old_env) def))]) ([#.UnivQ] [#.ExQ]) (#.Parameter idx) - (maybe.else (panic! ($_ text\compose + (maybe.else (panic! ($_ text\composite "Unknown type parameter" text.new_line " Index: " (n\encoded idx) text.new_line "Environment: " (|> env list.enumeration - (list\map (.function (_ [index type]) - ($_ text\compose - (n\encoded index) - " " (..format type)))) - (text.interposed (text\compose text.new_line " "))))) + (list\each (.function (_ [index type]) + ($_ text\composite + (n\encoded index) + " " (..format type)))) + (text.interposed (text\composite text.new_line " "))))) (list.item idx env)) _ @@ -258,7 +258,7 @@ (case type (#.Primitive name params) (` (#.Primitive (~ (code.text name)) - (.list (~+ (list\map code params))))) + (.list (~+ (list\each code params))))) (^template [<tag>] [(<tag> idx) @@ -276,7 +276,7 @@ (^template [<tag>] [(<tag> env body) - (` (<tag> (.list (~+ (list\map code env))) + (` (<tag> (.list (~+ (list\each code env))) (~ (code body))))]) ([#.UnivQ] [#.ExQ]) )) @@ -360,7 +360,7 @@ (#.Apply A F) (|> (..applied (list A) F) - (\ maybe.monad map quantified?) + (\ maybe.monad each quantified?) (maybe.else #0)) (^or (#.UnivQ _) (#.ExQ _)) @@ -420,7 +420,7 @@ [location meta.location valueT (meta.type valueN) .let [_ ("lux io log" - ($_ text\compose + ($_ text\composite (name\encoded (name_of ..:log!)) " " (location.format location) text.new_line "Expression: " (case valueC (#.Some valueC) @@ -454,7 +454,7 @@ (: (Foo Bit [Nat Text]) (foo expression)))) "NOTE: Careless use of type-casts is an easy way to introduce bugs. USE WITH CAUTION.")} - (let [casterC (` (: (All [(~+ (list\map code.local_identifier type_vars))] + (let [casterC (` (: (All [(~+ (list\each code.local_identifier type_vars))] (-> (~ input) (~ output))) (|>> :expected)))] (case value @@ -465,8 +465,9 @@ (in (list (` ((~ casterC) (~ value)))))))) (type: Typed - {#type Code - #expression Code}) + (Record + {#type Code + #expression Code})) (def: typed (Parser Typed) @@ -486,7 +487,7 @@ (Bar a b c) (bar expression))))} (macro.with_identifiers [g!_] - (let [shareC (` (: (All [(~+ (list\map code.local_identifier type_vars))] + (let [shareC (` (: (All [(~+ (list\each code.local_identifier type_vars))] (-> (~ (value@ #type exemplar)) (~ (value@ #type computation)))) (.function ((~ g!_) (~ g!_)) @@ -507,7 +508,7 @@ "=>" (.type (Bar Bit Nat Text)))} (in (list (` (:of ((~! :sharing) - [(~+ (list\map code.local_identifier type_vars))] + [(~+ (list\each code.local_identifier type_vars))] (~ (value@ #type exemplar)) (~ (value@ #expression exemplar)) diff --git a/stdlib/source/library/lux/type/abstract.lux b/stdlib/source/library/lux/type/abstract.lux index 57d9ae3ab..4e9e07045 100644 --- a/stdlib/source/library/lux/type/abstract.lux +++ b/stdlib/source/library/lux/type/abstract.lux @@ -35,11 +35,11 @@ list.tail) (type: .public Frame - {#.doc (example "Meta-data about an abstract/nominal type in a stack of them.")} - {#name Text - #type_vars (List Code) - #abstraction Code - #representation Code}) + (Record + {#name Text + #type_vars (List Code) + #abstraction Code + #representation Code})) (def: frames (Stack Frame) @@ -93,12 +93,10 @@ (exception.except ..no_active_frames []))))) (def: .public current - {#.doc (example "The currently-being-defined abstract/nominal type.")} (Meta Frame) (..peek! #.None)) (def: .public (specific name) - {#.doc (example "A specific abstract/nominal type still being defined somewhere in the scope.")} (-> Text (Meta Frame)) (..peek! (#.Some name))) @@ -179,10 +177,6 @@ (template [<name> <from> <to>] [(syntax: .public (<name> [[frame value] ..cast]) - {#.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 (` ((~! //.:as) [(~+ type_vars)] (~ <from>) (~ <to>) @@ -195,13 +189,13 @@ (def: abstraction_type_name (-> Name Text) (|>> name\encoded - ($_ text\compose + ($_ text\composite (name\encoded (name_of #..Abstraction)) " "))) (def: representation_definition_name (-> Text Text) - (|>> ($_ text\compose + (|>> ($_ text\composite (name\encoded (name_of #..Representation)) " "))) @@ -228,87 +222,9 @@ ... (This applies to uses of ":abstraction" and ":representation") (syntax: .public (abstract: [[export_policy [name type_vars] annotations representation_type primitives] ..abstract]) - {#.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 - - (def: (string value) - (-> Text String) - (:abstraction value)) - - (def: (text value) - (-> String Text) - (:representation value))) - - "Type-parameters are optional." - (abstract: (Duplicate a) - {} - - [a a] - - (def: (duplicate value) - (All [a] (-> a (Duplicate a))) - (:abstraction [value value]))) - - "Definitions can be nested." - (abstract: (Single a) - {} - - a - - (def: (single value) - (All [a] (-> a (Single a))) - (:abstraction value)) - - (abstract: (Double a) - {} - - [a a] - - (def: (double value) - (All [a] (-> a (Double a))) - (:abstraction [value value])) - - (def: (single' value) - (All [a] (-> a (Single a))) - (:abstraction Single [value value])) - - (let [value 0123] - (same? 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) - {} - - Text - - (abstract: Expression {} Any) - (abstract: Statement {} Any) - - (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) - "}")))) - )} (do meta.monad [current_module meta.current_module_name - .let [type_varsC (list\map code.local_identifier type_vars) + .let [type_varsC (list\each code.local_identifier type_vars) abstraction_declaration (` ((~ (code.local_identifier name)) (~+ type_varsC))) representation_declaration (` ((~ (code.local_identifier (representation_definition_name name))) (~+ type_varsC)))] @@ -322,13 +238,14 @@ [(~+ type_varsC)]))) (` (type: (~ representation_declaration) (~ representation_type))) - ($_ list\compose + ($_ list\composite primitives (list (` ((~! ..pop!))))))))) (type: (Selection a) - (#Specific Code a) - (#Current a)) + (Variant + (#Specific Code a) + (#Current a))) (def: (selection parser) (All [a] (-> (Parser a) (Parser (Selection a)))) @@ -336,22 +253,6 @@ parser)) (syntax: .public (:transmutation [selection (..selection <code>.any)]) - {#.doc (example "Transmutes an abstract/nominal type's phantom types." - (abstract: (JavaScript a) - {} - - Text - - (abstract: Expression {} Any) - (abstract: Statement {} Any) - - (def: (statement expression) - (-> (JavaScript Expression) (JavaScript Statement)) - (:transmutation expression)) - - (def: (statement' expression) - (-> (JavaScript Expression) (JavaScript Statement)) - (:transmutation JavaScript expression))))} (case selection (#Specific specific value) (in (list (` (.|> (~ value) @@ -364,11 +265,6 @@ (syntax: .public (^:representation [selection (<code>.form (..selection <code>.local_identifier)) body <code>.any branches (<>.some <code>.any)]) - {#.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 3e6f6a8c4..2d57a12d7 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -1,5 +1,4 @@ (.module: - {#.doc "Type-checking functionality."} [library [lux #* ["@" target] @@ -53,14 +52,12 @@ ["Actual" (//.format actual)])) (type: .public Var - {#.doc (example "The ID for a type-variable in a type-checking context.")} Nat) (type: Assumption [Type Type]) (type: .public (Check a) - {#.doc (example "A type-checking computation which may fail or yield a value.")} (-> Type_Context (Try [Type_Context a]))) (type: (Checker a) @@ -72,7 +69,7 @@ (implementation: .public functor (Functor Check) - (def: (map f fa) + (def: (each f fa) (function (_ context) (case (fa context) (#try.Success [context' output]) @@ -111,7 +108,7 @@ (function (_ context) (#try.Success [context x]))) - (def: (join ffa) + (def: (conjoint ffa) (function (_ context) (case (ffa context) (#try.Success [context' fa]) @@ -185,7 +182,6 @@ (..failure (exception.error exception message))) (def: .public existential - {#.doc "A brand-new existential type."} (Check [Nat Type]) (function (_ context) (let [id (value@ #.ex_counter context)] @@ -236,8 +232,6 @@ (exception.except ..unknown_type_var id)))) (def: .public (bind type id) - {#.doc (example "Attemmpts to buy a type-variable." - "Fails if the variable has been bound already.")} (-> Type Var (Check Any)) (function (_ context) (case (|> context (value@ #.var_bindings) (var::get id)) @@ -263,7 +257,6 @@ (exception.except ..unknown_type_var id)))) (def: .public var - {#.doc (example "A brand-new (unbound) type-variable.")} (Check [Var Type]) (function (_ context) (let [id (value@ #.var_counter context)] @@ -329,7 +322,6 @@ (exception.except ..unknown_type_var current))))) (def: .public fresh_context - {#.doc (example "An empty/un-used type-checking context.")} Type_Context {#.var_counter 0 #.ex_counter 0 @@ -374,7 +366,7 @@ (do {! ..monad} [ring (..ring id) _ (..assertion "" (n.> 1 (set.size ring))) - _ (monad.map ! (re_bind type) (set.list ring))] + _ (monad.each ! (re_bind type) (set.list ring))] then) (do ..monad [?bound (read' id)] @@ -453,7 +445,7 @@ [<pattern> (do ! [ring (..ring <id>) - _ (monad.map ! (re_bind <type>) (set.list ring))] + _ (monad.each ! (re_bind <type>) (set.list ring))] (in assumptions))]) ([[(#.Var _) _] idE atype] [[_ (#.Var _)] idA etype]) @@ -639,8 +631,8 @@ ..silent_failure!)) ..silent_failure!) - (^template [<compose>] - [[(<compose> eL eR) (<compose> aL aR)] + (^template [<composite>] + [[(<composite> eL eR) (<composite> aL aR)] (do ..monad [assumptions (check' assumptions eL aL)] (check' assumptions eR aR))]) @@ -667,12 +659,10 @@ ..silent_failure!)))) (def: .public (check expected actual) - {#.doc "Type-check to ensure that the 'expected' type subsumes the 'actual' type."} (-> Type Type (Check Any)) (check' (list) expected actual)) (def: .public (subsumes? expected actual) - {#.doc "A simple type-checking function that just returns a yes/no answer."} (-> Type Type Bit) (case (..result ..fresh_context (..check' (list) expected actual)) (#try.Failure _) @@ -682,19 +672,17 @@ true)) (def: .public 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 (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+) (|> paramsT+ - (monad.map ..monad clean) - (check\map (|>> (#.Primitive name)))) + (monad.each ..monad clean) + (check\each (|>> (#.Primitive name)))) (^or (#.Parameter _) (#.Ex _) (#.Named _)) (check\in inputT) @@ -704,7 +692,7 @@ (do ..monad [leftT' (clean leftT)] (|> (clean rightT) - (check\map (|>> (<tag> leftT')))))]) + (check\each (|>> (<tag> leftT')))))]) ([#.Sum] [#.Product] [#.Function] [#.Apply]) (#.Var id) @@ -720,7 +708,7 @@ (^template [<tag>] [(<tag> envT+ unquantifiedT) (do {! ..monad} - [envT+' (monad.map ! clean envT+)] + [envT+' (monad.each ! clean envT+)] (in (<tag> envT+' unquantifiedT)))]) ([#.UnivQ] [#.ExQ]) )) diff --git a/stdlib/source/library/lux/type/dynamic.lux b/stdlib/source/library/lux/type/dynamic.lux index f2f28fdf2..19898da65 100644 --- a/stdlib/source/library/lux/type/dynamic.lux +++ b/stdlib/source/library/lux/type/dynamic.lux @@ -21,7 +21,7 @@ ["Actual" (%.type actual)])) (abstract: .public Dynamic - {#.doc "A value coupled with its type, so it can be checked later."} + {} [Type Any] @@ -34,16 +34,12 @@ (|>> :representation)) (syntax: .public (:dynamic [value <code>.any]) - {#.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 <code>.any value <code>.any]) - {#.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)) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index 8af389efc..faaa608b2 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -93,8 +93,8 @@ (do {! meta.monad} [this_module_name meta.current_module_name imp_mods (meta.imported_modules this_module_name) - tag_lists (monad.map ! meta.tag_lists imp_mods) - .let [tag_lists (|> tag_lists list\join (list\map product.left) list\join) + tag_lists (monad.each ! meta.tag_lists imp_mods) + .let [tag_lists (|> tag_lists list\conjoint (list\each product.left) list\conjoint) candidates (list.only (|>> product.right (text\= simple_name)) tag_lists)]] (case candidates @@ -136,10 +136,10 @@ (try.else table (dictionary.has' name type table))) (: (Dictionary Text Type) (dictionary.empty text.hash)) - (list\join local_batches))]] + (list\conjoint local_batches))]] (in (|> total_locals dictionary.entries - (list\map (function (_ [name type]) [["" name] type])))))) + (list\each (function (_ [name type]) [["" name] type])))))) (def: local_structs (Meta (List [Name Type])) @@ -153,7 +153,7 @@ (do {! meta.monad} [this_module_name meta.current_module_name imported_modules (meta.imported_modules this_module_name) - accessible_definitions (monad.map ! meta.definitions imported_modules)] + accessible_definitions (monad.each ! meta.definitions imported_modules)] (in (list\mix (function (_ [imported_module definitions] tail) (available_definitions imported_module this_module_name definitions tail)) #.End @@ -201,8 +201,9 @@ (check.check expected_output actual_output))) (type: #rec Instance - {#constructor Name - #dependencies (List Instance)}) + (Record + {#constructor Name + #dependencies (List Instance)})) (def: (candidate_provision provision context dep alts) (-> (-> Lux Type_Context Type (Check Instance)) @@ -211,21 +212,21 @@ (do meta.monad [compiler meta.compiler_state] (case (|> alts - (list\map (function (_ [alt_name alt_type]) - (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) - - (#.Right =deps) - (list [alt_name =deps])))) - list\join) + (list\each (function (_ [alt_name alt_type]) + (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.each ! (provision compiler context') deps)] + (in =deps))) + (#.Left error) + (list) + + (#.Right =deps) + (list [alt_name =deps])))) + list\conjoint) #.End (meta.failure (format "No candidates for provisioning: " (%.type dep))) @@ -260,23 +261,23 @@ [compiler meta.compiler_state context meta.type_context] (case (|> alts - (list\map (function (_ [alt_name alt_type]) - (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 alt_type sig_type) - member_type (member_type member_idx alt_type) - _ (ensure_function_application! member_type input_types output_type) - context' check.context - =deps (monad.map ! (provision compiler context') deps)] - (in =deps))) - (#.Left error) - (list) - - (#.Right =deps) - (list [alt_name =deps])))) - list\join) + (list\each (function (_ [alt_name alt_type]) + (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 alt_type sig_type) + member_type (member_type member_idx alt_type) + _ (ensure_function_application! member_type input_types output_type) + context' check.context + =deps (monad.each ! (provision compiler context') deps)] + (in =deps))) + (#.Left error) + (list) + + (#.Right =deps) + (list [alt_name =deps])))) + list\conjoint) #.End (meta.failure (format "No alternatives for " (%.type (type.function input_types output_type)))) @@ -311,39 +312,16 @@ (code.identifier constructor) _ - (` ((~ (code.identifier constructor)) (~+ (list\map instance$ dependencies)))))) + (` ((~ (code.identifier constructor)) (~+ (list\each instance$ dependencies)))))) (syntax: .public (\\ [member <code>.identifier args (<>.or (<>.and (<>.some <code>.identifier) <code>.end!) (<>.and (<>.some <code>.any) <code>.end!))]) - {#.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 ++ (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} [[member_idx sig_type] (..implicit_member member) - input_types (monad.map ! ..implicit_type args) + input_types (monad.each ! ..implicit_type args) output_type meta.expected_type chosen_ones (alternatives sig_type member_idx input_types output_type)] (case chosen_ones @@ -353,19 +331,19 @@ (#.Item chosen #.End) (in (list (` (\ (~ (instance$ chosen)) (~ (code.local_identifier (product.right member))) - (~+ (list\map code.identifier args)))))) + (~+ (list\each code.identifier args)))))) _ (meta.failure (format "Too many implementations available: " (|> chosen_ones - (list\map (|>> product.left %.name)) + (list\each (|>> product.left %.name)) (text.interposed ", ")) " --- for type: " (%.type sig_type))))) (#.Right [args _]) (do {! meta.monad} [labels (|> (macro.identifier "") (list.repeated (list.size args)) (monad.all !))] - (in (list (` (let [(~+ (|> args (list.zipped/2 labels) (list\map ..pair_list) list\join))] + (in (list (` (let [(~+ (|> args (list.zipped/2 labels) (list\each ..pair_list) list\conjoint))] (..\\ (~ (code.identifier member)) (~+ labels))))))) )) @@ -381,28 +359,19 @@ (syntax: .public (with [implementations ..implicits body <code>.any]) - {#.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) - (list\map (function (_ [g!implicit implementation]) - (list g!implicit implementation))) - list\join))] + (list\each (function (_ [g!implicit implementation]) + (list g!implicit implementation))) + list\conjoint))] (~ body))))))) (syntax: .public (implicit: [implementations ..implicits]) - {#.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) - (list\map (function (_ [g!implicit implementation]) - (` (def: .private (~ g!implicit) - {#.implementation? #1} - (~ implementation))))))))) + (list\each (function (_ [g!implicit implementation]) + (` (def: .private (~ g!implicit) + {#.implementation? #1} + (~ implementation))))))))) diff --git a/stdlib/source/library/lux/type/poly.lux b/stdlib/source/library/lux/type/poly.lux index 8fba22756..def324897 100644 --- a/stdlib/source/library/lux/type/poly.lux +++ b/stdlib/source/library/lux/type/poly.lux @@ -59,13 +59,13 @@ (syntax: .public (derived: [[export_policy name [poly_func poly_args] ?custom_impl] ..derivedP]) (do {! meta.monad} - [poly_args (monad.map ! meta.normal poly_args) + [poly_args (monad.each ! meta.normal poly_args) .let [impl (case ?custom_impl (#.Some custom_impl) custom_impl #.None - (` ((~ (code.identifier poly_func)) (~+ (list\map code.identifier poly_args)))))]] + (` ((~ (code.identifier poly_func)) (~+ (list\each code.identifier poly_args)))))]] (in (.list (` (def: (~ export_policy) (~ (code.identifier ["" name])) {#.implementation? #1} (~ impl))))))) @@ -75,7 +75,7 @@ (`` (case type (#.Primitive name params) (` (#.Primitive (~ (code.text name)) - (.list (~+ (list\map (code env) params))))) + (.list (~+ (list\each (code env) params))))) (^template [<tag>] [(<tag> idx) @@ -102,8 +102,8 @@ (^template [<macro> <tag> <flattener>] [(<tag> left right) - (` (<macro> (~+ (list\map (code env) (<flattener> type)))))]) - ([.Variant #.Sum type.flat_variant] + (` (<macro> (~+ (list\each (code env) (<flattener> type)))))]) + ([.Union #.Sum type.flat_variant] [.Tuple #.Product type.flat_tuple]) (#.Named name sub_type) @@ -111,7 +111,7 @@ (^template [<tag>] [(<tag> scope body) - (` (<tag> (.list (~+ (list\map (code env) scope))) + (` (<tag> (.list (~+ (list\each (code env) scope))) (~ (code env body))))]) ([#.UnivQ] [#.ExQ]) ))) diff --git a/stdlib/source/library/lux/type/quotient.lux b/stdlib/source/library/lux/type/quotient.lux index 6334d68f3..be7663444 100644 --- a/stdlib/source/library/lux/type/quotient.lux +++ b/stdlib/source/library/lux/type/quotient.lux @@ -27,8 +27,9 @@ "All equivalent values will belong to the same class." "This means all equivalent values possess the same label.")} - {#value t - #label c} + (Record + {#value t + #label c}) (def: .public (quotient class value) (All [t c %] diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux index 7bb718659..2ab800d2c 100644 --- a/stdlib/source/library/lux/type/refinement.lux +++ b/stdlib/source/library/lux/type/refinement.lux @@ -14,8 +14,9 @@ (abstract: .public (Refined t %) {#.doc "A refined version of another type, using a predicate to select valid instances."} - {#value t - #predicate (Predicate t)} + (Record + {#value t + #predicate (Predicate t)}) (type: .public (Refiner t %) {#.doc (example "A selection mechanism for refined instances of a type.")} diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux index 3e37d8b30..796bf4e4d 100644 --- a/stdlib/source/library/lux/type/resource.lux +++ b/stdlib/source/library/lux/type/resource.lux @@ -176,8 +176,8 @@ swaps) maybe.trusted row.list) - g!inputsT+ (list\map (|>> (~) (..Key ..Commutative) (`)) g!inputs) - g!outputsT+ (list\map (|>> (~) (..Key ..Commutative) (`)) g!outputs)]] + g!inputsT+ (list\each (|>> (~) (..Key ..Commutative) (`)) g!inputs) + g!outputsT+ (list\each (|>> (~) (..Key ..Commutative) (`)) g!outputs)]] (in (list (` (: (All [(~ g!!) (~+ g!inputs) (~ g!context)] (-> ((~! monad.Monad) (~ g!!)) (Procedure (~ g!!) diff --git a/stdlib/source/library/lux/world/console.lux b/stdlib/source/library/lux/world/console.lux index 80e8eaebb..4f52cacb1 100644 --- a/stdlib/source/library/lux/world/console.lux +++ b/stdlib/source/library/lux/world/console.lux @@ -86,7 +86,7 @@ (def: (read _) (|> jvm_input java/io/InputStream::read - (\ (try.with io.monad) map .nat))) + (\ (try.with io.monad) each .nat))) (def: (read_line _) (java/io/Console::readLine jvm_console)) diff --git a/stdlib/source/library/lux/world/db/jdbc.lux b/stdlib/source/library/lux/world/db/jdbc.lux index 76c1cc17b..f2ca6ee00 100644 --- a/stdlib/source/library/lux/world/db/jdbc.lux +++ b/stdlib/source/library/lux/world/db/jdbc.lux @@ -51,16 +51,19 @@ (#static getConnection [java/lang/String java/lang/String java/lang/String] #io #try java/sql/Connection)) (type: .public Credentials - {#url URL - #user Text - #password Text}) + (Record + {#url URL + #user Text + #password Text})) -(type: .public ID Int) +(type: .public ID + Int) (type: .public (Statement input) - {#sql sql.Statement - #input (Input input) - #value input}) + (Record + {#sql sql.Statement + #input (Input input) + #value input})) (template [<name> <forge> <output>] [(capability: .public (<name> ! i) diff --git a/stdlib/source/library/lux/world/db/jdbc/input.lux b/stdlib/source/library/lux/world/db/jdbc/input.lux index 4a2f43507..e9035aded 100644 --- a/stdlib/source/library/lux/world/db/jdbc/input.lux +++ b/stdlib/source/library/lux/world/db/jdbc/input.lux @@ -47,8 +47,10 @@ (-> a [Nat java/sql/PreparedStatement] (Try [Nat java/sql/PreparedStatement]))) -(implementation: .public contravariant (Contravariant Input) - (def: (map-1 f fb) +(implementation: .public contravariant + (Contravariant Input) + + (def: (each f fb) (function (fa value circumstance) (fb (f value) circumstance)))) diff --git a/stdlib/source/library/lux/world/db/jdbc/output.lux b/stdlib/source/library/lux/world/db/jdbc/output.lux index e6e9a8306..933830e1e 100644 --- a/stdlib/source/library/lux/world/db/jdbc/output.lux +++ b/stdlib/source/library/lux/world/db/jdbc/output.lux @@ -53,7 +53,7 @@ (implementation: .public functor (Functor Output) - (def: (map f fa) + (def: (each f fa) (function (_ idx+rs) (case (fa idx+rs) (#try.Failure error) @@ -90,7 +90,7 @@ (function (_ [idx rs]) (#.Some [idx a]))) - (def: (join mma) + (def: (conjoint mma) (function (_ [idx rs]) (case (mma [idx rs]) (#try.Failure error) diff --git a/stdlib/source/library/lux/world/db/sql.lux b/stdlib/source/library/lux/world/db/sql.lux index a3b7aff6a..6b01531bc 100644 --- a/stdlib/source/library/lux/world/db/sql.lux +++ b/stdlib/source/library/lux/world/db/sql.lux @@ -55,7 +55,8 @@ [(Statement' kind)] ) -(type: .public Alias Text) +(type: .public Alias + Text) (def: .public no_alias Alias "") @@ -64,7 +65,8 @@ ... SQL (template [<declaration> <kind>] - [(type: .public <declaration> (SQL <kind>))] + [(type: .public <declaration> + (SQL <kind>))] [Literal (Value' Literal')] [Column (Value' Column')] @@ -108,7 +110,7 @@ (def: listing (-> (List (SQL Any)) Text) - (|>> (list\map (|>> :representation)) + (|>> (list\each (|>> :representation)) (text.interposed ", "))) ... Value @@ -215,10 +217,10 @@ _ (|> columns - (list\map (.function (_ [column alias]) - (if (text\= ..no_alias alias) - (:representation column) - (format (:representation column) " AS " alias)))) + (list\each (.function (_ [column alias]) + (if (text\= ..no_alias alias) + (:representation column) + (format (:representation column) " AS " alias)))) (text.interposed ", "))) " FROM " (:representation source))))] @@ -296,8 +298,8 @@ (format (:representation query) " ORDER BY " (|> pairs - (list\map (.function (_ [value order]) - (format (:representation value) " " (:representation order)))) + (list\each (.function (_ [value order]) + (format (:representation value) " " (:representation order)))) (text.interposed ", ")))))) (def: .public (group_by pairs query) @@ -323,7 +325,7 @@ (..parenthesize (..listing columns)) " VALUES " (|> rows - (list\map (|>> ..listing ..parenthesize)) + (list\each (|>> ..listing ..parenthesize)) (text.interposed ", ")) ))) @@ -336,8 +338,8 @@ _ (format " SET " (|> pairs - (list\map (.function (_ [column value]) - (format (:representation column) "=" (:representation value)))) + (list\each (.function (_ [column value]) + (format (:representation column) "=" (:representation value)))) (text.interposed ", "))))))) (def: .public delete diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 2a8dd0951..08bffdb97 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -97,14 +97,14 @@ (All [!] (-> (System !) Path (Maybe Path))) (|> path (..un_rooted fs) - (maybe\map product.left))) + (maybe\each 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) - (maybe\map product.right) + (maybe\each product.right) (maybe.else path))) (def: .public (async fs) @@ -218,7 +218,7 @@ [(def: <name> (|>> java/io/File::new <method> - (io\map (|>> (try.else false)))))] + (io\each (|>> (try.else false)))))] [file? java/io/File::isFile] [directory? java/io/File::isDirectory] @@ -238,8 +238,8 @@ (|> children array.list (monad.only ! (|>> <method>)) - (\ ! map (monad.map ! (|>> java/io/File::getAbsolutePath))) - (\ ! join)) + (\ ! each (monad.each ! (|>> java/io/File::getAbsolutePath))) + (\ ! conjoint)) #.None (\ io.monad in (exception.except ..cannot_find_directory [path])))))] @@ -251,12 +251,12 @@ (def: file_size (|>> java/io/File::new java/io/File::length - (\ (try.with io.monad) map .nat))) + (\ (try.with io.monad) each .nat))) (def: last_modified (|>> java/io/File::new (java/io/File::lastModified) - (\ (try.with io.monad) map (|>> duration.of_millis instant.absolute)))) + (\ (try.with io.monad) each (|>> duration.of_millis instant.absolute)))) (def: can_execute? (|>> java/io/File::new @@ -456,13 +456,13 @@ (Fs::readdir [path (..value_callback write!)] node_fs))] (|> subs array.list - (list\map (|>> (format path ..js_separator))) - (monad.map ! (function (_ sub) - (\ ! map (|>> (<method> []) [sub]) - (with_async write! (Try Stats) - (Fs::stat [sub (..value_callback write!)] node_fs))))) - (\ ! map (|>> (list.only product.right) - (list\map product.left))))))] + (list\each (|>> (format path ..js_separator))) + (monad.each ! (function (_ sub) + (\ ! each (|>> (<method> []) [sub]) + (with_async write! (Try Stats) + (Fs::stat [sub (..value_callback write!)] node_fs))))) + (\ ! each (|>> (list.only product.right) + (list\each product.left))))))] [directory_files Stats::isFile] [sub_directories Stats::isDirectory] @@ -490,7 +490,7 @@ (def: (can_execute? path) (let [node_fs (..node_fs [])] - (\ async.monad map + (\ async.monad each (|>> (case> (#try.Success _) true @@ -588,7 +588,7 @@ (~~ (template [<name> <method>] [(def: <name> (|>> <method> - (io\map (|>> (try.else false)))))] + (io\each (|>> (try.else false)))))] [file? os/path::isfile] [directory? os/path::isdir] @@ -602,13 +602,13 @@ (let [! (try.with io.monad)] (|> path os::listdir - (\ ! map (|>> array.list - (list\map (|>> (format path ..python_separator))) - (monad.map ! (function (_ sub) - (\ ! map (|>> [sub]) (<method> [sub])))) - (\ ! map (|>> (list.only product.right) - (list\map product.left))))) - (\ ! join))))] + (\ ! each (|>> array.list + (list\each (|>> (format path ..python_separator))) + (monad.each ! (function (_ sub) + (\ ! each (|>> [sub]) (<method> [sub])))) + (\ ! each (|>> (list.only product.right) + (list\each product.left))))) + (\ ! conjoint))))] [directory_files os/path::isfile] [sub_directories os/path::isdir] @@ -616,14 +616,14 @@ (def: file_size (|>> os/path::getsize - (\ (try.with io.monad) map .nat))) + (\ (try.with io.monad) each .nat))) (def: last_modified (|>> os/path::getmtime - (\ (try.with io.monad) map (|>> f.int - (i.* +1,000) - duration.of_millis - instant.absolute)))) + (\ (try.with io.monad) each (|>> f.int + (i.* +1,000) + duration.of_millis + instant.absolute)))) (def: (can_execute? path) (os::access [path (os::X_OK)])) @@ -714,7 +714,7 @@ (~~ (template [<name> <test>] [(def: <name> (|>> <test> - (io\map (|>> (try.else false)))))] + (io\each (|>> (try.else false)))))] [file? RubyFile::file?] [directory? RubyFile::directory?] @@ -730,7 +730,7 @@ children (RubyDir::children [] self) output (loop [input (|> children array.list - (list\map (|>> (format path ..ruby_separator)))) + (list\each (|>> (format path ..ruby_separator)))) output (: (List ..Path) (list))] (case input @@ -754,7 +754,7 @@ [(def: <name> (let [! (try.with io.monad)] (|>> RubyFile::stat - (\ ! map (`` (|>> (~~ (template.spliced <pipeline>))))))))] + (\ ! each (`` (|>> (~~ (template.spliced <pipeline>))))))))] [file_size [RubyStat::size .nat]] [last_modified [(RubyStat::mtime []) @@ -1000,9 +1000,10 @@ (\ fs directory? path)))) (type: Mock_File - {#mock_last_modified Instant - #mock_can_execute Bit - #mock_content Binary}) + (Record + {#mock_last_modified Instant + #mock_can_execute Bit + #mock_content Binary})) (type: #rec Mock (Dictionary Text (Either Mock_File Mock))) @@ -1189,9 +1190,9 @@ [(def: (<method> path) (|> store stm.read - (\ stm.monad map + (\ stm.monad each (|>> (<retrieve> separator path) - (try\map (function.constant true)) + (try\each (function.constant true)) (try.else false))) stm.commit!))] @@ -1238,9 +1239,9 @@ [|store| (stm.read store)] (in (|> |store| (..retrieve_mock_file! separator path) - (try\map (|>> product.right - (value@ #mock_content) - binary.size))))))) + (try\each (|>> product.right + (value@ #mock_content) + binary.size))))))) (def: (last_modified path) (stm.commit! @@ -1248,8 +1249,8 @@ [|store| (stm.read store)] (in (|> |store| (..retrieve_mock_file! separator path) - (try\map (|>> product.right - (value@ #mock_last_modified)))))))) + (try\each (|>> product.right + (value@ #mock_last_modified)))))))) (def: (can_execute? path) (stm.commit! @@ -1257,8 +1258,8 @@ [|store| (stm.read store)] (in (|> |store| (..retrieve_mock_file! separator path) - (try\map (|>> product.right - (value@ #mock_can_execute)))))))) + (try\each (|>> product.right + (value@ #mock_can_execute)))))))) (def: (read path) (stm.commit! @@ -1266,8 +1267,8 @@ [|store| (stm.read store)] (in (|> |store| (..retrieve_mock_file! separator path) - (try\map (|>> product.right - (value@ #mock_content)))))))) + (try\each (|>> product.right + (value@ #mock_content)))))))) (def: (delete path) (stm.commit! @@ -1295,7 +1296,7 @@ (do try.monad [[name file] (..retrieve_mock_file! separator path |store|)] (..update_mock_file! separator path now - (\ binary.monoid compose + (\ binary.monoid composite (value@ #mock_content file) content) |store|))) diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index 1625f79ef..35dfb894d 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -35,9 +35,10 @@ (abstract: .public Concern {#.doc (example "A particular concern to watch-out for.")} - {#creation Bit - #modification Bit - #deletion Bit} + (Record + {#creation Bit + #modification Bit + #deletion Bit}) (def: none Concern @@ -139,11 +140,11 @@ (-> (//.System Async) //.Path (Async (Try (List [//.Path Instant])))) (do {! (try.with async.monad)} [files (\ fs directory_files directory)] - (monad.map ! (function (_ file) - (|> file - (\ fs last_modified) - (\ ! map (|>> [file])))) - files))) + (monad.each ! (function (_ file) + (|> file + (\ fs last_modified) + (\ ! each (|>> [file])))) + files))) (def: (available_directory_changes fs [directory [concern file_tracker]]) (-> (//.System Async) [//.Path [Concern File_Tracker]] @@ -158,11 +159,11 @@ current_files) (list)) available (|> current_files - (list\map product.left) + (list\each product.left) (set.of_list text.hash)) deletions (if (..deletion? concern) (|> (dictionary.entries file_tracker) - (list\map product.left) + (list\each product.left) (list.only (|>> (set.member? available) not))) (list)) modifications (list.all (function (_ [path current_modification]) @@ -235,28 +236,28 @@ (do {! (try.with async.monad)} [changes (|> @tracker dictionary.entries - (monad.map ! (..available_directory_changes fs))) + (monad.each ! (..available_directory_changes fs))) _ (do async.monad [_ (stm.commit! (stm.write (|> changes - (list\map product.left) + (list\each product.left) (dictionary.of_list text.hash)) tracker))] (in (#try.Success []))) .let [[creations modifications deletions] (list\mix (function (_ [_ [creations modifications deletions]] [all_creations all_modifications all_deletions]) - [(list\compose creations all_creations) - (list\compose modifications all_modifications) - (list\compose deletions all_deletions)]) + [(list\composite creations all_creations) + (list\composite modifications all_modifications) + (list\composite deletions all_deletions)]) [(list) (list) (list)] changes)]] - (in ($_ list\compose - (list\map (|>> product.left [..creation]) creations) + (in ($_ list\composite + (list\each (|>> product.left [..creation]) creations) (|> modifications (list.only (function (_ [path previous_modification current_modification]) (not (instant\= previous_modification current_modification)))) - (list\map (|>> product.left [..modification]))) - (list\map (|>> [..deletion]) deletions) + (list\each (|>> product.left [..modification]))) + (list\each (|>> [..deletion]) deletions) ))))) ))) @@ -338,9 +339,9 @@ (def: default_key_concern (-> java/nio/file/WatchKey (IO Concern)) (|>> java/nio/file/WatchKey::pollEvents - (\ io.monad map (|>> ..default_list - (list\map default_event_concern) - (list\mix ..also ..none))))) + (\ io.monad each (|>> ..default_list + (list\each default_event_concern) + (list\mix ..also ..none))))) (import: java/nio/file/WatchService ["#::." @@ -401,7 +402,7 @@ (def: (watch_events concern) (-> Concern (List Watch_Event)) - ($_ list\compose + ($_ list\composite (if (..creation? concern) (list (:as Watch_Event (java/nio/file/StandardWatchEventKinds::ENTRY_CREATE))) (list)) diff --git a/stdlib/source/library/lux/world/input/keyboard.lux b/stdlib/source/library/lux/world/input/keyboard.lux index 4b3127c18..e33e8c4a7 100644 --- a/stdlib/source/library/lux/world/input/keyboard.lux +++ b/stdlib/source/library/lux/world/input/keyboard.lux @@ -100,8 +100,9 @@ (type: .public Press {#.doc (example "A key-press for a key.")} - {#pressed? Bit - #input Key}) + (Record + {#pressed? Bit + #input Key})) (template [<bit> <name>] [(def: .public (<name> key) diff --git a/stdlib/source/library/lux/world/net.lux b/stdlib/source/library/lux/world/net.lux index d1acb1f01..fae3c1f78 100644 --- a/stdlib/source/library/lux/world/net.lux +++ b/stdlib/source/library/lux/world/net.lux @@ -15,5 +15,6 @@ Text) (type: .public Location - {#address Address - #port Port}) + (Record + {#address Address + #port Port})) diff --git a/stdlib/source/library/lux/world/net/http.lux b/stdlib/source/library/lux/world/net/http.lux index 2c0877351..75b3c7b86 100644 --- a/stdlib/source/library/lux/world/net/http.lux +++ b/stdlib/source/library/lux/world/net/http.lux @@ -16,15 +16,16 @@ Text) (type: .public Method - #Post - #Get - #Put - #Patch - #Delete - #Head - #Connect - #Options - #Trace) + (Variant + #Post + #Get + #Put + #Patch + #Delete + #Head + #Connect + #Options + #Trace)) (type: .public Port Nat) @@ -46,28 +47,34 @@ (-> (Maybe Nat) (! (Try [Nat Binary])))) (type: .public Scheme - #HTTP - #HTTPS) + (Variant + #HTTP + #HTTPS)) (type: .public Address - {#port Port - #host Text}) + (Record + {#port Port + #host Text})) (type: .public Identification - {#local Address - #remote Address}) + (Record + {#local Address + #remote Address})) (type: .public Protocol - {#version Version - #scheme Scheme}) + (Record + {#version Version + #scheme Scheme})) (type: .public Resource - {#method Method - #uri URI}) + (Record + {#method Method + #uri URI})) (type: .public (Message !) - {#headers Headers - #body (Body !)}) + (Record + {#headers Headers + #body (Body !)})) (type: .public (Request !) [Identification Protocol Resource (Message !)]) diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux index 50a5a2436..eaf97a16e 100644 --- a/stdlib/source/library/lux/world/net/http/client.lux +++ b/stdlib/source/library/lux/world/net/http/client.lux @@ -127,7 +127,7 @@ (def: (default_body input) (-> java/io/BufferedInputStream (//.Body IO)) - (|>> (maybe\map (|>> [true])) + (|>> (maybe\each (|>> [true])) (maybe.else [false ..default_buffer_size]) (case> [_ 0] (do (try.with io.monad) @@ -161,14 +161,14 @@ +0 (in (..body_of output)) _ (|> buffer (binary.slice 0 (.nat so_far)) - (\ try.functor map - (|>> (\ binary.monoid compose output) + (\ try.functor each + (|>> (\ binary.monoid composite output) ..body_of)) (\ io.monad in)))) +0 (recur so_far output) _ (if (i.= remaining bytes_read) (recur +0 - (\ binary.monoid compose output buffer)) + (\ binary.monoid composite output buffer)) (recur (i.+ bytes_read so_far) output)))))))))) @@ -197,9 +197,9 @@ [connection (|> url java/net/URL::new java/net/URL::openConnection) .let [connection (:as java/net/HttpURLConnection connection)] _ (java/net/HttpURLConnection::setRequestMethod (..jvm_method method) connection) - _ (monad.map ! (function (_ [name value]) - (java/net/URLConnection::setRequestProperty name value connection)) - (dictionary.entries headers)) + _ (monad.each ! (function (_ [name value]) + (java/net/URLConnection::setRequestProperty name value connection)) + (dictionary.entries headers)) _ (case data (#.Some data) (do ! @@ -216,7 +216,7 @@ headers (..default_headers connection) input (|> connection java/net/URLConnection::getInputStream - (\ ! map (|>> java/io/BufferedInputStream::new)))] + (\ ! each (|>> java/io/BufferedInputStream::new)))] (in [(.nat status) {#//.headers headers #//.body (..default_body input)}]))))))] @@ -230,7 +230,7 @@ (def: (request method url headers data) (|> (\ client request method url headers data) async.future - (\ async.monad map + (\ async.monad each (|>> (case> (#try.Success [status message]) (#try.Success [status (revised@ #//.body (: (-> (//.Body IO) (//.Body Async)) (function (_ body) diff --git a/stdlib/source/library/lux/world/net/http/cookie.lux b/stdlib/source/library/lux/world/net/http/cookie.lux index c9673ed31..bb93c2c82 100644 --- a/stdlib/source/library/lux/world/net/http/cookie.lux +++ b/stdlib/source/library/lux/world/net/http/cookie.lux @@ -58,8 +58,9 @@ ) (type: .public CSRF_Policy - #Strict - #Lax) + (Variant + #Strict + #Lax)) (def: .public (same_site policy) (-> CSRF_Policy Directive) diff --git a/stdlib/source/library/lux/world/net/http/query.lux b/stdlib/source/library/lux/world/net/http/query.lux index 0fc879552..1f71fbcc7 100644 --- a/stdlib/source/library/lux/world/net/http/query.lux +++ b/stdlib/source/library/lux/world/net/http/query.lux @@ -35,7 +35,7 @@ [_ (l.this "%") code (|> (l.exactly 2 l.hexadecimal) (p.codec nat.hex) - (\ ! map text.from_code)) + (\ ! each text.from_code)) tail component] (in (format head code tail)))))))) diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index 30adaea99..26e25e7a7 100644 --- a/stdlib/source/library/lux/world/net/http/request.lux +++ b/stdlib/source/library/lux/world/net/http/request.lux @@ -35,10 +35,10 @@ (monad.mix try.monad (function (_ input [offset output]) (let [amount (binary.size input)] - (\ try.functor map (|>> [(n.+ amount offset)]) + (\ try.functor each (|>> [(n.+ amount offset)]) (binary.copy amount 0 input offset output)))) [0 (|> inputs - (list\map binary.size) + (list\each binary.size) (list\mix n.+ 0) binary.empty)] inputs))] diff --git a/stdlib/source/library/lux/world/output/video/resolution.lux b/stdlib/source/library/lux/world/output/video/resolution.lux index 08b5f1a3f..973cdac9b 100644 --- a/stdlib/source/library/lux/world/output/video/resolution.lux +++ b/stdlib/source/library/lux/world/output/video/resolution.lux @@ -20,8 +20,9 @@ (type: .public Resolution {#.doc (example "A screen resolution.")} - {#width Nat - #height Nat}) + (Record + {#width Nat + #height Nat})) (def: .public hash (Hash Resolution) diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index 05f9cd8a6..6262649aa 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -58,9 +58,9 @@ (All [!] (-> (Monad !) (Program !) (! Environment))) (do {! monad} [variables (\ program available_variables []) - entries (monad.map ! (function (_ name) - (\ ! map (|>> [name]) (\ program variable name))) - variables)] + entries (monad.each ! (function (_ name) + (\ ! each (|>> [name]) (\ program variable name))) + variables)] (in (|> entries (list.all (function (_ [name value]) (case value @@ -319,12 +319,12 @@ (#.Some process/env) (|> (Object::entries [process/env]) array.list - (list\map (|>> (array.read! 0) maybe.trusted))) + (list\each (|>> (array.read! 0) maybe.trusted))) #.None (list)) (list))) - @.python (\ io.monad map array.list (os/environ::keys [])) + @.python (\ io.monad each array.list (os/environ::keys [])) ... Lua offers no way to get all the environment variables available. @.lua (io.io (list)) @.ruby (|> (RubyEnv::keys []) @@ -335,7 +335,7 @@ ... (in (|> environment ... ..array_keys ... array.list - ... (list\map (function (_ variable) + ... (list\each (function (_ variable) ... [variable ("php array read" (:as Nat variable) environment)])) ... (dictionary.of_list text.hash)))) ... @.scheme (do io.monad diff --git a/stdlib/source/library/lux/world/service/inventory.lux b/stdlib/source/library/lux/world/service/inventory.lux index 38c69557e..6a5fac798 100644 --- a/stdlib/source/library/lux/world/service/inventory.lux +++ b/stdlib/source/library/lux/world/service/inventory.lux @@ -6,7 +6,8 @@ [security ["!" capability (#+ capability:)]]]]]) -(type: .public ID Nat) +(type: .public ID + Nat) (type: .public Ownership {#owner ID diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index a86f33a67..209c161bd 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -290,7 +290,7 @@ ... https://en.wikipedia.org/wiki/Code_injection#Shell_injection (def: windows? (IO (Try Bit)) - (\ (try.with io.monad) map + (\ (try.with io.monad) each (|>> java/lang/String::toLowerCase (text.starts_with? "windows")) (java/lang/System::getProperty "os.name"))) @@ -305,7 +305,7 @@ (java/lang/ProcessBuilder::directory (java/io/File::new working_directory)))] _ (|> builder java/lang/ProcessBuilder::environment - (\ try.functor map (..jvm::load_environment environment)) + (\ try.functor each (..jvm::load_environment environment)) (\ io.monad in)) process (java/lang/ProcessBuilder::start builder)] (..default_process process)))) @@ -380,5 +380,5 @@ (def: execute (|>> mock - (\ try.monad map (..mock_process (atom.atom init))) + (\ try.monad each (..mock_process (atom.atom init))) io.io))) |