diff options
Diffstat (limited to '')
64 files changed, 648 insertions, 609 deletions
diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index b5eed68f8..1894359a9 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -22,9 +22,9 @@ ["%" format (#+ format)]] [collection ["." dictionary (#+ Dictionary)] - ["." row (#+ Row) ("#\." fold)] + ["." row (#+ Row) ("#\." mix)] ["." set (#+ Set)] - ["." list ("#\." monoid functor fold)]] + ["." list ("#\." monoid functor mix)]] [format ["_" binary (#+ Writer)]]] [world @@ -280,9 +280,9 @@ #///directive.state #extension.state #///generation.log]) - (row\fold (function (_ right left) - (format left ..compilation_log_separator right)) - module))) + (row\mix (function (_ right left) + (format left ..compilation_log_separator right)) + module))) (def: with_reset_log (All [<type_vars>] @@ -329,10 +329,10 @@ (|> mapping (dictionary.revised' source ..empty (set.has target)) (dictionary.revised source (set.union forward)))] - (list\fold (function (_ previous) - (dictionary.revised' previous ..empty (set.has target))) - with_dependence+transitives - (set.list backward))))))] + (list\mix (function (_ previous) + (dictionary.revised' previous ..empty (set.has target))) + with_dependence+transitives + (set.list backward))))))] (|> dependence (revised@ #depends_on (update_dependence @@ -561,17 +561,17 @@ ... This currently assumes that all imports will be specified once in a single .module: form. ... This might not be the case in the future. [all_dependencies duplicates _] (: [(Set Module) (Set Module) Bit] - (list\fold (function (_ new [all duplicates seen_prelude?]) - (if (set.member? all new) - (if (text\= .prelude_module new) - (if seen_prelude? - [all (set.has new duplicates) seen_prelude?] - [all duplicates true]) - [all (set.has new duplicates) seen_prelude?]) - [(set.has new all) duplicates seen_prelude?])) - (: [(Set Module) (Set Module) Bit] - [all_dependencies ..empty (set.empty? all_dependencies)]) - new_dependencies))] + (list\mix (function (_ new [all duplicates seen_prelude?]) + (if (set.member? all new) + (if (text\= .prelude_module new) + (if seen_prelude? + [all (set.has new duplicates) seen_prelude?] + [all duplicates true]) + [all (set.has new duplicates) seen_prelude?]) + [(set.has new all) duplicates seen_prelude?])) + (: [(Set Module) (Set Module) Bit] + [all_dependencies ..empty (set.empty? all_dependencies)]) + new_dependencies))] [archive state] (if (set.empty? duplicates) (case new_dependencies #.End @@ -584,7 +584,7 @@ (monad.all ..monad)) .let [archive (|> archive,document+ (list\map product.left) - (list\fold archive.merged archive))]] + (list\mix archive.merged archive))]] (in [archive (try.trusted (..updated_state archive state))]))) (async\in (exception.except ..cannot_import_twice [module duplicates])))] 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 45216a70f..6d1f355ba 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux @@ -16,7 +16,7 @@ ["." text ("#\." equivalence) ["%" format (#+ Format format)]] [collection - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [math [number ["n" nat] @@ -262,10 +262,10 @@ (def: .public (apply [abstraction inputs]) (-> (Application Analysis) Analysis) - (list\fold (function (_ input abstraction') - (#Apply input abstraction')) - abstraction - inputs)) + (list\mix (function (_ input abstraction') + (#Apply input abstraction')) + abstraction + inputs)) (def: .public (application analysis) (-> Analysis (Application Analysis)) 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 fc7575260..6c31960e4 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 @@ -13,7 +13,7 @@ [text ["%" format (#+ format)]] [collection - ["." list ("#\." fold monoid functor)]]] + ["." list ("#\." mix monoid functor)]]] [math [number ["n" nat]]] @@ -216,19 +216,19 @@ _ (undefined)))] (do ! - [[memberP+ thenA] (list\fold (: (All [a] - (-> [Type Code] (Operation [(List Pattern) a]) - (Operation [(List Pattern) a]))) - (function (_ [memberT memberC] then) - (do ! - [[memberP [memberP+ thenA]] ((:as (All [a] (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a]))) - analyse_pattern) - #.None memberT memberC then)] - (in [(list& memberP memberP+) thenA])))) - (do ! - [nextA next] - (in [(list) nextA])) - matches)] + [[memberP+ thenA] (list\mix (: (All [a] + (-> [Type Code] (Operation [(List Pattern) a]) + (Operation [(List Pattern) a]))) + (function (_ [memberT memberC] then) + (do ! + [[memberP [memberP+ thenA]] ((:as (All [a] (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a]))) + analyse_pattern) + #.None memberT memberC then)] + (in [(list& memberP memberP+) thenA])))) + (do ! + [nextA next] + (in [(list) nextA])) + matches)] (in [(/.pattern/tuple memberP+) thenA]))) @@ -320,7 +320,7 @@ branchesT) outputHC (|> outputH product.left /coverage.determine) outputTC (monad.map ! (|>> product.left /coverage.determine) outputT) - _ (.case (monad.fold try.monad /coverage.merged outputHC outputTC) + _ (.case (monad.mix try.monad /coverage.merged outputHC outputTC) (#try.Success coverage) (///.assertion non_exhaustive_pattern_matching [inputC branches coverage] (/coverage.exhaustive? 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 e7efacf3c..753f6a13e 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 @@ -13,7 +13,7 @@ ["." text ["%" format (#+ Format format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." dictionary (#+ Dictionary)]]] [math [number @@ -128,17 +128,17 @@ (#.Item lastP prevsP+) (do ////.monad [lastC (determine lastP)] - (monad.fold ////.monad - (function (_ leftP rightC) - (do ////.monad - [leftC (determine leftP)] - (case rightC - #Exhaustive - (in leftC) - - _ - (in (#Seq leftC rightC))))) - lastC prevsP+))) + (monad.mix ////.monad + (function (_ leftP rightC) + (do ////.monad + [leftC (determine leftP)] + (case rightC + #Exhaustive + (in leftC) + + _ + (in (#Seq leftC rightC))))) + lastC prevsP+))) ... Variant patterns can be shown to be exhaustive if all the possible ... cases are handled exhaustively. @@ -243,17 +243,17 @@ ... else (do {! try.monad} - [casesM (monad.fold ! - (function (_ [tagA coverageA] casesSF') - (case (dictionary.value tagA casesSF') - (#.Some coverageSF) - (do ! - [coverageM (merged coverageA coverageSF)] - (in (dictionary.has tagA coverageM casesSF'))) - - #.None - (in (dictionary.has tagA coverageA casesSF')))) - casesSF (dictionary.entries casesA))] + [casesM (monad.mix ! + (function (_ [tagA coverageA] casesSF') + (case (dictionary.value tagA casesSF') + (#.Some coverageSF) + (do ! + [coverageM (merged coverageA coverageSF)] + (in (dictionary.has tagA coverageM casesSF'))) + + #.None + (in (dictionary.has tagA coverageA casesSF')))) + casesSF (dictionary.entries casesA))] (in (if (and (or (known_cases? addition_cases) (known_cases? so_far_cases)) (n.= (++ (n.max addition_cases so_far_cases)) @@ -360,9 +360,9 @@ #.None (case (list.reversed possibilitiesSF) (#.Item last prevs) - (in (list\fold (function (_ left right) (#Alt left right)) - last - prevs)) + (in (list\mix (function (_ left right) (#Alt left right)) + last + prevs)) #.End (undefined))))) 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 8aa2f284f..3589b7224 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 @@ -10,7 +10,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." fold monoid monad)]]] + ["." list ("#\." monoid monad)]]] ["." type ["." check]] ["." meta]]] 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 14e08a4c0..abe4b8df6 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 @@ -11,7 +11,7 @@ ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection - ["." list ("#\." fold functor)] + ["." list ("#\." mix functor)] [dictionary ["." plist]]]] ["." meta]]] @@ -264,10 +264,10 @@ (#try.Success [(revised@ #.modules (plist.revised self_name (|>> (revised@ #.tags (function (_ tag_bindings) - (list\fold (function (_ [idx tag] table) - (plist.has tag [idx namespaced_tags exported? type] table)) - tag_bindings - (list.enumeration tags)))) + (list\mix (function (_ [idx tag] table) + (plist.has tag [idx namespaced_tags exported? type] table)) + tag_bindings + (list.enumeration tags)))) (revised@ #.types (plist.has type_name [namespaced_tags exported? type])))) state) []])) 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 44d3b7deb..b859c7528 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 @@ -11,7 +11,7 @@ ["." text ("#\." equivalence)] ["." product] [collection - ["." list ("#\." functor fold monoid)] + ["." list ("#\." functor mix monoid)] [dictionary ["." plist]]]]]] ["." /// #_ @@ -90,17 +90,17 @@ (#.Item top_outer _) (let [[ref_type init_ref] (maybe.else (undefined) (..reference name top_outer)) - [ref inner'] (list\fold (: (-> Scope [Variable (List Scope)] [Variable (List Scope)]) - (function (_ scope ref+inner) - [(#variable.Foreign (value@ [#.captured #.counter] scope)) - (#.Item (revised@ #.captured - (: (-> Foreign Foreign) - (|>> (revised@ #.counter ++) - (revised@ #.mappings (plist.has name [ref_type (product.left ref+inner)])))) - scope) - (product.right ref+inner))])) - [init_ref #.End] - (list.reversed inner)) + [ref inner'] (list\mix (: (-> Scope [Variable (List Scope)] [Variable (List Scope)]) + (function (_ scope ref+inner) + [(#variable.Foreign (value@ [#.captured #.counter] scope)) + (#.Item (revised@ #.captured + (: (-> Foreign Foreign) + (|>> (revised@ #.counter ++) + (revised@ #.mappings (plist.has name [ref_type (product.left ref+inner)])))) + scope) + (product.right ref+inner))])) + [init_ref #.End] + (list.reversed inner)) scopes (list\compose inner' outer)] (#.Right [(with@ #.scopes scopes state) (#.Some [ref_type 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 886ffe065..b23704981 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 @@ -318,21 +318,21 @@ (/.except ..record_size_mismatch [size_ts size_record recordT record])) .let [tuple_range (list.indices size_ts) tag->idx (dictionary.of_list name.hash (list.zipped/2 tag_set tuple_range))] - idx->val (monad.fold ! - (function (_ [key val] idx->val) - (do ! - [key (///extension.lifted (meta.normal key))] - (case (dictionary.value key tag->idx) - (#.Some idx) - (if (dictionary.key? idx->val idx) - (/.except ..cannot_repeat_tag [key record]) - (in (dictionary.has idx val idx->val))) - - #.None - (/.except ..tag_does_not_belong_to_record [key recordT])))) - (: (Dictionary Nat Code) - (dictionary.empty n.hash)) - record) + idx->val (monad.mix ! + (function (_ [key val] idx->val) + (do ! + [key (///extension.lifted (meta.normal key))] + (case (dictionary.value key tag->idx) + (#.Some idx) + (if (dictionary.key? idx->val idx) + (/.except ..cannot_repeat_tag [key record]) + (in (dictionary.has idx val idx->val))) + + #.None + (/.except ..tag_does_not_belong_to_record [key recordT])))) + (: (Dictionary Nat Code) + (dictionary.empty n.hash)) + record) .let [ordered_tuple (list\map (function (_ idx) (maybe.trusted (dictionary.value idx idx->val))) tuple_range)]] 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 3c6425da3..98163f30d 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 @@ -11,7 +11,7 @@ [text ["%" format (#+ format)]] [collection - ["." list ("#\." fold monoid)]]]]] + ["." list ("#\." mix monoid)]]]]] ["." // #_ ["#." extension] ["#." analysis @@ -101,7 +101,7 @@ _ (|> expansion (monad.map ! (recur archive)) - (\ ! map (list\fold /.merge_requirements /.no_requirements))))) + (\ ! map (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 206ae9f64..18da2442f 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 @@ -103,10 +103,10 @@ (-> Extender (Bundle s i o) (Operation s i o Any))) (|> extensions dictionary.entries - (monad.fold //.monad - (function (_ [extension handle] output) - (..install extender extension handle)) - []))) + (monad.mix //.monad + (function (_ [extension handle] output) + (..install extender extension handle)) + []))) (def: .public (apply archive phase [name parameters]) (All [s i o] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index 508242cd8..d4ffdbb2b 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 @@ -18,7 +18,7 @@ ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection - ["." list ("#\." fold monad monoid)] + ["." list ("#\." mix monad monoid)] ["." array] ["." dictionary (#+ Dictionary)]]] [math @@ -1110,20 +1110,20 @@ true) arity_matches? (n.= (list.size inputsJT) (list.size parameters)) inputs_match? (and arity_matches? - (list\fold (function (_ [expectedJC actualJC] prev) - (and prev - (jvm\= expectedJC (: (Type Value) - (case (jvm_parser.var? actualJC) - (#.Some name) - (|> aliasing - (dictionary.value name) - (maybe.else name) - jvm.var) - - #.None - actualJC))))) - true - (list.zipped/2 parameters inputsJT)))]] + (list\mix (function (_ [expectedJC actualJC] prev) + (and prev + (jvm\= expectedJC (: (Type Value) + (case (jvm_parser.var? actualJC) + (#.Some name) + (|> aliasing + (dictionary.value name) + (maybe.else name) + jvm.var) + + #.None + actualJC))))) + true + (list.zipped/2 parameters inputsJT)))]] (in (and correct_class? correct_method? static_matches? @@ -1685,7 +1685,7 @@ [scope bodyA] (|> arguments' (#.Item [self_name selfT]) list.reversed - (list\fold scope.with_local (analyse archive body)) + (list\mix scope.with_local (analyse archive body)) (typeA.with_type .Any) /////analysis.with_scope)] (in (/////analysis.tuple (list (/////analysis.text ..constructor_tag) @@ -1761,7 +1761,7 @@ [scope bodyA] (|> arguments' (#.Item [self_name selfT]) list.reversed - (list\fold scope.with_local (analyse archive body)) + (list\mix scope.with_local (analyse archive body)) (typeA.with_type returnT) /////analysis.with_scope)] (in (/////analysis.tuple (list (/////analysis.text ..virtual_tag) @@ -1834,7 +1834,7 @@ arguments) [scope bodyA] (|> arguments' list.reversed - (list\fold scope.with_local (analyse archive body)) + (list\mix scope.with_local (analyse archive body)) (typeA.with_type returnT) /////analysis.with_scope)] (in (/////analysis.tuple (list (/////analysis.text ..static_tag) @@ -1930,19 +1930,19 @@ check.existential)] (in [var exT]))) vars)] - (in (list\fold (function (_ [varJ varT] mapping) - (dictionary.has (jvm_parser.name varJ) varT mapping)) - mapping - pairings)))) + (in (list\mix (function (_ [varJ varT] mapping) + (dictionary.has (jvm_parser.name varJ) varT mapping)) + mapping + pairings)))) (def: .public (with_override_mapping supers parent_type mapping) (-> (List (Type Class)) (Type Class) Mapping (Operation Mapping)) (do phase.monad [override_mapping (..override_mapping mapping supers parent_type)] - (in (list\fold (function (_ [super_var bound_type] mapping) - (dictionary.has super_var bound_type mapping)) - mapping - override_mapping)))) + (in (list\mix (function (_ [super_var bound_type] mapping) + (dictionary.has super_var bound_type mapping)) + mapping + override_mapping)))) (def: .public (hide_method_body arity bodyA) (-> Nat Analysis Analysis) @@ -2001,7 +2001,7 @@ [scope bodyA] (|> arguments' (#.Item [self_name selfT]) list.reversed - (list\fold scope.with_local (analyse archive body)) + (list\mix scope.with_local (analyse archive body)) (typeA.with_type returnT) /////analysis.with_scope)] (in (/////analysis.tuple (list (/////analysis.text ..overriden_tag) @@ -2066,14 +2066,14 @@ (n.= (list.size expected_parameters) (list.size actual_parameters)))] (in (|> (list.zipped/2 expected_parameters actual_parameters) - (list\fold (function (_ [expected actual] mapping) - (case (jvm_parser.var? actual) - (#.Some actual) - (dictionary.has actual expected mapping) - - #.None - mapping)) - jvm_alias.fresh))))) + (list\mix (function (_ [expected actual] mapping) + (case (jvm_parser.var? actual) + (#.Some actual) + (dictionary.has actual expected mapping) + + #.None + mapping)) + jvm_alias.fresh))))) (def: (anonymous_class_name module id) (-> Module Nat Text) @@ -2125,12 +2125,12 @@ _ (monad.map ! (|>> ..reflection (..ensure_fresh_class! class_loader)) super_interfaces) parameters (typeA.with_env (..parameter_types parameters)) - .let [mapping (list\fold (function (_ [parameterJ parameterT] mapping) - (dictionary.has (jvm_parser.name parameterJ) - parameterT - mapping)) - luxT.fresh - parameters)] + .let [mapping (list\mix (function (_ [parameterJ parameterT] mapping) + (dictionary.has (jvm_parser.name parameterJ) + parameterT + mapping)) + luxT.fresh + parameters)] super_classT (typeA.with_env (luxT.check (luxT.class mapping) (..signature super_class))) super_interfaceT+ (typeA.with_env 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 0242d94b6..29de45227 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 @@ -14,7 +14,7 @@ [text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." dictionary] ["." row]]] [macro @@ -263,10 +263,10 @@ [parameters (directive.lifted_analysis (typeA.with_env (jvm.parameter_types parameters))) - .let [mapping (list\fold (function (_ [parameterJ parameterT] mapping) - (dictionary.has (parser.name parameterJ) parameterT mapping)) - luxT.fresh - parameters)] + .let [mapping (list\mix (function (_ [parameterJ parameterT] mapping) + (dictionary.has (parser.name parameterJ) parameterT mapping)) + luxT.fresh + parameters)] super_classT (directive.lifted_analysis (typeA.with_env (luxT.check (luxT.class mapping) (..signature super_class)))) 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 e8518812e..49b696138 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 @@ -15,7 +15,7 @@ [collection ["." dictionary] ["." set] - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [math [number ["f" frac]]] @@ -75,7 +75,7 @@ ... branchG]))) ... conditionals))] ... (in (_.let (list [@input inputG]) -... (list (list\fold (function (_ [test then] else) +... (list (list\mix (function (_ [test then] else) ... (_.if test then else)) ... elseG ... conditionalsG))))))])) 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 0e0c91e60..142691489 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 @@ -14,7 +14,7 @@ ["%" format (#+ format)]] [collection ["." dictionary] - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [math [number ["f" frac]]] @@ -70,18 +70,18 @@ [branchG (phase archive branch)] (in [(|> chars (list\map (|>> .int _.int (_.= @input))) - (list\fold (function (_ clause total) - (if (same? _.nil total) - clause - (_.or clause total))) - _.nil)) + (list\mix (function (_ clause total) + (if (same? _.nil total) + clause + (_.or clause total))) + _.nil)) branchG]))) conditionals)) .let [closure (_.closure (list @input) - (list\fold (function (_ [test then] else) - (_.if test (_.return then) else)) - (_.return elseG) - conditionalsG))]] + (list\mix (function (_ [test then] else) + (_.if test (_.return then) else)) + (_.return elseG) + conditionalsG))]] (in (_.apply/1 closure inputG))))])) (def: lux_procs 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 02ddfbd71..3acac79be 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 @@ -15,7 +15,7 @@ [collection ["." dictionary] ["." set] - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [math [number ["f" frac]]] @@ -74,11 +74,11 @@ [branchG (phase archive branch)] (in [(|> chars (list\map (|>> .int _.int (_.=== @input))) - (list\fold (function (_ clause total) - (if (same? _.null total) - clause - (_.or clause total))) - _.null)) + (list\mix (function (_ clause total) + (if (same? _.null total) + clause + (_.or clause total))) + _.null)) branchG]))) conditionals)) .let [foreigns (|> conditionals @@ -89,10 +89,10 @@ set.list) @expression (_.constant (reference.artifact [context_module context_artifact])) directive (_.define_function @expression (list& (_.parameter @input) (list\map _.reference foreigns)) - (list\fold (function (_ [test then] else) - (_.if test (_.return then) else)) - (_.return elseG) - conditionalsG))] + (list\mix (function (_ [test then] else) + (_.if test (_.return then) else)) + (_.return elseG) + conditionalsG))] _ (generation.execute! directive) _ (generation.save! context_artifact directive)] (in (_.apply/* (list& inputG foreigns) @expression))))])) 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 c531d05d9..6f51e40f1 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 @@ -14,26 +14,72 @@ ["%" format (#+ format)]] [collection ["." dictionary] - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [math [number ["f" frac]]] [target - ["_" python (#+ Expression)]]]] + ["_" python (#+ Expression Statement)]]]] ["." //// #_ ["/" bundle] ["/#" // #_ ["." extension] [generation + ["." reference] [extension (#+ Nullary Unary Binary Trinary nullary unary binary trinary)] ["//" python #_ - ["#." runtime (#+ Operation Phase Handler Bundle Generator)]]] + ["#." runtime (#+ Operation Phase Phase! Handler Bundle Generator)] + ["#." primitive] + ["#." structure] + ["#." reference] + ["#." function] + ["#." case] + ["#." loop]]] [// - [synthesis (#+ %synthesis)] + [analysis (#+)] + ["." synthesis (#+ %synthesis)] ["." generation] [/// - ["#" phase]]]]]) + ["#" phase ("#\." monad)]]]]]) + +(def: .public (statement expression archive synthesis) + Phase! + (case synthesis + ... TODO: Get rid of this ASAP + (#synthesis.Extension "lux syntax char case!" parameters) + (do /////.monad + [body (expression archive synthesis)] + (in (:as (Statement Any) body))) + + (^template [<tag>] + [(^ (<tag> value)) + (/////\map _.return (expression archive synthesis))]) + ([synthesis.bit] + [synthesis.i64] + [synthesis.f64] + [synthesis.text] + [synthesis.variant] + [synthesis.tuple] + [#synthesis.Reference] + [synthesis.branch/get] + [synthesis.function/apply] + [#synthesis.Extension]) + + (^ (synthesis.branch/case case)) + (//case.case! false statement expression archive case) + + (^template [<tag> <generator>] + [(^ (<tag> value)) + (<generator> statement expression archive value)]) + ([synthesis.branch/let //case.let!] + [synthesis.branch/if //case.if!] + [synthesis.loop/scope //loop.scope!] + [synthesis.loop/recur //loop.recur!]) + + (^ (synthesis.function/abstraction abstraction)) + (/////\map _.return (//function.function statement expression archive abstraction)) + )) (def: .public (custom [parser handler]) (All [s] @@ -59,28 +105,48 @@ (function (_ extension_name phase archive [input else conditionals]) (do {! /////.monad} [inputG (phase archive input) - elseG (phase archive else) + else! (..statement phase archive else) @input (\ ! map _.var (generation.identifier "input")) - conditionalsG (: (Operation (List [(Expression Any) - (Expression Any)])) + conditionals! (: (Operation (List [(Expression Any) + (Statement Any)])) (monad.map ! (function (_ [chars branch]) (do ! - [branchG (phase archive branch)] + [branch! (..statement phase archive branch)] (in [(|> chars (list\map (|>> .int _.int (_.= @input))) - (list\fold (function (_ clause total) - (if (same? _.none total) - clause - (_.or clause total))) - _.none)) - branchG]))) + (list\mix (function (_ clause total) + (if (same? _.none total) + clause + (_.or clause total))) + _.none)) + branch!]))) conditionals)) - .let [closure (_.lambda (list @input) - (list\fold (function (_ [test then] else) - (_.? test then else)) - elseG - conditionalsG))]] - (in (_.apply/* closure (list inputG)))))])) + ... .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 + ... synthesis.path/then) + ... conditionals)))) + ... @closure (_.var (reference.artifact artifact_id)) + ... closure (_.def @closure dependencies + ... ($_ _.then + ... (_.set (list @input) inputG) + ... (list\mix (function (_ [test then!] else!) + ... (_.if test then! else!)) + ... else! + ... conditionals!)))] + ... _ (generation.execute! closure) + ... _ (generation.save! (product.right artifact_id) #.None closure) + ] + ... (in (_.apply/* @closure dependencies)) + (in (:as (Expression Any) + ($_ _.then + (_.set (list @input) inputG) + (list\mix (function (_ [test then!] else!) + (_.if test then! else!)) + else! + conditionals!))))))])) (def: lux_procs Bundle 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 25e244035..3cc7cf91c 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 @@ -15,7 +15,7 @@ [collection ["." dictionary] ["." set] - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [math [number ["f" frac]]] @@ -75,7 +75,7 @@ ... ... branchG]))) ... ... conditionals))] ... ... (in (_.let (list [@input inputG]) -... ... (list (list\fold (function (_ [test then] else) +... ... (list (list\mix (function (_ [test then] else) ... ... (_.if test then else)) ... ... elseG ... ... conditionalsG))))))])) 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 db479ccd3..253b342e8 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 @@ -14,7 +14,7 @@ ["%" format (#+ format)]] [collection ["." dictionary] - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [math [number ["f" frac]]] @@ -67,18 +67,18 @@ [branchG (phase archive branch)] (in [(|> chars (list\map (|>> .int _.int (_.= @input))) - (list\fold (function (_ clause total) - (if (same? _.nil total) - clause - (_.or clause total))) - _.nil)) + (list\mix (function (_ clause total) + (if (same? _.nil total) + clause + (_.or clause total))) + _.nil)) branchG]))) conditionals)) .let [closure (_.lambda #.None (list @input) - (list\fold (function (_ [test then] else) - (_.if test (_.return then) else)) - (_.return elseG) - conditionalsG))]] + (list\mix (function (_ [test then] else) + (_.if test (_.return then) else)) + (_.return elseG) + conditionalsG))]] (in (_.apply_lambda/* (list inputG) closure))))])) (def: lux_procs 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 2b2fca71f..79c3cce7b 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 @@ -15,7 +15,7 @@ [collection ["." dictionary] ["." set] - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [math [number ["f" frac]]] @@ -75,10 +75,10 @@ branchG]))) conditionals))] (in (_.let (list [@input inputG]) - (list\fold (function (_ [test then] else) - (_.if test then else)) - elseG - conditionalsG)))))])) + (list\mix (function (_ [test then] else) + (_.if test then else)) + elseG + conditionalsG)))))])) (def: lux_procs 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 fae91850c..982b48475 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 @@ -9,7 +9,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold monoid)] + ["." list ("#\." functor mix monoid)] ["." set]]] [math [number @@ -63,16 +63,16 @@ (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueG (expression archive valueS)] - (in (list\fold (function (_ side source) - (.let [method (.case side - (^template [<side> <accessor>] - [(<side> lefts) - (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple//left] - [#.Right //runtime.tuple//right]))] - (method source))) - valueG - pathP)))) + (in (list\mix (function (_ side source) + (.let [method (.case side + (^template [<side> <accessor>] + [(<side> lefts) + (<accessor> (_.int (.int lefts)))]) + ([#.Left //runtime.tuple//left] + [#.Right //runtime.tuple//right]))] + (method source))) + valueG + pathP)))) (def: @savepoint (_.var "lux_pm_savepoint")) (def: @cursor (_.var "lux_pm_cursor")) @@ -180,10 +180,10 @@ ..peek]) then!]))) (#.Item item))] - (in (list\fold (function (_ [when then] else) - (_.if when then else)) - (_.go @fail) - clauses)))]) + (in (list\mix (function (_ [when then] else) + (_.if when then else)) + (_.go @fail) + clauses)))]) ([#/////synthesis.I64_Fork //primitive.i64 _.=/2] [#/////synthesis.F64_Fork //primitive.f64 _.=/2] [#/////synthesis.Text_Fork //primitive.text _.string=/2]) 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 41faa95b6..c54bae779 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 @@ -10,7 +10,7 @@ [text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor)]]] [target ["_" common_lisp (#+ Expression Var/1)]]]] ["." // #_ 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 7eca077bf..0b2328715 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 @@ -290,4 +290,4 @@ (row.row [(%.nat ..module_id) (|> ..runtime _.code - (\ encoding.utf8 encode))])]))) + (\ encoding.utf8 encoded))])]))) 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 9b0431808..edce73735 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 @@ -8,7 +8,7 @@ [data ["." text] [collection - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [math [number ["n" nat]]] @@ -77,16 +77,16 @@ (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] - (in (list\fold (function (_ side source) - (.let [method (.case side - (^template [<side> <accessor>] - [(<side> lefts) - (<accessor> (_.i32 (.int lefts)))]) - ([#.Left //runtime.tuple//left] - [#.Right //runtime.tuple//right]))] - (method source))) - valueO - (list.reversed pathP))))) + (in (list\mix (function (_ side source) + (.let [method (.case side + (^template [<side> <accessor>] + [(<side> lefts) + (<accessor> (_.i32 (.int lefts)))]) + ([#.Left //runtime.tuple//left] + [#.Right //runtime.tuple//right]))] + (method source))) + valueO + (list.reversed pathP))))) (def: @savepoint (_.var "lux_pm_cursor_savepoint")) (def: @cursor (_.var "lux_pm_cursor")) 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 fdfc768a0..90f1cca9a 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 @@ -8,7 +8,7 @@ [text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [target ["_" js (#+ Expression Computation Var Statement)]]]] ["." // #_ @@ -81,12 +81,12 @@ apply_poly (.function (_ args func) (|> func (_.do "apply" (list _.null args)))) initialize_self! (_.define (//case.register 0) @self) - initialize! (list\fold (.function (_ post pre!) - ($_ _.then - pre! - (_.define (..input post) (_.at (_.i32 (.int post)) @@arguments)))) - initialize_self! - (list.indices arity))] + initialize! (list\mix (.function (_ post pre!) + ($_ _.then + pre! + (_.define (..input post) (_.at (_.i32 (.int post)) @@arguments)))) + initialize_self! + (list.indices arity))] environment (monad.map ! (expression archive) environment) .let [[definition instantiation] (with_closure @self environment ($_ _.then 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 08a3a7c80..8c3762238 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 @@ -8,7 +8,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [math [number ["n" nat]]] @@ -39,7 +39,7 @@ (_.define variable value) (_.set variable value))))) list.reversed - (list\fold _.then body))) + (list\mix _.then body))) (def: .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) 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 368c69bb0..3ea974987 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 @@ -783,4 +783,4 @@ #.None (|> ..runtime _.code - (\ utf8.codec encode))])]))) + (\ utf8.codec encoded))])]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux index 417f74d2d..928fbb101 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux @@ -10,7 +10,7 @@ ["." i32] ["n" nat]] [collection - ["." list ("#\." fold)]]] + ["." list ("#\." mix)]]] [target [jvm ["_" bytecode (#+ Label Bytecode) ("#\." monad)] @@ -241,16 +241,16 @@ (Generator [(List synthesis.Member) Synthesis]) (do phase.monad [recordG (phase archive recordS)] - (in (list\fold (function (_ step so_far) - (.let [next (.case step - (#.Left lefts) - (..left_projection lefts) - - (#.Right lefts) - (..right_projection lefts))] - (_.composite so_far next))) - recordG - (list.reversed path))))) + (in (list\mix (function (_ step so_far) + (.let [next (.case step + (#.Left lefts) + (..left_projection lefts) + + (#.Right lefts) + (..right_projection lefts))] + (_.composite so_far next))) + recordG + (list.reversed path))))) (def: .public (case phase archive [valueS path]) (Generator [Synthesis Path]) 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 ef53de88c..67c156db0 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 @@ -7,7 +7,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." set]]] [target ["_" lua (#+ Expression Var Statement)]]]] @@ -62,16 +62,16 @@ (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] - (in (list\fold (function (_ side source) - (.let [method (.case side - (^template [<side> <accessor>] - [(<side> lefts) - (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple//left] - [#.Right //runtime.tuple//right]))] - (method source))) - valueO - (list.reversed pathP))))) + (in (list\mix (function (_ side source) + (.let [method (.case side + (^template [<side> <accessor>] + [(<side> lefts) + (<accessor> (_.int (.int lefts)))]) + ([#.Left //runtime.tuple//left] + [#.Right //runtime.tuple//right]))] + (method source))) + valueO + (list.reversed pathP))))) (def: .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) 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 509808d62..88f59675d 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 @@ -10,7 +10,7 @@ [text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [target ["_" lua (#+ Var Expression Label Statement)]]]] ["." // #_ @@ -79,12 +79,12 @@ @scope (..@scope function_name) @self (_.var (///reference.artifact function_name)) initialize_self! (_.local/1 (//case.register 0) @self) - initialize! (list\fold (.function (_ post pre!) - ($_ _.then - pre! - (_.local/1 (..input post) (_.item (|> post ++ .int _.int) @curried)))) - initialize_self! - (list.indices arity)) + initialize! (list\mix (.function (_ post pre!) + ($_ _.then + pre! + (_.local/1 (..input post) (_.item (|> post ++ .int _.int) @curried)))) + initialize_self! + (list.indices arity)) pack (|>> (list) _.array) unpack (_.apply/1 (_.var "table.unpack")) @var_args (_.var "...")] 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 988274333..997030d05 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 @@ -430,4 +430,4 @@ #.None (|> ..runtime _.code - (\ utf8.codec encode))])]))) + (\ utf8.codec encoded))])]))) 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 28744fe33..ccea519f2 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 @@ -8,7 +8,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." set]]] [math [number @@ -83,16 +83,16 @@ (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueG (expression archive valueS)] - (in (list\fold (function (_ side source) - (.let [method (.case side - (^template [<side> <accessor>] - [(<side> lefts) - (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple//left] - [#.Right //runtime.tuple//right]))] - (method source))) - valueG - (list.reversed pathP))))) + (in (list\mix (function (_ side source) + (.let [method (.case side + (^template [<side> <accessor>] + [(<side> lefts) + (<accessor> (_.int (.int lefts)))]) + ([#.Left //runtime.tuple//left] + [#.Right //runtime.tuple//right]))] + (method source))) + valueG + (list.reversed pathP))))) (def: @savepoint (_.var "lux_pm_savepoint")) (def: @cursor (_.var "lux_pm_cursor")) 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 175fadfc3..c749c30f2 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 @@ -10,7 +10,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [target ["_" php (#+ Var Global Expression Argument Label Statement)]]]] ["." // #_ @@ -84,12 +84,12 @@ @selfG (_.global (///reference.artifact function_name)) @selfL (_.var (///reference.artifact function_name)) initialize_self! (_.set! (//case.register 0) @selfL) - initialize! (list\fold (.function (_ post pre!) - ($_ _.then - pre! - (_.set! (..input post) (_.item (|> post .int _.int) @curried)))) - initialize_self! - (list.indices arity))] + initialize! (list\mix (.function (_ post pre!) + ($_ _.then + pre! + (_.set! (..input post) (_.item (|> post .int _.int) @curried)))) + initialize_self! + (list.indices arity))] .let [[definition instantiation] (..with_closure closureG+ @selfG @selfL ($_ _.then (_.set! @num_args (_.func_num_args/0 [])) 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 9f66b15b3..8baa09008 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 @@ -8,7 +8,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." set (#+ Set)]]] [math [number @@ -45,7 +45,7 @@ (let [variable (//case.register (n.+ offset register))] (_.set! variable value)))) list.reversed - (list\fold _.then body))) + (list\mix _.then body))) (def: .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) @@ -89,7 +89,7 @@ (set.of_list _.hash))) [directive instantiation] (: [Statement Expression] (case (|> (list\map referenced_variables initsS+) - (list\fold set.union (referenced_variables bodyS)) + (list\mix set.union (referenced_variables bodyS)) (set.difference loop_variables) set.list) #.End 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 bd36c0785..8dfb51dd7 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 @@ -607,4 +607,4 @@ (row.row [..module_id (|> ..runtime _.code - (\ utf8.codec encode))])]))) + (\ utf8.codec encoded))])]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux index 4426bc6c8..10cb4d3b9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux @@ -8,7 +8,7 @@ [target ["_" python]]]] ["." / #_ - [runtime (#+ Phase Phase!)] + [runtime (#+ Phase)] ["#." primitive] ["#." structure] ["#." reference] @@ -18,7 +18,10 @@ ["/#" // #_ ["#." reference] ["/#" // #_ - ["#." extension] + ["#." extension + [generation + [python + ["#/." common]]]] ["/#" // #_ [analysis (#+)] ["#." synthesis] @@ -27,38 +30,6 @@ [reference (#+) [variable (#+)]]]]]]]) -(def: (statement expression archive synthesis) - Phase! - (case synthesis - (^template [<tag>] - [(^ (<tag> value)) - (//////phase\map _.return (expression archive synthesis))]) - ([////synthesis.bit] - [////synthesis.i64] - [////synthesis.f64] - [////synthesis.text] - [////synthesis.variant] - [////synthesis.tuple] - [#////synthesis.Reference] - [////synthesis.branch/get] - [////synthesis.function/apply] - [#////synthesis.Extension]) - - (^ (////synthesis.branch/case case)) - (/case.case! false statement expression archive case) - - (^template [<tag> <generator>] - [(^ (<tag> value)) - (<generator> statement expression archive value)]) - ([////synthesis.branch/let /case.let!] - [////synthesis.branch/if /case.if!] - [////synthesis.loop/scope /loop.scope!] - [////synthesis.loop/recur /loop.recur!]) - - (^ (////synthesis.function/abstraction abstraction)) - (//////phase\map _.return (/function.function statement expression archive abstraction)) - )) - (exception: .public cannot_recur_as_an_expression) (def: .public (expression archive synthesis) @@ -82,7 +53,7 @@ (//reference.reference /reference.system archive value) (^ (////synthesis.branch/case case)) - (/case.case ..statement expression archive case) + (/case.case ///extension/common.statement expression archive case) (^ (////synthesis.branch/let let)) (/case.let expression archive let) @@ -94,13 +65,13 @@ (/case.get expression archive get) (^ (////synthesis.loop/scope scope)) - (/loop.scope ..statement expression archive scope) + (/loop.scope ///extension/common.statement expression archive scope) (^ (////synthesis.loop/recur updates)) (//////phase.except ..cannot_recur_as_an_expression []) (^ (////synthesis.function/abstraction abstraction)) - (/function.function ..statement expression archive abstraction) + (/function.function ///extension/common.statement expression archive abstraction) (^ (////synthesis.function/apply application)) (/function.apply expression archive application) 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 5d66730d1..6262f0104 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 @@ -7,7 +7,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." set]]] [math [number @@ -88,16 +88,16 @@ (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] - (in (list\fold (function (_ side source) - (.let [method (.case side - (^template [<side> <accessor>] - [(<side> lefts) - (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple::left] - [#.Right //runtime.tuple::right]))] - (method source))) - valueO - (list.reversed pathP))))) + (in (list\mix (function (_ side source) + (.let [method (.case side + (^template [<side> <accessor>] + [(<side> lefts) + (<accessor> (_.int (.int lefts)))]) + ([#.Left //runtime.tuple::left] + [#.Right //runtime.tuple::right]))] + (method source))) + valueO + (list.reversed pathP))))) (def: @savepoint (_.var "lux_pm_savepoint")) (def: @cursor (_.var "lux_pm_cursor")) 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 eee714ea8..f4b31f61d 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 @@ -8,7 +8,7 @@ [text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [target ["_" python (#+ SVar Expression Statement)]]]] ["." // #_ @@ -80,12 +80,12 @@ apply_poly (.function (_ args func) (_.apply_poly (list) args func)) initialize_self! (_.set (list (//case.register 0)) @self) - initialize! (list\fold (.function (_ post pre!) - ($_ _.then - pre! - (_.set (list (..input post)) (_.item (|> post .int _.int) @curried)))) - initialize_self! - (list.indices arity))]] + initialize! (list\mix (.function (_ post pre!) + ($_ _.then + pre! + (_.set (list (..input post)) (_.item (|> post .int _.int) @curried)))) + initialize_self! + (list.indices arity))]] (with_closure function_artifact @self environment (_.def @self (list (_.poly @curried)) ($_ _.then 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 6739e6ec5..50469f64e 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 @@ -8,7 +8,7 @@ [text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." set]]] [math [number @@ -39,7 +39,7 @@ (_.set (list (//case.register (n.+ offset register))) value))) list.reversed - (list\fold _.then body))) + (list\mix _.then body))) (def: .public (set_scope body!) (-> (Statement Any) (Statement Any)) 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 207b74654..9952ea02d 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 @@ -458,4 +458,4 @@ #.None (|> ..runtime _.code - (\ utf8.codec encode))])])))) + (\ utf8.codec encoded))])])))) 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 288fdc4bf..e751e412b 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 @@ -8,7 +8,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." set]]] [macro ["." template]] @@ -66,16 +66,16 @@ (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] - (in (list\fold (function (_ side source) - (.let [method (.case side - (^template [<side> <accessor>] - [(<side> lefts) - (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple::left] - [#.Right //runtime.tuple::right]))] - (method source))) - valueO - (list.reversed pathP))))) + (in (list\mix (function (_ side source) + (.let [method (.case side + (^template [<side> <accessor>] + [(<side> lefts) + (<accessor> (_.int (.int lefts)))]) + ([#.Left //runtime.tuple::left] + [#.Right //runtime.tuple::right]))] + (method source))) + valueO + (list.reversed pathP))))) (def: $savepoint (_.var "lux_pm_cursor_savepoint")) (def: $cursor (_.var "lux_pm_cursor")) @@ -171,10 +171,10 @@ ..peek) then!]))) (#.Item item))] - (in (list\fold (function (_ [when then] else) - (_.if when then else)) - ..fail! - clauses)))]) + (in (list\mix (function (_ [when then] else) + (_.if when then else)) + ..fail! + clauses)))]) ([#/////synthesis.I64_Fork //primitive.i64 //runtime.i64::=] [#/////synthesis.F64_Fork //primitive.f64 _.=] [#/////synthesis.Text_Fork //primitive.text _.=]) 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 4ae6231c5..f2335374c 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 @@ -10,7 +10,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [target ["_" r (#+ Expression SVar)]]]] ["." // #_ @@ -97,7 +97,7 @@ (|> arity list.indices (list\map input_declaration) - (list\fold _.then bodyO)))] + (list\mix _.then bodyO)))] [(|> $num_args (_.> arityO)) (let [arity_args (_.slice (_.int +1) arityO $curried) output_func_args (_.slice (|> arityO (_.+ (_.int +1))) 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 859744980..28ac47ffb 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 @@ -8,7 +8,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor)] ["." set (#+ Set)]]] [math [number 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 21f2ded5a..f0ea2c3fb 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 @@ -850,4 +850,4 @@ (row.row [(%.nat ..module_id) (|> ..runtime _.code - (\ utf8.codec encode))])]))) + (\ utf8.codec encoded))])]))) 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 2af4e0dee..df08d8a21 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 @@ -9,7 +9,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." set]]] [math [number @@ -90,16 +90,16 @@ (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] - (in (list\fold (function (_ side source) - (.let [method (.case side - (^template [<side> <accessor>] - [(<side> lefts) - (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple//left] - [#.Right //runtime.tuple//right]))] - (method source))) - valueO - (list.reversed pathP))))) + (in (list\mix (function (_ side source) + (.let [method (.case side + (^template [<side> <accessor>] + [(<side> lefts) + (<accessor> (_.int (.int lefts)))]) + ([#.Left //runtime.tuple//left] + [#.Right //runtime.tuple//right]))] + (method source))) + valueO + (list.reversed pathP))))) (def: @savepoint (_.local "lux_pm_savepoint")) (def: @cursor (_.local "lux_pm_cursor")) 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 192807829..efc132065 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 @@ -8,7 +8,7 @@ [text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor mix)]]] [target ["_" ruby (#+ LVar GVar Expression Statement)]]]] ["." // #_ @@ -77,12 +77,12 @@ @num_args (_.local "num_args") @self (_.local function_name) initialize_self! (_.set (list (//case.register 0)) @self) - initialize! (list\fold (.function (_ post pre!) - ($_ _.then - pre! - (_.set (list (..input post)) (_.item (|> post .int _.int) @curried)))) - initialize_self! - (list.indices arity)) + initialize! (list\mix (.function (_ post pre!) + ($_ _.then + pre! + (_.set (list (..input post)) (_.item (|> post .int _.int) @curried)))) + initialize_self! + (list.indices arity)) [declaration instatiation] (with_closure closureO+ function_name (_.lambda (#.Some @self) (list (_.variadic @curried)) ($_ _.then 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 9fe46c86d..caf3afb78 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 @@ -8,7 +8,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." set]]] [math [number @@ -39,7 +39,7 @@ (_.set (list (//case.register (n.+ offset register))) value))) list.reversed - (list\fold _.then body))) + (list\mix _.then body))) (def: symbol (_.symbol "lux_continue")) 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 8a825e466..b083c0a67 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 @@ -401,4 +401,4 @@ #.None (|> ..runtime _.code - (\ utf8.codec encode))])]))) + (\ utf8.codec encoded))])]))) 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 ae841dc5b..e68b23464 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 @@ -8,7 +8,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." set]]] [macro ["." template]] @@ -64,16 +64,16 @@ (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] - (in (list\fold (function (_ side source) - (.let [method (.case side - (^template [<side> <accessor>] - [(<side> lefts) - (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple//left] - [#.Right //runtime.tuple//right]))] - (method source))) - valueO - (list.reversed pathP))))) + (in (list\mix (function (_ side source) + (.let [method (.case side + (^template [<side> <accessor>] + [(<side> lefts) + (<accessor> (_.int (.int lefts)))]) + ([#.Left //runtime.tuple//left] + [#.Right //runtime.tuple//right]))] + (method source))) + valueO + (list.reversed pathP))))) (def: @savepoint (_.var "lux_pm_cursor_savepoint")) (def: @cursor (_.var "lux_pm_cursor")) @@ -165,10 +165,10 @@ ..peek) then!]))) (#.Item item))] - (in (list\fold (function (_ [when then] else) - (_.if when then else)) - ..fail! - clauses)))]) + (in (list\mix (function (_ [when then] else) + (_.if when then else)) + ..fail! + clauses)))]) ([#/////synthesis.I64_Fork //primitive.i64 _.=/2] [#/////synthesis.F64_Fork //primitive.f64 _.=/2] [#/////synthesis.Text_Fork //primitive.text _.string=?/2]) 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 58d8b55c6..cfb345097 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 @@ -10,7 +10,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)]]] + ["." list ("#\." functor)]]] [target ["_" scheme (#+ Expression Computation Var)]]]] ["." // #_ 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 fb9add0aa..87ddc4929 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 @@ -8,7 +8,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor)] ["." set (#+ Set)]]] [math [number 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 452da33ef..221ee6d88 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 @@ -367,4 +367,4 @@ (row.row [(%.nat ..module_id) (|> ..runtime _.code - (\ utf8.codec encode))])]))) + (\ utf8.codec encoded))])]))) 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 1a178900e..d2bf439da 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 @@ -11,7 +11,7 @@ ["." bit ("#\." equivalence)] ["." text ("#\." equivalence)] [collection - ["." list ("#\." functor fold monoid)] + ["." list ("#\." functor mix monoid)] ["." set (#+ Set)]]] [math [number @@ -72,22 +72,22 @@ (#///analysis.Complex (#///analysis.Tuple tuple)) (let [tuple::last (-- (list.size tuple))] - (list\fold (function (_ [tuple::lefts tuple::member] nextC) - (.case tuple::member - (#///analysis.Simple #///analysis.Unit) - nextC - - _ - (let [right? (n.= tuple::last tuple::lefts) - end?' (and end? right?)] - (<| (///\map (|>> (#/.Seq (#/.Access (#/.Member (if right? - (#.Right (-- tuple::lefts)) - (#.Left tuple::lefts))))))) - (path' tuple::member end?') - (when> [(new> (not end?') [])] [(///\map ..clean_up)]) - nextC)))) - thenC - (list.reversed (list.enumeration tuple)))) + (list\mix (function (_ [tuple::lefts tuple::member] nextC) + (.case tuple::member + (#///analysis.Simple #///analysis.Unit) + nextC + + _ + (let [right? (n.= tuple::last tuple::lefts) + end?' (and end? right?)] + (<| (///\map (|>> (#/.Seq (#/.Access (#/.Member (if right? + (#.Right (-- tuple::lefts)) + (#.Left tuple::lefts))))))) + (path' tuple::member end?') + (when> [(new> (not end?') [])] [(///\map ..clean_up)]) + nextC)))) + thenC + (list.reversed (list.enumeration tuple)))) )) (def: (path archive synthesize pattern bodyA) @@ -110,7 +110,7 @@ (def: (weave_fork weave equivalence new_fork old_fork) (All [a] (-> (-> Path Path Path) (Equivalence a) (/.Fork a Path) (/.Fork a Path) (/.Fork a Path))) - (list\fold (..weave_branch weave equivalence) old_fork (#.Item new_fork))) + (list\mix (..weave_branch weave equivalence) old_fork (#.Item new_fork))) (def: (weave new old) (-> Path Path Path) @@ -228,7 +228,7 @@ (do {! ///.monad} [headSP (path archive synthesize headP headA) tailSP+ (monad.map ! (product.uncurried (path archive synthesize)) tailPA+)] - (in (/.branch/case [input (list\fold weave headSP tailSP+)])))) + (in (/.branch/case [input (list\mix weave headSP tailSP+)])))) (template: (!masking <variable> <output>) [[[(#///analysis.Bind <variable>) @@ -358,11 +358,11 @@ (#/.Text_Fork forks)) (|> (#.Item forks) (list\map product.right) - (list\fold for_path path_storage)) + (list\mix for_path path_storage)) (^or (^ (/.path/seq left right)) (^ (/.path/alt left right))) - (list\fold for_path path_storage (list left right)) + (list\mix for_path path_storage (list left right)) (^ (/.path/then bodyS)) (loop for_synthesis @@ -373,7 +373,7 @@ (for_synthesis valueS synthesis_storage) (^ (/.tuple members)) - (list\fold for_synthesis synthesis_storage members) + (list\mix for_synthesis synthesis_storage members) (#/.Reference (#///reference.Variable (#///reference/variable.Local register))) (if (set.member? (value@ #bindings synthesis_storage) register) @@ -384,10 +384,10 @@ (revised@ #dependencies (set.has var) synthesis_storage) (^ (/.function/apply [functionS argsS])) - (list\fold for_synthesis synthesis_storage (#.Item functionS argsS)) + (list\mix for_synthesis synthesis_storage (#.Item functionS argsS)) (^ (/.function/abstraction [environment arity bodyS])) - (list\fold for_synthesis synthesis_storage environment) + (list\mix for_synthesis synthesis_storage environment) (^ (/.branch/case [inputS pathS])) (revised@ #dependencies @@ -403,7 +403,7 @@ (for_synthesis inputS synthesis_storage)) (^ (/.branch/if [testS thenS elseS])) - (list\fold for_synthesis synthesis_storage (list testS thenS elseS)) + (list\mix for_synthesis synthesis_storage (list testS thenS elseS)) (^ (/.branch/get [access whole])) (for_synthesis whole synthesis_storage) @@ -417,13 +417,13 @@ (set.of_list n.hash)))) (for_synthesis iterationS) (value@ #dependencies))) - (list\fold for_synthesis synthesis_storage initsS+)) + (list\mix for_synthesis synthesis_storage initsS+)) (^ (/.loop/recur replacementsS+)) - (list\fold for_synthesis synthesis_storage replacementsS+) + (list\mix for_synthesis synthesis_storage replacementsS+) (#/.Extension [extension argsS]) - (list\fold for_synthesis synthesis_storage argsS) + (list\mix for_synthesis synthesis_storage argsS) _ synthesis_storage)) 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 f26b13ade..2aeacc78d 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 @@ -12,7 +12,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor monoid fold)]]] + ["." list ("#\." functor monoid)]]] [math [number ["n" nat]]]]] 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 39082e826..bba61a90f 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 @@ -178,22 +178,24 @@ ... TODO: Stop relying on this custom code. (^ (#/.Extension ["lux syntax char case!" (list& input else matches)])) - (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) - else (recur return? else)] - (in (#/.Extension ["lux syntax char case!" (list& input else matches)]))) + (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) + else (recur return? else)] + (in (#/.Extension ["lux syntax char case!" (list& input else matches)]))) + #.None) (#/.Extension [name args]) (|> args 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 cb647c284..88b2d3f1f 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 @@ -13,7 +13,7 @@ ["%" format]] [collection ["." dictionary (#+ Dictionary)] - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." set]]] [math [number @@ -181,10 +181,10 @@ (-> Register Nat Redundancy [(List Register) Redundancy]) (let [extension (|> amount list.indices (list\map (n.+ offset)))] [extension - (list\fold (function (_ register redundancy) - (dictionary.has register ..necessary! redundancy)) - redundancy - extension)])) + (list\mix (function (_ register redundancy) + (dictionary.has register ..necessary! redundancy)) + redundancy + extension)])) (def: (default arity) (-> Arity Redundancy) @@ -310,10 +310,10 @@ (and (set.member? bindings register) redundant?))) (list\map product.left))]] - (in [(list\fold dictionary.lacks redundancy (set.list bindings)) + (in [(list\mix dictionary.lacks redundancy (set.list bindings)) (|> redundants (list.sorted n.>) - (list\fold (..remove_local_from_path ..remove_local) (#/.Seq pre post)))])) + (list\mix (..remove_local_from_path ..remove_local) (#/.Seq pre post)))])) (#/.Then then) (do try.monad @@ -405,7 +405,7 @@ [[redundancy inits] (..list_optimization optimization' [redundancy inits]) .let [[extension redundancy] (..extended start (list.size inits) redundancy)] [redundancy iteration] (optimization' [redundancy iteration])] - (in [(list\fold dictionary.lacks redundancy extension) + (in [(list\mix dictionary.lacks redundancy extension) (#/.Control (#/.Loop (#/.Scope [start inits iteration])))])) (#/.Recur resets) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux index d4b612bf2..3105f2ad8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -333,7 +333,7 @@ [(case (|> <source_code> (!clip <start> <end>) (text.replaced ..digit_separator "") - (\ <codec> decode)) + (\ <codec> decoded)) (#.Right output) (#.Right [[(let [[where::file where::line where::column] where] [where::file where::line (!n/+ (!n/- <start> <end>) where::column)]) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index d810d7aca..e1ea19e37 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -20,7 +20,7 @@ [format ["." binary (#+ Writer)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." dictionary (#+ Dictionary)] ["." set] ["." row (#+ Row)]]] @@ -198,15 +198,15 @@ :representation (revised@ #next (n.max +next)) (revised@ #resolver (function (_ resolver) - (list\fold (function (_ [module [id entry]] resolver) - (case entry - (#.Some _) - (dictionary.has module [id entry] resolver) - - #.None - resolver)) - resolver - (dictionary.entries +resolver)))) + (list\mix (function (_ [module [id entry]] resolver) + (case entry + (#.Some _) + (dictionary.has module [id entry] resolver) + + #.None + resolver)) + resolver + (dictionary.entries +resolver)))) :abstraction))) (type: Reservation @@ -279,8 +279,8 @@ (correct_reservations? reservations))] (in (:abstraction {#next next - #resolver (list\fold (function (_ [module id] archive) - (dictionary.has module [id #.None] archive)) - (value@ #resolver (:representation ..empty)) - reservations)})))) + #resolver (list\mix (function (_ [module id] archive) + (dictionary.has module [id #.None] archive)) + (value@ #resolver (:representation ..empty)) + reservations)})))) ) 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 e4cc633de..af69bbdc9 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux @@ -14,7 +14,7 @@ ["%" format (#+ format)]] [collection ["." list] - ["." row (#+ Row) ("#\." functor fold)] + ["." row (#+ Row) ("#\." functor mix)] ["." dictionary (#+ Dictionary)]] [format ["." binary (#+ Writer)]]] @@ -145,21 +145,21 @@ _ (<>.failure (exception.error ..invalid_category [tag])))))] (|> (<binary>.row/64 category) - (\ <>.monad map (row\fold (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 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))))) ) 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 6ee936f42..e2a3ef238 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux @@ -13,7 +13,7 @@ ["." text ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." dictionary (#+ Dictionary)] ["." set (#+ Set)]]]]] [/// @@ -46,9 +46,9 @@ (def: .public graph (-> (List Dependency) Graph) - (list\fold (function (_ [module imports] graph) - (dictionary.has module imports graph)) - ..empty)) + (list\mix (function (_ [module imports] graph) + (dictionary.has module imports graph)) + ..empty)) (def: (ancestry archive) (-> Archive Graph) @@ -62,15 +62,15 @@ (#try.Failure error) ..fresh)] ancestors (monad.map ! recur (set.list parents))] - (in (list\fold set.union parents ancestors))))) + (in (list\mix set.union parents ancestors))))) ancestry (memo.open memo)] - (list\fold (function (_ module memory) - (if (dictionary.key? memory module) - memory - (let [[memory _] (ancestry [memory module])] - memory))) - ..empty - (archive.archived archive)))) + (list\mix (function (_ module memory) + (if (dictionary.key? memory module) + memory + (let [[memory _] (ancestry [memory module])] + memory))) + ..empty + (archive.archived archive)))) (def: (dependency? ancestry target source) (-> Graph Module Module Bit) 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 b4fa30d12..45f489e8b 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -19,7 +19,7 @@ ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." dictionary (#+ Dictionary)] ["." row (#+ Row)] ["." set]]] @@ -384,19 +384,19 @@ (-> (List [Bit [Module [archive.ID [Descriptor (Document .Module)]]]]) dependency.Order Purge) - (list\fold (function (_ [module_name [module_id [descriptor document]]] purge) - (let [purged? (: (Predicate Module) - (dictionary.key? purge))] - (if (purged? module_name) - purge - (if (|> descriptor - (value@ #descriptor.references) - set.list - (list.any? purged?)) - (dictionary.has module_name module_id purge) - purge)))) - (..initial_purge caches) - load_order)) + (list\mix (function (_ [module_name [module_id [descriptor document]]] purge) + (let [purged? (: (Predicate Module) + (dictionary.key? purge))] + (if (purged? module_name) + purge + (if (|> descriptor + (value@ #descriptor.references) + set.list + (list.any? purged?)) + (dictionary.has module_name module_id purge) + purge)))) + (..initial_purge caches) + load_order)) (def: pseudo_module Text @@ -422,10 +422,10 @@ [module_name [module_id [descriptor document]]]]))))))) load_order (|> pre_loaded_caches (list\map product.right) - (monad.fold try.monad - (function (_ [module [module_id [descriptor document]]] archive) - (archive.has module [descriptor document (: Output row.empty)] archive)) - archive) + (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) async\in) @@ -442,22 +442,22 @@ bundles])))))] (async\in (do {! try.monad} - [archive (monad.fold ! - (function (_ [[module descriptor,document,output] _bundle] archive) - (archive.has module descriptor,document,output archive)) - archive - loaded_caches) + [archive (monad.mix ! + (function (_ [[module descriptor,document,output] _bundle] archive) + (archive.has module descriptor,document,output archive)) + archive + loaded_caches) analysis_state (..analysis_state (value@ #static.host static) archive)] (in [archive analysis_state - (list\fold (function (_ [_ [+analysers +synthesizers +generators +directives]] - [analysers synthesizers generators directives]) - [(dictionary.merged +analysers analysers) - (dictionary.merged +synthesizers synthesizers) - (dictionary.merged +generators generators) - (dictionary.merged +directives directives)]) - ..empty_bundles - loaded_caches)]))))) + (list\mix (function (_ [_ [+analysers +synthesizers +generators +directives]] + [analysers synthesizers generators directives]) + [(dictionary.merged +analysers analysers) + (dictionary.merged +synthesizers synthesizers) + (dictionary.merged +generators generators) + (dictionary.merged +directives directives)]) + ..empty_bundles + loaded_caches)]))))) (def: .public (thaw host_environment fs static import contexts) (All [expression directive] 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 979edaa76..74d5aab33 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux @@ -127,7 +127,7 @@ (Async (Try Input))) (do (try.with async.monad) [[path binary] (..find_any_source_file fs importer import contexts partial_host_extension module)] - (case (\ utf8.codec decode binary) + (case (\ utf8.codec decoded binary) (#try.Success code) (in {#////.module module #////.file path @@ -145,17 +145,17 @@ (do {! (try.with async.monad)} [enumeration (|> directory (\ fs directory_files) - (\ ! map (monad.fold ! (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)) + (\ ! 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))] (|> directory (\ fs sub_directories) - (\ ! map (monad.fold ! (context_listing fs context) enumeration)) + (\ ! map (monad.mix ! (context_listing fs context) enumeration)) (\ ! join)))) (def: Action @@ -175,14 +175,14 @@ (-> (file.System Async) (List Context) (Action Enumeration)) (let [! (: (Monad Action) (try.with async.monad))] - (monad.fold ! - (function (_ context enumeration) - (do ! - [context (..canonical fs context)] - (..context_listing fs - (format context (\ fs separator)) - context - enumeration))) - (: Enumeration - (dictionary.empty text.hash)) - contexts))) + (monad.mix ! + (function (_ context enumeration) + (do ! + [context (..canonical fs context)] + (..context_listing fs + (format context (\ fs separator)) + context + enumeration))) + (: Enumeration + (dictionary.empty text.hash)) + contexts))) 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 d9707b0c0..ffee37de6 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -154,11 +154,11 @@ (def: (write_module static [module output] sink) (-> Static [archive.ID Output] java/util/jar/JarOutputStream (Try java/util/jar/JarOutputStream)) - (monad.fold try.monad - (function (_ [artifact custom content] sink) - (..write_class static module artifact custom content sink)) - sink - (row.list output))) + (monad.mix try.monad + (function (_ [artifact custom content] sink) + (..write_class static module artifact custom content sink)) + sink + (row.list output))) (def: (read_jar_entry_with_unknown_size input) (-> java/util/jar/JarInputStream [Nat Binary]) @@ -251,14 +251,14 @@ sink (|> order (list\map (function (_ [module [module_id [descriptor document output]]]) [module_id output])) - (monad.fold ! (..write_module static) - (java/util/jar/JarOutputStream::new buffer (..manifest program)))) + (monad.mix ! (..write_module static) + (java/util/jar/JarOutputStream::new buffer (..manifest program)))) [entries duplicates sink] (|> host_dependencies dictionary.values - (monad.fold ! ..write_host_dependency - [(set.empty text.hash) - (set.empty text.hash) - sink])) + (monad.mix ! ..write_host_dependency + [(set.empty text.hash) + (set.empty text.hash) + sink])) .let [_ (do_to sink (java/io/Flushable::flush) (java/io/Closeable::close))]] 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 a229c78a1..f888e6975 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux @@ -14,7 +14,7 @@ ["." encoding]] [collection ["." row] - ["." list ("#\." functor fold)] + ["." list ("#\." functor mix)] ["." dictionary (#+ Dictionary)] ["." set]] [format @@ -58,19 +58,19 @@ (-> Output (Try _.Expression)) (|>> row.list (list\map product.right) - (monad.fold try.monad - (function (_ content so_far) - (|> content - (\ encoding.utf8 decode) - (\ try.monad map - (|>> :expected - (:sharing [directive] - directive - so_far - - directive) - (..then so_far))))) - (: _.Expression (_.manual ""))))) + (monad.mix try.monad + (function (_ content so_far) + (|> content + (\ encoding.utf8 decoded) + (\ try.monad map + (|>> :expected + (:sharing [directive] + directive + so_far + + directive) + (..then so_far))))) + (: _.Expression (_.manual ""))))) (def: module_file (-> archive.ID file.Path) @@ -108,10 +108,10 @@ set.list (list.all (function (_ module) (dictionary.value module mapping))) (list\map (|>> ..module_file _.string _.load_relative/1)) - (list\fold ..then bundle) + (list\mix ..then bundle) (: _.Expression) _.code - (\ encoding.utf8 encode) + (\ encoding.utf8 encoded) tar.content)) module_file (tar.path (..module_file module_id))] (in (#tar.Normal [module_file now ..mode ..ownership entry_content])))) 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 fd6437557..9b49232e3 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux @@ -40,19 +40,19 @@ (|> output row.list (list\map (|>> product.right product.right)) - (monad.fold try.monad - (function (_ content so_far) - (|> content - (\ utf8.codec decode) - (\ try.monad map - (|>> :expected - (:sharing [directive] - directive - so_far - - directive) - (sequence so_far))))) - so_far))) + (monad.mix try.monad + (function (_ content so_far) + (|> content + (\ utf8.codec decoded) + (\ try.monad map + (|>> :expected + (:sharing [directive] + directive + so_far + + directive) + (sequence so_far))))) + so_far))) (def: .public (package header code sequence scope) (All [directive] @@ -67,5 +67,5 @@ (|> order (list\map (function (_ [module [module_id [descriptor document output]]]) [module_id output])) - (monad.fold ! (..write_module sequence) header) - (\ ! map (|>> scope code (\ utf8.codec encode))))))) + (monad.mix ! (..write_module sequence) header) + (\ ! map (|>> scope code (\ utf8.codec encoded))))))) |