From 565fe5a2e60ff3c6b612031d1c3bb89f330751da Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 30 Jun 2022 18:15:20 -0400 Subject: Moved ".../dictionary/plist" to ".../list/property". --- stdlib/source/library/lux.lux | 130 ++++++++++++++++++++++++++++++++---------- 1 file changed, 100 insertions(+), 30 deletions(-) (limited to 'stdlib/source/library/lux.lux') diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 9b479ce35..439fb69e3 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -1526,33 +1526,33 @@ (failure "Wrong syntax for if")} tokens))) -(def' .private PList +(def' .private Property_List Type (All (_ a) ($' List (Tuple Text a)))) -(def' .private (plist#value k plist) +(def' .private (property#value k property_list) (All (_ a) - (-> Text ($' PList a) ($' Maybe a))) - ({{#Item [[k' v] plist']} + (-> Text ($' Property_List a) ($' Maybe a))) + ({{#Item [[k' v] property_list']} (if (text#= k k') {#Some v} - (plist#value k plist')) + (property#value k property_list')) {#End} {#None}} - plist)) + property_list)) -(def' .private (plist#with k v plist) +(def' .private (property#with k v property_list) (All (_ a) - (-> Text a ($' PList a) ($' PList a))) - ({{#Item [k' v'] plist'} + (-> Text a ($' Property_List a) ($' Property_List a))) + ({{#Item [k' v'] property_list'} (if (text#= k k') - (partial_list [k v] plist') - (partial_list [k' v'] (plist#with k v plist'))) + (partial_list [k v] property_list') + (partial_list [k' v'] (property#with k v property_list'))) {#End} (list [k v])} - plist)) + property_list)) (def' .private (global_symbol full_name state) (-> Symbol ($' Meta Symbol)) @@ -1574,11 +1574,11 @@ {#None} {#Left (all text#composite "Unknown definition: " (symbol#encoded full_name))}} - (plist#value name definitions)) + (property#value name definitions)) {#None} {#Left (all text#composite "Unknown module: " module " @ " (symbol#encoded full_name))}} - (plist#value module modules)))) + (property#value module modules)))) (def' .private (|List| expression) (-> Code Code) @@ -1711,8 +1711,8 @@ {#Slot _} {#Left (text#composite "Unknown definition: " (symbol#encoded name))}} definition)} - (plist#value expected_short definitions))} - (plist#value expected_module modules)))) + (property#value expected_short definitions))} + (property#value expected_module modules)))) (def' .private (global_value global lux) (-> Symbol ($' Meta ($' Maybe (Tuple Type Any)))) @@ -2354,9 +2354,9 @@ Text Text Text ($' Maybe Macro)) (do maybe#monad - [$module (plist#value module modules) + [$module (property#value module modules) gdef (let' [[..#module_hash _ ..#module_aliases _ ..#definitions bindings ..#imports _ ..#module_state _] ("lux type check" Module $module)] - (plist#value name bindings))] + (property#value name bindings))] ({{#Alias [r_module r_name]} (named_macro' modules current_module r_module r_name) @@ -2652,9 +2652,75 @@ (meta#in type)} type)) +(def' .private (with_quantification' body lux) + (-> ($' Meta Code) ($' Meta Code)) + (let' [[..#info info/pre + ..#source source/pre + ..#current_module current_module/pre + ..#modules modules/pre + ..#scopes scopes/pre + ..#type_context type_context/pre + ..#host host/pre + ..#seed seed/pre + ..#expected expected/pre + ..#location location/pre + ..#extensions extensions/pre + ..#scope_type_vars scope_type_vars/pre + ..#eval eval/pre] lux] + ({{..#Right [lux/post output]} + (let' [[..#info info/post + ..#source source/post + ..#current_module current_module/post + ..#modules modules/post + ..#scopes scopes/post + ..#type_context type_context/post + ..#host host/post + ..#seed seed/post + ..#expected expected/post + ..#location location/post + ..#extensions extensions/post + ..#scope_type_vars scope_type_vars/post + ..#eval eval/post] lux/post] + {..#Right [[..#info info/post + ..#source source/post + ..#current_module current_module/post + ..#modules modules/post + ..#scopes scopes/pre + ..#type_context type_context/post + ..#host host/post + ..#seed seed/post + ..#expected expected/post + ..#location location/post + ..#extensions extensions/post + ..#scope_type_vars scope_type_vars/post + ..#eval eval/post] + output]}) + + failure + failure} + (body [..#info info/pre + ..#source source/pre + ..#current_module current_module/pre + ..#modules modules/pre + ..#scopes (partial_list [#name (list) + #inner 0 + #locals [#counter 0 + #mappings (list [..quantification_level [.Nat ("lux type as" Nat -1)]])] + #captured [#counter 0 + #mappings (list)]] + scopes/pre) + ..#type_context type_context/pre + ..#host host/pre + ..#seed seed/pre + ..#expected expected/pre + ..#location location/pre + ..#extensions extensions/pre + ..#scope_type_vars scope_type_vars/pre + ..#eval eval/pre])))) + (def' .public type_literal Macro - (macro (_ tokens) + (macro (type_literal tokens) ({{#Item type {#End}} (do meta#monad [initialized_quantification? (function' [lux] {#Right [lux (initialized_quantification? lux)]})] @@ -2669,10 +2735,14 @@ _ (failure "The expansion of the type-syntax had to yield a single element.")} type+)) - (in (list (..quantified (` (..type_literal (~ type)))))))) + (do meta#monad + [it (with_quantification' + (one_expansion + (type_literal tokens)))] + (in (list (..quantified it)))))) _ - (failure (wrong_syntax_error [..prelude "type"]))} + (failure (wrong_syntax_error [..prelude "type_literal"]))} tokens))) (def' .public is @@ -3394,7 +3464,7 @@ ..#scopes scopes ..#type_context types ..#host host ..#seed seed ..#expected expected ..#location location ..#extensions extensions ..#scope_type_vars scope_type_vars ..#eval _eval] state] - (case (plist#value name modules) + (case (property#value name modules) {#Some module} {#Right state module} @@ -3410,7 +3480,7 @@ ..#definitions definitions ..#imports _ ..#module_state _] =module]] - (case (plist#value name definitions) + (case (property#value name definitions) {#Some {#Slot [exported type group index]}} (meta#in [index (list#each (function (_ slot) @@ -3442,7 +3512,7 @@ ..#definitions definitions ..#imports _ ..#module_state _] =module]] - (case (plist#value name definitions) + (case (property#value name definitions) {#Some {#Type [exported? {#Named _ _type} {#Right slots}]}} (case (interface_methods _type) {#Some members} @@ -3544,7 +3614,7 @@ (function (_ token) (case token (pattern [_ {#Form (list [_ {#Text "lux def"}] [_ {#Symbol ["" slot_name]}] value export_policy)}]) - (case (plist#value slot_name tag_mappings) + (case (property#value slot_name tag_mappings) {#Some tag} (in (list tag value)) @@ -3955,7 +4025,7 @@ ..#seed seed ..#expected expected ..#location location ..#extensions extensions ..#scope_type_vars scope_type_vars ..#eval _eval] [current_module modules])] - (case (plist#value module modules) + (case (property#value module modules) {#Some =module} (let [to_alias (list#each (is (-> [Text Global] (List Text)) @@ -4091,7 +4161,7 @@ ..#scopes scopes ..#type_context types ..#host host ..#seed seed ..#expected expected ..#location location ..#extensions extensions ..#scope_type_vars scope_type_vars ..#eval _eval] state] - (case (plist#value expected_module modules) + (case (property#value expected_module modules) {#None} {#None} @@ -4100,7 +4170,7 @@ ..#module_aliases _ ..#imports _ ..#module_state _]} - (case (plist#value expected_short definitions) + (case (property#value expected_short definitions) {#None} {#None} @@ -4801,7 +4871,7 @@ (case (parsed (andP (tupleP (someP bindingP)) (someP anyP)) tokens) {#Some [bindings bodies]} (loop (again [bindings bindings - map (is (PList (List Code)) + map (is (Property_List (List Code)) (list))]) (let [normal (is (-> Code (List Code)) (function (_ it) @@ -4821,7 +4891,7 @@ "Incorrect expansion in with_expansions" " | Binding: " (text#encoded var_name) " | Expression: " (code#encoded expr))))] - (again &rest (plist#with var_name expansion map))) + (again &rest (property#with var_name expansion map))) {#End} (at meta#monad #in (list#conjoint (list#each normal bodies)))))) -- cgit v1.2.3