From de497378285e195cd722ba25b840982a2d59a282 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 11 May 2024 19:36:29 -0400 Subject: [PATCH] New type for `Type` (part 7). --- .../library/lux/compiler/default/init.lux | 13 +- .../library/lux/compiler/default/platform.lux | 4 +- .../library/lux/compiler/language/lux.lux | 32 +--- .../language/lux/analysis/evaluation.lux | 2 +- .../language/lux/analysis/inference.lux | 2 +- .../compiler/language/lux/analysis/module.lux | 5 +- .../compiler/language/lux/analysis/scope.lux | 4 +- .../compiler/language/lux/analysis/type.lux | 10 +- .../compiler/language/lux/phase/analysis.lux | 20 +-- .../language/lux/phase/analysis/complex.lux | 20 +-- .../language/lux/phase/analysis/function.lux | 2 +- .../language/lux/phase/analysis/when.lux | 22 +-- .../language/lux/phase/declaration.lux | 10 +- .../compiler/language/lux/phase/extension.lux | 4 +- .../lux/phase/extension/analysis/jvm.lux | 8 +- .../lux/phase/extension/analysis/lux.lux | 17 +- .../lux/phase/extension/declaration/jvm.lux | 2 +- .../lux/phase/extension/declaration/lux.lux | 13 +- .../lux/compiler/language/lux/syntax.lux | 24 +-- stdlib/source/library/lux/compiler/type.lux | 157 ++---------------- stdlib/source/library/lux/meta/code.lux | 32 ++-- stdlib/source/projection/lux/meta/code.lux | 10 +- 22 files changed, 122 insertions(+), 291 deletions(-) diff --git a/stdlib/source/library/lux/compiler/default/init.lux b/stdlib/source/library/lux/compiler/default/init.lux index 47fb49dd6..1f44ec04d 100644 --- a/stdlib/source/library/lux/compiler/default/init.lux +++ b/stdlib/source/library/lux/compiler/default/init.lux @@ -110,11 +110,6 @@ [(///translation.Buffer declaration) Registry]) -(the Analysis' (@type.new .Analysis)) -(the Synthesis' (@type.new .Synthesis)) -(the Translation' (@type.new .Translation)) -(the Declaration' (@type.new .Declaration)) - (the (with_analysis_defaults bundle) (-> analysis.Bundle (Operation Any)) @@ -124,7 +119,7 @@ (list.each' ! (function (_ [name handler]) (///declaration.of_analysis - (moduleA.override_definition [.prelude name] [true {@type.#Default [..Analysis' handler]}])))))] + (moduleA.override_definition [.prelude name] [true {@type.#Default [.Analysis handler]}])))))] (in []))) (the (with_synthesis_defaults bundle) @@ -136,7 +131,7 @@ (list.each' ! (function (_ [name handler]) (///declaration.of_analysis - (moduleA.override_definition [.prelude name] [true {@type.#Default [..Synthesis' handler]}])))))] + (moduleA.override_definition [.prelude name] [true {@type.#Default [.Synthesis handler]}])))))] (in []))) (the (with_translation_defaults bundle) @@ -149,7 +144,7 @@ (list.each' ! (function (_ [name handler]) (///declaration.of_analysis - (moduleA.override_definition [.prelude name] [true {@type.#Default [..Translation' handler]}])))))] + (moduleA.override_definition [.prelude name] [true {@type.#Default [.Translation handler]}])))))] (in []))) (the (with_declaration_defaults bundle) @@ -163,7 +158,7 @@ (function (_ [name handler]) (do ! [_ (///declaration.of_analysis - (moduleA.override_definition [.prelude name] [true {@type.#Default [..Declaration' handler]}]))] + (moduleA.override_definition [.prelude name] [true {@type.#Default [.Declaration handler]}]))] (in [])))))] (in []))) diff --git a/stdlib/source/library/lux/compiler/default/platform.lux b/stdlib/source/library/lux/compiler/default/platform.lux index 73e1b6b05..aa344c518 100644 --- a/stdlib/source/library/lux/compiler/default/platform.lux +++ b/stdlib/source/library/lux/compiler/default/platform.lux @@ -771,9 +771,9 @@ module.binding#export (phase.value analysis_state) future#in)] - (future#in (if (check.< ..Custom (@type.old /#type)) + (future#in (if (check.< ..Custom /#type) {try.#Success [context (list.as_stack (its compiler.#parameters it)) /#value]} - (exception.except ..invalid_custom_compiler [/#definition (@type.old /#type)])))))) + (exception.except ..invalid_custom_compiler [/#definition /#type])))))) (the .public (compile program global lux_compiler phase_wrapper import file_context extender expander platform compilation context all_extensions) diff --git a/stdlib/source/library/lux/compiler/language/lux.lux b/stdlib/source/library/lux/compiler/language/lux.lux index 7b6c99ac3..952900b94 100644 --- a/stdlib/source/library/lux/compiler/language/lux.lux +++ b/stdlib/source/library/lux/compiler/language/lux.lux @@ -23,26 +23,12 @@ ["[0]" signature] ["[0]" key (.only Key)]]]]]) -... TODO: Remove ASAP -(the type_as_binary - (Injection @type.Type) - (<| _.rec - (function (_ type)) - (all _.or - (_.and _.text (_.list (_.and _.bit type))) - (_.and _.bit _.natural) - _.natural - _.natural - (all _.and _.bit (_.stack (_.and type type)) type) - (_.and type type) - (_.and (_.and _.text _.text) type)))) - ... TODO: Remove #module_hash, #imports & #module_state ASAP. ... TODO: Not just from this projection, but from the lux.Module type. (the .public as_binary (Injection @type.Module) (let [definition (is (Injection @type.Definition) - (all _.and ..type_as_binary _.any)) + (all _.and _.type _.any)) alias (is (Injection @type.Alias) (_.and _.text _.text)) global (is (Injection @type.Global) @@ -62,25 +48,11 @@ ... #module_state _.any))) -... TODO: Remove ASAP -(the type_of_binary - (Projection @type.Type) - (<| <>.rec - (function (_ type)) - (all <>.or - (<>.and .text (.list (<>.and .bit type))) - (<>.and .bit .natural) - .natural - .natural - (all <>.and .bit (.stack (<>.and type type)) type) - (<>.and type type) - (<>.and (<>.and .text .text) type)))) - (the .public of_binary (Projection @type.Module) (let [definition (is (Projection @type.Definition) (all <>.and - ..type_of_binary + .type .any)) alias (is (Projection @type.Alias) (all <>.and diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis/evaluation.lux b/stdlib/source/library/lux/compiler/language/lux/analysis/evaluation.lux index a28879499..310c405a1 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/evaluation.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/evaluation.lux @@ -60,7 +60,7 @@ Eval)) (function (eval archive type exprC) (do phase.monad - [exprA (<| (//type.expecting (@type.old type)) + [exprA (<| (//type.expecting type) //scope.reset (analysis archive exprC)) module module.current_name diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis/inference.lux b/stdlib/source/library/lux/compiler/language/lux/analysis/inference.lux index 38243ce0d..0d4dff08a 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/inference.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/inference.lux @@ -127,7 +127,7 @@ {.#Quantification .existential _} (do phase.monad [:ex: /type.existential] - (general' variables archive analyse (maybe.trusted (type.reified (list (@type.old :ex:)) inferT)) args)) + (general' variables archive analyse (maybe.trusted (type.reified (list :ex:) inferT)) args)) {.#Reification inputT transT} (when (type.reified (list inputT) transT) diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis/module.lux b/stdlib/source/library/lux/compiler/language/lux/analysis/module.lux index c278b2318..8ba437324 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/module.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/module.lux @@ -131,7 +131,7 @@ {try.#Success [exported? {@type.#Definition [def_type def_value]}]} (if (.or (text.= this_module_name (name.module it)) exported?) - (if (type.= ,type (@type.old def_type)) + (if (type.= ,type def_type) (in (as @type.Label def_value)) (/.except ,not_a [it])) (/.except ,cannot_access [it this_module_name])) @@ -181,8 +181,7 @@ (macro de_aliased) {@type.#Definition [def_type def_value]} - (if (or (type.= @type.Macro (@type.old def_type)) - (type.= .Macro (@type.old def_type))) + (if (type.= @type.Macro def_type) {try.#Success [lux (as Macro def_value)]} {try.#Failure "..not_a_macro"}) diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis/scope.lux b/stdlib/source/library/lux/compiler/language/lux/analysis/scope.lux index 9102dbe73..404e0961b 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/scope.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/scope.lux @@ -116,7 +116,7 @@ (stack.reversed inner)) scopes (stack#composite inner' outer)] {.#Right [(has @type.#scopes scopes state) - {.#Some [(@type.old ref_type) ref]}]}) + {.#Some [ref_type ref]}]}) )))) (exception.the .public no_scope) @@ -134,7 +134,7 @@ new_head (revised @type.#locals (is (Change Local) (|>> (revised @type.#counter ++) - (revised @type.#mappings (property.has name [(@type.new type) new_var_id])))) + (revised @type.#mappings (property.has name [type new_var_id])))) head)] (when (phase.value' (has @type.#scopes {.#Top new_head tail} state) action) diff --git a/stdlib/source/library/lux/compiler/language/lux/analysis/type.lux b/stdlib/source/library/lux/compiler/language/lux/analysis/type.lux index fb2239194..1bc0338e6 100644 --- a/stdlib/source/library/lux/compiler/language/lux/analysis/type.lux +++ b/stdlib/source/library/lux/compiler/language/lux/analysis/type.lux @@ -35,9 +35,9 @@ (-> (Check it) (Operation it))) (function (_ state) - (when (action (@type.old_type_context (its @type.#type_context state))) + (when (action (its @type.#type_context state)) {try.#Success [context' output]} - {try.#Success [(has .#type_context (@type.new_type_context context') state) + {try.#Success [(has .#type_context context' state) output]} {try.#Failure error} @@ -73,14 +73,14 @@ (Change (Operation it)))) (phase.localized (its @type.#expected) (has @type.#expected) - (function.constant {.#Some (@type.new expected)}))) + (function.constant {.#Some expected}))) (the .public fresh (for_any (_ it) (Change (Operation it))) (phase.localized (its @type.#type_context) (has @type.#type_context) - (function.constant (@type.new_type_context check.fresh_context)))) + (function.constant check.fresh_context))) (exception.the .public no_expectation) @@ -100,7 +100,7 @@ (Operation Any)) (do phase.monad [expectedT ..expectation] - (..check (check.check (@type.old expectedT) actualT) + (..check (check.check expectedT actualT) ... (do [! check.monad] ... [pre check.context ... it (check.check expectedT actualT) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/analysis.lux b/stdlib/source/library/lux/compiler/language/lux/phase/analysis.lux index a2925efef..bf094ac2e 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/analysis.lux @@ -130,10 +130,10 @@ (if (text.contains? (its exception.#label extension.defaults_cannot_be_referenced) error) (when term - (@type.#Name _ ["" _]) + {@type.#Name _ ["" _]} (..not_an_abstraction term) - (@type.#Name _ it) + {@type.#Name _ it} (in it) _ @@ -200,10 +200,10 @@ ... In order to allow macros to reference any definition their owning module can see, when programmatically generating a name, they set themselves ... as the module in the name's provenance. ... The compiler then picks that up as the `quoted_module`, and uses it for name resolution in order to guarantee visibility of names in the expansion. - (@type.#Name [quoted_module _line _row] it) + {@type.#Name [quoted_module _line _row] it} (/reference.reference extender analysis archive quoted_module it) - (@type.#Form _ elems) + {@type.#Form _ elems} (when (list.as_stack elems) (stack.partial functionC argsC+) (..reification extender expander analysis archive functionC argsC+) @@ -211,25 +211,25 @@ _ failure) - (@type.#Variant _ elems) + {@type.#Variant _ elems} (when (list.as_stack elems) - (stack.partial (@type.#Name _ tag) values) + (stack.partial {@type.#Name _ tag} values) (..variant_analysis analysis archive tag (list.of_stack values)) - (stack.partial (@type.#Bit _ right?) values) + (stack.partial {@type.#Bit _ right?} values) (..sum_analysis analysis archive 0 right? (list.of_stack values)) - (stack.partial (@type.#Natural _ lefts) (@type.#Bit _ right?) values) + (stack.partial {@type.#Natural _ lefts} {@type.#Bit _ right?} values) (..sum_analysis analysis archive lefts right? (list.of_stack values)) _ failure) - (@type.#Tuple _ elems) + {@type.#Tuple _ elems} (/complex.record analysis archive (list.as_stack elems)) (,, (template.with [ ] - [( _ value) + [{ _ value} ( value)] [@type.#Text /simple.text] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/complex.lux index a6566b02b..7497195c7 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/complex.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/complex.lux @@ -117,7 +117,7 @@ (-> Phase Natural Bit Phase) (function (again valueC) (do [! phase.monad] - [expectedT (by ! each @type.old /type.expectation) + [expectedT /type.expectation expectedT' (/type.check (check.clean (stack) expectedT)) @ /.provenance here module.current_name] @@ -196,10 +196,10 @@ {.#None} (in [0 false])) expectedT /type.expectation] - (when (@type.old expectedT) + (when expectedT {.#Variable _} (do ! - [inferenceT (/inference.variant lefts right? (@type.old variantT)) + [inferenceT (/inference.variant lefts right? variantT) [inferredT valueA+] (/inference.general archive analyse inferenceT (stack valueC)) @ /.provenance] (in (/.variant @ [lefts right? (|> valueA+ stack.head try.trusted)]))) @@ -250,7 +250,7 @@ (-> Phase Archive (Stack @type.Code) (Operation /.Term)) (do [! phase.monad] - [expectedT (by ! each @type.old /type.expectation) + [expectedT /type.expectation here module.current_name] (/.with_exception ..cannot_analyse_tuple [here expectedT (list.of_stack membersC)] (when expectedT @@ -328,14 +328,14 @@ output (is (Stack [Name @type.Code]) {.#Empty})]) (when input - (stack.partial (@type.#Name _ ["" slotH]) valueH tail) + (stack.partial {@type.#Name _ ["" slotH]} valueH tail) (if pattern_matching? (phase#in {.#None}) (do phase.monad [slotH (module.normal ["" slotH])] (again tail {.#Top [slotH valueH] output}))) - (stack.partial (@type.#Name _ slotH) valueH tail) + (stack.partial {@type.#Name _ slotH} valueH tail) (do phase.monad [slotH (module.normal slotH)] (again tail {.#Top [slotH valueH] output})) @@ -363,7 +363,7 @@ (the (slot_type [[_ it] _]) (-> [@type.Label @type.Code] Type) - (@type.old it)) + it) (the (same_record? it) (Predicate (Stack [@type.Label @type.Code])) @@ -435,7 +435,7 @@ [[[_ :record:] _] (stack.head record)] (in [(stack.size record) (stack#each product.right record) - (@type.old :record:)]))))) + :record:]))))) {try.#Failure error} (in {.#None})))) @@ -472,7 +472,7 @@ (stack singletonC) (analyse archive singletonC) - (stack (@type.#Name _ pseudo_slot) singletonC) + (stack {@type.#Name _ pseudo_slot} singletonC) (do [! phase.monad] [head_k (module.normal pseudo_slot) slot (phase.try (module.slot head_k))] @@ -505,7 +505,7 @@ {.#Some [record_size membersC recordT]} (do ! [expectedT /type.expectation] - (when (@type.old expectedT) + (when expectedT {.#Variable _} (do ! [inferenceT (/inference.record record_size recordT) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/function.lux index 3500993c2..e491bfe6a 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/function.lux @@ -62,7 +62,7 @@ (-> Phase Text Text Phase) (do [! phase.monad] - [functionT (by ! each @type.old /type.expectation) + [functionT /type.expectation here module.current_name] (loop (again [expectedT functionT]) (/.with_exception ..cannot_analyse [here expectedT function_name arg_name body] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/when.lux b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/when.lux index f7868a57b..894c1db60 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/analysis/when.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/analysis/when.lux @@ -390,7 +390,7 @@ [here module.current_name] (/.except ..invalid [here pattern]))] (`` (.when pattern - (@type.#Name provenance ["" name]) + {@type.#Name provenance ["" name]} (/.with_provenance provenance (do phase.monad [outputA (/scope.with_local [name :input:] @@ -399,7 +399,7 @@ (in [{/pattern.#Bind idx} outputA]))) (,, (template.with [ ,tag ] - [(,tag provenance ) + [{,tag provenance } (simple_pattern_analysis :input: provenance {/pattern.#Simple } next)] [@type.Bit @type.#Bit pattern_value {/simple.#Bit pattern_value}] @@ -410,10 +410,10 @@ [@type.Text @type.#Text pattern_value {/simple.#Text pattern_value}] [Any @type.#Tuple (.list) {/simple.#Unit}])) - (@type.#Tuple provenance (.list singleton)) + {@type.#Tuple provenance (.list singleton)} (pattern_analysis :input: singleton next) - (@type.#Tuple provenance sub_patterns) + {@type.#Tuple provenance sub_patterns} (/.with_provenance provenance (do [! phase.monad] [record (//complex.normal true (list.as_stack sub_patterns)) @@ -447,28 +447,28 @@ {.#None} (..tuple_pattern_analysis pattern_analysis :input: (list.as_stack sub_patterns) next)))) - (@type.#Form provenance every_item) + {@type.#Form provenance every_item} (.when (list.as_stack every_item) - (stack.partial (@type.#Name provenance [.prelude extension.list]) sub_patterns) + (stack.partial {@type.#Name provenance [.prelude extension.list]} sub_patterns) (/.with_provenance provenance (..analysis_of_list pattern_analysis :input: sub_patterns next)) _ failure) - (@type.#Variant provenance every_item) + {@type.#Variant provenance every_item} (.when (list.as_stack every_item) - (stack.partial (@type.#Bit _ right?) values) + (stack.partial {@type.#Bit _ right?} values) (anonymous_variant pattern_analysis :input: pattern next provenance 0 right? values) - (stack.partial (@type.#Natural _ lefts) (@type.#Bit _ right?) values) + (stack.partial {@type.#Natural _ lefts} {@type.#Bit _ right?} values) (anonymous_variant pattern_analysis :input: pattern next provenance lefts right? values) - (stack.partial (@type.#Name _ tag) values) + (stack.partial {@type.#Name _ tag} values) (/.with_provenance provenance (do phase.monad [tag (module.normal tag) @@ -479,7 +479,7 @@ {.#None} [0 false])) - _ (/type.check (check.check :input: (@type.old variantT)))] + _ (/type.check (check.check :input: variantT))] (pattern_analysis :input: (code.variant (.list (code.natural lefts) (code.bit right?) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/declaration.lux b/stdlib/source/library/lux/compiler/language/lux/phase/declaration.lux index b4c903c97..0d73136a2 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/declaration.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/declaration.lux @@ -92,16 +92,16 @@ (if (text.contains? (its exception.#label extension.defaults_cannot_be_referenced) error) (when function_term - (@type.#Name _ definition) + {@type.#Name _ definition} (in definition) _ (//.except ..not_a_declaration [here function_term])) (//.except ..not_a_declaration [here function_term]))))) -(expansion.let [ (these (@type.#Form @module - (list (@type.#Name @extension [..prelude "module#"]) - (@type.#Tuple @annotations annotations))))] +(expansion.let [ (these {@type.#Form @module + (list {@type.#Name @extension [..prelude "module#"]} + {@type.#Tuple @annotations annotations})})] (the .public (phase wrapper extender expander) (for_any (_ anchor expression declaration) (-> //.Wrapper (Extender anchor expression declaration) Expander @@ -123,7 +123,7 @@ (//.except ..not_a_declaration [here code]))] _ (//.with (has [/.#analysis /.#state @type.#eval] extension_eval state))] (when code - (@type.#Form _ it) + {@type.#Form _ it} (when (list.as_stack it) (stack.partial term inputs) (do ! diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension.lux index 0f16621d3..d32fd15ee 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension.lux @@ -148,9 +148,9 @@ (Operation @type.Lux Value)) (do phase.monad [[actual_type value] (global_value name)] - (if (check.< expected_type (@type.old actual_type)) + (if (check.< expected_type actual_type) (in value) - (phase.except ..invalid [name expected_type (@type.old actual_type)])))) + (phase.except ..invalid [name expected_type actual_type])))) (the .public (reification extender lux phase archive diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/jvm.lux index bceab0c63..67dd779a6 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -551,7 +551,7 @@ (do [! phase.monad] [lengthA (<| (typeA.expecting ..int) (analyse archive lengthC)) - expectedT (by ! each @type.old typeA.expectation) + expectedT typeA.expectation expectedJT (jvm_array_type expectedT) elementJT (when (projection.array? expectedJT) {.#Some elementJT} @@ -862,7 +862,7 @@ (function (_ extension_name analyse archive []) (do phase.monad [expectedT typeA.expectation - [_ :object:] (check_object (@type.old expectedT)) + [_ :object:] (check_object expectedT) _ (typeA.inference :object:) @ analysis.provenance] (in [@ {analysis.#Extension [.prelude (text extension_name "|translation")] @@ -985,7 +985,7 @@ [?list.any (function (_ extension_name analyse archive [fromC]) (do [! phase.monad] - [toT (by ! each @type.old typeA.expectation) + [toT typeA.expectation toJT (check_jvm toT) [fromT fromA] (typeA.inferring (analyse archive fromC)) @@ -2655,7 +2655,7 @@ {#Constant [name annotations type value]} (`` (when value (,, (template.with [ ] - [( _ value) + [{ _ value} (do pool.monad [constant (`` (|> value (,, (template.spliced )))) attribute (attribute.constant constant)] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lux.lux index cffd7b8b1..9ee6939e6 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/analysis/lux.lux @@ -167,7 +167,7 @@ (do [! phase.monad] [input (<| (typeA.expecting @type.Character) (analysis archive input)) - expectedT (by ! each @type.old typeA.expectation) + expectedT typeA.expectation conditionals (list.each' ! (.function (_ [cases branch]) (<| (by ! each (|>> [cases])) (typeA.expecting expectedT) @@ -220,7 +220,7 @@ [(?.and ?list.any ?list.any) (.function (_ extension_name analysis archive [module 'expression]) (do [! phase.monad] - [module (eval archive (@type.new @type.Text) module)] + [module (eval archive @type.Text module)] (analysis.with_current_module (as Text module) (analysis archive (code.with [(as Text module) 0 0] 'expression)))))])) @@ -231,8 +231,8 @@ [(?.and ?list.any ?list.any) (.function (_ extension_name analysis archive [typeC valueC]) (do [! phase.monad] - [actualT (by ! each (|>> (as @type.Type) @type.old) - (eval archive (@type.new @type.Type) typeC)) + [actualT (by ! each (|>> (as @type.Type)) + (eval archive @type.Type typeC)) _ (typeA.inference actualT)] (<| (typeA.expecting actualT) (analysis archive valueC))))])) @@ -244,9 +244,8 @@ [(?.and ?list.any ?list.any) (.function (_ extension_name analysis archive [typeC valueC]) (do [! phase.monad] - [actualT (by ! each (|>> (as @type.Type) @type.old) - (eval archive (@type.new @type.Type) typeC)) - _ (typeA.inference actualT) + [actualT (eval archive @type.Type typeC) + _ (typeA.inference (as @type.Type actualT)) [valueT valueA] (typeA.inferring (analysis archive valueC))] (in valueA)))])) @@ -275,7 +274,7 @@ (-> Name @type.Default (Operation it))) (do phase.monad - [_ (typeA.inference (@type.old type))] + [_ (typeA.inference type)] (analysis.except ///.defaults_cannot_be_referenced [name]))) (the .public global @@ -302,7 +301,7 @@ {@type.#Definition [type _]} (do ! - [_ (typeA.inference (@type.old type)) + [_ (typeA.inference type) @ analysis.provenance] (in (analysis.constant @ def_name))) diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/jvm.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/jvm.lux index dc9f14192..415061526 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/jvm.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/jvm.lux @@ -244,7 +244,7 @@ {#Constant [name annotations type value]} (`` (when value (,, (template.with [ ] - [( _ value) + [{ _ value} (do pool.monad [constant (`` (|> value (,, (template.spliced )))) attribute (attribute.constant constant)] diff --git a/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/lux.lux b/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/lux.lux index 79fbd0cb8..10ed1aa87 100644 --- a/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/lux.lux +++ b/stdlib/source/library/lux/compiler/language/lux/phase/extension/declaration/lux.lux @@ -166,8 +166,6 @@ (synthesis archive codeA))] (definition' archive translation name code//type codeS))) -(the Analysis' (@type.new .Analysis)) - ... TODO: Get rid of this function ASAP. (the refresh (for_any (_ anchor expression declaration) @@ -181,9 +179,9 @@ (its [/////declaration.#translation /////declaration.#phase] state)])] _ (<| /////declaration.of_analysis (do ! - [_ (module.override_definition [.prelude "in_module#"] [true {@type.#Default [..Analysis' (analysisE.in_module#_extension eval "in_module#")]}]) - _ (module.override_definition [.prelude "is#"] [true {@type.#Default [..Analysis' (analysisE.is#_extension eval "is#")]}]) - _ (module.override_definition [.prelude "as#"] [true {@type.#Default [..Analysis' (analysisE.as#_extension eval "as#")]}])] + [_ (module.override_definition [.prelude "in_module#"] [true {@type.#Default [.Analysis (analysisE.in_module#_extension eval "in_module#")]}]) + _ (module.override_definition [.prelude "is#"] [true {@type.#Default [.Analysis (analysisE.is#_extension eval "is#")]}]) + _ (module.override_definition [.prelude "as#"] [true {@type.#Default [.Analysis (analysisE.as#_extension eval "as#")]}])] (in [])))] (in []))) @@ -193,7 +191,7 @@ [(all <>.and .local ?list.any ?list.any) (function (_ phase archive [short_name valueC exported?C]) (when valueC - (@type.#Name _ original) + {@type.#Name _ original} (do phase.monad [_ ..refresh state phase.state @@ -222,8 +220,7 @@ [type valueT value] (..definition archive full_name valueC) [_ _ exported?] (evaluate! archive @type.Bit exported?C) _ (<| /////declaration.of_analysis - (module.define short_name [(as Bit exported?) {@type.#Definition [(@type.new type) - value]}]))] + (module.define short_name [(as Bit exported?) {@type.#Definition [type value]}]))] (in /////declaration.no_requirements))))])) (the imports diff --git a/stdlib/source/library/lux/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/compiler/language/lux/syntax.lux index 11d473047..9908ca632 100644 --- a/stdlib/source/library/lux/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/compiler/language/lux/syntax.lux @@ -293,9 +293,9 @@ [(inlined (,as where numerator denominator) (-> Provenance ,numerator_type Natural @type.Code) - (@type.#Form where (list (@type.#Name where [.prelude ,extension]) - (,numerator_tag where numerator) - (@type.#Natural where denominator))))] + {@type.#Form where (list {@type.#Name where [.prelude ,extension]} + {,numerator_tag where numerator} + {@type.#Natural where denominator})})] [as_fraction fraction.extension Natural @type.#Natural] [as_rational rational.extension Integer @type.#Integer] @@ -342,7 +342,7 @@ [where::file where::line (!n/+ (!n/- ) where::column)]) @code] - ( where output)) + { where output}) {.#Left error} (..failure [where @code] @@ -393,7 +393,7 @@ (the !implicit_name (template.macro (_ the_globals source where tag) [(!letE [source' name] (..implicit_name the_globals source) - (..success source' (tag where name)))])) + (..success source' {tag where name}))])) (expansion.let [ (..success source' ["" simple])] (`` (the (full_name_projection the_globals aliases start source) @@ -419,7 +419,7 @@ (the !full_name_projection (template.macro (_ the_globals offset source where aliases tag) [(!letE [source' full_name] (..full_name_projection the_globals aliases offset source) - (..success source' (tag where full_name)))])) + (..success source' {tag where full_name}))])) (inlined (natural the_globals start where offset) (-> types_of_the_globals Offset Provenance Offset @@ -466,7 +466,7 @@ (<| (!letE [[where' numerator_end _] numerator] (..value the_globals where start end decimal.base_10)) (let [denominator (n.decimal (its unit.#factor ,unit))]) (..success [where' (after numerator_end) @code] - (@type.#Decimal where (decimal./ denominator numerator))))] + {@type.#Decimal where (decimal./ denominator numerator)}))] [unit.degree] [unit.gradian] @@ -478,8 +478,8 @@ [[(,, (static.text (its unit.#suffix ,unit)))] (<| (!letE [[where' numerator_end _] numerator] (..value the_globals where start end decimal.base_10)) (..success [where' (after numerator_end) @code] - (@type.#Decimal where (decimal.* (its unit.#factor ,unit) - numerator))))] + {@type.#Decimal where (decimal.* (its unit.#factor ,unit) + numerator)}))] [unit.radian] [unit.turn] @@ -607,7 +607,7 @@ (..failure source' error) (if (same? error) - (..success source' ( where (list.of_stack (stack.reversed stack)))) + (..success source' { where (list.of_stack (stack.reversed stack))}) (..failure source' error)))))] ... Form and tuple syntax is mostly the same, differing only in the @@ -639,7 +639,7 @@ (revised .#column (|>> (!n/+ size) (!n/+ 2)) where)) (after 'end) @code] - (@type.#Text where 'content))) + {@type.#Text where 'content})) _ (!failure the_globals where offset))) @@ -663,7 +663,7 @@ (..success [(revised .#column (|>> after/2) where) (after/2 offset/0) @code] - (@type.#Bit where value))) + {@type.#Bit where value})) (the .public (parse @code @module aliases) (-> Source_Code module.Name Aliases diff --git a/stdlib/source/library/lux/compiler/type.lux b/stdlib/source/library/lux/compiler/type.lux index db70caa0d..fc7060b8c 100644 --- a/stdlib/source/library/lux/compiler/type.lux +++ b/stdlib/source/library/lux/compiler/type.lux @@ -3,9 +3,7 @@ (.using [library - [lux (.except Polarity contra_variant co_variant - - Module Name + [lux (.except Module Name Bit Text text Decimal @@ -52,8 +50,7 @@ ["[0]" product] [collection ["[0]" list (.use "[1]#[0]" functor) - ["[0]" property (.use "[1]#[0]" functor)]] - ["[0]" stack (.use "[1]#[0]" monad)]]] + ["[0]" property]]]] [meta ["[0]" name]] ["[0]" function] @@ -162,96 +159,6 @@ {#Reification (Type _) (Type _)} {#Named ..Name (Type _)})) -(the .public (old it) - (-> ..Type - .Type) - it - ... (`` (when it - ... {#Nominal name parameters} - ... {.#Nominal name (|> parameters - ... (list#each (.function (_ [polarity it]) - ... [polarity (old it)])))} - - ... {#Reification left right} - ... {.#Reification (old left) (old right)} - - ... {#Parameter parameter it} - ... {.#Parameter (|> it - ... (n.* 2) - ... (n.+ (when parameter - ... .abstraction 0 - ... .argument 1)))} - - ... (,, (with_template [,new ,old] - ... [{,new it} - ... {,old it}] - - ... [#Variable .#Variable] - ... [#Opaque .#Opaque] - ... )) - - ... {#Quantification quantification closure body} - ... {.#Quantification quantification - ... (|> closure - ... (stack#each (.function (_ [abstraction argument]) - ... (stack (old abstraction) (old argument)))) - ... stack#conjoint) - ... (old body)} - - ... (,, (with_template [,new ,old] - ... [{,new name body} - ... {,old name (old body)}] - - ... [#Named .#Named] - ... )) - ... )) - ) - -(the .public (new it) - (-> .Type - ..Type) - it - ... (`` (when it - ... {.#Nominal name parameters} - ... {#Nominal name (|> parameters - ... (list#each (.function (_ [polarity it]) - ... [polarity (new it)])))} - - ... {.#Reification left right} - ... {#Reification (new left) (new right)} - - ... {.#Parameter it} - ... (let [[it parameter] (n./% 2 it)] - ... {#Parameter (n.= 1 parameter) it}) - - ... (,, (with_template [,new ,old] - ... [{,old it} - ... {,new it}] - - ... [#Variable .#Variable] - ... [#Opaque .#Opaque] - ... )) - - ... {.#Quantification quantification closure body} - ... {#Quantification quantification - ... (loop (new_closure [closure closure]) - ... (when closure - ... (stack.partial abstraction argument closure) - ... (stack.partial [(new abstraction) (new argument)] - ... (new_closure closure)) - - ... else - ... (stack))) - ... (new body)} - - ... (,, (with_template [,new ,old] - ... [{,old name body} - ... {,new name (new body)}] - - ... [#Named .#Named] - ... )))) - ) - (the .public Character .Type ..Natural) @@ -265,45 +172,17 @@ [(And ..Provenance ,it)])) (every .public (Code _) - (let [Code (type (Code _))] - (Or - ... #Bit - (Code' ..Bit) - ... #Natural - (Code' ..Natural) - ... #Integer - (Code' ..Integer) - ... #Revolution - (Code' ..Revolution) - ... #Decimal - (Code' ..Decimal) - ... #Text - (Code' ..Text) - ... #Name - (Code' ..Name) - ... #Form - (Code' (List' Code)) - ... #Variant - (Code' (List' Code)) - ... #Tuple - (Code' (List' Code))))) - -(with_template [,right? ,lefts ,tag] - [(the .public ,tag - (<| (template#macro (_ ,where ,it)) - [{,lefts ,right? [,where ,it]}]))] - - [#0 0 #Bit] - [#0 1 #Natural] - [#0 2 #Integer] - [#0 3 #Revolution] - [#0 4 #Decimal] - [#0 5 #Text] - [#0 6 #Name] - [#0 7 #Form] - [#0 8 #Variant] - [#1 8 #Tuple] - ) + (Variant + {#Bit (Code' ..Bit)} + {#Natural (Code' ..Natural)} + {#Integer (Code' ..Integer)} + {#Revolution (Code' ..Revolution)} + {#Decimal (Code' ..Decimal)} + {#Text (Code' ..Text)} + {#Name (Code' ..Name)} + {#Form (Code' (List' (Code _)))} + {#Variant (Code' (List' (Code _)))} + {#Tuple (Code' (List' (Code _)))})) (the Maybe (<| (template#macro (_ ,it)) @@ -367,16 +246,6 @@ #var_counter ..Natural #var_bindings (..List' [..Natural (..Maybe ..Type)])])) -(the .public old_type_context - (-> ..Type_Context - .Type_Context) - (revised ..#var_bindings (list#each (product.then function.identity (maybe#each ..old))))) - -(the .public new_type_context - (-> .Type_Context - ..Type_Context) - (revised .#var_bindings (list#each (product.then function.identity (maybe#each ..new))))) - (every .public Lux (Record [#info ..Info diff --git a/stdlib/source/library/lux/meta/code.lux b/stdlib/source/library/lux/meta/code.lux index 0a4192d5c..8de75ae21 100644 --- a/stdlib/source/library/lux/meta/code.lux +++ b/stdlib/source/library/lux/meta/code.lux @@ -31,7 +31,7 @@ [(the .public (-> /.Code) - (|>> ( provenance.dummy)))] + (|>> { provenance.dummy}))] [bit /.Bit /.#Bit] [natural /.Natural /.#Natural] @@ -46,7 +46,7 @@ [(the .public (-> /.Code) - (|>> ( provenance.dummy)))] + (|>> { provenance.dummy}))] [form (/.List /.Code) /.#Form] [variant (/.List /.Code) /.#Variant] @@ -57,7 +57,7 @@ (-> /.Text /.Code) (|>> [""] - (/.#Name provenance.dummy))) + {/.#Name provenance.dummy})) (`` (the .public equivalence (Equivalence /.Code) @@ -65,7 +65,7 @@ (the (= x y) (when [x y] (,, (with_template [ ] - [[( _ x) ( _ y)] + [[{ _ x} { _ y}] (by = x y)] [/.#Bit bit.equivalence] @@ -77,7 +77,7 @@ [/.#Name name.equivalence])) (,, (with_template [] - [[( _ xs) ( _ ys)] + [[{ _ xs} { _ ys}] (by (list.equivalence =) = xs ys)] [/.#Form] @@ -94,7 +94,7 @@ (text.Injection /.Code) (`` (when it (,, (with_template [ ] - [( _ value) + [{ _ value} (by as value)] [/.#Bit bit.text] @@ -104,11 +104,11 @@ [/.#Decimal decimal.base_10] [/.#Name name.absolute])) - (/.#Text _ value) + {/.#Text _ value} (text.as_text value) (,, (with_template [ ] - [( _ members) + [{ _ members} (.text (list#mix (function (_ next prev) (let [next (absolute next)] @@ -129,7 +129,7 @@ (text.Injection /.Code)) (`` (when it (,, (with_template [ ] - [( _ value) + [{ _ value} (by as value)] [/.#Bit bit.text] @@ -139,11 +139,11 @@ [/.#Decimal decimal.base_10] [/.#Name (name.relative module)])) - (/.#Text _ value) + {/.#Text _ value} (text.as_text value) (,, (with_template [ ] - [( _ members) + [{ _ members} (.text (list#mix (function (_ next prev) (let [next (relative module next)] @@ -167,8 +167,8 @@ substitute (when it (,, (with_template [] - [( provenance parts) - ( provenance (list#each replaced parts))] + [{ provenance parts} + { provenance (list#each replaced parts)}] [/.#Form] [/.#Variant] @@ -185,7 +185,7 @@ /.Provenance) (`` (when it (,, (with_template [,tag] - [(,tag it _) + [{,tag it _} it] [/.#Bit] @@ -205,8 +205,8 @@ (Change /.Code)) (`` (when it (,, (with_template [,tag] - [(,tag _ it) - (,tag provenance it)] + [{,tag _ it} + {,tag provenance it}] [/.#Bit] [/.#Natural] diff --git a/stdlib/source/projection/lux/meta/code.lux b/stdlib/source/projection/lux/meta/code.lux index d933136a0..1fd2283cd 100644 --- a/stdlib/source/projection/lux/meta/code.lux +++ b/stdlib/source/projection/lux/meta/code.lux @@ -44,7 +44,7 @@ (Projection ) (function (_ tape) (when (?list.any tape) - {try.#Success [tape ( @ it)]} + {try.#Success [tape { @ it}]} {try.#Success [tape it]} else @@ -75,7 +75,7 @@ (Projection Text) (function (_ tape) (when (?list.any tape) - {try.#Success [tape (/.#Name @ ["" it])]} + {try.#Success [tape {/.#Name @ ["" it]}]} {try.#Success [tape it]} else @@ -91,10 +91,10 @@ (Projection Name) (function (_ tape) (when (?list.any tape) - {try.#Success [tape (/.#Name @ ["" it])]} + {try.#Success [tape {/.#Name @ ["" it]}]} {try.#Failure ..not_expected} - {try.#Success [tape (/.#Name @ it)]} + {try.#Success [tape {/.#Name @ it}]} {try.#Success [tape it]} else @@ -112,7 +112,7 @@ (Change (Projection it))) (function (_ global) (when (?list.any global) - {try.#Success [global (,tag _ local)]} + {try.#Success [global {,tag _ local}]} (when (?list.value local projection) {try.#Success it} {try.#Success [global it]}