From cd71a864ad5be13ed6ec6d046e0a2cb1087bdf94 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 10 Sep 2021 01:21:23 -0400 Subject: Migrated variants to the new syntax. --- stdlib/source/library/lux.lux | 2308 +++++++++++++++++++++-------------------- 1 file changed, 1172 insertions(+), 1136 deletions(-) (limited to 'stdlib/source/library/lux.lux') diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 5f6f9342e..7d94363f3 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -18,153 +18,177 @@ ... (Ex (_ a) a)) ("lux def" Any ("lux type check type" - (9 #1 [..prelude_module "Any"] - (8 #0 (0 #0) (4 #0 1)))) + {9 #1 + [..prelude_module "Any"] + {8 #0 + {0 #0} + {4 #0 1}}}) #1) ... (type: .public Nothing ... (All (_ a) a)) ("lux def" Nothing ("lux type check type" - (9 #1 [..prelude_module "Nothing"] - (7 #0 (0 #0) (4 #0 1)))) + {9 #1 + [..prelude_module "Nothing"] + {7 #0 + {0 #0} + {4 #0 1}}}) #1) ... (type: .public (List a) ... #End -... (#Item a (List a))) +... {#Item a (List a)}) ("lux def type tagged" List - (9 #1 [..prelude_module "List"] - (7 #0 (0 #0) - (1 #0 - ... End - Any - ... Item - (2 #0 (4 #0 1) - (9 #0 (4 #0 1) (4 #0 0)))))) - ("End" "Item") + {9 #1 + [..prelude_module "List"] + {7 #0 + {0 #0} + {1 #0 + ... End + Any + ... Item + {2 #0 + {4 #0 1} + {9 #0 + {4 #0 1} + {4 #0 0}}}}}} + {"End" "Item"} #1) ("lux def" Bit ("lux type check type" - (9 #1 [..prelude_module "Bit"] - (0 #0 "#Bit" #End))) + {9 #1 + [..prelude_module "Bit"] + {0 #0 "#Bit" #End}}) #1) ("lux def" I64 ("lux type check type" - (9 #1 [..prelude_module "I64"] - (7 #0 (0 #0) - (0 #0 "#I64" (#Item (4 #0 1) #End))))) + {9 #1 + [..prelude_module "I64"] + {7 #0 + {0 #0} + {0 #0 "#I64" {#Item {4 #0 1} #End}}}}) #1) ("lux def" Nat ("lux type check type" - (9 #1 [..prelude_module "Nat"] - (0 #0 "#I64" (#Item (0 #0 "#Nat" #End) #End)))) + {9 #1 + [..prelude_module "Nat"] + {0 #0 "#I64" {#Item {0 #0 "#Nat" #End} #End}}}) #1) ("lux def" Int ("lux type check type" - (9 #1 [..prelude_module "Int"] - (0 #0 "#I64" (#Item (0 #0 "#Int" #End) #End)))) + {9 #1 + [..prelude_module "Int"] + {0 #0 "#I64" {#Item {0 #0 "#Int" #End} #End}}}) #1) ("lux def" Rev ("lux type check type" - (9 #1 [..prelude_module "Rev"] - (0 #0 "#I64" (#Item (0 #0 "#Rev" #End) #End)))) + {9 #1 + [..prelude_module "Rev"] + {0 #0 "#I64" {#Item {0 #0 "#Rev" #End} #End}}}) #1) ("lux def" Frac ("lux type check type" - (9 #1 [..prelude_module "Frac"] - (0 #0 "#Frac" #End))) + {9 #1 + [..prelude_module "Frac"] + {0 #0 "#Frac" #End}}) #1) ("lux def" Text ("lux type check type" - (9 #1 [..prelude_module "Text"] - (0 #0 "#Text" #End))) + {9 #1 + [..prelude_module "Text"] + {0 #0 "#Text" #End}}) #1) ("lux def" Name ("lux type check type" - (9 #1 [..prelude_module "Name"] - (2 #0 Text Text))) + {9 #1 + [..prelude_module "Name"] + {2 #0 Text Text}}) #1) ... (type: .public (Maybe a) ... #None -... (#Some a)) +... {#Some a}) ("lux def type tagged" Maybe - (9 #1 [..prelude_module "Maybe"] - (7 #0 #End - (1 #0 - ... None - Any - ... Some - (4 #0 1)))) - ("None" "Some") + {9 #1 + [..prelude_module "Maybe"] + {7 #0 + #End + {1 #0 + ... None + Any + ... Some + {4 #0 1}}}} + {"None" "Some"} #1) ... (type: .public Type ... (Rec Type ... (Variant -... (#Primitive Text (List Type)) -... (#Sum Type Type) -... (#Product Type Type) -... (#Function Type Type) -... (#Parameter Nat) -... (#Var Nat) -... (#Ex Nat) -... (#UnivQ (List Type) Type) -... (#ExQ (List Type) Type) -... (#Apply Type Type) -... (#Named Name Type)))) +... {#Primitive Text (List Type)} +... {#Sum Type Type} +... {#Product Type Type} +... {#Function Type Type} +... {#Parameter Nat} +... {#Var Nat} +... {#Ex Nat} +... {#UnivQ (List Type) Type} +... {#ExQ (List Type) Type} +... {#Apply Type Type} +... {#Named Name Type}))) ("lux def type tagged" Type - (9 #1 [..prelude_module "Type"] - ({Type - ({Type_List - ({Type_Pair - (9 #0 (0 #0 ["" #End]) - (7 #0 #End - (1 #0 - ... Primitive - (2 #0 Text Type_List) - (1 #0 - ... Sum - Type_Pair - (1 #0 - ... Product - Type_Pair - (1 #0 - ... Function - Type_Pair - (1 #0 - ... Parameter - Nat - (1 #0 - ... Var - Nat - (1 #0 - ... Ex - Nat - (1 #0 - ... UnivQ - (2 #0 Type_List Type) - (1 #0 - ... ExQ - (2 #0 Type_List Type) - (1 #0 - ... Apply - Type_Pair - ... Named - (2 #0 Name Type)))))))))))))} - ("lux type check type" (2 #0 Type Type)))} - ("lux type check type" (9 #0 Type List)))} - ("lux type check type" (9 #0 (0 #0 ["" #End]) (4 #0 0))))) - ("Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named") + {9 #1 [..prelude_module "Type"] + ({Type + ({Type_List + ({Type_Pair + {9 #0 + {0 #0 ["" #End]} + {7 #0 + #End + {1 #0 + ... Primitive + {2 #0 Text Type_List} + {1 #0 + ... Sum + Type_Pair + {1 #0 + ... Product + Type_Pair + {1 #0 + ... Function + Type_Pair + {1 #0 + ... Parameter + Nat + {1 #0 + ... Var + Nat + {1 #0 + ... Ex + Nat + {1 #0 + ... UnivQ + {2 #0 Type_List Type} + {1 #0 + ... ExQ + {2 #0 Type_List Type} + {1 #0 + ... Apply + Type_Pair + ... Named + {2 #0 Name Type}}}}}}}}}}}}}} + ("lux type check type" {2 #0 Type Type}))} + ("lux type check type" {9 #0 Type List}))} + ("lux type check type" {9 #0 {0 #0 ["" #End]} {4 #0 0}}))} + {"Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"} #1) ... (type: .public Location @@ -173,8 +197,8 @@ ... #line Nat ... #column Nat])) ("lux def type tagged" Location - (#Named [..prelude_module "Location"] - (#Product Text (#Product Nat Nat))) + {#Named [..prelude_module "Location"] + {#Product Text {#Product Nat Nat}}} ["module" "line" "column"] #1) @@ -183,80 +207,81 @@ ... [#meta m ... #datum v])) ("lux def type tagged" Ann - (#Named [..prelude_module "Ann"] - (#UnivQ #End - (#UnivQ #End - (#Product (#Parameter 3) - (#Parameter 1))))) + {#Named [..prelude_module "Ann"] + {#UnivQ #End + {#UnivQ #End + {#Product + {#Parameter 3} + {#Parameter 1}}}}} ["meta" "datum"] #1) ... (type: .public (Code' w) -... (#Bit Bit) -... (#Nat Nat) -... (#Int Int) -... (#Rev Rev) -... (#Frac Frac) -... (#Text Text) -... (#Identifier Name) -... (#Tag Name) -... (#Form (List (w (Code' w)))) -... (#Variant (List (w (Code' w)))) -... (#Tuple (List (w (Code' w))))) +... {#Bit Bit} +... {#Nat Nat} +... {#Int Int} +... {#Rev Rev} +... {#Frac Frac} +... {#Text Text} +... {#Identifier Name} +... {#Tag Name} +... {#Form (List (w (Code' w)))} +... {#Variant (List (w (Code' w)))} +... {#Tuple (List (w (Code' w)))}) ("lux def type tagged" Code' - (#Named [..prelude_module "Code'"] - ({Code - ({Code_List - (#UnivQ #End - (#Sum - ... Bit - Bit - (#Sum - ... Nat - Nat - (#Sum - ... Int - Int - (#Sum - ... Rev - Rev - (#Sum - ... Frac - Frac - (#Sum - ... Text - Text - (#Sum - ... Identifier - Name - (#Sum - ... Tag - Name - (#Sum - ... Form - Code_List - (#Sum - ... Variant - Code_List - ... Tuple - Code_List - )))))))))) - )} - ("lux type check type" (#Apply Code List)))} - ("lux type check type" (#Apply (#Apply (#Parameter 1) - (#Parameter 0)) - (#Parameter 1))))) - ("Bit" "Nat" "Int" "Rev" "Frac" "Text" "Identifier" "Tag" "Form" "Variant" "Tuple") + {#Named [..prelude_module "Code'"] + ({Code + ({Code_List + {#UnivQ #End + {#Sum + ... Bit + Bit + {#Sum + ... Nat + Nat + {#Sum + ... Int + Int + {#Sum + ... Rev + Rev + {#Sum + ... Frac + Frac + {#Sum + ... Text + Text + {#Sum + ... Identifier + Name + {#Sum + ... Tag + Name + {#Sum + ... Form + Code_List + {#Sum + ... Variant + Code_List + ... Tuple + Code_List + }}}}}}}}}} + }} + ("lux type check type" {#Apply Code List}))} + ("lux type check type" {#Apply {#Apply {#Parameter 1} + {#Parameter 0}} + {#Parameter 1}}))} + {"Bit" "Nat" "Int" "Rev" "Frac" "Text" "Identifier" "Tag" "Form" "Variant" "Tuple"} #1) ... (type: .public Code ... (Ann Location (Code' (Ann Location)))) ("lux def" Code ("lux type check type" - (#Named [..prelude_module "Code"] - ({w - (#Apply (#Apply w Code') w)} - ("lux type check type" (#Apply Location Ann))))) + {#Named [..prelude_module "Code"] + ({w + {#Apply {#Apply w Code'} w}} + ("lux type check type" {#Apply Location Ann}))}) #1) ("lux def" private @@ -277,119 +302,118 @@ ("lux def" _ann ("lux type check" - (#Function (#Apply (#Apply Location Ann) - Code') - Code) + {#Function {#Apply {#Apply Location Ann} Code'} + Code} ([_ data] [dummy_location data])) #0) ("lux def" bit$ - ("lux type check" (#Function Bit Code) - ([_ value] (_ann (#Bit value)))) + ("lux type check" {#Function Bit Code} + ([_ value] (_ann {#Bit value}))) #0) ("lux def" nat$ - ("lux type check" (#Function Nat Code) - ([_ value] (_ann (#Nat value)))) + ("lux type check" {#Function Nat Code} + ([_ value] (_ann {#Nat value}))) #0) ("lux def" int$ - ("lux type check" (#Function Int Code) - ([_ value] (_ann (#Int value)))) + ("lux type check" {#Function Int Code} + ([_ value] (_ann {#Int value}))) #0) ("lux def" rev$ - ("lux type check" (#Function Rev Code) - ([_ value] (_ann (#Rev value)))) + ("lux type check" {#Function Rev Code} + ([_ value] (_ann {#Rev value}))) #0) ("lux def" frac$ - ("lux type check" (#Function Frac Code) - ([_ value] (_ann (#Frac value)))) + ("lux type check" {#Function Frac Code} + ([_ value] (_ann {#Frac value}))) #0) ("lux def" text$ - ("lux type check" (#Function Text Code) - ([_ text] (_ann (#Text text)))) + ("lux type check" {#Function Text Code} + ([_ text] (_ann {#Text text}))) #0) ("lux def" identifier$ - ("lux type check" (#Function Name Code) - ([_ name] (_ann (#Identifier name)))) + ("lux type check" {#Function Name Code} + ([_ name] (_ann {#Identifier name}))) #0) ("lux def" local_identifier$ - ("lux type check" (#Function Text Code) - ([_ name] (_ann (#Identifier ["" name])))) + ("lux type check" {#Function Text Code} + ([_ name] (_ann {#Identifier ["" name]}))) #0) ("lux def" tag$ - ("lux type check" (#Function Name Code) - ([_ name] (_ann (#Tag name)))) + ("lux type check" {#Function Name Code} + ([_ name] (_ann {#Tag name}))) #0) ("lux def" local_tag$ - ("lux type check" (#Function Text Code) - ([_ name] (_ann (#Tag ["" name])))) + ("lux type check" {#Function Text Code} + ([_ name] (_ann {#Tag ["" name]}))) #0) ("lux def" form$ - ("lux type check" (#Function (#Apply Code List) Code) - ([_ tokens] (_ann (#Form tokens)))) + ("lux type check" {#Function {#Apply Code List} Code} + ([_ tokens] (_ann {#Form tokens}))) #0) ("lux def" variant$ - ("lux type check" (#Function (#Apply Code List) Code) - ([_ tokens] (_ann (#Variant tokens)))) + ("lux type check" {#Function {#Apply Code List} Code} + ([_ tokens] (_ann {#Variant tokens}))) #0) ("lux def" tuple$ - ("lux type check" (#Function (#Apply Code List) Code) - ([_ tokens] (_ann (#Tuple tokens)))) + ("lux type check" {#Function {#Apply Code List} Code} + ([_ tokens] (_ann {#Tuple tokens}))) #0) ... (type: .public Definition ... [Bit Type Any]) ("lux def" Definition ("lux type check type" - (#Named [..prelude_module "Definition"] - (#Product Bit (#Product Type Any)))) + {#Named [..prelude_module "Definition"] + {#Product Bit {#Product Type Any}}}) .public) ... (type: .public Alias ... Name) ("lux def" Alias ("lux type check type" - (#Named [..prelude_module "Alias"] - Name)) + {#Named [..prelude_module "Alias"] + Name}) .public) ... (type: .public Label ... [Bit Type (List Text) Nat]) ("lux def" Label ("lux type check type" - (#Named [..prelude_module "Label"] - (#Product Bit (#Product Type (#Product (#Apply Text List) Nat))))) + {#Named [..prelude_module "Label"] + {#Product Bit {#Product Type {#Product {#Apply Text List} Nat}}}}) .public) ... (type: .public Global ... (Variant -... (#Definition Definition) -... (#Type [Bit Type (Either [Text (List Text)] [Text (List Text)])]) -... (#Tag Label) -... (#Slot Label) -... (#Alias Alias))) +... {#Definition Definition} +... {#Type [Bit Type (Either [Text (List Text)] [Text (List Text)])]} +... {#Tag Label} +... {#Slot Label} +... {#Alias Alias})) ("lux def type tagged" Global - (#Named [..prelude_module "Global"] - (#Sum Definition - (#Sum ({labels - (#Product Bit (#Product Type (#Sum labels labels)))} - (#Product Text (#Apply Text List))) - (#Sum Label - (#Sum Label - Alias))))) - ("Definition" "Type" "Label" "Slot" "Alias") + {#Named [..prelude_module "Global"] + {#Sum Definition + {#Sum ({labels + {#Product Bit {#Product Type {#Sum labels labels}}}} + {#Product Text {#Apply Text List}}) + {#Sum Label + {#Sum Label + Alias}}}}} + {"Definition" "Type" "Label" "Slot" "Alias"} .public) ... (type: .public (Bindings k v) @@ -397,29 +421,29 @@ ... [#counter Nat ... #mappings (List [k v])])) ("lux def type tagged" Bindings - (#Named [..prelude_module "Bindings"] - (#UnivQ #End - (#UnivQ #End - (#Product - ... counter - Nat - ... mappings - (#Apply (#Product (#Parameter 3) - (#Parameter 1)) - List))))) + {#Named [..prelude_module "Bindings"] + {#UnivQ #End + {#UnivQ #End + {#Product + ... counter + Nat + ... mappings + {#Apply {#Product {#Parameter 3} + {#Parameter 1}} + List}}}}} ["counter" "mappings"] .public) ... (type: .public Ref -... (#Local Nat) -... (#Captured Nat)) +... {#Local Nat} +... {#Captured Nat}) ("lux def type tagged" Ref - (#Named [..prelude_module "Ref"] - (#Sum ... Local - Nat - ... Captured - Nat)) - ("Local" "Captured") + {#Named [..prelude_module "Ref"] + {#Sum ... Local + Nat + ... Captured + Nat}} + {"Local" "Captured"} .public) ... (type: .public Scope @@ -429,44 +453,44 @@ ... #locals (Bindings Text [Type Nat]) ... #captured (Bindings Text [Type Ref])])) ("lux def type tagged" Scope - (#Named [..prelude_module "Scope"] - (#Product ... name - (#Apply Text List) - (#Product ... inner - Nat - (#Product ... locals - (#Apply (#Product Type Nat) (#Apply Text Bindings)) - ... captured - (#Apply (#Product Type Ref) (#Apply Text Bindings)))))) + {#Named [..prelude_module "Scope"] + {#Product ... name + {#Apply Text List} + {#Product ... inner + Nat + {#Product ... locals + {#Apply {#Product Type Nat} {#Apply Text Bindings}} + ... captured + {#Apply {#Product Type Ref} {#Apply Text Bindings}}}}}} ["name" "inner" "locals" "captured"] .public) ("lux def" Code_List ("lux type check type" - (#Apply Code List)) + {#Apply Code List}) #0) ... (type: .public (Either l r) -... (#Left l) -... (#Right r)) +... {#Left l} +... {#Right r}) ("lux def type tagged" Either - (#Named [..prelude_module "Either"] - (#UnivQ #End - (#UnivQ #End - (#Sum - ... Left - (#Parameter 3) - ... Right - (#Parameter 1))))) - ("Left" "Right") + {#Named [..prelude_module "Either"] + {#UnivQ #End + {#UnivQ #End + {#Sum + ... Left + {#Parameter 3} + ... Right + {#Parameter 1}}}}} + {"Left" "Right"} .public) ... (type: .public Source ... [Location Nat Text]) ("lux def" Source ("lux type check type" - (#Named [..prelude_module "Source"] - (#Product Location (#Product Nat Text)))) + {#Named [..prelude_module "Source"] + {#Product Location {#Product Nat Text}}}) .public) ... (type: .public Module_State @@ -474,16 +498,16 @@ ... #Compiled ... #Cached) ("lux def type tagged" Module_State - (#Named [..prelude_module "Module_State"] - (#Sum - ... #Active - Any - (#Sum - ... #Compiled - Any - ... #Cached - Any))) - ("Active" "Compiled" "Cached") + {#Named [..prelude_module "Module_State"] + {#Sum + ... #Active + Any + {#Sum + ... #Compiled + Any + ... #Cached + Any}}} + {"Active" "Compiled" "Cached"} .public) ... (type: .public Module @@ -494,22 +518,22 @@ ... #imports (List Text) ... #module_state Module_State])) ("lux def type tagged" Module - (#Named [..prelude_module "Module"] - (#Product - ... module_hash - Nat - (#Product - ... module_aliases - (#Apply (#Product Text Text) List) - (#Product - ... definitions - (#Apply (#Product Text Global) List) - (#Product - ... imports - (#Apply Text List) - ... module_state - Module_State - ))))) + {#Named [..prelude_module "Module"] + {#Product + ... module_hash + Nat + {#Product + ... module_aliases + {#Apply {#Product Text Text} List} + {#Product + ... definitions + {#Apply {#Product Text Global} List} + {#Product + ... imports + {#Apply Text List} + ... module_state + Module_State + }}}}} ["module_hash" "module_aliases" "definitions" "imports" "module_state"] .public) @@ -519,14 +543,14 @@ ... #var_counter Nat ... #var_bindings (List [Nat (Maybe Type)])])) ("lux def type tagged" Type_Context - (#Named [..prelude_module "Type_Context"] - (#Product ... ex_counter - Nat - (#Product ... var_counter - Nat - ... var_bindings - (#Apply (#Product Nat (#Apply Type Maybe)) - List)))) + {#Named [..prelude_module "Type_Context"] + {#Product ... ex_counter + Nat + {#Product ... var_counter + Nat + ... var_bindings + {#Apply {#Product Nat {#Apply Type Maybe}} + List}}}} ["ex_counter" "var_counter" "var_bindings"] .public) @@ -535,14 +559,14 @@ ... #Eval ... #Interpreter) ("lux def type tagged" Mode - (#Named [..prelude_module "Mode"] - (#Sum ... Build - Any - (#Sum ... Eval - Any - ... Interpreter - Any))) - ("Build" "Eval" "Interpreter") + {#Named [..prelude_module "Mode"] + {#Sum ... Build + Any + {#Sum ... Eval + Any + ... Interpreter + Any}}} + {"Build" "Eval" "Interpreter"} .public) ... (type: .public Info @@ -551,15 +575,15 @@ ... #version Text ... #mode Mode])) ("lux def type tagged" Info - (#Named [..prelude_module "Info"] - (#Product - ... target - Text - (#Product - ... version - Text - ... mode - Mode))) + {#Named [..prelude_module "Info"] + {#Product + ... target + Text + {#Product + ... version + Text + ... mode + Mode}}} ["target" "version" "mode"] .public) @@ -579,52 +603,52 @@ ... #eval (-> Type Code (-> Lux (Either Text [Lux Any]))) ... #host Any])) ("lux def type tagged" Lux - (#Named [..prelude_module "Lux"] - ({Lux - (#Apply (0 #0 ["" #End]) - (#UnivQ #End - (#Product - ... info - Info - (#Product - ... source - Source - (#Product - ... location - Location - (#Product - ... current_module - (#Apply Text Maybe) - (#Product - ... modules - (#Apply (#Product Text Module) List) - (#Product - ... scopes - (#Apply Scope List) - (#Product - ... type_context - Type_Context - (#Product - ... expected - (#Apply Type Maybe) - (#Product - ... seed - Nat - (#Product - ... scope_type_vars - (#Apply Nat List) - (#Product - ... extensions - Any - (#Product - ... eval - (#Function Type - (#Function Code - (#Function Lux - (#Sum Text (#Product Lux Any))))) - ... host - Any))))))))))))))} - (#Apply (0 #0 ["" #End]) (#Parameter 0)))) + {#Named [..prelude_module "Lux"] + ({Lux + {#Apply {0 #0 ["" #End]} + {#UnivQ #End + {#Product + ... info + Info + {#Product + ... source + Source + {#Product + ... location + Location + {#Product + ... current_module + {#Apply Text Maybe} + {#Product + ... modules + {#Apply {#Product Text Module} List} + {#Product + ... scopes + {#Apply Scope List} + {#Product + ... type_context + Type_Context + {#Product + ... expected + {#Apply Type Maybe} + {#Product + ... seed + Nat + {#Product + ... scope_type_vars + {#Apply Nat List} + {#Product + ... extensions + Any + {#Product + ... eval + {#Function Type + {#Function Code + {#Function Lux + {#Sum Text {#Product Lux Any}}}}} + ... host + Any}}}}}}}}}}}}}}} + {#Apply {0 #0 ["" #End]} {#Parameter 0}})} ["info" "source" "location" "current_module" "modules" "scopes" "type_context" "expected" "seed" "scope_type_vars" "extensions" "eval" "host"] .public) @@ -632,63 +656,63 @@ ... (-> Lux (Either Text [Lux a]))) ("lux def" Meta ("lux type check type" - (#Named [..prelude_module "Meta"] - (#UnivQ #End - (#Function Lux - (#Apply (#Product Lux (#Parameter 1)) - (#Apply Text Either)))))) + {#Named [..prelude_module "Meta"] + {#UnivQ #End + {#Function Lux + {#Apply {#Product Lux {#Parameter 1}} + {#Apply Text Either}}}}}) .public) ... (type: .public Macro' ... (-> (List Code) (Meta (List Code)))) ("lux def" Macro' ("lux type check type" - (#Named [..prelude_module "Macro'"] - (#Function Code_List (#Apply Code_List Meta)))) + {#Named [..prelude_module "Macro'"] + {#Function Code_List {#Apply Code_List Meta}}}) .public) ... (type: .public Macro ... (primitive "#Macro")) ("lux def" Macro ("lux type check type" - (#Named [..prelude_module "Macro"] - (#Primitive "#Macro" #End))) + {#Named [..prelude_module "Macro"] + {#Primitive "#Macro" #End}}) .public) ... Base functions & macros ("lux def" in_meta ("lux type check" - (#UnivQ #End - (#Function (#Parameter 1) - (#Function Lux - (#Apply (#Product Lux - (#Parameter 1)) - (#Apply Text Either))))) + {#UnivQ #End + {#Function {#Parameter 1} + {#Function Lux + {#Apply {#Product Lux + {#Parameter 1}} + {#Apply Text Either}}}}} ([_ val] ([_ state] - (#Right state val)))) + {#Right state val}))) #0) ("lux def" failure ("lux type check" - (#UnivQ #End - (#Function Text - (#Function Lux - (#Apply (#Product Lux - (#Parameter 1)) - (#Apply Text Either))))) + {#UnivQ #End + {#Function Text + {#Function Lux + {#Apply {#Product Lux + {#Parameter 1}} + {#Apply Text Either}}}}} ([_ msg] ([_ state] - (#Left msg)))) + {#Left msg}))) #0) ("lux def" let'' ("lux macro" ([_ tokens] - ({(#Item lhs (#Item rhs (#Item body #End))) - (in_meta (#Item (form$ (#Item (variant$ (#Item lhs (#Item body #End))) - (#Item rhs #End))) - #End)) + ({{#Item lhs {#Item rhs {#Item body #End}}} + (in_meta {#Item (form$ {#Item (variant$ {#Item lhs {#Item body #End}}) + {#Item rhs #End}}) + #End}) _ (failure "Wrong syntax for let''")} @@ -698,33 +722,33 @@ ("lux def" function'' ("lux macro" ([_ tokens] - ({(#Item [_ (#Tuple (#Item arg args'))] (#Item body #End)) - (in_meta (#Item (_ann (#Form (#Item (_ann (#Tuple (#Item (_ann (#Identifier ["" ""])) - (#Item arg #End)))) - (#Item ({#End - body - - _ - (_ann (#Form (#Item (_ann (#Identifier [..prelude_module "function''"])) - (#Item (_ann (#Tuple args')) - (#Item body #End)))))} - args') - #End)))) - #End)) - - (#Item [_ (#Identifier ["" self])] (#Item [_ (#Tuple (#Item arg args'))] (#Item body #End))) - (in_meta (#Item (_ann (#Form (#Item (_ann (#Tuple (#Item (_ann (#Identifier ["" self])) - (#Item arg #End)))) - (#Item ({#End - body - - _ - (_ann (#Form (#Item (_ann (#Identifier [..prelude_module "function''"])) - (#Item (_ann (#Tuple args')) - (#Item body #End)))))} - args') - #End)))) - #End)) + ({{#Item [_ {#Tuple {#Item arg args'}}] {#Item body #End}} + (in_meta {#Item (_ann {#Form {#Item (_ann {#Tuple {#Item (_ann {#Identifier ["" ""]}) + {#Item arg #End}}}) + {#Item ({#End + body + + _ + (_ann {#Form {#Item (_ann {#Identifier [..prelude_module "function''"]}) + {#Item (_ann {#Tuple args'}) + {#Item body #End}}}})} + args') + #End}}}) + #End}) + + {#Item [_ {#Identifier ["" self]}] {#Item [_ {#Tuple {#Item arg args'}}] {#Item body #End}}} + (in_meta {#Item (_ann {#Form {#Item (_ann {#Tuple {#Item (_ann {#Identifier ["" self]}) + {#Item arg #End}}}) + {#Item ({#End + body + + _ + (_ann {#Form {#Item (_ann {#Identifier [..prelude_module "function''"]}) + {#Item (_ann {#Tuple args'}) + {#Item body #End}}}})} + args') + #End}}}) + #End}) _ (failure "Wrong syntax for function''")} @@ -733,70 +757,70 @@ ("lux def" location_code ("lux type check" Code - (tuple$ (#Item (text$ "") (#Item (nat$ 0) (#Item (nat$ 0) #End))))) + (tuple$ {#Item (text$ "") {#Item (nat$ 0) {#Item (nat$ 0) #End}}})) #0) ("lux def" meta_code - ("lux type check" (#Function Name (#Function Code Code)) + ("lux type check" {#Function Name {#Function Code Code}} ([_ tag] ([_ value] - (tuple$ (#Item location_code - (#Item (form$ (#Item (tag$ tag) (#Item value #End))) - #End)))))) + (tuple$ {#Item location_code + {#Item (form$ {#Item (tag$ tag) {#Item value #End}}) + #End}})))) #0) ("lux def" flag_meta - ("lux type check" (#Function Text Code) + ("lux type check" {#Function Text Code} ([_ tag] - (tuple$ (#Item [(meta_code [..prelude_module "Tag"] (tuple$ (#Item (text$ ..prelude_module) (#Item (text$ tag) #End)))) - (#Item [(meta_code [..prelude_module "Bit"] (bit$ #1)) - #End])])))) + (tuple$ {#Item [(meta_code [..prelude_module "Tag"] (tuple$ {#Item (text$ ..prelude_module) {#Item (text$ tag) #End}})) + {#Item [(meta_code [..prelude_module "Bit"] (bit$ #1)) + #End]}]}))) #0) ("lux def" as_def - ("lux type check" (#Function Code (#Function Code (#Function Code Code))) + ("lux type check" {#Function Code {#Function Code {#Function Code Code}}} (function'' [name value export_policy] - (form$ (#Item (text$ "lux def") (#Item name (#Item value (#Item export_policy #End))))))) + (form$ {#Item (text$ "lux def") {#Item name {#Item value {#Item export_policy #End}}}}))) #0) ("lux def" as_checked - ("lux type check" (#Function Code (#Function Code Code)) + ("lux type check" {#Function Code {#Function Code Code}} (function'' [type value] - (form$ (#Item (text$ "lux type check") (#Item type (#Item value #End)))))) + (form$ {#Item (text$ "lux type check") {#Item type {#Item value #End}}}))) #0) ("lux def" as_function - ("lux type check" (#Function Code (#Function (#Apply Code List) (#Function Code Code))) + ("lux type check" {#Function Code {#Function {#Apply Code List} {#Function Code Code}}} (function'' [self inputs output] - (form$ (#Item (identifier$ [..prelude_module "function''"]) - (#Item self - (#Item (tuple$ inputs) - (#Item output #End))))))) + (form$ {#Item (identifier$ [..prelude_module "function''"]) + {#Item self + {#Item (tuple$ inputs) + {#Item output #End}}}}))) #0) ("lux def" as_macro - ("lux type check" (#Function Code Code) + ("lux type check" {#Function Code Code} (function'' [expression] - (form$ (#Item (text$ "lux macro") - (#Item expression - #End))))) + (form$ {#Item (text$ "lux macro") + {#Item expression + #End}}))) #0) ("lux def" def:'' ("lux macro" (function'' [tokens] - ({(#Item [export_policy - (#Item [[_ (#Form (#Item [name args]))] - (#Item [type (#Item [body #End])])])]) - (in_meta (#Item [(as_def name + ({{#Item [export_policy + {#Item [[_ {#Form {#Item [name args]}}] + {#Item [type {#Item [body #End]}]}]}]} + (in_meta {#Item [(as_def name (as_checked type (as_function name args body)) export_policy) - #End])) + #End]}) - (#Item [export_policy (#Item [name (#Item [type (#Item [body #End])])])]) - (in_meta (#Item [(as_def name (as_checked type body) + {#Item [export_policy {#Item [name {#Item [type {#Item [body #End]}]}]}]} + (in_meta {#Item [(as_def name (as_checked type body) export_policy) - #End])) + #End]}) _ (failure "Wrong syntax for def''")} @@ -806,10 +830,10 @@ ("lux def" macro:' ("lux macro" (function'' [tokens] - ({(#Item export_policy (#Item [_ (#Form (#Item name args))] (#Item body #End))) - (in_meta (#Item (as_def name (as_macro (as_function name args body)) + ({{#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item body #End}}} + (in_meta {#Item (as_def name (as_macro (as_function name args body)) export_policy) - #End)) + #End}) _ (failure "Wrong syntax for macro:'")} @@ -820,58 +844,58 @@ (in_meta #End)) (macro:' .private ($' tokens) - ({(#Item x #End) + ({{#Item x #End} (in_meta tokens) - (#Item x (#Item y xs)) - (in_meta (#Item (form$ (#Item (identifier$ [..prelude_module "$'"]) - (#Item (form$ (#Item (tag$ [..prelude_module "Apply"]) - (#Item y (#Item x #End)))) - xs))) - #End)) + {#Item x {#Item y xs}} + (in_meta {#Item (form$ {#Item (identifier$ [..prelude_module "$'"]) + {#Item (variant$ {#Item (tag$ [..prelude_module "Apply"]) + {#Item y {#Item x #End}}}) + xs}}) + #End}) _ (failure "Wrong syntax for $'")} tokens)) (def:'' .private (list\each f xs) - (#UnivQ #End - (#UnivQ #End - (#Function (#Function (#Parameter 3) (#Parameter 1)) - (#Function ($' List (#Parameter 3)) - ($' List (#Parameter 1)))))) + {#UnivQ #End + {#UnivQ #End + {#Function {#Function {#Parameter 3} {#Parameter 1}} + {#Function ($' List {#Parameter 3}) + ($' List {#Parameter 1})}}}} ({#End #End - (#Item x xs') - (#Item (f x) (list\each f xs'))} + {#Item x xs'} + {#Item (f x) (list\each f xs')}} xs)) (def:'' .private Replacement_Environment Type - ($' List (#Product Text Code))) + ($' List {#Product Text Code})) (def:'' .private (replacement_environment xs ys) - (#Function ($' List Text) (#Function ($' List Code) Replacement_Environment)) - ({[(#Item x xs') (#Item y ys')] - (#Item [x y] (replacement_environment xs' ys')) + {#Function ($' List Text) {#Function ($' List Code) Replacement_Environment}} + ({[{#Item x xs'} {#Item y ys'}] + {#Item [x y] (replacement_environment xs' ys')} _ #End} [xs ys])) (def:'' .private (text\= reference sample) - (#Function Text (#Function Text Bit)) + {#Function Text {#Function Text Bit}} ("lux text =" reference sample)) (def:'' .private (replacement for environment) - (#Function Text (#Function Replacement_Environment ($' Maybe Code))) + {#Function Text {#Function Replacement_Environment ($' Maybe Code)}} ({#End #None - (#Item [k v] environment') + {#Item [k v] environment'} ({#1 - (#Some v) + {#Some v} #0 (replacement for environment')} @@ -879,30 +903,30 @@ environment)) (def:'' .private (with_replacements reps syntax) - (#Function Replacement_Environment (#Function Code Code)) - ({[_ (#Identifier "" name)] - ({(#Some replacement) + {#Function Replacement_Environment {#Function Code Code}} + ({[_ {#Identifier "" name}] + ({{#Some replacement} replacement #None syntax} (..replacement name reps)) - [meta (#Form parts)] - [meta (#Form (list\each (with_replacements reps) parts))] + [meta {#Form parts}] + [meta {#Form (list\each (with_replacements reps) parts)}] - [meta (#Variant members)] - [meta (#Variant (list\each (with_replacements reps) members))] + [meta {#Variant members}] + [meta {#Variant (list\each (with_replacements reps) members)}] - [meta (#Tuple members)] - [meta (#Tuple (list\each (with_replacements reps) members))] + [meta {#Tuple members}] + [meta {#Tuple (list\each (with_replacements reps) members)}] _ syntax} syntax)) (def:'' .private (n/* param subject) - (#Function Nat (#Function Nat Nat)) + {#Function Nat {#Function Nat Nat}} ("lux type as" Nat ("lux i64 *" ("lux type as" Int param) @@ -910,36 +934,36 @@ (def:'' .private (list\mix f init xs) ... (All (_ a b) (-> (-> b a a) a (List b) a)) - (#UnivQ #End (#UnivQ #End (#Function (#Function (#Parameter 1) - (#Function (#Parameter 3) - (#Parameter 3))) - (#Function (#Parameter 3) - (#Function ($' List (#Parameter 1)) - (#Parameter 3)))))) + {#UnivQ #End {#UnivQ #End {#Function {#Function {#Parameter 1} + {#Function {#Parameter 3} + {#Parameter 3}}} + {#Function {#Parameter 3} + {#Function ($' List {#Parameter 1}) + {#Parameter 3}}}}}} ({#End init - (#Item x xs') + {#Item x xs'} (list\mix f (f x init) xs')} xs)) (def:'' .private (list\size list) - (#UnivQ #End - (#Function ($' List (#Parameter 1)) Nat)) + {#UnivQ #End + {#Function ($' List {#Parameter 1}) Nat}} (list\mix (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list)) (def:'' .private (let$ binding value body) - (#Function Code (#Function Code (#Function Code Code))) - (form$ (#Item (variant$ (#Item binding (#Item body #End))) - (#Item value #End)))) + {#Function Code {#Function Code {#Function Code Code}}} + (form$ {#Item (variant$ {#Item binding {#Item body #End}}) + {#Item value #End}})) (def:'' .private (UnivQ$ body) - (#Function Code Code) - (form$ (#Item (tag$ [..prelude_module "UnivQ"]) (#Item (tag$ [..prelude_module "End"]) (#Item body #End))))) + {#Function Code Code} + (variant$ {#Item (tag$ [..prelude_module "UnivQ"]) {#Item (tag$ [..prelude_module "End"]) {#Item body #End}}})) (def:'' .private (ExQ$ body) - (#Function Code Code) - (form$ (#Item (tag$ [..prelude_module "ExQ"]) (#Item (tag$ [..prelude_module "End"]) (#Item body #End))))) + {#Function Code Code} + (variant$ {#Item (tag$ [..prelude_module "ExQ"]) {#Item (tag$ [..prelude_module "End"]) {#Item body #End}}})) (def:'' .private quantification_level Text @@ -948,24 +972,24 @@ double_quote))) (def:'' .private quantified - (#Function Code Code) + {#Function Code Code} (let$ (local_identifier$ ..quantification_level) (nat$ 0))) (def:'' .private (quantified_type_parameter idx) - (#Function Nat Code) - (form$ (#Item (tag$ [..prelude_module "Parameter"]) - (#Item (form$ (#Item (text$ "lux i64 +") - (#Item (local_identifier$ ..quantification_level) - (#Item (nat$ idx) - #End)))) - #End)))) + {#Function Nat Code} + (variant$ {#Item (tag$ [..prelude_module "Parameter"]) + {#Item (form$ {#Item (text$ "lux i64 +") + {#Item (local_identifier$ ..quantification_level) + {#Item (nat$ idx) + #End}}}) + #End}})) (def:'' .private (next_level depth) - (#Function Nat Nat) + {#Function Nat Nat} ("lux i64 +" 2 depth)) (def:'' .private (self_id? id) - (#Function Nat Bit) + {#Function Nat Bit} ("lux i64 =" id ("lux type as" Nat ("lux i64 *" +2 ("lux i64 /" +2 @@ -973,49 +997,49 @@ id)))))) (def:'' .public (__adjusted_quantified_type__ permission depth type) - (#Function Nat (#Function Nat (#Function Type Type))) + {#Function Nat {#Function Nat {#Function Type Type}}} ({0 ({... Jackpot! - (#Parameter id) + {#Parameter id} ({id' - ({#0 (#Parameter id') - #1 (#Parameter ("lux i64 -" 2 id'))} + ({#0 {#Parameter id'} + #1 {#Parameter ("lux i64 -" 2 id')}} (self_id? id))} ("lux i64 -" ("lux i64 -" depth id) 0)) ... Recur - (#Primitive name parameters) - (#Primitive name (list\each (__adjusted_quantified_type__ permission depth) - parameters)) + {#Primitive name parameters} + {#Primitive name (list\each (__adjusted_quantified_type__ permission depth) + parameters)} - (#Sum left right) - (#Sum (__adjusted_quantified_type__ permission depth left) - (__adjusted_quantified_type__ permission depth right)) + {#Sum left right} + {#Sum (__adjusted_quantified_type__ permission depth left) + (__adjusted_quantified_type__ permission depth right)} - (#Product left right) - (#Product (__adjusted_quantified_type__ permission depth left) - (__adjusted_quantified_type__ permission depth right)) + {#Product left right} + {#Product (__adjusted_quantified_type__ permission depth left) + (__adjusted_quantified_type__ permission depth right)} - (#Function input output) - (#Function (__adjusted_quantified_type__ permission depth input) - (__adjusted_quantified_type__ permission depth output)) + {#Function input output} + {#Function (__adjusted_quantified_type__ permission depth input) + (__adjusted_quantified_type__ permission depth output)} - (#UnivQ environment body) - (#UnivQ environment - (__adjusted_quantified_type__ permission (next_level depth) body)) + {#UnivQ environment body} + {#UnivQ environment + (__adjusted_quantified_type__ permission (next_level depth) body)} - (#ExQ environment body) - (#ExQ environment - (__adjusted_quantified_type__ permission (next_level depth) body)) + {#ExQ environment body} + {#ExQ environment + (__adjusted_quantified_type__ permission (next_level depth) body)} - (#Apply parameter function) - (#Apply (__adjusted_quantified_type__ permission depth parameter) - (__adjusted_quantified_type__ permission depth function)) + {#Apply parameter function} + {#Apply (__adjusted_quantified_type__ permission depth parameter) + (__adjusted_quantified_type__ permission depth function)} ... Leave these alone. - (#Named name anonymous) type - (#Var id) type - (#Ex id) type} + {#Named name anonymous} type + {#Var id} type + {#Ex id} type} type) _ @@ -1023,29 +1047,29 @@ permission)) (def:'' .private (with_correct_quantification body) - (#Function Code Code) - (form$ (#Item (identifier$ [prelude_module "__adjusted_quantified_type__"]) - (#Item (local_identifier$ ..quantification_level) - (#Item (nat$ 0) - (#Item body - #End)))))) + {#Function Code Code} + (form$ {#Item (identifier$ [prelude_module "__adjusted_quantified_type__"]) + {#Item (local_identifier$ ..quantification_level) + {#Item (nat$ 0) + {#Item body + #End}}}})) (def:'' .private (with_quantification depth body) - (#Function Nat (#Function Code Code)) + {#Function Nat {#Function Code Code}} ({g!level (let$ g!level - (form$ (#Item (text$ "lux i64 +") - (#Item g!level - (#Item (nat$ ("lux type as" Nat - ("lux i64 *" +2 - ("lux type as" Int - depth)))) - #End)))) + (form$ {#Item (text$ "lux i64 +") + {#Item g!level + {#Item (nat$ ("lux type as" Nat + ("lux i64 *" +2 + ("lux type as" Int + depth)))) + #End}}}) body)} (local_identifier$ ..quantification_level))) (def:'' .private (initialized_quantification? lux) - (#Function Lux Bit) + {#Function Lux Bit} ({[#info _ #source _ #current_module _ #modules _ #scopes scopes #type_context _ #host _ #seed _ #expected _ #location _ #extensions _ @@ -1070,17 +1094,17 @@ lux)) (macro:' .public (All tokens lux) - ({(#Item [_ (#Form (#Item self_name args))] - (#Item body #End)) - (#Right [lux - (#Item ({raw + ({{#Item [_ {#Form {#Item self_name args}}] + {#Item body #End}} + {#Right [lux + {#Item ({raw ({#1 raw #0 (..quantified raw)} (initialized_quantification? lux))} ({#End body - (#Item head tail) + {#Item head tail} (with_correct_quantification (let$ self_name (quantified_type_parameter 0) ({[_ raw] @@ -1095,24 +1119,24 @@ body)] args))))} args)) - #End)]) + #End}]} _ - (#Left "Wrong syntax for All")} + {#Left "Wrong syntax for All"}} tokens)) (macro:' .public (Ex tokens lux) - ({(#Item [_ (#Form (#Item self_name args))] - (#Item body #End)) - (#Right [lux - (#Item ({raw + ({{#Item [_ {#Form {#Item self_name args}}] + {#Item body #End}} + {#Right [lux + {#Item ({raw ({#1 raw #0 (..quantified raw)} (initialized_quantification? lux))} ({#End body - (#Item head tail) + {#Item head tail} (with_correct_quantification (let$ self_name (quantified_type_parameter 0) ({[_ raw] @@ -1127,47 +1151,47 @@ body)] args))))} args)) - #End)]) + #End}]} _ - (#Left "Wrong syntax for Ex")} + {#Left "Wrong syntax for Ex"}} tokens)) (def:'' .private (list\reversed list) (All (_ a) - (#Function ($' List a) ($' List a))) + {#Function ($' List a) ($' List a)}) (list\mix ("lux type check" (All (_ a) - (#Function a (#Function ($' List a) ($' List a)))) - (function'' [head tail] (#Item head tail))) + {#Function a {#Function ($' List a) ($' List a)}}) + (function'' [head tail] {#Item head tail})) #End list)) (macro:' .public (-> tokens) - ({(#Item output inputs) - (in_meta (#Item (list\mix ("lux type check" (#Function Code (#Function Code Code)) - (function'' [i o] (form$ (#Item (tag$ [..prelude_module "Function"]) (#Item i (#Item o #End)))))) + ({{#Item output inputs} + (in_meta {#Item (list\mix ("lux type check" {#Function Code {#Function Code Code}} + (function'' [i o] (variant$ {#Item (tag$ [..prelude_module "Function"]) {#Item i {#Item o #End}}}))) output inputs) - #End)) + #End}) _ (failure "Wrong syntax for ->")} (list\reversed tokens))) (macro:' .public (list xs) - (in_meta (#Item (list\mix (function'' [head tail] - (form$ (#Item (tag$ [..prelude_module "Item"]) - (#Item (tuple$ (#Item [head (#Item [tail #End])])) - #End)))) + (in_meta {#Item (list\mix (function'' [head tail] + (variant$ {#Item (tag$ [..prelude_module "Item"]) + {#Item (tuple$ {#Item [head {#Item [tail #End]}]}) + #End}})) (tag$ [..prelude_module "End"]) (list\reversed xs)) - #End))) + #End})) (macro:' .public (list& xs) - ({(#Item last init) + ({{#Item last init} (in_meta (list (list\mix (function'' [head tail] - (form$ (list (tag$ [..prelude_module "Item"]) - (tuple$ (list head tail))))) + (variant$ (list (tag$ [..prelude_module "Item"]) + (tuple$ (list head tail))))) last init))) @@ -1179,8 +1203,8 @@ ({#End (in_meta (list (identifier$ [..prelude_module "Nothing"]))) - (#Item last prevs) - (in_meta (list (list\mix (function'' [left right] (form$ (list (tag$ [..prelude_module "Sum"]) left right))) + {#Item last prevs} + (in_meta (list (list\mix (function'' [left right] (variant$ (list (tag$ [..prelude_module "Sum"]) left right))) last prevs)))} (list\reversed tokens))) @@ -1189,24 +1213,24 @@ ({#End (in_meta (list (identifier$ [..prelude_module "Any"]))) - (#Item last prevs) - (in_meta (list (list\mix (function'' [left right] (form$ (list (tag$ [..prelude_module "Product"]) left right))) + {#Item last prevs} + (in_meta (list (list\mix (function'' [left right] (variant$ (list (tag$ [..prelude_module "Product"]) left right))) last prevs)))} (list\reversed tokens))) (macro:' .private (function' tokens) - (let'' [name tokens'] ({(#Item [[_ (#Identifier ["" name])] tokens']) + (let'' [name tokens'] ({{#Item [[_ {#Identifier ["" name]}] tokens']} [name tokens'] _ ["" tokens]} tokens) - ({(#Item [[_ (#Tuple args)] (#Item [body #End])]) + ({{#Item [[_ {#Tuple args}] {#Item [body #End]}]} ({#End (failure "function' requires a non-empty arguments tuple.") - (#Item [harg targs]) + {#Item [harg targs]} (in_meta (list (form$ (list (tuple$ (list (local_identifier$ name) harg)) (list\mix (function'' [arg body'] @@ -1222,9 +1246,9 @@ tokens'))) (macro:' .private (def:''' tokens) - ({(#Item [export_policy - (#Item [[_ (#Form (#Item [name args]))] - (#Item [type (#Item [body #End])])])]) + ({{#Item [export_policy + {#Item [[_ {#Form {#Item [name args]}}] + {#Item [type {#Item [body #End]}]}]}]} (in_meta (list (form$ (list (text$ "lux def") name (form$ (list (text$ "lux type check") @@ -1235,7 +1259,7 @@ body)))) export_policy)))) - (#Item [export_policy (#Item [name (#Item [type (#Item [body #End])])])]) + {#Item [export_policy {#Item [name {#Item [type {#Item [body #End]}]}]}]} (in_meta (list (form$ (list (text$ "lux def") name (form$ (list (text$ "lux type check") @@ -1257,15 +1281,15 @@ (def:''' .private (pairs xs) (All (_ a) (-> ($' List a) ($' List (Tuple a a)))) - ({(#Item x (#Item y xs')) - (#Item [x y] (pairs xs')) + ({{#Item x {#Item y xs'}} + {#Item [x y] (pairs xs')} _ #End} xs)) (macro:' .private (let' tokens) - ({(#Item [[_ (#Tuple bindings)] (#Item [body #End])]) + ({{#Item [[_ {#Tuple bindings}] {#Item [body #End]}]} (in_meta (list (list\mix ("lux type check" (-> (Tuple Code Code) Code Code) (function' [binding body] @@ -1285,7 +1309,7 @@ ({#End #0 - (#Item x xs') + {#Item x xs'} ({#1 #1 #0 (any? p xs')} (p x))} @@ -1299,16 +1323,18 @@ (def:''' .private (untemplated_list tokens) (-> ($' List Code) Code) ({#End - (_ann (#Tag [..prelude_module "End"])) + (_ann {#Tag [..prelude_module "End"]}) - (#Item [token tokens']) - (_ann (#Form (list (_ann (#Tag [..prelude_module "Item"])) token (untemplated_list tokens'))))} + {#Item [token tokens']} + (_ann {#Variant (list (_ann {#Tag [..prelude_module "Item"]}) + token + (untemplated_list tokens'))})} tokens)) (def:''' .private (list\composite xs ys) (All (_ a) (-> ($' List a) ($' List a) ($' List a))) - ({(#Item x xs') - (#Item x (list\composite xs' ys)) + ({{#Item x xs'} + {#Item x (list\composite xs' ys)} #End ys} @@ -1316,7 +1342,7 @@ (def:''' .private (right_associativity op a1 a2) (-> Code Code Code Code) - ({[_ (#Form parts)] + ({[_ {#Form parts}] (form$ (list\composite parts (list a1 a2))) _ @@ -1330,8 +1356,8 @@ (func left right))) (macro:' .public (_$ tokens) - ({(#Item op tokens') - ({(#Item first nexts) + ({{#Item op tokens'} + ({{#Item first nexts} (in_meta (list (list\mix (function\flipped (right_associativity op)) first nexts))) _ @@ -1343,8 +1369,8 @@ tokens)) (macro:' .public ($_ tokens) - ({(#Item op tokens') - ({(#Item last prevs) + ({{#Item op tokens'} + ({{#Item last prevs} (in_meta (list (list\mix (right_associativity op) last prevs))) _ @@ -1362,26 +1388,26 @@ ... (: (All (_ a b) (-> (-> a (m b)) (m a) (m b))) ... then))) ("lux def type tagged" Monad - (#Named [..prelude_module "Monad"] - (All (_ !) - (Tuple (All (_ a) - (-> a ($' ! a))) - (All (_ a b) - (-> (-> a ($' ! b)) - ($' ! a) - ($' ! b)))))) + {#Named [..prelude_module "Monad"] + (All (_ !) + (Tuple (All (_ a) + (-> a ($' ! a))) + (All (_ a b) + (-> (-> a ($' ! b)) + ($' ! a) + ($' ! b)))))} ["in" "then"] #0) (def:''' .private maybe_monad ($' Monad Maybe) [#in - (function' [x] (#Some x)) + (function' [x] {#Some x}) #then (function' [f ma] ({#None #None - (#Some a) (f a)} + {#Some a} (f a)} ma))]) (def:''' .private meta_monad @@ -1389,26 +1415,26 @@ [#in (function' [x] (function' [state] - (#Right state x))) + {#Right state x})) #then (function' [f ma] (function' [state] - ({(#Left msg) - (#Left msg) + ({{#Left msg} + {#Left msg} - (#Right [state' a]) + {#Right [state' a]} (f a state')} (ma state))))]) (macro:' .private (do tokens) - ({(#Item monad (#Item [_ (#Tuple bindings)] (#Item body #End))) + ({{#Item monad {#Item [_ {#Tuple bindings}] {#Item body #End}}} (let' [g!in (local_identifier$ "in") g!then (local_identifier$ " then ") body' (list\mix ("lux type check" (-> (Tuple Code Code) Code Code) (function' [binding body'] (let' [[var value] binding] - ({[_ (#Identifier [module short])] + ({[_ {#Identifier [module short]}] ({"" (form$ (list g!then (form$ (list (tuple$ (list (local_identifier$ "") var)) body')) @@ -1445,11 +1471,11 @@ ({#End (in #End) - (#Item x xs') + {#Item x xs'} (do m [y (f x) ys (monad\each m f xs')] - (in (#Item y ys)))} + (in {#Item y ys}))} xs))) (def:''' .private (monad\mix m f y xs) @@ -1463,14 +1489,14 @@ ({#End (in y) - (#Item x xs') + {#Item x xs'} (do m [y' (f x y)] (monad\mix m f y' xs'))} xs))) (macro:' .public (if tokens) - ({(#Item test (#Item then (#Item else #End))) + ({{#Item test {#Item then {#Item else #End}}} (in_meta (list (form$ (list (variant$ (list (bit$ #1) then (bit$ #0) else)) test)))) @@ -1486,9 +1512,9 @@ (def:''' .private (plist\value k plist) (All (_ a) (-> Text ($' PList a) ($' Maybe a))) - ({(#Item [[k' v] plist']) + ({{#Item [[k' v] plist']} (if (text\= k k') - (#Some v) + {#Some v} (plist\value k plist')) #End @@ -1513,37 +1539,37 @@ #scopes scopes #type_context types #host host #seed seed #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars #eval _eval] state] - ({(#Some [#module_hash _ #module_aliases _ #definitions definitions #imports _ #module_state _]) - ({(#Some constant) - ({(#Alias real_name) - (#Right [state real_name]) + ({{#Some [#module_hash _ #module_aliases _ #definitions definitions #imports _ #module_state _]} + ({{#Some constant} + ({{#Alias real_name} + {#Right [state real_name]} - (#Definition [exported? def_type def_value]) - (#Right [state full_name]) + {#Definition [exported? def_type def_value]} + {#Right [state full_name]} - (#Type [exported? type labels]) - (#Right [state full_name]) + {#Type [exported? type labels]} + {#Right [state full_name]} - (#Label _) - (#Left ($_ text\composite "Unknown definition: " (name\encoded full_name))) + {#Label _} + {#Left ($_ text\composite "Unknown definition: " (name\encoded full_name))} - (#Slot _) - (#Left ($_ text\composite "Unknown definition: " (name\encoded full_name)))} + {#Slot _} + {#Left ($_ text\composite "Unknown definition: " (name\encoded full_name))}} constant) #None - (#Left ($_ text\composite "Unknown definition: " (name\encoded full_name)))} + {#Left ($_ text\composite "Unknown definition: " (name\encoded full_name))}} (plist\value name definitions)) #None - (#Left ($_ text\composite "Unknown module: " module " @ " (name\encoded full_name)))} + {#Left ($_ text\composite "Unknown module: " module " @ " (name\encoded full_name))}} (plist\value module modules)))) (def:''' .private (code_list expression) (-> Code Code) - (let' [type (form$ (list (tag$ [..prelude_module "Apply"]) - (identifier$ [..prelude_module "Code"]) - (identifier$ [..prelude_module "List"])))] + (let' [type (variant$ (list (tag$ [..prelude_module "Apply"]) + (identifier$ [..prelude_module "Code"]) + (identifier$ [..prelude_module "List"])))] (form$ (list (text$ "lux type check") type expression)))) (def:''' .private (spliced replace? untemplated elems) @@ -1552,20 +1578,20 @@ ({#End (in_meta (tag$ [..prelude_module "End"])) - (#Item lastI inits) + {#Item lastI inits} (do meta_monad - [lastO ({[_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))] + [lastO ({[_ {#Form {#Item [[_ {#Identifier ["" "~+"]}] {#Item [spliced #End]}]}}] (in (code_list spliced)) _ (do meta_monad [lastO (untemplated lastI)] - (in (code_list (form$ (list (tag$ [..prelude_module "Item"]) - (tuple$ (list lastO (tag$ [..prelude_module "End"]))))))))} + (in (code_list (variant$ (list (tag$ [..prelude_module "Item"]) + (tuple$ (list lastO (tag$ [..prelude_module "End"]))))))))} lastI)] (monad\mix meta_monad (function' [leftI rightO] - ({[_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))] + ({[_ {#Form {#Item [[_ {#Identifier ["" "~+"]}] {#Item [spliced #End]}]}}] (let' [g!in-module (form$ (list (text$ "lux in-module") (text$ ..prelude_module) (identifier$ [..prelude_module "list\composite"])))] @@ -1574,7 +1600,7 @@ _ (do meta_monad [leftO (untemplated leftI)] - (in (form$ (list (tag$ [..prelude_module "Item"]) (tuple$ (list leftO rightO))))))} + (in (variant$ (list (tag$ [..prelude_module "Item"]) (tuple$ (list leftO rightO))))))} leftI)) lastO inits))} @@ -1587,41 +1613,41 @@ (def:''' .private (untemplated_text value) (-> Text Code) - (with_location (form$ (list (tag$ [..prelude_module "Text"]) (text$ value))))) + (with_location (variant$ (list (tag$ [..prelude_module "Text"]) (text$ value))))) (def:''' .private (untemplated replace? subst token) (-> Bit Text Code ($' Meta Code)) - ({[_ [_ (#Bit value)]] - (in_meta (with_location (form$ (list (tag$ [..prelude_module "Bit"]) (bit$ value))))) + ({[_ [_ {#Bit value}]] + (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Bit"]) (bit$ value))))) - [_ [_ (#Nat value)]] - (in_meta (with_location (form$ (list (tag$ [..prelude_module "Nat"]) (nat$ value))))) + [_ [_ {#Nat value}]] + (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Nat"]) (nat$ value))))) - [_ [_ (#Int value)]] - (in_meta (with_location (form$ (list (tag$ [..prelude_module "Int"]) (int$ value))))) + [_ [_ {#Int value}]] + (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Int"]) (int$ value))))) - [_ [_ (#Rev value)]] - (in_meta (with_location (form$ (list (tag$ [..prelude_module "Rev"]) (rev$ value))))) + [_ [_ {#Rev value}]] + (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Rev"]) (rev$ value))))) - [_ [_ (#Frac value)]] - (in_meta (with_location (form$ (list (tag$ [..prelude_module "Frac"]) (frac$ value))))) + [_ [_ {#Frac value}]] + (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Frac"]) (frac$ value))))) - [_ [_ (#Text value)]] + [_ [_ {#Text value}]] (in_meta (untemplated_text value)) - [#0 [_ (#Tag [module name])]] - (in_meta (with_location (form$ (list (tag$ [..prelude_module "Tag"]) (tuple$ (list (text$ module) (text$ name))))))) + [#0 [_ {#Tag [module name]}]] + (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Tag"]) (tuple$ (list (text$ module) (text$ name))))))) - [#1 [_ (#Tag [module name])]] + [#1 [_ {#Tag [module name]}]] (let' [module' ({"" subst _ module} module)] - (in_meta (with_location (form$ (list (tag$ [..prelude_module "Tag"]) (tuple$ (list (text$ module') (text$ name)))))))) + (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Tag"]) (tuple$ (list (text$ module') (text$ name)))))))) - [#1 [_ (#Identifier [module name])]] + [#1 [_ {#Identifier [module name]}]] (do meta_monad [real_name ({"" (if (text\= "" subst) @@ -1632,52 +1658,52 @@ (in [module name])} module) .let' [[module name] real_name]] - (in_meta (with_location (form$ (list (tag$ [..prelude_module "Identifier"]) (tuple$ (list (text$ module) (text$ name)))))))) + (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Identifier"]) (tuple$ (list (text$ module) (text$ name)))))))) - [#0 [_ (#Identifier [module name])]] - (in_meta (with_location (form$ (list (tag$ [..prelude_module "Identifier"]) (tuple$ (list (text$ module) (text$ name))))))) + [#0 [_ {#Identifier [module name]}]] + (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Identifier"]) (tuple$ (list (text$ module) (text$ name))))))) - [#1 [_ (#Form (#Item [[_ (#Identifier ["" "~"])] (#Item [unquoted #End])]))]] + [#1 [_ {#Form {#Item [[_ {#Identifier ["" "~"]}] {#Item [unquoted #End]}]}}]] (in_meta (form$ (list (text$ "lux type check") (identifier$ [..prelude_module "Code"]) unquoted))) - [#1 [_ (#Form (#Item [[_ (#Identifier ["" "~!"])] (#Item [dependent #End])]))]] + [#1 [_ {#Form {#Item [[_ {#Identifier ["" "~!"]}] {#Item [dependent #End]}]}}]] (do meta_monad [independent (untemplated replace? subst dependent)] - (in (with_location (form$ (list (tag$ [..prelude_module "Form"]) - (untemplated_list (list (untemplated_text "lux in-module") - (untemplated_text subst) - independent))))))) + (in (with_location (variant$ (list (tag$ [..prelude_module "Form"]) + (untemplated_list (list (untemplated_text "lux in-module") + (untemplated_text subst) + independent))))))) - [#1 [_ (#Form (#Item [[_ (#Identifier ["" "~'"])] (#Item [keep_quoted #End])]))]] + [#1 [_ {#Form {#Item [[_ {#Identifier ["" "~'"]}] {#Item [keep_quoted #End]}]}}]] (untemplated #0 subst keep_quoted) - [_ [meta (#Form elems)]] + [_ [meta {#Form elems}]] (do meta_monad [output (spliced replace? (untemplated replace? subst) elems) - .let' [[_ output'] (with_location (form$ (list (tag$ [..prelude_module "Form"]) output)))]] + .let' [[_ output'] (with_location (variant$ (list (tag$ [..prelude_module "Form"]) output)))]] (in [meta output'])) - [_ [meta (#Variant elems)]] + [_ [meta {#Variant elems}]] (do meta_monad [output (spliced replace? (untemplated replace? subst) elems) - .let' [[_ output'] (with_location (form$ (list (tag$ [..prelude_module "Variant"]) output)))]] + .let' [[_ output'] (with_location (variant$ (list (tag$ [..prelude_module "Variant"]) output)))]] (in [meta output'])) - [_ [meta (#Tuple elems)]] + [_ [meta {#Tuple elems}]] (do meta_monad [output (spliced replace? (untemplated replace? subst) elems) - .let' [[_ output'] (with_location (form$ (list (tag$ [..prelude_module "Tuple"]) output)))]] + .let' [[_ output'] (with_location (variant$ (list (tag$ [..prelude_module "Tuple"]) output)))]] (in [meta output']))} [replace? token])) (macro:' .public (primitive tokens) - ({(#Item [_ (#Text class_name)] #End) - (in_meta (list (form$ (list (tag$ [..prelude_module "Primitive"]) (text$ class_name) (tag$ [..prelude_module "End"]))))) + ({{#Item [_ {#Text class_name}] #End} + (in_meta (list (variant$ (list (tag$ [..prelude_module "Primitive"]) (text$ class_name) (tag$ [..prelude_module "End"]))))) - (#Item [_ (#Text class_name)] (#Item [_ (#Tuple params)] #End)) - (in_meta (list (form$ (list (tag$ [..prelude_module "Primitive"]) (text$ class_name) (untemplated_list params))))) + {#Item [_ {#Text class_name}] {#Item [_ {#Tuple params}] #End}} + (in_meta (list (variant$ (list (tag$ [..prelude_module "Primitive"]) (text$ class_name) (untemplated_list params))))) _ (failure "Wrong syntax for primitive")} @@ -1689,16 +1715,16 @@ #scopes scopes #type_context types #host host #seed seed #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars #eval _eval] - ({(#Some module_name) - (#Right [state module_name]) + ({{#Some module_name} + {#Right [state module_name]} _ - (#Left "Cannot get the module name without a module!")} + {#Left "Cannot get the module name without a module!"}} current_module)} state)) (macro:' .public (` tokens) - ({(#Item template #End) + ({{#Item template #End} (do meta_monad [current_module current_module_name =template (untemplated #1 current_module template)] @@ -1711,7 +1737,7 @@ tokens)) (macro:' .public (`' tokens) - ({(#Item template #End) + ({{#Item template #End} (do meta_monad [=template (untemplated #1 "" template)] (in (list (form$ (list (text$ "lux type check") (identifier$ [..prelude_module "Code"]) =template))))) @@ -1721,7 +1747,7 @@ tokens)) (macro:' .public (' tokens) - ({(#Item template #End) + ({{#Item template #End} (do meta_monad [=template (untemplated #0 "" template)] (in (list (form$ (list (text$ "lux type check") (identifier$ [..prelude_module "Code"]) =template))))) @@ -1731,15 +1757,21 @@ tokens)) (macro:' .public (|> tokens) - ({(#Item [init apps]) + ({{#Item [init apps]} (in_meta (list (list\mix ("lux type check" (-> Code Code Code) (function' [app acc] - ({[_ (#Tuple parts)] + ({[_ {#Variant parts}] + (variant$ (list\composite parts (list acc))) + + [_ {#Tuple parts}] (tuple$ (list\composite parts (list acc))) - [_ (#Form parts)] + [_ {#Form parts}] (form$ (list\composite parts (list acc))) + [_ {#Tag _}] + (` {(~ app) (~ acc)}) + _ (` ((~ app) (~ acc)))} app))) @@ -1751,15 +1783,21 @@ tokens)) (macro:' .public (<| tokens) - ({(#Item [init apps]) + ({{#Item [init apps]} (in_meta (list (list\mix ("lux type check" (-> Code Code Code) (function' [app acc] - ({[_ (#Tuple parts)] + ({[_ {#Variant parts}] + (variant$ (list\composite parts (list acc))) + + [_ {#Tuple parts}] (tuple$ (list\composite parts (list acc))) - [_ (#Form parts)] + [_ {#Form parts}] (form$ (list\composite parts (list acc))) + [_ {#Tag name}] + (` {(~ app) (~ acc)}) + _ (` ((~ app) (~ acc)))} app))) @@ -1777,8 +1815,8 @@ (def:''' .private (identifier_name x) (-> Code ($' Maybe Name)) - ({[_ (#Identifier sname)] - (#Some sname) + ({[_ {#Identifier sname}] + {#Some sname} _ #None} @@ -1786,8 +1824,8 @@ (def:''' .private (tag_name x) (-> Code ($' Maybe Name)) - ({[_ (#Tag sname)] - (#Some sname) + ({[_ {#Tag sname}] + {#Some sname} _ #None} @@ -1795,8 +1833,8 @@ (def:''' .private (identifier_short x) (-> Code ($' Maybe Text)) - ({[_ (#Identifier "" sname)] - (#Some sname) + ({[_ {#Identifier "" sname}] + {#Some sname} _ #None} @@ -1804,8 +1842,8 @@ (def:''' .private (tuple_list tuple) (-> Code ($' Maybe ($' List Code))) - ({[_ (#Tuple members)] - (#Some members) + ({[_ {#Tuple members}] + {#Some members} _ #None} @@ -1813,22 +1851,22 @@ (def:''' .private (realized_template env template) (-> Replacement_Environment Code Code) - ({[_ (#Identifier "" sname)] - ({(#Some subst) + ({[_ {#Identifier "" sname}] + ({{#Some subst} subst _ template} (..replacement sname env)) - [meta (#Form elems)] - [meta (#Form (list\each (realized_template env) elems))] + [meta {#Form elems}] + [meta {#Form (list\each (realized_template env) elems)}] - [meta (#Tuple elems)] - [meta (#Tuple (list\each (realized_template env) elems))] + [meta {#Tuple elems}] + [meta {#Tuple (list\each (realized_template env) elems)}] - [meta (#Variant elems)] - [meta (#Variant (list\each (realized_template env) elems))] + [meta {#Variant elems}] + [meta {#Variant (list\each (realized_template env) elems)}] _ template} @@ -1869,8 +1907,8 @@ (list\mix list\composite #End (list\reversed xs))) (macro:' .public (template tokens) - ({(#Item [[_ (#Tuple bindings)] (#Item [[_ (#Tuple templates)] data])]) - ({[(#Some bindings') (#Some data')] + ({{#Item [[_ {#Tuple bindings}] {#Item [[_ {#Tuple templates}] data]}]} + ({[{#Some bindings'} {#Some data'}] (let' [apply ("lux type check" (-> Replacement_Environment ($' List Code)) (function' [env] (list\each (realized_template env) templates))) num_bindings (list\size bindings')] @@ -1988,7 +2026,7 @@ (def:''' .private (macro_type? type) (-> Type Bit) - ({(#Named ["library/lux" "Macro"] (#Primitive "#Macro" #End)) + ({{#Named ["library/lux" "Macro"] {#Primitive "#Macro" #End}} #1 _ @@ -2003,25 +2041,25 @@ [$module (plist\value module modules) gdef (let' [[#module_hash _ #module_aliases _ #definitions bindings #imports _ #module_state _] ("lux type check" Module $module)] (plist\value name bindings))] - ({(#Alias [r_module r_name]) + ({{#Alias [r_module r_name]} (macro'' modules current_module r_module r_name) - (#Definition [exported? def_type def_value]) + {#Definition [exported? def_type def_value]} (if (macro_type? def_type) (if exported? - (#Some ("lux type as" Macro def_value)) + {#Some ("lux type as" Macro def_value)} (if (text\= module current_module) - (#Some ("lux type as" Macro def_value)) + {#Some ("lux type as" Macro def_value)} #None)) #None) - (#Type [exported? type labels]) + {#Type [exported? type labels]} #None - (#Label _) + {#Label _} #None - (#Slot _) + {#Slot _} #None} ("lux type check" Global gdef)))) @@ -2047,7 +2085,7 @@ #seed seed #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars #eval _eval] - (#Right state (macro'' modules current_module module name))} + {#Right state (macro'' modules current_module module name)}} state))))) (def:''' .private (macro? name) @@ -2055,7 +2093,7 @@ (do meta_monad [name (normal name) output (macro' name)] - (in ({(#Some _) #1 + (in ({{#Some _} #1 #None #0} output)))) @@ -2065,20 +2103,20 @@ ({#End xs - (#Item [x #End]) + {#Item [x #End]} xs - (#Item [x xs']) + {#Item [x xs']} (list& x sep (list\interposed sep xs'))} xs)) (def:''' .private (single_expansion token) (-> Code ($' Meta ($' List Code))) - ({[_ (#Form (#Item [_ (#Identifier name)] args))] + ({[_ {#Form {#Item [_ {#Identifier name}] args}}] (do meta_monad [name' (normal name) ?macro (macro' name')] - ({(#Some macro) + ({{#Some macro} (("lux type as" Macro' macro) args) #None @@ -2091,11 +2129,11 @@ (def:''' .private (expansion token) (-> Code ($' Meta ($' List Code))) - ({[_ (#Form (#Item [_ (#Identifier name)] args))] + ({[_ {#Form {#Item [_ {#Identifier name}] args}}] (do meta_monad [name' (normal name) ?macro (macro' name')] - ({(#Some macro) + ({{#Some macro} (do meta_monad [top_level_expansion (("lux type as" Macro' macro) args) recursive_expansion (monad\each meta_monad expansion top_level_expansion)] @@ -2111,11 +2149,11 @@ (def:''' .private (full_expansion syntax) (-> Code ($' Meta ($' List Code))) - ({[_ (#Form (#Item [_ (#Identifier name)] args))] + ({[_ {#Form {#Item [_ {#Identifier name}] args}}] (do meta_monad [name' (normal name) ?macro (macro' name')] - ({(#Some macro) + ({{#Some macro} (do meta_monad [expansion (("lux type as" Macro' macro) args) expansion' (monad\each meta_monad full_expansion expansion)] @@ -2124,23 +2162,23 @@ #None (do meta_monad [args' (monad\each meta_monad full_expansion args)] - (in (list (form$ (#Item (identifier$ name) (list\conjoint args'))))))} + (in (list (form$ {#Item (identifier$ name) (list\conjoint args')}))))} ?macro)) - [_ (#Form members)] + [_ {#Form members}] (do meta_monad [members' (monad\each meta_monad full_expansion members)] (in (list (form$ (list\conjoint members'))))) - [_ (#Tuple members)] + [_ {#Variant members}] (do meta_monad [members' (monad\each meta_monad full_expansion members)] - (in (list (tuple$ (list\conjoint members'))))) + (in (list (variant$ (list\conjoint members'))))) - [_ (#Variant members)] + [_ {#Tuple members}] (do meta_monad [members' (monad\each meta_monad full_expansion members)] - (in (list (variant$ (list\conjoint members'))))) + (in (list (tuple$ (list\conjoint members'))))) _ (in_meta (list syntax))} @@ -2152,49 +2190,49 @@ (def:''' .private (code\encoded code) (-> Code Text) - ({[_ (#Bit value)] + ({[_ {#Bit value}] (bit\encoded value) - [_ (#Nat value)] + [_ {#Nat value}] (nat\encoded value) - [_ (#Int value)] + [_ {#Int value}] (int\encoded value) - [_ (#Rev value)] + [_ {#Rev value}] ("lux io error" "@code\encoded Undefined behavior.") - [_ (#Frac value)] + [_ {#Frac value}] (frac\encoded value) - [_ (#Text value)] + [_ {#Text value}] (text\encoded value) - [_ (#Identifier [module name])] + [_ {#Identifier [module name]}] (if (text\= "" module) name ($_ text\composite module "." name)) - [_ (#Tag [module name])] + [_ {#Tag [module name]}] (if (text\= "" module) ($_ text\composite "#" name) ($_ text\composite "#" module "." name)) - [_ (#Form xs)] + [_ {#Form xs}] ($_ text\composite "(" (|> xs (list\each code\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")") - [_ (#Tuple xs)] + [_ {#Tuple xs}] ($_ text\composite "[" (|> xs (list\each code\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) "]") - [_ (#Variant xs)] + [_ {#Variant xs}] ($_ text\composite "{" (|> xs (list\each code\encoded) (list\interposed " ") @@ -2204,45 +2242,45 @@ (def:''' .private (normal_type type) (-> Code Code) - ({[_ (#Form (#Item [_ (#Tag tag)] parts))] - (form$ (#Item (tag$ tag) (list\each normal_type parts))) + ({[_ {#Variant {#Item [_ {#Tag tag}] parts}}] + (` {(~ (tag$ tag)) (~+ (list\each normal_type parts))}) - [_ (#Variant members)] + [_ {#Variant members}] (` (Or (~+ (list\each normal_type members)))) - [_ (#Tuple members)] + [_ {#Tuple members}] (` (Tuple (~+ (list\each normal_type members)))) - [_ (#Form (#Item [_ (#Text "lux in-module")] - (#Item [_ (#Text module)] - (#Item type' - #End))))] + [_ {#Form {#Item [_ {#Text "lux in-module"}] + {#Item [_ {#Text module}] + {#Item type' + #End}}}}] (` ("lux in-module" (~ (text$ module)) (~ (normal_type type')))) - [_ (#Form (#Item [_ (#Identifier ["" ":~"])] (#Item expression #End)))] + [_ {#Form {#Item [_ {#Identifier ["" ":~"]}] {#Item expression #End}}}] expression - [_0 (#Form (#Item [_1 (#Variant (#Item binding (#Item body #End)))] - (#Item value - #End)))] - [_0 (#Form (#Item [_1 (#Variant (#Item binding (#Item (normal_type body) #End)))] - (#Item value - #End)))] - - [_0 (#Form (#Item [_1 (#Identifier ["library/lux" "__adjusted_quantified_type__"])] - (#Item _permission - (#Item _level - (#Item body - #End)))))] - [_0 (#Form (#Item [_1 (#Identifier [..prelude_module "__adjusted_quantified_type__"])] - (#Item _permission - (#Item _level - (#Item (normal_type body) - #End)))))] - - [_ (#Form (#Item type_fn args))] + [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item body #End}}}] + {#Item value + #End}}}] + [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item (normal_type body) #End}}}] + {#Item value + #End}}}] + + [_0 {#Form {#Item [_1 {#Identifier ["library/lux" "__adjusted_quantified_type__"]}] + {#Item _permission + {#Item _level + {#Item body + #End}}}}}] + [_0 {#Form {#Item [_1 {#Identifier [..prelude_module "__adjusted_quantified_type__"]}] + {#Item _permission + {#Item _level + {#Item (normal_type body) + #End}}}}}] + + [_ {#Form {#Item type_fn args}}] (list\mix ("lux type check" (-> Code Code Code) - (function' [arg type_fn] (` (#.Apply (~ arg) (~ type_fn))))) + (function' [arg type_fn] (` {#.Apply (~ arg) (~ type_fn)}))) (normal_type type_fn) (list\each normal_type args)) @@ -2251,13 +2289,13 @@ type)) (macro:' .public (type tokens) - ({(#Item type #End) + ({{#Item type #End} (do meta_monad - [initialized_quantification? (function' [lux] (#Right [lux (initialized_quantification? lux)]))] + [initialized_quantification? (function' [lux] {#Right [lux (initialized_quantification? lux)]})] (if initialized_quantification? (do meta_monad [type+ (full_expansion type)] - ({(#Item type' #End) + ({{#Item type' #End} (in (list (normal_type type'))) _ @@ -2270,7 +2308,7 @@ tokens)) (macro:' .public (: tokens) - ({(#Item type (#Item value #End)) + ({{#Item type {#Item value #End}} (in_meta (list (` ("lux type check" (..type (~ type)) (~ value))))) @@ -2280,7 +2318,7 @@ tokens)) (macro:' .public (:as tokens) - ({(#Item type (#Item value #End)) + ({{#Item type {#Item value #End}} (in_meta (list (` ("lux type as" (..type (~ type)) (~ value))))) @@ -2313,16 +2351,16 @@ #seed seed #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars #eval _eval] - (#Right [#info info #source source #current_module _ #modules modules + {#Right [#info info #source source #current_module _ #modules modules #scopes scopes #type_context types #host host #seed ("lux i64 +" 1 seed) #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars #eval _eval] - (local_identifier$ ($_ text\composite "__gensym__" prefix (nat\encoded seed))))} + (local_identifier$ ($_ text\composite "__gensym__" prefix (nat\encoded seed)))}} state)) (macro:' .public (exec tokens) - ({(#Item value actions) + ({{#Item value actions} (let' [dummy (local_identifier$ "")] (in_meta (list (list\mix ("lux type check" (-> Code Code Code) (function' [pre post] (` ({(~ dummy) (~ post)} @@ -2336,29 +2374,29 @@ (macro:' .private (def:' tokens) (let' [parts (: (Maybe [Code Code (List Code) (Maybe Code) Code]) - ({(#Item export_policy (#Item [_ (#Form (#Item name args))] (#Item type (#Item body #End)))) - (#Some [export_policy name args (#Some type) body]) + ({{#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item type {#Item body #End}}}} + {#Some [export_policy name args {#Some type} body]} - (#Item export_policy (#Item name (#Item type (#Item body #End)))) - (#Some [export_policy name #End (#Some type) body]) + {#Item export_policy {#Item name {#Item type {#Item body #End}}}} + {#Some [export_policy name #End {#Some type} body]} - (#Item export_policy (#Item [_ (#Form (#Item name args))] (#Item body #End))) - (#Some [export_policy name args #None body]) + {#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item body #End}}} + {#Some [export_policy name args #None body]} - (#Item export_policy (#Item name (#Item body #End))) - (#Some [export_policy name #End #None body]) + {#Item export_policy {#Item name {#Item body #End}}} + {#Some [export_policy name #End #None body]} _ #None} tokens))] - ({(#Some [export_policy name args ?type body]) + ({{#Some [export_policy name args ?type body]} (let' [body' ({#End body _ (` (function' (~ name) [(~+ args)] (~ body)))} args) - body'' ({(#Some type) + body'' ({{#Some type} (` (: (~ type) (~ body'))) #None @@ -2374,9 +2412,9 @@ (def:' .private (expander branches) (-> (List Code) (Meta (List Code))) - ({(#Item [_ (#Form (#Item [_ (#Identifier name)] args))] - (#Item body - branches')) + ({{#Item [_ {#Form {#Item [_ {#Identifier name}] args}}] + {#Item body + branches'}} (do meta_monad [??? (macro? name)] (if ??? @@ -2389,7 +2427,7 @@ body sub_expansion))))) - (#Item pattern (#Item body branches')) + {#Item pattern {#Item body branches'}} (do meta_monad [sub_expansion (expander branches')] (in (list& pattern body sub_expansion))) @@ -2406,7 +2444,7 @@ branches)) (macro:' .public (case tokens) - ({(#Item value branches) + ({{#Item value branches} (do meta_monad [expansion (expander branches)] (in (list (` ((~ (variant$ expansion)) (~ value)))))) @@ -2417,11 +2455,11 @@ (macro:' .public (^ tokens) (case tokens - (#Item [_ (#Form (#Item pattern #End))] (#Item body branches)) + {#Item [_ {#Form {#Item pattern #End}}] {#Item body branches}} (do meta_monad [pattern+ (full_expansion pattern)] (case pattern+ - (#Item pattern' #End) + {#Item pattern' #End} (in (list& pattern' body branches)) _ @@ -2432,7 +2470,7 @@ (macro:' .public (^or tokens) (case tokens - (^ (list& [_ (#Form patterns)] body branches)) + (^ (list& [_ {#Form patterns}] body branches)) (case patterns #End (failure "^or cannot have 0 patterns") @@ -2448,7 +2486,7 @@ (def:' .private (identifier? code) (-> Code Bit) (case code - [_ (#Identifier _)] + [_ {#Identifier _}] #1 _ @@ -2456,7 +2494,7 @@ (macro:' .public (let tokens) (case tokens - (^ (list [_ (#Tuple bindings)] body)) + (^ (list [_ {#Tuple bindings}] body)) (if (multiple? 2 (list\size bindings)) (|> bindings pairs list\reversed (list\mix (: (-> [Code Code] Code Code) @@ -2476,12 +2514,12 @@ (macro:' .public (function tokens) (case (: (Maybe [Text Code (List Code) Code]) (case tokens - (^ (list [_ (#Form (list& [_ (#Identifier ["" name])] head tail))] body)) - (#Some name head tail body) + (^ (list [_ {#Form (list& [_ {#Identifier ["" name]}] head tail)}] body)) + {#Some name head tail body} _ #None)) - (#Some g!name head tail body) + {#Some g!name head tail body} (let [g!blank (local_identifier$ "") nest (: (-> Code (-> Code Code Code)) (function' [g!name] @@ -2500,7 +2538,7 @@ (-> (List Code) (Maybe Any)) (case tokens (^ (list)) - (#Some []) + {#Some []} _ #None)) @@ -2509,7 +2547,7 @@ (-> (List Code) (Maybe [(List Code) Code])) (case tokens (^ (list& code tokens')) - (#Some [tokens' code]) + {#Some [tokens' code]} _ #None)) @@ -2517,8 +2555,8 @@ (def:' .private (local_identifierP tokens) (-> (List Code) (Maybe [(List Code) Text])) (case tokens - (^ (list& [_ (#Identifier ["" local_identifier])] tokens')) - (#Some [tokens' local_identifier]) + (^ (list& [_ {#Identifier ["" local_identifier]}] tokens')) + {#Some [tokens' local_identifier]} _ #None)) @@ -2528,14 +2566,14 @@ (-> (List Code) (Maybe (List ))) (case tokens #End - (#Some #End) + {#Some #End} _ (do maybe_monad [% ( tokens) .let' [[tokens head] %] tail ( tokens)] - (in (#Item head tail)))))] + (in {#Item head tail}))))] [parametersP Text local_identifierP] [enhanced_parametersP Code anyP] @@ -2545,7 +2583,7 @@ [(def:' .private ( tokens) (-> (List Code) (Maybe [(List Code) [Text (List )]])) (case tokens - (^ (list& [_ (#Form local_declaration)] tokens')) + (^ (list& [_ {#Form local_declaration}] tokens')) (do maybe_monad [% (local_identifierP local_declaration) .let' [[local_declaration name] %] @@ -2567,13 +2605,13 @@ (case tokens (^ (list& candidate tokens')) (case candidate - [_ (#Bit it)] + [_ {#Bit it}] [tokens' candidate] - [_ (#Identifier ["" _])] + [_ {#Identifier ["" _]}] [tokens (` .private)] - [_ (#Identifier it)] + [_ {#Identifier it}] [tokens' candidate] _ @@ -2600,11 +2638,11 @@ (case tokens ... TB (^ (list& type body tokens')) - (#Some [tokens' [(#Some type) body]]) + {#Some [tokens' [{#Some type} body]]} ... B (^ (list& body tokens')) - (#Some [tokens' [#None body]]) + {#Some [tokens' [#None body]]} _ #None)) @@ -2621,7 +2659,7 @@ (macro:' .public (def: tokens) (case (definitionP tokens) - (#Some [export_policy name parameters ?type body]) + {#Some [export_policy name parameters ?type body]} (let [body (case parameters #End body @@ -2630,7 +2668,7 @@ (` (function ((~ (..local_identifier$ name)) (~+ parameters)) (~ body)))) body (case ?type - (#Some type) + {#Some type} (` (: (~ type) (~ body))) @@ -2655,7 +2693,7 @@ (macro:' .public (macro: tokens) (case (macroP tokens) - (#Some [export_policy name args body]) + {#Some [export_policy name args body]} (let [name (local_identifier$ name) body (case args #End @@ -2678,13 +2716,13 @@ #End #None - (#Item x xs') + {#Item x xs'} (case (f x) #None (list\one f xs') - (#Some y) - (#Some y)))) + {#Some y} + {#Some y}))) (template [
] [(macro: .public ( tokens) @@ -2712,17 +2750,17 @@ (macro: (maybe\else tokens state) (case tokens (^ (list else maybe)) - (let [g!temp (: Code [dummy_location (#Identifier ["" ""])]) + (let [g!temp (: Code [dummy_location {#Identifier ["" ""]}]) code (` (case (~ maybe) - (#.Some (~ g!temp)) + {#.Some (~ g!temp)} (~ g!temp) #.None (~ else)))] - (#Right [state (list code)])) + {#Right [state (list code)]}) _ - (#Left "Wrong syntax for maybe\else"))) + {#Left "Wrong syntax for maybe\else"})) (def: (text\all_split_by splitter input) (-> Text Text (List Text)) @@ -2730,7 +2768,7 @@ #None (list input) - (#Some idx) + {#Some idx} (list& ("lux text clip" 0 idx input) (text\all_split_by splitter (let [after_offset ("lux i64 +" 1 idx) @@ -2746,52 +2784,52 @@ #End #None - (#Item x xs') + {#Item x xs'} (if ("lux i64 =" 0 idx) - (#Some x) + {#Some x} (item ("lux i64 -" 1 idx) xs')))) ... https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction (def: (reduced env type) (-> (List Type) Type Type) (case type - (#Sum left right) - (#Sum (reduced env left) (reduced env right)) + {#Sum left right} + {#Sum (reduced env left) (reduced env right)} - (#Product left right) - (#Product (reduced env left) (reduced env right)) + {#Product left right} + {#Product (reduced env left) (reduced env right)} - (#Apply arg func) - (#Apply (reduced env arg) (reduced env func)) + {#Apply arg func} + {#Apply (reduced env arg) (reduced env func)} - (#UnivQ ?local_env ?local_def) + {#UnivQ ?local_env ?local_def} (case ?local_env #End - (#UnivQ env ?local_def) + {#UnivQ env ?local_def} _ type) - (#ExQ ?local_env ?local_def) + {#ExQ ?local_env ?local_def} (case ?local_env #End - (#ExQ env ?local_def) + {#ExQ env ?local_def} _ type) - (#Function ?input ?output) - (#Function (reduced env ?input) (reduced env ?output)) + {#Function ?input ?output} + {#Function (reduced env ?input) (reduced env ?output)} - (#Parameter idx) + {#Parameter idx} (case (item idx env) - (#Some parameter) + {#Some parameter} parameter _ type) - (#Named name type) + {#Named name type} (reduced env type) _ @@ -2801,18 +2839,18 @@ (def: (applied_type param type_fn) (-> Type Type (Maybe Type)) (case type_fn - (#UnivQ env body) - (#Some (reduced (list& type_fn param env) body)) + {#UnivQ env body} + {#Some (reduced (list& type_fn param env) body)} - (#ExQ env body) - (#Some (reduced (list& type_fn param env) body)) + {#ExQ env body} + {#Some (reduced (list& type_fn param env) body)} - (#Apply A F) + {#Apply A F} (do maybe_monad [type_fn* (applied_type A F)] (applied_type param type_fn*)) - (#Named name type) + {#Named name type} (applied_type param type) _ @@ -2822,7 +2860,7 @@ [(def: ( type) (-> Type (List Type)) (case type - ( left right) + { left right} (list& left ( right)) _ @@ -2836,9 +2874,9 @@ (def: (flat_application type) (-> Type [Type (List Type)]) (case type - (#Apply head func') + {#Apply head func'} (let [[func tail] (flat_application func')] - [func (#Item head tail)]) + [func {#Item head tail}]) _ [type (list)])) @@ -2846,28 +2884,28 @@ (def: (interface_methods type) (-> Type (Maybe (List Type))) (case type - (#Product _) - (#Some (flat_tuple type)) + {#Product _} + {#Some (flat_tuple type)} - (#Apply arg func) + {#Apply arg func} (do maybe_monad [output (applied_type arg func)] (interface_methods output)) - (#UnivQ _ body) + {#UnivQ _ body} (interface_methods body) - (#ExQ _ body) + {#ExQ _ body} (interface_methods body) - (#Named name type) + {#Named name type} (interface_methods type) - (#Sum _) + {#Sum _} #None _ - (#Some (list type)))) + {#Some (list type)})) (def: (module name) (-> Text (Meta Module)) @@ -2877,11 +2915,11 @@ #seed seed #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars #eval _eval] state] (case (plist\value name modules) - (#Some module) - (#Right state module) + {#Some module} + {#Right state module} _ - (#Left ($_ text\composite "Unknown module: " name)))))) + {#Left ($_ text\composite "Unknown module: " name)})))) (def: (type_slot [module name]) (-> Name (Meta [Nat (List Name) Bit Type])) @@ -2889,7 +2927,7 @@ [=module (..module module) .let [[#module_hash _ #module_aliases _ #definitions definitions #imports _ #module_state _] =module]] (case (plist\value (text\composite "#" name) definitions) - (#Some (#Slot [exported type group index])) + {#Some {#Slot [exported type group index]}} (in_meta [index (list\each (function (_ slot) [module slot]) @@ -2903,26 +2941,26 @@ (def: (record_slots type) (-> Type (Meta (Maybe [(List Name) (List Type)]))) (case type - (#Apply arg func) + {#Apply arg func} (record_slots func) - (#UnivQ env body) + {#UnivQ env body} (record_slots body) - (#ExQ env body) + {#ExQ env body} (record_slots body) - (#Named [module name] unnamed) + {#Named [module name] unnamed} (do meta_monad [=module (..module module) .let [[#module_hash _ #module_aliases _ #definitions definitions #imports _ #module_state _] =module]] (case (plist\value name definitions) - (#Some (#Type [exported? (#Named _ _type) (#Right slots)])) + {#Some {#Type [exported? {#Named _ _type} {#Right slots}]}} (case (interface_methods _type) - (#Some members) - (in_meta (#Some [(list\each (function (_ slot) [module slot]) - (#Item slots)) - members])) + {#Some members} + (in_meta {#Some [(list\each (function (_ slot) [module slot]) + {#Item slots}) + members]}) _ (in_meta #None)) @@ -2941,16 +2979,16 @@ #seed seed #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars #eval _eval] state] (case expected - (#Some type) - (#Right state type) + {#Some type} + {#Right state type} #None - (#Left "Not expecting any type."))))) + {#Left "Not expecting any type."})))) (def: (type\encoded type) (-> Type Text) (case type - (#Primitive name params) + {#Primitive name params} (case params #End name @@ -2958,38 +2996,38 @@ _ ($_ text\composite "(" name " " (|> params (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")")) - (#Sum _) - ($_ text\composite "(Or " (|> (flat_variant type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")") + {#Sum _} + ($_ text\composite "{" (|> (flat_variant type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) "}") - (#Product _) + {#Product _} ($_ text\composite "[" (|> (flat_tuple type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) "]") - (#Function _) + {#Function _} ($_ text\composite "(-> " (|> (flat_lambda type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")") - (#Parameter id) + {#Parameter id} (nat\encoded id) - (#Var id) + {#Var id} ($_ text\composite "⌈v:" (nat\encoded id) "⌋") - (#Ex id) + {#Ex id} ($_ text\composite "⟨e:" (nat\encoded id) "⟩") - (#UnivQ env body) + {#UnivQ env body} ($_ text\composite "(All " (type\encoded body) ")") - (#ExQ env body) + {#ExQ env body} ($_ text\composite "(Ex " (type\encoded body) ")") - (#Apply _) + {#Apply _} (let [[func args] (flat_application type)] ($_ text\composite "(" (type\encoded func) " " (|> args (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")")) - (#Named name _) + {#Named name _} (name\encoded name) )) @@ -3000,7 +3038,7 @@ tags+type (record_slots struct_type) tags (: (Meta (List Name)) (case tags+type - (#Some [tags _]) + {#Some [tags _]} (in_meta tags) _ @@ -3014,9 +3052,9 @@ (: (-> Code (Meta (List Code))) (function (_ token) (case token - (^ [_ (#Form (list [_ (#Text "lux def")] [_ (#Identifier ["" tag_name])] value export_policy))]) + (^ [_ {#Form (list [_ {#Text "lux def"}] [_ {#Identifier ["" tag_name]}] value export_policy)}]) (case (plist\value tag_name tag_mappings) - (#Some tag) + {#Some tag} (in (list tag value)) _ @@ -3033,7 +3071,7 @@ #End "" - (#Item head tail) + {#Item head tail} (list\mix (function (_ right left) ($_ text\composite left separator right)) head @@ -3046,7 +3084,7 @@ #None _ - (#Item tokens))) + {#Item tokens})) (def: (implementationP tokens) (-> (List Code) (Maybe [Code Text (List Code) Code (List Code)])) @@ -3060,7 +3098,7 @@ (macro: .public (implementation: tokens) (case (implementationP tokens) - (#Some [export_policy name args type definitions]) + {#Some [export_policy name args type definitions]} (let [usage (case args #End (local_identifier$ name) @@ -3085,12 +3123,12 @@ (-> (-> (List Code) (Maybe [(List Code) a])) (-> (List Code) (Maybe (List a))))) (case tokens - (#Item _) + {#Item _} (do maybe_monad [% (itP tokens) .let [[tokens' head] %] tail (case tokens' - (#Item _) + {#Item _} (everyP itP tokens') #End @@ -3098,27 +3136,27 @@ (in (list& head tail))) #End - (#Some (list)))) + {#Some (list)})) (def: (caseP tokens) (-> (List Code) (Maybe [(List Code) [Text Code]])) (case tokens - (^ (list& [_ (#Tag ["" niladic])] tokens')) - (#Some [tokens' [niladic (` .Any)]]) + (^ (list& [_ {#Tag ["" niladic]}] tokens')) + {#Some [tokens' [niladic (` .Any)]]} - (^ (list& [_ (#Form (list& [_ (#Tag ["" polyadic])] caseT))] tokens')) - (#Some [tokens' [polyadic (` (..Tuple (~+ caseT)))]]) + (^ (list& [_ {#Variant (list& [_ {#Tag ["" polyadic]}] caseT)}] tokens')) + {#Some [tokens' [polyadic (` (..Tuple (~+ caseT)))]]} _ #None)) (macro: .public (Variant tokens) (case (everyP caseP tokens) - (#Some cases) + {#Some cases} (in_meta (list (` (..Union (~+ (list\each product\right cases)))) - (form$ (list\each (function (_ case) - (text$ (product\left case))) - cases)))) + (variant$ (list\each (function (_ case) + (text$ (product\left case))) + cases)))) #None (failure "Wrong syntax for Variant"))) @@ -3126,17 +3164,17 @@ (def: (slotP tokens) (-> (List Code) (Maybe [(List Code) [Text Code]])) (case tokens - (^ (list& [_ (#Tag ["" slot])] type tokens')) - (#Some [tokens' [slot type]]) + (^ (list& [_ {#Tag ["" slot]}] type tokens')) + {#Some [tokens' [slot type]]} _ #None)) (macro: .public (Record tokens) (case tokens - (^ (list [_ (#Tuple record)])) + (^ (list [_ {#Tuple record}])) (case (everyP slotP record) - (#Some slots) + {#Some slots} (in_meta (list (` (..Tuple (~+ (list\each product\right slots)))) (tuple$ (list\each (function (_ slot) (text$ (product\left slot))) @@ -3161,30 +3199,30 @@ (def: (textP tokens) (-> (List Code) (Maybe [(List Code) Text])) (case tokens - (^ (list& [_ (#Text it)] tokens')) - (#Some [tokens' it]) + (^ (list& [_ {#Text it}] tokens')) + {#Some [tokens' it]} _ #None)) (def: (type_declaration it) (-> Code (Meta (Tuple Code (Maybe (Either (List Text) (List Text)))))) - ({[_ (#Form (#Item [_ (#Identifier declarer)] parameters))] + ({[_ {#Form {#Item [_ {#Identifier declarer}] parameters}}] (do meta_monad [declaration (single_expansion (form$ (list& (identifier$ declarer) parameters)))] (case declaration - (^ (list type [_ (#Form tags)])) + (^ (list type [_ {#Variant tags}])) (case (everyP textP tags) - (#Some tags) - (in_meta [type (#Some (#Left tags))]) + {#Some tags} + (in_meta [type {#Some {#Left tags}}]) #None (failure "Improper type-definition syntax")) - (^ (list type [_ (#Tuple slots)])) + (^ (list type [_ {#Tuple slots}])) (case (everyP textP slots) - (#Some slots) - (in_meta [type (#Some (#Right slots))]) + {#Some slots} + (in_meta [type {#Some {#Right slots}}]) #None (failure "Improper type-definition syntax")) @@ -3201,7 +3239,7 @@ (macro: .public (type: tokens) (case (typeP tokens) - (#Some [export_policy name args type_codes]) + {#Some [export_policy name args type_codes]} (do meta_monad [type+labels?? (..type_declaration type_codes) module_name current_module_name @@ -3210,30 +3248,27 @@ type' (: (Maybe Code) (case args #End - (#Some type) + {#Some type} _ - (#Some (` (.All ((~ type_name) (~+ (list\each local_identifier$ args))) - (~ type))))))]] + {#Some (` (.All ((~ type_name) (~+ (list\each local_identifier$ args))) + (~ type)))}))]] (case type' - (#Some type'') - (let [typeC (` (#.Named [(~ (text$ module_name)) + {#Some type''} + (let [typeC (` {#.Named [(~ (text$ module_name)) (~ (text$ name))] - (.type (~ type''))))] + (.type (~ type''))})] (in_meta (list (case labels?? - (#Some labels) - (case labels - (#Left tags) - (` ("lux def type tagged" (~ type_name) - (~ typeC) - ((~+ (list\each text$ tags))) - (~ export_policy))) - - (#Right slots) - (` ("lux def type tagged" (~ type_name) - (~ typeC) - [(~+ (list\each text$ slots))] - (~ export_policy)))) + {#Some labels} + (` ("lux def type tagged" (~ type_name) + (~ typeC) + (~ (case labels + {#Left tags} + (` {(~+ (list\each text$ tags))}) + + {#Right slots} + (` [(~+ (list\each text$ slots))]))) + (~ export_policy))) _ (` ("lux def" (~ type_name) @@ -3261,8 +3296,8 @@ (type: Referrals (Variant #All - (#Only (List Text)) - (#Exclude (List Text)) + {#Only (List Text)} + {#Exclude (List Text)} #Ignore #Nothing)) @@ -3286,7 +3321,7 @@ (: (-> Code (Meta Text)) (function (_ def) (case def - [_ (#Identifier ["" name])] + [_ {#Identifier ["" name]}] (in_meta name) _ @@ -3296,24 +3331,24 @@ (def: (referrals_parser tokens) (-> (List Code) (Meta [Referrals (List Code)])) (case tokens - (^or (^ (list& [_ (#Variant (list [_ (#Text "+")] [_ (#Tuple defs)]))] tokens')) - (^ (list& [_ (#Variant (list [_ (#Text "only")] [_ (#Tuple defs)]))] tokens'))) + (^or (^ (list& [_ {#Variant (list [_ {#Text "+"}] [_ {#Tuple defs}])}] tokens')) + (^ (list& [_ {#Variant (list [_ {#Text "only"}] [_ {#Tuple defs}])}] tokens'))) (do meta_monad [defs' (..referral_references defs)] - (in [(#Only defs') tokens'])) + (in [{#Only defs'} tokens'])) - (^or (^ (list& [_ (#Variant (list [_ (#Text "-")] [_ (#Tuple defs)]))] tokens')) - (^ (list& [_ (#Variant (list [_ (#Text "exclude")] [_ (#Tuple defs)]))] tokens'))) + (^or (^ (list& [_ {#Variant (list [_ {#Text "-"}] [_ {#Tuple defs}])}] tokens')) + (^ (list& [_ {#Variant (list [_ {#Text "exclude"}] [_ {#Tuple defs}])}] tokens'))) (do meta_monad [defs' (..referral_references defs)] - (in [(#Exclude defs') tokens'])) + (in [{#Exclude defs'} tokens'])) - (^or (^ (list& [_ (#Text "*")] tokens')) - (^ (list& [_ (#Text "all")] tokens'))) + (^or (^ (list& [_ {#Text "*"}] tokens')) + (^ (list& [_ {#Text "all"}] tokens'))) (in_meta [#All tokens']) - (^or (^ (list& [_ (#Text "_")] tokens')) - (^ (list& [_ (#Text "ignore")] tokens'))) + (^or (^ (list& [_ {#Text "_"}] tokens')) + (^ (list& [_ {#Text "ignore"}] tokens'))) (in_meta [#Ignore tokens']) _ @@ -3325,12 +3360,12 @@ #End (in_meta [#End #End]) - (^ (list& [_ (#Form (list& [_ (#Text prefix)] structs))] parts')) + (^ (list& [_ {#Form (list& [_ {#Text prefix}] structs)}] parts')) (do meta_monad [structs' (monad\each meta_monad (function (_ struct) (case struct - [_ (#Identifier ["" struct_name])] + [_ {#Identifier ["" struct_name]}] (in_meta struct_name) _ @@ -3338,7 +3373,7 @@ structs) next+remainder (openings_parser parts')] (let [[next remainder] next+remainder] - (in_meta [(#Item [prefix structs'] next) + (in_meta [{#Item [prefix structs'] next} remainder]))) _ @@ -3362,7 +3397,7 @@ ((: (-> Text Text Text) (function (recur left right) (case (..text\split_by pattern right) - (#Some [pre post]) + {#Some [pre post]} (recur ($_ "lux text concat" left pre replacement) post) #None @@ -3392,8 +3427,8 @@ (-> Text Text Text) (case [(text\split_by ..module_separator hierarchy) (text\split_by ..parallel_hierarchy_sigil root)] - [(#Some [_ hierarchy']) - (#Some ["" root'])] + [{#Some [_ hierarchy']} + {#Some ["" root']}] (normal_parallel_path' hierarchy' root') _ @@ -3404,8 +3439,8 @@ (def: (normal_parallel_path hierarchy root) (-> Text Text (Maybe Text)) (case (text\split_by ..parallel_hierarchy_sigil root) - (#Some ["" root']) - (#Some (normal_parallel_path' hierarchy root')) + {#Some ["" root']} + {#Some (normal_parallel_path' hierarchy root')} _ #None)) @@ -3416,7 +3451,7 @@ #None relatives - (#Some found) + {#Some found} (if ("lux i64 =" relatives found) (relative_ups ("lux i64 +" 1 relatives) input) relatives))) @@ -3427,7 +3462,7 @@ (^or [0 _] [_ #End]) list - [_ (#Item _ tail)] + [_ {#Item _ tail}] (list\after ("lux i64 -" 1 amount) tail))) (def: (absolute_module_name nested? relative_root module) @@ -3465,7 +3500,7 @@ (function (_ token) (case token ... Simple - [_ (#Identifier ["" module_name])] + [_ {#Identifier ["" module_name]}] (do meta_monad [absolute_module_name (..absolute_module_name nested? relative_root module_name)] (in (list [#import_name absolute_module_name @@ -3474,10 +3509,10 @@ #refer_open (list)]]))) ... Nested - (^ [_ (#Tuple (list& [_ (#Identifier ["" module_name])] extra))]) + (^ [_ {#Tuple (list& [_ {#Identifier ["" module_name]}] extra)}]) (do meta_monad [absolute_module_name (case (normal_parallel_path relative_root module_name) - (#Some parallel_path) + {#Some parallel_path} (in parallel_path) #None @@ -3498,10 +3533,10 @@ #refer_open openings]] sub_imports)))) - (^ [_ (#Tuple (list& [_ (#Text alias)] [_ (#Identifier ["" module_name])] extra))]) + (^ [_ {#Tuple (list& [_ {#Text alias}] [_ {#Identifier ["" module_name]}] extra)}]) (do meta_monad [absolute_module_name (case (normal_parallel_path relative_root module_name) - (#Some parallel_path) + {#Some parallel_path} (in parallel_path) #None @@ -3510,15 +3545,15 @@ .let [[referral extra] referral+extra] openings+extra (openings_parser extra) .let [[openings extra] openings+extra - module_alias (..module_alias (#Item module_name context) alias)] - sub_imports (imports_parser #1 absolute_module_name (#Item module_alias context) extra)] + module_alias (..module_alias {#Item module_name context} alias)] + sub_imports (imports_parser #1 absolute_module_name {#Item module_alias context} extra)] (in (case [referral openings] [#Ignore #End] sub_imports _ (list& [#import_name absolute_module_name - #import_alias (#Some module_alias) + #import_alias {#Some module_alias} #import_refer [#refer_defs referral #refer_open openings]] sub_imports)))) @@ -3542,38 +3577,38 @@ #scope_type_vars scope_type_vars #eval _eval] [current_module modules])] (case (plist\value module modules) - (#Some =module) + {#Some =module} (let [to_alias (list\each (: (-> [Text Global] (List Text)) (function (_ [name definition]) (case definition - (#Alias _) + {#Alias _} (list) - (#Definition [exported? def_type def_value]) + {#Definition [exported? def_type def_value]} (if exported? (list name) (list)) - (#Type [exported? type labels]) + {#Type [exported? type labels]} (if exported? (list name) (list)) - (#Label _) + {#Label _} (list) - (#Slot _) + {#Slot _} (list)))) (let [[#module_hash _ #module_aliases _ #definitions definitions #imports _ #module_state _] =module] definitions))] - (#Right state (list\conjoint to_alias))) + {#Right state (list\conjoint to_alias)}) #None - (#Left ($_ text\composite + {#Left ($_ text\composite "Unknown module: " (text\encoded module) ..\n "Current module: " (case current_module - (#Some current_module) + {#Some current_module} (text\encoded current_module) #None @@ -3582,7 +3617,7 @@ (list\each (function (_ [name module]) (text$ name))) tuple$ - code\encoded)))) + code\encoded))}) )) (def: (list\only p xs) @@ -3592,9 +3627,9 @@ #End (list) - (#Item x xs') + {#Item x xs'} (if (p x) - (#Item x (list\only p xs')) + {#Item x (list\only p xs')} (list\only p xs')))) (def: (is_member? cases name) @@ -3611,7 +3646,7 @@ (-> (-> a (Maybe b)) a a (Maybe b))) (case (f x1) #None (f x2) - (#Some y) (#Some y))) + {#Some y} {#Some y})) (def: (in_env name state) (-> Text Lux (Maybe Type)) @@ -3630,7 +3665,7 @@ (on_either (list\one (: (-> [Text [Type Any]] (Maybe Type)) (function (_ [bname [type _]]) (if (text\= name bname) - (#Some type) + {#Some type} #None)))) (: (List [Text [Type Any]]) locals) (: (List [Text [Type Any]]) closure))))) @@ -3647,26 +3682,26 @@ #None #None - (#Some [#definitions definitions #module_hash _ #module_aliases _ #imports _ #module_state _]) + {#Some [#definitions definitions #module_hash _ #module_aliases _ #imports _ #module_state _]} (case (plist\value v_name definitions) #None #None - (#Some definition) + {#Some definition} (case definition - (#Alias real_name) + {#Alias real_name} (definition_type real_name state) - (#Definition [exported? def_type def_value]) - (#Some def_type) + {#Definition [exported? def_type def_value]} + {#Some def_type} - (#Type [exported? type labels]) - (#Some ..Type) + {#Type [exported? type labels]} + {#Some ..Type} - (#Label _) + {#Label _} #None - (#Slot _) + {#Slot _} #None))))) (def: (definition_value name state) @@ -3678,29 +3713,29 @@ #scope_type_vars scope_type_vars #eval _eval] state] (case (plist\value v_module modules) #None - (#Left (text\composite "Unknown definition: " (name\encoded name))) + {#Left (text\composite "Unknown definition: " (name\encoded name))} - (#Some [#definitions definitions #module_hash _ #module_aliases _ #imports _ #module_state _]) + {#Some [#definitions definitions #module_hash _ #module_aliases _ #imports _ #module_state _]} (case (plist\value v_name definitions) #None - (#Left (text\composite "Unknown definition: " (name\encoded name))) + {#Left (text\composite "Unknown definition: " (name\encoded name))} - (#Some definition) + {#Some definition} (case definition - (#Alias real_name) + {#Alias real_name} (definition_value real_name state) - (#Definition [exported? def_type def_value]) - (#Right [state [def_type def_value]]) + {#Definition [exported? def_type def_value]} + {#Right [state [def_type def_value]]} - (#Type [exported? type labels]) - (#Right [state [..Type type]]) + {#Type [exported? type labels]} + {#Right [state [..Type type]]} - (#Label _) - (#Left (text\composite "Unknown definition: " (name\encoded name))) + {#Label _} + {#Left (text\composite "Unknown definition: " (name\encoded name))} - (#Slot _) - (#Left (text\composite "Unknown definition: " (name\encoded name)))))))) + {#Slot _} + {#Left (text\composite "Unknown definition: " (name\encoded name))}))))) (def: (type_variable idx bindings) (-> Nat (List [Nat (Maybe Type)]) (Maybe Type)) @@ -3708,7 +3743,7 @@ #End #End - (#Item [var bound] bindings') + {#Item [var bound] bindings'} (if ("lux i64 =" idx var) bound (type_variable idx bindings')))) @@ -3721,24 +3756,24 @@ (function (_ compiler) (let [temp (if (text\= "" module) (case (in_env name compiler) - (#Some struct_type) - (#Right [compiler struct_type]) + {#Some struct_type} + {#Right [compiler struct_type]} _ (case (definition_type [current_module name] compiler) - (#Some struct_type) - (#Right [compiler struct_type]) + {#Some struct_type} + {#Right [compiler struct_type]} _ - (#Left ($_ text\composite "Unknown var: " (name\encoded full_name))))) + {#Left ($_ text\composite "Unknown var: " (name\encoded full_name))})) (case (definition_type full_name compiler) - (#Some struct_type) - (#Right [compiler struct_type]) + {#Some struct_type} + {#Right [compiler struct_type]} _ - (#Left ($_ text\composite "Unknown var: " (name\encoded full_name)))))] + {#Left ($_ text\composite "Unknown var: " (name\encoded full_name))}))] (case temp - (#Right [compiler (#Var type_id)]) + {#Right [compiler {#Var type_id}]} (let [[#info _ #source _ #current_module _ #modules _ #scopes _ #type_context type_context #host _ #seed _ #expected _ #location _ #extensions extensions @@ -3748,8 +3783,8 @@ #None temp - (#Some actualT) - (#Right [compiler actualT]))) + {#Some actualT} + {#Right [compiler actualT]})) _ temp)) @@ -3759,9 +3794,9 @@ (All (_ a b) (-> (List a) (List b) (List [a b]))) (case xs - (#Item x xs') + {#Item x xs'} (case ys - (#Item y ys') + {#Item y ys'} (list& [x y] (zipped/2 xs' ys')) _ @@ -3772,12 +3807,12 @@ (macro: .public (^open tokens) (case tokens - (^ (list& [_ (#Form (list [_ (#Text alias)]))] body branches)) + (^ (list& [_ {#Form (list [_ {#Text alias}])}] body branches)) (do meta_monad [g!temp (..identifier "temp")] (in (list& g!temp (` (..^open (~ g!temp) (~ (text$ alias)) (~ body))) branches))) - (^ (list [_ (#Identifier name)] [_ (#Text alias)] body)) + (^ (list [_ {#Identifier name}] [_ {#Text alias}] body)) (do meta_monad [init_type (type_definition name) struct_evidence (record_slots init_type)] @@ -3785,7 +3820,7 @@ #None (failure (text\composite "Can only 'open' structs: " (type\encoded init_type))) - (#Some tags&members) + {#Some tags&members} (do meta_monad [full_body ((: (-> Name [(List Name) (List Type)] Code (Meta Code)) (function (recur source [tags members] target) @@ -3799,7 +3834,7 @@ (do meta_monad [m_implementation (record_slots m_type)] (case m_implementation - (#Some m_tags&members) + {#Some m_tags&members} (recur m_local m_tags&members enhanced_target) @@ -3834,8 +3869,8 @@ (All (_ a) (-> Nat (List a) (List [Nat a]))) (case xs - (#Item x xs') - (#Item [idx x] (enumeration' ("lux i64 +" 1 idx) xs')) + {#Item x xs'} + {#Item [idx x] (enumeration' ("lux i64 +" 1 idx) xs')} #End #End)) @@ -3847,7 +3882,7 @@ (macro: .public (value@ tokens) (case tokens - (^ (list [_ (#Tag slot')] record)) + (^ (list [_ {#Tag slot'}] record)) (do meta_monad [slot (normal slot') output (..type_slot slot) @@ -3855,7 +3890,7 @@ g!_ (..identifier "_") g!output (..identifier "")] (case (interface_methods type) - (#Some members) + {#Some members} (let [pattern (|> (zipped/2 tags (enumeration members)) (list\each (: (-> [Name [Nat Type]] (List Code)) (function (_ [[r_module r_name] [r_idx r_type]]) @@ -3870,7 +3905,7 @@ _ (failure "value@ can only use records."))) - (^ (list [_ (#Tuple slots)] record)) + (^ (list [_ {#Tuple slots}] record)) (in_meta (list (list\mix (: (-> Code Code Code) (function (_ slot inner) (` (..value@ (~ slot) (~ inner))))) @@ -3901,7 +3936,7 @@ tuple$) source+ (` ({(~ pattern) (~ g!output)} (~ source)))]] (case output - (#Some [tags' members']) + {#Some [tags' members']} (do meta_monad [decls' (monad\each meta_monad (: (-> [Nat Name Type] (Meta (List Code))) @@ -3917,15 +3952,15 @@ (macro: .public (open: tokens) (case tokens - (^ (list [_ (#Text alias)] struct)) + (^ (list [_ {#Text alias}] struct)) (case struct - [_ (#Identifier struct_name)] + [_ {#Identifier struct_name}] (do meta_monad [struct_type (type_definition struct_name) output (record_slots struct_type) .let [source (identifier$ struct_name)]] (case output - (#Some [tags members]) + {#Some [tags members]} (do meta_monad [decls' (monad\each meta_monad (: (-> [Nat Name Type] (Meta (List Code))) (function (_ [tag_index sname stype]) @@ -4001,13 +4036,13 @@ #All (exported_definitions module_name) - (#Only +defs) + {#Only +defs} (do meta_monad [*defs (exported_definitions module_name) _ (test_referrals module_name *defs +defs)] (in +defs)) - (#Exclude _defs) + {#Exclude _defs} (do meta_monad [*defs (exported_definitions module_name) _ (test_referrals module_name *defs _defs)] @@ -4033,7 +4068,7 @@ (macro: (refer tokens) (case tokens - (^ (list& [_ (#Text module_name)] options)) + (^ (list& [_ {#Text module_name}] options)) (do meta_monad [=refer (referrals module_name options)] (referral_definitions module_name =refer)) @@ -4049,10 +4084,10 @@ #All (list (' "*")) - (#Only defs) + {#Only defs} (list (variant$ (list (' "+") (tuple$ (list\each local_identifier$ defs))))) - (#Exclude defs) + {#Exclude defs} (list (variant$ (list (' "-") (tuple$ (list\each local_identifier$ defs))))) #Ignore @@ -4082,11 +4117,11 @@ (refer_code module_name m_alias =refer))) imports) =module (` ("lux def module" (~ =imports)))]] - (in (#Item =module =refers)))) + (in {#Item =module =refers}))) (macro: .public (\ tokens) (case tokens - (^ (list struct [_ (#Identifier member)])) + (^ (list struct [_ {#Identifier member}])) (in_meta (list (` (let [(^open (~ (text$ (alias_stand_in 0)))) (~ struct)] (~ (identifier$ member)))))) (^ (list& struct member args)) @@ -4097,13 +4132,13 @@ (macro: .public (with@ tokens) (case tokens - (^ (list [_ (#Tag slot')] value record)) + (^ (list [_ {#Tag slot'}] value record)) (do meta_monad [slot (normal slot') output (..type_slot slot) .let [[idx tags exported? type] output]] (case (interface_methods type) - (#Some members) + {#Some members} (do meta_monad [pattern' (monad\each meta_monad (: (-> [Name [Nat Type]] (Meta [Name Nat Code])) @@ -4133,7 +4168,7 @@ _ (failure "with@ can only use records."))) - (^ (list [_ (#Tuple slots)] value record)) + (^ (list [_ {#Tuple slots}] value record)) (case slots #End (failure "Wrong syntax for with@") @@ -4153,7 +4188,7 @@ [_ accesses'] (list\mix (: (-> [Code Code] [Code (List (List Code))] [Code (List (List Code))]) (function (_ [new_slot new_binding] [old_record accesses']) [(` (value@ (~ new_slot) (~ new_binding))) - (#Item (list new_binding old_record) accesses')])) + {#Item (list new_binding old_record) accesses'}])) [record (: (List (List Code)) #End)] pairs) accesses (list\conjoint (list\reversed accesses'))]] @@ -4180,13 +4215,13 @@ (macro: .public (revised@ tokens) (case tokens - (^ (list [_ (#Tag slot')] fun record)) + (^ (list [_ {#Tag slot'}] fun record)) (do meta_monad [slot (normal slot') output (..type_slot slot) .let [[idx tags exported? type] output]] (case (interface_methods type) - (#Some members) + {#Some members} (do meta_monad [pattern' (monad\each meta_monad (: (-> [Name [Nat Type]] (Meta [Name Nat Code])) @@ -4216,7 +4251,7 @@ _ (failure "revised@ can only use records."))) - (^ (list [_ (#Tuple slots)] fun record)) + (^ (list [_ {#Tuple slots}] fun record)) (case slots #End (failure "Wrong syntax for revised@") @@ -4249,9 +4284,9 @@ (macro: .public (^template tokens) (case tokens - (^ (list& [_ (#Form (list [_ (#Tuple bindings)] - [_ (#Tuple templates)]))] - [_ (#Form data)] + (^ (list& [_ {#Form (list [_ {#Tuple bindings}] + [_ {#Tuple templates}])}] + [_ {#Form data}] branches)) (case (: (Maybe (List Code)) (do maybe_monad @@ -4267,7 +4302,7 @@ list\conjoint in)) #None)))) - (#Some output) + {#Some output} (in_meta (list\composite output branches)) #None @@ -4293,57 +4328,57 @@ #End #End - (#Item x xs') + {#Item x xs'} (case ys #End #End - (#Item y ys') + {#Item y ys'} (list& x y (interleaved xs' ys'))))) (def: (type_code type) (-> Type Code) (case type - (#Primitive name params) - (` (#.Primitive (~ (text$ name)) (~ (untemplated_list (list\each type_code params))))) + {#Primitive name params} + (` {#.Primitive (~ (text$ name)) (~ (untemplated_list (list\each type_code params)))}) (^template [] - [( left right) - (` ( (~ (type_code left)) (~ (type_code right))))]) + [{ left right} + (` { (~ (type_code left)) (~ (type_code right))})]) ([#.Sum] [#.Product] [#.Function] [#.Apply]) (^template [] - [( id) - (` ( (~ (nat$ id))))]) + [{ id} + (` { (~ (nat$ id))})]) ([#.Parameter] [#.Var] [#.Ex]) (^template [] - [( env type) + [{ env type} (let [env' (untemplated_list (list\each type_code env))] - (` ( (~ env') (~ (type_code type)))))]) + (` { (~ env') (~ (type_code type))}))]) ([#.UnivQ] [#.ExQ]) - (#Named [module name] anonymous) + {#Named [module name] anonymous} ... TODO: Generate the explicit type definition instead of using ... the "identifier$" shortcut below. - ... (` (#.Named [(~ (text$ module)) (~ (text$ name))] - ... (~ (type_code anonymous)))) + ... (` {#.Named [(~ (text$ module)) (~ (text$ name))] + ... (~ (type_code anonymous))}) (identifier$ [module name]))) (macro: .public (loop tokens) (let [?params (case tokens - (^ (list name [_ (#Tuple bindings)] body)) - (#Some [name bindings body]) + (^ (list name [_ {#Tuple bindings}] body)) + {#Some [name bindings body]} - (^ (list [_ (#Tuple bindings)] body)) - (#Some [(local_identifier$ "recur") bindings body]) + (^ (list [_ {#Tuple bindings}] body)) + {#Some [(local_identifier$ "recur") bindings body]} _ #None)] (case ?params - (#Some [name bindings body]) + {#Some [name bindings body]} (let [pairs (pairs bindings) vars (list\each product\left pairs) inits (list\each product\right pairs)] @@ -4351,7 +4386,7 @@ (do meta_monad [inits' (: (Meta (List Name)) (case (monad\each maybe_monad identifier_name inits) - (#Some inits') (in_meta inits') + {#Some inits'} (in_meta inits') #None (failure "Wrong syntax for loop"))) init_types (monad\each meta_monad type_definition inits') expected ..expected_type] @@ -4376,7 +4411,7 @@ (macro: .public (^slots tokens) (case tokens - (^ (list& [_ (#Form (list [_ (#Tuple (list& hslot' tslots'))]))] body branches)) + (^ (list& [_ {#Form (list [_ {#Tuple (list& hslot' tslots')}])}] body branches)) (do meta_monad [slots (: (Meta [Name (List Name)]) (case (: (Maybe [Name (List Name)]) @@ -4384,7 +4419,7 @@ [hslot (..tag_name hslot') tslots (monad\each maybe_monad ..tag_name tslots')] (in [hslot tslots]))) - (#Some slots) + {#Some slots} (in_meta slots) #None @@ -4404,7 +4439,7 @@ (function (_ [module name]) (let [tag (tag$ [module name])] (case (plist\value name slot_pairings) - (#Some binding) (list tag binding) + {#Some binding} (list tag binding) #None (list tag g!_)))))) list\conjoint tuple$)]] @@ -4416,27 +4451,27 @@ (def: (with_expansions' label tokens target) (-> Text (List Code) Code (List Code)) (case target - (^or [_ (#Bit _)] [_ (#Nat _)] [_ (#Int _)] [_ (#Rev _)] [_ (#Frac _)] [_ (#Text _)] [_ (#Tag _)]) + (^or [_ {#Bit _}] [_ {#Nat _}] [_ {#Int _}] [_ {#Rev _}] [_ {#Frac _}] [_ {#Text _}] [_ {#Tag _}]) (list target) - [_ (#Identifier [module name])] + [_ {#Identifier [module name]}] (if (and (text\= "" module) (text\= label name)) tokens (list target)) (^template [] - [[location ( elems)] - (list [location ( (list\conjoint (list\each (with_expansions' label tokens) elems)))])]) + [[location { elems}] + (list [location { (list\conjoint (list\each (with_expansions' label tokens) elems))}])]) ([#Form] [#Variant] [#Tuple]))) (macro: .public (with_expansions tokens) (case tokens - (^ (list& [_ (#Tuple bindings)] bodies)) + (^ (list& [_ {#Tuple bindings}] bodies)) (case bindings - (^ (list& [_ (#Identifier ["" var_name])] expr bindings')) + (^ (list& [_ {#Identifier ["" var_name]}] expr bindings')) (do meta_monad [expansion (single_expansion expr)] (in (with_expansions' var_name expansion @@ -4457,7 +4492,7 @@ (-> Type Type) (case type (^template [] - [(#Named ["library/lux" ] _) + [{#Named ["library/lux" ] _} type]) (["Bit"] ["Nat"] @@ -4466,7 +4501,7 @@ ["Frac"] ["Text"]) - (#Named _ type') + {#Named _ type'} (flat_alias type') _ @@ -4479,7 +4514,7 @@ .let [[type value] type+value]] (case (flat_alias type) (^template [ ] - [(#Named ["library/lux" ] _) + [{#Named ["library/lux" ] _} (in ( (:as value)))]) (["Bit" Bit bit$] ["Nat" Nat nat$] @@ -4494,7 +4529,7 @@ (def: (static_literal token) (-> Code (Meta Code)) (case token - [_ (#Identifier [def_module def_name])] + [_ {#Identifier [def_module def_name]}] (if (text\= "" def_module) (do meta_monad [current_module current_module_name] @@ -4502,10 +4537,10 @@ (static_simple_literal [def_module def_name])) (^template [] - [[meta ( parts)] + [[meta { parts}] (do meta_monad [=parts (monad\each meta_monad static_literal parts)] - (in [meta ( =parts)]))]) + (in [meta { =parts}]))]) ([#Form] [#Variant] [#Tuple]) @@ -4532,7 +4567,7 @@ (def: (case_level^ level) (-> Code (Meta [Code Code])) (case level - (^ [_ (#Tuple (list expr binding))]) + (^ [_ {#Tuple (list expr binding)}]) (in_meta [expr binding]) _ @@ -4545,7 +4580,7 @@ #End (failure "Multi-level patterns cannot be empty.") - (#Item init extras) + {#Item init extras} (do meta_monad [extras' (monad\each meta_monad case_level^ extras)] (in [init extras'])))) @@ -4554,7 +4589,7 @@ (-> Code [Multi_Level_Case Code] (List Code)) (let [inner_pattern_body (list\mix (function (_ [calculation pattern] success) (let [bind? (case pattern - [_ (#Identifier _)] + [_ {#Identifier _}] #1 _ @@ -4566,17 +4601,17 @@ (~+ (if bind? (list) (list g!_ (` #.None)))))))) - (` (#.Some (~ body))) + (` {#.Some (~ body)}) (: (List [Code Code]) (list\reversed levels)))] (list init_pattern inner_pattern_body))) (macro: .public (^multi tokens) (case tokens - (^ (list& [_meta (#Form levels)] body next_branches)) + (^ (list& [_meta {#Form levels}] body next_branches)) (do meta_monad [mlc (multi_level_case^ levels) .let [initial_bind? (case mlc - [[_ (#Identifier _)] _] + [[_ {#Identifier _}] _] #1 _ @@ -4584,13 +4619,13 @@ expected ..expected_type g!temp (..identifier "temp")] (let [output (list g!temp - (` ({(#Some (~ g!temp)) + (` ({{#Some (~ g!temp)} (~ g!temp) #None (case (~ g!temp) (~+ next_branches))} - ("lux type check" (#.Apply (~ (type_code expected)) Maybe) + ("lux type check" {#.Apply (~ (type_code expected)) Maybe} (case (~ g!temp) (~+ (multi_level_case$ g!temp [mlc body])) @@ -4613,9 +4648,10 @@ (macro: .public (name_of tokens) (case tokens (^template [] - [(^ (list [_ ( [module name])])) + [(^ (list [_ { [module name]}])) (in_meta (list (` [(~ (text$ module)) (~ (text$ name))])))]) - ([#Identifier] [#Tag]) + ([#Identifier] + [#Tag]) _ (failure (..wrong_syntax_error [..prelude_module "name_of"])))) @@ -4627,16 +4663,16 @@ #scopes scopes #type_context types #host host #seed seed #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars #eval _eval] - (#Right [state scope_type_vars]))) + {#Right [state scope_type_vars]})) (macro: .public (:parameter tokens) (case tokens - (^ (list [_ (#Nat idx)])) + (^ (list [_ {#Nat idx}])) (do meta_monad [stvs ..scope_type_vars] (case (..item idx (list\reversed stvs)) - (#Some var_id) - (in (list (` (#Ex (~ (nat$ var_id)))))) + {#Some var_id} + (in (list (` {#Ex (~ (nat$ var_id))}))) #None (failure (text\composite "Indexed-type does not exist: " (nat\encoded idx))))) @@ -4651,7 +4687,7 @@ (macro: .public (^@ tokens) (case tokens - (^ (list& [_meta (#Form (list [_ (#Identifier ["" name])] pattern))] body branches)) + (^ (list& [_meta {#Form (list [_ {#Identifier ["" name]}] pattern)}] body branches)) (let [g!whole (local_identifier$ name)] (in_meta (list& g!whole (` (case (~ g!whole) (~ pattern) (~ body))) @@ -4662,7 +4698,7 @@ (macro: .public (^|> tokens) (case tokens - (^ (list& [_meta (#Form (list [_ (#Identifier ["" name])] [_ (#Tuple steps)]))] body branches)) + (^ (list& [_meta {#Form (list [_ {#Identifier ["" name]}] [_ {#Tuple steps}])}] body branches)) (let [g!name (local_identifier$ name)] (in_meta (list& g!name (` (let [(~ g!name) (|> (~ g!name) (~+ steps))] @@ -4685,7 +4721,7 @@ (def: location (Meta Location) (function (_ compiler) - (#Right [compiler (value@ #location compiler)]))) + {#Right [compiler (value@ #location compiler)]})) (macro: .public (undefined tokens) (case tokens @@ -4702,7 +4738,7 @@ (macro: .public (:of tokens) (case tokens - (^ (list [_ (#Identifier var_name)])) + (^ (list [_ {#Identifier var_name}])) (do meta_monad [var_type (type_definition var_name)] (in (list (type_code var_type)))) @@ -4719,8 +4755,8 @@ (def: (tupleP tokens) (-> (List Code) (Maybe [(List Code) (List Code)])) (case tokens - (^ (list& [_ (#Tuple tuple)] tokens')) - (#Some [tokens' tuple]) + (^ (list& [_ {#Tuple tuple}] tokens')) + {#Some [tokens' tuple]} _ #None)) @@ -4737,7 +4773,7 @@ (macro: .public (template: tokens) (case (templateP tokens) - (#Some [export_policy name args input_templates]) + {#Some [export_policy name args input_templates]} (do meta_monad [g!tokens (..identifier "tokens") g!compiler (..identifier "compiler") @@ -4750,51 +4786,51 @@ ((~ (local_identifier$ name)) (~ g!tokens) (~ g!compiler)) (case (~ g!tokens) (^ (list (~+ (list\each local_identifier$ args)))) - (#.Right [(~ g!compiler) + {#.Right [(~ g!compiler) (list (~+ (list\each (function (_ template) (` (`' (~ (with_replacements rep_env template))))) - input_templates)))]) + input_templates)))]} (~ g!_) - (#.Left (~ (text$ (..wrong_syntax_error [this_module name])))))))))) + {#.Left (~ (text$ (..wrong_syntax_error [this_module name])))})))))) #None (failure (..wrong_syntax_error (name_of ..template:))))) (macro: .public (as_is tokens compiler) - (#Right [compiler tokens])) + {#Right [compiler tokens]}) (macro: .public (char tokens compiler) (case tokens - (^multi (^ (list [_ (#Text input)])) + (^multi (^ (list [_ {#Text input}])) (|> input "lux text size" ("lux i64 =" 1))) (|> input ("lux text char" 0) nat$ list [compiler] #Right) _ - (#Left (..wrong_syntax_error (name_of ..char))))) + {#Left (..wrong_syntax_error (name_of ..char))})) (def: target (Meta Text) (function (_ compiler) - (#Right [compiler (value@ [#info #target] compiler)]))) + {#Right [compiler (value@ [#info #target] compiler)]})) (def: (platform_name choice) (-> Code (Meta Text)) (case choice - [_ (#Text platform)] + [_ {#Text platform}] (..in_meta platform) - [_ (#Identifier identifier)] + [_ {#Identifier identifier}] (do meta_monad [identifier (..global_identifier identifier) type+value (..definition_value identifier) .let [[type value] type+value]] (case (..flat_alias type) - (^or (#Primitive "#Text" #End) - (#Named ["library/lux" "Text"] (#Primitive "#Text" #End))) + (^or {#Primitive "#Text" #End} + {#Named ["library/lux" "Text"] {#Primitive "#Text" #End}}) (in (:as ..Text value)) _ @@ -4815,10 +4851,10 @@ #None (failure ($_ text\composite "No code for target platform: " target)) - (#Some default) + {#Some default} (in_meta (list default))) - (#Item [key pick] options') + {#Item [key pick] options'} (do meta_monad [platform (..platform_name key)] (if (text\= target platform) @@ -4831,25 +4867,25 @@ list\size (n/% 2) ("lux i64 =" 0)) - (#Some (pairs tokens)) + {#Some (pairs tokens)} #None)) (macro: .public (for tokens) (do meta_monad [target ..target] (case tokens - (^ (list [_ (#Tuple options)])) + (^ (list [_ {#Tuple options}])) (case (pairs' options) - (#Some options) + {#Some options} (target_pick target options #None) #None (failure (..wrong_syntax_error (name_of ..for)))) - (^ (list [_ (#Tuple options)] default)) + (^ (list [_ {#Tuple options}] default)) (case (pairs' options) - (#Some options) - (target_pick target options (#Some default)) + {#Some options} + (target_pick target options {#Some default}) #None (failure (..wrong_syntax_error (name_of ..for)))) @@ -4860,17 +4896,17 @@ (def: (embedded_expansions code) (-> Code (Meta [(List [Code Code]) Code])) (case code - (^ [ann (#Form (list [_ (#Identifier ["" "~~"])] expansion))]) + (^ [ann {#Form (list [_ {#Identifier ["" "~~"]}] expansion)}]) (do meta_monad [g!expansion (..identifier "g!expansion")] (in [(list [g!expansion expansion]) g!expansion])) (^template [] - [[ann ( parts)] + [[ann { parts}] (do meta_monad [=parts (monad\each meta_monad embedded_expansions parts)] (in [(list\mix list\composite (list) (list\each product\left =parts)) - [ann ( (list\each product\right =parts))]]))]) + [ann { (list\each product\right =parts)}]]))]) ([#Form] [#Variant] [#Tuple]) @@ -4902,24 +4938,24 @@ #End last - (#Item [init inits']) - (` (#.Item (~ init) (~ (untemplated_list& last inits')))))) + {#Item [init inits']} + (` {#.Item (~ init) (~ (untemplated_list& last inits'))}))) (template [ ] [(def: ( g!meta untemplated_pattern elems) (-> Code (-> Code (Meta Code)) (-> (List Code) (Meta Code))) (case (list\reversed elems) - (#Item [_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))] - inits) + {#Item [_ {#Form {#Item [[_ {#Identifier ["" "~+"]}] {#Item [spliced #End]}]}}] + inits} (do meta_monad [=inits (monad\each meta_monad untemplated_pattern (list\reversed inits))] - (in (` [(~ g!meta) ( (~ (untemplated_list& spliced =inits)))]))) + (in (` [(~ g!meta) { (~ (untemplated_list& spliced =inits))}]))) _ (do meta_monad [=elems (monad\each meta_monad untemplated_pattern elems)] - (in (` [(~ g!meta) ( (~ (untemplated_list =elems)))])))))] + (in (` [(~ g!meta) { (~ (untemplated_list =elems))}])))))] [#.Form untemplated_form] [#.Tuple untemplated_tuple] @@ -4932,8 +4968,8 @@ [g!meta (..identifier "g!meta")] (case pattern (^template [ ] - [[_ ( value)] - (in (` [(~ g!meta) ( (~ ( value)))]))]) + [[_ { value}] + (in (` [(~ g!meta) { (~ ( value))}]))]) ([#.Bit bit$] [#.Nat nat$] [#.Int int$] @@ -4943,14 +4979,14 @@ [#.Tag name$] [#.Identifier name$]) - [_ (#Form (#Item [[_ (#Identifier ["" "~"])] (#Item [unquoted #End])]))] + [_ {#Form {#Item [[_ {#Identifier ["" "~"]}] {#Item [unquoted #End]}]}}] (in_meta unquoted) - [_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))] + [_ {#Form {#Item [[_ {#Identifier ["" "~+"]}] {#Item [spliced #End]}]}}] (failure "Cannot use (~+) inside of ^code unless it is the last element in a form or a tuple.") (^template [ ] - [[_ ( elems)] + [[_ { elems}] ( g!meta untemplated_pattern elems)]) ([#Form ..untemplated_form] [#Variant ..untemplated_variant] @@ -4959,7 +4995,7 @@ (macro: .public (^code tokens) (case tokens - (^ (list& [_meta (#Form (list template))] body branches)) + (^ (list& [_meta {#Form (list template)}] body branches)) (do meta_monad [pattern (untemplated_pattern template)] (in (list& pattern body branches))) @@ -4982,7 +5018,7 @@ (macro: .public (:let tokens) (case tokens - (^ (list [_ (#Tuple bindings)] bodyT)) + (^ (list [_ {#Tuple bindings}] bodyT)) (if (multiple? 2 (list\size bindings)) (in_meta (list (` (..with_expansions [(~+ (|> bindings ..pairs @@ -5010,9 +5046,9 @@ (def: (methodP tokens) (-> (List Code) (Maybe [(List Code) [Text Code]])) (case tokens - (^ (list& [_ (#Form (list [_ (#Text "lux type check")] type [_ (#Identifier ["" name])]))] + (^ (list& [_ {#Form (list [_ {#Text "lux type check"}] type [_ {#Identifier ["" name]}])}] tokens')) - (#Some [tokens' [name type]]) + {#Some [tokens' [name type]]} _ #None)) @@ -5021,7 +5057,7 @@ (do meta_monad [methods' (monad\each meta_monad expansion tokens)] (case (everyP methodP (list\conjoint methods')) - (#Some methods) + {#Some methods} (in (list (` (..Tuple (~+ (list\each product\right methods)))) (tuple$ (list\each (|>> product\left text$) methods)))) @@ -5031,13 +5067,13 @@ (def: (recursive_type g!self g!dummy name body) (-> Code Code Text Code Code) (` ((.All ((~ g!self) (~ g!dummy)) - (~ (let$ (local_identifier$ name) (` (#.Apply (..primitive "") (~ g!self))) + (~ (let$ (local_identifier$ name) (` {#.Apply (..primitive "") (~ g!self)}) body))) (..primitive "")))) (macro: .public (Rec tokens) (case tokens - (^ (list [_ (#Identifier "" name)] body)) + (^ (list [_ {#Identifier "" name}] body)) (do meta_monad [body' (expansion body) g!self (identifier "g!self") -- cgit v1.2.3