diff options
author | Eduardo Julian | 2021-09-10 01:21:23 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-09-10 01:21:23 -0400 |
commit | cd71a864ad5be13ed6ec6d046e0a2cb1087bdf94 (patch) | |
tree | af6366578f98f1a8e551f4da9f3ad230fd63a4dd /stdlib/source/library | |
parent | ef77466323f85a3d1b65b46a3deb93652ef22085 (diff) |
Migrated variants to the new syntax.
Diffstat (limited to '')
252 files changed, 5421 insertions, 5355 deletions
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 <item_type>))) (case tokens #End - (#Some #End) + {#Some #End} _ (do maybe_monad [% (<item_parser> tokens) .let' [[tokens head] %] tail (<parser> tokens)] - (in (#Item head tail)))))] + (in {#Item head tail}))))] [parametersP Text local_identifierP] [enhanced_parametersP Code anyP] @@ -2545,7 +2583,7 @@ [(def:' .private (<parser> tokens) (-> (List Code) (Maybe [(List Code) [Text (List <parameter_type>)]])) (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 [<name> <form> <message>] [(macro: .public (<name> 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: (<name> type) (-> Type (List Type)) (case type - (<tag> left right) + {<tag> left right} (list& left (<name> 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 [<tag>] - [(<tag> left right) - (` (<tag> (~ (type_code left)) (~ (type_code right))))]) + [{<tag> left right} + (` {<tag> (~ (type_code left)) (~ (type_code right))})]) ([#.Sum] [#.Product] [#.Function] [#.Apply]) (^template [<tag>] - [(<tag> id) - (` (<tag> (~ (nat$ id))))]) + [{<tag> id} + (` {<tag> (~ (nat$ id))})]) ([#.Parameter] [#.Var] [#.Ex]) (^template [<tag>] - [(<tag> env type) + [{<tag> env type} (let [env' (untemplated_list (list\each type_code env))] - (` (<tag> (~ env') (~ (type_code type)))))]) + (` {<tag> (~ 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 [<tag>] - [[location (<tag> elems)] - (list [location (<tag> (list\conjoint (list\each (with_expansions' label tokens) elems)))])]) + [[location {<tag> elems}] + (list [location {<tag> (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 [<name>] - [(#Named ["library/lux" <name>] _) + [{#Named ["library/lux" <name>] _} 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 [<name> <type> <wrapper>] - [(#Named ["library/lux" <name>] _) + [{#Named ["library/lux" <name>] _} (in (<wrapper> (:as <type> 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 [<tag>] - [[meta (<tag> parts)] + [[meta {<tag> parts}] (do meta_monad [=parts (monad\each meta_monad static_literal parts)] - (in [meta (<tag> =parts)]))]) + (in [meta {<tag> =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 [<tag>] - [(^ (list [_ (<tag> [module name])])) + [(^ (list [_ {<tag> [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 [<tag>] - [[ann (<tag> parts)] + [[ann {<tag> parts}] (do meta_monad [=parts (monad\each meta_monad embedded_expansions parts)] (in [(list\mix list\composite (list) (list\each product\left =parts)) - [ann (<tag> (list\each product\right =parts))]]))]) + [ann {<tag> (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 [<tag> <name>] [(def: (<name> 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) (<tag> (~ (untemplated_list& spliced =inits)))]))) + (in (` [(~ g!meta) {<tag> (~ (untemplated_list& spliced =inits))}]))) _ (do meta_monad [=elems (monad\each meta_monad untemplated_pattern elems)] - (in (` [(~ g!meta) (<tag> (~ (untemplated_list =elems)))])))))] + (in (` [(~ g!meta) {<tag> (~ (untemplated_list =elems))}])))))] [#.Form untemplated_form] [#.Tuple untemplated_tuple] @@ -4932,8 +4968,8 @@ [g!meta (..identifier "g!meta")] (case pattern (^template [<tag> <gen>] - [[_ (<tag> value)] - (in (` [(~ g!meta) (<tag> (~ (<gen> value)))]))]) + [[_ {<tag> value}] + (in (` [(~ g!meta) {<tag> (~ (<gen> 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 [<tag> <untemplated>] - [[_ (<tag> elems)] + [[_ {<tag> elems}] (<untemplated> 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") diff --git a/stdlib/source/library/lux/abstract/comonad.lux b/stdlib/source/library/lux/abstract/comonad.lux index b4dd60a68..20e24bcb5 100644 --- a/stdlib/source/library/lux/abstract/comonad.lux +++ b/stdlib/source/library/lux/abstract/comonad.lux @@ -26,15 +26,15 @@ (macro: .public (be tokens state) (case (: (Maybe [(Maybe Text) Code (List Code) Code]) (case tokens - (^ (list [_ (#.Tuple (list [_ (#.Identifier ["" name])] comonad))] [_ (#.Tuple bindings)] body)) - (#.Some [(#.Some name) comonad bindings body]) + (^ (list [_ {#.Tuple (list [_ {#.Identifier ["" name]}] comonad)}] [_ {#.Tuple bindings}] body)) + {#.Some [{#.Some name} comonad bindings body]} - (^ (list comonad [_ (#.Tuple bindings)] body)) - (#.Some [#.None comonad bindings body]) + (^ (list comonad [_ {#.Tuple bindings}] body)) + {#.Some [#.None comonad bindings body]} _ #.None)) - (#.Some [?name comonad bindings body]) + {#.Some [?name comonad bindings body]} (if (|> bindings list.size (n.% 2) (n.= 0)) (let [[module short] (name_of ..be) identifier (: (-> Text Code) @@ -47,19 +47,19 @@ (with_expansions [<default> (` (|> (~ value) (~ g!disjoint) ((~ g!each) (function ((~ g!_) (~ var)) (~ body')))))] (let [[var value] binding] (case var - [_ (#.Identifier ["" _])] + [_ {#.Identifier ["" _]}] <default> - [_ (#.Identifier _)] + [_ {#.Identifier _}] (` ((~ var) (~ value) (~ body'))) _ <default>))))) body (list.reversed (list.pairs bindings)))] - (#.Right [state (list (case ?name - (#.Some name) - (let [name [location.dummy (#.Identifier ["" name])]] + {#.Right [state (list (case ?name + {#.Some name} + (let [name [location.dummy {#.Identifier ["" name]}]] (` (.case (~ comonad) (~ name) (.case (~ name) @@ -69,8 +69,8 @@ #.None (` (.case (~ comonad) [(~ g!each) (~' out) (~ g!disjoint)] - (~ body')))))])) - (#.Left "'be' bindings must have an even number of parts.")) + (~ body')))))]}) + {#.Left "'be' bindings must have an even number of parts."}) #.None - (#.Left "Wrong syntax for 'be'"))) + {#.Left "Wrong syntax for 'be'"})) diff --git a/stdlib/source/library/lux/abstract/enum.lux b/stdlib/source/library/lux/abstract/enum.lux index 390bd9956..c78a0711f 100644 --- a/stdlib/source/library/lux/abstract/enum.lux +++ b/stdlib/source/library/lux/abstract/enum.lux @@ -16,10 +16,10 @@ (loop [end to output #.End] (cond (< end from) - (recur (pred end) (#.Item end output)) + (recur (pred end) {#.Item end output}) (< from end) - (recur (succ end) (#.Item end output)) + (recur (succ end) {#.Item end output}) ... (= end from) - (#.Item end output))))) + {#.Item end output})))) diff --git a/stdlib/source/library/lux/abstract/functor.lux b/stdlib/source/library/lux/abstract/functor.lux index c72ae415b..5b7b4d3f1 100644 --- a/stdlib/source/library/lux/abstract/functor.lux +++ b/stdlib/source/library/lux/abstract/functor.lux @@ -20,11 +20,11 @@ (implementation (def: (each f fa|ga) (case fa|ga - (#.Left fa) - (#.Left (f\each f fa)) + {#.Left fa} + {#.Left (f\each f fa)} - (#.Right ga) - (#.Right (g\each f ga)))))) + {#.Right ga} + {#.Right (g\each f ga)})))) (type: .public (And f g) (All (_ a) (.And (f a) (g a)))) diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index 98baec35e..c915945a1 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -13,7 +13,7 @@ #.End init - (#.Item x xs') + {#.Item x xs'} (list\mix f (f x init) xs'))) (def: (list\size xs) @@ -24,21 +24,21 @@ #.End counter - (#.Item _ xs') + {#.Item _ xs'} (recur (++ counter) xs')))) (def: (reversed xs) (All (_ a) (-> (List a) (List a))) - (list\mix (function (_ head tail) (#.Item head tail)) + (list\mix (function (_ head tail) {#.Item head tail}) #.End xs)) (def: (pairs xs) (All (_ a) (-> (List a) (List [a a]))) (case xs - (#.Item x1 (#.Item x2 xs')) - (#.Item [x1 x2] (pairs xs')) + {#.Item x1 {#.Item x2 xs'}} + {#.Item [x1 x2] (pairs xs')} _ #.End)) @@ -57,15 +57,15 @@ (macro: .public (do tokens state) (case (: (Maybe [(Maybe Text) Code (List Code) Code]) (case tokens - (^ (list [_ (#.Tuple (list [_ (#.Identifier ["" name])] monad))] [_ (#.Tuple bindings)] body)) - (#.Some [(#.Some name) monad bindings body]) + (^ (list [_ {#.Tuple (list [_ {#.Identifier ["" name]}] monad)}] [_ {#.Tuple bindings}] body)) + {#.Some [{#.Some name} monad bindings body]} - (^ (list monad [_ (#.Tuple bindings)] body)) - (#.Some [#.None monad bindings body]) + (^ (list monad [_ {#.Tuple bindings}] body)) + {#.Some [#.None monad bindings body]} _ #.None)) - (#.Some [?name monad bindings body]) + {#.Some [?name monad bindings body]} (if (|> bindings list\size .int ("lux i64 %" +2) ("lux i64 =" +0)) (let [[module short] (name_of ..do) identifier (: (-> Text Code) @@ -78,19 +78,19 @@ (with_expansions [<default> (` (|> (~ value) ((~ g!each) (function ((~ g!_) (~ var)) (~ body'))) (~ g!conjoint)))] (let [[var value] binding] (case var - [_ (#.Identifier ["" _])] + [_ {#.Identifier ["" _]}] <default> - [_ (#.Identifier _)] + [_ {#.Identifier _}] (` ((~ var) (~ value) (~ body'))) _ <default>))))) body (reversed (pairs bindings)))] - (#.Right [state (list (case ?name - (#.Some name) - (let [name [location.dummy (#.Identifier ["" name])]] + {#.Right [state (list (case ?name + {#.Some name} + (let [name [location.dummy {#.Identifier ["" name]}]] (` (.case (~ monad) (~ name) (.case (~ name) @@ -100,11 +100,11 @@ #.None (` (.case (~ monad) [(~ g!each) (~' in) (~ g!conjoint)] - (~ body')))))])) - (#.Left "'do' bindings must have an even number of parts.")) + (~ body')))))]}) + {#.Left "'do' bindings must have an even number of parts."}) #.None - (#.Left "Wrong syntax for 'do'"))) + {#.Left "Wrong syntax for 'do'"})) (def: .public (then monad f) (All (_ ! a b) @@ -123,10 +123,10 @@ #.End (!\in #.End) - (#.Item x xs') + {#.Item x xs'} (|> x (!\each (function (_ _x) - (!\each (|>> (#.Item _x)) (recur xs')))) + (!\each (|>> {#.Item _x}) (recur xs')))) !\conjoint))))) (def: .public (each monad f) @@ -139,10 +139,10 @@ #.End (!\in #.End) - (#.Item x xs') + {#.Item x xs'} (|> (f x) (!\each (function (_ _x) - (!\each (|>> (#.Item _x)) (recur xs')))) + (!\each (|>> {#.Item _x}) (recur xs')))) !\conjoint))))) (def: .public (only monad f) @@ -155,12 +155,12 @@ #.End (!\in #.End) - (#.Item head xs') + {#.Item head xs'} (|> (f head) (!\each (function (_ verdict) (!\each (function (_ tail) (if verdict - (#.Item head tail) + {#.Item head tail} tail)) (recur xs')))) !\conjoint))))) @@ -173,7 +173,7 @@ #.End (\ monad in init) - (#.Item x xs') + {#.Item x xs'} (do monad [init' (f x init)] (mix monad f init' xs')))) diff --git a/stdlib/source/library/lux/abstract/monad/free.lux b/stdlib/source/library/lux/abstract/monad/free.lux index 2f4d88fcc..04718ceb8 100644 --- a/stdlib/source/library/lux/abstract/monad/free.lux +++ b/stdlib/source/library/lux/abstract/monad/free.lux @@ -8,19 +8,19 @@ (type: .public (Free F a) (Variant - (#Pure a) - (#Effect (F (Free F a))))) + {#Pure a} + {#Effect (F (Free F a))})) (implementation: .public (functor dsl) (All (_ F) (-> (Functor F) (Functor (Free F)))) (def: (each f ea) (case ea - (#Pure a) - (#Pure (f a)) + {#Pure a} + {#Pure (f a)} - (#Effect value) - (#Effect (\ dsl each (each f) value))))) + {#Effect value} + {#Effect (\ dsl each (each f) value)}))) (implementation: .public (apply dsl) (All (_ F) (-> (Functor F) (Apply (Free F)))) @@ -30,16 +30,16 @@ (def: (on ea ef) (case [ef ea] - [(#Pure f) (#Pure a)] - (#Pure (f a)) + [{#Pure f} {#Pure a}] + {#Pure (f a)} - [(#Pure f) (#Effect fa)] - (#Effect (\ dsl each + [{#Pure f} {#Effect fa}] + {#Effect (\ dsl each (\ (..functor dsl) each f) - fa)) + fa)} - [(#Effect ff) _] - (#Effect (\ dsl each (on ea) ff)) + [{#Effect ff} _] + {#Effect (\ dsl each (on ea) ff)} ))) (implementation: .public (monad dsl) @@ -48,20 +48,20 @@ (def: &functor (..functor dsl)) (def: (in a) - (#Pure a)) + {#Pure a}) (def: (conjoint efefa) (case efefa - (#Pure efa) + {#Pure efa} (case efa - (#Pure a) - (#Pure a) + {#Pure a} + {#Pure a} - (#Effect fa) - (#Effect fa)) + {#Effect fa} + {#Effect fa}) - (#Effect fefa) - (#Effect (\ dsl each + {#Effect fefa} + {#Effect (\ dsl each (\ (monad dsl) conjoint) - fefa)) + fefa)} ))) diff --git a/stdlib/source/library/lux/abstract/monad/indexed.lux b/stdlib/source/library/lux/abstract/monad/indexed.lux index 6e8ddb602..3051aba52 100644 --- a/stdlib/source/library/lux/abstract/monad/indexed.lux +++ b/stdlib/source/library/lux/abstract/monad/indexed.lux @@ -33,8 +33,8 @@ (type: Context (Variant - (#Macro Name Code) - (#Binding Binding))) + {#Macro Name Code} + {#Binding Binding})) (def: global_identifier (Parser Name) @@ -67,12 +67,12 @@ (macro.with_identifiers [g!_ g!then] (let [body (list\mix (function (_ context next) (case context - (#Macro macro parameter) + {#Macro macro parameter} (` ((~ (code.identifier macro)) (~ parameter) (~ next))) - (#Binding [binding value]) + {#Binding [binding value]} (` ((~ g!then) (.function ((~ g!_) (~ binding)) (~ next)) @@ -80,7 +80,7 @@ expression (list.reversed context))] (in (list (case ?name - (#.Some name) + {#.Some name} (let [name (code.local_identifier name)] (` (let [(~ name) (~ monad) [#..in (~' in) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index 28a48035f..2e70ed49e 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -67,7 +67,7 @@ (monad.do meta.monad [expansion expander] (case expansion - (#.Item singleton #.End) + {#.Item singleton #.End} (in singleton) _ @@ -87,7 +87,7 @@ aliases))] (case [(value@ #bottom inputs) (value@ #bottom outputs)] - [(#.Some bottomI) (#.Some bottomO)] + [{#.Some bottomI} {#.Some bottomO}] (monad.do meta.monad [inputC (singleton (macro.full_expansion (stack_mix (value@ #top inputs) bottomI))) outputC (singleton (macro.full_expansion (stack_mix (value@ #top outputs) bottomO)))] @@ -191,12 +191,12 @@ (def: .public ||L (All (_ a b) (=> [a] [(Or a b)])) (function (_ [stack l]) - [stack (0 #0 l)])) + [stack {0 #0 l}])) (def: .public ||R (All (_ a b) (=> [b] [(Or a b)])) (function (_ [stack r]) - [stack (0 #1 r)])) + [stack {0 #1 r}])) (template [<input> <output> <word> <func>] [(`` (def: .public <word> diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index 5ce45f632..e3635595a 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -54,8 +54,8 @@ (do [! io.monad] [current (async.value read)] (case current - (#.Some [head tail]) - (\ ! each (|>> (#.Item head)) + {#.Some [head tail]} + (\ ! each (|>> {#.Item head}) (pending tail)) #.None @@ -94,15 +94,15 @@ [[head tail] |mailbox| ?state' (on_mail head state self)] (case ?state' - (#try.Failure error) + {#try.Failure error} (let [[_ resolve] (value@ #obituary (:representation self))] (exec (io.run! (do io.monad [pending (..pending tail)] - (resolve [error state (#.Item head pending)]))) + (resolve [error state {#.Item head pending}]))) (in []))) - (#try.Success state') + {#try.Success state'} (recur state' tail))))] self))) @@ -147,10 +147,10 @@ (if resolved? (do ! [_ (atom.write! (product.right entry) (value@ #mailbox (:representation actor)))] - (in (#try.Success []))) + (in {#try.Success []})) (recur |mailbox|&resolve))) - (#.Some [_ |mailbox|']) + {#.Some [_ |mailbox|']} (recur |mailbox|')))))) (in (exception.except ..dead []))))) @@ -171,15 +171,15 @@ (do [! async.monad] [outcome (message state self)] (case outcome - (#try.Success [state' return]) + {#try.Success [state' return]} (exec - (io.run! (resolve (#try.Success return))) - (async.resolved (#try.Success state'))) + (io.run! (resolve {#try.Success return})) + (async.resolved {#try.Success state'})) - (#try.Failure error) + {#try.Failure error} (exec - (io.run! (resolve (#try.Failure error))) - (async.resolved (#try.Failure error))))))])) + (io.run! (resolve {#try.Failure error})) + (async.resolved {#try.Failure error})))))])) (def: .public (tell! message actor) (All (_ s o) (-> (Message s o) (Actor s) (Async (Try o)))) @@ -187,11 +187,11 @@ (do async.monad [outcome (async.future (..mail! mail actor))] (case outcome - (#try.Success) + {#try.Success} async - (#try.Failure error) - (in (#try.Failure error))))))] + {#try.Failure error} + (in {#try.Failure error})))))] ) ) @@ -244,7 +244,7 @@ #.None (` (~! ..default_on_mail)) - (#.Some [[mailN stateN selfN] bodyC]) + {#.Some [[mailN stateN selfN] bodyC]} (` (function ((~ g!_) (~ (code.local_identifier mailN)) (~ (code.local_identifier stateN)) diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index 903ac8bd9..6e38aff6f 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -31,12 +31,12 @@ (do [! io.monad] [(^@ old [_value _observers]) (atom.read! async)] (case _value - (#.Some _) + {#.Some _} (in #0) #.None (do ! - [.let [new [(#.Some value) #.None]] + [.let [new [{#.Some value} #.None]] succeeded? (atom.compare_and_swap! old new async)] (if succeeded? (do ! @@ -47,7 +47,7 @@ (def: .public (resolved value) (All (_ a) (-> a (Async a))) - (:abstraction (atom [(#.Some value) (list)]))) + (:abstraction (atom [{#.Some value} (list)]))) (def: .public (async _) (All (_ a) (-> Any [(Async a) (Resolver a)])) @@ -66,11 +66,11 @@ [.let [async (:representation async)] (^@ old [_value _observers]) (atom.read! async)] (case _value - (#.Some value) + {#.Some value} (f value) #.None - (let [new [_value (#.Item f _observers)]] + (let [new [_value {#.Item f _observers}]] (do ! [swapped? (atom.compare_and_swap! old new async)] (if swapped? @@ -85,7 +85,7 @@ (|>> (case> #.None #0 - (#.Some _) + {#.Some _} #1))))) (implementation: .public functor diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index 1021c7e05..5498eeb06 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -42,7 +42,7 @@ stopped? (current #.None)] (if stopped? ... I closed the sink. - (in (#try.Success [])) + (in {#try.Success []}) ... Someone else interacted with the sink. (do ! [latter (atom.read! sink)] @@ -63,12 +63,12 @@ [(Async (Maybe [a (Channel a)])) (async.Resolver (Maybe [a (Channel a)]))] (async.async []))] - fed? (current (#.Some [value next]))] + fed? (current {#.Some [value next]})] (if fed? ... I fed the sink. (do ! [_ (atom.compare_and_swap! current resolve_next sink)] - (in (#try.Success []))) + (in {#try.Success []})) ... Someone else interacted with the sink. (do ! [latter (atom.read! sink)] @@ -102,8 +102,8 @@ [item_f ff item_a fa] (case [item_f item_a] - [(#.Some [head_f tail_f]) (#.Some [head_a tail_a])] - (in (#.Some [(head_f head_a) (on tail_a tail_f)])) + [{#.Some [head_f tail_f]} {#.Some [head_a tail_a]}] + (in {#.Some [(head_f head_a) (on tail_a tail_f)]}) _ (in #.None))))) @@ -118,7 +118,7 @@ (def: &functor ..functor) (def: (in a) - (async.resolved (#.Some [a ..empty]))) + (async.resolved {#.Some [a ..empty]})) (def: (conjoint mma) (let [[output sink] (channel [])] @@ -128,13 +128,13 @@ (do [! async.monad] [?mma mma] (case ?mma - (#.Some [ma mma']) + {#.Some [ma mma']} (do ! [_ (loop [ma ma] (do ! [?ma ma] (case ?ma - (#.Some [a ma']) + {#.Some [a ma']} (exec (io.run! (\ sink feed a)) (recur ma')) @@ -158,9 +158,9 @@ (do async.monad [item channel] (case item - (#.Some [head tail]) + {#.Some [head tail]} (case (io.run! (subscriber head)) - (#.Some _) + {#.Some _} (recur tail) #.None @@ -175,10 +175,10 @@ (do async.monad [item channel] (case item - (#.Some [head tail]) + {#.Some [head tail]} (let [tail' (only pass? tail)] (if (pass? head) - (in (#.Some [head tail'])) + (in {#.Some [head tail']}) tail')) #.None @@ -187,7 +187,7 @@ (def: .public (of_async async) (All (_ a) (-> (Async a) (Channel a))) (async\each (function (_ value) - (#.Some [value ..empty])) + {#.Some [value ..empty]}) async)) (def: .public (mix f init channel) @@ -200,7 +200,7 @@ #.None (in init) - (#.Some [head tail]) + {#.Some [head tail]} (do ! [init' (f head init)] (mix f init' tail))))) @@ -213,12 +213,12 @@ [item channel] (case item #.None - (in (#.Some [init (in #.None)])) + (in {#.Some [init (in #.None)]}) - (#.Some [head tail]) + {#.Some [head tail]} (do ! [init' (f head init)] - (in (#.Some [init (mixes f init' tail)])))))) + (in {#.Some [init (mixes f init' tail)]}))))) (def: .public (poll milli_seconds action) (All (_ a) @@ -241,8 +241,8 @@ (do async.monad [?next (f init)] (case ?next - (#.Some [state output]) - (in (#.Some [output (iterations f state)])) + {#.Some [state output]} + (in {#.Some [output (iterations f state)]}) #.None (in #.None)))) @@ -252,10 +252,10 @@ (do async.monad [item channel] (case item - (#.Some [head tail]) + {#.Some [head tail]} (if (\ equivalence = previous head) (distinct' equivalence previous tail) - (in (#.Some [head (distinct' equivalence head tail)]))) + (in {#.Some [head (distinct' equivalence head tail)]})) #.None (in #.None)))) @@ -265,8 +265,8 @@ (do async.monad [item channel] (in (case item - (#.Some [head tail]) - (#.Some [head (distinct' equivalence head tail)]) + {#.Some [head tail]} + {#.Some [head (distinct' equivalence head tail)]} #.None #.None)))) @@ -276,8 +276,8 @@ (do [! async.monad] [item channel] (case item - (#.Some [head tail]) - (\ ! each (|>> (#.Item head)) + {#.Some [head tail]} + (\ ! each (|>> {#.Item head}) (list tail)) #.None @@ -289,7 +289,7 @@ #.End ..empty - (#.Item head tail) - (async.resolved (#.Some [head (do async.monad + {#.Item head tail} + (async.resolved {#.Some [head (do async.monad [_ (async.delay milli_seconds)] - (sequential milli_seconds tail))])))) + (sequential milli_seconds tail))]}))) diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index 013720460..755e201ff 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -89,9 +89,9 @@ #.None (in true) - (#.Some sink) + {#.Some sink} (sink []))] - (in (#try.Success (value@ #open_positions post)))))))))] + (in {#try.Success (value@ #open_positions post)})))))))] ) (abstract: .public Mutex diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux index 6b89926ff..382859176 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -54,10 +54,10 @@ (do ! [result (\ sink feed new_value)] (case result - (#try.Success _) + {#try.Success _} (in []) - (#try.Failure _) + {#try.Failure _} (un_follow! sink var)))) observers)] (in [])) @@ -68,7 +68,7 @@ (do io.monad [.let [[channel sink] (frp.channel [])] _ (atom.update! (function (_ [value observers]) - [value (#.Item sink observers)]) + [value {#.Item sink observers}]) (:representation target))] (in [channel sink])))] ) @@ -99,12 +99,12 @@ (All (_ a) (-> (Var a) (STM a))) (function (_ tx) (case (var_value var tx) - (#.Some value) + {#.Some value} [tx value] #.None (let [value (..read! var)] - [(#.Item [var value value] tx) + [{#.Item [var value value] tx} value])))) (def: (with_updated_var var value tx) @@ -113,28 +113,28 @@ #.End #.End - (#.Item [_var _original _current] tx') + {#.Item [_var _original _current] tx'} (if (same? (:as (Var Any) var) (:as (Var Any) _var)) - (#.Item [#var (:as (Var Any) _var) + {#.Item [#var (:as (Var Any) _var) #original (:as Any _original) #current (:as Any value)] - tx') - (#.Item [#var _var + tx'} + {#.Item [#var _var #original _original #current _current] - (with_updated_var var value tx'))))) + (with_updated_var var value tx')}))) (def: .public (write value var) (All (_ a) (-> a (Var a) (STM Any))) (function (_ tx) (case (var_value var tx) - (#.Some _) + {#.Some _} [(with_updated_var var value tx) []] #.None - [(#.Item [var (..read! var) value] tx) + [{#.Item [var (..read! var) value] tx} []]))) (implementation: .public functor @@ -223,7 +223,7 @@ (atom.write! (product.right entry) pending_commits) (recur |commits|&resolve))) - (#.Some [head tail]) + {#.Some [head tail]} (recur tail))))))) (def: (process_commit! commit) diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index c9430c1ed..f52b7f319 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -91,14 +91,14 @@ (def: (execute! action) (-> (IO Any) Any) (case (try (io.run! action)) - (#try.Failure error) + {#try.Failure error} (exec ("lux io log" ($_ "lux text concat" "ERROR DURING THREAD EXECUTION:" text.new_line error)) []) - (#try.Success _) + {#try.Success _} [])) (def: .public (schedule! milli_seconds action) @@ -129,9 +129,9 @@ ... Default (do [! io.monad] [now (\ ! each (|>> instant.millis .nat) instant.now) - _ (atom.update! (|>> (#.Item [#creation now + _ (atom.update! (|>> {#.Item [#creation now #delay milli_seconds - #action action])) + #action action]}) ..runner)] (in []))))) diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index 039265ff7..3ea07e3e7 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -40,26 +40,26 @@ (-> (Exception e) (-> Text a) (Try a) (Try a))) (case try - (#//.Success output) - (#//.Success output) + {#//.Success output} + {#//.Success output} - (#//.Failure error) + {#//.Failure error} (let [reference (value@ #label exception)] (if (text.starts_with? reference error) - (#//.Success (|> error + {#//.Success (|> error (text.clip_since (text.size reference)) maybe.trusted - then)) - (#//.Failure error))))) + then)} + {#//.Failure error})))) (def: .public (otherwise else try) (All (_ a) (-> (-> Text a) (Try a) a)) (case try - (#//.Success output) + {#//.Success output} output - (#//.Failure error) + {#//.Failure error} (else error))) (def: .public (error exception message) @@ -68,12 +68,12 @@ (def: .public (except exception message) (All (_ e a) (-> (Exception e) e (Try a))) - (#//.Failure (..error exception message))) + {#//.Failure (..error exception message)}) (def: .public (assertion exception message test) (All (_ e) (-> (Exception e) e Bit (Try Any))) (if test - (#//.Success []) + {#//.Success []} (..except exception message))) (def: exception @@ -131,7 +131,7 @@ #.End "" - (#.Item head tail) + {#.Item head tail} (list\mix (function (_ post pre) ($_ text\composite pre text.new_line (on_entry post))) (on_entry head) @@ -148,8 +148,8 @@ (|> entries (list\mix (function (_ entry [index next]) [(++ index) - (#.Item [(n\encoded index) (format entry)] - next)]) + {#.Item [(n\encoded index) (format entry)] + next}]) [0 #.End]) product.right list.reversed @@ -173,13 +173,13 @@ (def: .public (with exception message computation) (All (_ e a) (-> (Exception e) e (Try a) (Try a))) (case computation - (#//.Failure error) - (#//.Failure (case error + {#//.Failure error} + {#//.Failure (case error "" (..error exception message) _ - (..decorated (..error exception message) error))) + (..decorated (..error exception message) error))} success success)) diff --git a/stdlib/source/library/lux/control/function/memo.lux b/stdlib/source/library/lux/control/function/memo.lux index 8e99b18ab..cccc36bf4 100644 --- a/stdlib/source/library/lux/control/function/memo.lux +++ b/stdlib/source/library/lux/control/function/memo.lux @@ -23,7 +23,7 @@ (do [! state.monad] [memory state.get] (case (dictionary.value input memory) - (#.Some output) + {#.Some output} (in output) #.None diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index 159f037e3..820d40253 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -58,7 +58,7 @@ #.End (in (list body)) - (#.Item mutual #.End) + {#.Item mutual #.End} (.let [g!name (|> mutual (value@ [#declaration #declaration.name]) code.local_identifier)] (in (list (` (.let [(~ g!name) (: (~ (value@ #type mutual)) (function (~ (declaration.format (value@ #declaration mutual))) @@ -110,7 +110,7 @@ #.End (in (list)) - (#.Item definition #.End) + {#.Item definition #.End} (.let [(^slots [#export_policy #mutual]) definition (^slots [#declaration #type #body]) mutual] (in (list (` (.def: (~ export_policy) (~ (declaration.format declaration)) diff --git a/stdlib/source/library/lux/control/lazy.lux b/stdlib/source/library/lux/control/lazy.lux index 16b501d9e..baedf1354 100644 --- a/stdlib/source/library/lux/control/lazy.lux +++ b/stdlib/source/library/lux/control/lazy.lux @@ -25,13 +25,13 @@ (let [cache (atom.atom #.None)] (:abstraction (function (_ _) (case (io.run! (atom.read! cache)) - (#.Some value) + {#.Some value} value _ (let [value (generator [])] (exec - (io.run! (atom.compare_and_swap! _ (#.Some value) cache)) + (io.run! (atom.compare_and_swap! _ {#.Some value} cache)) value))))))) (def: .public (value lazy) diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 036377285..0387618a8 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -13,7 +13,7 @@ ... (type: (Maybe a) ... #.None -... (#.Some a)) +... {#.Some a}) (implementation: .public monoid (All (_ a) (Monoid (Maybe a))) @@ -25,8 +25,8 @@ #.None my - (#.Some x) - (#.Some x)))) + {#.Some x} + {#.Some x}))) (implementation: .public functor (Functor Maybe) @@ -34,7 +34,7 @@ (def: (each f ma) (case ma #.None #.None - (#.Some a) (#.Some (f a))))) + {#.Some a} {#.Some (f a)}))) (implementation: .public apply (Apply Maybe) @@ -43,8 +43,8 @@ (def: (on fa ff) (case [ff fa] - [(#.Some f) (#.Some a)] - (#.Some (f a)) + [{#.Some f} {#.Some a}] + {#.Some (f a)} _ #.None))) @@ -55,14 +55,14 @@ (def: &functor ..functor) (def: (in x) - (#.Some x)) + {#.Some x}) (def: (conjoint mma) (case mma #.None #.None - (#.Some mx) + {#.Some mx} mx))) (implementation: .public (equivalence super) @@ -73,7 +73,7 @@ [#.None #.None] #1 - [(#.Some x) (#.Some y)] + [{#.Some x} {#.Some y}] (\ super = x y) _ @@ -90,7 +90,7 @@ #.None 0 - (#.Some value) + {#.Some value} (\ super hash value)))) (implementation: .public (with monad) @@ -109,7 +109,7 @@ #.None (in #.None) - (#.Some Mma) + {#.Some Mma} Mma)))) (def: .public (lifted monad) @@ -119,16 +119,16 @@ (macro: .public (else tokens state) (case tokens (^ (.list else maybe)) - (let [g!temp (: Code [location.dummy (#.Identifier ["" ""])])] - (#.Right [state (.list (` (case (~ maybe) - (#.Some (~ g!temp)) + (let [g!temp (: Code [location.dummy {#.Identifier ["" ""]}])] + {#.Right [state (.list (` (case (~ maybe) + {#.Some (~ g!temp)} (~ g!temp) #.None - (~ else))))])) + (~ else))))]}) _ - (#.Left "Wrong syntax for else"))) + {#.Left "Wrong syntax for else"})) (def: .public trusted (All (_ a) (-> (Maybe a) a)) @@ -140,15 +140,15 @@ #.None #.End - (#.Some value) - (#.Item value #.End))) + {#.Some value} + {#.Item value #.End})) (macro: .public (when tokens state) (case tokens (^ (.list test then)) - (#.Right [state (.list (` (.if (~ test) + {#.Right [state (.list (` (.if (~ test) (~ then) - #.None)))]) + #.None)))]} _ - (#.Left "Wrong syntax for when"))) + {#.Left "Wrong syntax for when"})) diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index 7b7c499aa..17731a079 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -25,11 +25,11 @@ (def: (each f ma) (function (_ input) (case (ma input) - (#try.Failure msg) - (#try.Failure msg) + {#try.Failure msg} + {#try.Failure msg} - (#try.Success [input' a]) - (#try.Success [input' (f a)]))))) + {#try.Success [input' a]} + {#try.Success [input' (f a)]})))) (implementation: .public apply (All (_ s) (Apply (Parser s))) @@ -39,16 +39,16 @@ (def: (on fa ff) (function (_ input) (case (ff input) - (#try.Success [input' f]) + {#try.Success [input' f]} (case (fa input') - (#try.Success [input'' a]) - (#try.Success [input'' (f a)]) + {#try.Success [input'' a]} + {#try.Success [input'' (f a)]} - (#try.Failure msg) - (#try.Failure msg)) + {#try.Failure msg} + {#try.Failure msg}) - (#try.Failure msg) - (#try.Failure msg))))) + {#try.Failure msg} + {#try.Failure msg})))) (implementation: .public monad (All (_ s) (Monad (Parser s))) @@ -57,34 +57,34 @@ (def: (in x) (function (_ input) - (#try.Success [input x]))) + {#try.Success [input x]})) (def: (conjoint mma) (function (_ input) (case (mma input) - (#try.Failure msg) - (#try.Failure msg) + {#try.Failure msg} + {#try.Failure msg} - (#try.Success [input' ma]) + {#try.Success [input' ma]} (ma input'))))) (def: .public (assertion message test) (All (_ s) (-> Text Bit (Parser s Any))) (function (_ input) (if test - (#try.Success [input []]) - (#try.Failure message)))) + {#try.Success [input []]} + {#try.Failure message}))) (def: .public (maybe parser) (All (_ s a) (-> (Parser s a) (Parser s (Maybe a)))) (function (_ input) (case (parser input) - (#try.Failure _) - (#try.Success [input #.None]) + {#try.Failure _} + {#try.Success [input #.None]} - (#try.Success [input' x]) - (#try.Success [input' (#.Some x)])))) + {#try.Success [input' x]} + {#try.Success [input' {#.Some x}]}))) (def: .public (result parser input) (All (_ s a) @@ -103,23 +103,23 @@ (-> (Parser s a) (Parser s b) (Parser s (Or a b)))) (function (_ tokens) (case (left tokens) - (#try.Success [tokens' output]) - (#try.Success [tokens' (0 #0 output)]) + {#try.Success [tokens' output]} + {#try.Success [tokens' {0 #0 output}]} - (#try.Failure _) + {#try.Failure _} (case (right tokens) - (#try.Success [tokens' output]) - (#try.Success [tokens' (0 #1 output)]) + {#try.Success [tokens' output]} + {#try.Success [tokens' {0 #1 output}]} - (#try.Failure error) - (#try.Failure error))))) + {#try.Failure error} + {#try.Failure error})))) (def: .public (either this that) (All (_ s a) (-> (Parser s a) (Parser s a) (Parser s a))) (function (_ tokens) (case (this tokens) - (#try.Failure _) + {#try.Failure _} (that tokens) output @@ -130,10 +130,10 @@ (-> (Parser s a) (Parser s (List a)))) (function (_ input) (case (parser input) - (#try.Failure _) - (#try.Success [input (list)]) + {#try.Failure _} + {#try.Success [input (list)]} - (#try.Success [input' head]) + {#try.Success [input' head]} (..result (\ ..monad each (|>> (list& head)) (some parser)) input')))) @@ -153,7 +153,7 @@ [x parser] (|> parser (exactly (-- amount)) - (\ ! each (|>> (#.Item x))))))) + (\ ! each (|>> {#.Item x})))))) (def: .public (at_least amount parser) (All (_ s a) (-> Nat (Parser s a) (Parser s (List a)))) @@ -167,11 +167,11 @@ 0 (\ ..monad in (list)) _ (function (_ input) (case (parser input) - (#try.Failure msg) - (#try.Success [input (list)]) + {#try.Failure msg} + {#try.Success [input (list)]} - (#try.Success [input' x]) - (..result (\ ..monad each (|>> (#.Item x)) + {#try.Success [input' x]} + (..result (\ ..monad each (|>> {#.Item x}) (at_most (-- amount) parser)) input'))))) @@ -192,51 +192,51 @@ #.None (in #.End) - (#.Some x) + {#.Some x} (|> parser (..and separator) ..some - (\ ! each (|>> (list\each product.right) (#.Item x))))))) + (\ ! each (|>> (list\each product.right) {#.Item x})))))) (def: .public (not parser) (All (_ s a) (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) - (#try.Failure msg) - (#try.Success [input []]) + {#try.Failure msg} + {#try.Success [input []]} _ - (#try.Failure "Expected to fail; yet succeeded.")))) + {#try.Failure "Expected to fail; yet succeeded."}))) (def: .public (failure message) (All (_ s a) (-> Text (Parser s a))) (function (_ input) - (#try.Failure message))) + {#try.Failure message})) (def: .public (lifted operation) (All (_ s a) (-> (Try a) (Parser s a))) (function (_ input) (case operation - (#try.Success output) - (#try.Success [input output]) + {#try.Success output} + {#try.Success [input output]} - (#try.Failure error) - (#try.Failure error)))) + {#try.Failure error} + {#try.Failure error}))) (def: .public (else value parser) (All (_ s a) (-> a (Parser s a) (Parser s a))) (function (_ input) (case (parser input) - (#try.Failure error) - (#try.Success [input value]) + {#try.Failure error} + {#try.Success [input value]} - (#try.Success [input' output]) - (#try.Success [input' output])))) + {#try.Success [input' output]} + {#try.Success [input' output]}))) (def: .public remaining (All (_ s) (Parser s s)) (function (_ inputs) - (#try.Success [inputs inputs]))) + {#try.Success [inputs inputs]})) (def: .public (rec parser) (All (_ s a) (-> (-> (Parser s a) (Parser s a)) (Parser s a))) @@ -267,28 +267,28 @@ (All (_ s a) (-> (Parser s a) (Parser s Bit))) (function (_ input) (case (parser input) - (#try.Failure error) - (#try.Success [input false]) + {#try.Failure error} + {#try.Success [input false]} - (#try.Success [input' _]) - (#try.Success [input' true])))) + {#try.Success [input' _]} + {#try.Success [input' true]}))) (def: .public (parses parser) (All (_ s a) (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success [input' _]) - (#try.Success [input' []])))) + {#try.Success [input' _]} + {#try.Success [input' []]}))) (def: .public (speculative parser) (All (_ s a) (-> (Parser s a) (Parser s a))) (function (_ input) (case (parser input) - (#try.Success [input' output]) - (#try.Success [input output]) + {#try.Success [input' output]} + {#try.Success [input output]} output output))) @@ -297,13 +297,13 @@ (All (_ s a z) (-> (Codec a z) (Parser s a) (Parser s z))) (function (_ input) (case (parser input) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success [input' to_decode]) + {#try.Success [input' to_decode]} (case (\ codec decoded to_decode) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success value) - (#try.Success [input' value]))))) + {#try.Success value} + {#try.Success [input' value]})))) diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/library/lux/control/parser/analysis.lux index bbc90f043..0c5f47cb3 100644 --- a/stdlib/source/library/lux/control/parser/analysis.lux +++ b/stdlib/source/library/lux/control/parser/analysis.lux @@ -53,13 +53,13 @@ (def: .public (result parser input) (All (_ a) (-> (Parser a) (List Analysis) (Try a))) (case (parser input) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success [#.End value]) - (#try.Success value) + {#try.Success [#.End value]} + {#try.Success value} - (#try.Success [unconsumed _]) + {#try.Success [unconsumed _]} (exception.except ..unconsumed_input unconsumed))) (def: .public any @@ -69,23 +69,23 @@ #.End (exception.except ..cannot_parse input) - (#.Item [head tail]) - (#try.Success [tail head])))) + {#.Item [head tail]} + {#try.Success [tail head]}))) (def: .public end! (Parser Any) (function (_ tokens) (case tokens - #.End (#try.Success [tokens []]) - _ (#try.Failure (format "Expected list of tokens to be empty!" - (remaining_inputs tokens)))))) + #.End {#try.Success [tokens []]} + _ {#try.Failure (format "Expected list of tokens to be empty!" + (remaining_inputs tokens))}))) (def: .public end? (Parser Bit) (function (_ tokens) - (#try.Success [tokens (case tokens + {#try.Success [tokens (case tokens #.End true - _ false)]))) + _ false)]})) (template [<query> <assertion> <tag> <type> <eq>] [(`` (as_is (def: .public <query> @@ -93,7 +93,7 @@ (function (_ input) (case input (^ (list& (<tag> x) input')) - (#try.Success [input' x]) + {#try.Success [input' x]} _ (exception.except ..cannot_parse input)))) @@ -104,7 +104,7 @@ (case input (^ (list& (<tag> actual) input')) (if (\ <eq> = expected actual) - (#try.Success [input' []]) + {#try.Success [input' []]} (exception.except ..cannot_parse input)) _ @@ -128,7 +128,7 @@ (^ (list& (/.tuple head) tail)) (do try.monad [output (..result parser head)] - (#try.Success [tail output])) + {#try.Success [tail output]}) _ (exception.except ..cannot_parse input)))) diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index d6de3c7cd..0f5e925e1 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -41,29 +41,29 @@ (def: .public (result parser input) (All (_ a) (-> (Parser a) Binary (Try a))) (case (parser [0 input]) - (#try.Failure msg) - (#try.Failure msg) + {#try.Failure msg} + {#try.Failure msg} - (#try.Success [[end _] output]) + {#try.Success [[end _] output]} (let [length (/.size input)] (if (n.= end length) - (#try.Success output) + {#try.Success output} (exception.except ..binary_was_not_fully_read [length end]))))) (def: .public end? (Parser Bit) (function (_ (^@ input [offset data])) - (#try.Success [input (n.= offset (/.size data))]))) + {#try.Success [input (n.= offset (/.size data))]})) (def: .public offset (Parser Offset) (function (_ (^@ input [offset data])) - (#try.Success [input offset]))) + {#try.Success [input offset]})) (def: .public remaining (Parser Nat) (function (_ (^@ input [offset data])) - (#try.Success [input (n.- offset (/.size data))]))) + {#try.Success [input (n.- offset (/.size data))]})) (type: .public Size Nat) @@ -78,11 +78,11 @@ (Parser I64) (function (_ [offset binary]) (case (<read> offset binary) - (#try.Success data) - (#try.Success [(n.+ <size> offset) binary] data) + {#try.Success data} + {#try.Success [(n.+ <size> offset) binary] data} - (#try.Failure error) - (#try.Failure error))))] + {#try.Failure error} + {#try.Failure error})))] [bits/8 ..size/8 /.read/8!] [bits/16 ..size/16 /.read/16!] @@ -115,7 +115,7 @@ (with_expansions [<case>+' (template.spliced <case>+)] (case flag (^template [<number> <tag> <parser>] - [<number> (`` (\ ! each (|>> ((~~ (template.spliced <tag>)))) <parser>))]) + [<number> (`` (\ ! each (|>> {(~~ (template.spliced <tag>))}) <parser>))]) (<case>+') _ (//.lifted (exception.except ..invalid_tag [(template.amount [<case>+]) flag])))))]) @@ -154,7 +154,7 @@ (-> Nat (Parser Binary)) (function (_ [offset binary]) (case size - 0 (#try.Success [[offset binary] (/.empty 0)]) + 0 {#try.Success [[offset binary] (/.empty 0)]} _ (|> binary (/.slice offset size) (\ try.monad each (|>> [[(n.+ size offset) binary]])))))) diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/library/lux/control/parser/cli.lux index c60b80d6a..aca4512fb 100644 --- a/stdlib/source/library/lux/control/parser/cli.lux +++ b/stdlib/source/library/lux/control/parser/cli.lux @@ -16,26 +16,26 @@ (def: .public (result parser inputs) (All (_ a) (-> (Parser a) (List Text) (Try a))) (case (//.result parser inputs) - (#try.Success [remaining output]) + {#try.Success [remaining output]} (case remaining #.End - (#try.Success output) + {#try.Success output} _ - (#try.Failure (format "Remaining CLI inputs: " (text.interposed " " remaining)))) + {#try.Failure (format "Remaining CLI inputs: " (text.interposed " " remaining))}) - (#try.Failure try) - (#try.Failure try))) + {#try.Failure try} + {#try.Failure try})) (def: .public any (Parser Text) (function (_ inputs) (case inputs - (#.Item arg inputs') - (#try.Success [inputs' arg]) + {#.Item arg inputs'} + {#try.Success [inputs' arg]} _ - (#try.Failure "Cannot parse empty arguments.")))) + {#try.Failure "Cannot parse empty arguments."}))) (def: .public (parse parser) (All (_ a) (-> (-> Text (Try a)) (Parser a))) @@ -52,33 +52,33 @@ [[remaining raw] (any inputs)] (if (text\= reference raw) (in [remaining []]) - (#try.Failure (format "Missing token: '" reference "'")))))) + {#try.Failure (format "Missing token: '" reference "'")})))) (def: .public (somewhere cli) (All (_ a) (-> (Parser a) (Parser a))) (function (_ inputs) (loop [immediate inputs] (case (//.result cli immediate) - (#try.Success [remaining output]) - (#try.Success [remaining output]) + {#try.Success [remaining output]} + {#try.Success [remaining output]} - (#try.Failure try) + {#try.Failure try} (case immediate #.End - (#try.Failure try) + {#try.Failure try} - (#.Item to_omit immediate') + {#.Item to_omit immediate'} (do try.monad [[remaining output] (recur immediate')] - (in [(#.Item to_omit remaining) + (in [{#.Item to_omit remaining} output]))))))) (def: .public end (Parser Any) (function (_ inputs) (case inputs - #.End (#try.Success [inputs []]) - _ (#try.Failure (format "Unknown parameters: " (text.interposed " " inputs)))))) + #.End {#try.Success [inputs []]} + _ {#try.Failure (format "Unknown parameters: " (text.interposed " " inputs))}))) (def: .public (named name value) (All (_ a) (-> Text (Parser a) (Parser a))) diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index f9fc4d550..d58874cf4 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -25,7 +25,7 @@ (All (_ a) (-> (List [a a]) (List a))) (case pairs #.End #.End - (#.Item [[x y] pairs']) (list& x y (un_paired pairs')))) + {#.Item [[x y] pairs']} (list& x y (un_paired pairs')))) (type: .public Parser (//.Parser (List Code))) @@ -41,29 +41,29 @@ (function (_ tokens) (case tokens #.End - (#try.Failure "There are no tokens to parse!") + {#try.Failure "There are no tokens to parse!"} - (#.Item [t tokens']) - (#try.Success [tokens' t])))) + {#.Item [t tokens']} + {#try.Success [tokens' t]}))) (def: .public next (Parser Code) (function (_ tokens) (case tokens #.End - (#try.Failure "There are no tokens to parse!") + {#try.Failure "There are no tokens to parse!"} - (#.Item next _) - (#try.Success [tokens next])))) + {#.Item next _} + {#try.Success [tokens next]}))) (template [<query> <check> <type> <tag> <eq> <desc>] - [(with_expansions [<failure> (as_is (#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))))] + [(with_expansions [<failure> (as_is {#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})] (def: .public <query> (Parser <type>) (function (_ tokens) (case tokens - (#.Item [[_ (<tag> x)] tokens']) - (#try.Success [tokens' x]) + {#.Item [[_ {<tag> x}] tokens']} + {#try.Success [tokens' x]} _ <failure>))) @@ -72,9 +72,9 @@ (-> <type> (Parser Any)) (function (_ tokens) (case tokens - (#.Item [[_ (<tag> actual)] tokens']) + {#.Item [[_ {<tag> actual}] tokens']} (if (\ <eq> = expected actual) - (#try.Success [tokens' []]) + {#try.Success [tokens' []]} <failure>) _ @@ -94,23 +94,23 @@ (-> Code (Parser Any)) (function (_ tokens) (case tokens - (#.Item [token tokens']) + {#.Item [token tokens']} (if (code\= code token) - (#try.Success [tokens' []]) - (#try.Failure ($_ text\composite "Expected a " (code.format code) " but instead got " (code.format token) - (remaining_inputs tokens)))) + {#try.Success [tokens' []]} + {#try.Failure ($_ text\composite "Expected a " (code.format code) " but instead got " (code.format token) + (remaining_inputs tokens))}) _ - (#try.Failure "There are no tokens to parse!")))) + {#try.Failure "There are no tokens to parse!"}))) (template [<query> <check> <tag> <eq> <desc>] - [(with_expansions [<failure> (as_is (#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))))] + [(with_expansions [<failure> (as_is {#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})] (def: .public <query> (Parser Text) (function (_ tokens) (case tokens - (#.Item [[_ (<tag> ["" x])] tokens']) - (#try.Success [tokens' x]) + {#.Item [[_ {<tag> ["" x]}] tokens']} + {#try.Success [tokens' x]} _ <failure>))) @@ -119,9 +119,9 @@ (-> Text (Parser Any)) (function (_ tokens) (case tokens - (#.Item [[_ (<tag> ["" actual])] tokens']) + {#.Item [[_ {<tag> ["" actual]}] tokens']} (if (\ <eq> = expected actual) - (#try.Success [tokens' []]) + {#try.Success [tokens' []]} <failure>) _ @@ -137,13 +137,13 @@ (-> (Parser a) (Parser a))) (function (_ tokens) (case tokens - (#.Item [[_ (<tag> members)] tokens']) + {#.Item [[_ {<tag> members}] tokens']} (case (p members) - (#try.Success [#.End x]) (#try.Success [tokens' x]) - _ (#try.Failure ($_ text\composite "Parser was expected to fully consume " <desc> (remaining_inputs tokens)))) + {#try.Success [#.End x]} {#try.Success [tokens' x]} + _ {#try.Failure ($_ text\composite "Parser was expected to fully consume " <desc> (remaining_inputs tokens))}) _ - (#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))))))] + {#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})))] [form #.Form "form"] [variant #.Variant "variant"] @@ -154,32 +154,32 @@ (Parser Any) (function (_ tokens) (case tokens - #.End (#try.Success [tokens []]) - _ (#try.Failure ($_ text\composite "Expected list of tokens to be empty!" (remaining_inputs tokens)))))) + #.End {#try.Success [tokens []]} + _ {#try.Failure ($_ text\composite "Expected list of tokens to be empty!" (remaining_inputs tokens))}))) (def: .public end? (Parser Bit) (function (_ tokens) - (#try.Success [tokens (case tokens + {#try.Success [tokens (case tokens #.End true - _ false)]))) + _ false)]})) (def: .public (result parser inputs) (All (_ a) (-> (Parser a) (List Code) (Try a))) (case (parser inputs) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success [unconsumed value]) + {#try.Success [unconsumed value]} (case unconsumed #.End - (#try.Success value) + {#try.Success value} _ - (#try.Failure (|> unconsumed + {#try.Failure (|> unconsumed (list\each code.format) (text.interposed ", ") - (text\composite "Unconsumed inputs: ")))))) + (text\composite "Unconsumed inputs: "))}))) (def: .public (local inputs parser) (All (_ a) (-> (List Code) (Parser a) (Parser a))) @@ -195,5 +195,5 @@ result (//.or parser ..any)] (case result - (#.Left _) (//.failure (text\composite "Did NOT expect to parse code: " (code.format sample))) - (#.Right output) (in output)))) + {#.Left _} (//.failure (text\composite "Did NOT expect to parse code: " (code.format sample))) + {#.Right output} (in output)))) diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index 1ad723411..ce254222e 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -33,8 +33,8 @@ (-> Property (Parser Text)) (function (_ environment) (case (dictionary.value name environment) - (#.Some value) - (#try.Success [environment value]) + {#.Some value} + {#try.Success [environment value]} #.None (exception.except ..unknown_property [name])))) diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/library/lux/control/parser/json.lux index 4d09fa72b..3a0d76c1f 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -34,16 +34,16 @@ (def: .public (result parser json) (All (_ a) (-> (Parser a) JSON (Try a))) (case (//.result parser (list json)) - (#try.Success [remainder output]) + {#try.Success [remainder output]} (case remainder #.End - (#try.Success output) + {#try.Success output} _ (exception.except ..unconsumed_input remainder)) - (#try.Failure error) - (#try.Failure error))) + {#try.Failure error} + {#try.Failure error})) (def: .public any (Parser JSON) @@ -52,8 +52,8 @@ #.End (exception.except ..empty_input []) - (#.Item head tail) - (#try.Success [tail head])))) + {#.Item head tail} + {#try.Success [tail head]}))) (exception: .public (unexpected_value [value JSON]) (exception.report @@ -65,7 +65,7 @@ (do //.monad [head ..any] (case head - (<tag> value) + {<tag> value} (in value) _ @@ -89,7 +89,7 @@ (do //.monad [head ..any] (case head - (<tag> value) + {<tag> value} (in (\ <equivalence> = test value)) _ @@ -100,10 +100,10 @@ (do //.monad [head ..any] (case head - (<tag> value) + {<tag> value} (if (\ <equivalence> = test value) (in []) - (//.failure (exception.error ..value_mismatch [(<tag> test) (<tag> value)]))) + (//.failure (exception.error ..value_mismatch [{<tag> test} {<tag> value}]))) _ (//.failure (exception.error ..unexpected_value [head])))))] @@ -123,12 +123,12 @@ (do //.monad [head ..any] (case head - (#/.Array values) + {#/.Array values} (case (//.result parser (row.list values)) - (#try.Failure error) + {#try.Failure error} (//.failure error) - (#try.Success [remainder output]) + {#try.Success [remainder output]} (case remainder #.End (in output) @@ -144,17 +144,17 @@ (do //.monad [head ..any] (case head - (#/.Object kvs) + {#/.Object kvs} (case (|> kvs dictionary.entries (list\each (function (_ [key value]) - (list (#/.String key) value))) + (list {#/.String key} value))) list.together (//.result parser)) - (#try.Failure error) + {#try.Failure error} (//.failure error) - (#try.Success [remainder output]) + {#try.Success [remainder output]} (case remainder #.End (in output) @@ -169,20 +169,20 @@ (All (_ a) (-> Text (Parser a) (Parser a))) (function (recur inputs) (case inputs - (^ (list& (#/.String key) value inputs')) + (^ (list& {#/.String key} value inputs')) (if (text\= key field_name) (case (//.result parser (list value)) - (#try.Success [#.End output]) - (#try.Success [inputs' output]) + {#try.Success [#.End output]} + {#try.Success [inputs' output]} - (#try.Success [inputs'' _]) + {#try.Success [inputs'' _]} (exception.except ..unconsumed_input inputs'') - (#try.Failure error) - (#try.Failure error)) + {#try.Failure error} + {#try.Failure error}) (do try.monad [[inputs'' output] (recur inputs')] - (in [(list& (#/.String key) value inputs'') + (in [(list& {#/.String key} value inputs'') output]))) #.End diff --git a/stdlib/source/library/lux/control/parser/synthesis.lux b/stdlib/source/library/lux/control/parser/synthesis.lux index 0bc446089..1578f9115 100644 --- a/stdlib/source/library/lux/control/parser/synthesis.lux +++ b/stdlib/source/library/lux/control/parser/synthesis.lux @@ -53,13 +53,13 @@ (def: .public (result parser input) (All (_ a) (-> (Parser a) (List Synthesis) (Try a))) (case (parser input) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success [#.End value]) - (#try.Success value) + {#try.Success [#.End value]} + {#try.Success value} - (#try.Success [unconsumed _]) + {#try.Success [unconsumed _]} (exception.except ..unconsumed_input unconsumed))) (def: .public any @@ -69,22 +69,22 @@ #.End (exception.except ..empty_input []) - (#.Item [head tail]) - (#try.Success [tail head])))) + {#.Item [head tail]} + {#try.Success [tail head]}))) (def: .public end! (Parser Any) (.function (_ tokens) (case tokens - #.End (#try.Success [tokens []]) + #.End {#try.Success [tokens []]} _ (exception.except ..expected_empty_input [tokens])))) (def: .public end? (Parser Bit) (.function (_ tokens) - (#try.Success [tokens (case tokens + {#try.Success [tokens (case tokens #.End true - _ false)]))) + _ false)]})) (template [<query> <assertion> <tag> <type> <eq>] [(`` (def: .public <query> @@ -92,7 +92,7 @@ (.function (_ input) (case input (^ (list& (<tag> x) input')) - (#try.Success [input' x]) + {#try.Success [input' x]} _ (exception.except ..cannot_parse input))))) @@ -103,7 +103,7 @@ (case input (^ (list& (<tag> actual) input')) (if (\ <eq> = expected actual) - (#try.Success [input' []]) + {#try.Success [input' []]} (exception.except ..cannot_parse input)) _ @@ -125,7 +125,7 @@ (^ (list& (/.tuple head) tail)) (do try.monad [output (..result parser head)] - (#try.Success [tail output])) + {#try.Success [tail output]}) _ (exception.except ..cannot_parse input)))) @@ -138,7 +138,7 @@ (if (n.= expected actual) (do try.monad [output (..result parser (list body))] - (#try.Success [tail [environment output]])) + {#try.Success [tail [environment output]]}) (exception.except ..wrong_arity [expected actual])) _ @@ -152,7 +152,7 @@ (do try.monad [inits (..result init_parsers inits) iteration (..result iteration_parser (list iteration))] - (#try.Success [tail [start inits iteration]])) + {#try.Success [tail [start inits iteration]]}) _ (exception.except ..cannot_parse input)))) diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux index 9c847ad5c..8594dc353 100644 --- a/stdlib/source/library/lux/control/parser/text.lux +++ b/stdlib/source/library/lux/control/parser/text.lux @@ -58,18 +58,18 @@ (def: .public (result parser input) (All (_ a) (-> (Parser a) Text (Try a))) (case (parser [start_offset input]) - (#try.Failure msg) - (#try.Failure msg) + {#try.Failure msg} + {#try.Failure msg} - (#try.Success [[end_offset _] output]) + {#try.Success [[end_offset _] output]} (if (n.= end_offset (/.size input)) - (#try.Success output) + {#try.Success output} (exception.except ..unconsumed_input [end_offset input])))) (def: .public offset (Parser Offset) (function (_ (^@ input [offset tape])) - (#try.Success [input offset]))) + {#try.Success [input offset]})) (def: (with_slices parser) (-> (Parser (List Slice)) (Parser Slice)) @@ -87,8 +87,8 @@ (Parser Text) (function (_ [offset tape]) (case (/.char offset tape) - (#.Some output) - (#try.Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]) + {#.Some output} + {#try.Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]} _ (exception.except ..cannot_parse [])))) @@ -97,10 +97,10 @@ (Parser Slice) (function (_ [offset tape]) (case (/.char offset tape) - (#.Some _) - (#try.Success [[("lux i64 +" 1 offset) tape] + {#.Some _} + {#try.Success [[("lux i64 +" 1 offset) tape] [#basis offset - #distance 1]]) + #distance 1]]} _ (exception.except ..cannot_slice [])))) @@ -110,7 +110,7 @@ (All (_ a) (-> (Parser a) (Parser <type>))) (function (_ input) (case (parser input) - (#try.Failure msg) + {#try.Failure msg} (<any> input) _ @@ -128,10 +128,10 @@ (-> Text (Parser Any)) (function (_ [offset tape]) (case (/.index_since offset reference tape) - (#.Some where) + {#.Some where} (if (n.= offset where) - (#try.Success [[("lux i64 +" (/.size reference) offset) tape] - []]) + {#try.Success [[("lux i64 +" (/.size reference) offset) tape] + []]} (exception.except ..cannot_match [reference])) _ @@ -141,15 +141,15 @@ (Parser Any) (function (_ (^@ input [offset tape])) (if (n.= offset (/.size tape)) - (#try.Success [input []]) + {#try.Success [input []]} (exception.except ..unconsumed_input input)))) (def: .public next (Parser Text) (function (_ (^@ input [offset tape])) (case (/.char offset tape) - (#.Some output) - (#try.Success [input (/.of_char output)]) + {#.Some output} + {#try.Success [input (/.of_char output)]} _ (exception.except ..cannot_parse [])))) @@ -157,7 +157,7 @@ (def: .public remaining (Parser Text) (function (_ (^@ input [offset tape])) - (#try.Success [input (..left_over offset tape)]))) + {#try.Success [input (..left_over offset tape)]})) (def: .public (range bottom top) (-> Nat Nat (Parser Text)) @@ -211,10 +211,10 @@ (-> Text (Parser Text)) (function (_ [offset tape]) (case (/.char offset tape) - (#.Some output) + {#.Some output} (let [output' (/.of_char output)] (if (<modifier> (/.contains? output' options)) - (#try.Success [[("lux i64 +" 1 offset) tape] output']) + {#try.Success [[("lux i64 +" 1 offset) tape] output']} (exception.except <exception> [options output]))) _ @@ -229,12 +229,12 @@ (-> Text (Parser Slice)) (function (_ [offset tape]) (case (/.char offset tape) - (#.Some output) + {#.Some output} (let [output' (/.of_char output)] (if (<modifier> (/.contains? output' options)) - (#try.Success [[("lux i64 +" 1 offset) tape] + {#try.Success [[("lux i64 +" 1 offset) tape] [#basis offset - #distance 1]]) + #distance 1]]} (exception.except <exception> [options output]))) _ @@ -252,9 +252,9 @@ (-> (-> Char Bit) (Parser Text)) (function (_ [offset tape]) (case (/.char offset tape) - (#.Some output) + {#.Some output} (if (parser output) - (#try.Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]) + {#try.Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]} (exception.except ..character_does_not_satisfy_predicate [output])) _ @@ -340,11 +340,11 @@ (All (_ a) (-> Text (Parser a) (Parser a))) (function (_ real_input) (case (..result parser local_input) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success value) - (#try.Success [real_input value])))) + {#try.Success value} + {#try.Success [real_input value]}))) (def: .public (slice parser) (-> (Parser Slice) (Parser Text)) @@ -352,8 +352,8 @@ [[basis distance] parser] (function (_ (^@ input [offset tape])) (case (/.clip basis distance tape) - (#.Some output) - (#try.Success [input output]) + {#.Some output} + {#try.Success [input output]} #.None (exception.except ..cannot_slice []))))) diff --git a/stdlib/source/library/lux/control/parser/tree.lux b/stdlib/source/library/lux/control/parser/tree.lux index 7a28812ac..68b4336a5 100644 --- a/stdlib/source/library/lux/control/parser/tree.lux +++ b/stdlib/source/library/lux/control/parser/tree.lux @@ -28,7 +28,7 @@ (def: .public value (All (_ t) (Parser t t)) (function (_ zipper) - (#try.Success [zipper (zipper.value zipper)]))) + {#try.Success [zipper (zipper.value zipper)]})) (exception: .public cannot_move_further) @@ -40,8 +40,8 @@ #.None (exception.except ..cannot_move_further []) - (#.Some next) - (#try.Success [next []]))))] + {#.Some next} + {#try.Success [next []]})))] [down zipper.down] [up zipper.up] diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index c75df1031..4e2414934 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -23,7 +23,7 @@ ["[0]" //]) (template: (|recursion_dummy|) - [(#.Primitive "" #.End)]) + [{#.Primitive "" #.End}]) (template [<name>] [(exception: .public (<name> [type Type]) @@ -74,13 +74,13 @@ (def: (result' env poly types) (All (_ a) (-> Env (Parser a) (List Type) (Try a))) (case (//.result poly [env types]) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success [[env' remaining] output]) + {#try.Success [[env' remaining] output]} (case remaining #.End - (#try.Success output) + {#try.Success output} _ (exception.except ..unconsumed_input remaining)))) @@ -92,17 +92,17 @@ (def: .public env (Parser Env) (.function (_ [env inputs]) - (#try.Success [[env inputs] env]))) + {#try.Success [[env inputs] env]})) (def: (with_env temp poly) (All (_ a) (-> Env (Parser a) (Parser a))) (.function (_ [env inputs]) (case (//.result poly [temp inputs]) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success [[_ remaining] output]) - (#try.Success [[env remaining] output])))) + {#try.Success [[_ remaining] output]} + {#try.Success [[env remaining] output]}))) (def: .public next (Parser Type) @@ -111,8 +111,8 @@ #.End (exception.except ..empty_input []) - (#.Item headT tail) - (#try.Success [[env inputs] headT])))) + {#.Item headT tail} + {#try.Success [[env inputs] headT]}))) (def: .public any (Parser Type) @@ -121,18 +121,18 @@ #.End (exception.except ..empty_input []) - (#.Item headT tail) - (#try.Success [[env tail] headT])))) + {#.Item headT tail} + {#try.Success [[env tail] headT]}))) (def: .public (local types poly) (All (_ a) (-> (List Type) (Parser a) (Parser a))) (.function (_ [env pass_through]) (case (result' env poly types) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success output) - (#try.Success [[env pass_through] output])))) + {#try.Success output} + {#try.Success [[env pass_through] output]}))) (def: (label idx) (-> Nat Code) @@ -146,11 +146,11 @@ (case (//.result poly [(dictionary.has current_id [type g!var] env) inputs]) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success [[_ inputs'] output]) - (#try.Success [[env inputs'] [g!var output]]))))) + {#try.Success [[_ inputs'] output]} + {#try.Success [[env inputs'] [g!var output]]})))) (template [<name> <flattener> <tag> <exception>] [(`` (def: .public (<name> poly) @@ -192,8 +192,8 @@ (recur (++ current_arg) (|> env' (dictionary.has funcI [headT funcL]) - (dictionary.has (++ funcI) [(#.Parameter (++ funcI)) varL])) - (#.Item varL all_varsL))) + (dictionary.has (++ funcI) [{#.Parameter (++ funcI)} varL])) + {#.Item varL all_varsL})) (let [partialI (|> current_arg (n.* 2) (n.+ funcI)) partial_varI (++ partialI) partial_varL (label partial_varI) @@ -203,8 +203,8 @@ (recur (++ current_arg) (|> env' (dictionary.has partialI [(|recursion_dummy|) partialC]) - (dictionary.has partial_varI [(#.Parameter partial_varI) partial_varL])) - (#.Item partial_varL all_varsL)))) + (dictionary.has partial_varI [{#.Parameter partial_varI} partial_varL])) + {#.Item partial_varL all_varsL}))) [all_varsL env']))]] (<| (with_env env') (local (list non_poly)) @@ -229,7 +229,7 @@ .let [[funcT paramsT] (type.flat_application (type.anonymous headT))]] (if (n.= 0 (list.size paramsT)) (//.failure (exception.error ..not_application headT)) - (..local (#.Item funcT paramsT) poly)))) + (..local {#.Item funcT paramsT} poly)))) (template [<name> <test>] [(def: .public (<name> expected) @@ -258,9 +258,9 @@ [env ..env headT any] (case headT - (#.Parameter idx) + {#.Parameter idx} (case (dictionary.value (adjusted_idx env idx) env) - (#.Some [poly_type poly_code]) + {#.Some [poly_type poly_code]} (in poly_code) #.None @@ -275,10 +275,10 @@ [env ..env headT any] (case headT - (#.Parameter idx) + {#.Parameter idx} (if (n.= id (adjusted_idx env idx)) (in []) - (//.failure (exception.error ..wrong_parameter [(#.Parameter id) headT]))) + (//.failure (exception.error ..wrong_parameter [{#.Parameter id} headT]))) _ (//.failure (exception.error ..not_parameter headT))))) @@ -288,7 +288,7 @@ (do //.monad [headT any] (case headT - (#.Ex ex_id) + {#.Ex ex_id} (in ex_id) _ @@ -299,7 +299,7 @@ (do //.monad [inputT any] (case inputT - (#.Named name anonymousT) + {#.Named name anonymousT} (in [name anonymousT]) _ @@ -310,7 +310,7 @@ (do [! //.monad] [headT any] (case (type.anonymous headT) - (^ (#.Apply (|recursion_dummy|) (#.UnivQ _ headT'))) + (^ {#.Apply (|recursion_dummy|) {#.UnivQ _ headT'}}) (do ! [[recT _ output] (|> poly (with_extension (|recursion_dummy|)) @@ -327,9 +327,9 @@ [env ..env headT any] (case (type.anonymous headT) - (^multi (^ (#.Apply (|recursion_dummy|) (#.Parameter funcT_idx))) + (^multi (^ {#.Apply (|recursion_dummy|) {#.Parameter funcT_idx}}) (n.= 0 (adjusted_idx env funcT_idx)) - [(dictionary.value 0 env) (#.Some [self_type self_call])]) + [(dictionary.value 0 env) {#.Some [self_type self_call]}]) (in self_call) _ diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/library/lux/control/parser/xml.lux index a54e68170..6a1eb1206 100644 --- a/stdlib/source/library/lux/control/parser/xml.lux +++ b/stdlib/source/library/lux/control/parser/xml.lux @@ -42,13 +42,13 @@ (def: (result' parser attrs documents) (All (_ a) (-> (Parser a) Attrs (List XML) (Try a))) (case (//.result parser [attrs documents]) - (#try.Success [[attrs' remaining] output]) + {#try.Success [[attrs' remaining] output]} (if (list.empty? remaining) - (#try.Success output) + {#try.Success output} (exception.except ..unconsumed_inputs remaining)) - (#try.Failure error) - (#try.Failure error))) + {#try.Failure error} + {#try.Failure error})) (def: .public (result parser documents) (All (_ a) (-> (Parser a) (List XML) (Try a))) @@ -61,12 +61,12 @@ #.End (exception.except ..empty_input []) - (#.Item head tail) + {#.Item head tail} (case head - (#/.Text value) - (#try.Success [[attrs tail] value]) + {#/.Text value} + {#try.Success [[attrs tail] value]} - (#/.Node _) + {#/.Node _} (exception.except ..unexpected_input []))))) (def: .public tag @@ -76,13 +76,13 @@ #.End (exception.except ..empty_input []) - (#.Item head _) + {#.Item head _} (case head - (#/.Text _) + {#/.Text _} (exception.except ..unexpected_input []) - (#/.Node tag _ _) - (#try.Success [[attrs documents] tag]))))) + {#/.Node tag _ _} + {#try.Success [[attrs documents] tag]})))) (def: .public (attribute name) (-> Attribute (Parser Text)) @@ -91,8 +91,8 @@ #.None (exception.except ..unknown_attribute [name (dictionary.keys attrs)]) - (#.Some value) - (#try.Success [[attrs documents] value])))) + {#.Some value} + {#try.Success [[attrs documents] value]}))) (def: .public (node expected parser) (All (_ a) (-> Tag (Parser a) (Parser a))) @@ -101,12 +101,12 @@ #.End (exception.except ..empty_input []) - (#.Item head tail) + {#.Item head tail} (case head - (#/.Text _) + {#/.Text _} (exception.except ..unexpected_input []) - (#/.Node actual attrs' children) + {#/.Node actual attrs' children} (if (name\= expected actual) (|> children (..result' parser attrs') @@ -120,8 +120,8 @@ #.End (exception.except ..empty_input []) - (#.Item head tail) - (#try.Success [[attrs tail] head])))) + {#.Item head tail} + {#try.Success [[attrs tail] head]}))) (exception: .public nowhere) @@ -129,16 +129,16 @@ (All (_ a) (-> (Parser a) (Parser a))) (function (recur [attrs input]) (case (//.result parser [attrs input]) - (#try.Success [[attrs remaining] output]) - (#try.Success [[attrs remaining] output]) + {#try.Success [[attrs remaining] output]} + {#try.Success [[attrs remaining] output]} - (#try.Failure error) + {#try.Failure error} (case input #.End (exception.except ..nowhere []) - (#.Item head tail) + {#.Item head tail} (do try.monad [[[attrs tail'] output] (recur [attrs tail])] - (in [[attrs (#.Item head tail')] + (in [[attrs {#.Item head tail'}] output])))))) diff --git a/stdlib/source/library/lux/control/pipe.lux b/stdlib/source/library/lux/control/pipe.lux index 9c3c5ce36..2f9c81229 100644 --- a/stdlib/source/library/lux/control/pipe.lux +++ b/stdlib/source/library/lux/control/pipe.lux @@ -37,7 +37,7 @@ (def: _reversed_ (Parser Any) (function (_ tokens) - (#try.Success [(list.reversed tokens) []]))) + {#try.Success [(list.reversed tokens) []]})) (syntax: .public (cond> [_ _reversed_ prev <code>.any diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index 58f406e3a..934daf578 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -35,20 +35,20 @@ output (Try a)]) (format error (case output - (#try.Success _) + {#try.Success _} "" - (#try.Failure error|output) + {#try.Failure error|output} (format separator error|output)))) (def: (clean clean_up output) (All (_ a) (-> (Try Any) (Try a) (Try a))) (case clean_up - (#try.Success _) + {#try.Success _} output - (#try.Failure error) + {#try.Failure error} (exception.except ..clean_up_error [error output]))) (def: .public (run! monad computation) @@ -65,9 +65,9 @@ (All (_ ! a) (-> (Monad !) (-> a (! (Try Any))) a (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) - (\ monad in [(#.Item (function (_ region) (cleaner value)) - cleaners) - (#try.Success value)]))) + (\ monad in [{#.Item (function (_ region) (cleaner value)) + cleaners} + {#try.Success value}]))) (implementation: .public (functor super) (All (_ !) @@ -80,11 +80,11 @@ (\ super each (function (_ [cleaners' temp]) [cleaners' (case temp - (#try.Success value) - (#try.Success (f value)) + {#try.Success value} + {#try.Success (f value)} - (#try.Failure error) - (#try.Failure error))]) + {#try.Failure error} + {#try.Failure error})]) (fa region+cleaners)))))) (implementation: .public (apply super) @@ -101,16 +101,16 @@ [[cleaners ef] (ff [region cleaners]) [cleaners ea] (fa [region cleaners])] (case ef - (#try.Success f) + {#try.Success f} (case ea - (#try.Success a) - (in [cleaners (#try.Success (f a))]) + {#try.Success a} + (in [cleaners {#try.Success (f a)}]) - (#try.Failure error) - (in [cleaners (#try.Failure error)])) + {#try.Failure error} + (in [cleaners {#try.Failure error}])) - (#try.Failure error) - (in [cleaners (#try.Failure error)])))))) + {#try.Failure error} + (in [cleaners {#try.Failure error}])))))) (implementation: .public (monad super) (All (_ !) @@ -122,25 +122,25 @@ (def: (in value) (function (_ [region cleaners]) - (\ super in [cleaners (#try.Success value)]))) + (\ super in [cleaners {#try.Success value}]))) (def: (conjoint ffa) (function (_ [region cleaners]) (do super [[cleaners efa] (ffa [region cleaners])] (case efa - (#try.Success fa) + {#try.Success fa} (fa [region cleaners]) - (#try.Failure error) - (in [cleaners (#try.Failure error)])))))) + {#try.Failure error} + (in [cleaners {#try.Failure error}])))))) (def: .public (failure monad error) (All (_ ! a) (-> (Monad !) Text (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) - (\ monad in [cleaners (#try.Failure error)]))) + (\ monad in [cleaners {#try.Failure error}]))) (def: .public (except monad exception message) (All (_ ! e a) @@ -154,5 +154,5 @@ (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) (\ monad each - (|>> #try.Success [cleaners]) + (|>> {#try.Success} [cleaners]) operation))) diff --git a/stdlib/source/library/lux/control/remember.lux b/stdlib/source/library/lux/control/remember.lux index b2db48900..dcf7c1c8b 100644 --- a/stdlib/source/library/lux/control/remember.lux +++ b/stdlib/source/library/lux/control/remember.lux @@ -30,7 +30,7 @@ ["Today" (%.date today)] ["Message" message] ["Code" (case focus - (#.Some focus) + {#.Some focus} (%.code focus) #.None @@ -44,10 +44,10 @@ (do <>.monad [raw <c>.text] (case (\ date.codec decoded raw) - (#try.Success date) + {#try.Success date} (in date) - (#try.Failure message) + {#try.Failure message} (<>.failure message))))) (syntax: .public (remember [deadline ..deadline @@ -57,7 +57,7 @@ today (instant.date now)] (if (date\< deadline today) (in (case focus - (#.Some focus) + {#.Some focus} (list focus) #.None @@ -71,7 +71,7 @@ (in (list (` (..remember (~ (code.text (%.date deadline))) (~ (code.text (format <message> " " message))) (~+ (case focus - (#.Some focus) + {#.Some focus} (list focus) #.None diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 16d58007c..b18a38dd8 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -11,19 +11,19 @@ (type: .public (Try a) (Variant - (#Failure Text) - (#Success a))) + {#Failure Text} + {#Success a})) (implementation: .public functor (Functor Try) (def: (each f ma) (case ma - (#Failure msg) - (#Failure msg) + {#Failure msg} + {#Failure msg} - (#Success datum) - (#Success (f datum))))) + {#Success datum} + {#Success (f datum)}))) (implementation: .public apply (Apply Try) @@ -32,16 +32,16 @@ (def: (on fa ff) (case ff - (#Success f) + {#Success f} (case fa - (#Success a) - (#Success (f a)) + {#Success a} + {#Success (f a)} - (#Failure msg) - (#Failure msg)) + {#Failure msg} + {#Failure msg}) - (#Failure msg) - (#Failure msg)))) + {#Failure msg} + {#Failure msg}))) (implementation: .public monad (Monad Try) @@ -49,14 +49,14 @@ (def: &functor ..functor) (def: (in a) - (#Success a)) + {#Success a}) (def: (conjoint mma) (case mma - (#Failure msg) - (#Failure msg) + {#Failure msg} + {#Failure msg} - (#Success ma) + {#Success ma} ma))) (implementation: .public (with monad) @@ -74,10 +74,10 @@ (do monad [eMea MeMea] (case eMea - (#Failure try) - (in (#Failure try)) + {#Failure try} + (in {#Failure try}) - (#Success Mea) + {#Success Mea} Mea)))) (def: .public (lifted monad) @@ -89,10 +89,10 @@ (def: (= reference sample) (case [reference sample] - [(#Success reference) (#Success sample)] + [{#Success reference} {#Success sample}] (_\= reference sample) - [(#Failure reference) (#Failure sample)] + [{#Failure reference} {#Failure sample}] ("lux text =" reference sample) _ @@ -103,42 +103,42 @@ (All (_ a) (-> (Try a) a)) (case try - (#Success value) + {#Success value} value - (#Failure message) + {#Failure message} (panic! message))) (def: .public (maybe try) (All (_ a) (-> (Try a) (Maybe a))) (case try - (#Success value) - (#.Some value) + {#Success value} + {#.Some value} - (#Failure message) + {#Failure message} #.None)) (def: .public (of_maybe maybe) (All (_ a) (-> (Maybe a) (Try a))) (case maybe - (#.Some value) - (#Success value) + {#.Some value} + {#Success value} #.None - (#Failure (`` (("lux in-module" (~~ (static .prelude_module)) .name\encoded) - (name_of ..of_maybe)))))) + {#Failure (`` (("lux in-module" (~~ (static .prelude_module)) .name\encoded) + (name_of ..of_maybe)))})) (macro: .public (else tokens compiler) (case tokens (^ (list else try)) - (#Success [compiler (list (` (case (~ try) - (#..Success (~' g!temp)) + {#Success [compiler (list (` (case (~ try) + {#..Success (~' g!temp)} (~' g!temp) - (#..Failure (~ [location.dummy (#.Identifier ["" ""])])) - (~ else))))]) + {#..Failure (~ [location.dummy {#.Identifier ["" ""]}])} + (~ else))))]} _ - (#Failure "Wrong syntax for else"))) + {#Failure "Wrong syntax for else"})) diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index 0805da036..6d824d2eb 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -63,7 +63,11 @@ (def: (conjoint MlMla) (do monad [[l1 Mla] (for [@.old - (: ((:parameter 1) (Writer (:parameter 0) ((:parameter 1) (Writer (:parameter 0) (:parameter 2))))) + (: {#.Apply (Writer (:parameter 0) + {#.Apply (Writer (:parameter 0) + (:parameter 2)) + (:parameter 1)}) + (:parameter 1)} MlMla)] ... On new compiler MlMla) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index 33bac997b..e4a07b788 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -198,31 +198,31 @@ (def: .public (read/8! index binary) (-> Nat Binary (Try I64)) (if (n.< (..!size binary) index) - (#try.Success (!read index binary)) + {#try.Success (!read index binary)} (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (read/16! index binary) (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 1 index)) - (#try.Success ($_ i64.or + {#try.Success ($_ i64.or (i64.left_shifted 8 (!read index binary)) - (!read (n.+ 1 index) binary))) + (!read (n.+ 1 index) binary))} (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (read/32! index binary) (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 3 index)) - (#try.Success ($_ i64.or + {#try.Success ($_ i64.or (i64.left_shifted 24 (!read index binary)) (i64.left_shifted 16 (!read (n.+ 1 index) binary)) (i64.left_shifted 8 (!read (n.+ 2 index) binary)) - (!read (n.+ 3 index) binary))) + (!read (n.+ 3 index) binary))} (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (read/64! index binary) (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 7 index)) - (#try.Success ($_ i64.or + {#try.Success ($_ i64.or (i64.left_shifted 56 (!read index binary)) (i64.left_shifted 48 (!read (n.+ 1 index) binary)) (i64.left_shifted 40 (!read (n.+ 2 index) binary)) @@ -230,32 +230,32 @@ (i64.left_shifted 24 (!read (n.+ 4 index) binary)) (i64.left_shifted 16 (!read (n.+ 5 index) binary)) (i64.left_shifted 8 (!read (n.+ 6 index) binary)) - (!read (n.+ 7 index) binary))) + (!read (n.+ 7 index) binary))} (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (write/8! index value binary) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) index) - (#try.Success (|> binary - (!write index value))) + {#try.Success (|> binary + (!write index value))} (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (write/16! index value binary) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 1 index)) - (#try.Success (|> binary + {#try.Success (|> binary (!write index (i64.right_shifted 8 value)) - (!write (n.+ 1 index) value))) + (!write (n.+ 1 index) value))} (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (write/32! index value binary) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 3 index)) - (#try.Success (|> binary + {#try.Success (|> binary (!write index (i64.right_shifted 24 value)) (!write (n.+ 1 index) (i64.right_shifted 16 value)) (!write (n.+ 2 index) (i64.right_shifted 8 value)) - (!write (n.+ 3 index) value))) + (!write (n.+ 3 index) value))} (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (write/64! index value binary) @@ -270,7 +270,7 @@ (!write (n.+ 6 index) (i64.right_shifted 8 value)) (!write (n.+ 7 index) value))] (|> binary write_high write_low #try.Success))] - (#try.Success (|> binary + {#try.Success (|> binary (!write index (i64.right_shifted 56 value)) (!write (n.+ 1 index) (i64.right_shifted 48 value)) (!write (n.+ 2 index) (i64.right_shifted 40 value)) @@ -278,7 +278,7 @@ (!write (n.+ 4 index) (i64.right_shifted 24 value)) (!write (n.+ 5 index) (i64.right_shifted 16 value)) (!write (n.+ 6 index) (i64.right_shifted 8 value)) - (!write (n.+ 7 index) value)))) + (!write (n.+ 7 index) value))}) (exception.except ..index_out_of_bounds [(..!size binary) index]))) (implementation: .public equivalence @@ -329,7 +329,7 @@ (!read (n.+ source_offset index) source) target) (recur (++ index))) - (#try.Success target)))))))) + {#try.Success target}))))))) (def: .public (slice offset length binary) (-> Nat Nat Binary (Try Binary)) @@ -337,7 +337,7 @@ limit (n.+ length offset)] (if (n.> size limit) (exception.except ..slice_out_of_bounds [size offset length]) - (with_expansions [<jvm> (as_is (#try.Success (java/util/Arrays::copyOfRange binary (.int offset) (.int limit))))] + (with_expansions [<jvm> (as_is {#try.Success (java/util/Arrays::copyOfRange binary (.int offset) (.int limit))})] (for [@.old <jvm> @.jvm <jvm>] @@ -350,10 +350,10 @@ 0 binary _ (let [distance (n.- bytes (..!size binary))] (case (..slice bytes distance binary) - (#try.Success slice) + {#try.Success slice} slice - (#try.Failure _) + {#try.Failure _} (..empty 0))))) (implementation: .public monoid diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux index b1926e164..d78777213 100644 --- a/stdlib/source/library/lux/data/bit.lux +++ b/stdlib/source/library/lux/data/bit.lux @@ -56,9 +56,9 @@ (def: (decoded input) (case input - "#1" (#.Right #1) - "#0" (#.Right #0) - _ (#.Left "Wrong syntax for Bit.")))) + "#1" {#.Right #1} + "#0" {#.Right #0} + _ {#.Left "Wrong syntax for Bit."}))) (def: .public complement (All (_ a) (-> (-> a Bit) (-> a Bit))) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 0bd99245d..31cfc865b 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -22,7 +22,7 @@ "#Array") (type: .public (Array a) - (#.Primitive ..type_name (#.Item a #.End))) + {#.Primitive ..type_name {#.Item a #.End}}) (with_expansions [<index_type> (primitive "java.lang.Long") <elem_type> (primitive "java.lang.Object") @@ -79,7 +79,7 @@ [(let [output (<read!> index array)] (if (<null?> output) #.None - (#.Some output)))]) + {#.Some output}))]) (def: .public (read! index array) (All (_ a) @@ -89,7 +89,7 @@ (let [value ("jvm aaload" array index)] (if ("jvm object null?" value) #.None - (#.Some value))) + {#.Some value})) @.jvm (let [value (|> array @@ -97,7 +97,7 @@ ("jvm array read object" (!int index)))] (if ("jvm object null?" value) #.None - (#.Some (:expected value)))) + {#.Some (:expected value)})) @.js (!read! "js array read" "js object undefined?") @.python (!read! "python array read" "python object none?") @@ -149,7 +149,7 @@ (All (_ a) (-> Nat (Array a) Bit)) (case (..read! index array) - (#.Some _) + {#.Some _} true _ @@ -162,7 +162,7 @@ #.None array - (#.Some value) + {#.Some value} (write! index (transform value) array))) (def: .public (upsert! index default transform array) @@ -183,7 +183,7 @@ #.None target - (#.Some value) + {#.Some value} (write! (n.+ offset dest_start) value target))) dest_array (list.indices length)))) @@ -195,7 +195,7 @@ #.None count - (#.Some _) + {#.Some _} (++ count))) 0 (list.indices (size array)))) @@ -212,7 +212,7 @@ #.None xs' - (#.Some x) + {#.Some x} (if (p x) xs' (delete! idx xs')))) @@ -229,9 +229,9 @@ #.None (recur (++ idx)) - (#.Some x) + {#.Some x} (if (p x) - (#.Some x) + {#.Some x} (recur (++ idx)))) #.None)))) @@ -245,9 +245,9 @@ #.None (recur (++ idx)) - (#.Some x) + {#.Some x} (if (p idx x) - (#.Some [idx x]) + {#.Some [idx x]} (recur (++ idx)))) #.None)))) @@ -259,7 +259,7 @@ #.None ys - (#.Some x) + {#.Some x} (write! idx x ys))) (empty arr_size) (list.indices arr_size)))) @@ -286,8 +286,8 @@ _ (recur (-- idx) (case (read! idx array) - (#.Some head) - (#.Item head output) + {#.Some head} + {#.Item head output} #.None output))))) @@ -302,13 +302,13 @@ _ (recur (-- idx) - (#.Item (maybe.else default (read! idx array)) - output))))) + {#.Item (maybe.else default (read! idx array)) + output})))) (def: .public (list default array) (All (_ a) (-> (Maybe a) (Array a) (List a))) (case default - (#.Some default) + {#.Some default} (list|+default default array) #.None @@ -327,7 +327,7 @@ [#.None #.None] true - [(#.Some x) (#.Some y)] + [{#.Some x} {#.Some y}] (,\= x y) _ @@ -359,7 +359,7 @@ #.None mb - (#.Some x) + {#.Some x} (write! idx (f x) mb))) (empty arr_size) (list.indices arr_size)) @@ -377,7 +377,7 @@ #.None (recur so_far (++ idx)) - (#.Some value) + {#.Some value} (recur (f value so_far) (++ idx))) so_far))))) @@ -390,7 +390,7 @@ (loop [idx 0] (if (n.< size idx) (case (..read! idx array) - (#.Some value) + {#.Some value} (<op> (predicate value) (recur (++ idx))) diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index 3d7e785f3..bc78d8032 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -58,11 +58,11 @@ ... Dictionaries. (type: (Node k v) (Variant - (#Hierarchy Nat (Array (Node k v))) - (#Base Bit_Map - (Array (Either (Node k v) - [k v]))) - (#Collisions Hash_Code (Array [k v])))) + {#Hierarchy Nat (Array (Node k v))} + {#Base Bit_Map + (Array (Either (Node k v) + [k v]))} + {#Collisions Hash_Code (Array [k v])})) ... #Hierarchy nodes are meant to point down only to lower-level nodes. (type: (Hierarchy k v) @@ -127,7 +127,7 @@ ... The cannonical empty node, which is just an empty #Base node. (def: empty_node Node - (#Base clean_bitmap (array.empty 0))) + {#Base clean_bitmap (array.empty 0)}) ... Expands a copy of the array, to have 1 extra slot, which is used ... for storing the value. @@ -241,11 +241,11 @@ (let [[bitmap base] node] (case (array.read! idx h_array) #.None [insertion_idx node] - (#.Some sub_node) (if (n.= except_idx idx) + {#.Some sub_node} (if (n.= except_idx idx) [insertion_idx node] [(++ insertion_idx) [(with_bit_position (to_bit_position idx) bitmap) - (array.write! insertion_idx (#.Left sub_node) base)]]) + (array.write! insertion_idx {#.Left sub_node} base)]]) ))) [0 [clean_bitmap (array.empty (-- h_size))]] @@ -268,10 +268,10 @@ bitmap) [(++ base_idx) (case (array.read! base_idx base) - (#.Some (#.Left sub_node)) + {#.Some {#.Left sub_node}} (array.write! hierarchy_idx sub_node h_array) - (#.Some (#.Right [key' val'])) + {#.Some {#.Right [key' val']}} (array.write! hierarchy_idx (node\has (level_up level) (\ key_hash hash key') key' val' key_hash empty_node) h_array) @@ -289,7 +289,7 @@ (def: (node\empty? node) (All (_ k v) (-> (Node k v) Bit)) (`` (case node - (#Base (~~ (static ..clean_bitmap)) _) + {#Base (~~ (static ..clean_bitmap)) _} #1 _ @@ -300,47 +300,47 @@ (case node ... For #Hierarchy nodes, check whether one can add the element to ... a sub-node. If impossible, introduce a new singleton sub-node. - (#Hierarchy _size hierarchy) + {#Hierarchy _size hierarchy} (let [idx (level_index level hash) [_size' sub_node] (case (array.read! idx hierarchy) - (#.Some sub_node) + {#.Some sub_node} [_size sub_node] _ [(++ _size) empty_node])] - (#Hierarchy _size' - (array\revised idx (node\has (level_up level) hash key val key_hash sub_node) - hierarchy))) + {#Hierarchy _size' + (array\revised idx (node\has (level_up level) hash key val key_hash sub_node) + hierarchy)}) ... For #Base nodes, check if the corresponding Bit_Position has ... already been used. - (#Base bitmap base) + {#Base bitmap base} (let [bit (level_bit_position level hash)] (if (with_bit_position? bit bitmap) ... If so... (let [idx (base_index bit bitmap)] (case (array.read! idx base) ... If it's being used by a node, add the KV to it. - (#.Some (#.Left sub_node)) + {#.Some {#.Left sub_node}} (let [sub_node' (node\has (level_up level) hash key val key_hash sub_node)] - (#Base bitmap (array\revised idx (#.Left sub_node') base))) + {#Base bitmap (array\revised idx {#.Left sub_node'} base)}) ... Otherwise, if it's being used by a KV, compare the keys. - (#.Some (#.Right key' val')) + {#.Some {#.Right key' val'}} (if (\ key_hash = key key') ... If the same key is found, replace the value. - (#Base bitmap (array\revised idx (#.Right key val) base)) + {#Base bitmap (array\revised idx {#.Right key val} base)} ... Otherwise, compare the hashes of the keys. - (#Base bitmap (array\revised idx - (#.Left (let [hash' (\ key_hash hash key')] + {#Base bitmap (array\revised idx + {#.Left (let [hash' (\ key_hash hash key')] (if (n.= hash hash') ... If the hashes are ... the same, a new ... #Collisions node ... is added. - (#Collisions hash (|> (array.empty 2) + {#Collisions hash (|> (array.empty 2) (array.write! 0 [key' val']) - (array.write! 1 [key val]))) + (array.write! 1 [key val]))} ... Otherwise, one can ... just keep using ... #Base nodes, so @@ -349,8 +349,8 @@ (let [next_level (level_up level)] (|> empty_node (node\has next_level hash' key' val' key_hash) - (node\has next_level hash key val key_hash)))))) - base))) + (node\has next_level hash key val key_hash)))))} + base)}) #.None (undefined))) @@ -360,35 +360,35 @@ (if (n.< ..promotion_threshold base_count) ... If so, resize the #Base node to accommodate the ... new KV-pair. - (#Base (with_bit_position bit bitmap) - (array\has (base_index bit bitmap) (#.Right [key val]) base)) + {#Base (with_bit_position bit bitmap) + (array\has (base_index bit bitmap) {#.Right [key val]} base)} ... Otherwise, promote it to a #Hierarchy node, and add the new ... KV-pair as a singleton node to it. - (#Hierarchy (++ base_count) - (|> base - (promotion node\has key_hash level bitmap) - (array.write! (level_index level hash) - (node\has (level_up level) hash key val key_hash empty_node)))))))) + {#Hierarchy (++ base_count) + (|> base + (promotion node\has key_hash level bitmap) + (array.write! (level_index level hash) + (node\has (level_up level) hash key val key_hash empty_node)))})))) ... For #Collisions nodes, compare the hashes. - (#Collisions _hash _colls) + {#Collisions _hash _colls} (if (n.= hash _hash) ... If they're equal, that means the new KV contributes to the ... collisions. (case (collision_index key_hash key _colls) ... If the key was already present in the collisions-list, its ... value gets updated. - (#.Some coll_idx) - (#Collisions _hash (array\revised coll_idx [key val] _colls)) + {#.Some coll_idx} + {#Collisions _hash (array\revised coll_idx [key val] _colls)} ... Otherwise, the KV-pair is added to the collisions-list. #.None - (#Collisions _hash (array\has (array.size _colls) [key val] _colls))) + {#Collisions _hash (array\has (array.size _colls) [key val] _colls)}) ... If the hashes are not equal, create a new #Base node that ... contains the old #Collisions node, plus the new KV-pair. - (|> (#Base (level_bit_position level _hash) - (|> (array.empty 1) - (array.write! 0 (#.Left node)))) + (|> {#Base (level_bit_position level _hash) + (|> (array.empty 1) + (array.write! 0 {#.Left node}))} (node\has level hash key val key_hash))) )) @@ -397,7 +397,7 @@ (case node ... For #Hierarchy nodes, find out if there's a valid sub-node for ... the Hash-Code. - (#Hierarchy h_size h_array) + {#Hierarchy h_size h_array} (let [idx (level_index level hash)] (case (array.read! idx h_array) ... If not, there's nothing to remove. @@ -405,7 +405,7 @@ node ... But if there is, try to remove the key from the sub-node. - (#.Some sub_node) + {#.Some sub_node} (let [sub_node' (node\lacks (level_up level) hash key key_hash sub_node)] ... Then check if a removal was actually done. (if (same? sub_node sub_node') @@ -416,22 +416,22 @@ ... Check if it's due time for a demotion. (if (n.> demotion_threshold h_size) ... If so, just clear the space. - (#Hierarchy (-- h_size) (array\clear idx h_array)) + {#Hierarchy (-- h_size) (array\clear idx h_array)} ... Otherwise, perform it. - (#Base (demotion idx [h_size h_array]))) + {#Base (demotion idx [h_size h_array])}) ... But if the sub_removal yielded a non_empty node, then ... just update the hiearchy branch. - (#Hierarchy h_size (array\revised idx sub_node' h_array))))))) + {#Hierarchy h_size (array\revised idx sub_node' h_array)}))))) ... For #Base nodes, check whether the Bit_Position is set. - (#Base bitmap base) + {#Base bitmap base} (let [bit (level_bit_position level hash)] (if (with_bit_position? bit bitmap) (let [idx (base_index bit bitmap)] (case (array.read! idx base) ... If set, check if it's a sub_node, and remove the KV ... from it. - (#.Some (#.Left sub_node)) + {#.Some {#.Left sub_node}} (let [sub_node' (node\lacks (level_up level) hash key key_hash sub_node)] ... Verify that it was removed. (if (same? sub_node sub_node') @@ -445,20 +445,20 @@ empty_node ... But if not, then just unset the position and ... remove the node. - (#Base (without_bit_position bit bitmap) - (array\lacks idx base))) + {#Base (without_bit_position bit bitmap) + (array\lacks idx base)}) ... But, if it did not come out empty, then the ... position is kept, and the node gets updated. - (#Base bitmap - (array\revised idx (#.Left sub_node') base))))) + {#Base bitmap + (array\revised idx {#.Left sub_node'} base)}))) ... If, however, there was a KV-pair instead of a sub-node. - (#.Some (#.Right [key' val'])) + {#.Some {#.Right [key' val']}} ... Check if the keys match. (if (\ key_hash = key key') ... If so, remove the KV-pair and unset the Bit_Position. - (#Base (without_bit_position bit bitmap) - (array\lacks idx base)) + {#Base (without_bit_position bit bitmap) + (array\lacks idx base)} ... Otherwise, there's nothing to remove. node) @@ -468,42 +468,42 @@ node)) ... For #Collisions nodes, It need to find out if the key already existst. - (#Collisions _hash _colls) + {#Collisions _hash _colls} (case (collision_index key_hash key _colls) ... If not, then there's nothing to remove. #.None node ... But if so, then check the size of the collisions list. - (#.Some idx) + {#.Some idx} (if (n.= 1 (array.size _colls)) ... If there's only one left, then removing it leaves us with ... an empty node. empty_node ... Otherwise, just shrink the array by removing the KV-pair. - (#Collisions _hash (array\lacks idx _colls)))) + {#Collisions _hash (array\lacks idx _colls)})) )) (def: (node\value level hash key key_hash node) (All (_ k v) (-> Level Hash_Code k (Hash k) (Node k v) (Maybe v))) (case node ... For #Hierarchy nodes, just look-up the key on its children. - (#Hierarchy _size hierarchy) + {#Hierarchy _size hierarchy} (case (array.read! (level_index level hash) hierarchy) #.None #.None - (#.Some sub_node) (node\value (level_up level) hash key key_hash sub_node)) + {#.Some sub_node} (node\value (level_up level) hash key key_hash sub_node)) ... For #Base nodes, check the leaves, and recursively check the branches. - (#Base bitmap base) + {#Base bitmap base} (let [bit (level_bit_position level hash)] (if (with_bit_position? bit bitmap) (case (array.read! (base_index bit bitmap) base) - (#.Some (#.Left sub_node)) + {#.Some {#.Left sub_node}} (node\value (level_up level) hash key key_hash sub_node) - (#.Some (#.Right [key' val'])) + {#.Some {#.Right [key' val']}} (if (\ key_hash = key key') - (#.Some val') + {#.Some val'} #.None) #.None @@ -511,7 +511,7 @@ #.None)) ... For #Collisions nodes, do a linear scan of all the known KV-pairs. - (#Collisions _hash _colls) + {#Collisions _hash _colls} (\ maybe.monad each product.right (array.example (|>> product.left (\ key_hash = key)) _colls)) @@ -520,41 +520,41 @@ (def: (node\size node) (All (_ k v) (-> (Node k v) Nat)) (case node - (#Hierarchy _size hierarchy) + {#Hierarchy _size hierarchy} (array\mix n.+ 0 (array\each node\size hierarchy)) - (#Base _ base) + {#Base _ base} (array\mix n.+ 0 (array\each (function (_ sub_node') (case sub_node' - (#.Left sub_node) (node\size sub_node) - (#.Right _) 1)) + {#.Left sub_node} (node\size sub_node) + {#.Right _} 1)) base)) - (#Collisions hash colls) + {#Collisions hash colls} (array.size colls) )) (def: (node\entries node) (All (_ k v) (-> (Node k v) (List [k v]))) (case node - (#Hierarchy _size hierarchy) + {#Hierarchy _size hierarchy} (array\mix (function (_ sub_node tail) (list\composite (node\entries sub_node) tail)) #.End hierarchy) - (#Base bitmap base) + {#Base bitmap base} (array\mix (function (_ branch tail) (case branch - (#.Left sub_node) + {#.Left sub_node} (list\composite (node\entries sub_node) tail) - (#.Right [key' val']) - (#.Item [key' val'] tail))) + {#.Right [key' val']} + {#.Item [key' val'] tail})) #.End base) - (#Collisions hash colls) - (array\mix (function (_ [key' val'] tail) (#.Item [key' val'] tail)) + {#Collisions hash colls} + (array\mix (function (_ [key' val'] tail) {#.Item [key' val'] tail}) #.End colls))) @@ -591,15 +591,15 @@ (All (_ k v) (-> (Dictionary k v) k Bit)) (case (value key dict) #.None #0 - (#.Some _) #1)) + {#.Some _} #1)) (exception: .public key_already_exists) (def: .public (has' key val dict) (All (_ k v) (-> k v (Dictionary k v) (Try (Dictionary k v)))) (case (value key dict) - #.None (#try.Success (has key val dict)) - (#.Some _) (exception.except ..key_already_exists []))) + #.None {#try.Success (has key val dict)} + {#.Some _} (exception.except ..key_already_exists []))) (def: .public (revised key f dict) (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) @@ -607,7 +607,7 @@ #.None dict - (#.Some val) + {#.Some val} (has key (f val) dict))) (def: .public (revised' key default f dict) @@ -641,7 +641,7 @@ (All (_ k v) (-> (Dictionary k v) (List <side>))) (|>> ..entries (list\mix (function (_ [k v] bundle) - (#.Item <side> bundle)) + {#.Item <side> bundle}) #.End)))] [k keys] @@ -661,7 +661,7 @@ #.None (has key val2 dict) - (#.Some val1) + {#.Some val1} (has key (f val2 val1) dict))) dict1 (entries dict2))) @@ -672,7 +672,7 @@ #.None dict - (#.Some val) + {#.Some val} (|> dict (lacks from_key) (has to_key val)))) @@ -683,7 +683,7 @@ (list\mix (function (_ key new_dict) (case (value key dict) #.None new_dict - (#.Some val) (has key val new_dict))) + {#.Some val} (has key val new_dict))) (empty key_hash) keys))) @@ -695,7 +695,7 @@ (..size subject)) (list.every? (function (_ [k rv]) (case (..value k subject) - (#.Some sv) + {#.Some sv} (,\= rv sv) _ @@ -707,23 +707,23 @@ (def: (each f fa) (case fa - (#Hierarchy size hierarchy) - (#Hierarchy size (array\each (each f) hierarchy)) + {#Hierarchy size hierarchy} + {#Hierarchy size (array\each (each f) hierarchy)} - (#Base bitmap base) - (#Base bitmap (array\each (function (_ either) + {#Base bitmap base} + {#Base bitmap (array\each (function (_ either) (case either - (#.Left fa') - (#.Left (each f fa')) + {#.Left fa'} + {#.Left (each f fa')} - (#.Right [k v]) - (#.Right [k (f v)]))) - base)) + {#.Right [k v]} + {#.Right [k (f v)]})) + base)} - (#Collisions hash collisions) - (#Collisions hash (array\each (function (_ [k v]) + {#Collisions hash collisions} + {#Collisions hash (array\each (function (_ [k v]) [k (f v)]) - collisions))))) + collisions)}))) (implementation: .public functor (All (_ k) (Functor (Dictionary k))) diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index 857683d40..d6376e88b 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -65,11 +65,11 @@ #.None #.None - (#.Some node) + {#.Some node} (let [node_key (value@ #key node)] (cond (\ dict = node_key key) ... (_\= node_key key) - (#.Some (value@ #value node)) + {#.Some (value@ #value node)} (\ dict < node_key key) ... (_\< node_key key) @@ -90,7 +90,7 @@ #.None #0 - (#.Some node) + {#.Some node} (let [node_key (value@ #key node)] (or (\ dict = node_key key) ... (_\= node_key key) @@ -106,13 +106,13 @@ #.None #.None - (#.Some node) + {#.Some node} (loop [node node] (case (value@ <side> node) #.None - (#.Some (value@ #value node)) + {#.Some (value@ #value node)} - (#.Some side) + {#.Some side} (recur side)))))] [min #left] @@ -126,7 +126,7 @@ #.None 0 - (#.Some node) + {#.Some node} (++ (n.+ (recur (value@ #left node)) (recur (value@ #right node))))))) @@ -155,42 +155,42 @@ #Red (red (value@ #key center) (value@ #value center) - (#.Some addition) + {#.Some addition} (value@ #right center)) #Black (with_expansions [<default_behavior> (as_is (black (value@ #key center) (value@ #value center) - (#.Some addition) + {#.Some addition} (value@ #right center)))] (case (value@ #color addition) #Red (case (value@ #left addition) - (^multi (#.Some left) + (^multi {#.Some left} [(value@ #color left) #Red]) (red (value@ #key addition) (value@ #value addition) - (#.Some (blackened left)) - (#.Some (black (value@ #key center) + {#.Some (blackened left)} + {#.Some (black (value@ #key center) (value@ #value center) (value@ #right addition) - (value@ #right center)))) + (value@ #right center))}) _ (case (value@ #right addition) - (^multi (#.Some right) + (^multi {#.Some right} [(value@ #color right) #Red]) (red (value@ #key right) (value@ #value right) - (#.Some (black (value@ #key addition) + {#.Some (black (value@ #key addition) (value@ #value addition) (value@ #left addition) - (value@ #left right))) - (#.Some (black (value@ #key center) + (value@ #left right))} + {#.Some (black (value@ #key center) (value@ #value center) (value@ #right right) - (value@ #right center)))) + (value@ #right center))}) _ <default_behavior>)) @@ -205,41 +205,41 @@ (red (value@ #key center) (value@ #value center) (value@ #left center) - (#.Some addition)) + {#.Some addition}) #Black (with_expansions [<default_behavior> (as_is (black (value@ #key center) (value@ #value center) (value@ #left center) - (#.Some addition)))] + {#.Some addition}))] (case (value@ #color addition) #Red (case (value@ #right addition) - (^multi (#.Some right) + (^multi {#.Some right} [(value@ #color right) #Red]) (red (value@ #key addition) (value@ #value addition) - (#.Some (black (value@ #key center) + {#.Some (black (value@ #key center) (value@ #value center) (value@ #left center) - (value@ #left addition))) - (#.Some (blackened right))) + (value@ #left addition))} + {#.Some (blackened right)}) _ (case (value@ #left addition) - (^multi (#.Some left) + (^multi {#.Some left} [(value@ #color left) #Red]) (red (value@ #key left) (value@ #value left) - (#.Some (black (value@ #key center) + {#.Some (black (value@ #key center) (value@ #value center) (value@ #left center) - (value@ #left left))) - (#.Some (black (value@ #key addition) + (value@ #left left))} + {#.Some (black (value@ #key addition) (value@ #value addition) (value@ #right left) - (value@ #right addition)))) + (value@ #right addition))}) _ <default_behavior>)) @@ -253,9 +253,9 @@ root' (loop [?root (value@ #root dict)] (case ?root #.None - (#.Some (red key value #.None #.None)) + {#.Some (red key value #.None #.None)} - (#.Some root) + {#.Some root} (let [reference (value@ #key root)] (`` (cond (~~ (template [<comp> <tag> <add>] [(<comp> reference key) @@ -263,15 +263,15 @@ outcome (recur side_root)] (if (same? side_root outcome) ?root - (#.Some (<add> (maybe.trusted outcome) - root))))] + {#.Some (<add> (maybe.trusted outcome) + root)}))] [_\< #left ..with_left] [(order.> (value@ #&order dict)) #right ..with_right] )) ... (_\= reference key) - (#.Some (with@ #value value root)) + {#.Some (with@ #value value root)} ))) ))] (with@ #root root' dict))) @@ -279,28 +279,28 @@ (def: (left_balanced key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left - (^multi (#.Some left) + (^multi {#.Some left} [(value@ #color left) #Red] - [(value@ #left left) (#.Some left>>left)] + [(value@ #left left) {#.Some left>>left}] [(value@ #color left>>left) #Red]) (red (value@ #key left) (value@ #value left) - (#.Some (blackened left>>left)) - (#.Some (black key value (value@ #right left) ?right))) + {#.Some (blackened left>>left)} + {#.Some (black key value (value@ #right left) ?right)}) - (^multi (#.Some left) + (^multi {#.Some left} [(value@ #color left) #Red] - [(value@ #right left) (#.Some left>>right)] + [(value@ #right left) {#.Some left>>right}] [(value@ #color left>>right) #Red]) (red (value@ #key left>>right) (value@ #value left>>right) - (#.Some (black (value@ #key left) + {#.Some (black (value@ #key left) (value@ #value left) (value@ #left left) - (value@ #left left>>right))) - (#.Some (black key value + (value@ #left left>>right))} + {#.Some (black key value (value@ #right left>>right) - ?right))) + ?right)}) _ (black key value ?left ?right))) @@ -308,26 +308,26 @@ (def: (right_balanced key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right - (^multi (#.Some right) + (^multi {#.Some right} [(value@ #color right) #Red] - [(value@ #right right) (#.Some right>>right)] + [(value@ #right right) {#.Some right>>right}] [(value@ #color right>>right) #Red]) (red (value@ #key right) (value@ #value right) - (#.Some (black key value ?left (value@ #left right))) - (#.Some (blackened right>>right))) + {#.Some (black key value ?left (value@ #left right))} + {#.Some (blackened right>>right)}) - (^multi (#.Some right) + (^multi {#.Some right} [(value@ #color right) #Red] - [(value@ #left right) (#.Some right>>left)] + [(value@ #left right) {#.Some right>>left}] [(value@ #color right>>left) #Red]) (red (value@ #key right>>left) (value@ #value right>>left) - (#.Some (black key value ?left (value@ #left right>>left))) - (#.Some (black (value@ #key right) + {#.Some (black key value ?left (value@ #left right>>left))} + {#.Some (black (value@ #key right) (value@ #value right) (value@ #right right>>left) - (value@ #right right)))) + (value@ #right right))}) _ (black key value ?left ?right))) @@ -335,27 +335,27 @@ (def: (without_left key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left - (^multi (#.Some left) + (^multi {#.Some left} [(value@ #color left) #Red]) - (red key value (#.Some (blackened left)) ?right) + (red key value {#.Some (blackened left)} ?right) _ (case ?right - (^multi (#.Some right) + (^multi {#.Some right} [(value@ #color right) #Black]) - (right_balanced key value ?left (#.Some (reddened right))) + (right_balanced key value ?left {#.Some (reddened right)}) - (^multi (#.Some right) + (^multi {#.Some right} [(value@ #color right) #Red] - [(value@ #left right) (#.Some right>>left)] + [(value@ #left right) {#.Some right>>left}] [(value@ #color right>>left) #Black]) (red (value@ #key right>>left) (value@ #value right>>left) - (#.Some (black key value ?left (value@ #left right>>left))) - (#.Some (right_balanced (value@ #key right) + {#.Some (black key value ?left (value@ #left right>>left))} + {#.Some (right_balanced (value@ #key right) (value@ #value right) (value@ #right right>>left) - (\ maybe.functor each reddened (value@ #right right))))) + (\ maybe.functor each reddened (value@ #right right)))}) _ (panic! error_message)) @@ -364,27 +364,27 @@ (def: (without_right key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right - (^multi (#.Some right) + (^multi {#.Some right} [(value@ #color right) #Red]) - (red key value ?left (#.Some (blackened right))) + (red key value ?left {#.Some (blackened right)}) _ (case ?left - (^multi (#.Some left) + (^multi {#.Some left} [(value@ #color left) #Black]) - (left_balanced key value (#.Some (reddened left)) ?right) + (left_balanced key value {#.Some (reddened left)} ?right) - (^multi (#.Some left) + (^multi {#.Some left} [(value@ #color left) #Red] - [(value@ #right left) (#.Some left>>right)] + [(value@ #right left) {#.Some left>>right}] [(value@ #color left>>right) #Black]) (red (value@ #key left>>right) (value@ #value left>>right) - (#.Some (left_balanced (value@ #key left) + {#.Some (left_balanced (value@ #key left) (value@ #value left) (\ maybe.functor each reddened (value@ #left left)) - (value@ #left left>>right))) - (#.Some (black key value (value@ #right left>>right) ?right))) + (value@ #left left>>right))} + {#.Some (black key value (value@ #right left>>right) ?right)}) _ (panic! error_message) @@ -399,7 +399,7 @@ [_ #.None] ?left - [(#.Some left) (#.Some right)] + [{#.Some left} {#.Some right}] (case [(value@ #color left) (value@ #color right)] [#Red #Red] (do maybe.monad @@ -408,37 +408,37 @@ #Red (in (red (value@ #key fused) (value@ #value fused) - (#.Some (red (value@ #key left) + {#.Some (red (value@ #key left) (value@ #value left) (value@ #left left) - (value@ #left fused))) - (#.Some (red (value@ #key right) + (value@ #left fused))} + {#.Some (red (value@ #key right) (value@ #value right) (value@ #right fused) - (value@ #right right))))) + (value@ #right right))})) #Black (in (red (value@ #key left) (value@ #value left) (value@ #left left) - (#.Some (red (value@ #key right) + {#.Some (red (value@ #key right) (value@ #value right) - (#.Some fused) - (value@ #right right))))))) + {#.Some fused} + (value@ #right right))})))) [#Red #Black] - (#.Some (red (value@ #key left) + {#.Some (red (value@ #key left) (value@ #value left) (value@ #left left) (prepended (value@ #right left) - ?right))) + ?right))} [#Black #Red] - (#.Some (red (value@ #key right) + {#.Some (red (value@ #key right) (value@ #value right) (prepended ?left (value@ #left right)) - (value@ #right right))) + (value@ #right right))} [#Black #Black] (do maybe.monad @@ -447,23 +447,23 @@ #Red (in (red (value@ #key fused) (value@ #value fused) - (#.Some (black (value@ #key left) + {#.Some (black (value@ #key left) (value@ #value left) (value@ #left left) - (value@ #left fused))) - (#.Some (black (value@ #key right) + (value@ #left fused))} + {#.Some (black (value@ #key right) (value@ #value right) (value@ #right fused) - (value@ #right right))))) + (value@ #right right))})) #Black (in (without_left (value@ #key left) (value@ #value left) (value@ #left left) - (#.Some (black (value@ #key right) + {#.Some (black (value@ #key right) (value@ #value right) - (#.Some fused) - (value@ #right right))))) + {#.Some fused} + (value@ #right right))})) )) ) @@ -478,7 +478,7 @@ #.None [#.None #0] - (#.Some root) + {#.Some root} (let [root_key (value@ #key root) root_val (value@ #value root)] (if (_\= root_key key) @@ -495,22 +495,22 @@ [side_outcome _] (if go_left? (case (value@ #left root) - (^multi (#.Some left) + (^multi {#.Some left} [(value@ #color left) #Black]) - [(#.Some (without_left root_key root_val side_outcome (value@ #right root))) + [{#.Some (without_left root_key root_val side_outcome (value@ #right root))} #0] _ - [(#.Some (red root_key root_val side_outcome (value@ #right root))) + [{#.Some (red root_key root_val side_outcome (value@ #right root))} #0]) (case (value@ #right root) - (^multi (#.Some right) + (^multi {#.Some right} [(value@ #color right) #Black]) - [(#.Some (without_right root_key root_val (value@ #left root) side_outcome)) + [{#.Some (without_right root_key root_val (value@ #left root) side_outcome)} #0] _ - [(#.Some (red root_key root_val (value@ #left root) side_outcome)) + [{#.Some (red root_key root_val (value@ #left root) side_outcome)} #0]) ))) )) @@ -521,14 +521,14 @@ (with@ #root ?root dict) dict) - (#.Some root) - (with@ #root (#.Some (blackened root)) dict) + {#.Some root} + (with@ #root {#.Some (blackened root)} dict) ))) (def: .public (revised key transform dict) (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (..value key dict) - (#.Some old) + {#.Some old} (..has key (transform old) dict) #.None @@ -549,7 +549,7 @@ #.None (list) - (#.Some node') + {#.Some node'} ($_ list\composite (recur (value@ #left node')) (list <output>) @@ -571,7 +571,7 @@ [#.End #.End] #1 - [(#.Item [keyR valueR] entriesR') (#.Item [keyS valueS] entriesS')] + [{#.Item [keyR valueR] entriesR'} {#.Item [keyS valueS] entriesS'}] (and (/\= keyR keyS) (,\= valueR valueS) (recur entriesR' entriesS')) diff --git a/stdlib/source/library/lux/data/collection/dictionary/plist.lux b/stdlib/source/library/lux/data/collection/dictionary/plist.lux index 9bd4665df..85fec4622 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux @@ -34,9 +34,9 @@ #.End #.None - (#.Item [k' v'] properties') + {#.Item [k' v'] properties'} (if (text\= key k') - (#.Some v') + {#.Some v'} (value key properties')))) (template [<name> <type> <access>] @@ -51,7 +51,7 @@ (def: .public (contains? key properties) (All (_ a) (-> Text (PList a) Bit)) (case (..value key properties) - (#.Some _) + {#.Some _} true #.None @@ -63,12 +63,12 @@ #.End (list [key val]) - (#.Item [k' v'] properties') + {#.Item [k' v'] properties'} (if (text\= key k') - (#.Item [key val] - properties') - (#.Item [k' v'] - (has key val properties'))))) + {#.Item [key val] + properties'} + {#.Item [k' v'] + (has key val properties')}))) (def: .public (revised key f properties) (All (_ a) (-> Text (-> a a) (PList a) (PList a))) @@ -76,10 +76,10 @@ #.End #.End - (#.Item [k' v'] properties') + {#.Item [k' v'] properties'} (if (text\= key k') - (#.Item [k' (f v')] properties') - (#.Item [k' v'] (revised key f properties'))))) + {#.Item [k' (f v')] properties'} + {#.Item [k' v'] (revised key f properties')}))) (def: .public (lacks key properties) (All (_ a) (-> Text (PList a) (PList a))) @@ -87,11 +87,11 @@ #.End properties - (#.Item [k' v'] properties') + {#.Item [k' v'] properties'} (if (text\= key k') properties' - (#.Item [k' v'] - (lacks key properties'))))) + {#.Item [k' v'] + (lacks key properties')}))) (def: .public equivalence (All (_ a) (-> (Equivalence a) (Equivalence (PList a)))) diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index 286290c96..5c630614b 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -21,7 +21,7 @@ ... (type: (List a) ... #End -... (#Item a (List a))) +... {#Item a (List a)}) (implementation: .public mix (Mix List) @@ -31,7 +31,7 @@ #.End init - (#.Item x xs') + {#.Item x xs'} (mix f (f x init) xs')))) (def: .public (mixes f init inputs) @@ -40,13 +40,13 @@ #.End (list init) - (#.Item [head tail]) - (#.Item [init (mixes f (f head init) tail)]))) + {#.Item [head tail]} + {#.Item [init (mixes f (f head init) tail)]})) (def: .public (reversed xs) (All (_ a) (-> (List a) (List a))) - (mix (function (_ head tail) (#.Item head tail)) + (mix (function (_ head tail) {#.Item head tail}) #.End xs)) @@ -57,9 +57,9 @@ #.End #.End - (#.Item x xs') + {#.Item x xs'} (if (keep? x) - (#.Item x (only keep? xs')) + {#.Item x (only keep? xs')} (only keep? xs')))) (def: .public (partition satisfies? list) @@ -68,17 +68,17 @@ #.End [#.End #.End] - (#.Item head tail) + {#.Item head tail} (let [[in out] (partition satisfies? tail)] (if (satisfies? head) - [(#.Item head in) out] - [in (#.Item head out)])))) + [{#.Item head in} out] + [in {#.Item head out}])))) (def: .public (pairs xs) (All (_ a) (-> (List a) (List [a a]))) (case xs (^ (list& x1 x2 xs')) - (#.Item [x1 x2] (pairs xs')) + {#.Item [x1 x2] (pairs xs')} _ #.End)) @@ -92,11 +92,11 @@ #.End #.End - (#.Item x xs') + {#.Item x xs'} <then>) <else>))] - [first (#.Item x (first (-- n) xs')) #.End] + [first {#.Item x (first (-- n) xs')} #.End] [after (after (-- n) xs') xs] ) @@ -108,12 +108,12 @@ #.End #.End - (#.Item x xs') + {#.Item x xs'} (if (predicate x) <then> <else>)))] - [while (#.Item x (while predicate xs')) #.End] + [while {#.Item x (while predicate xs')} #.End] [until (until predicate xs') xs] ) @@ -125,9 +125,9 @@ #.End [#.End #.End] - (#.Item x xs') + {#.Item x xs'} (let [[tail rest] (split_at (-- n) xs')] - [(#.Item x tail) rest])) + [{#.Item x tail} rest])) [#.End xs])) (def: (split_when' predicate ys xs) @@ -137,10 +137,10 @@ #.End [ys xs] - (#.Item x xs') + {#.Item x xs'} (if (predicate x) [ys xs] - (split_when' predicate (#.Item x ys) xs')))) + (split_when' predicate {#.Item x ys} xs')))) (def: .public (split_when predicate xs) (All (_ a) @@ -156,21 +156,21 @@ _ (let [[pre post] (split_at size list)] - (#.Item pre (sub size post))))) + {#.Item pre (sub size post)}))) (def: .public (repeated n x) (All (_ a) (-> Nat a (List a))) (case n 0 #.End - _ (#.Item x (repeated (-- n) x)))) + _ {#.Item x (repeated (-- n) x)})) (def: (iterations' f x) (All (_ a) (-> (-> a (Maybe a)) a (List a))) (case (f x) - (#.Some x') - (#.Item x (iterations' f x')) + {#.Some x'} + {#.Item x (iterations' f x')} #.None (list))) @@ -179,8 +179,8 @@ (All (_ a) (-> (-> a (Maybe a)) a (List a))) (case (f x) - (#.Some x') - (#.Item x (iterations' f x')) + {#.Some x'} + {#.Item x (iterations' f x')} #.None (list x))) @@ -192,10 +192,10 @@ #.End #.None - (#.Item x xs') + {#.Item x xs'} (case (check x) - (#.Some output) - (#.Some output) + {#.Some output} + {#.Some output} #.None (one check xs')))) @@ -207,8 +207,8 @@ @.js (mix (function (_ head tail) (case (check head) - (#.Some head) - (#.Item head tail) + {#.Some head} + {#.Item head tail} #.None tail)) @@ -218,10 +218,10 @@ #.End #.End - (#.Item x xs') + {#.Item x xs'} (case (check x) - (#.Some output) - (#.Item output (all check xs')) + {#.Some output} + {#.Item output (all check xs')} #.None (all check xs'))))) @@ -231,7 +231,7 @@ (-> (Predicate a) (List a) (Maybe a))) (..one (function (_ value) (if (predicate value) - (#.Some value) + {#.Some value} #.None)) xs)) @@ -242,10 +242,10 @@ #.End xs - (#.Item x #.End) + {#.Item x #.End} xs - (#.Item x xs') + {#.Item x xs'} (list& x sep (interposed sep xs')))) (def: .public (size list) @@ -260,7 +260,7 @@ #.End <init> - (#.Item head tail) + {#.Item head tail} (<op> (predicate head) (<name> predicate tail))))] @@ -275,9 +275,9 @@ #.End #.None - (#.Item x xs') + {#.Item x xs'} (case i - 0 (#.Some x) + 0 {#.Some x} _ (item (-- i) xs')))) (implementation: .public (equivalence Equivalence<a>) @@ -288,7 +288,7 @@ [#.End #.End] #1 - [(#.Item x xs') (#.Item y ys')] + [{#.Item x xs'} {#.Item y ys'}] (and (\ Equivalence<a> = x y) (= xs' ys')) @@ -317,8 +317,8 @@ #.End ys - (#.Item x xs') - (#.Item x (composite xs' ys))))) + {#.Item x xs'} + {#.Item x (composite xs' ys)}))) (open: "[0]" ..monoid) @@ -330,8 +330,8 @@ #.End #.End - (#.Item a ma') - (#.Item (f a) (each f ma'))))) + {#.Item a ma'} + {#.Item (f a) (each f ma')}))) (open: "[0]" ..functor) @@ -345,7 +345,7 @@ #.End #.End - (#.Item f ff') + {#.Item f ff'} (|> ff' (on fa) (composite (each f fa)))))) @@ -356,7 +356,7 @@ (def: &functor ..functor) (def: (in a) - (#.Item a #.End)) + {#.Item a #.End}) (def: conjoint (|>> reversed (mix composite identity)))) @@ -367,11 +367,11 @@ #.End (list) - (#.Item x xs') + {#.Item x xs'} (let [[pre post] (mix (function (_ x' [pre post]) (if (< x x') - [(#.Item x' pre) post] - [pre (#.Item x' post)])) + [{#.Item x' pre} post] + [pre {#.Item x' post}])) [(list) (list)] xs')] ($_ composite (sorted < pre) (list x) (sorted < post))))) @@ -391,7 +391,7 @@ #.End #0 - (#.Item x' xs') + {#.Item x' xs'} (or (\ eq = x x') (member? eq xs' x)))) @@ -402,8 +402,8 @@ #.End #.None - (#.Item x xs') - (#.Some <side>)))] + {#.Item x xs'} + {#.Some <side>}))] [head a x] [tail (List a) xs'] @@ -417,7 +417,7 @@ (def: (identifier$ name) (-> Text Code) - [["" 0 0] (#.Identifier "" name)]) + [["" 0 0] {#.Identifier "" name}]) (def: (nat\encoded value) (-> Nat Text) @@ -443,7 +443,7 @@ (macro: .public (zipped tokens state) (case tokens - (^ (list [_ (#.Nat num_lists)])) + (^ (list [_ {#.Nat num_lists}])) (if (n.> 0 num_lists) (let [(^open "[0]") ..functor indices (..indices num_lists) @@ -458,7 +458,7 @@ (let [base (nat\encoded idx)] [(identifier$ base) (identifier$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (each (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) + pattern (` [(~+ (each (function (_ [v vs]) (` {#.Item (~ v) (~ vs)})) vars+lists))]) g!step (identifier$ "0step0") g!blank (identifier$ "0,0") @@ -467,23 +467,23 @@ (function ((~ g!step) (~+ list_vars)) (case [(~+ list_vars)] (~ pattern) - (#.Item [(~+ (each product.left vars+lists))] - ((~ g!step) (~+ list_vars))) + {#.Item [(~+ (each product.left vars+lists))] + ((~ g!step) (~+ list_vars))} (~ g!blank) #.End))))] - (#.Right [state (list code)])) - (#.Left "Cannot zipped 0 lists.")) + {#.Right [state (list code)]}) + {#.Left "Cannot zipped 0 lists."}) _ - (#.Left "Wrong syntax for zipped"))) + {#.Left "Wrong syntax for zipped"})) (def: .public zipped/2 (zipped 2)) (def: .public zipped/3 (zipped 3)) (macro: .public (zipped_with tokens state) (case tokens - (^ (list [_ (#.Nat num_lists)])) + (^ (list [_ {#.Nat num_lists}])) (if (n.> 0 num_lists) (let [(^open "[0]") ..functor indices (..indices num_lists) @@ -501,7 +501,7 @@ (let [base (nat\encoded idx)] [(identifier$ base) (identifier$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (each (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) + pattern (` [(~+ (each (function (_ [v vs]) (` {#.Item (~ v) (~ vs)})) vars+lists))]) g!step (identifier$ "0step0") g!blank (identifier$ "0,0") @@ -510,16 +510,16 @@ (function ((~ g!step) (~ g!func) (~+ list_vars)) (case [(~+ list_vars)] (~ pattern) - (#.Item ((~ g!func) (~+ (each product.left vars+lists))) - ((~ g!step) (~ g!func) (~+ list_vars))) + {#.Item ((~ g!func) (~+ (each product.left vars+lists))) + ((~ g!step) (~ g!func) (~+ list_vars))} (~ g!blank) #.End))))] - (#.Right [state (list code)])) - (#.Left "Cannot zipped_with 0 lists.")) + {#.Right [state (list code)]}) + {#.Left "Cannot zipped_with 0 lists."}) _ - (#.Left "Wrong syntax for zipped_with"))) + {#.Left "Wrong syntax for zipped_with"})) (def: .public zipped_with/2 (zipped_with 2)) (def: .public zipped_with/3 (zipped_with 3)) @@ -530,10 +530,10 @@ #.End #.None - (#.Item x #.End) - (#.Some x) + {#.Item x #.End} + {#.Some x} - (#.Item x xs') + {#.Item x xs'} (last xs'))) (def: .public (inits xs) @@ -542,16 +542,16 @@ #.End #.None - (#.Item x #.End) - (#.Some #.End) + {#.Item x #.End} + {#.Some #.End} - (#.Item x xs') + {#.Item x xs'} (case (inits xs') #.None (undefined) - (#.Some tail) - (#.Some (#.Item x tail))) + {#.Some tail} + {#.Some {#.Item x tail}}) )) (def: .public together @@ -573,7 +573,9 @@ [lMla MlMla ... TODO: Remove this version ASAP and use one below. lla (for [@.old - (: ((:parameter 0) (List (List (:parameter 1)))) + (: {#.Apply + (type (List (List (:parameter 1)))) + (:parameter 0)} (monad.all ! lMla))] (monad.all ! lMla))] (in (..together lla))))) @@ -590,15 +592,15 @@ #.End #.End - (#.Item x xs') - (#.Item [idx x] (recur (++ idx) xs'))))) + {#.Item x xs'} + {#.Item [idx x] (recur (++ idx) xs')}))) (macro: .public (when tokens state) (case tokens (^ (.list test then)) - (#.Right [state (.list (` (.if (~ test) + {#.Right [state (.list (` (.if (~ test) (~ then) - (.list))))]) + (.list))))]} _ - (#.Left "Wrong syntax for when"))) + {#.Left "Wrong syntax for when"})) diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index 3e3bd9e87..7a52a1e9f 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -76,7 +76,7 @@ (with@ #front (.list val) queue) _ - (revised@ #rear (|>> (#.Item val)) queue))) + (revised@ #rear (|>> {#.Item val}) queue))) (implementation: .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Queue a)))) diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux index 28f1f135f..6e56b4b1c 100644 --- a/stdlib/source/library/lux/data/collection/queue/priority.lux +++ b/stdlib/source/library/lux/data/collection/queue/priority.lux @@ -57,13 +57,13 @@ #.None 0 - (#.Some tree) + {#.Some tree} (loop [node tree] (case (tree.root node) - (0 #0 _) + {0 #0 _} 1 - (0 #1 [left right]) + {0 #1 [left right]} (n.+ (recur left) (recur right)))))) (def: .public (member? equivalence queue member) @@ -72,13 +72,13 @@ #.None false - (#.Some tree) + {#.Some tree} (loop [node tree] (case (tree.root node) - (0 #0 reference) + {0 #0 reference} (\ equivalence = reference member) - (0 #1 [left right]) + {0 #1 [left right]} (or (recur left) (recur right)))))) @@ -90,25 +90,25 @@ .let [highest_priority (tree.tag tree)]] (loop [node tree] (case (tree.root node) - (0 #0 reference) + {0 #0 reference} (if (n.= highest_priority (tree.tag node)) #.None - (#.Some node)) + {#.Some node}) - (0 #1 left right) + {0 #1 left right} (if (n.= highest_priority (tree.tag left)) (case (recur left) #.None - (#.Some right) + {#.Some right} - (#.Some =left) - (#.Some (\ ..builder branch =left right))) + {#.Some =left} + {#.Some (\ ..builder branch =left right)}) (case (recur right) #.None - (#.Some left) + {#.Some left} - (#.Some =right) - (#.Some (\ ..builder branch left =right))))))))) + {#.Some =right} + {#.Some (\ ..builder branch left =right)}))))))) (def: .public (end priority value queue) (All (_ a) (-> Priority a (Queue a) (Queue a))) @@ -116,10 +116,10 @@ (:abstraction (case (:representation queue) #.None - (#.Some addition) + {#.Some addition} - (#.Some tree) - (#.Some (\ ..builder branch tree addition))))))] + {#.Some tree} + {#.Some (\ ..builder branch tree addition)}))))] ) (def: .public empty? diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index 728a67ce4..aa8c6d0f7 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -34,8 +34,8 @@ (type: (Node a) (Variant - (#Base (Array a)) - (#Hierarchy (Array (Node a))))) + {#Base (Array a)} + {#Hierarchy (Array (Node a))})) (type: (Base a) (Array a)) @@ -93,7 +93,7 @@ (def: (path level tail) (All (_ a) (-> Level (Base a) (Node a))) (if (n.= 0 level) - (#Base tail) + {#Base tail} (|> (empty_hierarchy []) (array.write! 0 (path (level_down level) tail)) #Hierarchy))) @@ -109,15 +109,15 @@ ... If we're currently on a bottom node sub_node (if (n.= branching_exponent level) ... Just add the tail to it - (#Base tail) + {#Base tail} ... Otherwise, check whether there's a vacant spot (case (array.read! sub_idx parent) ... If so, set the path to the tail #.None (..path (level_down level) tail) ... If not, push the tail onto the sub_node. - (#.Some (#Hierarchy sub_node)) - (#Hierarchy (with_tail size (level_down level) tail sub_node)) + {#.Some {#Hierarchy sub_node}} + {#Hierarchy (with_tail size (level_down level) tail sub_node)} _ (undefined)) @@ -136,11 +136,11 @@ (All (_ a) (-> Level Index a (Hierarchy a) (Hierarchy a))) (let [sub_idx (branch_idx (i64.right_shifted level idx))] (case (array.read! sub_idx hierarchy) - (#.Some (#Hierarchy sub_node)) + {#.Some {#Hierarchy sub_node}} (|> (array.clone hierarchy) - (array.write! sub_idx (#Hierarchy (hierarchy\has (level_down level) idx val sub_node)))) + (array.write! sub_idx {#Hierarchy (hierarchy\has (level_down level) idx val sub_node)})) - (^multi (#.Some (#Base base)) + (^multi {#.Some {#Base base}} (n.= 0 (level_down level))) (|> (array.clone hierarchy) (array.write! sub_idx (|> (array.clone base) @@ -160,13 +160,13 @@ (do maybe.monad [base|hierarchy (array.read! sub_idx hierarchy) sub (case base|hierarchy - (#Hierarchy sub) + {#Hierarchy sub} (without_tail size (level_down level) sub) - (#Base _) + {#Base _} (undefined))] (|> (array.clone hierarchy) - (array.write! sub_idx (#Hierarchy sub)) + (array.write! sub_idx {#Hierarchy sub}) #.Some)) ... Else... @@ -178,10 +178,10 @@ (def: (node\list node) (All (_ a) (-> (Node a) (List a))) (case node - (#Base base) + {#Base base} (array.list #.None base) - (#Hierarchy hierarchy) + {#Hierarchy hierarchy} (|> hierarchy (array.list #.None) list.reversed @@ -228,7 +228,7 @@ (: (Hierarchy (:parameter 0)) (empty_hierarchy []))] (empty_hierarchy [])) - (array.write! 0 (#Hierarchy (value@ #root row))) + (array.write! 0 {#Hierarchy (value@ #root row)}) (array.write! 1 (..path (value@ #level row) (value@ #tail row))))) (revised@ #level level_up)) ... Otherwise, just push the current tail onto the root. @@ -261,18 +261,18 @@ hierarchy (value@ #root row)] (case [(n.> branching_exponent level) (array.read! (branch_idx (i64.right_shifted level idx)) hierarchy)] - [#1 (#.Some (#Hierarchy sub))] + [#1 {#.Some {#Hierarchy sub}}] (recur (level_down level) sub) - [#0 (#.Some (#Base base))] - (#try.Success base) + [#0 {#.Some {#Base base}}] + {#try.Success base} [_ #.None] (exception.except ..base_was_not_found []) _ (exception.except ..incorrect_row_structure []))) - (#try.Success (value@ #tail row))) + {#try.Success (value@ #tail row)}) (exception.except ..index_out_of_bounds [row idx]))) (def: .public (item idx row) @@ -280,8 +280,8 @@ (do try.monad [base (base_for idx row)] (case (array.read! (branch_idx idx) base) - (#.Some value) - (#try.Success value) + {#.Some value} + {#try.Success value} #.None (exception.except ..incorrect_row_structure [])))) @@ -290,14 +290,14 @@ (All (_ a) (-> Nat a (Row a) (Try (Row a)))) (let [row_size (value@ #size row)] (if (within_bounds? row idx) - (#try.Success (if (n.< (tail_off row_size) idx) + {#try.Success (if (n.< (tail_off row_size) idx) (revised@ #root (hierarchy\has (value@ #level row) idx val) row) (revised@ #tail (for [@.old (: (-> (Base (:parameter 0)) (Base (:parameter 0))) (|>> array.clone (array.write! (branch_idx idx) val)))] (|>> array.clone (array.write! (branch_idx idx) val))) - row))) + row))} (exception.except ..index_out_of_bounds [row idx])))) (def: .public (revised idx f row) @@ -332,10 +332,10 @@ (without_tail row_size init_level (value@ #root row)))] (if (n.> branching_exponent level) (case [(array.read! 1 root) (array.read! 0 root)] - [#.None (#.Some (#Hierarchy sub_node))] + [#.None {#.Some {#Hierarchy sub_node}}] (recur (level_down level) sub_node) - ... [#.None (#.Some (#Base _))] + ... [#.None {#.Some {#Base _}}] ... (undefined) _ @@ -350,8 +350,8 @@ (def: .public (list row) (All (_ a) (-> (Row a) (List a))) - (list\composite (node\list (#Hierarchy (value@ #root row))) - (node\list (#Base (value@ #tail row))))) + (list\composite (node\list {#Hierarchy (value@ #root row)}) + (node\list {#Base (value@ #tail row)}))) (def: .public of_list (All (_ a) (-> (List a) (Row a))) @@ -373,10 +373,10 @@ (def: (= v1 v2) (case [v1 v2] - [(#Base b1) (#Base b2)] + [{#Base b1} {#Base b2}] (\ (array.equivalence Equivalence<a>) = b1 b2) - [(#Hierarchy h1) (#Hierarchy h2)] + [{#Hierarchy h1} {#Hierarchy h2}] (\ (array.equivalence (node_equivalence Equivalence<a>)) = h1 h2) _ @@ -388,20 +388,20 @@ (def: (= v1 v2) (and (n.= (value@ #size v1) (value@ #size v2)) (let [(^open "node\[0]") (node_equivalence Equivalence<a>)] - (and (node\= (#Base (value@ #tail v1)) - (#Base (value@ #tail v2))) - (node\= (#Hierarchy (value@ #root v1)) - (#Hierarchy (value@ #root v2)))))))) + (and (node\= {#Base (value@ #tail v1)} + {#Base (value@ #tail v2)}) + (node\= {#Hierarchy (value@ #root v1)} + {#Hierarchy (value@ #root v2)})))))) (implementation: node_mix (Mix Node) (def: (mix f init xs) (case xs - (#Base base) + {#Base base} (array\mix f init base) - (#Hierarchy hierarchy) + {#Hierarchy hierarchy} (array\mix (function (_ node init') (mix f init' node)) init hierarchy)))) @@ -414,8 +414,8 @@ (mix f (mix f init - (#Hierarchy (value@ #root xs))) - (#Base (value@ #tail xs)))))) + {#Hierarchy (value@ #root xs)}) + {#Base (value@ #tail xs)})))) (implementation: .public monoid (All (_ a) (Monoid (Row a))) @@ -430,11 +430,11 @@ (def: (each f xs) (case xs - (#Base base) - (#Base (array\each f base)) + {#Base base} + {#Base (array\each f base)} - (#Hierarchy hierarchy) - (#Hierarchy (array\each (each f) hierarchy))))) + {#Hierarchy hierarchy} + {#Hierarchy (array\each (each f) hierarchy)}))) (implementation: .public functor (Functor Row) @@ -485,15 +485,15 @@ (-> (Predicate a) (Node a) Bit)) (function (help predicate node) (case node - (#Base base) + {#Base base} (<array> predicate base) - (#Hierarchy hierarchy) + {#Hierarchy hierarchy} (<array> (help predicate) hierarchy))))] (function (<name> predicate row) (let [(^slots [#root #tail]) row] - (<op> (help predicate (#Hierarchy root)) - (help predicate (#Base tail)))))))] + (<op> (help predicate {#Hierarchy root}) + (help predicate {#Base tail}))))))] [every? array.every? #1 and] [any? array.any? #0 or] diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index a641721c8..6e4e0b801 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -42,7 +42,7 @@ #.End (recur start next) - (#.Item head' tail') + {#.Item head' tail'} (recur head' tail'))]))) (template [<name> <return>] @@ -91,7 +91,7 @@ (if <pred_test> [(list) xs] (let [[tail next] (<splitter> <pred_step> xs')] - [(#.Item [x tail]) next]))))] + [{#.Item [x tail]} next]))))] [split_when (-> a Bit) (pred x) pred] [split_at Nat (n.= 0 pred) (-- pred)] diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index cd36648eb..89baa8935 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -43,7 +43,7 @@ (case multiplicity 0 set _ (case (dictionary.value elem (:representation set)) - (#.Some current) + {#.Some current} (:abstraction (if (n.> multiplicity current) (dictionary.revised elem (n.- multiplicity) (:representation set)) diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux index feb2d2805..87925a89a 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -31,8 +31,8 @@ #.End #.None - (#.Item value _) - (#.Some value))) + {#.Item value _} + {#.Some value})) (def: .public (next stack) (All (_ a) (-> (Stack a) (Maybe [a (Stack a)]))) @@ -40,12 +40,12 @@ #.End #.None - (#.Item top stack') - (#.Some [top (:abstraction stack')]))) + {#.Item top stack'} + {#.Some [top (:abstraction stack')]})) (def: .public (top value stack) (All (_ a) (-> a (Stack a) (Stack a))) - (:abstraction (#.Item value (:representation stack)))) + (:abstraction {#.Item value (:representation stack)})) (implementation: .public (equivalence super) (All (_ a) diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux index 96d92ac6d..281e9f2ed 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -27,7 +27,7 @@ (value@ #children) (list\each flat) list\conjoint - (#.Item (value@ #value tree)))) + {#.Item (value@ #value tree)})) (def: .public (leaf value) (All (_ a) (-> a (Tree a))) diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index b4e042069..c5fc655e8 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -45,40 +45,40 @@ (:abstraction [#monoid monoid #tag tag - #root (0 #0 value)])) + #root {0 #0 value}])) (def: (branch left right) (:abstraction [#monoid monoid #tag (\ monoid composite (..tag left) (..tag right)) - #root (0 #1 [left right])]))) + #root {0 #1 [left right]}]))) (def: .public (value tree) (All (_ @ t v) (-> (Tree @ t v) v)) (case (value@ #root (:representation tree)) - (0 #0 value) + {0 #0 value} value - (0 #1 [left right]) + {0 #1 [left right]} (value left))) (def: .public (tags tree) (All (_ @ t v) (-> (Tree @ t v) (List t))) (case (value@ #root (:representation tree)) - (0 #0 value) + {0 #0 value} (list (value@ #tag (:representation tree))) - (0 #1 [left right]) + {0 #1 [left right]} (list\composite (tags left) (tags right)))) (def: .public (values tree) (All (_ @ t v) (-> (Tree @ t v) (List v))) (case (value@ #root (:representation tree)) - (0 #0 value) + {0 #0 value} (list value) - (0 #1 [left right]) + {0 #1 [left right]} (list\composite (values left) (values right)))) @@ -90,10 +90,10 @@ (loop [_tag tag//identity _node root] (case _node - (0 #0 value) - (#.Some value) + {0 #0 value} + {#.Some value} - (0 #1 [left right]) + {0 #1 [left right]} (let [shifted_tag (tag//composite _tag (..tag left))] (if (predicate shifted_tag) (recur _tag (value@ #root (:representation left))) @@ -104,7 +104,7 @@ (def: .public (exists? predicate tree) (All (_ @ t v) (-> (Predicate t) (Tree @ t v) Bit)) (case (..one predicate tree) - (#.Some _) + {#.Some _} true #.None diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index ee7daa341..313a61909 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -92,11 +92,11 @@ #.End #.None - (#.Item head tail) - (#.Some [#family (#.Some [#parent (with@ [#node #//.children] (list) zipper) + {#.Item head tail} + {#.Some [#family {#.Some [#parent (with@ [#node #//.children] (list) zipper) #lefts #.End - #rights tail]) - #node head]))) + #rights tail]} + #node head]})) (def: .public (up zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) @@ -107,33 +107,33 @@ (revised@ #node (: (-> (Tree (:parameter 0)) (Tree (:parameter 0))) (with@ #//.children (list\composite (list.reversed lefts) - (#.Item (value@ #node zipper) - rights)))) + {#.Item (value@ #node zipper) + rights}))) parent)] (with@ [#node #//.children] (list\composite (list.reversed lefts) - (#.Item (value@ #node zipper) - rights)) + {#.Item (value@ #node zipper) + rights}) parent)))))) (template [<one> <all> <side> <op_side>] [(def: .public (<one> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (value@ #family zipper) - (#.Some family) + {#.Some family} (case (value@ <side> family) - (#.Item next side') - (#.Some (for [@.old - [#family (#.Some (|> family + {#.Item next side'} + {#.Some (for [@.old + [#family {#.Some (|> family (with@ <side> side') - (revised@ <op_side> (|>> (#.Item (value@ #node zipper)))))) + (revised@ <op_side> (|>> {#.Item (value@ #node zipper)})))} #node next]] (let [move (: (All (_ a) (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ side' zipper) (|>> (with@ <side> side') - (revised@ <op_side> (|>> (#.Item (value@ #node zipper)))))))] - [#family (#.Some (move side' zipper family)) - #node next]))) + (revised@ <op_side> (|>> {#.Item (value@ #node zipper)})))))] + [#family {#.Some (move side' zipper family)} + #node next]))} #.End #.None) @@ -147,24 +147,24 @@ #.None #.None - (#.Some family) + {#.Some family} (case (list.reversed (value@ <side> family)) #.End #.None - (#.Item last prevs) - (#.Some (for [@.old [#family (#.Some (|> family + {#.Item last prevs} + {#.Some (for [@.old [#family {#.Some (|> family (with@ <side> #.End) - (revised@ <op_side> (|>> (#.Item (value@ #node zipper)) - (list\composite prevs))))) + (revised@ <op_side> (|>> {#.Item (value@ #node zipper)} + (list\composite prevs))))} #node last]] (let [move (: (All (_ a) (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ prevs zipper) (|>> (with@ <side> #.End) - (revised@ <op_side> (|>> (#.Item (value@ #node zipper)) + (revised@ <op_side> (|>> {#.Item (value@ #node zipper)} (list\composite prevs))))))] - [#family (#.Some (move prevs zipper family)) - #node last]))))))] + [#family {#.Some (move prevs zipper family)} + #node last]))})))] [right rightmost #rights #lefts] [left leftmost #lefts #rights] @@ -173,14 +173,14 @@ (def: .public (next zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..down zipper) - (#.Some forward) - (#.Some forward) + {#.Some forward} + {#.Some forward} #.None (loop [@ zipper] (case (..right @) - (#.Some forward) - (#.Some forward) + {#.Some forward} + {#.Some forward} #.None (do maybe.monad @@ -190,12 +190,12 @@ (def: (bottom zipper) (All (_ a) (-> (Zipper a) (Zipper a))) (case (..right zipper) - (#.Some forward) + {#.Some forward} (bottom forward) #.None (case (..down zipper) - (#.Some forward) + {#.Some forward} (bottom forward) #.None @@ -207,13 +207,13 @@ #.None (..up zipper) - (#.Some backward) - (#.Some (case (..down backward) - (#.Some then) + {#.Some backward} + {#.Some (case (..down backward) + {#.Some then} (..bottom then) #.None - backward)))) + backward)})) (template [<name> <move>] [(def: .public (<name> zipper) @@ -222,13 +222,13 @@ #.None #.None - (#.Some @) + {#.Some @} (loop [@ @] (case (<move> @) #.None - (#.Some @) + {#.Some @} - (#.Some @) + {#.Some @} (recur @)))))] [end ..next] @@ -241,7 +241,7 @@ #.None true - (#.Some _) + {#.Some _} false)) (def: .public (interpose value zipper) @@ -253,7 +253,7 @@ (def: .public (adopt value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) (revised@ [#node #//.children] - (|>> (#.Item (//.leaf value))) + (|>> {#.Item (//.leaf value)}) zipper)) (def: .public (remove zipper) @@ -266,7 +266,7 @@ (value@ #rights family) (value@ #parent family))) - (#.Item next side) + {#.Item next side} (in (|> zipper (with@ #family (|> family (with@ #lefts side) @@ -280,10 +280,10 @@ #.None #.None - (#.Some family) - (#.Some (with@ #family - (#.Some (revised@ <side> (|>> (#.Item (//.leaf value))) family)) - zipper))))] + {#.Some family} + {#.Some (with@ #family + {#.Some (revised@ <side> (|>> {#.Item (//.leaf value)}) family)} + zipper)}))] [insert_left #lefts] [insert_right #rights] diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux index 234b7a093..0fcc94723 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -85,7 +85,7 @@ (function (_ altV) (case altV (^template [<number> <tag> <writer>] - [(<tag> caseV) + [{<tag> caseV} (let [[caseS caseT] (<writer> caseV)] [(.++ caseS) (function (_ [offset binary]) @@ -233,7 +233,7 @@ (function (_ altV) (case altV (^template [<number> <tag> <writer>] - [(<tag> caseV) + [{<tag> caseV} (let [[caseS caseT] (<writer> caseV)] [(.++ caseS) (function (_ [offset binary]) @@ -268,7 +268,7 @@ (function (_ altV) (case altV (^template [<number> <tag> <writer>] - [(<tag> caseV) + [{<tag> caseV} (let [[caseS caseT] (<writer> caseV)] [(.++ caseS) (function (_ [offset binary]) diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux index a0d849ccf..e0c1d1773 100644 --- a/stdlib/source/library/lux/data/format/css.lux +++ b/stdlib/source/library/lux/data/format/css.lux @@ -50,7 +50,7 @@ (def: .public (font font) (-> Font (CSS Special)) (let [with_unicode (case (value@ #/font.unicode_range font) - (#.Some unicode_range) + {#.Some unicode_range} (let [unicode_range' (format "U+" (\ nat.hex encoded (value@ #/font.start unicode_range)) "-" (\ nat.hex encoded (value@ #/font.end unicode_range)))] (list ["unicode-range" unicode_range'])) @@ -74,7 +74,7 @@ (-> URL (Maybe Query) (CSS Special)) (:abstraction (format (format "@import url(" (%.text url) ")") (case query - (#.Some query) + {#.Some query} (format " " (/query.query query)) #.None diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index ae4393448..1d5fe95df 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -922,7 +922,7 @@ #.None (:representation Stop stop) - (#.Some hint) + {#.Some hint} (format (:representation Hint hint) ..value_separator (:representation Stop stop))))])]) (type: .public (List/1 a) @@ -1078,7 +1078,7 @@ (Value Image)) (let [after_extent (format "at " (:representation location)) with_extent (case extent - (#.Some extent) + {#.Some extent} (format (..extent extent) " " after_extent) #.None @@ -1158,7 +1158,7 @@ (def: .public (font_family options) (-> (List Font) (Value Font)) (case options - (#.Item _) + {#.Item _} (|> options (list\each ..font_name) (text.interposed ",") diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index 10cf2c203..7e1a7e322 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -41,7 +41,7 @@ #Parent #Self #Top - (#Frame Text))) + {#Frame Text})) (def: (target value) (-> Target Text) @@ -50,7 +50,7 @@ #Parent "_parent" #Self "_self" #Top "_top" - (#Frame name) name)) + {#Frame name} name)) ... Properly formats text to ensure no injection can happen on the HTML. (def: safe @@ -176,7 +176,7 @@ (-> URL (Maybe Target) Meta) (let [partial (list ["href" href]) full (case target - (#.Some target) + {#.Some target} (list& ["target" (..target target)] partial) #.None @@ -213,7 +213,7 @@ (def: .public (image source attributes) (-> URL Attributes Image) (|> attributes - (#.Item ["src" source]) + {#.Item ["src" source]} (..simple "img"))) (def: .public (svg attributes content) @@ -267,9 +267,9 @@ (type: .public Shape (Variant - (#Rectangle Rectangle) - (#Circle Circle) - (#Polygon Polygon))) + {#Rectangle Rectangle} + {#Circle Circle} + {#Polygon Polygon})) (template [<name> <shape> <type> <format>] [(def: (<name> attributes shape) @@ -286,13 +286,13 @@ (def: (area attributes shape) (-> Attributes Shape (HTML Any)) (case shape - (#Rectangle rectangle) + {#Rectangle rectangle} (..rectangle attributes rectangle) - (#Circle circle) + {#Circle circle} (..circle attributes circle) - (#Polygon polygon) + {#Polygon polygon} (..polygon attributes polygon))) (def: .public (each attributes areas for) @@ -303,7 +303,7 @@ #.End (..empty "map" attributes) - (#.Item head tail) + {#.Item head tail} (..tag "map" attributes (list\mix (function.flipped ..and) head tail))))) @@ -348,7 +348,7 @@ (-> (Maybe Content) Attributes <type> <type>) (..tag <container_tag> attributes (case description - (#.Some description) + {#.Some description} ($_ ..and (..tag <description_tag> (list) description) content) @@ -469,7 +469,7 @@ #.End (..empty "dl" attributes) - (#.Item head tail) + {#.Item head tail} (..tag "dl" attributes (list\mix (function.flipped ..and) head tail)))) @@ -527,7 +527,7 @@ #.End head - (#.Item first rest) + {#.Item first rest} (..and head (..table_body (list\mix (function.flipped ..and) first rest)))) @@ -535,21 +535,21 @@ #.None content - (#.Some footer) + {#.Some footer} (..and content (..table_foot (..table_row footer)))) content (case columns #.None content - (#.Some columns) + {#.Some columns} (..and (..columns_group columns) content)) content (case caption #.None content - (#.Some caption) + {#.Some caption} (..and (:as HTML caption) content))] (..tag "table" attributes diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index 052ce1c18..aa6ef2279 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -43,12 +43,12 @@ (type: .public JSON (Rec JSON (Variant - (#Null Null) - (#Boolean Boolean) - (#Number Number) - (#String String) - (#Array (Row JSON)) - (#Object (Dictionary String JSON))))) + {#Null Null} + {#Boolean Boolean} + {#Number Number} + {#String String} + {#Array (Row JSON)} + {#Object (Dictionary String JSON)}))) (template [<name> <type>] [(type: .public <name> @@ -85,26 +85,26 @@ (def: (jsonF token) (-> JSON Code) (case token - (#Null _) + {#Null _} (` #..Null) (^template [<ctor> <json_tag>] - [(<json_tag> value) - (` (<json_tag> (~ (<ctor> value))))]) + [{<json_tag> value} + (` {<json_tag> (~ (<ctor> value))})]) ([code.bit #..Boolean] [code.frac #..Number] [code.text #..String]) - (#Array members) - (` (#..Array ((~! row.row) (~+ (row.list (row\each jsonF members)))))) + {#Array members} + (` {#..Array ((~! row.row) (~+ (row.list (row\each jsonF members))))}) - (#Object pairs) - (` (#..Object ((~! dictionary.of_list) + {#Object pairs} + (` {#..Object ((~! dictionary.of_list) (~! text.hash) (list (~+ (|> pairs dictionary.entries (list\each (function (_ [key_name value]) - (` [(~ (code.text key_name)) (~ (jsonF value))]))))))))))) + (` [(~ (code.text key_name)) (~ (jsonF value))])))))))}))) (syntax: .public (json [token ..jsonP]) (in (list (` (: JSON (~ (jsonF token))))))) @@ -112,47 +112,47 @@ (def: .public (fields json) (-> JSON (Try (List String))) (case json - (#Object obj) - (#try.Success (dictionary.keys obj)) + {#Object obj} + {#try.Success (dictionary.keys obj)} _ - (#try.Failure ($_ text\composite "Cannot get the fields of a non-object.")))) + {#try.Failure ($_ text\composite "Cannot get the fields of a non-object.")})) (def: .public (field key json) (-> String JSON (Try JSON)) (case json - (#Object obj) + {#Object obj} (case (dictionary.value key obj) - (#.Some value) - (#try.Success value) + {#.Some value} + {#try.Success value} #.None - (#try.Failure ($_ text\composite "Missing field '" key "' on object."))) + {#try.Failure ($_ text\composite "Missing field '" key "' on object.")}) _ - (#try.Failure ($_ text\composite "Cannot get field '" key "' on a non-object.")))) + {#try.Failure ($_ text\composite "Cannot get field '" key "' on a non-object.")})) (def: .public (has key value json) (-> String JSON JSON (Try JSON)) (case json - (#Object obj) - (#try.Success (#Object (dictionary.has key value obj))) + {#Object obj} + {#try.Success {#Object (dictionary.has key value obj)}} _ - (#try.Failure ($_ text\composite "Cannot set field '" key "' on a non-object.")))) + {#try.Failure ($_ text\composite "Cannot set field '" key "' on a non-object.")})) (template [<name> <tag> <type>] [(def: .public (<name> key json) (-> Text JSON (Try <type>)) (case (field key json) - (#try.Success (<tag> value)) - (#try.Success value) + {#try.Success {<tag> value}} + {#try.Success value} - (#try.Success _) - (#try.Failure ($_ text\composite "Wrong value type at key: " key)) + {#try.Success _} + {#try.Failure ($_ text\composite "Wrong value type at key: " key)} - (#try.Failure error) - (#try.Failure error)))] + {#try.Failure error} + {#try.Failure error}))] [boolean_field #Boolean Boolean] [number_field #Number Number] @@ -170,13 +170,13 @@ #1 (^template [<tag> <struct>] - [[(<tag> x') (<tag> y')] + [[{<tag> x'} {<tag> y'}] (\ <struct> = x' y')]) ([#Boolean bit.equivalence] [#Number f.equivalence] [#String text.equivalence]) - [(#Array xs) (#Array ys)] + [{#Array xs} {#Array ys}] (and (n.= (row.size xs) (row.size ys)) (list\mix (function (_ idx prev) (and prev @@ -188,13 +188,13 @@ #1 (list.indices (row.size xs)))) - [(#Object xs) (#Object ys)] + [{#Object xs} {#Object ys}] (and (n.= (dictionary.size xs) (dictionary.size ys)) (list\mix (function (_ [xk xv] prev) (and prev (case (dictionary.value xk ys) #.None #0 - (#.Some yv) (= xv yv)))) + {#.Some yv} (= xv yv)))) #1 (dictionary.entries xs))) @@ -273,7 +273,7 @@ (-> JSON Text) (case json (^template [<tag> <format>] - [(<tag> value) + [{<tag> value} (<format> value)]) ([#Null ..null_format] [#Boolean ..boolean_format] @@ -337,10 +337,10 @@ offset (<text>.many <text>.decimal)] (in ($_ text\composite mark (if signed?' "-" "") offset))))] (case (f\decoded ($_ text\composite (if signed? "-" "") digits "." decimals exp)) - (#try.Failure message) + {#try.Failure message} (<>.failure message) - (#try.Success value) + {#try.Success value} (in value)))) (def: escaped_parser diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux index 163bb3b20..b04f60806 100644 --- a/stdlib/source/library/lux/data/format/markdown.lux +++ b/stdlib/source/library/lux/data/format/markdown.lux @@ -110,7 +110,7 @@ (list\each (function (_ [idx [summary detail]]) (format "1. " (:representation summary) (case detail - (#.Some detail) + {#.Some detail} (|> detail :representation ..indent @@ -128,7 +128,7 @@ (|>> (list\each (function (_ [summary detail]) (format "* " (:representation summary) (case detail - (#.Some detail) + {#.Some detail} (|> detail :representation ..indent diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index c0864904c..ec7b997e9 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -76,7 +76,7 @@ [(def: .public (<in> value) (-> Nat (Try <type>)) (if (n.< <limit> value) - (#try.Success (:abstraction value)) + {#try.Success (:abstraction value)} (exception.except <exception> [value]))) (def: .public <out> @@ -230,10 +230,10 @@ (def: (un_padded string) (-> Binary (Try Binary)) (case (binary.size string) - 0 (#try.Success string) + 0 {#try.Success string} size (loop [end (-- size)] (case end - 0 (#try.Success (\ utf8.codec encoded "")) + 0 {#try.Success (\ utf8.codec encoded "")} _ (do try.monad [last_char (binary.read/8! end string)] (`` (case (.nat last_char) @@ -261,7 +261,7 @@ binary.size (n.> <size>)) (exception.except <exception> [value]) - (#try.Success (:abstraction value))) + {#try.Success (:abstraction value)}) (exception.except ..not_ascii [value]))) (def: .public <out> @@ -569,10 +569,10 @@ (type: .public Entry (Variant - (#Normal ..Normal) - (#Symbolic_Link ..Symbolic_Link) - (#Directory ..Directory) - (#Contiguous ..Contiguous))) + {#Normal ..Normal} + {#Symbolic_Link ..Symbolic_Link} + {#Directory ..Directory} + {#Contiguous ..Contiguous})) (type: Device Small) @@ -720,10 +720,10 @@ (def: entry_writer (Writer Entry) - (|>> (case> (#Normal value) (..normal_file_writer value) - (#Symbolic_Link value) (..symbolic_link_writer value) - (#Directory value) (..directory_writer value) - (#Contiguous value) (..contiguous_file_writer value)))) + (|>> (case> {#Normal value} (..normal_file_writer value) + {#Symbolic_Link value} (..symbolic_link_writer value) + {#Directory value} (..directory_writer value) + {#Contiguous value} (..contiguous_file_writer value)))) (def: end_of_archive_size Size diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index 5131090ec..90aaa1b1e 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -37,8 +37,8 @@ (type: .public XML (Rec XML (Variant - (#Text Text) - (#Node Tag Attrs (List XML))))) + {#Text Text} + {#Node Tag Attrs (List XML)}))) (def: namespace_separator ":") @@ -61,7 +61,7 @@ #.None (<>.codec int.decimal (<text>.many <text>.decimal)) - (#.Some _) + {#.Some _} (<>.codec int.decimal (<text>.many <text>.hexadecimal)))] (in (|> code .nat text.of_char))) (<>.before (<text>.this ";")) @@ -95,7 +95,7 @@ #.None (in ["" first_part]) - (#.Some second_part) + {#.Some second_part} (in [first_part second_part])))) (def: tag^ namespaced_symbol^) @@ -176,18 +176,18 @@ .let [no_children^ ($_ <>.either (do <>.monad [_ (<text>.this "/>")] - (in (#Node tag attrs (list)))) + (in {#Node tag attrs (list)})) (do <>.monad [_ (<text>.this ">") _ (<>.some (<>.either <text>.space ..comment^)) _ (..close_tag^ tag)] - (in (#Node tag attrs (list))))) + (in {#Node tag attrs (list)}))) with_children^ (do <>.monad [_ (<text>.this ">") children (<>.many node^) _ (..close_tag^ tag)] - (in (#Node tag attrs children)))]] + (in {#Node tag attrs children}))]] ($_ <>.either no_children^ with_children^)) @@ -245,10 +245,10 @@ (loop [prefix "" input input] (case input - (#Text value) + {#Text value} (sanitize_value value) - (^ (#Node xml_tag xml_attrs (list (#Text value)))) + (^ {#Node xml_tag xml_attrs (list {#Text value})}) (let [tag (..tag xml_tag) attrs (if (dictionary.empty? xml_attrs) "" @@ -258,7 +258,7 @@ (sanitize_value value) "</" tag ">")) - (#Node xml_tag xml_attrs xml_children) + {#Node xml_tag xml_attrs xml_children} (let [tag (..tag xml_tag) attrs (if (dictionary.empty? xml_attrs) "" @@ -279,11 +279,11 @@ (def: (= reference sample) (case [reference sample] - [(#Text reference/value) (#Text sample/value)] + [{#Text reference/value} {#Text sample/value}] (text\= reference/value sample/value) - [(#Node reference/tag reference/attrs reference/children) - (#Node sample/tag sample/attrs sample/children)] + [{#Node reference/tag reference/attrs reference/children} + {#Node sample/tag sample/attrs sample/children}] (and (name\= reference/tag sample/tag) (\ (dictionary.equivalence text.equivalence) = reference/attrs sample/attrs) (n.= (list.size reference/children) diff --git a/stdlib/source/library/lux/data/name.lux b/stdlib/source/library/lux/data/name.lux index 64d1f19ff..79d1feef3 100644 --- a/stdlib/source/library/lux/data/name.lux +++ b/stdlib/source/library/lux/data/name.lux @@ -53,10 +53,10 @@ (def: (decoded input) (case (text.all_split_by ..separator input) (^ (list short)) - (#.Right ["" short]) + {#.Right ["" short]} (^ (list module short)) - (#.Right [module short]) + {#.Right [module short]} _ - (#.Left (text\composite "Invalid format for Name: " input))))) + {#.Left (text\composite "Invalid format for Name: " input)}))) diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux index 85d27f12b..174a2936f 100644 --- a/stdlib/source/library/lux/data/sum.lux +++ b/stdlib/source/library/lux/data/sum.lux @@ -9,7 +9,7 @@ [(def: .public (<name> value) (All (_ left right) (-> <name> (Or left right))) - (0 <right?> value))] + {0 <right?> value})] [#0 left] [#1 right]) @@ -20,8 +20,8 @@ (-> (Or a b) c))) (function (_ input) (case input - (0 #0 l) (on_left l) - (0 #1 r) (on_right r)))) + {0 #0 l} (on_left l) + {0 #1 r} (on_right r)))) (def: .public (then on_left on_right) (All (_ l l' r r') @@ -29,8 +29,8 @@ (-> (Or l r) (Or l' r')))) (function (_ input) (case input - (0 #0 l) (0 #0 (on_left l)) - (0 #1 r) (0 #1 (on_right r))))) + {0 #0 l} {0 #0 (on_left l)} + {0 #1 r} {0 #1 (on_right r)}))) (template [<name> <side> <right?>] [(def: .public (<name> items) @@ -39,10 +39,10 @@ #.End #.End - (#.Item (0 <right?> x) items') - (#.Item [x (<name> items')]) + {#.Item {0 <right?> x} items'} + {#.Item [x (<name> items')]} - (#.Item _ items') + {#.Item _ items'} (<name> items')))] [lefts a #0] @@ -55,21 +55,21 @@ #.End [#.End #.End] - (#.Item x xs') + {#.Item x xs'} (let [[lefts rights] (partition xs')] (case x - (0 #0 x') [(#.Item x' lefts) rights] - (0 #1 x') [lefts (#.Item x' rights)])))) + {0 #0 x'} [{#.Item x' lefts} rights] + {0 #1 x'} [lefts {#.Item x' rights}])))) (def: .public (equivalence left right) (All (_ l r) (-> (Equivalence l) (Equivalence r) (Equivalence (Or l r)))) (implementation (def: (= reference sample) (case [reference sample] - [(#.Left reference) (#.Left sample)] + [{#.Left reference} {#.Left sample}] (\ left = reference sample) - [(#.Right reference) (#.Right sample)] + [{#.Right reference} {#.Right sample}] (\ right = reference sample) _ @@ -83,8 +83,8 @@ (\ right &equivalence))) (def: (hash value) (case value - (#.Left value) + {#.Left value} (\ left hash value) - (#.Right value) + {#.Right value} (\ right hash value))))) diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index b3961edc4..7823bd333 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -53,7 +53,7 @@ (def: .public (char index input) (-> Nat Text (Maybe Char)) (if (n.< ("lux text size" input) index) - (#.Some ("lux text char" index input)) + {#.Some ("lux text char" index input)} #.None)) (def: .public (index_since offset pattern input) @@ -74,13 +74,13 @@ #.None output - (#.Some offset') + {#.Some offset'} (recur (++ offset') output'))))) (def: .public (starts_with? prefix x) (-> Text Text Bit) (case (index prefix x) - (#.Some 0) + {#.Some 0} true _ @@ -89,7 +89,7 @@ (def: .public (ends_with? postfix x) (-> Text Text Bit) (case (last_index postfix x) - (#.Some n) + {#.Some n} (n.= (size x) (n.+ (size postfix) n)) @@ -104,7 +104,7 @@ (def: .public (contains? sub text) (-> Text Text Bit) (case ("lux text index" 0 sub text) - (#.Some _) + {#.Some _} true _ @@ -134,20 +134,20 @@ (-> Nat Nat Text (Maybe Text)) (if (|> size (n.+ offset) (n.> ("lux text size" input))) #.None - (#.Some ("lux text clip" offset size input)))) + {#.Some ("lux text clip" offset size input)})) (def: .public (clip_since offset input) (-> Nat Text (Maybe Text)) (let [size ("lux text size" input)] (if (n.> size offset) #.None - (#.Some ("lux text clip" offset (n.- offset size) input))))) + {#.Some ("lux text clip" offset (n.- offset size) input)}))) (def: .public (split_at at x) (-> Nat Text (Maybe [Text Text])) (case [(..clip 0 at x) (..clip_since at x)] - [(#.Some pre) (#.Some post)] - (#.Some [pre post]) + [{#.Some pre} {#.Some post}] + {#.Some [pre post]} _ #.None)) @@ -165,14 +165,14 @@ (loop [input sample output (: (List Text) (list))] (case (..split_by token input) - (#.Some [pre post]) + {#.Some [pre post]} (|> output - (#.Item pre) + {#.Item pre} (recur post)) #.None (|> output - (#.Item input) + {#.Item input} list.reversed)))) (def: .public (replaced/1 pattern replacement template) @@ -219,7 +219,7 @@ (loop [left "" right template] (case (..split_by pattern right) - (#.Some [pre post]) + {#.Some [pre post]} (recur ($_ "lux text concat" left pre replacement) post) #.None diff --git a/stdlib/source/library/lux/data/text/encoding/utf8.lux b/stdlib/source/library/lux/data/text/encoding/utf8.lux index 817288316..fc063228e 100644 --- a/stdlib/source/library/lux/data/text/encoding/utf8.lux +++ b/stdlib/source/library/lux/data/text/encoding/utf8.lux @@ -113,7 +113,7 @@ (def: (decoded value) (-> Binary (Try Text)) - (with_expansions [<jvm> (#try.Success (java/lang/String::new value (//.name //.utf_8)))] + (with_expansions [<jvm> {#try.Success (java/lang/String::new value (//.name //.utf_8))}] (for [@.old <jvm> @.jvm <jvm> @@ -137,7 +137,7 @@ (try (:as Text ("python object do" "decode" (:expected value) "utf-8"))) @.lua - (#try.Success ("lua utf8 decode" value)) + {#try.Success ("lua utf8 decode" value)} @.ruby (|> value diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux index db706cc42..422239a27 100644 --- a/stdlib/source/library/lux/data/text/escape.lux +++ b/stdlib/source/library/lux/data/text/escape.lux @@ -182,15 +182,15 @@ (case (|> current ("lux text clip" (n.+ ..ascii_escape_offset offset) ..code_size) (\ n.hex decoded)) - (#try.Success char) + {#try.Success char} (let [limit' (|> limit (n.- offset) (n.- ..unicode_escape_offset))] - (#try.Success [(format previous + {#try.Success [(format previous ("lux text clip" 0 offset current) (//.of_char char)) ("lux text clip" (n.+ ..unicode_escape_offset offset) limit' current) - limit'])) + limit']}) - (#try.Failure error) + {#try.Failure error} (exception.except ..invalid_unicode_escape [current offset]))) (def: .public (un_escaped text) @@ -234,14 +234,14 @@ _ (recur (++ offset) previous current limit)) - (#try.Success (case previous + {#try.Success (case previous "" current - _ (format previous current)))))) + _ (format previous current))}))) (syntax: .public (literal [literal <code>.text]) (case (..un_escaped literal) - (#try.Success un_escaped) + {#try.Success un_escaped} (in (list (code.text un_escaped))) - (#try.Failure error) + {#try.Failure error} (meta.failure error))) diff --git a/stdlib/source/library/lux/data/text/format.lux b/stdlib/source/library/lux/data/text/format.lux index 759ccb847..b22f3ce00 100644 --- a/stdlib/source/library/lux/data/text/format.lux +++ b/stdlib/source/library/lux/data/text/format.lux @@ -128,5 +128,5 @@ #.None "#.None" - (#.Some value) - (..format "(#.Some " (format value) ")")))) + {#.Some value} + (..format "{#.Some " (format value) "}")))) diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index 94fd16694..63b112bb4 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -110,7 +110,7 @@ re_range^ re_options^))] (in (case negate? - (#.Some _) (` ((~! <text>.not) ($_ ((~! <>.either)) (~+ parts)))) + {#.Some _} (` ((~! <text>.not) ($_ ((~! <>.either)) (~+ parts)))) #.None (` ($_ ((~! <>.either)) (~+ parts))))))) (def: re_user_class^ @@ -273,7 +273,7 @@ (type: Re_Group (Variant #Non_Capturing - (#Capturing [(Maybe Text) Nat]))) + {#Capturing [(Maybe Text) Nat]})) (def: (re_sequential^ capturing? re_scoped^ current_module) (-> Bit @@ -290,16 +290,16 @@ [Nat (List Code) (List (List Code))]) (function (_ part [idx names steps]) (case part - (^or (#.Left complex) (#.Right [#Non_Capturing complex])) + (^or {#.Left complex} {#.Right [#Non_Capturing complex]}) [idx names (list& (list g!temp complex (` .let) (` [(~ g!total) (\ (~! //.monoid) (~' composite) (~ g!total) (~ g!temp))])) steps)] - (#.Right [(#Capturing [?name num_captures]) scoped]) + {#.Right [{#Capturing [?name num_captures]} scoped]} (let [[idx! name!] (case ?name - (#.Some _name) + {#.Some _name} [idx (code.identifier ["" _name])] #.None @@ -334,31 +334,31 @@ (All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser [Text (Or l r)]))) (function (_ input) (case (left input) - (#try.Success [input' [lt lv]]) - (#try.Success [input' [lt (0 #0 lv)]]) + {#try.Success [input' [lt lv]]} + {#try.Success [input' [lt {0 #0 lv}]]} - (#try.Failure _) + {#try.Failure _} (case (right input) - (#try.Success [input' [rt rv]]) - (#try.Success [input' [rt (0 #1 rv)]]) + {#try.Success [input' [rt rv]]} + {#try.Success [input' [rt {0 #1 rv}]]} - (#try.Failure error) - (#try.Failure error))))) + {#try.Failure error} + {#try.Failure error})))) (def: (|||_^ left right) (All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser Text))) (function (_ input) (case (left input) - (#try.Success [input' [lt lv]]) - (#try.Success [input' lt]) + {#try.Success [input' [lt lv]]} + {#try.Success [input' lt]} - (#try.Failure _) + {#try.Failure _} (case (right input) - (#try.Success [input' [rt rv]]) - (#try.Success [input' rt]) + {#try.Success [input' [rt rv]]} + {#try.Success [input' rt]} - (#try.Failure error) - (#try.Failure error))))) + {#try.Failure error} + {#try.Failure error})))) (def: (prep_alternative [num_captures alt]) (-> [Nat Code] Code) @@ -401,12 +401,12 @@ _ (<text>.this ">") [num_captures pattern] (re_alternative^ #1 re_scoped^ current_module) _ (<text>.this ")")] - (in [(#Capturing [(#.Some captured_name) num_captures]) pattern])) + (in [{#Capturing [{#.Some captured_name} num_captures]} pattern])) (do <>.monad [_ (<text>.this "(") [num_captures pattern] (re_alternative^ #1 re_scoped^ current_module) _ (<text>.this ")")] - (in [(#Capturing [#.None num_captures]) pattern])))) + (in [{#Capturing [#.None num_captures]} pattern])))) (def: (regex^ current_module) (-> Text (Parser Code)) @@ -417,11 +417,11 @@ [current_module meta.current_module_name] (case (<text>.result (regex^ current_module) pattern) - (#try.Failure error) + {#try.Failure error} (meta.failure (format "Error while parsing regular-expression:" //.new_line error)) - (#try.Success regex) + {#try.Success regex} (in (list regex))))) (syntax: .public (^regex [[pattern bindings] (<code>.form (<>.and <code>.text (<>.maybe <code>.any))) @@ -430,6 +430,6 @@ (with_identifiers [g!temp] (in (list& (` (^multi (~ g!temp) [((~! <text>.result) (..regex (~ (code.text pattern))) (~ g!temp)) - (#try.Success (~ (maybe.else g!temp bindings)))])) + {#try.Success (~ (maybe.else g!temp bindings))}])) body branches)))) diff --git a/stdlib/source/library/lux/data/text/unicode/set.lux b/stdlib/source/library/lux/data/text/unicode/set.lux index b47505a09..32a05b3a4 100644 --- a/stdlib/source/library/lux/data/text/unicode/set.lux +++ b/stdlib/source/library/lux/data/text/unicode/set.lux @@ -217,10 +217,10 @@ (loop [tree (:representation set)] (if (//block.within? (tree.tag tree) character) (case (tree.root tree) - (0 #0 _) + {0 #0 _} true - (0 #1 left right) + {0 #1 left right} (or (recur left) (recur right))) false))) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 8f3245ea2..7b107d8e5 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -126,7 +126,7 @@ (let [member ("lua array read" idx tuple)] (if ("lua object nil?" member) #.End - (#.Item member (recur (++ idx))))))))] + {#.Item member (recur (++ idx))})))))] (as_is)) (def: (tuple_inspection inspection) @@ -145,7 +145,7 @@ (with_expansions [<jvm> (let [object (:as java/lang/Object value)] (`` (<| (~~ (template [<class> <processing>] [(case (ffi.check <class> object) - (#.Some value) + {#.Some value} (`` (|> value (~~ (template.spliced <processing>)))) #.None)] @@ -155,16 +155,16 @@ [java/lang/String [(:as .Text) %.text]] )) (case (ffi.check [java/lang/Object] object) - (#.Some value) + {#.Some value} (let [value (:as (array.Array java/lang/Object) value)] (case (array.read! 0 value) - (^multi (#.Some tag) + (^multi {#.Some tag} [(ffi.check java/lang/Integer tag) - (#.Some tag)] + {#.Some tag}] [[(array.read! 1 value) (array.read! 2 value)] - [last? (#.Some choice)]]) + [last? {#.Some choice}]]) (let [last? (case last? - (#.Some _) #1 + {#.Some _} #1 #.None #0)] (|> (%.format (%.nat (.nat (java/lang/Integer::longValue tag))) " " (%.bit last?) @@ -256,8 +256,8 @@ "number" (case (math::type [value]) - (#.Some "integer") (|> value (:as .Int) %.int) - (#.Some "float") (|> value (:as .Frac) %.frac) + {#.Some "integer"} (|> value (:as .Int) %.int) + {#.Some "float"} (|> value (:as .Frac) %.frac) _ (..tostring value)) @@ -447,18 +447,18 @@ representations membersR+ variantV variantV] (case representations - (#.Item leftR (#.Item rightR extraR+)) + {#.Item leftR {#.Item rightR extraR+}} (case (:as (Or Any Any) variantV) - (#.Left left) + {#.Left left} [lefts #0 (leftR left)] - (#.Right right) + {#.Right right} (case extraR+ #.End [lefts #1 (rightR right)] _ - (recur (++ lefts) (#.Item rightR extraR+) right))) + (recur (++ lefts) {#.Item rightR extraR+} right))) _ (undefined)))] @@ -475,10 +475,10 @@ #.End "" - (#.Item lastR #.End) + {#.Item lastR #.End} (lastR tupleV) - (#.Item headR tailR) + {#.Item headR tailR} (let [[leftV rightV] (:as [Any Any] tupleV)] (%.format (headR leftV) " " (recur tailR rightV)))))] (%.format "[" tuple_body "]")))))) @@ -496,7 +496,7 @@ (do <>.monad [[funcT inputsT+] (<type>.applied (<>.and <type>.any (<>.many <type>.any)))] (case (type.applied inputsT+ funcT) - (#.Some outputT) + {#.Some outputT} (<type>.local (list outputT) representation) #.None @@ -512,10 +512,10 @@ (def: .public (representation type value) (-> Type Any (Try Text)) (case (<type>.result ..representation_parser type) - (#try.Success representation) - (#try.Success (representation value)) + {#try.Success representation} + {#try.Success (representation value)} - (#try.Failure _) + {#try.Failure _} (exception.except ..cannot_represent_value type))) (syntax: .public (private [definition <code>.identifier]) @@ -589,7 +589,7 @@ #.None (` (~! ..inspection)) - (#.Some format) + {#.Some format} format)] (` [(~ (code.text name)) ((~ format) (~ (code.local_identifier name)))]))) diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index f523c3335..7ebe3cfdf 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -35,12 +35,12 @@ ["[0]" syntax]]]]]]]) (template: (|recursion_dummy|) - [(#.Primitive "" #.End)]) + [{#.Primitive "" #.End}]) (type: Fragment (Variant - (#Comment Text) - (#Code Code))) + {#Comment Text} + {#Code Code})) (def: fragment (Parser Fragment) @@ -51,7 +51,7 @@ (-> Code Nat) (case code (^template [<tag>] - [[[_ _ column] (<tag> _)] + [[[_ _ column] {<tag> _}] column]) ([#.Bit] [#.Nat] @@ -63,7 +63,7 @@ [#.Tag]) (^template [<tag>] - [[[_ _ column] (<tag> members)] + [[[_ _ column] {<tag> members}] (|> members (list\each reference_column) (list\mix n.min column))]) @@ -89,7 +89,7 @@ (-> Text Location Nat Code [Location Text]) (case example (^template [<tag> <prefix>] - [[new_location (<tag> [module short])] + [[new_location {<tag> [module short]}] (let [documentation (<| (text.prefix <prefix>) (cond (text\= expected_module module) short @@ -106,7 +106,7 @@ [#.Tag syntax.sigil]) (^template [<tag> <format>] - [[new_location (<tag> value)] + [[new_location {<tag> value}] (let [documentation (`` (|> value (~~ (template.spliced <format>))))] [(revised@ #.column (n.+ (text.size documentation)) new_location) (format (padding reference_column old_location new_location) @@ -119,7 +119,7 @@ [#.Text [%.text]]) (^template [|<| |>| <tag>] - [[group_location (<tag> members)] + [[group_location {<tag> members}] (let [[group_location' members_documentation] (list\mix (function (_ part [last_location text_accum]) (let [[member_location member_documentation] (code_documentation expected_module last_location reference_column part)] [member_location (format text_accum member_documentation)])) @@ -144,10 +144,10 @@ (def: (fragment_documentation module fragment) (-> Text Fragment Text) (case fragment - (#Comment comment) + {#Comment comment} (..single_line_comment comment) - (#Code example) + {#Code example} (let [reference_column (..reference_column example) [location _] example] (|> example @@ -161,7 +161,7 @@ (-> Nat Text) (format "_" (%.nat id)) ... (case (text.char id ..parameter_name_options) - ... (#.Some char) + ... {#.Some char} ... (text.of_char char) ... #.None @@ -192,7 +192,7 @@ (if (type_parameter? id) (let [parameter_id (..parameter_id level id)] (case (list.item parameter_id type_function_arguments) - (#.Some found) + {#.Some found} found _ @@ -222,29 +222,29 @@ (def: (%type' level type_function_name nestable? module type) (-> Nat Text Bit Text Type Text) (case type - (#.Primitive name params) + {#.Primitive name params} (|> params (list\each (|>> (%type' level type_function_name false module) (format " "))) - (#.Item (%.text name)) + {#.Item (%.text name)} text.together (text.enclosed ["(primitive " ")"])) - (#.Sum _) + {#.Sum _} (|> type type.flat_variant (list\each (%type' level type_function_name false module)) (text.interposed " ") (text.enclosed ["(Or " ")"])) - (#.Product _) + {#.Product _} (|> type type.flat_tuple (list\each (%type' level type_function_name false module)) (text.interposed " ") (text.enclosed ["[" "]"])) - (#.Function input output) + {#.Function input output} (let [[ins out] (type.flat_function type)] (format "(-> " (|> ins (list\each (%type' level type_function_name false module)) (text.interposed " ")) @@ -252,17 +252,17 @@ (%type' level type_function_name false module out) ")")) - (#.Parameter idx) + {#.Parameter idx} (parameter_name [type_function_name (list)] level idx) (^template [<tag> <pre> <post>] - [(<tag> id) + [{<tag> id} (format <pre> (%.nat id) <post>)]) ([#.Var "⌈" "⌋"] [#.Ex "⟨" "⟩"]) (^template [<tag> <name> <flat>] - [(<tag> _) + [{<tag> _} (let [[level' body] (<flat> type) args (level_parameters level level') body_doc (%type' (n.+ level level') type_function_name nestable? module body)] @@ -274,15 +274,15 @@ ([#.UnivQ "All" type.flat_univ_q] [#.ExQ "Ex" type.flat_ex_q]) - (^ (#.Apply (|recursion_dummy|) (#.Parameter 0))) + (^ {#.Apply (|recursion_dummy|) {#.Parameter 0}}) type_function_name - (^ (#.Apply (|recursion_dummy|) (#.UnivQ _ body))) + (^ {#.Apply (|recursion_dummy|) {#.UnivQ _ body}}) (format "(Rec " type_function_name \n (nested " " (%type' level type_function_name nestable? module body)) ")") - (#.Apply param fun) + {#.Apply param fun} (let [[type_func type_arguments] (type.flat_application type)] (format "(" (%type' level type_function_name false module type_func) " " (|> type_arguments @@ -290,7 +290,7 @@ (text.interposed " ")) ")")) - (#.Named [_module _name] type) + {#.Named [_module _name] type} (cond (text\= module _module) _name @@ -308,9 +308,9 @@ (def: (parameterized_type arity type) (-> Nat Type (Maybe Type)) (case arity - 0 (#.Some type) + 0 {#.Some type} _ (case type - (#.UnivQ _env _type) + {#.UnivQ _env _type} (parameterized_type (-- arity) _type) _ @@ -325,7 +325,7 @@ _ (case type - (#.Primitive name params) + {#.Primitive name params} (case params #.End (format "(primitive " (%.text name) ")") @@ -333,7 +333,7 @@ _ (format "(primitive " (%.text name) " " (|> params (list\each (type_definition' false level arity type_function_info #.None module)) (text.interposed " ")) ")")) - (#.Sum _) + {#.Sum _} (let [members (type.flat_variant type)] (case tags #.End @@ -348,20 +348,20 @@ (list.zipped/2 tags) (list\each (function (_ [t_name type]) (case type - (#.Product _) + {#.Product _} (let [types (type.flat_tuple type)] - (format " (#" t_name " " + (format " {#" t_name " " (|> types (list\each (type_definition' false level arity type_function_info #.None module)) (text.interposed " ")) - ")")) + "}")) _ - (format " (#" t_name " " (type_definition' false level arity type_function_info #.None module type) ")")))) + (format " {#" t_name " " (type_definition' false level arity type_function_info #.None module type) "}")))) (text.interposed \n) (text.enclosed [(format "(Variant" \n) ")"])))) - (#.Product _) + {#.Product _} (let [members (type.flat_tuple type)] (case tags #.End @@ -376,24 +376,24 @@ (text.enclosed [" [" "]"]) (text.enclosed [(format "(Record" \n) ")"])))) - (#.Function input output) + {#.Function input output} (let [[ins out] (type.flat_function type)] (format "(-> " (|> ins (list\each (type_definition' false level arity type_function_info #.None module)) (text.interposed " ")) " " (type_definition' false level arity type_function_info #.None module out) ")")) - (#.Parameter idx) + {#.Parameter idx} (parameter_name type_function_info level idx) (^template [<tag> <pre>] - [(<tag> id) + [{<tag> id} (format <pre> (%.nat id))]) ([#.Var "-"] [#.Ex "+"]) (^template [<tag> <name> <flat>] - [(<tag> _) + [{<tag> _} (let [[level' body] (<flat> type) args (level_parameters (n.- arity level) level') body_doc (type_definition' nestable? (n.+ level level') arity type_function_info tags module body) @@ -409,10 +409,10 @@ [#.ExQ "Ex" type.flat_ex_q]) ... Recursive call - (^ (#.Apply (|recursion_dummy|) (#.Parameter 0))) + (^ {#.Apply (|recursion_dummy|) {#.Parameter 0}}) (product.left type_function_info) - (^ (#.Apply (|recursion_dummy|) (#.UnivQ _ body))) + (^ {#.Apply (|recursion_dummy|) {#.UnivQ _ body}}) (|> (type_definition' nestable? level arity type_function_info tags module body) (text.all_split_by \n) (list\each (text.prefix " ")) @@ -420,7 +420,7 @@ (text.enclosed [(format "(Rec " (product.left type_function_info) \n) ")"])) - (#.Apply param fun) + {#.Apply param fun} (let [[type_func type_arguments] (type.flat_application type)] (format "(" (type_definition' false level arity type_function_info tags module type_func) " " (|> type_arguments @@ -428,7 +428,7 @@ (text.interposed " ")) ")")) - (#.Named [_module _name] type) + {#.Named [_module _name] type} (cond (text\= module _module) _name @@ -443,7 +443,7 @@ (-> Text [Text (List Text)] (List Text) Type Text) (let [arity (list.size parameters)] (case (parameterized_type arity type) - (#.Some type) + {#.Some type} (type_definition' true (-- arity) arity [name parameters] tags module type) #.None @@ -552,7 +552,7 @@ (~+ (list\each code.local_identifier parameters)))) ... Description (~+ (case description - (#.Some description) + {#.Some description} (list (` (<| ((~! md.paragraph)) ((~! md.text)) (~ description)))) diff --git a/stdlib/source/library/lux/extension.lux b/stdlib/source/library/lux/extension.lux index 885c32fbc..e4b320a27 100644 --- a/stdlib/source/library/lux/extension.lux +++ b/stdlib/source/library/lux/extension.lux @@ -51,10 +51,10 @@ (~ g!_) <end>] (.\ (~! <>.monad) (~' in) (~ body))) (~ g!inputs)) - (#.Right (~ g!_)) + {#.Right (~ g!_)} (~ g!_) - (#.Left (~ g!error)) + {#.Left (~ g!error)} ((~! phase.failure) (~ g!error))) ))))))))] diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux index b8a1dbf58..57f346903 100644 --- a/stdlib/source/library/lux/ffi.js.lux +++ b/stdlib/source/library/lux/ffi.js.lux @@ -93,8 +93,8 @@ (type: Method (Variant - (#Static Static_Method) - (#Virtual Virtual_Method))) + {#Static Static_Method} + {#Virtual Virtual_Method})) (def: common_method (Parser Common_Method) @@ -116,9 +116,9 @@ (type: Member (Variant - (#Constructor Constructor) - (#Field Field) - (#Method Method))) + {#Constructor Constructor} + {#Field Field} + {#Method Method})) (def: member (Parser Member) @@ -144,7 +144,7 @@ (-> Code [Bit Code] Code) (if nullable? (` (case (~ input) - (#.Some (~ g!temp)) + {#.Some (~ g!temp)} (~ g!temp) #.None @@ -165,7 +165,7 @@ (` (let [(~ g!temp) (~ output)] (if ("js object null?" (~ g!temp)) #.None - (#.Some (~ g!temp))))) + {#.Some (~ g!temp)}))) (` (let [(~ g!temp) (~ output)] (if (not ("js object null?" (~ g!temp))) (~ g!temp) @@ -176,8 +176,8 @@ (type: Import (Variant - (#Class [Class_Declaration Text (List Member)]) - (#Function Static_Method))) + {#Class [Class_Declaration Text (List Member)]} + {#Function Static_Method})) (def: class_declaration (Parser Class_Declaration) @@ -238,7 +238,7 @@ (syntax: .public (import: [import ..import]) (with_identifiers [g!temp g!_] (case import - (#Class [[class_name class_parameters] format members]) + {#Class [[class_name class_parameters] format members]} (with_identifiers [g!object] (let [qualify (: (-> Text Code) (function (_ member_name) @@ -254,7 +254,7 @@ (..Object (primitive (~ (code.text real_class)))))) (list\each (function (_ member) (case member - (#Constructor inputsT) + {#Constructor inputsT} (let [g!inputs (input_variables inputsT)] (` (def: ((~ (qualify "new")) [(~+ (list\each product.right g!inputs))]) @@ -266,7 +266,7 @@ ("js constant" (~ (code.text real_class))) [(~+ (list\each (with_null g!temp) g!inputs))]))))) - (#Field [static? field fieldT]) + {#Field [static? field fieldT]} (if static? (` ((~! syntax:) ((~ (qualify field)) []) (\ (~! meta.monad) (~' in) @@ -280,9 +280,9 @@ (:expected (~ (without_null g!temp fieldT (` ("js object get" (~ (code.text field)) (~ g!object))))))))) - (#Method method) + {#Method method} (case method - (#Static [method alias inputsT io? try? outputT]) + {#Static [method alias inputsT io? try? outputT]} (..make_function (qualify (maybe.else method alias)) g!temp (%.format real_class "." method) @@ -291,7 +291,7 @@ try? outputT) - (#Virtual [method alias inputsT io? try? outputT]) + {#Virtual [method alias inputsT io? try? outputT]} (let [g!inputs (input_variables inputsT)] (` (def: ((~ (qualify (maybe.else method alias))) [(~+ (list\each product.right g!inputs))] @@ -312,7 +312,7 @@ [(~+ (list\each (with_null g!temp) g!inputs))]))))))))))) members))))) - (#Function [name alias inputsT io? try? outputT]) + {#Function [name alias inputsT io? try? outputT]} (in (list (..make_function (code.local_identifier (maybe.else name alias)) g!temp name @@ -337,9 +337,9 @@ #.None (~ g!_) - (#.Some (:as (~ type) (~ constant)))))))) + {#.Some (:as (~ type) (~ constant))}))))) - (#.Item [next tail]) + {#.Item [next tail]} (let [separator "."] (in (list (` (: (.Maybe (~ type)) (case (..type_of (~ constant)) @@ -355,7 +355,7 @@ #.None .false - (#.Some _) + {#.Some _} .true)]) (template [<name> <constant>] @@ -370,7 +370,7 @@ (def: .public on_node_js? Bit (case (..constant (Object Any) [process]) - (#.Some process) + {#.Some process} (case (:as Text ("js apply" ("js constant" "Object.prototype.toString.call") process)) "[object process]" diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index fd9e9d111..0ccc11f86 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -56,7 +56,7 @@ (template [<name> <class>] [(`` (def: .public <name> .Type - (#.Primitive <class> #.End)))] + {#.Primitive <class> #.End}))] [Boolean box.boolean] [Byte box.byte] @@ -71,7 +71,7 @@ (template [<name> <class>] [(`` (def: .public <name> .Type - (#.Primitive (reflection.reflection <class>) #.End)))] + {#.Primitive (reflection.reflection <class>) #.End}))] ... Primitives [boolean reflection.boolean] @@ -227,8 +227,8 @@ (type: FieldDecl (Variant - (#ConstantField (Type Value) Code) - (#VariableField State (Type Value)))) + {#ConstantField (Type Value) Code} + {#VariableField State (Type Value)})) (type: MethodDecl (Record @@ -239,43 +239,43 @@ (type: Method_Definition (Variant - (#ConstructorMethod [Bit + {#ConstructorMethod [Bit (List (Type Var)) Text (List Argument) (List (Typed Code)) Code - (List (Type Class))]) - (#VirtualMethod [Bit + (List (Type Class))]} + {#VirtualMethod [Bit Bit (List (Type Var)) Text (List Argument) (Type Return) Code - (List (Type Class))]) - (#OverridenMethod [Bit + (List (Type Class))]} + {#OverridenMethod [Bit (Type Declaration) (List (Type Var)) Text (List Argument) (Type Return) Code - (List (Type Class))]) - (#StaticMethod [Bit + (List (Type Class))]} + {#StaticMethod [Bit (List (Type Var)) (List Argument) (Type Return) Code - (List (Type Class))]) - (#AbstractMethod [(List (Type Var)) + (List (Type Class))]} + {#AbstractMethod [(List (Type Var)) (List Argument) (Type Return) - (List (Type Class))]) - (#NativeMethod [(List (Type Var)) + (List (Type Class))]} + {#NativeMethod [(List (Type Var)) (List Argument) (Type Return) - (List (Type Class))]))) + (List (Type Class))]})) (type: Partial_Call (Record @@ -318,10 +318,10 @@ (type: Import_Member_Declaration (Variant - (#EnumDecl (List Text)) - (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl]) - (#MethodDecl [ImportMethodCommons ImportMethodDecl]) - (#FieldAccessDecl ImportFieldDecl))) + {#EnumDecl (List Text)} + {#ConstructorDecl [ImportMethodCommons ImportConstructorDecl]} + {#MethodDecl [ImportMethodCommons ImportMethodDecl]} + {#FieldAccessDecl ImportFieldDecl})) (def: (primitive_type mode type) (-> Primitive_Mode (Type Primitive) Code) @@ -362,7 +362,7 @@ (-> (Type Parameter) Code) (`` (<| (~~ (template [<when> <binding> <then>] [(case (<when> type) - (#.Some <binding>) + {#.Some <binding>} <then> #.None)] @@ -382,7 +382,7 @@ (-> Primitive_Mode (Type Value) Code) (`` (<| (~~ (template [<when> <binding> <then>] [(case (<when> type) - (#.Some <binding>) + {#.Some <binding>} <then> #.None)] @@ -390,12 +390,12 @@ [parser.parameter? type (parameter_type type)] [parser.primitive? type (primitive_type mode type)] [parser.array? elementT (case (parser.primitive? elementT) - (#.Some elementT) - (` (#.Primitive (~ (code.text (..reflection (type.array elementT)))) #.End)) + {#.Some elementT} + (` {#.Primitive (~ (code.text (..reflection (type.array elementT)))) #.End}) #.None - (` (#.Primitive (~ (code.text array.type_name)) - (#.Item (~ (value_type mode elementT)) #.End))))])) + (` {#.Primitive (~ (code.text array.type_name)) + {#.Item (~ (value_type mode elementT)) #.End}}))])) (undefined) ))) @@ -433,8 +433,8 @@ (-> (-> Code Code) Code Code) (case (f input) (^template [<tag>] - [[meta (<tag> parts)] - [meta (<tag> (list\each (replaced f) parts))]]) + [[meta {<tag> parts}] + [meta {<tag> (list\each (replaced f) parts)}]]) ([#.Form] [#.Variant] [#.Tuple]) @@ -445,7 +445,7 @@ (def: (parser->replacer p ast) (-> (Parser Code) (-> Code Code)) (case (<>.result p (list ast)) - (#.Right [#.End ast']) + {#.Right [#.End ast']} ast' _ @@ -455,10 +455,10 @@ (def: (field->parser class_name self_name [[field_name _ _] field]) (-> Text Text [Member_Declaration FieldDecl] (Parser Code)) (case field - (#ConstantField _) + {#ConstantField _} (get_const_parser class_name field_name) - (#VariableField _) + {#VariableField _} (<>.either (get_var_parser class_name field_name self_name) (put_var_parser class_name field_name self_name)))) @@ -510,22 +510,22 @@ (def: (method->parser class_name [[method_name _ _] meth_def]) (-> Text [Member_Declaration Method_Definition] (Parser Code)) (case meth_def - (#ConstructorMethod strict? type_vars self_name args constructor_args return_expr exs) + {#ConstructorMethod strict? type_vars self_name args constructor_args return_expr exs} (constructor_parser class_name args) - (#StaticMethod strict? type_vars args return_type return_expr exs) + {#StaticMethod strict? type_vars args return_type return_expr exs} (static_method_parser class_name method_name args) - (#VirtualMethod final? strict? type_vars self_name args return_type return_expr exs) + {#VirtualMethod final? strict? type_vars self_name args return_type return_expr exs} (virtual_method_parser class_name method_name args self_name) - (#OverridenMethod strict? owner_class type_vars self_name args return_type return_expr exs) + {#OverridenMethod strict? owner_class type_vars self_name args return_type return_expr exs} (special_method_parser class_name method_name args self_name) - (#AbstractMethod type_vars args return_type exs) + {#AbstractMethod type_vars args return_type exs} (virtual_method_parser class_name method_name args "") - (#NativeMethod type_vars args return_type exs) + {#NativeMethod type_vars args return_type exs} (virtual_method_parser class_name method_name args ""))) (def: privacy_modifier^ @@ -754,14 +754,14 @@ anns ..annotations^ type (..type^ type_vars) body <code>.any] - (in [[name #PublicP anns] (#ConstantField [type body])]))) + (in [[name #PublicP anns] {#ConstantField [type body]}]))) (<code>.form (do <>.monad [pm privacy_modifier^ sm state_modifier^ name <code>.local_identifier anns ..annotations^ type (..type^ type_vars)] - (in [[name pm anns] (#VariableField [sm type])]))))) + (in [[name pm anns] {#VariableField [sm type]}]))))) (def: (argument^ type_vars) (-> (List (Type Var)) (Parser Argument)) @@ -798,7 +798,7 @@ (in [[#member_name constructor_method_name #member_privacy pm #member_anns annotations] - (#ConstructorMethod strict_fp? method_vars self_name arguments constructor_args body exs)])))) + {#ConstructorMethod strict_fp? method_vars self_name arguments constructor_args body exs}])))) (def: (virtual_method_def^ class_vars) (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition])) @@ -819,7 +819,7 @@ (in [[#member_name name #member_privacy pm #member_anns annotations] - (#VirtualMethod final? strict_fp? method_vars self_name arguments return_type body exs)])))) + {#VirtualMethod final? strict_fp? method_vars self_name arguments return_type body exs}])))) (def: overriden_method_def^ (Parser [Member_Declaration Method_Definition]) @@ -840,7 +840,7 @@ (in [[#member_name name #member_privacy #PublicP #member_anns annotations] - (#OverridenMethod strict_fp? owner_class method_vars self_name arguments return_type body exs)])))) + {#OverridenMethod strict_fp? owner_class method_vars self_name arguments return_type body exs}])))) (def: static_method_def^ (Parser [Member_Declaration Method_Definition]) @@ -859,7 +859,7 @@ (in [[#member_name name #member_privacy pm #member_anns annotations] - (#StaticMethod strict_fp? method_vars arguments return_type body exs)])))) + {#StaticMethod strict_fp? method_vars arguments return_type body exs}])))) (def: abstract_method_def^ (Parser [Member_Declaration Method_Definition]) @@ -876,7 +876,7 @@ (in [[#member_name name #member_privacy pm #member_anns annotations] - (#AbstractMethod method_vars arguments return_type exs)])))) + {#AbstractMethod method_vars arguments return_type exs}])))) (def: native_method_def^ (Parser [Member_Declaration Method_Definition]) @@ -893,7 +893,7 @@ (in [[#member_name name #member_privacy pm #member_anns annotations] - (#NativeMethod method_vars arguments return_type exs)])))) + {#NativeMethod method_vars arguments return_type exs}])))) (def: (method_def^ class_vars) (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition])) @@ -938,7 +938,7 @@ (<code>.form (do <>.monad [_ (<code>.this! (' "enum")) enum_members (<>.some <code>.local_identifier)] - (in (#EnumDecl enum_members)))) + (in {#EnumDecl enum_members}))) (<code>.form (do <>.monad [tvars (<>.else (list) ..vars^) _ (<code>.identifier! ["" "new"]) @@ -947,7 +947,7 @@ ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^] - (in (#ConstructorDecl [[#import_member_mode (maybe.else #AutoPrM ?prim_mode) + (in {#ConstructorDecl [[#import_member_mode (maybe.else #AutoPrM ?prim_mode) #import_member_alias (maybe.else "new" ?alias) #import_member_kind #VirtualIMK #import_member_tvars tvars @@ -955,7 +955,7 @@ #import_member_maybe? maybe? #import_member_try? try? #import_member_io? io?] - []])) + []]}) )) (<code>.form (do <>.monad [kind (: (Parser ImportMethodKind) @@ -969,7 +969,7 @@ args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^ return (..return^ total_vars)] - (in (#MethodDecl [[#import_member_mode (maybe.else #AutoPrM ?prim_mode) + (in {#MethodDecl [[#import_member_mode (maybe.else #AutoPrM ?prim_mode) #import_member_alias (maybe.else name ?alias) #import_member_kind kind #import_member_tvars tvars @@ -978,7 +978,7 @@ #import_member_try? try? #import_member_io? io?] [#import_method_name name - #import_method_return return]])))) + #import_method_return return]]}))) (<code>.form (do <>.monad [static? (<>.parses? (<code>.this! (' "static"))) name <code>.local_identifier @@ -986,12 +986,12 @@ gtype (..type^ owner_vars) maybe? (<>.parses? (<code>.this! (' "?"))) setter? (<>.parses? (<code>.this! (' #!)))] - (in (#FieldAccessDecl [#import_field_mode (maybe.else #AutoPrM ?prim_mode) + (in {#FieldAccessDecl [#import_field_mode (maybe.else #AutoPrM ?prim_mode) #import_field_name name #import_field_static? static? #import_field_maybe? maybe? #import_field_setter? setter? - #import_field_type gtype])))) + #import_field_type gtype]}))) )) (def: bundle @@ -1061,14 +1061,14 @@ (def: (field_decl$ [[name pm anns] field]) (-> [Member_Declaration FieldDecl] Code) (case field - (#ConstantField class value) + {#ConstantField class value} (` ("constant" (~ (code.text name)) [(~+ (list\each annotation$ anns))] (~ (value$ class)) (~ value) )) - (#VariableField sm class) + {#VariableField sm class} (` ("variable" (~ (code.text name)) (~ (privacy_modifier$ pm)) (~ (state_modifier$ sm)) @@ -1088,7 +1088,7 @@ (def: (method_def$ fully_qualified_class_name method_parser super_class fields [[name pm anns] method_def]) (-> External (Parser Code) (Type Class) (List [Member_Declaration FieldDecl]) [Member_Declaration Method_Definition] Code) (case method_def - (#ConstructorMethod strict_fp? type_vars self_name arguments constructor_args body exs) + {#ConstructorMethod strict_fp? type_vars self_name arguments constructor_args body exs} (let [replacer (|> (list\each (field->parser fully_qualified_class_name self_name) fields) (list\mix <>.either method_parser) parser->replacer)] @@ -1104,7 +1104,7 @@ (~ (replaced replacer body)) ))) - (#VirtualMethod final? strict_fp? type_vars self_name arguments return_type body exs) + {#VirtualMethod final? strict_fp? type_vars self_name arguments return_type body exs} (let [replacer (|> (list\each (field->parser fully_qualified_class_name self_name) fields) (list\mix <>.either method_parser) parser->replacer)] @@ -1121,7 +1121,7 @@ [(~+ (list\each class$ exs))] (~ (replaced replacer body))))) - (#OverridenMethod strict_fp? declaration type_vars self_name arguments return_type body exs) + {#OverridenMethod strict_fp? declaration type_vars self_name arguments return_type body exs} (let [replacer (|> (list\each (field->parser fully_qualified_class_name self_name) fields) (list\mix <>.either method_parser) parser->replacer) @@ -1150,7 +1150,7 @@ (replaced super_replacer))) ))) - (#StaticMethod strict_fp? type_vars arguments return_type body exs) + {#StaticMethod strict_fp? type_vars arguments return_type body exs} (let [replacer (parser->replacer (<>.failure ""))] (` ("static" (~ (code.text name)) @@ -1163,7 +1163,7 @@ [(~+ (list\each class$ exs))] (~ (replaced replacer body))))) - (#AbstractMethod type_vars arguments return_type exs) + {#AbstractMethod type_vars arguments return_type exs} (` ("abstract" (~ (code.text name)) (~ (privacy_modifier$ pm)) @@ -1173,7 +1173,7 @@ (~ (return$ return_type)) [(~+ (list\each class$ exs))])) - (#NativeMethod type_vars arguments return_type exs) + {#NativeMethod type_vars arguments return_type exs} (` ("native" (~ (code.text name)) (~ (privacy_modifier$ pm)) @@ -1255,12 +1255,12 @@ (in (list (` (let [(~ g!temp) (~ expr)] (if ("jvm object null?" (~ g!temp)) #.None - (#.Some (~ g!temp))))))))) + {#.Some (~ g!temp)}))))))) (syntax: .public (!!! [expr <code>.any]) (with_identifiers [g!value] (in (list (` (.case (~ expr) - (#.Some (~ g!value)) + {#.Some (~ g!value)} (~ g!value) #.None @@ -1273,11 +1273,11 @@ class_type (` (.primitive (~ (code.text class_name)))) check_type (` (.Maybe (~ class_type))) check_code (` (if ("jvm object instance?" (~ (code.text class_name)) (~ g!unchecked)) - (#.Some (.:as (~ class_type) - (~ g!unchecked))) + {#.Some (.:as (~ class_type) + (~ g!unchecked))} #.None))] (case unchecked - (#.Some unchecked) + {#.Some unchecked} (in (list (` (: (~ check_type) (let [(~ g!unchecked) (~ unchecked)] (~ check_code)))))) @@ -1314,10 +1314,10 @@ (def: (member_type_vars class_tvars member) (-> (List (Type Var)) Import_Member_Declaration (List (Type Var))) (case member - (#ConstructorDecl [commons _]) + {#ConstructorDecl [commons _]} (list\composite class_tvars (value@ #import_member_tvars commons)) - (#MethodDecl [commons _]) + {#MethodDecl [commons _]} (case (value@ #import_member_kind commons) #StaticIMK (value@ #import_member_tvars commons) @@ -1331,7 +1331,7 @@ (def: (member_def_arg_bindings vars member) (-> (List (Type Var)) Import_Member_Declaration (Meta [(List [Bit Code]) (List (Type Value)) (List Code)])) (case member - (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) + (^or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) (let [(^slots [#import_member_tvars #import_member_args]) commons] (do [! meta.monad] [arg_inputs (monad.each ! @@ -1356,7 +1356,7 @@ (def: (with_return_maybe member never_null? unboxed return_term) (-> Import_Member_Declaration Bit (Type Value) Code Code) (case member - (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) + (^or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) (cond (or never_null? (dictionary.key? ..boxes unboxed)) return_term @@ -1379,7 +1379,7 @@ [(def: (<name> member return_term) (-> Import_Member_Declaration Code Code) (case member - (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) + (^or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) (if (value@ <tag> commons) <term_trans> return_term) @@ -1420,7 +1420,7 @@ raw) (list)])))) unboxed/boxed (case (dictionary.value unboxed ..boxes) - (#.Some boxed) + {#.Some boxed} (<unbox/box> unboxed boxed refined) #.None @@ -1490,7 +1490,7 @@ (-> (List (Type Var)) Class_Kind (Type Declaration) [(List [Bit Code]) (List (Type Value)) (List Code)] Import_Member_Declaration Text Text (Meta (List Code))) (let [[full_name class_tvars] (parser.declaration class)] (case member - (#EnumDecl enum_members) + {#EnumDecl enum_members} (with_identifiers [g!_] (do meta.monad [.let [enum_type (: Code @@ -1509,7 +1509,7 @@ (~ (get_static_field full_name name)))))))]] (in (list\each getter_interop enum_members)))) - (#ConstructorDecl [commons _]) + {#ConstructorDecl [commons _]} (do meta.monad [.let [classT (type.class full_name (list)) def_name (code.identifier ["" (..import_name import_format method_prefix (value@ #import_member_alias commons))]) @@ -1528,7 +1528,7 @@ (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\each product.right arg_function_inputs)))]) ((~' in) (.list (.` (~ jvm_interop))))))))) - (#MethodDecl [commons method]) + {#MethodDecl [commons method]} (with_identifiers [g!obj] (do meta.monad [.let [def_name (code.identifier ["" (..import_name import_format method_prefix (value@ #import_member_alias commons))]) @@ -1566,7 +1566,7 @@ (list\each ..decorate_input)))))) jvm_interop (: Code (case (type.void? method_return) - (#.Left method_return) + {#.Left method_return} (|> [method_return callC] (with_automatic_output_conversion (value@ #import_member_mode commons)) @@ -1575,7 +1575,7 @@ (with_return_io member)) - (#.Right method_return) + {#.Right method_return} (|> callC (with_return_try member) (with_return_io member))))]] @@ -1583,7 +1583,7 @@ (~+ (syntax_inputs object_ast))]) ((~' in) (.list (.` (~ jvm_interop)))))))))) - (#FieldAccessDecl fad) + {#FieldAccessDecl fad} (do meta.monad [.let [(^open "[0]") fad getter_name (code.identifier ["" (..import_name import_format method_prefix import_field_name)]) @@ -1655,12 +1655,12 @@ (-> (Type Declaration) (Meta Class_Kind)) (let [[class_name _] (parser.declaration declaration)] (case (load_class class_name) - (#.Right class) + {#.Right class} (\ meta.monad in (if (interface? class) #Interface #Class)) - (#.Left _) + {#.Left _} (meta.failure (format "Unknown class: " class_name))))) (syntax: .public (import: [declaration ..declaration^ @@ -1708,7 +1708,7 @@ (if (lux_type\= .Any type) (\ meta.monad in $Object) (case type - (#.Primitive name params) + {#.Primitive name params} (`` (cond (~~ (template [<type>] [(text\= (..reflection <type>) name) (case params @@ -1747,7 +1747,7 @@ (text\= array.type_name name) (case params - (#.Item elementLT #.End) + {#.Item elementLT #.End} (\ meta.monad each type.array (lux_type->jvm_type elementLT)) @@ -1759,7 +1759,7 @@ #.End (let [[_ unprefixed] (maybe.trusted (text.split_by descriptor.array_prefix name))] (\ meta.monad each type.array - (lux_type->jvm_type (#.Primitive unprefixed (list))))) + (lux_type->jvm_type {#.Primitive unprefixed (list)}))) _ <failure>) @@ -1772,22 +1772,22 @@ (do meta.monad [paramJT (lux_type->jvm_type paramLT)] (case (parser.parameter? paramJT) - (#.Some paramJT) + {#.Some paramJT} (in paramJT) #.None <failure>))) params))))) - (#.Apply A F) + {#.Apply A F} (case (lux_type.applied (list A) F) #.None <failure> - (#.Some type') + {#.Some type'} (lux_type->jvm_type type')) - (#.Named _ type') + {#.Named _ type'} (lux_type->jvm_type type') _ @@ -1795,7 +1795,7 @@ (syntax: .public (length [array <code>.any]) (case array - [_ (#.Identifier array_name)] + [_ {#.Identifier array_name}] (do meta.monad [array_type (meta.type array_name) array_jvm_type (lux_type->jvm_type array_type) @@ -1830,7 +1830,7 @@ (syntax: .public (read! [idx <code>.any array <code>.any]) (case array - [_ (#.Identifier array_name)] + [_ {#.Identifier array_name}] (do meta.monad [array_type (meta.type array_name) array_jvm_type (lux_type->jvm_type array_type) @@ -1868,7 +1868,7 @@ value <code>.any array <code>.any]) (case array - [_ (#.Identifier array_name)] + [_ {#.Identifier array_name}] (do meta.monad [array_type (meta.type array_name) array_jvm_type (lux_type->jvm_type array_type) @@ -1918,7 +1918,7 @@ object <code>.any]) (case [(parser.array? type) (parser.class? type)] - (^or [(#.Some _) _] [_ (#.Some _)]) + (^or [{#.Some _} _] [_ {#.Some _}]) (in (list (` (.: (~ (..value_type #ManualPrM type)) ("jvm object cast" (~ object)))))) diff --git a/stdlib/source/library/lux/ffi.lua.lux b/stdlib/source/library/lux/ffi.lua.lux index 91f5b598c..8760b35f0 100644 --- a/stdlib/source/library/lux/ffi.lua.lux +++ b/stdlib/source/library/lux/ffi.lua.lux @@ -91,8 +91,8 @@ (type: Method (Variant - (#Static Static_Method) - (#Virtual Virtual_Method))) + {#Static Static_Method} + {#Virtual Virtual_Method})) (def: common_method (Parser Common_Method) @@ -114,8 +114,8 @@ (type: Member (Variant - (#Field Field) - (#Method Method))) + {#Field Field} + {#Method Method})) (def: member (Parser Member) @@ -140,7 +140,7 @@ (-> Code [Bit Code] Code) (if nilable? (` (case (~ input) - (#.Some (~ g!temp)) + {#.Some (~ g!temp)} (~ g!temp) #.None @@ -153,7 +153,7 @@ (` (let [(~ g!temp) (~ output)] (if ("lua object nil?" (~ g!temp)) #.None - (#.Some (~ g!temp))))) + {#.Some (~ g!temp)}))) (` (let [(~ g!temp) (~ output)] (if (not ("lua object nil?" (~ g!temp))) (~ g!temp) @@ -161,9 +161,9 @@ (type: Import (Variant - (#Class [Text Text (List Member)]) - (#Function Static_Method) - (#Constant Field))) + {#Class [Text Text (List Member)]} + {#Function Static_Method} + {#Constant Field})) (def: import ($_ <>.or @@ -221,7 +221,7 @@ ... (import: (os/getenv [..String] "io" "?" ..String)))} (with_identifiers [g!temp] (case import - (#Class [class format members]) + {#Class [class format members]} (with_identifiers [g!object] (let [qualify (: (-> Text Code) (function (_ member_name) @@ -232,7 +232,7 @@ g!type (code.local_identifier class) real_class (text.replaced "/" "." class) imported (case (text.all_split_by "/" class) - (#.Item head tail) + {#.Item head tail} (list\mix (function (_ sub super) (` ("lua object get" (~ (code.text sub)) (:as (..Object .Any) (~ super))))) @@ -245,7 +245,7 @@ (..Object (primitive (~ (code.text real_class)))))) (list\each (function (_ member) (case member - (#Field [static? field fieldT]) + {#Field [static? field fieldT]} (if static? (` ((~! syntax:) ((~ (qualify field)) []) (\ (~! meta.monad) (~' in) @@ -260,9 +260,9 @@ (~ (without_nil g!temp fieldT (` ("lua object get" (~ (code.text field)) (:as (..Object .Any) (~ g!object)))))))))) - (#Method method) + {#Method method} (case method - (#Static [method alias inputsT io? try? outputT]) + {#Static [method alias inputsT io? try? outputT]} (..make_function (qualify (maybe.else method alias)) g!temp (` ("lua object get" (~ (code.text method)) @@ -272,7 +272,7 @@ try? outputT) - (#Virtual [method alias inputsT io? try? outputT]) + {#Virtual [method alias inputsT io? try? outputT]} (let [g!inputs (input_variables inputsT)] (` (def: ((~ (qualify (maybe.else method alias))) [(~+ (list\each product.right g!inputs))] @@ -292,7 +292,7 @@ (~+ (list\each (with_nil g!temp) g!inputs))))))))))))) members))))) - (#Function [name alias inputsT io? try? outputT]) + {#Function [name alias inputsT io? try? outputT]} (in (list (..make_function (code.local_identifier (maybe.else name alias)) g!temp (` ("lua constant" (~ (code.text (text.replaced "/" "." name))))) @@ -301,7 +301,7 @@ try? outputT))) - (#Constant [_ name fieldT]) + {#Constant [_ name fieldT]} (in (list (` ((~! syntax:) ((~ (code.local_identifier name)) []) (\ (~! meta.monad) (~' in) (list (` (.:as (~ (nilable_type fieldT)) diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index 6e77cb642..ce87fcbec 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -78,10 +78,10 @@ (type: GenericType (Rec GenericType (Variant - (#GenericTypeVar Text) - (#GenericClass [Text (List GenericType)]) - (#GenericArray GenericType) - (#GenericWildcard (Maybe [BoundKind GenericType]))))) + {#GenericTypeVar Text} + {#GenericClass [Text (List GenericType)]} + {#GenericArray GenericType} + {#GenericWildcard (Maybe [BoundKind GenericType])}))) (type: Type_Parameter [Text (List GenericType)]) @@ -147,8 +147,8 @@ (type: FieldDecl (Variant - (#ConstantField GenericType Code) - (#VariableField State GenericType))) + {#ConstantField GenericType Code} + {#VariableField State GenericType})) (type: MethodDecl (Record @@ -167,42 +167,42 @@ (type: Method_Definition (Variant - (#ConstructorMethod [Bit + {#ConstructorMethod [Bit (List Type_Parameter) (List ArgDecl) (List ConstructorArg) Code - (List GenericType)]) - (#VirtualMethod [Bit + (List GenericType)]} + {#VirtualMethod [Bit Bit (List Type_Parameter) Text (List ArgDecl) GenericType Code - (List GenericType)]) - (#OverridenMethod [Bit + (List GenericType)]} + {#OverridenMethod [Bit Class_Declaration (List Type_Parameter) Text (List ArgDecl) GenericType Code - (List GenericType)]) - (#StaticMethod [Bit + (List GenericType)]} + {#StaticMethod [Bit (List Type_Parameter) (List ArgDecl) GenericType Code - (List GenericType)]) - (#AbstractMethod [(List Type_Parameter) + (List GenericType)]} + {#AbstractMethod [(List Type_Parameter) (List ArgDecl) GenericType - (List GenericType)]) - (#NativeMethod [(List Type_Parameter) + (List GenericType)]} + {#NativeMethod [(List Type_Parameter) (List ArgDecl) GenericType - (List GenericType)]))) + (List GenericType)]})) (type: Partial_Call (Record @@ -245,10 +245,10 @@ (type: Import_Member_Declaration (Variant - (#EnumDecl (List Text)) - (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl]) - (#MethodDecl [ImportMethodCommons ImportMethodDecl]) - (#FieldAccessDecl ImportFieldDecl))) + {#EnumDecl (List Text)} + {#ConstructorDecl [ImportMethodCommons ImportConstructorDecl]} + {#MethodDecl [ImportMethodCommons ImportMethodDecl]} + {#FieldAccessDecl ImportFieldDecl})) ... Utils (def: (manual_primitive_type class) @@ -256,7 +256,7 @@ (case class (^template [<prim> <type>] [<prim> - (#.Some (' <type>))]) + {#.Some (' <type>)}]) (["boolean" (primitive "java.lang.Boolean")] ["byte" (primitive "java.lang.Byte")] ["short" (primitive "java.lang.Short")] @@ -275,7 +275,7 @@ (case class (^template [<prim> <type>] [<prim> - (#.Some (' <type>))]) + {#.Some (' <type>)}]) (["boolean" .Bit] ["byte" .Int] ["short" .Int] @@ -300,12 +300,12 @@ (case [name+params mode in_array?] (^multi [[prim #.End] #ManualPrM #0] [(manual_primitive_type prim) - (#.Some output)]) + {#.Some output}]) output (^multi [[prim #.End] #AutoPrM #0] [(auto_primitive_type prim) - (#.Some output)]) + {#.Some output}]) output [[name params] _ _] @@ -316,7 +316,7 @@ (def: (class_type' mode type_params in_array? class) (-> Primitive_Mode (List Type_Parameter) Bit GenericType Code) (case class - (#GenericTypeVar name) + {#GenericTypeVar name} (case (list.example (function (_ [pname pbounds]) (and (text\= name pname) (not (list.empty? pbounds)))) @@ -324,21 +324,21 @@ #.None (code.identifier ["" name]) - (#.Some [pname pbounds]) + {#.Some [pname pbounds]} (class_type' mode type_params in_array? (maybe.trusted (list.head pbounds)))) - (#GenericClass name+params) + {#GenericClass name+params} (generic_class_type' mode type_params in_array? name+params class_type') - (#GenericArray param) + {#GenericArray param} (let [=param (class_type' mode type_params #1 param)] (` ((~! array.Array) (~ =param)))) - (^or (#GenericWildcard #.None) (#GenericWildcard (#.Some [#LowerBound _]))) + (^or {#GenericWildcard #.None} {#GenericWildcard {#.Some [#LowerBound _]}}) (` .Any) - (#GenericWildcard (#.Some [#UpperBound upper_bound])) + {#GenericWildcard {#.Some [#UpperBound upper_bound]}} (class_type' mode type_params in_array? upper_bound) )) @@ -358,7 +358,7 @@ #.End (code.identifier ["" pname]) - (#.Item bound1 _) + {#.Item bound1 _} (class_type #ManualPrM class_params bound1)))) class_params)] (` (primitive (~ (code.text (safe class_name))) @@ -369,7 +369,7 @@ (def: (simple_class$ env class) (-> (List Type_Parameter) GenericType Text) (case class - (#GenericTypeVar name) + {#GenericTypeVar name} (case (list.example (function (_ [pname pbounds]) (and (text\= name pname) (not (list.empty? pbounds)))) @@ -377,25 +377,25 @@ #.None type_var_class - (#.Some [pname pbounds]) + {#.Some [pname pbounds]} (simple_class$ env (maybe.trusted (list.head pbounds)))) - (^or (#GenericWildcard #.None) (#GenericWildcard (#.Some [#LowerBound _]))) + (^or {#GenericWildcard #.None} {#GenericWildcard {#.Some [#LowerBound _]}}) type_var_class - (#GenericWildcard (#.Some [#UpperBound upper_bound])) + {#GenericWildcard {#.Some [#UpperBound upper_bound]}} (simple_class$ env upper_bound) - (#GenericClass name env) + {#GenericClass name env} (safe name) - (#GenericArray param') + {#GenericArray param'} (case param' - (#GenericArray param) + {#GenericArray param} (format "[" (simple_class$ env param)) (^template [<prim> <class>] - [(#GenericClass <prim> #.End) + [{#GenericClass <prim> #.End} <class>]) (["boolean" "[Z"] ["byte" "[B"] @@ -436,8 +436,8 @@ (-> (-> Code Code) Code Code) (case (f input) (^template [<tag>] - [[meta (<tag> parts)] - [meta (<tag> (list\each (pre_walk_replace f) parts))]]) + [[meta {<tag> parts}] + [meta {<tag> (list\each (pre_walk_replace f) parts)}]]) ([#.Form] [#.Variant] [#.Tuple]) @@ -448,7 +448,7 @@ (def: (parser_replacer p ast) (-> (Parser Code) (-> Code Code)) (case (<>.result p (list ast)) - (#.Right [#.End ast']) + {#.Right [#.End ast']} ast' _ @@ -458,10 +458,10 @@ (def: (field_parser class_name [[field_name _ _] field]) (-> Text [Member_Declaration FieldDecl] (Parser Code)) (case field - (#ConstantField _) + {#ConstantField _} (get_const_parser class_name field_name) - (#VariableField _) + {#VariableField _} (<>.either (get_var_parser class_name field_name) (put_var_parser class_name field_name)))) @@ -505,20 +505,20 @@ (def: (method_parser params class_name [[method_name _ _] meth_def]) (-> (List Type_Parameter) Text [Member_Declaration Method_Definition] (Parser Code)) (case meth_def - (#ConstructorMethod strict? type_vars args constructor_args return_expr exs) + {#ConstructorMethod strict? type_vars args constructor_args return_expr exs} (constructor_parser params class_name args) - (#StaticMethod strict? type_vars args return_type return_expr exs) + {#StaticMethod strict? type_vars args return_type return_expr exs} (static_method_parser params class_name method_name args) - (^or (#VirtualMethod final? strict? type_vars self_name args return_type return_expr exs) - (#OverridenMethod strict? owner_class type_vars self_name args return_type return_expr exs)) + (^or {#VirtualMethod final? strict? type_vars self_name args return_type return_expr exs} + {#OverridenMethod strict? owner_class type_vars self_name args return_type return_expr exs}) (special_method_parser params class_name method_name args) - (#AbstractMethod type_vars args return_type exs) + {#AbstractMethod type_vars args return_type exs} (virtual_method_parser params class_name method_name args) - (#NativeMethod type_vars args return_type exs) + {#NativeMethod type_vars args return_type exs} (virtual_method_parser params class_name method_name args))) ... Parsers @@ -556,24 +556,24 @@ ($_ <>.either (do <>.monad [_ (<code>.this! (' ?))] - (in (#GenericWildcard #.None))) + (in {#GenericWildcard #.None})) (<code>.tuple (do <>.monad [_ (<code>.this! (' ?)) bound_kind bound_kind^ bound recur^] - (in (#GenericWildcard (#.Some [bound_kind bound]))))) + (in {#GenericWildcard {#.Some [bound_kind bound]}}))) (do <>.monad [name <code>.local_identifier _ (no_periods_assertion name)] (if (list.member? text.equivalence (list\each product.left type_vars) name) - (in (#GenericTypeVar name)) - (in (#GenericClass name (list))))) + (in {#GenericTypeVar name}) + (in {#GenericClass name (list)}))) (<code>.tuple (do <>.monad [component recur^] (case component (^template [<class> <name>] - [(#GenericClass <name> #.End) - (in (#GenericClass <class> (list)))]) + [{#GenericClass <name> #.End} + (in {#GenericClass <class> (list)})]) (["[Z" "boolean"] ["[B" "byte"] ["[S" "short"] @@ -584,14 +584,14 @@ ["[C" "char"]) _ - (in (#GenericArray component))))) + (in {#GenericArray component})))) (<code>.form (do <>.monad [name <code>.local_identifier _ (no_periods_assertion name) params (<>.some recur^) _ (<>.assertion (format name " cannot be a type-parameter!") (not (list.member? text.equivalence (list\each product.left type_vars) name)))] - (in (#GenericClass name params)))) + (in {#GenericClass name params}))) )))) (def: type_param^ @@ -702,14 +702,14 @@ anns ..annotations^ type (..generic_type^ type_vars) body <code>.any] - (in [[name #PublicP anns] (#ConstantField [type body])]))) + (in [[name #PublicP anns] {#ConstantField [type body]}]))) (<code>.form (do <>.monad [pm privacy_modifier^ sm state_modifier^ name <code>.local_identifier anns ..annotations^ type (..generic_type^ type_vars)] - (in [[name pm anns] (#VariableField [sm type])]))))) + (in [[name pm anns] {#VariableField [sm type]}]))))) (def: (arg_decl^ type_vars) (-> (List Type_Parameter) (Parser ArgDecl)) @@ -744,7 +744,7 @@ (in [[#member_name constructor_method_name #member_privacy pm #member_anns annotations] - (#ConstructorMethod strict_fp? method_vars arg_decls constructor_args body exs)])))) + {#ConstructorMethod strict_fp? method_vars arg_decls constructor_args body exs}])))) (def: (virtual_method_def^ class_vars) (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition])) @@ -765,10 +765,10 @@ (in [[#member_name name #member_privacy pm #member_anns annotations] - (#VirtualMethod final? strict_fp? - method_vars - this_name arg_decls return_type - body exs)])))) + {#VirtualMethod final? strict_fp? + method_vars + this_name arg_decls return_type + body exs}])))) (def: overriden_method_def^ (Parser [Member_Declaration Method_Definition]) @@ -788,10 +788,10 @@ (in [[#member_name name #member_privacy #PublicP #member_anns annotations] - (#OverridenMethod strict_fp? - owner_class method_vars - this_name arg_decls return_type - body exs)])))) + {#OverridenMethod strict_fp? + owner_class method_vars + this_name arg_decls return_type + body exs}])))) (def: static_method_def^ (Parser [Member_Declaration Method_Definition]) @@ -810,7 +810,7 @@ (in [[#member_name name #member_privacy pm #member_anns annotations] - (#StaticMethod strict_fp? method_vars arg_decls return_type body exs)])))) + {#StaticMethod strict_fp? method_vars arg_decls return_type body exs}])))) (def: abstract_method_def^ (Parser [Member_Declaration Method_Definition]) @@ -827,7 +827,7 @@ (in [[#member_name name #member_privacy pm #member_anns annotations] - (#AbstractMethod method_vars arg_decls return_type exs)])))) + {#AbstractMethod method_vars arg_decls return_type exs}])))) (def: native_method_def^ (Parser [Member_Declaration Method_Definition]) @@ -844,7 +844,7 @@ (in [[#member_name name #member_privacy pm #member_anns annotations] - (#NativeMethod method_vars arg_decls return_type exs)])))) + {#NativeMethod method_vars arg_decls return_type exs}])))) (def: (method_def^ class_vars) (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition])) @@ -885,7 +885,7 @@ (<code>.form (do <>.monad [_ (<code>.this! (' "enum")) enum_members (<>.some <code>.local_identifier)] - (in (#EnumDecl enum_members)))) + (in {#EnumDecl enum_members}))) (<code>.form (do <>.monad [tvars ..type_params^ _ (<code>.this! (' new)) @@ -894,7 +894,7 @@ ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^] - (in (#ConstructorDecl [[#import_member_mode (maybe.else #AutoPrM ?prim_mode) + (in {#ConstructorDecl [[#import_member_mode (maybe.else #AutoPrM ?prim_mode) #import_member_alias (maybe.else "new" ?alias) #import_member_kind #VirtualIMK #import_member_tvars tvars @@ -902,7 +902,7 @@ #import_member_maybe? maybe? #import_member_try? try? #import_member_io? io?] - []])))) + []]}))) (<code>.form (do <>.monad [kind (: (Parser ImportMethodKind) (<>.or (<code>.this! (' "static")) @@ -915,7 +915,7 @@ args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^ return (..generic_type^ total_vars)] - (in (#MethodDecl [[#import_member_mode (maybe.else #AutoPrM ?prim_mode) + (in {#MethodDecl [[#import_member_mode (maybe.else #AutoPrM ?prim_mode) #import_member_alias (maybe.else name ?alias) #import_member_kind kind #import_member_tvars tvars @@ -924,7 +924,7 @@ #import_member_try? try? #import_member_io? io?] [#import_method_name name - #import_method_return return]])))) + #import_method_return return]]}))) (<code>.form (do <>.monad [static? (<>.parses? (<code>.this! (' "static"))) name <code>.local_identifier @@ -932,12 +932,12 @@ gtype (..generic_type^ owner_vars) maybe? (<>.parses? (<code>.this! (' "?"))) setter? (<>.parses? (<code>.this! (' #!)))] - (in (#FieldAccessDecl [#import_field_mode (maybe.else #AutoPrM ?prim_mode) + (in {#FieldAccessDecl [#import_field_mode (maybe.else #AutoPrM ?prim_mode) #import_field_name name #import_field_static? static? #import_field_maybe? maybe? #import_field_setter? setter? - #import_field_type gtype])))) + #import_field_type gtype]}))) )) (def: bundle @@ -992,19 +992,19 @@ (def: (generic_type$ gtype) (-> GenericType JVM_Code) (case gtype - (#GenericTypeVar name) + {#GenericTypeVar name} name - (#GenericClass name params) + {#GenericClass name params} (format "(" (safe name) " " (spaced (list\each generic_type$ params)) ")") - (#GenericArray param) + {#GenericArray param} (format "(" array.type_name " " (generic_type$ param) ")") - (#GenericWildcard #.None) + {#GenericWildcard #.None} "?" - (#GenericWildcard (#.Some [bound_kind bound])) + {#GenericWildcard {#.Some [bound_kind bound]}} (format (bound_kind$ bound_kind) (generic_type$ bound)))) (def: (type_param$ [name bounds]) @@ -1041,7 +1041,7 @@ (def: (field_decl$ [[name pm anns] field]) (-> [Member_Declaration FieldDecl] JVM_Code) (case field - (#ConstantField class value) + {#ConstantField class value} (with_parens (spaced (list "constant" name (with_brackets (spaced (list\each annotation$ anns))) @@ -1049,7 +1049,7 @@ (code.format value)) )) - (#VariableField sm class) + {#VariableField sm class} (with_parens (spaced (list "variable" name (privacy_modifier$ pm) @@ -1072,7 +1072,7 @@ (def: (method_def$ replacer super_class [[name pm anns] method_def]) (-> (-> Code Code) Super_Class_Decl [Member_Declaration Method_Definition] JVM_Code) (case method_def - (#ConstructorMethod strict_fp? type_vars arg_decls constructor_args body exs) + {#ConstructorMethod strict_fp? type_vars arg_decls constructor_args body exs} (with_parens (spaced (list "init" (privacy_modifier$ pm) @@ -1085,7 +1085,7 @@ (code.format (pre_walk_replace replacer body)) ))) - (#VirtualMethod final? strict_fp? type_vars this_name arg_decls return_type body exs) + {#VirtualMethod final? strict_fp? type_vars this_name arg_decls return_type body exs} (with_parens (spaced (list "virtual" name @@ -1100,7 +1100,7 @@ (code.format (pre_walk_replace replacer (` (let [(~ (code.local_identifier this_name)) (~' _jvm_this)] (~ body)))))))) - (#OverridenMethod strict_fp? class_decl type_vars this_name arg_decls return_type body exs) + {#OverridenMethod strict_fp? class_decl type_vars this_name arg_decls return_type body exs} (let [super_replacer (parser_replacer (<code>.form (do <>.monad [_ (<code>.this! (' ::super!)) args (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any)) @@ -1128,7 +1128,7 @@ (code.format)) )))) - (#StaticMethod strict_fp? type_vars arg_decls return_type body exs) + {#StaticMethod strict_fp? type_vars arg_decls return_type body exs} (with_parens (spaced (list "static" name @@ -1141,7 +1141,7 @@ (generic_type$ return_type) (code.format (pre_walk_replace replacer body))))) - (#AbstractMethod type_vars arg_decls return_type exs) + {#AbstractMethod type_vars arg_decls return_type exs} (with_parens (spaced (list "abstract" name @@ -1152,7 +1152,7 @@ (with_brackets (spaced (list\each arg_decl$ arg_decls))) (generic_type$ return_type)))) - (#NativeMethod type_vars arg_decls return_type exs) + {#NativeMethod type_vars arg_decls return_type exs} (with_parens (spaced (list "native" name @@ -1242,12 +1242,12 @@ (in (list (` (let [(~ g!temp) (~ expr)] (if ("jvm object null?" (~ g!temp)) #.None - (#.Some (~ g!temp))))))))) + {#.Some (~ g!temp)}))))))) (syntax: .public (!!! [expr <code>.any]) (with_identifiers [g!value] (in (list (` (.case (~ expr) - (#.Some (~ g!value)) + {#.Some (~ g!value)} (~ g!value) #.None @@ -1260,11 +1260,11 @@ class_type (` (.primitive (~ (code.text class_name)))) check_type (` (.Maybe (~ class_type))) check_code (` (if ((~ (code.text (format "jvm instanceof" ":" class_name))) (~ g!unchecked)) - (#.Some (.:as (~ class_type) - (~ g!unchecked))) + {#.Some (.:as (~ class_type) + (~ g!unchecked))} #.None))] (case unchecked - (#.Some unchecked) + {#.Some unchecked} (in (list (` (: (~ check_type) (let [(~ g!unchecked) (~ unchecked)] (~ check_code)))))) @@ -1299,10 +1299,10 @@ (def: (member_type_vars class_tvars member) (-> (List Type_Parameter) Import_Member_Declaration (List Type_Parameter)) (case member - (#ConstructorDecl [commons _]) + {#ConstructorDecl [commons _]} (list\composite class_tvars (value@ #import_member_tvars commons)) - (#MethodDecl [commons _]) + {#MethodDecl [commons _]} (case (value@ #import_member_kind commons) #StaticIMK (value@ #import_member_tvars commons) @@ -1316,7 +1316,7 @@ (def: (member_def_arg_bindings type_params class member) (-> (List Type_Parameter) Class_Declaration Import_Member_Declaration (Meta [(List [Bit Code]) (List Text) (List Code)])) (case member - (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) + (^or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) (let [(^slots [#import_member_tvars #import_member_args]) commons] (do [! meta.monad] [arg_inputs (monad.each ! @@ -1343,7 +1343,7 @@ (def: (decorate_return_maybe class member return_term) (-> Class_Declaration Import_Member_Declaration Code Code) (case member - (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) + (^or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) (if (value@ #import_member_maybe? commons) (` (??? (~ return_term))) (let [g!temp (` ((~' ~') (~ (code.identifier ["" " Ω "]))))] @@ -1362,7 +1362,7 @@ [(def: (<name> member return_term) (-> Import_Member_Declaration Code Code) (case member - (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _])) + (^or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) (if (value@ <tag> commons) <term_trans> return_term) @@ -1437,7 +1437,7 @@ (list.only free_type_param?) (list\each lux_type_parameter))] (case member - (#EnumDecl enum_members) + {#EnumDecl enum_members} (macro.with_identifiers [g!_] (do [! meta.monad] [.let [enum_type (: Code @@ -1458,7 +1458,7 @@ ((~ (code.text (format "jvm getstatic" ":" full_name ":" name)))))))))]] (in (list\each getter_interop enum_members)))) - (#ConstructorDecl [commons _]) + {#ConstructorDecl [commons _]} (do meta.monad [.let [def_name (code.identifier ["" (..import_name import_format method_prefix (value@ #import_member_alias commons))]) jvm_extension (code.text (format "jvm new" ":" full_name ":" (text.interposed "," arg_classes))) @@ -1470,7 +1470,7 @@ (in (list (` ((~! syntax:) ((~ def_name) [(~+ (syntax_inputs (list\each product.right arg_function_inputs)))]) ((~' in) (.list (.` (~ jvm_interop))))))))) - (#MethodDecl [commons method]) + {#MethodDecl [commons method]} (with_identifiers [g!obj] (do meta.monad [.let [def_name (code.identifier ["" (..import_name import_format method_prefix (value@ #import_member_alias commons))]) @@ -1504,7 +1504,7 @@ (~+ (syntax_inputs object_ast))]) ((~' in) (.list (.` (~ jvm_interop)))))))))) - (#FieldAccessDecl fad) + {#FieldAccessDecl fad} (do meta.monad [.let [(^open "[0]") fad base_gtype (class_type import_field_mode type_params import_field_type) @@ -1583,12 +1583,12 @@ (-> Class_Declaration (Meta Class_Kind)) (let [class_name (..safe class_name)] (case (..load_class class_name) - (#try.Success class) + {#try.Success class} (\ meta.monad in (if (interface? class) #Interface #Class)) - (#try.Failure error) + {#try.Failure error} (meta.failure (format "Cannot load class: " class_name text.new_line error))))) @@ -1607,7 +1607,7 @@ size <code>.any]) (case type (^template [<type> <array_op>] - [(^ (#GenericClass <type> (list))) + [(^ {#GenericClass <type> (list)}) (in (list (` (<array_op> (~ size)))))]) (["boolean" "jvm znewarray"] ["byte" "jvm bnewarray"] @@ -1629,18 +1629,18 @@ (if (type\= Any type) (\ meta.monad in "java.lang.Object") (case type - (#.Primitive name params) + {#.Primitive name params} (\ meta.monad in name) - (#.Apply A F) + {#.Apply A F} (case (type.applied (list A) F) #.None (meta.failure (format "Cannot apply type: " (type.format F) " to " (type.format A))) - (#.Some type') + {#.Some type'} (type_class_name type')) - (#.Named _ type') + {#.Named _ type'} (type_class_name type') _ @@ -1649,7 +1649,7 @@ (syntax: .public (read! [idx <code>.any array <code>.any]) (case array - [_ (#.Identifier array_name)] + [_ {#.Identifier array_name}] (do meta.monad [array_type (meta.type array_name) array_jvm_type (type_class_name array_type)] @@ -1678,7 +1678,7 @@ value <code>.any array <code>.any]) (case array - [_ (#.Identifier array_name)] + [_ {#.Identifier array_name}] (do meta.monad [array_type (meta.type array_name) array_jvm_type (type_class_name array_type)] diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux index 78d75f269..ae8e4b347 100644 --- a/stdlib/source/library/lux/ffi.php.lux +++ b/stdlib/source/library/lux/ffi.php.lux @@ -99,8 +99,8 @@ (type: Method (Variant - (#Static Static_Method) - (#Virtual Virtual_Method))) + {#Static Static_Method} + {#Virtual Virtual_Method})) (def: common_method (Parser Common_Method) @@ -122,8 +122,8 @@ (type: Member (Variant - (#Field Field) - (#Method Method))) + {#Field Field} + {#Method Method})) (def: member (Parser Member) @@ -148,7 +148,7 @@ (-> Code [Bit Code] Code) (if nullable? (` (case (~ input) - (#.Some (~ g!temp)) + {#.Some (~ g!temp)} (~ g!temp) #.Null @@ -161,7 +161,7 @@ (` (let [(~ g!temp) (~ output)] (if ("php object null?" (~ g!temp)) #.None - (#.Some (~ g!temp))))) + {#.Some (~ g!temp)}))) (` (let [(~ g!temp) (~ output)] (if (not ("php object null?" (~ g!temp))) (~ g!temp) @@ -169,9 +169,9 @@ (type: Import (Variant - (#Class Text (Maybe Alias) Text (List Member)) - (#Function Static_Method) - (#Constant Field))) + {#Class Text (Maybe Alias) Text (List Member)} + {#Function Static_Method} + {#Constant Field})) (def: import (Parser Import) @@ -188,10 +188,10 @@ (syntax: .public (try [expression <code>.any]) ... {#.doc (example (case (try (risky_computation input)) - ... (#.Right success) + ... {#.Right success} ... (do_something success) - ... (#.Left error) + ... {#.Left error} ... (recover_from_failure error)))} (in (list (` ("lux try" ((~! io.io) (~ expression))))))) @@ -239,7 +239,7 @@ (syntax: .public (import: [import ..import]) (with_identifiers [g!temp] (case import - (#Class [class alias format members]) + {#Class [class alias format members]} (with_identifiers [g!object] (let [qualify (: (-> Text Code) (function (_ member_name) @@ -253,7 +253,7 @@ (..Object (primitive (~ (code.text class)))))) (list\each (function (_ member) (case member - (#Field [static? field alias fieldT]) + {#Field [static? field alias fieldT]} (if static? (` ((~! syntax:) ((~ (qualify (maybe.else field alias))) []) (\ (~! meta.monad) (~' in) @@ -267,9 +267,9 @@ (~ (without_null g!temp fieldT (` ("php object get" (~ (code.text field)) (:as (..Object .Any) (~ g!object)))))))))) - (#Method method) + {#Method method} (case method - (#Static [method alias inputsT io? try? outputT]) + {#Static [method alias inputsT io? try? outputT]} (..make_function (qualify (maybe.else method alias)) g!temp (` ("php object get" (~ (code.text method)) @@ -280,7 +280,7 @@ try? outputT) - (#Virtual [method alias inputsT io? try? outputT]) + {#Virtual [method alias inputsT io? try? outputT]} (let [g!inputs (input_variables inputsT)] (` (def: ((~ (qualify (maybe.else method alias))) [(~+ (list\each product.right g!inputs))] @@ -300,7 +300,7 @@ (~+ (list\each (with_null g!temp) g!inputs))))))))))))) members))))) - (#Function [name alias inputsT io? try? outputT]) + {#Function [name alias inputsT io? try? outputT]} (let [imported (` ("php constant" (~ (code.text name))))] (in (list (..make_function (code.local_identifier (maybe.else name alias)) g!temp @@ -310,7 +310,7 @@ try? outputT)))) - (#Constant [_ name alias fieldT]) + {#Constant [_ name alias fieldT]} (let [imported (` ("php constant" (~ (code.text name))))] (in (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.else name alias))) []) (\ (~! meta.monad) (~' in) diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux index d5f1e23a2..ccee694ae 100644 --- a/stdlib/source/library/lux/ffi.py.lux +++ b/stdlib/source/library/lux/ffi.py.lux @@ -92,8 +92,8 @@ (type: Method (Variant - (#Static Static_Method) - (#Virtual Virtual_Method))) + {#Static Static_Method} + {#Virtual Virtual_Method})) (def: common_method (Parser Common_Method) @@ -115,9 +115,9 @@ (type: Member (Variant - (#Constructor Constructor) - (#Field Field) - (#Method Method))) + {#Constructor Constructor} + {#Field Field} + {#Method Method})) (def: member (Parser Member) @@ -143,7 +143,7 @@ (-> Code [Bit Code] Code) (if noneable? (` (case (~ input) - (#.Some (~ g!temp)) + {#.Some (~ g!temp)} (~ g!temp) #.None @@ -156,7 +156,7 @@ (` (let [(~ g!temp) (~ output)] (if ("python object none?" (~ g!temp)) #.None - (#.Some (~ g!temp))))) + {#.Some (~ g!temp)}))) (` (let [(~ g!temp) (~ output)] (if (not ("python object none?" (~ g!temp))) (~ g!temp) @@ -164,8 +164,8 @@ (type: Import (Variant - (#Class [Text Text (List Member)]) - (#Function Static_Method))) + {#Class [Text Text (List Member)]} + {#Function Static_Method})) (def: import (Parser Import) @@ -241,7 +241,7 @@ ... ("static" getmtime [..String] "io" "try" ..Float)]))} (with_identifiers [g!temp] (case import - (#Class [class format members]) + {#Class [class format members]} (with_identifiers [g!object] (let [qualify (: (-> Text Code) (function (_ member_name) @@ -252,7 +252,7 @@ g!type (code.local_identifier class) real_class (text.replaced "/" "." class) imported (case (text.all_split_by "/" class) - (#.Item head tail) + {#.Item head tail} (list\mix (function (_ sub super) (` ("python object get" (~ (code.text sub)) (:as (..Object .Any) (~ super))))) @@ -265,7 +265,7 @@ (..Object (primitive (~ (code.text real_class)))))) (list\each (function (_ member) (case member - (#Constructor inputsT) + {#Constructor inputsT} (let [g!inputs (input_variables inputsT)] (` (def: ((~ (qualify "new")) [(~+ (list\each product.right g!inputs))]) @@ -276,7 +276,7 @@ (:as ..Function (~ imported)) (~+ (list\each (with_none g!temp) g!inputs))))))) - (#Field [static? field fieldT]) + {#Field [static? field fieldT]} (if static? (` ((~! syntax:) ((~ (qualify field)) []) (\ (~! meta.monad) (~' in) @@ -291,9 +291,9 @@ (~ (without_none g!temp fieldT (` ("python object get" (~ (code.text field)) (:as (..Object .Any) (~ g!object)))))))))) - (#Method method) + {#Method method} (case method - (#Static [method alias inputsT io? try? outputT]) + {#Static [method alias inputsT io? try? outputT]} (..make_function (qualify (maybe.else method alias)) g!temp (` ("python object get" (~ (code.text method)) @@ -303,7 +303,7 @@ try? outputT) - (#Virtual [method alias inputsT io? try? outputT]) + {#Virtual [method alias inputsT io? try? outputT]} (let [g!inputs (input_variables inputsT)] (` (def: ((~ (qualify (maybe.else method alias))) [(~+ (list\each product.right g!inputs))] @@ -323,7 +323,7 @@ (~+ (list\each (with_none g!temp) g!inputs))))))))))))) members))))) - (#Function [name alias inputsT io? try? outputT]) + {#Function [name alias inputsT io? try? outputT]} (in (list (..make_function (code.local_identifier (maybe.else name alias)) g!temp (` ("python constant" (~ (code.text name)))) diff --git a/stdlib/source/library/lux/ffi.rb.lux b/stdlib/source/library/lux/ffi.rb.lux index 62620c6af..c2d06bb78 100644 --- a/stdlib/source/library/lux/ffi.rb.lux +++ b/stdlib/source/library/lux/ffi.rb.lux @@ -99,8 +99,8 @@ (type: Method (Variant - (#Static Static_Method) - (#Virtual Virtual_Method))) + {#Static Static_Method} + {#Virtual Virtual_Method})) (def: common_method (Parser Common_Method) @@ -122,8 +122,8 @@ (type: Member (Variant - (#Field Field) - (#Method Method))) + {#Field Field} + {#Method Method})) (def: member (Parser Member) @@ -148,7 +148,7 @@ (-> Code [Bit Code] Code) (if nilable? (` (case (~ input) - (#.Some (~ g!temp)) + {#.Some (~ g!temp)} (~ g!temp) #.None @@ -161,7 +161,7 @@ (` (let [(~ g!temp) (~ output)] (if ("ruby object nil?" (~ g!temp)) #.None - (#.Some (~ g!temp))))) + {#.Some (~ g!temp)}))) (` (let [(~ g!temp) (~ output)] (if (not ("ruby object nil?" (~ g!temp))) (~ g!temp) @@ -169,9 +169,9 @@ (type: Import (Variant - (#Class Text (Maybe Alias) Text (List Member)) - (#Function Static_Method) - (#Constant Field))) + {#Class Text (Maybe Alias) Text (List Member)} + {#Function Static_Method} + {#Constant Field})) (def: import (Parser [(Maybe Text) Import]) @@ -232,7 +232,7 @@ (syntax: .public (import: [[?module import] ..import]) (with_identifiers [g!temp] (case import - (#Class [class alias format members]) + {#Class [class alias format members]} (with_identifiers [g!object] (let [qualify (: (-> Text Code) (function (_ member_name) @@ -243,7 +243,7 @@ g!type (code.local_identifier (maybe.else class alias)) module_import (: (List Code) (case ?module - (#.Some module) + {#.Some module} (list (` ("ruby import" (~ (code.text module))))) #.None @@ -253,7 +253,7 @@ (..Object (primitive (~ (code.text class)))))) (list\each (function (_ member) (case member - (#Field [static? field alias fieldT]) + {#Field [static? field alias fieldT]} (if static? (` ((~! syntax:) ((~ (qualify (maybe.else field alias))) []) (\ (~! meta.monad) (~' in) @@ -269,9 +269,9 @@ (~ (without_nil g!temp fieldT (` ("ruby object get" (~ (code.text field)) (:as (..Object .Any) (~ g!object)))))))))) - (#Method method) + {#Method method} (case method - (#Static [method alias inputsT io? try? outputT]) + {#Static [method alias inputsT io? try? outputT]} (..make_function (qualify (maybe.else method alias)) g!temp (` ("ruby object get" (~ (code.text method)) @@ -284,7 +284,7 @@ try? outputT) - (#Virtual [method alias inputsT io? try? outputT]) + {#Virtual [method alias inputsT io? try? outputT]} (let [g!inputs (input_variables inputsT)] (` (def: ((~ (qualify (maybe.else method alias))) [(~+ (list\each product.right g!inputs))] @@ -304,10 +304,10 @@ (~+ (list\each (with_nil g!temp) g!inputs))))))))))))) members))))) - (#Function [name alias inputsT io? try? outputT]) + {#Function [name alias inputsT io? try? outputT]} (let [imported (` (.exec (~+ (case ?module - (#.Some module) + {#.Some module} (list (` ("ruby import" (~ (code.text module))))) #.None @@ -321,10 +321,10 @@ try? outputT)))) - (#Constant [_ name alias fieldT]) + {#Constant [_ name alias fieldT]} (let [imported (` (.exec (~+ (case ?module - (#.Some module) + {#.Some module} (list (` ("ruby import" (~ (code.text module))))) #.None diff --git a/stdlib/source/library/lux/ffi.scm.lux b/stdlib/source/library/lux/ffi.scm.lux index 0862942c1..18800df0a 100644 --- a/stdlib/source/library/lux/ffi.scm.lux +++ b/stdlib/source/library/lux/ffi.scm.lux @@ -120,7 +120,7 @@ (-> Code [Bit Code] Code) (if nilable? (` (case (~ input) - (#.Some (~ g!temp)) + {#.Some (~ g!temp)} (~ g!temp) #.None @@ -133,7 +133,7 @@ (` (let [(~ g!temp) (~ output)] (if ("scheme object nil?" (~ g!temp)) #.None - (#.Some (~ g!temp))))) + {#.Some (~ g!temp)}))) (` (let [(~ g!temp) (~ output)] (if (not ("scheme object nil?" (~ g!temp))) (~ g!temp) @@ -141,8 +141,8 @@ (type: Import (Variant - (#Function Common_Method) - (#Constant Field))) + {#Function Common_Method} + {#Constant Field})) (def: import (Parser Import) @@ -153,10 +153,10 @@ (syntax: .public (try [expression <code>.any]) ... {#.doc (example (case (try (risky_computation input)) - ... (#.Right success) + ... {#.Right success} ... (do_something success) - ... (#.Left error) + ... {#.Left error} ... (recover_from_failure error)))} (in (list (` ("lux try" ((~! io.io) (~ expression))))))) @@ -204,7 +204,7 @@ (syntax: .public (import: [import ..import]) (with_identifiers [g!temp] (case import - (#Function [name alias inputsT io? try? outputT]) + {#Function [name alias inputsT io? try? outputT]} (let [imported (` ("scheme constant" (~ (code.text name))))] (in (list (..make_function (code.local_identifier (maybe.else name alias)) g!temp @@ -214,7 +214,7 @@ try? outputT)))) - (#Constant [_ name alias fieldT]) + {#Constant [_ name alias fieldT]} (let [imported (` ("scheme constant" (~ (code.text name))))] (in (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.else name alias)))) (\ (~! meta.monad) (~' in) diff --git a/stdlib/source/library/lux/macro.lux b/stdlib/source/library/lux/macro.lux index 46d2ada34..5962e36fa 100644 --- a/stdlib/source/library/lux/macro.lux +++ b/stdlib/source/library/lux/macro.lux @@ -21,11 +21,11 @@ (def: .public (single_expansion syntax) (-> Code (Meta (List Code))) (case syntax - [_ (#.Form (#.Item [[_ (#.Identifier name)] args]))] + [_ {#.Form {#.Item [[_ {#.Identifier name}] args]}}] (do //.monad [?macro (//.macro name)] (case ?macro - (#.Some macro) + {#.Some macro} ((:as Macro' macro) args) #.None @@ -37,11 +37,11 @@ (def: .public (expansion syntax) (-> Code (Meta (List Code))) (case syntax - [_ (#.Form (#.Item [[_ (#.Identifier name)] args]))] + [_ {#.Form {#.Item [[_ {#.Identifier name}] args]}}] (do //.monad [?macro (//.macro name)] (case ?macro - (#.Some macro) + {#.Some macro} (do [! //.monad] [top_level_expansion ((:as Macro' macro) args)] (|> top_level_expansion @@ -57,11 +57,11 @@ (def: .public (full_expansion syntax) (-> Code (Meta (List Code))) (case syntax - [_ (#.Form (#.Item [[_ (#.Identifier name)] args]))] + [_ {#.Form {#.Item [[_ {#.Identifier name}] args]}}] (do //.monad [?macro (//.macro name)] (case ?macro - (#.Some macro) + {#.Some macro} (do //.monad [expansion ((:as Macro' macro) args) expansion' (monad.each //.monad full_expansion expansion)] @@ -72,18 +72,18 @@ [parts' (monad.each //.monad full_expansion (list& (code.identifier name) args))] (in (list (code.form (list\conjoint parts'))))))) - [_ (#.Form (#.Item [harg targs]))] + [_ {#.Form {#.Item [harg targs]}}] (do //.monad [harg+ (full_expansion harg) targs+ (monad.each //.monad full_expansion targs)] (in (list (code.form (list\composite harg+ (list\conjoint (: (List (List Code)) targs+))))))) - [_ (#.Variant members)] + [_ {#.Variant members}] (do //.monad [members' (monad.each //.monad full_expansion members)] (in (list (code.variant (list\conjoint members'))))) - [_ (#.Tuple members)] + [_ {#.Tuple members}] (do //.monad [members' (monad.each //.monad full_expansion members)] (in (list (code.tuple (list\conjoint members'))))) @@ -103,7 +103,7 @@ (def: (local_identifier ast) (-> Code (Meta Text)) (case ast - [_ (#.Identifier [_ name])] + [_ {#.Identifier [_ name]}] (\ //.monad in name) _ @@ -117,7 +117,7 @@ (macro: .public (with_identifiers tokens) (case tokens - (^ (list [_ (#.Tuple identifiers)] body)) + (^ (list [_ {#.Tuple identifiers}] body)) (do [! //.monad] [identifier_names (monad.each ! ..local_identifier identifiers) .let [identifier_defs (list\conjoint (list\each (: (-> Text (List Code)) @@ -148,16 +148,16 @@ macro_name [module short]] (case (: (Maybe [Bit Code]) (case tokens - (^ (list [_ (#.Text "omit")] + (^ (list [_ {#.Text "omit"}] token)) - (#.Some [#1 token]) + {#.Some [#1 token]} (^ (list token)) - (#.Some [#0 token]) + {#.Some [#0 token]} _ #.None)) - (#.Some [omit? token]) + {#.Some [omit? token]} (do //.monad [location //.location output (<func> token) diff --git a/stdlib/source/library/lux/macro/code.lux b/stdlib/source/library/lux/macro/code.lux index b80a1a418..aaa054c96 100644 --- a/stdlib/source/library/lux/macro/code.lux +++ b/stdlib/source/library/lux/macro/code.lux @@ -20,17 +20,17 @@ ["[0]" location]]]]) ... (type: (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)))}) ... (type: Code ... (Ann Location (Code' (Ann Location)))) @@ -38,7 +38,7 @@ (template [<name> <type> <tag>] [(def: .public (<name> x) (-> <type> Code) - [location.dummy (<tag> x)])] + [location.dummy {<tag> x}])] [bit Bit #.Bit] [nat Nat #.Nat] @@ -56,7 +56,7 @@ (template [<name> <tag>] [(def: .public (<name> name) (-> Text Code) - [location.dummy (<tag> ["" name])])] + [location.dummy {<tag> ["" name]}])] [local_identifier #.Identifier] [local_tag #.Tag]) @@ -67,7 +67,7 @@ (def: (= x y) (case [x y] (^template [<tag> <eq>] - [[[_ (<tag> x')] [_ (<tag> y')]] + [[[_ {<tag> x'}] [_ {<tag> y'}]] (\ <eq> = x' y')]) ([#.Bit bit.equivalence] [#.Nat nat.equivalence] @@ -79,7 +79,7 @@ [#.Tag name.equivalence]) (^template [<tag>] - [[[_ (<tag> xs')] [_ (<tag> ys')]] + [[[_ {<tag> xs'}] [_ {<tag> ys'}]] (\ (list.equivalence =) = xs' ys')]) ([#.Form] [#.Variant] @@ -92,7 +92,7 @@ (-> Code Text) (case ast (^template [<tag> <struct>] - [[_ (<tag> value)] + [[_ {<tag> value}] (\ <struct> encoded value)]) ([#.Bit bit.codec] [#.Nat nat.decimal] @@ -101,14 +101,14 @@ [#.Frac frac.decimal] [#.Identifier name.codec]) - [_ (#.Text value)] + [_ {#.Text value}] (text.format value) - [_ (#.Tag name)] + [_ {#.Tag name}] (text\composite "#" (\ name.codec encoded name)) (^template [<tag> <open> <close>] - [[_ (<tag> members)] + [[_ {<tag> members}] ($_ text\composite <open> (list\mix (function (_ next prev) @@ -130,8 +130,8 @@ substitute (case ast (^template [<tag>] - [[location (<tag> parts)] - [location (<tag> (list\each (replaced original substitute) parts))]]) + [[location {<tag> parts}] + [location {<tag> (list\each (replaced original substitute) parts)}]]) ([#.Form] [#.Variant] [#.Tuple]) diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux index ca48592af..f53a6473b 100644 --- a/stdlib/source/library/lux/macro/local.lux +++ b/stdlib/source/library/lux/macro/local.lux @@ -36,14 +36,14 @@ (All (_ a) (-> Text (-> Module (Try [Module a])) (Meta a))) (function (_ compiler) (case (|> compiler (value@ #.modules) (plist.value name)) - (#.Some module) + {#.Some module} (case (body module) - (#try.Success [module' output]) - (#try.Success [(revised@ #.modules (plist.has name module') compiler) - output]) + {#try.Success [module' output]} + {#try.Success [(revised@ #.modules (plist.has name module') compiler) + output]} - (#try.Failure error) - (#try.Failure error)) + {#try.Failure error} + {#try.Failure error}) #.None (exception.except ..unknown_module [name])))) @@ -52,17 +52,17 @@ (-> [Name Macro] (Meta Any)) (do meta.monad [[module_name definition_name] (meta.normal name) - .let [definition (: Global (#.Definition [false .Macro macro])) + .let [definition (: Global {#.Definition [false .Macro macro]}) add_macro! (: (-> (PList Global) (PList Global)) (plist.has definition_name definition))]] (..with_module module_name (function (_ module) (case (|> module (value@ #.definitions) (plist.value definition_name)) #.None - (#try.Success [(revised@ #.definitions add_macro! module) - []]) + {#try.Success [(revised@ #.definitions add_macro! module) + []]} - (#.Some _) + {#.Some _} (exception.except ..cannot_shadow_definition [module_name definition_name])))))) (def: (pop_one name) @@ -74,9 +74,9 @@ (..with_module module_name (function (_ module) (case (|> module (value@ #.definitions) (plist.value definition_name)) - (#.Some _) - (#try.Success [(revised@ #.definitions lacks_macro! module) - []]) + {#.Some _} + {#try.Success [(revised@ #.definitions lacks_macro! module) + []]} #.None (exception.except ..unknown_definition [module_name definition_name])))))) @@ -90,7 +90,7 @@ _ (..pop_one self) compiler meta.compiler_state] (in (case (value@ #.expected compiler) - (#.Some _) + {#.Some _} (list (' [])) #.None diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index efdb15f1f..3b885c86a 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -29,19 +29,19 @@ (All (_ a) (-> Code (Parser a) (Parser a))) (function (_ tokens) (case (parser tokens) - (#try.Success [tokens output]) - (#try.Success [tokens output]) + {#try.Success [tokens output]} + {#try.Success [tokens output]} - (#try.Failure error) - (#try.Failure ($_ text\composite + {#try.Failure error} + {#try.Failure ($_ text\composite "Failed to parse: " (code.format binding) text.new_line - error))))) + error)}))) (def: (un_paired pairs) (All (_ a) (-> (List [a a]) (List a))) (case pairs #.End #.End - (#.Item [[x y] pairs']) (list& x y (un_paired pairs')))) + {#.Item [[x y] pairs']} (list& x y (un_paired pairs')))) (def: syntax (Parser [Code [Text (List Code)] Code]) @@ -54,7 +54,7 @@ (macro: .public (syntax: tokens) (case (</>.result ..syntax tokens) - (#try.Success [export_policy [name args] body]) + {#try.Success [export_policy [name args] body]} (with_identifiers [g!tokens g!body g!error] (do [! meta.monad] [_ (if (|> args list.size nat.even?) @@ -67,10 +67,10 @@ (` ((~! ..self_documenting) (' (~ var)) (~ parser)))])] (case var - [_ (#.Identifier ["" _])] + [_ {#.Identifier ["" _]}] <default> - [_ (#.Identifier _)] + [_ {#.Identifier _}] (in [var parser]) _ @@ -86,11 +86,11 @@ [(~+ (..un_paired vars+parsers))] ((~' in) (~ body)))) (~ g!tokens)) - (#try.Success (~ g!body)) + {#try.Success (~ g!body)} ((~ g!body) (~ g!state)) - (#try.Failure (~ g!error)) - (#try.Failure ((~! text.interposed) (~! text.new_line) (list (~ error_msg) (~ g!error))))))))))) + {#try.Failure (~ g!error)} + {#try.Failure ((~! text.interposed) (~! text.new_line) (list (~ error_msg) (~ g!error)))}))))))) - (#try.Failure error) + {#try.Failure error} (meta.failure (macro.wrong_syntax_error (name_of ..syntax:))))) diff --git a/stdlib/source/library/lux/macro/syntax/definition.lux b/stdlib/source/library/lux/macro/syntax/definition.lux index 707c44ea2..9cbe2fb1a 100644 --- a/stdlib/source/library/lux/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/macro/syntax/definition.lux @@ -56,10 +56,10 @@ (` ((~ (code.text ..extension)) (~ (code.local_identifier name)) (~ (case value - (#.Left check) + {#.Left check} (//check.format check) - (#.Right value) + {#.Right value} value)) (~ (code.bit export?))))) @@ -90,9 +90,9 @@ (do <>.monad [definition (..parser compiler) _ (case (value@ #value definition) - (#.Left _) + {#.Left _} (in []) - (#.Right _) + {#.Right _} (<>.lifted (exception.except ..lacks_type [definition])))] (in definition))) diff --git a/stdlib/source/library/lux/macro/syntax/export.lux b/stdlib/source/library/lux/macro/syntax/export.lux index 91428bb7e..2d33f7098 100644 --- a/stdlib/source/library/lux/macro/syntax/export.lux +++ b/stdlib/source/library/lux/macro/syntax/export.lux @@ -16,11 +16,11 @@ (do [! <>.monad] [candiate <code>.next] (case candiate - [_ (#.Identifier ["" _])] + [_ {#.Identifier ["" _]}] (in default_policy) - (^or [_ (#.Bit _)] - [_ (#.Identifier _)]) + (^or [_ {#.Bit _}] + [_ {#.Identifier _}]) (do ! [_ <code>.any] (in candiate)) diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index 2f690935b..8be738131 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -86,11 +86,11 @@ [(syntax: .public (<name> [name (<>.or (<>.and (..part true) (..part false)) (..part false))]) (case name - (#.Left [simple complex]) + {#.Left [simple complex]} (in (list (<complex> [(text.interposed "" simple) (text.interposed "" complex)]))) - (#.Right simple) + {#.Right simple} (in (list (|> simple (text.interposed "") <simple>)))))] [identifier code.local_identifier code.identifier] @@ -103,17 +103,17 @@ (def: (applied env template) (-> Environment Code Code) (case template - [_ (#.Identifier "" name)] + [_ {#.Identifier "" name}] (case (dictionary.value name env) - (#.Some substitute) + {#.Some substitute} substitute #.None template) (^template [<tag>] - [[meta (<tag> elems)] - [meta (<tag> (list\each (applied env) elems))]]) + [[meta {<tag> elems}] + [meta {<tag> (list\each (applied env) elems)}]]) ([#.Form] [#.Variant] [#.Tuple]) @@ -143,7 +143,7 @@ (.let [environment (: Environment (|> (list.zipped/2 parameters inputs) (dictionary.of_list text.hash)))] - (#.Right [compiler (list\each (..applied environment) template)])) + {#.Right [compiler (list\each (..applied environment) template)]}) (exception.except ..irregular_arguments [parameters_amount inputs_amount])))))) (def: local @@ -162,12 +162,12 @@ [here_name meta.current_module_name expression? (: (Meta Bit) (function (_ lux) - (#try.Success [lux (case (value@ #.expected lux) + {#try.Success [lux (case (value@ #.expected lux) #.None false - (#.Some _) - true)]))) + {#.Some _} + true)]})) g!pop (local.push (list\each (function (_ local) [[here_name (value@ #name local)] (..macro local)]) diff --git a/stdlib/source/library/lux/math/infix.lux b/stdlib/source/library/lux/math/infix.lux index 616c62709..de54af790 100644 --- a/stdlib/source/library/lux/math/infix.lux +++ b/stdlib/source/library/lux/math/infix.lux @@ -21,10 +21,10 @@ (type: Infix (Rec Infix (Variant - (#Const Code) - (#Call (List Code)) - (#Unary Code Infix) - (#Binary Infix Code Infix)))) + {#Const Code} + {#Call (List Code)} + {#Unary Code Infix} + {#Binary Infix Code Infix}))) (def: literal (Parser Code) @@ -51,7 +51,7 @@ init_param expression steps (<>.some (<>.and <code>.any expression))] (in (list\mix (function (_ [op param] [_subject _op _param]) - [(#Binary _subject _op _param) op param]) + [{#Binary _subject _op _param} op param]) [init_subject init_op init_param] steps)))) ))) @@ -59,16 +59,16 @@ (def: (prefix infix) (-> Infix Code) (case infix - (#Const value) + {#Const value} value - (#Call parts) + {#Call parts} (code.form parts) - (#Unary op subject) + {#Unary op subject} (` ((~ op) (~ (prefix subject)))) - (#Binary left op right) + {#Binary left op right} (` ((~ op) (~ (prefix right)) (~ (prefix left)))))) (syntax: .public (infix [expr ..expression]) diff --git a/stdlib/source/library/lux/math/modular.lux b/stdlib/source/library/lux/math/modular.lux index 189a4b060..e82f222cc 100644 --- a/stdlib/source/library/lux/math/modular.lux +++ b/stdlib/source/library/lux/math/modular.lux @@ -136,7 +136,7 @@ (let [[modulus value] (:representation modular) [[vk mk] gcd] (i.extended_gcd value (//.divisor modulus))] (case gcd - +1 (#.Some (..modular modulus vk)) + +1 {#.Some (..modular modulus vk)} _ #.None)))] ) @@ -151,6 +151,6 @@ (-> (Modulus r%) (Modulus s%) (Try (-> (Mod s%) (Mod r%))))) (if (//.= reference subject) - (#try.Success (|>> ..value - (..modular reference))) + {#try.Success (|>> ..value + (..modular reference))} (exception.except ..moduli_are_not_equal [reference subject]))) diff --git a/stdlib/source/library/lux/math/modulus.lux b/stdlib/source/library/lux/math/modulus.lux index 4a4b000df..0d3c4fb7f 100644 --- a/stdlib/source/library/lux/math/modulus.lux +++ b/stdlib/source/library/lux/math/modulus.lux @@ -27,7 +27,7 @@ (Ex (_ %) (-> Int (Try (Modulus %)))) (if (i.= +0 value) (exception.except ..zero_cannot_be_a_modulus []) - (#try.Success (:abstraction value)))) + {#try.Success (:abstraction value)})) (def: .public divisor (All (_ %) (-> (Modulus %) Int)) diff --git a/stdlib/source/library/lux/math/number.lux b/stdlib/source/library/lux/math/number.lux index 2f0338817..4c20fd9fd 100644 --- a/stdlib/source/library/lux/math/number.lux +++ b/stdlib/source/library/lux/math/number.lux @@ -19,7 +19,7 @@ (def: (separator_prefixed? number) (-> Text Bit) (case ("lux text index" 0 ..separator number) - (#.Some 0) + {#.Some 0} #1 _ @@ -32,34 +32,34 @@ (template [<macro> <nat> <int> <rev> <frac> <error>] [(macro: .public (<macro> tokens state) (case tokens - (#.Item [meta (#.Text repr')] #.End) + {#.Item [meta {#.Text repr'}] #.End} (if (..separator_prefixed? repr') - (#try.Failure <error>) + {#try.Failure <error>} (let [repr (..without_separators repr')] (case (\ <nat> decoded repr) - (#try.Success value) - (#try.Success [state (list [meta (#.Nat value)])]) + {#try.Success value} + {#try.Success [state (list [meta {#.Nat value}])]} - (^multi (#try.Failure _) + (^multi {#try.Failure _} [(\ <int> decoded repr) - (#try.Success value)]) - (#try.Success [state (list [meta (#.Int value)])]) + {#try.Success value}]) + {#try.Success [state (list [meta {#.Int value}])]} - (^multi (#try.Failure _) + (^multi {#try.Failure _} [(\ <rev> decoded repr) - (#try.Success value)]) - (#try.Success [state (list [meta (#.Rev value)])]) + {#try.Success value}]) + {#try.Success [state (list [meta {#.Rev value}])]} - (^multi (#try.Failure _) + (^multi {#try.Failure _} [(\ <frac> decoded repr) - (#try.Success value)]) - (#try.Success [state (list [meta (#.Frac value)])]) + {#try.Success value}]) + {#try.Success [state (list [meta {#.Frac value}])]} _ - (#try.Failure <error>)))) + {#try.Failure <error>}))) _ - (#try.Failure <error>)))] + {#try.Failure <error>}))] [bin /nat.binary /int.binary /rev.binary /frac.binary "Invalid binary syntax."] [oct /nat.octal /int.octal /rev.octal /frac.octal "Invalid octal syntax."] diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index c919e8ab5..230f18c1d 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -201,11 +201,11 @@ (def: (decoded input) (case ("lux f64 decode" input) - (#.Some value) - (#try.Success value) + {#.Some value} + {#try.Success value} #.None - (#try.Failure "Could not decode Frac")))) + {#try.Failure "Could not decode Frac"}))) (def: log/2 (-> Frac Frac) @@ -355,13 +355,13 @@ (\ codec decoded))] (in [("lux text clip" 0 split_index representation) (//int.* <factor> (.int exponent))]))]) - ([+1 (^or [(#.Some split_index) #.None #.None #.None] - [#.None (#.Some split_index) #.None #.None])] - [-1 (^or [#.None #.None (#.Some split_index) #.None] - [#.None #.None #.None (#.Some split_index)])]) + ([+1 (^or [{#.Some split_index} #.None #.None #.None] + [#.None {#.Some split_index} #.None #.None])] + [-1 (^or [#.None #.None {#.Some split_index} #.None] + [#.None #.None #.None {#.Some split_index}])]) _ - (#try.Success [representation +0]))) + {#try.Success [representation +0]})) (template [<struct> <nat> <int> <error>] [(implementation: .public <struct> @@ -388,7 +388,7 @@ (do [! try.monad] [[mantissa exponent] (..representation_exponent <nat> representation) [whole decimal] (case ("lux text index" 0 "." mantissa) - (#.Some split_index) + {#.Some split_index} (do ! [.let [after_offset (++ split_index) after_length (//nat.- after_offset ("lux text size" mantissa))] @@ -399,7 +399,7 @@ decimal])) #.None - (#try.Failure ("lux text concat" <error> representation))) + {#try.Failure ("lux text concat" <error> representation)}) .let [whole ("lux text clip" 1 (-- ("lux text size" whole)) whole)] mantissa (\ <nat> decoded (case decimal 0 whole @@ -410,7 +410,7 @@ (//i64.left_shifted ..sign_offset (.i64 sign)) (//i64.left_shifted ..mantissa_size (.i64 (//int.+ (.int ..double_bias) exponent))) (//i64.zero ..mantissa_size (.i64 mantissa)))))) - (#try.Failure ("lux text concat" <error> representation))))))] + {#try.Failure ("lux text concat" <error> representation)}))))] [binary //nat.binary //int.binary "Invalid binary syntax: "] [octal //nat.octal //int.octal "Invalid octaladecimal syntax: "] diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index 4fbab4334..8ccf4b8c8 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -197,7 +197,7 @@ sign (..bit (-- width)) mantissa (..mask (-- width)) co_mantissa (..xor (.i64 -1) mantissa)] - (#.Some (: Sub + {#.Some (: Sub (implementation (def: &equivalence ..equivalence) (def: width width) @@ -207,5 +207,5 @@ (def: (wide value) (.i64 (case (.nat (..and sign value)) 0 value - _ (..or co_mantissa value)))))))) + _ (..or co_mantissa value))))))}) #.None)) diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index 0e515f8a5..5c4ff3cd6 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -229,8 +229,8 @@ (\ try.functor each (|>> -- .int ..opposite --))) _ - (#try.Failure <error>)) - (#try.Failure <error>)))))] + {#try.Failure <error>}) + {#try.Failure <error>}))))] [binary //nat.binary "Invalid binary syntax for Int: "] [octal //nat.octal "Invalid octal syntax for Int: "] diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux index 3efe7f197..0b0bf4105 100644 --- a/stdlib/source/library/lux/math/number/nat.lux +++ b/stdlib/source/library/lux/math/number/nat.lux @@ -191,8 +191,8 @@ (def: (binary_value digit) (-> Nat (Maybe Nat)) (case digit - (^ (char "0")) (#.Some 0) - (^ (char "1")) (#.Some 1) + (^ (char "0")) {#.Some 0} + (^ (char "1")) {#.Some 1} _ #.None)) (def: (octal_character value) @@ -211,14 +211,14 @@ (def: (octal_value digit) (-> Nat (Maybe Nat)) (case digit - (^ (char "0")) (#.Some 0) - (^ (char "1")) (#.Some 1) - (^ (char "2")) (#.Some 2) - (^ (char "3")) (#.Some 3) - (^ (char "4")) (#.Some 4) - (^ (char "5")) (#.Some 5) - (^ (char "6")) (#.Some 6) - (^ (char "7")) (#.Some 7) + (^ (char "0")) {#.Some 0} + (^ (char "1")) {#.Some 1} + (^ (char "2")) {#.Some 2} + (^ (char "3")) {#.Some 3} + (^ (char "4")) {#.Some 4} + (^ (char "5")) {#.Some 5} + (^ (char "6")) {#.Some 6} + (^ (char "7")) {#.Some 7} _ #.None)) (def: (decimal_character value) @@ -239,16 +239,16 @@ (def: (decimal_value digit) (-> Nat (Maybe Nat)) (case digit - (^ (char "0")) (#.Some 0) - (^ (char "1")) (#.Some 1) - (^ (char "2")) (#.Some 2) - (^ (char "3")) (#.Some 3) - (^ (char "4")) (#.Some 4) - (^ (char "5")) (#.Some 5) - (^ (char "6")) (#.Some 6) - (^ (char "7")) (#.Some 7) - (^ (char "8")) (#.Some 8) - (^ (char "9")) (#.Some 9) + (^ (char "0")) {#.Some 0} + (^ (char "1")) {#.Some 1} + (^ (char "2")) {#.Some 2} + (^ (char "3")) {#.Some 3} + (^ (char "4")) {#.Some 4} + (^ (char "5")) {#.Some 5} + (^ (char "6")) {#.Some 6} + (^ (char "7")) {#.Some 7} + (^ (char "8")) {#.Some 8} + (^ (char "9")) {#.Some 9} _ #.None)) (def: (hexadecimal_character value) @@ -276,12 +276,12 @@ (-> Nat (Maybe Nat)) (case digit (^template [<character> <number>] - [(^ (char <character>)) (#.Some <number>)]) + [(^ (char <character>)) {#.Some <number>}]) (["0" 0] ["1" 1] ["2" 2] ["3" 3] ["4" 4] ["5" 5] ["6" 6] ["7" 7] ["8" 8] ["9" 9]) (^template [<lower> <upper> <number>] - [(^or (^ (char <lower>)) (^ (char <upper>))) (#.Some <number>)]) + [(^or (^ (char <lower>)) (^ (char <upper>))) {#.Some <number>}]) (["a" "A" 10] ["b" "B" 11] ["c" "C" 12] ["d" "D" 13] ["e" "E" 14] ["f" "F" 15]) _ #.None)) @@ -312,16 +312,16 @@ output 0] (if (..< input_size idx) (case (<to_value> ("lux text char" idx repr)) - (#.Some digit_value) + {#.Some digit_value} (recur (++ idx) (|> output ("lux i64 left-shift" <shift>) ("lux i64 or" digit_value))) _ - (#try.Failure ("lux text concat" <error> repr))) - (#try.Success output))) - (#try.Failure ("lux text concat" <error> repr))))))] + {#try.Failure ("lux text concat" <error> repr)}) + {#try.Success output})) + {#try.Failure ("lux text concat" <error> repr)}))))] [1 binary binary_character binary_value "Invalid binary syntax for Nat: "] [3 octal octal_character octal_value "Invalid octal syntax for Nat: "] @@ -345,7 +345,7 @@ (def: (decoded repr) (let [input_size ("lux text size" repr)] - (with_expansions [<failure> (#try.Failure ("lux text concat" "Invalid decimal syntax for Nat: " repr))] + (with_expansions [<failure> {#try.Failure ("lux text concat" "Invalid decimal syntax for Nat: " repr)}] (if (..> 0 input_size) (loop [idx 0 output 0] @@ -354,10 +354,10 @@ #.None <failure> - (#.Some digit_value) + {#.Some digit_value} (recur (++ idx) (|> output (..* 10) (..+ digit_value)))) - (#try.Success output))) + {#try.Success output})) <failure>))))) (implementation: .public hash diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux index 1e6aff940..be5bb235a 100644 --- a/stdlib/source/library/lux/math/number/ratio.lux +++ b/stdlib/source/library/lux/math/number/ratio.lux @@ -30,7 +30,7 @@ (def: .public (nat value) (-> Ratio (Maybe Nat)) (case (value@ #denominator value) - 1 (#.Some (value@ #numerator value)) + 1 {#.Some (value@ #numerator value)} _ #.None)) (def: (normal (^slots [#numerator #denominator])) @@ -136,7 +136,7 @@ (def: (decoded input) (case (text.split_by ..separator input) - (#.Some [num denom]) + {#.Some [num denom]} (do try.monad [numerator (n\decoded num) denominator (n\decoded denom)] @@ -144,7 +144,7 @@ #denominator denominator]))) #.None - (#.Left (text\composite "Invalid syntax for ratio: " input))))) + {#.Left (text\composite "Invalid syntax for ratio: " input)}))) (template [<identity> <composite> <name>] [(implementation: .public <name> diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index 07013dc94..a652d3913 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -225,7 +225,7 @@ ("lux text clip" 1 (-- ("lux text size" input)) input)) (template [<struct> <codec> <char_bit_size> <error>] - [(with_expansions [<error_output> (as_is (#try.Failure ("lux text concat" <error> repr)))] + [(with_expansions [<error_output> (as_is {#try.Failure ("lux text concat" <error> repr)})] (implementation: .public <struct> (Codec Text Rev) @@ -253,8 +253,8 @@ (case ("lux text char" 0 repr) (^ (char ".")) (case (\ <codec> decoded (..decimals repr)) - (#try.Success output) - (#try.Success (.rev output)) + {#try.Success output} + {#try.Success (.rev output)} _ <error_output>) @@ -365,10 +365,10 @@ #.None #.None - (#.Some digit) + {#.Some digit} (recur (++ idx) (digits\put! idx digit output))) - (#.Some output)))))) + {#.Some output}))))) (def: (digits\< param subject) (-> Digits Digits Bit) @@ -425,7 +425,7 @@ (def: (decoded input) (let [dotted? (case ("lux text index" 0 "." input) - (#.Some 0) + {#.Some 0} true _ @@ -435,7 +435,7 @@ (//nat.<= (++ //i64.width)))] (if (and dotted? within_limits?) (case (|> input ..decimals ..text_digits) - (#.Some digits) + {#.Some digits} (loop [digits digits idx 0 output 0] @@ -447,9 +447,9 @@ (recur (digits\-! power digits) (++ idx) (//i64.one (//nat.- idx (-- //i64.width)) output)))) - (#try.Success (.rev output)))) + {#try.Success (.rev output)})) #.None - (#try.Failure ("lux text concat" "Wrong syntax for Rev: " input))) - (#try.Failure ("lux text concat" "Wrong syntax for Rev: " input)))) + {#try.Failure ("lux text concat" "Wrong syntax for Rev: " input)}) + {#try.Failure ("lux text concat" "Wrong syntax for Rev: " input)})) )) diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index 348482e63..b7dd727d7 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -91,7 +91,7 @@ (do ..monad [sample random] (case (check sample) - (#.Some output) + {#.Some output} (in output) #.None @@ -102,7 +102,7 @@ (do ..monad [sample gen] (case (refiner sample) - (#.Some refined) + {#.Some refined} (in refined) #.None @@ -207,10 +207,10 @@ (if ? (do ! [=left left] - (in (0 #0 =left))) + (in {0 #0 =left})) (do ! [=right right] - (in (0 #1 =right)))))) + (in {0 #1 =right}))))) (def: .public (either left right) (All (_ a) (-> (Random a) (Random a) (Random a))) @@ -233,22 +233,26 @@ (if some? (do ! [value value_gen] - (in (#.Some value))) + (in {#.Some value})) (in #.None)))) -(template [<name> <type> <zero> <plus>] - [(def: .public (<name> size value_gen) - (All (_ a) (-> Nat (Random a) (Random (<type> a)))) - (if (n.> 0 size) - (do ..monad - [x value_gen - xs (<name> (-- size) value_gen)] - (in (<plus> x xs))) - (\ ..monad in <zero>)))] - - [list List (.list) #.Item] - [row Row row.empty row.suffix] - ) +(def: .public (list size value_gen) + (All (_ a) (-> Nat (Random a) (Random (List a)))) + (if (n.> 0 size) + (do ..monad + [x value_gen + xs (list (-- size) value_gen)] + (in {#.Item x xs})) + (\ ..monad in (.list)))) + +(def: .public (row size value_gen) + (All (_ a) (-> Nat (Random a) (Random (Row a)))) + (if (n.> 0 size) + (do ..monad + [x value_gen + xs (row (-- size) value_gen)] + (in (row.suffix x xs))) + (\ ..monad in row.empty))) (template [<name> <type> <ctor>] [(def: .public (<name> size value_gen) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index 122dde3ca..433d76d91 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -34,11 +34,11 @@ (def: (each f fa) (function (_ lux) (case (fa lux) - (#try.Failure msg) - (#try.Failure msg) + {#try.Failure msg} + {#try.Failure msg} - (#try.Success [lux' a]) - (#try.Success [lux' (f a)]))))) + {#try.Success [lux' a]} + {#try.Success [lux' (f a)]})))) (implementation: .public apply (Apply Meta) @@ -48,16 +48,16 @@ (def: (on fa ff) (function (_ lux) (case (ff lux) - (#try.Success [lux' f]) + {#try.Success [lux' f]} (case (fa lux') - (#try.Success [lux'' a]) - (#try.Success [lux'' (f a)]) + {#try.Success [lux'' a]} + {#try.Success [lux'' (f a)]} - (#try.Failure msg) - (#try.Failure msg)) + {#try.Failure msg} + {#try.Failure msg}) - (#try.Failure msg) - (#try.Failure msg))))) + {#try.Failure msg} + {#try.Failure msg})))) (implementation: .public monad (Monad Meta) @@ -66,15 +66,15 @@ (def: (in x) (function (_ lux) - (#try.Success [lux x]))) + {#try.Success [lux x]})) (def: (conjoint mma) (function (_ lux) (case (mma lux) - (#try.Failure msg) - (#try.Failure msg) + {#try.Failure msg} + {#try.Failure msg} - (#try.Success [lux' ma]) + {#try.Success [lux' ma]} (ma lux'))))) (def: .public (result' lux action) @@ -84,54 +84,54 @@ (def: .public (result lux action) (All (_ a) (-> Lux (Meta a) (Try a))) (case (action lux) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success [_ output]) - (#try.Success output))) + {#try.Success [_ output]} + {#try.Success output})) (def: .public (either left right) (All (_ a) (-> (Meta a) (Meta a) (Meta a))) (function (_ lux) (case (left lux) - (#try.Failure error) + {#try.Failure error} (right lux) - (#try.Success [lux' output]) - (#try.Success [lux' output])))) + {#try.Success [lux' output]} + {#try.Success [lux' output]}))) (def: .public (assertion message test) (-> Text Bit (Meta Any)) (function (_ lux) (if test - (#try.Success [lux []]) - (#try.Failure message)))) + {#try.Success [lux []]} + {#try.Failure message}))) (def: .public (failure error) (All (_ a) (-> Text (Meta a))) (function (_ state) - (#try.Failure (location.with (value@ #.location state) error)))) + {#try.Failure (location.with (value@ #.location state) error)})) (def: .public (module name) (-> Text (Meta Module)) (function (_ lux) (case (plist.value name (value@ #.modules lux)) - (#.Some module) - (#try.Success [lux module]) + {#.Some module} + {#try.Success [lux module]} _ - (#try.Failure ($_ text\composite "Unknown module: " name))))) + {#try.Failure ($_ text\composite "Unknown module: " name)}))) (def: .public current_module_name (Meta Text) (function (_ lux) (case (value@ #.current_module lux) - (#.Some current_module) - (#try.Success [lux current_module]) + {#.Some current_module} + {#try.Success [lux current_module]} _ - (#try.Failure "No current module.")))) + {#try.Failure "No current module."}))) (def: .public current_module (Meta Module) @@ -143,7 +143,7 @@ (def: (macro_type? type) (-> Type Bit) (`` (case type - (#.Named [(~~ (static .prelude_module)) "Macro"] (#.Primitive "#Macro" #.End)) + {#.Named [(~~ (static .prelude_module)) "Macro"] {#.Primitive "#Macro" #.End}} true _ @@ -166,12 +166,12 @@ [[module name] (..normal full_name)] (: (Meta (Maybe Macro)) (function (_ lux) - (#try.Success [lux + {#try.Success [lux (case (..current_module_name lux) - (#try.Failure error) + {#try.Failure error} #.None - (#try.Success [_ this_module]) + {#try.Success [_ this_module]} (let [modules (value@ #.modules lux)] (loop [module module name name] @@ -183,45 +183,45 @@ (value@ #.definitions) (plist.value name)))] (case definition - (#.Alias [r_module r_name]) + {#.Alias [r_module r_name]} (recur r_module r_name) - (#.Definition [exported? def_type def_value]) + {#.Definition [exported? def_type def_value]} (if (macro_type? def_type) - (#.Some (:as Macro def_value)) + {#.Some (:as Macro def_value)} #.None) - (#.Type [exported? type labels]) + {#.Type [exported? type labels]} #.None - (#.Label _) + {#.Label _} #.None - (#.Slot _) - #.None)))))]))))) + {#.Slot _} + #.None)))))]})))) (def: .public seed (Meta Nat) (function (_ lux) - (#try.Success [(revised@ #.seed ++ lux) - (value@ #.seed lux)]))) + {#try.Success [(revised@ #.seed ++ lux) + (value@ #.seed lux)]})) (def: .public (module_exists? module) (-> Text (Meta Bit)) (function (_ lux) - (#try.Success [lux (case (plist.value module (value@ #.modules lux)) - (#.Some _) + {#try.Success [lux (case (plist.value module (value@ #.modules lux)) + {#.Some _} #1 #.None - #0)]))) + #0)]})) (def: (on_either f x1 x2) (All (_ a b) (-> (-> a (Maybe b)) a a (Maybe b))) (case (f x1) #.None (f x2) - (#.Some y) (#.Some y))) + {#.Some y} {#.Some y})) (def: (type_variable idx bindings) (-> Nat (List [Nat (Maybe Type)]) (Maybe Type)) @@ -229,7 +229,7 @@ #.End #.None - (#.Item [var bound] bindings') + {#.Item [var bound] bindings'} (if (n.= idx var) bound (type_variable idx bindings')))) @@ -237,16 +237,16 @@ (def: (clean_type type) (-> Type (Meta Type)) (case type - (#.Var var) + {#.Var var} (function (_ lux) (case (|> lux (value@ [#.type_context #.var_bindings]) (type_variable var)) - (^or #.None (#.Some (#.Var _))) - (#try.Success [lux type]) + (^or #.None {#.Some {#.Var _}}) + {#try.Success [lux type]} - (#.Some type') - (#try.Success [lux type']))) + {#.Some type'} + {#try.Success [lux type']})) _ (\ ..monad in type))) @@ -269,11 +269,11 @@ (: (List [Text [Type Any]]) (value@ [#.captured #.mappings] scope)))] (in type)) - (#.Some var_type) + {#.Some var_type} ((clean_type var_type) lux) #.None - (#try.Failure ($_ text\composite "Unknown variable: " name)))))) + {#try.Failure ($_ text\composite "Unknown variable: " name)})))) (def: without_lux_runtime (-> (List Text) (List Text)) @@ -303,8 +303,8 @@ (value@ #.modules) (plist.value normal_module))] (plist.value normal_short definitions))) - (#.Some definition) - (#try.Success [lux definition]) + {#.Some definition} + {#try.Success [lux definition]} _ (let [current_module (|> lux (value@ #.current_module) (maybe.else "???")) @@ -312,11 +312,11 @@ (value@ #.modules) (list\each product.left) ..module_listing)] - (#try.Failure ($_ text\composite + {#try.Failure ($_ text\composite "Unknown definition: " (name\encoded name) text.new_line " Current module: " current_module text.new_line (case (plist.value current_module (value@ #.modules lux)) - (#.Some this_module) + {#.Some this_module} (let [candidates (|> lux (value@ #.modules) (list\each (function (_ [module_name module]) @@ -324,20 +324,20 @@ (value@ #.definitions) (list.all (function (_ [def_name global]) (case global - (^or (#.Definition [exported? _]) - (#.Type [exported? _])) + (^or {#.Definition [exported? _]} + {#.Type [exported? _]}) (if (and exported? (text\= normal_short def_name)) - (#.Some (name\encoded [module_name def_name])) + {#.Some (name\encoded [module_name def_name])} #.None) - (#.Alias _) + {#.Alias _} #.None - (#.Label _) + {#.Label _} #.None - (#.Slot _) + {#.Slot _} #.None)))))) list.together (list.sorted text\<) @@ -357,35 +357,35 @@ _ "") - " All known modules: " all_known_modules text.new_line))))))) + " All known modules: " all_known_modules text.new_line)}))))) (def: .public (export name) (-> Name (Meta Definition)) (do ..monad [definition (..definition name)] (case definition - (#.Definition definition) + {#.Definition definition} (let [[exported? def_type def_value] definition] (if exported? (in definition) (failure ($_ text\composite "Definition is not an export: " (name\encoded name))))) - (#.Type [exported? type labels]) + {#.Type [exported? type labels]} (if exported? (in [exported? .Type type]) (failure ($_ text\composite "Type is not an export: " (name\encoded name)))) - (#.Alias de_aliased) + {#.Alias de_aliased} (failure ($_ text\composite "Aliases are not considered exports: " (name\encoded name))) - (#.Label _) + {#.Label _} (failure ($_ text\composite "Tags are not considered exports: " (name\encoded name))) - (#.Slot _) + {#.Slot _} (failure ($_ text\composite "Slots are not considered exports: " (name\encoded name)))))) @@ -395,21 +395,21 @@ (do ..monad [definition (definition name)] (case definition - (#.Alias de_aliased) + {#.Alias de_aliased} (definition_type de_aliased) - (#.Definition [exported? def_type def_value]) + {#.Definition [exported? def_type def_value]} (clean_type def_type) - (#.Type [exported? type labels]) + {#.Type [exported? type labels]} (in .Type) - (#.Label _) + {#.Label _} (failure ($_ text\composite "Tags have no type: " (name\encoded name))) - (#.Slot _) + {#.Slot _} (failure ($_ text\composite "Slots have no type: " (name\encoded name)))))) @@ -429,10 +429,10 @@ (do ..monad [definition (definition name)] (case definition - (#.Alias de_aliased) + {#.Alias de_aliased} (type_definition de_aliased) - (#.Definition [exported? def_type def_value]) + {#.Definition [exported? def_type def_value]} (let [type_code (`` ("lux in-module" (~~ (static .prelude_module)) .type_code))] (if (or (same? .Type def_type) (\ code.equivalence = @@ -441,13 +441,13 @@ (in (:as Type def_value)) (..failure ($_ text\composite "Definition is not a type: " (name\encoded name))))) - (#.Type [exported? type labels]) + {#.Type [exported? type labels]} (in type) - (#.Label _) + {#.Label _} (..failure ($_ text\composite "Tag is not a type: " (name\encoded name))) - (#.Slot _) + {#.Slot _} (..failure ($_ text\composite "Slot is not a type: " (name\encoded name)))))) (def: .public (globals module) @@ -455,29 +455,29 @@ (function (_ lux) (case (plist.value module (value@ #.modules lux)) #.None - (#try.Failure ($_ text\composite "Unknown module: " module)) + {#try.Failure ($_ text\composite "Unknown module: " module)} - (#.Some module) - (#try.Success [lux (value@ #.definitions module)])))) + {#.Some module} + {#try.Success [lux (value@ #.definitions module)]}))) (def: .public (definitions module) (-> Text (Meta (List [Text Definition]))) (\ ..monad each (list.all (function (_ [name global]) (case global - (#.Alias de_aliased) + {#.Alias de_aliased} #.None - (#.Definition definition) - (#.Some [name definition]) + {#.Definition definition} + {#.Some [name definition]} - (#.Type [exported? type labels]) - (#.Some [name [exported? .Type type]]) + {#.Type [exported? type labels]} + {#.Some [name [exported? .Type type]]} - (#.Label _) + {#.Label _} #.None - (#.Slot _) + {#.Slot _} #.None))) (..globals module))) @@ -505,12 +505,12 @@ [.let [[module_name name] type_name] module (..module module_name)] (case (plist.value name (value@ #.definitions module)) - (#.Some (#.Type [exported? type labels])) + {#.Some {#.Type [exported? type labels]}} (case labels - (^or (#.Left labels) - (#.Right labels)) - (in (#.Some (list\each (|>> [module_name]) - (#.Item labels))))) + (^or {#.Left labels} + {#.Right labels}) + (in {#.Some (list\each (|>> [module_name]) + {#.Item labels})})) _ (in #.None)))) @@ -518,17 +518,17 @@ (def: .public location (Meta Location) (function (_ lux) - (#try.Success [lux (value@ #.location lux)]))) + {#try.Success [lux (value@ #.location lux)]})) (def: .public expected_type (Meta Type) (function (_ lux) (case (value@ #.expected lux) - (#.Some type) - (#try.Success [lux type]) + {#.Some type} + {#try.Success [lux type]} #.None - (#try.Failure "Not expecting any type.")))) + {#try.Failure "Not expecting any type."}))) (def: .public (imported_modules module_name) (-> Text (Meta (List Text))) @@ -556,7 +556,7 @@ =module (..module module) this_module_name ..current_module_name] (case (plist.value (text\composite "#" name) (value@ #.definitions =module)) - (#.Some (<tag> [exported? type group idx])) + {#.Some {<tag> [exported? type group idx]}} (if (or (text\= this_module_name module) exported?) (in [idx (list\each (|>> [module]) group) type]) @@ -577,17 +577,17 @@ this_module_name ..current_module_name] (in (list.all (function (_ [short global]) (case global - (#.Type [exported? type labels]) + {#.Type [exported? type labels]} (if (or exported? (text\= this_module_name module)) - (#.Some [(list\each (|>> [module]) + {#.Some [(list\each (|>> [module]) (case labels - (#.Left tags) - (#.Item tags) + {#.Left tags} + {#.Item tags} - (#.Right slots) - (#.Item slots))) - type]) + {#.Right slots} + {#.Item slots})) + type]} #.None) _ @@ -599,52 +599,52 @@ (function (_ lux) (case (list.inits (value@ #.scopes lux)) #.None - (#try.Failure "No local environment") + {#try.Failure "No local environment"} - (#.Some scopes) - (#try.Success [lux + {#.Some scopes} + {#try.Success [lux (list\each (|>> (value@ [#.locals #.mappings]) (list\each (function (_ [name [type _]]) [name type]))) - scopes)])))) + scopes)]}))) (def: .public (de_aliased def_name) (-> Name (Meta Name)) (do ..monad [constant (..definition def_name)] (in (case constant - (#.Alias real_def_name) + {#.Alias real_def_name} real_def_name - (#.Definition _) + {#.Definition _} def_name - (#.Type _) + {#.Type _} def_name - (#.Label _) + {#.Label _} def_name - (#.Slot _) + {#.Slot _} def_name)))) (def: .public compiler_state (Meta Lux) (function (_ lux) - (#try.Success [lux lux]))) + {#try.Success [lux lux]})) (def: .public type_context (Meta Type_Context) (function (_ lux) - (#try.Success [lux (value@ #.type_context lux)]))) + {#try.Success [lux (value@ #.type_context lux)]})) (def: .public (lifted result) (All (_ a) (-> (Try a) (Meta a))) (case result - (#try.Success output) + {#try.Success output} (\ ..monad in output) - (#try.Failure error) + {#try.Failure error} (..failure error))) (def: .public (eval type code) @@ -658,8 +658,8 @@ (All (_ it) (-> (Meta it) (Meta (Try it)))) (function (_ lux) (case (computation lux) - (#try.Success [lux' output]) - (#try.Success [lux' (#try.Success output)]) + {#try.Success [lux' output]} + {#try.Success [lux' {#try.Success output}]} - (#try.Failure error) - (#try.Success [lux (#try.Failure error)])))) + {#try.Failure error} + {#try.Success [lux {#try.Failure error}]}))) diff --git a/stdlib/source/library/lux/meta/location.lux b/stdlib/source/library/lux/meta/location.lux index 7f37b4d77..3c797eda0 100644 --- a/stdlib/source/library/lux/meta/location.lux +++ b/stdlib/source/library/lux/meta/location.lux @@ -22,14 +22,14 @@ (case tokens #.End (let [location (value@ #.location compiler)] - (#.Right [compiler + {#.Right [compiler (list (` (.: .Location - [(~ [..dummy (#.Text (value@ #.module location))]) - (~ [..dummy (#.Nat (value@ #.line location))]) - (~ [..dummy (#.Nat (value@ #.column location))])])))])) + [(~ [..dummy {#.Text (value@ #.module location)}]) + (~ [..dummy {#.Nat (value@ #.line location)}]) + (~ [..dummy {#.Nat (value@ #.column location)}])])))]}) _ - (#.Left (`` (("lux in-module" (~~ (static .prelude_module)) wrong_syntax_error) (name_of ..here)))))) + {#.Left (`` (("lux in-module" (~~ (static .prelude_module)) wrong_syntax_error) (name_of ..here)))})) (def: .public (format it) (-> Location Text) diff --git a/stdlib/source/library/lux/program.lux b/stdlib/source/library/lux/program.lux index 7b81afa69..844da6654 100644 --- a/stdlib/source/library/lux/program.lux +++ b/stdlib/source/library/lux/program.lux @@ -21,8 +21,8 @@ (type: Arguments (Variant - (#Raw Text) - (#Parsed (List Code)))) + {#Raw Text} + {#Parsed (List Code)})) (def: arguments^ (<code>.Parser Arguments) @@ -43,11 +43,11 @@ ((~' in) (~ g!output))))] (in (list (` ("lux def program" (~ (case args - (#Raw args) + {#Raw args} (` (.function ((~ g!program) (~ (code.identifier ["" args]))) (~ initialization+event_loop))) - (#Parsed args) + {#Parsed args} (` (.function ((~ g!program) (~ g!args)) (case ((~! <cli>.result) (: (~! (<cli>.Parser (io.IO .Any))) ((~! do) (~! <>.monad) @@ -55,8 +55,8 @@ (~ g!_) (~! <cli>.end)] ((~' in) (~ initialization+event_loop)))) (~ g!args)) - (#.Right (~ g!output)) + {#.Right (~ g!output)} (~ g!output) - (#.Left (~ g!message)) + {#.Left (~ g!message)} (.panic! (~ g!message)))))))))))))) diff --git a/stdlib/source/library/lux/target/common_lisp.lux b/stdlib/source/library/lux/target/common_lisp.lux index a208ba0ff..1a14f8d6e 100644 --- a/stdlib/source/library/lux/target/common_lisp.lux +++ b/stdlib/source/library/lux/target/common_lisp.lux @@ -156,7 +156,7 @@ #.End "" - (#.Item _) + {#.Item _} (|> singles (list\each ..code) (text.interposed " ") @@ -174,7 +174,7 @@ (def: .public (call/* func) (-> (Expression Any) (-> (List (Expression Any)) (Computation Any))) - (|>> (#.Item func) ..form)) + (|>> {#.Item func} ..form)) (template [<name> <function>] [(def: .public <name> @@ -406,7 +406,7 @@ #.End expression - (#.Item single #.End) + {#.Item single #.End} (:abstraction (format <prefix> single " " (:representation expression))) diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux index c648d5bf2..662f0c3a4 100644 --- a/stdlib/source/library/lux/target/js.lux +++ b/stdlib/source/library/lux/target/js.lux @@ -406,7 +406,7 @@ (text.interposed text.new_line)) text.new_line (case default - (#.Some default) + {#.Some default} (format "default:" (..nested (:representation default))) diff --git a/stdlib/source/library/lux/target/jvm.lux b/stdlib/source/library/lux/target/jvm.lux index e32769bbc..0d07ab2aa 100644 --- a/stdlib/source/library/lux/target/jvm.lux +++ b/stdlib/source/library/lux/target/jvm.lux @@ -11,18 +11,18 @@ (type: .public Literal (Variant - (#Boolean Bit) - (#Int Int) - (#Long Int) - (#Double Frac) - (#Char Nat) - (#String Text))) + {#Boolean Bit} + {#Int Int} + {#Long Int} + {#Double Frac} + {#Char Nat} + {#String Text})) (type: .public Constant (Variant - (#BIPUSH Int) + {#BIPUSH Int} - (#SIPUSH Int) + {#SIPUSH Int} #ICONST_M1 #ICONST_0 @@ -44,7 +44,7 @@ #ACONST_NULL - (#LDC Literal))) + {#LDC Literal})) (type: .public Int_Arithmetic (Variant @@ -84,10 +84,10 @@ (type: .public Arithmetic (Variant - (#Int_Arithmetic Int_Arithmetic) - (#Long_Arithmetic Long_Arithmetic) - (#Float_Arithmetic Float_Arithmetic) - (#Double_Arithmetic Double_Arithmetic))) + {#Int_Arithmetic Int_Arithmetic} + {#Long_Arithmetic Long_Arithmetic} + {#Float_Arithmetic Float_Arithmetic} + {#Double_Arithmetic Double_Arithmetic})) (type: .public Int_Bitwise (Variant @@ -109,8 +109,8 @@ (type: .public Bitwise (Variant - (#Int_Bitwise Int_Bitwise) - (#Long_Bitwise Long_Bitwise))) + {#Int_Bitwise Int_Bitwise} + {#Long_Bitwise Long_Bitwise})) (type: .public Conversion (Variant @@ -137,8 +137,8 @@ (Variant #ARRAYLENGTH - (#NEWARRAY (Type Primitive)) - (#ANEWARRAY (Type category.Object)) + {#NEWARRAY (Type Primitive)} + {#ANEWARRAY (Type category.Object)} #BALOAD #BASTORE @@ -166,58 +166,58 @@ (type: .public Object (Variant - (#GETSTATIC (Type Class) Text (Type Value)) - (#PUTSTATIC (Type Class) Text (Type Value)) + {#GETSTATIC (Type Class) Text (Type Value)} + {#PUTSTATIC (Type Class) Text (Type Value)} - (#NEW (Type Class)) + {#NEW (Type Class)} - (#INSTANCEOF (Type Class)) - (#CHECKCAST (Type category.Object)) + {#INSTANCEOF (Type Class)} + {#CHECKCAST (Type category.Object)} - (#GETFIELD (Type Class) Text (Type Value)) - (#PUTFIELD (Type Class) Text (Type Value)) + {#GETFIELD (Type Class) Text (Type Value)} + {#PUTFIELD (Type Class) Text (Type Value)} - (#INVOKEINTERFACE (Type Class) Text (Type Method)) - (#INVOKESPECIAL (Type Class) Text (Type Method)) - (#INVOKESTATIC (Type Class) Text (Type Method)) - (#INVOKEVIRTUAL (Type Class) Text (Type Method)))) + {#INVOKEINTERFACE (Type Class) Text (Type Method)} + {#INVOKESPECIAL (Type Class) Text (Type Method)} + {#INVOKESTATIC (Type Class) Text (Type Method)} + {#INVOKEVIRTUAL (Type Class) Text (Type Method)})) (type: .public Register Nat) (type: .public Local_Int (Variant - (#ILOAD Register) - (#ISTORE Register))) + {#ILOAD Register} + {#ISTORE Register})) (type: .public Local_Long (Variant - (#LLOAD Register) - (#LSTORE Register))) + {#LLOAD Register} + {#LSTORE Register})) (type: .public Local_Float (Variant - (#FLOAD Register) - (#FSTORE Register))) + {#FLOAD Register} + {#FSTORE Register})) (type: .public Local_Double (Variant - (#DLOAD Register) - (#DSTORE Register))) + {#DLOAD Register} + {#DSTORE Register})) (type: .public Local_Object (Variant - (#ALOAD Register) - (#ASTORE Register))) + {#ALOAD Register} + {#ASTORE Register})) (type: .public Local (Variant - (#Local_Int Local_Int) - (#IINC Register) - (#Local_Long Local_Long) - (#Local_Float Local_Float) - (#Local_Double Local_Double) - (#Local_Object Local_Object))) + {#Local_Int Local_Int} + {#IINC Register} + {#Local_Long Local_Long} + {#Local_Float Local_Float} + {#Local_Double Local_Double} + {#Local_Object Local_Object})) (type: .public Stack (Variant @@ -246,30 +246,30 @@ (type: .public (Branching label) (Variant - (#IF_ICMPEQ label) - (#IF_ICMPGE label) - (#IF_ICMPGT label) - (#IF_ICMPLE label) - (#IF_ICMPLT label) - (#IF_ICMPNE label) - (#IFEQ label) - (#IFNE label) - (#IFGE label) - (#IFGT label) - (#IFLE label) - (#IFLT label) - - (#TABLESWITCH Int Int label (List label)) - (#LOOKUPSWITCH label (List [Int label])) - - (#IF_ACMPEQ label) - (#IF_ACMPNE label) - (#IFNONNULL label) - (#IFNULL label))) + {#IF_ICMPEQ label} + {#IF_ICMPGE label} + {#IF_ICMPGT label} + {#IF_ICMPLE label} + {#IF_ICMPLT label} + {#IF_ICMPNE label} + {#IFEQ label} + {#IFNE label} + {#IFGE label} + {#IFGT label} + {#IFLE label} + {#IFLT label} + + {#TABLESWITCH Int Int label (List label)} + {#LOOKUPSWITCH label (List [Int label])} + + {#IF_ACMPEQ label} + {#IF_ACMPNE label} + {#IFNONNULL label} + {#IFNULL label})) (type: .public (Exception label) (Variant - (#Try label label label (Type Class)) + {#Try label label label (Type Class)} #ATHROW)) (type: .public Concurrency @@ -288,26 +288,26 @@ (type: .public (Control label) (Variant - (#GOTO label) - (#Branching (Branching label)) - (#Exception (Exception label)) - (#Concurrency Concurrency) - (#Return Return))) + {#GOTO label} + {#Branching (Branching label)} + {#Exception (Exception label)} + {#Concurrency Concurrency} + {#Return Return})) (type: .public (Instruction embedded label) (Variant #NOP - (#Constant Constant) - (#Arithmetic Arithmetic) - (#Bitwise Bitwise) - (#Conversion Conversion) - (#Array Array) - (#Object Object) - (#Local Local) - (#Stack Stack) - (#Comparison Comparison) - (#Control (Control label)) - (#Embedded embedded))) + {#Constant Constant} + {#Arithmetic Arithmetic} + {#Bitwise Bitwise} + {#Conversion Conversion} + {#Array Array} + {#Object Object} + {#Local Local} + {#Stack Stack} + {#Comparison Comparison} + {#Control (Control label)} + {#Embedded embedded})) (type: .public (Bytecode embedded label) (Row (Instruction embedded label))) diff --git a/stdlib/source/library/lux/target/jvm/attribute.lux b/stdlib/source/library/lux/target/jvm/attribute.lux index 78ce1854d..ed10a42c6 100644 --- a/stdlib/source/library/lux/target/jvm/attribute.lux +++ b/stdlib/source/library/lux/target/jvm/attribute.lux @@ -55,8 +55,8 @@ (type: .public Attribute (Rec Attribute (Variant - (#Constant (Info (Constant Any))) - (#Code (Info <Code>))))) + {#Constant (Info (Constant Any))} + {#Code (Info <Code>)}))) (type: .public Code <Code>) @@ -82,16 +82,16 @@ (-> Attribute Nat) (case attribute (^template [<tag>] - [(<tag> [name length info]) + [{<tag> [name length info]} (|> length //unsigned.value (n.+ ..common_attribute_length))]) ([#Constant] [#Code]))) ... TODO: Inline ASAP (def: (constant' @name index) (-> (Index UTF8) (Constant Any) Attribute) - (#Constant [#name @name + {#Constant [#name @name #length (|> /constant.length //unsigned.u4 try.trusted) - #info index])) + #info index]}) (def: .public (constant index) (-> (Constant Any) (Resource Attribute)) @@ -102,13 +102,13 @@ ... TODO: Inline ASAP (def: (code' @name specification) (-> (Index UTF8) Code Attribute) - (#Code [#name @name + {#Code [#name @name ... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 #length (|> specification (/code.length ..length) //unsigned.u4 try.trusted) - #info specification])) + #info specification]}) (def: .public (code specification) (-> Code (Resource Attribute)) @@ -119,8 +119,8 @@ (def: .public (writer value) (Writer Attribute) (case value - (#Constant attribute) + {#Constant attribute} ((info_writer /constant.writer) attribute) - (#Code attribute) + {#Code attribute} ((info_writer (/code.writer writer)) attribute))) diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 85fa58c78..d999f5320 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -78,7 +78,7 @@ (def: relative_identity Relative - (function.constant (#try.Success [..no_exceptions _.empty]))) + (function.constant {#try.Success [..no_exceptions _.empty]})) (implementation: relative_monoid (Monoid Relative) @@ -106,11 +106,11 @@ (def: .public new_label (Bytecode Label) (function (_ [pool environment tracker]) - (#try.Success [[pool + {#try.Success [[pool environment (revised@ #next ++ tracker)] [..relative_identity - (value@ #next tracker)]]))) + (value@ #next tracker)]]})) (exception: .public (label_has_already_been_set [label Label]) (exception.report @@ -131,7 +131,7 @@ (with_expansions [<success> (as_is (in [[pool environment (revised@ #known - (dictionary.has label [actual (#.Some @here)]) + (dictionary.has label [actual {#.Some @here}]) tracker)] [..relative_identity []]]))] @@ -140,10 +140,10 @@ (function (_ [pool environment tracker]) (let [@here (value@ #program_counter tracker)] (case (dictionary.value label (value@ #known tracker)) - (#.Some [expected (#.Some address)]) + {#.Some [expected {#.Some address}]} (exception.except ..label_has_already_been_set [label]) - (#.Some [expected #.None]) + {#.Some [expected #.None]} (do try.monad [[actual environment] (/environment.continue expected environment)] <success>) @@ -455,10 +455,10 @@ (do ..monad [index (..lifted (//constant/pool.string value))] (case (|> index //index.value //unsigned.value //unsigned.u1) - (#try.Success index) + {#try.Success index} (..bytecode $0 $1 @_ _.ldc [index]) - (#try.Failure _) + {#try.Failure _} (..bytecode $0 $1 @_ _.ldc_w/string [index])))) (import: java/lang/Float @@ -480,10 +480,10 @@ _ (do ..monad [index (..lifted (<constant> (<constructor> value)))] (case (|> index //index.value //unsigned.value //unsigned.u1) - (#try.Success index) + {#try.Success index} (..bytecode $0 $1 @_ _.ldc [index]) - (#try.Failure _) + {#try.Failure _} (..bytecode $0 $1 @_ <wide> [index])))))] [int I32 //constant.integer //constant/pool.integer _.ldc_w/integer @@ -502,10 +502,10 @@ (do ..monad [index (..lifted (//constant/pool.float (//constant.float value)))] (case (|> index //index.value //unsigned.value //unsigned.u1) - (#try.Success index) + {#try.Success index} (..bytecode $0 $1 @_ _.ldc [index]) - (#try.Failure _) + {#try.Failure _} (..bytecode $0 $1 @_ _.ldc_w/float [index])))) (def: float_bits @@ -583,10 +583,10 @@ (def: (register id) (-> Nat (Bytecode Register)) (case (//unsigned.u1 id) - (#try.Success register) + {#try.Success register} (\ ..monad in register) - (#try.Failure error) + {#try.Failure error} (..except ..invalid_register [id]))) (template [<for> <size> <name> <general> <specials>] @@ -715,10 +715,10 @@ (def: (resolve_label label resolver) (-> Label Resolver (Try [Stack Address])) (case (dictionary.value label resolver) - (#.Some [actual (#.Some address)]) - (#try.Success [actual address]) + {#.Some [actual {#.Some address}]} + {#try.Success [actual address]} - (#.Some [actual #.None]) + {#.Some [actual #.None]} (exception.except ..unset_label [label]) #.None @@ -727,7 +727,7 @@ (def: (acknowledge_label stack label tracker) (-> Stack Label Tracker Tracker) (case (dictionary.value label (value@ #known tracker)) - (#.Some _) + {#.Some _} tracker #.None @@ -757,10 +757,10 @@ (\ /stack.equivalence = expected actual)) jump (..jump @from @to)] (case jump - (#.Left jump) + {#.Left jump} (exception.except ..cannot_do_a_big_jump [label @from jump]) - (#.Right jump) + {#.Right jump} (in [..no_exceptions (bytecode jump)])))) []]])))))))] @@ -802,19 +802,19 @@ (with@ #program_counter program_counter'))] [(function (_ resolver) (case (dictionary.value label resolver) - (#.Some [expected (#.Some @to)]) + {#.Some [expected {#.Some @to}]} (do try.monad [_ (exception.assertion ..mismatched_environments [(name_of <instruction>) label @here expected actual] (\ /stack.equivalence = expected actual)) jump (..jump @from @to)] (case jump - (#.Left jump) + {#.Left jump} <on_long_jump> - (#.Right jump) + {#.Right jump} <on_short_jump>)) - (#.Some [expected #.None]) + {#.Some [expected #.None]} (exception.except ..unset_label [label]) #.None @@ -832,10 +832,10 @@ (def: (big_jump jump) (-> Any_Jump Big_Jump) (case jump - (#.Left big) + {#.Left big} big - (#.Right small) + {#.Right small} (/jump.lifted small))) (exception: .public invalid_tableswitch) @@ -865,7 +865,7 @@ (monad.each ! get) (monad.then ! (monad.each ! product.right)))] (in [@default @at_minimum @afterwards])) - (#.Some [@default @at_minimum @afterwards]) + {#.Some [@default @at_minimum @afterwards]} (do [! try.monad] [>default (\ ! each ..big_jump (..jump @from @default)) >at_minimum (\ ! each ..big_jump (..jump @from @at_minimum)) @@ -907,7 +907,7 @@ (monad.each ! (|>> product.right get)) (monad.then ! (monad.each ! product.right)))] (in [@default @cases])) - (#.Some [@default @cases]) + {#.Some [@default @cases]} (do [! try.monad] [>default (\ ! each ..big_jump (..jump @from @default)) >cases (|> @cases @@ -1025,7 +1025,7 @@ (do ..monad [@catch (..lifted (//constant/pool.class (//name.internal (..reflection catch))))] (function (_ [pool environment tracker]) - (#try.Success + {#try.Success [[pool environment (..acknowledge_label /stack.catch @handler tracker)] @@ -1042,7 +1042,7 @@ #//exception.handler @handler #//exception.catch @catch]) _.empty]))) - []]])))) + []]]}))) (def: .public (composite pre post) (All (_ pre post) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux index 9ba2ca0d4..c7b6481fb 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux @@ -28,7 +28,7 @@ (do try.monad [limit (<limit> type)] (in [#limit limit - #stack (#.Some /stack.empty)])))] + #stack {#.Some /stack.empty}])))] [static /limit.static] [virtual /limit.virtual] @@ -53,8 +53,8 @@ (def: .public (stack environment) (-> Environment (Try Stack)) (case (value@ #..stack environment) - (#.Some stack) - (#try.Success stack) + {#.Some stack} + {#try.Success stack} #.None (exception.except ..discontinuity []))) @@ -72,13 +72,13 @@ (def: .public (continue expected environment) (-> Stack Environment (Try [Stack Environment])) (case (value@ #..stack environment) - (#.Some actual) + {#.Some actual} (if (\ /stack.equivalence = expected actual) - (#try.Success [actual environment]) + {#try.Success [actual environment]} (exception.except ..mismatched_stacks [expected actual])) #.None - (#try.Success [expected (with@ #..stack (#.Some expected) environment)]))) + {#try.Success [expected (with@ #..stack {#.Some expected} environment)]})) (def: .public (consumes amount) (-> U2 Condition) @@ -88,7 +88,7 @@ (do try.monad [previous (..stack environment) current (/stack.pop amount previous)] - (in (with@ #..stack (#.Some current) environment))))) + (in (with@ #..stack {#.Some current} environment))))) (def: .public (produces amount) (-> U2 Condition) @@ -100,7 +100,7 @@ (value@ [#..limit #/limit.stack]) (/stack.max current))]] (in (|> environment - (with@ #..stack (#.Some current)) + (with@ #..stack {#.Some current}) (with@ [#..limit #/limit.stack] limit)))))) (def: .public (has registry) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index 9fe36c303..646278f35 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -634,12 +634,12 @@ _ (binary.write/32! offset (///signed.value maximum) binary)] (loop [offset (n.+ (///unsigned.value ..integer_size) offset) afterwards (: (List Big_Jump) - (#.Item at_minimum afterwards))] + {#.Item at_minimum afterwards})] (case afterwards #.End (in binary) - (#.Item head tail) + {#.Item head tail} (do ! [_ (binary.write/32! offset (///signed.value head) binary)] (recur (n.+ (///unsigned.value ..big_jump_size) offset) @@ -698,7 +698,7 @@ #.End (in binary) - (#.Item [value jump] tail) + {#.Item [value jump] tail} (do ! [_ (binary.write/32! offset (///signed.value value) binary) _ (binary.write/32! (n.+ (///unsigned.value ..integer_size) offset) (///signed.value jump) binary)] diff --git a/stdlib/source/library/lux/target/jvm/constant.lux b/stdlib/source/library/lux/target/jvm/constant.lux index d1e9b2122..27efe496d 100644 --- a/stdlib/source/library/lux/target/jvm/constant.lux +++ b/stdlib/source/library/lux/target/jvm/constant.lux @@ -157,22 +157,22 @@ (type: .public Constant (Variant - (#UTF8 UTF8) - (#Integer Integer) - (#Float Float) - (#Long Long) - (#Double Double) - (#Class Class) - (#String String) - (#Field (Reference //category.Value)) - (#Method (Reference //category.Method)) - (#Interface_Method (Reference //category.Method)) - (#Name_And_Type (Name_And_Type Any)))) + {#UTF8 UTF8} + {#Integer Integer} + {#Float Float} + {#Long Long} + {#Double Double} + {#Class Class} + {#String String} + {#Field (Reference //category.Value)} + {#Method (Reference //category.Method)} + {#Interface_Method (Reference //category.Method)} + {#Name_And_Type (Name_And_Type Any)})) (def: .public (size constant) (-> Constant Nat) (case constant - (^or (#Long _) (#Double _)) + (^or {#Long _} {#Double _}) 2 _ @@ -186,7 +186,7 @@ (def: (= reference sample) (case [reference sample] (^template [<tag> <equivalence>] - [[(<tag> reference) (<tag> sample)] + [[{<tag> reference} {<tag> sample}] (\ <equivalence> = reference sample)]) ([#UTF8 text.equivalence] [#Integer (..value_equivalence i32.equivalence)] @@ -244,7 +244,7 @@ (function (_ value) (case value (^template [<case> <tag> <writer>] - [(<case> value) + [{<case> value} (binaryF\composite (/tag.writer <tag>) (<writer> value))]) (<constants>) diff --git a/stdlib/source/library/lux/target/jvm/constant/pool.lux b/stdlib/source/library/lux/target/jvm/constant/pool.lux index 2ae78260d..41ff5ad26 100644 --- a/stdlib/source/library/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/library/lux/target/jvm/constant/pool.lux @@ -57,19 +57,19 @@ (with_expansions [<try_again> (as_is (recur (.++ idx)))] (loop [idx 0] (case (row.item idx pool) - (#try.Success entry) + {#try.Success entry} (case entry - [index (<tag> reference)] + [index {<tag> reference}] (if (\ <equivalence> = reference <value>') - (#try.Success [[current pool] - index]) + {#try.Success [[current pool] + index]} <try_again>) _ <try_again>) - (#try.Failure _) - (let [new (<tag> <value>')] + {#try.Failure _} + (let [new {<tag> <value>'}] (do [! try.monad] [@new (//unsigned.u2 (//.size new)) next (: (Try Index) diff --git a/stdlib/source/library/lux/target/jvm/encoding/signed.lux b/stdlib/source/library/lux/target/jvm/encoding/signed.lux index 3bafb4bfc..5d4f124a6 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/signed.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/signed.lux @@ -67,7 +67,7 @@ (i64.or negative value) (i64.and positive value)) value) - (#try.Success (:abstraction value)) + {#try.Success (:abstraction value)} (exception.except ..value_exceeds_the_scope [value <size>]))))) (template [<abstract_operation> <concrete_operation>] diff --git a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux index df550075b..097265bcf 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux @@ -74,7 +74,7 @@ (-> Nat (Try <name>)) (if (n.> (:representation <maximum>) value) (exception.except ..value_exceeds_the_maximum [(name_of <name>) value <maximum>]) - (#try.Success (:abstraction value)))) + {#try.Success (:abstraction value)})) (def: .public (<+> parameter subject) (-> <name> <name> (Try <name>)) @@ -88,7 +88,7 @@ subject' (:representation subject)] (if (n.> subject' parameter') (exception.except ..subtraction_cannot_yield_negative_value [(name_of <name>) parameter subject]) - (#try.Success (:abstraction (n.- parameter' subject')))))) + {#try.Success (:abstraction (n.- parameter' subject'))}))) (def: .public (<max> left right) (-> <name> <name> <name>) diff --git a/stdlib/source/library/lux/target/jvm/loader.lux b/stdlib/source/library/lux/target/jvm/loader.lux index 1d5eda342..82999be00 100644 --- a/stdlib/source/library/lux/target/jvm/loader.lux +++ b/stdlib/source/library/lux/target/jvm/loader.lux @@ -116,12 +116,12 @@ (let [class_name (:as Text class_name) classes (|> library atom.read! io.run!)] (case (dictionary.value class_name classes) - (#.Some bytecode) + {#.Some bytecode} (case (..define class_name bytecode (<| <cast> self)) - (#try.Success class) + {#try.Success class} (:expected class) - (#try.Failure error) + {#try.Failure error} (panic! (exception.error ..cannot_define [class_name error]))) #.None @@ -135,7 +135,7 @@ (in (exception.except ..already_stored name)) (do ! [_ (atom.update! (dictionary.has name bytecode) library)] - (in (#try.Success [])))))) + (in {#try.Success []}))))) (def: .public (load name loader) (-> Text java/lang/ClassLoader diff --git a/stdlib/source/library/lux/target/jvm/method.lux b/stdlib/source/library/lux/target/jvm/method.lux index 11e8e1c06..a56b732c3 100644 --- a/stdlib/source/library/lux/target/jvm/method.lux +++ b/stdlib/source/library/lux/target/jvm/method.lux @@ -59,16 +59,16 @@ (monad.all !) (\ ! each row.of_list)) attributes (case code - (#.Some code) + {#.Some code} (do ! [environment (case (if (//modifier.has? static modifier) (//bytecode/environment.static type) (//bytecode/environment.virtual type)) - (#try.Success environment) + {#try.Success environment} (in environment) - (#try.Failure error) - (function (_ _) (#try.Failure error))) + {#try.Failure error} + (function (_ _) {#try.Failure error})) [environment exceptions instruction output] (//bytecode.resolve environment code) .let [bytecode (|> instruction //bytecode/instruction.result format.instance)] @code (//attribute.code [#//attribute/code.limit (value@ #//bytecode/environment.limit environment) diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index 740d43c63..59a3d72d6 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -128,10 +128,10 @@ (def: .public (load class_loader name) (-> java/lang/ClassLoader External (Try (java/lang/Class java/lang/Object))) (case (java/lang/Class::forName name false class_loader) - (#try.Success class) - (#try.Success class) + {#try.Success class} + {#try.Success class} - (#try.Failure _) + {#try.Failure _} (exception.except ..unknown_class [name]))) (def: .public (sub? class_loader super sub) @@ -146,7 +146,7 @@ java/lang/reflect/Type (Try (/.Type Class))) (<| (case (ffi.check java/lang/Class reflection) - (#.Some class) + {#.Some class} (let [class_name (|> class (:as (java/lang/Class java/lang/Object)) java/lang/Class::getName)] @@ -164,13 +164,13 @@ [/reflection.char])) (text.starts_with? /descriptor.array_prefix class_name)) (exception.except ..not_a_class reflection) - (#try.Success (/.class class_name (list)))))) + {#try.Success (/.class class_name (list))}))) _) (case (ffi.check java/lang/reflect/ParameterizedType reflection) - (#.Some reflection) + {#.Some reflection} (let [raw (java/lang/reflect/ParameterizedType::getRawType reflection)] (case (ffi.check java/lang/Class raw) - (#.Some raw) + {#.Some raw} (do [! try.monad] [paramsT (|> reflection java/lang/reflect/ParameterizedType::getActualTypeArguments @@ -190,11 +190,11 @@ (def: .public (parameter reflection) (-> java/lang/reflect/Type (Try (/.Type Parameter))) (<| (case (ffi.check java/lang/reflect/TypeVariable reflection) - (#.Some reflection) - (#try.Success (/.var (java/lang/reflect/TypeVariable::getName reflection))) + {#.Some reflection} + {#try.Success (/.var (java/lang/reflect/TypeVariable::getName reflection))} _) (case (ffi.check java/lang/reflect/WildcardType reflection) - (#.Some reflection) + {#.Some reflection} ... TODO: Instead of having single lower/upper bounds, should ... allow for multiple ones. (case [(array.read! 0 (java/lang/reflect/WildcardType::getLowerBounds reflection)) @@ -202,18 +202,18 @@ (^template [<pattern> <kind>] [<pattern> (case (ffi.check java/lang/reflect/GenericArrayType bound) - (#.Some _) + {#.Some _} ... TODO: Array bounds should not be "erased" as they ... are right now. - (#try.Success /.wildcard) + {#try.Success /.wildcard} _ (\ try.monad each <kind> (..class' parameter bound)))]) - ([[_ (#.Some bound)] /.upper] - [[(#.Some bound) _] /.lower]) + ([[_ {#.Some bound}] /.upper] + [[{#.Some bound} _] /.lower]) _ - (#try.Success /.wildcard)) + {#try.Success /.wildcard}) _) (..class' parameter reflection))) @@ -225,14 +225,14 @@ (def: .public (type reflection) (-> java/lang/reflect/Type (Try (/.Type Value))) (<| (case (ffi.check java/lang/Class reflection) - (#.Some reflection) + {#.Some reflection} (let [class_name (|> reflection (:as (java/lang/Class java/lang/Object)) java/lang/Class::getName)] (`` (cond (~~ (template [<reflection> <type>] [(text\= (/reflection.reflection <reflection>) class_name) - (#try.Success <type>)] + {#try.Success <type>}] [/reflection.boolean /.boolean] [/reflection.byte /.byte] @@ -244,10 +244,10 @@ [/reflection.char /.char])) (if (text.starts_with? /descriptor.array_prefix class_name) (<t>.result /parser.value (|> class_name //name.internal //name.read)) - (#try.Success (/.class class_name (list))))))) + {#try.Success (/.class class_name (list))})))) _) (case (ffi.check java/lang/reflect/GenericArrayType reflection) - (#.Some reflection) + {#.Some reflection} (|> reflection java/lang/reflect/GenericArrayType::getGenericComponentType type @@ -260,13 +260,13 @@ (-> java/lang/reflect/Type (Try (/.Type Return))) (with_expansions [<else> (as_is (..type reflection))] (case (ffi.check java/lang/Class reflection) - (#.Some class) + {#.Some class} (let [class_name (|> reflection (:as (java/lang/Class java/lang/Object)) java/lang/Class::getName)] (if (text\= (/reflection.reflection /reflection.void) class_name) - (#try.Success /.void) + {#try.Success /.void} <else>)) #.None @@ -295,7 +295,7 @@ (def: .public (correspond class type) (-> (java/lang/Class java/lang/Object) Type (Try Mapping)) (case type - (#.Primitive name params) + {#.Primitive name params} (let [class_name (java/lang/Class::getName class) class_params (array.list #.None (java/lang/Class::getTypeParameters class)) num_class_params (list.size class_params) @@ -312,12 +312,12 @@ (exception.except ..type_parameter_mismatch [num_class_params num_type_params class type])) (exception.except ..cannot_correspond [class type]))) - (#.Named name anonymousT) + {#.Named name anonymousT} (correspond class anonymousT) - (#.Apply inputT abstractionT) + {#.Apply inputT abstractionT} (case (type.applied (list inputT) abstractionT) - (#.Some outputT) + {#.Some outputT} (correspond class outputT) #.None @@ -349,13 +349,13 @@ (def: .public (field field target) (-> Text (java/lang/Class java/lang/Object) (Try java/lang/reflect/Field)) (case (java/lang/Class::getDeclaredField field target) - (#try.Success field) + {#try.Success field} (let [owner (java/lang/reflect/Field::getDeclaringClass field)] (if (same? owner target) - (#try.Success field) + {#try.Success field} (exception.except ..mistaken_field_owner [field owner target]))) - (#try.Failure _) + {#try.Failure _} (exception.except ..unknown_field [field target]))) (def: .public deprecated? diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index 023d844e8..d144ac6fe 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -55,7 +55,7 @@ [(def: <name> (Parser (Check Type)) (<>.after <parser> - (<>\in (check\in (#.Primitive (//reflection.reflection <reflection>) #.End)))))] + (<>\in (check\in {#.Primitive (//reflection.reflection <reflection>) #.End}))))] [boolean //parser.boolean //reflection.boolean] [byte //parser.byte //reflection.byte] @@ -71,7 +71,7 @@ [(def: <name> (Parser (Check Type)) (<>.after <parser> - (<>\in (check\in (#.Primitive <box> #.End)))))] + (<>\in (check\in {#.Primitive <box> #.End}))))] [boxed_boolean //parser.boolean //box.boolean] [boxed_byte //parser.byte //box.byte] @@ -123,7 +123,7 @@ #.None (check.except ..unknown_var [var]) - (#.Some type) + {#.Some type} (check\in type))))) (def: (class' parameter) @@ -136,7 +136,7 @@ (<>.else (list)))] (in (do [! check.monad] [parameters (monad.all ! parameters)] - (in (#.Primitive name parameters))))) + (in {#.Primitive name parameters})))) (<>.after (<text>.this //descriptor.class_prefix)) (<>.before (<text>.this //descriptor.class_suffix)))) @@ -173,7 +173,7 @@ (-> (Parser (Check Type)) (Parser (Check Type))) (|>> (<>\each (check\each (function (_ elementT) (case elementT - (#.Primitive name #.End) + {#.Primitive name #.End} (if (`` (or (~~ (template [<reflection>] [(text\= (//reflection.reflection <reflection>) name)] @@ -185,7 +185,7 @@ [//reflection.float] [//reflection.double] [//reflection.char])))) - (#.Primitive (|> name //reflection.class //reflection.array //reflection.reflection) #.End) + {#.Primitive (|> name //reflection.class //reflection.array //reflection.reflection) #.End} (|> elementT array.Array .type)) _ @@ -229,8 +229,8 @@ (def: .public (check operation input) (All (_ a) (-> (Parser (Check a)) Text (Check a))) (case (<text>.result operation input) - (#try.Success check) + {#try.Success check} check - (#try.Failure error) + {#try.Failure error} (check.failure error))) diff --git a/stdlib/source/library/lux/target/python.lux b/stdlib/source/library/lux/target/python.lux index af0514a76..a649fbcf1 100644 --- a/stdlib/source/library/lux/target/python.lux +++ b/stdlib/source/library/lux/target/python.lux @@ -371,7 +371,7 @@ (format "while " (:representation test) ":" (..nested (:representation body!)) (case else! - (#.Some else!) + {#.Some else!} (format text.new_line "else:" (..nested (:representation else!))) @@ -424,7 +424,7 @@ (def: .public (exec code globals) (-> (Expression Any) (Maybe (Expression Any)) (Statement Any)) (let [extra (case globals - (#.Some globals) + {#.Some globals} (.list globals) #.None diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index acc560f31..85a3c92c3 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -373,7 +373,7 @@ #.None proc - (#.Some name) + {#.Some name} (format (:representation name) " = " proc)) (text.enclosed ["(" ")"]) :abstraction))) diff --git a/stdlib/source/library/lux/target/scheme.lux b/stdlib/source/library/lux/target/scheme.lux index 285d934ad..390a43867 100644 --- a/stdlib/source/library/lux/target/scheme.lux +++ b/stdlib/source/library/lux/target/scheme.lux @@ -76,7 +76,7 @@ (def: (arguments [mandatory rest]) (-> Arguments (Code Any)) (case rest - (#.Some rest) + {#.Some rest} (case mandatory #.End rest @@ -159,17 +159,17 @@ (|>> (case> #.End (:abstraction "()") - (#.Item head tail) + {#.Item head tail} (|> tail (list\each (|>> :representation ..nested)) - (#.Item (:representation head)) + {#.Item (:representation head)} (text.interposed nested_new_line) (text.enclosed ["(" ")"]) :abstraction))))) (def: .public (apply/* args func) (-> (List Expression) Expression Computation) - (..form (#.Item func args))) + (..form {#.Item func args})) (template [<name> <function>] [(def: .public (<name> members) @@ -340,7 +340,7 @@ (-> Var Arguments Expression Computation) (..form (list (..var "define") (|> arguments - (revised@ #mandatory (|>> (#.Item name))) + (revised@ #mandatory (|>> {#.Item name})) ..arguments) body))) @@ -350,7 +350,7 @@ (def: .public begin (-> (List Expression) Computation) - (|>> (#.Item (..var "begin")) ..form)) + (|>> {#.Item (..var "begin")} ..form)) (def: .public (set! name value) (-> Var Expression Computation) @@ -371,7 +371,7 @@ #.None (list) - (#.Some else) + {#.Some else} (list (..form (list (..var "else") else)))) (list\composite (list\each (function (_ [when then]) (..form (list when then))) diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index ae72ceb48..6aebcaadc 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -306,7 +306,7 @@ (loop [remaining encoding output (set.of_list name.hash (list))] (case (text.split_by ..coverage_separator remaining) - (#.Some [head tail]) + {#.Some [head tail]} (recur tail (set.has [module head] output)) #.None @@ -353,7 +353,7 @@ .let [coverage (|> definitions (list\mix (function (_ [short [exported? _]] aggregate) (if exported? - (#.Item short aggregate) + {#.Item short aggregate} aggregate)) #.End) ..encoded_coverage)]] @@ -381,10 +381,10 @@ product.right (function (_ _)) "lux try" - (case> (#try.Success output) + (case> {#try.Success output} output - (#try.Failure error) + {#try.Failure error} (..assertion (exception.error ..error_during_execution [error]) false)) io.io async.future diff --git a/stdlib/source/library/lux/time.lux b/stdlib/source/library/lux/time.lux index de7525d42..f87a8f6f6 100644 --- a/stdlib/source/library/lux/time.lux +++ b/stdlib/source/library/lux/time.lux @@ -86,7 +86,7 @@ (def: .public (of_millis milli_seconds) (-> Nat (Try Time)) (if (n.< ..limit milli_seconds) - (#try.Success (:abstraction milli_seconds)) + {#try.Success (:abstraction milli_seconds)} (exception.except ..time_exceeds_a_day [milli_seconds]))) (def: .public millis diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux index a739ff6f5..7053a71e1 100644 --- a/stdlib/source/library/lux/time/date.lux +++ b/stdlib/source/library/lux/time/date.lux @@ -79,11 +79,11 @@ (-> Year Month Nat (Try Date)) (if (..invalid_day? year month day_of_month) (exception.except ..invalid_day [year month day_of_month]) - (#try.Success + {#try.Success (:abstraction [#year year #month month - #day day_of_month])))) + #day day_of_month])})) (def: .public epoch Date diff --git a/stdlib/source/library/lux/time/day.lux b/stdlib/source/library/lux/time/day.lux index ecdbc79ab..aee0a9f33 100644 --- a/stdlib/source/library/lux/time/day.lux +++ b/stdlib/source/library/lux/time/day.lux @@ -112,7 +112,7 @@ (def: (decoded value) (case value (^template [<tag>] - [(^ (template.text [<tag>])) (#try.Success <tag>)]) + [(^ (template.text [<tag>])) {#try.Success <tag>}]) ([#..Monday] [#..Tuesday] [#..Wednesday] @@ -158,7 +158,7 @@ (-> Nat (Try Day)) (case number (^template [<number> <day>] - [<number> (#try.Success <day>)]) + [<number> {#try.Success <day>}]) (<pairs>) _ (exception.except ..invalid_day [number]))) ) diff --git a/stdlib/source/library/lux/time/duration.lux b/stdlib/source/library/lux/time/duration.lux index 2361a23f8..d0c044d39 100644 --- a/stdlib/source/library/lux/time/duration.lux +++ b/stdlib/source/library/lux/time/duration.lux @@ -178,8 +178,8 @@ (..merged (..up seconds ..second)) (..merged (..up millis ..milli_second)))]] (in (case sign - (#.Left _) (..inverse span) - (#.Right _) span))))) + {#.Left _} (..inverse span) + {#.Right _} span))))) (implementation: .public codec (Codec Text Duration) diff --git a/stdlib/source/library/lux/time/month.lux b/stdlib/source/library/lux/time/month.lux index 57724be44..e2936b80e 100644 --- a/stdlib/source/library/lux/time/month.lux +++ b/stdlib/source/library/lux/time/month.lux @@ -88,7 +88,7 @@ (-> Nat (Try Month)) (case number (^template [<number> <month>] - [<number> (#try.Success <month>)]) + [<number> {#try.Success <month>}]) (<pairs>) _ (exception.except ..invalid_month [number]))) ) @@ -226,7 +226,7 @@ (def: (decoded value) (case value (^template [<tag>] - [(^ (template.text [<tag>])) (#try.Success <tag>)]) + [(^ (template.text [<tag>])) {#try.Success <tag>}]) ([#..January] [#..February] [#..March] diff --git a/stdlib/source/library/lux/time/year.lux b/stdlib/source/library/lux/time/year.lux index 5a621bac3..9b69e84d6 100644 --- a/stdlib/source/library/lux/time/year.lux +++ b/stdlib/source/library/lux/time/year.lux @@ -42,7 +42,7 @@ (-> Int (Try Year)) (case value +0 (exception.except ..there_is_no_year_0 []) - _ (#try.Success (:abstraction (..internal value))))) + _ {#try.Success (:abstraction (..internal value))})) (def: .public value (-> Year Int) @@ -118,8 +118,8 @@ digits (<text>.many <text>.decimal) raw_year (<>.codec i.decimal (in (text\composite "+" digits)))] (<>.lifted (..year (case sign - (#.Left _) (i.* -1 raw_year) - (#.Right _) raw_year))))) + {#.Left _} (i.* -1 raw_year) + {#.Right _} raw_year))))) (implementation: .public codec (Codec Text Year) diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux index 35759ca87..a43b9a4d9 100644 --- a/stdlib/source/library/lux/tool/compiler/default/init.lux +++ b/stdlib/source/library/lux/tool/compiler/default/init.lux @@ -94,22 +94,22 @@ (def: (reader current_module aliases [location offset source_code]) (-> Module Aliases Source (///analysis.Operation Reader)) (function (_ [bundle state]) - (#try.Success [[bundle state] - (///syntax.parse current_module aliases ("lux text size" source_code))]))) + {#try.Success [[bundle state] + (///syntax.parse current_module aliases ("lux text size" source_code))]})) (def: (read source reader) (-> Source Reader (///analysis.Operation [Source Code])) (function (_ [bundle compiler]) (case (reader source) - (#.Left [source' error]) - (#try.Failure error) + {#.Left [source' error]} + {#try.Failure error} - (#.Right [source' output]) + {#.Right [source' output]} (let [[location _] output] - (#try.Success [[bundle (|> compiler + {#try.Success [[bundle (|> compiler (with@ #.source source') (with@ #.location location))] - [source' output]]))))) + [source' output]]})))) (type: (Operation a) (All (_ anchor expression directive) @@ -209,13 +209,13 @@ (..reader module aliases source))] (function (_ state) (case (///phase.result' state (..iteration' wrapper archive expander reader source pre_payload)) - (#try.Success [state source&requirements&buffer]) - (#try.Success [state (#.Some source&requirements&buffer)]) + {#try.Success [state source&requirements&buffer]} + {#try.Success [state {#.Some source&requirements&buffer}]} - (#try.Failure error) + {#try.Failure error} (if (exception.match? ///syntax.end_of_file error) - (#try.Success [state #.None]) - (exception.with ///.cannot_compile module (#try.Failure error))))))) + {#try.Success [state #.None]} + (exception.with ///.cannot_compile module {#try.Failure error})))))) (def: (default_dependencies prelude input) (-> Module ///.Input (List Module)) @@ -257,16 +257,16 @@ #descriptor.state #.Compiled #descriptor.registry final_registry]]] (in [state - (#.Right [descriptor + {#.Right [descriptor (document.write key analysis_module) (row\each (function (_ [artifact_id custom directive]) [artifact_id custom (write_directive directive)]) - final_buffer)])])) + final_buffer)]}])) - (#.Some [source requirements temporary_payload]) + {#.Some [source requirements temporary_payload]} (let [[temporary_buffer temporary_registry] temporary_payload] (in [state - (#.Left [#///.dependencies (|> requirements + {#.Left [#///.dependencies (|> requirements (value@ #///directive.imports) (list\each product.left)) #///.process (function (_ state archive) @@ -284,5 +284,5 @@ (value@ #///directive.referrals) (monad.each ! (execute! archive))) temporary_payload (..get_current_payload temporary_payload)] - (..iteration wrapper archive expander module source temporary_payload (..module_aliases analysis_module))))))])])) + (..iteration wrapper archive expander module source temporary_payload (..module_aliases analysis_module))))))]}])) )))))])))) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index d24ad8f33..f884282eb 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -382,7 +382,7 @@ (exception.except ..cannot_import_circular_dependency [importer importee]) ... else - (#try.Success []))) + {#try.Success []})) (with_expansions [<Context> (as_is [Archive <State+>]) <Result> (as_is (Try <Context>)) @@ -423,20 +423,20 @@ [[_ dependence] (stm.update (..depend importer module) dependence)] (in dependence)))] (case (..verify_dependencies importer module dependence) - (#try.Failure error) - (in [(async.resolved (#try.Failure error)) + {#try.Failure error} + (in [(async.resolved {#try.Failure error}) #.None]) - (#try.Success _) + {#try.Success _} (do ! [[archive state] (stm.read current)] (if (archive.archived? archive module) - (in [(async\in (#try.Success [archive state])) + (in [(async\in {#try.Success [archive state]}) #.None]) (do ! [@pending (stm.read pending)] (case (dictionary.value module @pending) - (#.Some [return signal]) + {#.Some [return signal]} (in [return #.None]) @@ -446,7 +446,7 @@ [module_id (archive.id module archive)] (in [module_id archive])) (archive.reserve module archive)) - (#try.Success [module_id archive]) + {#try.Success [module_id archive]} (do ! [_ (stm.write [archive state] current) .let [[return signal] (:sharing [<type_vars>] @@ -457,31 +457,31 @@ (async.async []))] _ (stm.update (dictionary.has module [return signal]) pending)] (in [return - (#.Some [[archive state] + {#.Some [[archive state] module_id - signal])])) + signal]}])) - (#try.Failure error) - (in [(async\in (#try.Failure error)) + {#try.Failure error} + (in [(async\in {#try.Failure error}) #.None]))))))))))) _ (case signal #.None (in []) - (#.Some [context module_id resolver]) + {#.Some [context module_id resolver]} (do ! [result (compile importer import! module_id context module) result (case result - (#try.Failure error) + {#try.Failure error} (in result) - (#try.Success [resulting_archive resulting_state]) + {#try.Success [resulting_archive resulting_state]} (stm.commit! (do stm.monad [[_ [merged_archive _]] (stm.update (function (_ [archive state]) [(archive.merged resulting_archive archive) state]) current)] - (in (#try.Success [merged_archive resulting_state]))))) + (in {#try.Success [merged_archive resulting_state]})))) _ (async.future (resolver result))] (in [])))] return))))) @@ -579,7 +579,7 @@ #.End (in [archive state]) - (#.Item _) + {#.Item _} (do ! [archive,document+ (|> new_dependencies (list\each (import! module)) @@ -598,27 +598,27 @@ try.trusted product.left) archive) - (#try.Success [state more|done]) + {#try.Success [state more|done]} (case more|done - (#.Left more) + {#.Left more} (continue! [archive state] more all_dependencies) - (#.Right [descriptor document output]) + {#.Right [descriptor document output]} (do ! [.let [_ (debug.log! (..module_compilation_log module state)) descriptor (with@ #descriptor.references all_dependencies descriptor)] _ (..cache_module static platform module_id [descriptor document output])] (case (archive.has module [descriptor document output] archive) - (#try.Success archive) + {#try.Success archive} (in [archive (..with_reset_log state)]) - (#try.Failure error) - (async\in (#try.Failure error))))) + {#try.Failure error} + (async\in {#try.Failure error})))) - (#try.Failure error) + {#try.Failure error} (do ! [_ (ioW.freeze (value@ #&file_system platform) static archive)] - (async\in (#try.Failure error)))))))))] + (async\in {#try.Failure error}))))))))] (compiler archive.runtime_module compilation_module))) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux index 35c150116..fb9566948 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux @@ -38,12 +38,12 @@ (type: .public Primitive (.Variant #Unit - (#Bit Bit) - (#Nat Nat) - (#Int Int) - (#Rev Rev) - (#Frac Frac) - (#Text Text))) + {#Bit Bit} + {#Nat Nat} + {#Int Int} + {#Rev Rev} + {#Frac Frac} + {#Text Text})) (type: .public Tag Nat) @@ -77,15 +77,15 @@ (type: .public (Composite a) (.Variant - (#Variant (Variant a)) - (#Tuple (Tuple a)))) + {#Variant (Variant a)} + {#Tuple (Tuple a)})) (type: .public Pattern (Rec Pattern (.Variant - (#Simple Primitive) - (#Complex (Composite Pattern)) - (#Bind Register)))) + {#Simple Primitive} + {#Complex (Composite Pattern)} + {#Bind Register}))) (type: .public (Branch' e) (Record @@ -101,13 +101,13 @@ (type: .public Analysis (Rec Analysis (.Variant - (#Primitive Primitive) - (#Structure (Composite Analysis)) - (#Reference Reference) - (#Case Analysis (Match' Analysis)) - (#Function (Environment Analysis) Analysis) - (#Apply Analysis Analysis) - (#Extension (Extension Analysis))))) + {#Primitive Primitive} + {#Structure (Composite Analysis)} + {#Reference Reference} + {#Case Analysis (Match' Analysis)} + {#Function (Environment Analysis) Analysis} + {#Apply Analysis Analysis} + {#Extension (Extension Analysis)}))) (type: .public Branch (Branch' Analysis)) @@ -124,7 +124,7 @@ true (^template [<tag> <=>] - [[(<tag> reference) (<tag> sample)] + [[{<tag> reference} {<tag> sample}] (<=> reference sample)]) ([#Bit bit\=] [#Nat n.=] @@ -141,13 +141,13 @@ (def: (= reference sample) (case [reference sample] - [(#Variant [reference_lefts reference_right? reference_value]) - (#Variant [sample_lefts sample_right? sample_value])] + [{#Variant [reference_lefts reference_right? reference_value]} + {#Variant [sample_lefts sample_right? sample_value]}] (and (n.= reference_lefts sample_lefts) (bit\= reference_right? sample_right?) (/\= reference_value sample_value)) - [(#Tuple reference) (#Tuple sample)] + [{#Tuple reference} {#Tuple sample}] (\ (list.equivalence /\=) = reference sample) _ @@ -161,13 +161,13 @@ (def: (hash value) (case value - (#Variant [lefts right? value]) + {#Variant [lefts right? value]} ($_ n.* 2 (\ n.hash hash lefts) (\ bit.hash hash right?) (\ super hash value)) - (#Tuple members) + {#Tuple members} ($_ n.* 3 (\ (list.hash super) hash members)) ))) @@ -177,13 +177,13 @@ (def: (= reference sample) (case [reference sample] - [(#Simple reference) (#Simple sample)] + [{#Simple reference} {#Simple sample}] (\ primitive_equivalence = reference sample) - [(#Complex reference) (#Complex sample)] + [{#Complex reference} {#Complex sample}] (\ (composite_equivalence =) = reference sample) - [(#Bind reference) (#Bind sample)] + [{#Bind reference} {#Bind sample}] (n.= reference sample) _ @@ -201,31 +201,31 @@ (def: (= reference sample) (case [reference sample] - [(#Primitive reference) (#Primitive sample)] + [{#Primitive reference} {#Primitive sample}] (\ primitive_equivalence = reference sample) - [(#Structure reference) (#Structure sample)] + [{#Structure reference} {#Structure sample}] (\ (composite_equivalence =) = reference sample) - [(#Reference reference) (#Reference sample)] + [{#Reference reference} {#Reference sample}] (\ reference.equivalence = reference sample) - [(#Case [reference_analysis reference_match]) - (#Case [sample_analysis sample_match])] + [{#Case [reference_analysis reference_match]} + {#Case [sample_analysis sample_match]}] (and (= reference_analysis sample_analysis) - (\ (list.equivalence (branch_equivalence =)) = (#.Item reference_match) (#.Item sample_match))) + (\ (list.equivalence (branch_equivalence =)) = {#.Item reference_match} {#.Item sample_match})) - [(#Function [reference_environment reference_analysis]) - (#Function [sample_environment sample_analysis])] + [{#Function [reference_environment reference_analysis]} + {#Function [sample_environment sample_analysis]}] (and (= reference_analysis sample_analysis) (\ (list.equivalence =) = reference_environment sample_environment)) - [(#Apply [reference_input reference_abstraction]) - (#Apply [sample_input sample_abstraction])] + [{#Apply [reference_input reference_abstraction]} + {#Apply [sample_input sample_abstraction]}] (and (= reference_input sample_input) (= reference_abstraction sample_abstraction)) - [(#Extension reference) (#Extension sample)] + [{#Extension reference} {#Extension sample}] (\ (extension.equivalence =) = reference sample) _ @@ -239,11 +239,11 @@ ) (template: .public (unit) - [(#..Primitive #..Unit)]) + [{#..Primitive #..Unit}]) (template [<name> <tag>] [(template: .public (<name> value) - [(#..Primitive (<tag> value))])] + [{#..Primitive {<tag> value}}])] [bit #..Bit] [nat #..Nat] @@ -264,14 +264,17 @@ (n.= (-- size) tag)) (template: .public (no_op value) - [(|> 1 #variable.Local #reference.Variable #..Reference - (#..Function (list)) - (#..Apply value))]) + [(|> 1 + {#variable.Local} + {#reference.Variable} + {#..Reference} + {#..Function (list)} + {#..Apply value})]) (def: .public (apply [abstraction inputs]) (-> (Application Analysis) Analysis) (list\mix (function (_ input abstraction') - (#Apply input abstraction')) + {#Apply input abstraction'}) abstraction inputs)) @@ -280,39 +283,39 @@ (loop [abstraction analysis inputs (list)] (case abstraction - (#Apply input next) - (recur next (#.Item input inputs)) + {#Apply input next} + (recur next {#.Item input inputs}) _ [abstraction inputs]))) (template [<name> <tag>] [(template: .public (<name> content) - [(.<| #..Reference + [(.<| {#..Reference} <tag> content)])] - [variable #reference.Variable] - [constant #reference.Constant] + [variable {#reference.Variable}] + [constant {#reference.Constant}] - [variable/local reference.local] - [variable/foreign reference.foreign] + [variable/local (reference.local)] + [variable/foreign (reference.foreign)] ) (template [<name> <tag>] [(template: .public (<name> content) - [(.<| #..Complex + [(.<| {#..Complex} <tag> content)])] - [pattern/variant #..Variant] - [pattern/tuple #..Tuple] + [pattern/variant {#..Variant}] + [pattern/tuple {#..Tuple}] ) (template [<name> <tag>] [(template: .public (<name> content) - [(.<| #..Structure - <tag> + [(.<| {#..Structure} + {<tag>} content)])] [variant #..Variant] @@ -320,11 +323,11 @@ ) (template: .public (pattern/unit) - [(#..Simple #..Unit)]) + [{#..Simple #..Unit}]) (template [<name> <tag>] [(template: .public (<name> content) - [(#..Simple (<tag> content))])] + [{#..Simple {<tag> content}}])] [pattern/bit #..Bit] [pattern/nat #..Nat] @@ -335,18 +338,18 @@ ) (template: .public (pattern/bind register) - [(#..Bind register)]) + [{#..Bind register}]) (def: .public (%analysis analysis) (Format Analysis) (case analysis - (#Primitive primitive) + {#Primitive primitive} (case primitive #Unit "[]" (^template [<tag> <format>] - [(<tag> value) + [{<tag> value} (<format> value)]) ([#Bit %.bit] [#Nat %.nat] @@ -355,24 +358,24 @@ [#Frac %.frac] [#Text %.text])) - (#Structure structure) + {#Structure structure} (case structure - (#Variant [lefts right? value]) + {#Variant [lefts right? value]} (format "(" (%.nat lefts) " " (%.bit right?) " " (%analysis value) ")") - (#Tuple members) + {#Tuple members} (|> members (list\each %analysis) (text.interposed " ") (text.enclosed ["[" "]"]))) - (#Reference reference) + {#Reference reference} (reference.format reference) - (#Case analysis match) + {#Case analysis match} "{?}" - (#Function environment body) + {#Function environment body} (|> (%analysis body) (format " ") (format (|> environment @@ -381,15 +384,15 @@ (text.enclosed ["[" "]"]))) (text.enclosed ["(" ")"])) - (#Apply _) + {#Apply _} (|> analysis ..application - #.Item + {#.Item} (list\each %analysis) (text.interposed " ") (text.enclosed ["(" ")"])) - (#Extension name parameters) + {#Extension name parameters} (|> parameters (list\each %analysis) (text.interposed " ") @@ -412,12 +415,12 @@ (function (_ [bundle state]) (let [old_source (value@ #.source state)] (case (action [bundle (with@ #.source source state)]) - (#try.Success [[bundle' state'] output]) - (#try.Success [[bundle' (with@ #.source old_source state')] - output]) + {#try.Success [[bundle' state'] output]} + {#try.Success [[bundle' (with@ #.source old_source state')] + output]} - (#try.Failure error) - (#try.Failure error))))) + {#try.Failure error} + {#try.Failure error})))) (def: fresh_bindings (All (_ k v) (Bindings k v)) @@ -434,18 +437,18 @@ (def: .public (with_scope action) (All (_ a) (-> (Operation a) (Operation [Scope a]))) (function (_ [bundle state]) - (case (action [bundle (revised@ #.scopes (|>> (#.Item fresh_scope)) state)]) - (#try.Success [[bundle' state'] output]) + (case (action [bundle (revised@ #.scopes (|>> {#.Item fresh_scope}) state)]) + {#try.Success [[bundle' state'] output]} (case (value@ #.scopes state') - (#.Item head tail) - (#try.Success [[bundle' (with@ #.scopes tail state')] - [head output]]) + {#.Item head tail} + {#try.Success [[bundle' (with@ #.scopes tail state')] + [head output]]} #.End - (#try.Failure "Impossible error: Drained scopes!")) + {#try.Failure "Impossible error: Drained scopes!"}) - (#try.Failure error) - (#try.Failure error)))) + {#try.Failure error} + {#try.Failure error}))) (def: scope_reset (List Scope) @@ -455,18 +458,18 @@ (All (_ a) (-> (Operation a) (Operation a))) (function (_ [bundle state]) (case (action [bundle (with@ #.scopes ..scope_reset state)]) - (#try.Success [[bundle' state'] output]) - (#try.Success [[bundle' (with@ #.scopes (value@ #.scopes state) state')] - output]) + {#try.Success [[bundle' state'] output]} + {#try.Success [[bundle' (with@ #.scopes (value@ #.scopes state) state')] + output]} - (#try.Failure error) - (#try.Failure error)))) + {#try.Failure error} + {#try.Failure error}))) (def: .public (with_current_module name) (All (_ a) (-> Text (Operation a) (Operation a))) (extension.localized (value@ #.current_module) (with@ #.current_module) - (function.constant (#.Some name)))) + (function.constant {#.Some name}))) (def: .public (with_location location action) (All (_ a) (-> Location (Operation a) (Operation a))) @@ -475,12 +478,12 @@ (function (_ [bundle state]) (let [old_location (value@ #.location state)] (case (action [bundle (with@ #.location location state)]) - (#try.Success [[bundle' state'] output]) - (#try.Success [[bundle' (with@ #.location old_location state')] - output]) + {#try.Success [[bundle' state'] output]} + {#try.Success [[bundle' (with@ #.location old_location state')] + output]} - (#try.Failure error) - (#try.Failure error)))))) + {#try.Failure error} + {#try.Failure error}))))) (def: (locate_error location error) (-> Location Text Text) @@ -490,7 +493,7 @@ (def: .public (failure error) (-> Text Operation) (function (_ [bundle state]) - (#try.Failure (locate_error (value@ #.location state) error)))) + {#try.Failure (locate_error (value@ #.location state) error)})) (def: .public (except exception parameters) (All (_ e) (-> (Exception e) e Operation)) @@ -505,7 +508,7 @@ (def: .public (failure' error) (-> Text (phase.Operation Lux)) (function (_ state) - (#try.Failure (locate_error (value@ #.location state) error)))) + {#try.Failure (locate_error (value@ #.location state) error)})) (def: .public (except' exception parameters) (All (_ e) (-> (Exception e) e (phase.Operation Lux))) @@ -516,18 +519,18 @@ (function (_ bundle,state) (case (exception.with exception message (action bundle,state)) - (#try.Success output) - (#try.Success output) + {#try.Success output} + {#try.Success output} - (#try.Failure error) + {#try.Failure error} (let [[bundle state] bundle,state] - (#try.Failure (locate_error (value@ #.location state) error)))))) + {#try.Failure (locate_error (value@ #.location state) error)})))) (def: .public (install state) (-> .Lux (Operation Any)) (function (_ [bundle _]) - (#try.Success [[bundle state] - []]))) + {#try.Success [[bundle state] + []]})) (template [<name> <type> <field> <value>] [(def: .public (<name> value) @@ -535,7 +538,7 @@ (extension.update (with@ <field> <value>)))] [set_source_code Source #.source value] - [set_current_module Text #.current_module (#.Some value)] + [set_current_module Text #.current_module {#.Some value}] [set_location Location #.location value] ) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux index 0b9e317fe..ed5983d14 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux @@ -38,10 +38,10 @@ (do try.monad [output (expander macro inputs state)] (case output - (#try.Success output) - (#try.Success output) + {#try.Success output} + {#try.Success output} - (#try.Failure error) + {#try.Failure error} ((meta.failure (exception.error ..expansion_failed [name inputs error])) state))))) (def: .public (expand_one expander name macro inputs) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux index dd8d86836..cd74d94f4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux @@ -70,7 +70,7 @@ (All (_ anchor expression directive) (Operation anchor expression directive <phase>)) (function (_ [bundle state]) - (#try.Success [[bundle state] (value@ [<component> #..phase] state)])))] + {#try.Success [[bundle state] (value@ [<component> #..phase] state)]}))] [analysis #..analysis analysis.Phase] [synthesis #..synthesis synthesis.Phase] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux index 7ed71e658..72a086650 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux @@ -115,21 +115,21 @@ (All (_ anchor expression directive output) <with_type>) (function (_ body) (function (_ [bundle state]) - (case (body [bundle (with@ <tag> (#.Some <with_value>) state)]) - (#try.Success [[bundle' state'] output]) - (#try.Success [[bundle' (with@ <tag> (value@ <tag> state) state')] - output]) + (case (body [bundle (with@ <tag> {#.Some <with_value>} state)]) + {#try.Success [[bundle' state'] output]} + {#try.Success [[bundle' (with@ <tag> (value@ <tag> state) state')] + output]} - (#try.Failure error) - (#try.Failure error))))) + {#try.Failure error} + {#try.Failure error})))) (def: .public <get> (All (_ anchor expression directive) (Operation anchor expression directive <get_type>)) (function (_ (^@ stateE [bundle state])) (case (value@ <tag> state) - (#.Some output) - (#try.Success [stateE output]) + {#.Some output} + {#try.Success [stateE output]} #.None (exception.except <exception> [])))) @@ -138,8 +138,8 @@ (All (_ anchor expression directive) (-> <get_type> (Operation anchor expression directive Any))) (function (_ [bundle state]) - (#try.Success [[bundle (with@ <tag> (#.Some value) state)] - []])))] + {#try.Success [[bundle (with@ <tag> {#.Some value} state)] + []]}))] [#anchor (with_anchor anchor) @@ -160,14 +160,14 @@ (All (_ anchor expression directive) (Operation anchor expression directive artifact.Registry)) (function (_ (^@ stateE [bundle state])) - (#try.Success [stateE (value@ #registry state)]))) + {#try.Success [stateE (value@ #registry state)]})) (def: .public (set_registry value) (All (_ anchor expression directive) (-> artifact.Registry (Operation anchor expression directive Any))) (function (_ [bundle state]) - (#try.Success [[bundle (with@ #registry value state)] - []]))) + {#try.Success [[bundle (with@ #registry value state)] + []]})) (def: .public next (All (_ anchor expression directive) @@ -197,10 +197,10 @@ (-> Context expression (Operation anchor expression directive Any))) (function (_ (^@ state+ [bundle state])) (case (\ (value@ #host state) evaluate! label code) - (#try.Success output) - (#try.Success [state+ output]) + {#try.Success output} + {#try.Success [state+ output]} - (#try.Failure error) + {#try.Failure error} (exception.except ..cannot_interpret error)))) (def: .public (execute! code) @@ -208,10 +208,10 @@ (-> directive (Operation anchor expression directive Any))) (function (_ (^@ state+ [bundle state])) (case (\ (value@ #host state) execute! code) - (#try.Success output) - (#try.Success [state+ output]) + {#try.Success output} + {#try.Success [state+ output]} - (#try.Failure error) + {#try.Failure error} (exception.except ..cannot_interpret error)))) (def: .public (define! context custom code) @@ -219,10 +219,10 @@ (-> Context (Maybe Text) expression (Operation anchor expression directive [Text Any directive]))) (function (_ (^@ stateE [bundle state])) (case (\ (value@ #host state) define! context custom code) - (#try.Success output) - (#try.Success [stateE output]) + {#try.Success output} + {#try.Success [stateE output]} - (#try.Failure error) + {#try.Failure error} (exception.except ..cannot_interpret error)))) (def: .public (save! artifact_id custom code) @@ -231,11 +231,11 @@ (do [! phase.monad] [?buffer (extension.read (value@ #buffer))] (case ?buffer - (#.Some buffer) + {#.Some buffer} ... TODO: Optimize by no longer checking for overwrites... (if (row.any? (|>> product.left (n.= artifact_id)) buffer) (phase.except ..cannot_overwrite_output [artifact_id]) - (extension.update (with@ #buffer (#.Some (row.suffix [artifact_id custom code] buffer))))) + (extension.update (with@ #buffer {#.Some (row.suffix [artifact_id custom code] buffer)}))) #.None (phase.except ..no_buffer_for_saving_code [artifact_id])))) @@ -246,8 +246,8 @@ (-> Text (Operation anchor expression directive artifact.ID))) (function (_ (^@ stateE [bundle state])) (let [[id registry'] (<artifact> name (value@ #registry state))] - (#try.Success [[bundle (with@ #registry registry' state)] - id]))))] + {#try.Success [[bundle (with@ #registry registry' state)] + id]})))] [learn artifact.definition] [learn_custom artifact.custom] @@ -272,16 +272,16 @@ (do try.monad [module_id (archive.id _module archive) registry (if (text\= (value@ #module state) _module) - (#try.Success (value@ #registry state)) + {#try.Success (value@ #registry state)} (do try.monad [[descriptor document] (archive.find _module archive)] - (#try.Success (value@ #descriptor.registry descriptor))))] + {#try.Success (value@ #descriptor.registry descriptor)}))] (case (artifact.remember _name registry) #.None (exception.except ..unknown_definition [name (artifact.definitions registry)]) - (#.Some id) - (#try.Success [stateE [module_id id]])))))) + {#.Some id} + {#try.Success [stateE [module_id id]]}))))) (exception: .public no_context) @@ -301,7 +301,7 @@ #.None (exception.except ..no_context []) - (#.Some id) + {#.Some id} (do try.monad [module_id (archive.id (value@ #module state) archive)] (in [stateE [module_id id]]))))) @@ -313,7 +313,7 @@ (Operation anchor expression directive a))) (function (_ [bundle state]) (do try.monad - [[[bundle' state'] output] (body [bundle (with@ #context (#.Some id) state)])] + [[[bundle' state'] output] (body [bundle (with@ #context {#.Some id} state)])] (in [[bundle' (with@ #context (value@ #context state) state')] output])))) @@ -326,7 +326,7 @@ (do try.monad [[[bundle' state'] output] (body [bundle (|> state (with@ #registry registry') - (with@ #context (#.Some id)))]) + (with@ #context {#.Some id}))]) module_id (archive.id (value@ #module state) archive)] (in [[bundle' (with@ #context (value@ #context state) state')] [[module_id id] @@ -336,6 +336,6 @@ (All (_ anchor expression directive a) (-> Text (Operation anchor expression directive Any))) (function (_ [bundle state]) - (#try.Success [[bundle + {#try.Success [[bundle (revised@ #log (row.suffix message) state)] - []]))) + []]})) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux index c8c2b9fd3..53968905c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux @@ -41,7 +41,7 @@ (-> Archive Phase (Fix (-> (Code' (Ann Location)) (Operation Analysis)))) (case code' (^template [<tag> <analyser>] - [(<tag> value) + [{<tag> value} (<analyser> value)]) ([#.Bit /primitive.bit] [#.Nat /primitive.nat] @@ -50,28 +50,28 @@ [#.Frac /primitive.frac] [#.Text /primitive.text]) - (^ (#.Form (list& [_ (#.Tag tag)] - values))) + (^ {#.Form (list& [_ {#.Tag tag}] + values)}) (case values - (#.Item value #.End) + {#.Item value #.End} (/structure.tagged_sum compile tag archive value) _ (/structure.tagged_sum compile tag archive (` [(~+ values)]))) - (^ (#.Form (list& [_ (#.Nat lefts)] [_ (#.Bit right?)] - values))) + (^ {#.Form (list& [_ {#.Nat lefts}] [_ {#.Bit right?}] + values)}) (case values - (#.Item value #.End) + {#.Item value #.End} (/structure.sum compile lefts right? archive value) _ (/structure.sum compile lefts right? archive (` [(~+ values)]))) - (#.Tag tag) + {#.Tag tag} (/structure.tagged_sum compile tag archive (' [])) - (^ (#.Tuple elems)) + (^ {#.Tuple elems}) (/structure.record archive compile elems) _ @@ -80,30 +80,30 @@ (def: (compile|others expander archive compile code') (-> Expander Archive Phase (-> (Code' (Ann Location)) (Operation Analysis))) (case code' - (#.Identifier reference) + {#.Identifier reference} (/reference.reference reference) - (^ (#.Form (list [_ (#.Record branches)] input))) + (^ {#.Form (list [_ {#.Record branches}] input)}) (/case.case compile branches archive input) - (^ (#.Form (list& [_ (#.Text extension_name)] extension_args))) + (^ {#.Form (list& [_ {#.Text extension_name}] extension_args)}) (//extension.apply archive compile [extension_name extension_args]) - (^ (#.Form (list [_ (#.Tuple (list [_ (#.Identifier ["" function_name])] - [_ (#.Identifier ["" arg_name])]))] - body))) + (^ {#.Form (list [_ {#.Tuple (list [_ {#.Identifier ["" function_name]}] + [_ {#.Identifier ["" arg_name]}])}] + body)}) (/function.function compile function_name arg_name archive body) - (^ (#.Form (list& functionC argsC+))) + (^ {#.Form (list& functionC argsC+)}) (do [! //.monad] [[functionT functionA] (/type.with_inference (compile archive functionC))] (case functionA - (#/.Reference (#reference.Constant def_name)) + {#/.Reference {#reference.Constant def_name}} (do ! [?macro (//extension.lifted (meta.macro def_name))] (case ?macro - (#.Some macro) + {#.Some macro} (do ! [expansion (//extension.lifted (/macro.expand_one expander def_name macro argsC+))] (compile archive expansion)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux index ec8fb396e..d7a7bf6ab 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux @@ -69,8 +69,8 @@ #.End baseT - (#.Item head tail) - (re_quantify tail (#.UnivQ head baseT)))) + {#.Item head tail} + (re_quantify tail {#.UnivQ head baseT}))) ... Type-checking on the input value is done during the analysis of a ... "case" expression, to ensure that the patterns being used make @@ -85,53 +85,53 @@ (list)) caseT caseT] (.case caseT - (#.Var id) + {#.Var id} (do ///.monad [?caseT' (//type.with_env (check.peek id))] (.case ?caseT' - (#.Some caseT') + {#.Some caseT'} (recur envs caseT') _ (/.except ..cannot_simplify_for_pattern_matching caseT))) - (#.Named name unnamedT) + {#.Named name unnamedT} (recur envs unnamedT) - (#.UnivQ env unquantifiedT) - (recur (#.Item env envs) unquantifiedT) + {#.UnivQ env unquantifiedT} + (recur {#.Item env envs} unquantifiedT) - (#.ExQ _) + {#.ExQ _} (do ///.monad [[var_id varT] (//type.with_env check.var)] (recur envs (maybe.trusted (type.applied (list varT) caseT)))) - (#.Apply inputT funcT) + {#.Apply inputT funcT} (.case funcT - (#.Var funcT_id) + {#.Var funcT_id} (do ///.monad [funcT' (//type.with_env (do check.monad [?funct' (check.peek funcT_id)] (.case ?funct' - (#.Some funct') + {#.Some funct'} (in funct') _ (check.except ..cannot_simplify_for_pattern_matching caseT))))] - (recur envs (#.Apply inputT funcT'))) + (recur envs {#.Apply inputT funcT'})) _ (.case (type.applied (list inputT) funcT) - (#.Some outputT) + {#.Some outputT} (recur envs outputT) #.None (/.except ..cannot_simplify_for_pattern_matching caseT))) - (#.Product _) + {#.Product _} (|> caseT type.flat_tuple (list\each (re_quantify envs)) @@ -169,56 +169,56 @@ (def: (analyse_pattern num_tags inputT pattern next) (All (_ a) (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a]))) (.case pattern - [location (#.Identifier ["" name])] + [location {#.Identifier ["" name]}] (/.with_location location (do ///.monad [outputA (//scope.with_local [name inputT] next) idx //scope.next_local] - (in [(#/.Bind idx) outputA]))) + (in [{#/.Bind idx} outputA]))) (^template [<type> <input> <output>] [[location <input>] - (analyse_primitive <type> inputT location (#/.Simple <output>) next)]) - ([Bit (#.Bit pattern_value) (#/.Bit pattern_value)] - [Nat (#.Nat pattern_value) (#/.Nat pattern_value)] - [Int (#.Int pattern_value) (#/.Int pattern_value)] - [Rev (#.Rev pattern_value) (#/.Rev pattern_value)] - [Frac (#.Frac pattern_value) (#/.Frac pattern_value)] - [Text (#.Text pattern_value) (#/.Text pattern_value)] - [Any (#.Tuple #.End) #/.Unit]) + (analyse_primitive <type> inputT location {#/.Simple <output>} next)]) + ([Bit {#.Bit pattern_value} {#/.Bit pattern_value}] + [Nat {#.Nat pattern_value} {#/.Nat pattern_value}] + [Int {#.Int pattern_value} {#/.Int pattern_value}] + [Rev {#.Rev pattern_value} {#/.Rev pattern_value}] + [Frac {#.Frac pattern_value} {#/.Frac pattern_value}] + [Text {#.Text pattern_value} {#/.Text pattern_value}] + [Any {#.Tuple #.End} #/.Unit]) - (^ [location (#.Tuple (list singleton))]) + (^ [location {#.Tuple (list singleton)}]) (analyse_pattern #.None inputT singleton next) - [location (#.Tuple sub_patterns)] + [location {#.Tuple sub_patterns}] (do [! ///.monad] [record (//structure.normal sub_patterns) record_size,members,recordT (: (Operation (Maybe [Nat (List Code) Type])) (.case record - (#.Some record) + {#.Some record} (//structure.order record) #.None (in #.None)))] (.case record_size,members,recordT - (#.Some [record_size members recordT]) + {#.Some [record_size members recordT]} (do ! [_ (.case inputT - (#.Var _id) + {#.Var _id} (//type.with_env (check.check inputT recordT)) _ (in []))] - (analyse_pattern (#.Some record_size) inputT [location (#.Tuple members)] next)) + (analyse_pattern {#.Some record_size} inputT [location {#.Tuple members}] next)) #.None (/.with_location location (do [! ///.monad] [inputT' (simplify_case inputT)] (.case inputT' - (#.Product _) + {#.Product _} (let [matches (loop [types (type.flat_tuple inputT') patterns sub_patterns output (: (List [Type Code]) @@ -227,17 +227,17 @@ [#.End #.End] output - [(#.Item headT #.End) (#.Item headP #.End)] - (#.Item [headT headP] output) + [{#.Item headT #.End} {#.Item headP #.End}] + {#.Item [headT headP] output} - [remainingT (#.Item headP #.End)] - (#.Item [(type.tuple remainingT) headP] output) + [remainingT {#.Item headP #.End}] + {#.Item [(type.tuple remainingT) headP] output} - [(#.Item headT #.End) remainingP] - (#.Item [headT (code.tuple remainingP)] output) + [{#.Item headT #.End} remainingP] + {#.Item [headT (code.tuple remainingP)] output} - [(#.Item headT tailT) (#.Item headP tailP)] - (recur tailT tailP (#.Item [headT headP] output)) + [{#.Item headT tailT} {#.Item headP tailP}] + (recur tailT tailP {#.Item [headT headP] output}) _ (undefined)))] @@ -261,22 +261,22 @@ _ (/.except ..cannot_match_with_pattern [inputT' pattern])))))) - [location (#.Tag tag)] + [location {#.Tag tag}] (/.with_location location (analyse_pattern #.None inputT (` ((~ pattern))) next)) - (^ [location (#.Form (list& [_ (#.Nat lefts)] [_ (#.Bit right?)] values))]) + (^ [location {#.Form (list& [_ {#.Nat lefts}] [_ {#.Bit right?}] values)}]) (/.with_location location (do ///.monad [inputT' (simplify_case inputT)] (.case inputT' - (#.Sum _) + {#.Sum _} (let [flat_sum (type.flat_variant inputT') size_sum (list.size flat_sum) num_cases (maybe.else size_sum num_tags) idx (/.tag lefts right?)] (.case (list.item idx flat_sum) - (^multi (#.Some caseT) + (^multi {#.Some caseT} (n.< num_cases idx)) (do ///.monad [[testP nextA] (if (and (n.> num_cases size_sum) @@ -292,7 +292,7 @@ _ (/.except ..sum_has_no_case [idx inputT]))) - (#.UnivQ _) + {#.UnivQ _} (do ///.monad [[ex_id exT] (//type.with_env check.existential)] @@ -304,7 +304,7 @@ _ (/.except ..cannot_match_with_pattern [inputT' pattern])))) - (^ [location (#.Form (list& [_ (#.Tag tag)] values))]) + (^ [location {#.Form (list& [_ {#.Tag tag}] values)}]) (/.with_location location (do ///.monad [tag (///extension.lifted (meta.normal tag)) @@ -312,7 +312,7 @@ _ (//type.with_env (check.check inputT variantT)) .let [[lefts right?] (/.choice (list.size group) idx)]] - (analyse_pattern (#.Some (list.size group)) inputT (` ((~ (code.nat lefts)) (~ (code.bit right?)) (~+ values))) next))) + (analyse_pattern {#.Some (list.size group)} inputT (` ((~ (code.nat lefts)) (~ (code.bit right?)) (~+ values))) next))) _ (/.except ..not_a_pattern pattern) @@ -321,7 +321,7 @@ (def: .public (case analyse branches archive inputC) (-> Phase (List [Code Code]) Phase) (.case branches - (#.Item [patternH bodyH] branchesT) + {#.Item [patternH bodyH] branchesT} (do [! ///.monad] [[inputT inputA] (//type.with_inference (analyse archive inputC)) @@ -333,13 +333,13 @@ outputHC (|> outputH product.left /coverage.determine) outputTC (monad.each ! (|>> product.left /coverage.determine) outputT) _ (.case (monad.mix try.monad /coverage.merged outputHC outputTC) - (#try.Success coverage) + {#try.Success coverage} (///.assertion non_exhaustive_pattern_matching [inputC branches coverage] (/coverage.exhaustive? coverage)) - (#try.Failure error) + {#try.Failure error} (/.failure error))] - (in (#/.Case inputA [outputH outputT]))) + (in {#/.Case inputA [outputH outputT]})) #.End (/.except ..cannot_have_empty_branches ""))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux index 5dcedd669..70623af8a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux @@ -51,16 +51,16 @@ (Rec Coverage (.Variant #Partial - (#Bit Bit) - (#Variant (Maybe Nat) (Dictionary Nat Coverage)) - (#Seq Coverage Coverage) - (#Alt Coverage Coverage) + {#Bit Bit} + {#Variant (Maybe Nat) (Dictionary Nat Coverage)} + {#Seq Coverage Coverage} + {#Alt Coverage Coverage} #Exhaustive))) (def: .public (exhaustive? coverage) (-> Coverage Bit) (case coverage - (#Exhaustive _) + {#Exhaustive _} #1 _ @@ -72,12 +72,12 @@ #Partial "#Partial" - (#Bit value') + {#Bit value'} (|> value' %.bit - (text.enclosed ["(#Bit " ")"])) + (text.enclosed ["{#Bit " "}"])) - (#Variant ?max_cases cases) + {#Variant ?max_cases cases} (|> cases dictionary.entries (list\each (function (_ [idx coverage]) @@ -85,13 +85,13 @@ (text.interposed " ") (text.enclosed ["{" "}"]) (format (%.nat (..cases ?max_cases)) " ") - (text.enclosed ["(#Variant " ")"])) + (text.enclosed ["{#Variant " "}"])) - (#Seq left right) - (format "(#Seq " (%coverage left) " " (%coverage right) ")") + {#Seq left right} + (format "{#Seq " (%coverage left) " " (%coverage right) "}") - (#Alt left right) - (format "(#Alt " (%coverage left) " " (%coverage right) ")") + {#Alt left right} + (format "{#Alt " (%coverage left) " " (%coverage right) "}") #Exhaustive "#Exhaustive")) @@ -99,14 +99,14 @@ (def: .public (determine pattern) (-> Pattern (Operation Coverage)) (case pattern - (^or (#/.Simple #/.Unit) - (#/.Bind _)) + (^or {#/.Simple #/.Unit} + {#/.Bind _}) (////\in #Exhaustive) ... Primitive patterns always have partial coverage because there ... are too many possibilities as far as values go. (^template [<tag>] - [(#/.Simple (<tag> _)) + [{#/.Simple {<tag> _}} (////\in #Partial)]) ([#/.Nat] [#/.Int] @@ -117,17 +117,17 @@ ... Bits are the exception, since there is only "#1" and ... "#0", which means it is possible for bit ... pattern-matching to become exhaustive if complementary parts meet. - (#/.Simple (#/.Bit value)) - (////\in (#Bit value)) + {#/.Simple {#/.Bit value}} + (////\in {#Bit value}) ... Tuple patterns can be exhaustive if there is exhaustiveness for all of ... their sub-patterns. - (#/.Complex (#/.Tuple membersP+)) + {#/.Complex {#/.Tuple membersP+}} (case (list.reversed membersP+) - (^or #.End (#.Item _ #.End)) + (^or #.End {#.Item _ #.End}) (/.except ..invalid_tuple_pattern []) - (#.Item lastP prevsP+) + {#.Item lastP prevsP+} (do ////.monad [lastC (determine lastP)] (monad.mix ////.monad @@ -139,22 +139,22 @@ (in leftC) _ - (in (#Seq leftC rightC))))) + (in {#Seq leftC rightC})))) lastC prevsP+))) ... Variant patterns can be shown to be exhaustive if all the possible ... cases are handled exhaustively. - (#/.Complex (#/.Variant [lefts right? value])) + {#/.Complex {#/.Variant [lefts right? value]}} (do ////.monad [value_coverage (determine value) .let [idx (if right? (++ lefts) lefts)]] - (in (#Variant (if right? - (#.Some idx) + (in {#Variant (if right? + {#.Some idx} #.None) - (|> (dictionary.empty n.hash) - (dictionary.has idx value_coverage))))))) + (|> (dictionary.empty n.hash) + (dictionary.has idx value_coverage))})))) (def: (xor left right) (-> Bit Bit Bit) @@ -176,7 +176,7 @@ (def: (flat_alt coverage) (-> Coverage (List Coverage)) (case coverage - (#Alt left right) + {#Alt left right} (list& left (flat_alt right)) _ @@ -188,19 +188,19 @@ [#Exhaustive #Exhaustive] #1 - [(#Bit sideR) (#Bit sideS)] + [{#Bit sideR} {#Bit sideS}] (bit\= sideR sideS) - [(#Variant allR casesR) (#Variant allS casesS)] + [{#Variant allR casesR} {#Variant allS casesS}] (and (n.= (cases allR) (cases allS)) (\ (dictionary.equivalence =) = casesR casesS)) - [(#Seq leftR rightR) (#Seq leftS rightS)] + [{#Seq leftR rightR} {#Seq leftS rightS}] (and (= leftR leftS) (= rightR rightS)) - [(#Alt _) (#Alt _)] + [{#Alt _} {#Alt _}] (let [flatR (flat_alt reference) flatS (flat_alt sample)] (and (n.= (list.size flatR) (list.size flatS)) @@ -230,11 +230,11 @@ (try\in #Partial) ... 2 bit coverages are exhaustive if they complement one another. - (^multi [(#Bit sideA) (#Bit sideSF)] + (^multi [{#Bit sideA} {#Bit sideSF}] (xor sideA sideSF)) (try\in #Exhaustive) - [(#Variant allA casesA) (#Variant allSF casesSF)] + [{#Variant allA casesA} {#Variant allSF casesSF}] (let [addition_cases (cases allSF) so_far_cases (cases allA)] (cond (and (known_cases? addition_cases) @@ -250,7 +250,7 @@ [casesM (monad.mix ! (function (_ [tagA coverageA] casesSF') (case (dictionary.value tagA casesSF') - (#.Some coverageSF) + {#.Some coverageSF} (do ! [coverageM (merged coverageA coverageSF)] (in (dictionary.has tagA coverageM casesSF'))) @@ -264,15 +264,15 @@ (dictionary.size casesM)) (list.every? exhaustive? (dictionary.values casesM))) #Exhaustive - (#Variant (case allSF - (#.Some _) + {#Variant (case allSF + {#.Some _} allSF _ allA) - casesM)))))) + casesM}))))) - [(#Seq leftA rightA) (#Seq leftSF rightSF)] + [{#Seq leftA rightA} {#Seq leftSF rightSF}] (case [(coverage/= leftSF leftA) (coverage/= rightSF rightA)] ... Same prefix [#1 #0] @@ -283,17 +283,17 @@ ... (since only the "left" part would influence whether the ... merged coverage is exhaustive or not). (in leftSF) - (in (#Seq leftSF rightM)))) + (in {#Seq leftSF rightM}))) ... Same suffix [#0 #1] (do try.monad [leftM (merged leftA leftSF)] - (in (#Seq leftM rightA))) + (in {#Seq leftM rightA})) ... The 2 sequences cannot possibly be merged. [#0 #0] - (try\in (#Alt so_far addition)) + (try\in {#Alt so_far addition}) ... There is nothing the addition adds to the coverage. [#1 #1] @@ -308,12 +308,12 @@ (try\in #Exhaustive) ... The left part will always match, so the addition is redundant. - (^multi [(#Seq left right) single] + (^multi [{#Seq left right} single] (coverage/= left single)) (exception.except ..redundant_pattern [so_far addition]) ... The right part is not necessary, since it can always match the left. - (^multi [single (#Seq left right)] + (^multi [single {#Seq left right}] (coverage/= left single)) (try\in single) @@ -326,7 +326,7 @@ ... other ones in the original Alt. ... This process must be repeated until no further productive ... merges can be done. - [_ (#Alt leftS rightS)] + [_ {#Alt leftS rightS}] (do [! try.monad] [.let [fuse_once (: (-> Coverage (List Coverage) (Try [(Maybe Coverage) @@ -337,34 +337,34 @@ #.End (in [#.None (list coverageA)]) - (#.Item altSF altsSF') + {#.Item altSF altsSF'} (case (merged coverageA altSF) - (#try.Success altMSF) + {#try.Success altMSF} (case altMSF - (#Alt _) + {#Alt _} (do ! [[success altsSF+] (recur altsSF')] - (in [success (#.Item altSF altsSF+)])) + (in [success {#.Item altSF altsSF+}])) _ - (in [(#.Some altMSF) altsSF'])) + (in [{#.Some altMSF} altsSF'])) - (#try.Failure error) - (#try.Failure error)) + {#try.Failure error} + {#try.Failure error}) ))))] [successA possibilitiesSF] (fuse_once addition (flat_alt so_far))] (loop [successA successA possibilitiesSF possibilitiesSF] (case successA - (#.Some coverageA') + {#.Some coverageA'} (do ! [[successA' possibilitiesSF'] (fuse_once coverageA' possibilitiesSF)] (recur successA' possibilitiesSF')) #.None (case (list.reversed possibilitiesSF) - (#.Item last prevs) - (in (list\mix (function (_ left right) (#Alt left right)) + {#.Item last prevs} + (in (list\mix (function (_ left right) {#Alt left right}) last prevs)) @@ -376,4 +376,4 @@ ... The addition cannot possibly improve the coverage. (exception.except ..redundant_pattern [so_far addition]) ... There are now 2 alternative paths. - (try\in (#Alt so_far addition))))) + (try\in {#Alt so_far addition})))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux index fe0a32584..c0733c07a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux @@ -54,31 +54,31 @@ (loop [expectedT functionT] (/.with_stack ..cannot_analyse [expectedT function_name arg_name body] (case expectedT - (#.Named name unnamedT) + {#.Named name unnamedT} (recur unnamedT) - (#.Apply argT funT) + {#.Apply argT funT} (case (type.applied (list argT) funT) - (#.Some value) + {#.Some value} (recur value) #.None (/.failure (ex.error cannot_analyse [expectedT function_name arg_name body]))) (^template [<tag> <instancer>] - [(<tag> _) + [{<tag> _} (do ! [[_ instanceT] (//type.with_env <instancer>)] (recur (maybe.trusted (type.applied (list instanceT) expectedT))))]) ([#.UnivQ check.existential] [#.ExQ check.var]) - (#.Var id) + {#.Var id} (do ! [?expectedT' (//type.with_env (check.peek id))] (case ?expectedT' - (#.Some expectedT') + {#.Some expectedT'} (recur expectedT') ... Inference @@ -86,17 +86,17 @@ (do ! [[input_id inputT] (//type.with_env check.var) [output_id outputT] (//type.with_env check.var) - .let [functionT (#.Function inputT outputT)] + .let [functionT {#.Function inputT outputT}] functionA (recur functionT) _ (//type.with_env (check.check expectedT functionT))] (in functionA)))) - (#.Function inputT outputT) + {#.Function inputT outputT} (<| (\ ! each (.function (_ [scope bodyA]) - (#/.Function (list\each (|>> /.variable) + {#/.Function (list\each (|>> /.variable) (//scope.environment scope)) - bodyA))) + bodyA})) /.with_scope ... Functions have access not only to their argument, but ... also to themselves, through a local variable. diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux index b6d610a7f..47768945d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux @@ -66,27 +66,28 @@ (def: (replace parameter_idx replacement type) (-> Nat Type Type Type) (case type - (#.Primitive name params) - (#.Primitive name (list\each (replace parameter_idx replacement) params)) + {#.Primitive name params} + {#.Primitive name (list\each (replace parameter_idx replacement) params)} (^template [<tag>] - [(<tag> left right) - (<tag> (replace parameter_idx replacement left) - (replace parameter_idx replacement right))]) + [{<tag> left right} + {<tag> + (replace parameter_idx replacement left) + (replace parameter_idx replacement right)}]) ([#.Sum] [#.Product] [#.Function] [#.Apply]) - (#.Parameter idx) + {#.Parameter idx} (if (n.= parameter_idx idx) replacement type) (^template [<tag>] - [(<tag> env quantified) - (<tag> (list\each (replace parameter_idx replacement) env) - (replace (n.+ 2 parameter_idx) replacement quantified))]) + [{<tag> env quantified} + {<tag> (list\each (replace parameter_idx replacement) env) + (replace (n.+ 2 parameter_idx) replacement quantified)}]) ([#.UnivQ] [#.ExQ]) @@ -96,7 +97,7 @@ (def: (named_type location id) (-> Location Nat Type) (let [name (format "{New Type " (%.location location) " " (%.nat id) "}")] - (#.Primitive name (list)))) + {#.Primitive name (list)})) (def: new_named_type (Operation Type) @@ -120,17 +121,17 @@ [_ (//type.infer inferT)] (in [inferT (list)])) - (#.Item argC args') + {#.Item argC args'} (case inferT - (#.Named name unnamedT) + {#.Named name unnamedT} (general archive analyse unnamedT args) - (#.UnivQ _) + {#.UnivQ _} (do ///.monad [[var_id varT] (//type.with_env check.var)] (general archive analyse (maybe.trusted (type.applied (list varT) inferT)) args)) - (#.ExQ _) + {#.ExQ _} (do [! ///.monad] [[var_id varT] (//type.with_env check.var) output (general archive analyse @@ -146,9 +147,9 @@ (check.check varT newT))))] (in output)) - (#.Apply inputT transT) + {#.Apply inputT transT} (case (type.applied (list inputT) transT) - (#.Some outputT) + {#.Some outputT} (general archive analyse outputT args) #.None @@ -161,7 +162,7 @@ ... By inferring back-to-front, a lot of type-annotations can be ... avoided in Lux code, since the inference algorithm can piece ... things together more easily. - (#.Function inputT outputT) + {#.Function inputT outputT} (do ///.monad [[outputT' args'A] (general archive analyse outputT args') argA (<| (/.with_stack ..cannot_infer_argument [inputT argC]) @@ -169,12 +170,12 @@ (analyse archive argC))] (in [outputT' (list& argA args'A)])) - (#.Var infer_id) + {#.Var infer_id} (do ///.monad [?inferT' (//type.with_env (check.peek infer_id))] (case ?inferT' - (#.Some inferT') + {#.Some inferT'} (general archive analyse inferT' args) _ @@ -188,22 +189,22 @@ (-> Nat Type Type Type) (function (recur base) (case base - (#.Primitive name parameters) - (#.Primitive name (list\each recur parameters)) + {#.Primitive name parameters} + {#.Primitive name (list\each recur parameters)} (^template [<tag>] - [(<tag> left right) - (<tag> (recur left) (recur right))]) + [{<tag> left right} + {<tag> (recur left) (recur right)}]) ([#.Sum] [#.Product] [#.Function] [#.Apply]) - (#.Parameter index) + {#.Parameter index} (if (n.= target index) sub base) (^template [<tag>] - [(<tag> environment quantified) - (<tag> (list\each recur environment) quantified)]) + [{<tag> environment quantified} + {<tag> (list\each recur environment) quantified}]) ([#.UnivQ] [#.ExQ]) _ @@ -213,26 +214,26 @@ (def: (record' record_size target originalT inferT) (-> Nat Nat Type Type (Operation Type)) (case inferT - (#.Named name unnamedT) + {#.Named name unnamedT} (record' record_size target originalT unnamedT) (^template [<tag>] - [(<tag> env bodyT) + [{<tag> env bodyT} (do ///.monad [bodyT+ (record' record_size (n.+ 2 target) originalT bodyT)] - (in (<tag> env bodyT+)))]) + (in {<tag> env bodyT+}))]) ([#.UnivQ] [#.ExQ]) - (#.Apply inputT funcT) + {#.Apply inputT funcT} (case (type.applied (list inputT) funcT) - (#.Some outputT) + {#.Some outputT} (record' record_size target originalT outputT) #.None (/.except ..invalid_type_application inferT)) - (#.Product _) + {#.Product _} (let [[lefts right] (list.split_at (-- record_size) (type.flat_tuple inferT))] (///\in (|> inferT (type.function (list\composite lefts (list (type.tuple right)))) @@ -251,20 +252,20 @@ (loop [depth 0 currentT inferT] (case currentT - (#.Named name unnamedT) + {#.Named name unnamedT} (do ///.monad [unnamedT+ (recur depth unnamedT)] (in unnamedT+)) (^template [<tag>] - [(<tag> env bodyT) + [{<tag> env bodyT} (do ///.monad [bodyT+ (recur (++ depth) bodyT)] - (in (<tag> env bodyT+)))]) + (in {<tag> env bodyT+}))]) ([#.UnivQ] [#.ExQ]) - (#.Sum _) + {#.Sum _} (let [cases (type.flat_variant currentT) actual_size (list.size cases) boundary (-- expected_size)] @@ -272,7 +273,7 @@ (and (n.> expected_size actual_size) (n.< boundary tag))) (case (list.item tag cases) - (#.Some caseT) + {#.Some caseT} (///\in (if (n.= 0 depth) (type.function (list caseT) currentT) (let [replace' (replace (|> depth -- (n.* 2)) inferT)] @@ -296,9 +297,9 @@ ... else (/.except ..variant_tag_out_of_bounds [expected_size tag inferT]))) - (#.Apply inputT funcT) + {#.Apply inputT funcT} (case (type.applied (list inputT) funcT) - (#.Some outputT) + {#.Some outputT} (variant tag expected_size outputT) #.None diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux index 31ace4429..84124d32f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux @@ -44,19 +44,19 @@ (exception.report ["Definition" (%.name name)] ["Original" (case already_existing - (#.Alias alias) + {#.Alias alias} (format "alias " (%.name alias)) - (#.Definition definition) + {#.Definition definition} (format "definition " (%.name name)) - (#.Type _) + {#.Type _} (format "type " (%.name name)) - (#.Label _) + {#.Label _} (format "tag " (%.name name)) - (#.Slot _) + {#.Slot _} (format "slot " (%.name name)))])) (exception: .public (can_only_change_state_of_active_module [module Text @@ -82,14 +82,14 @@ (do ///.monad [self_name meta.current_module_name] (function (_ state) - (#try.Success [(revised@ #.modules + {#try.Success [(revised@ #.modules (plist.revised self_name (revised@ #.imports (function (_ current) (if (list.any? (text\= module) current) current - (#.Item module current))))) + {#.Item module current})))) state) - []]))))) + []]})))) (def: .public (alias alias module) (-> Text Text (Operation Any)) @@ -97,11 +97,11 @@ (do ///.monad [self_name meta.current_module_name] (function (_ state) - (#try.Success [(revised@ #.modules + {#try.Success [(revised@ #.modules (plist.revised self_name (revised@ #.module_aliases (: (-> (List [Text Text]) (List [Text Text])) - (|>> (#.Item [alias module]))))) + (|>> {#.Item [alias module]})))) state) - []]))))) + []]})))) (def: .public (exists? module) (-> Text (Operation Bit)) @@ -110,8 +110,8 @@ (|> state (value@ #.modules) (plist.value module) - (case> (#.Some _) #1 #.None #0) - [state] #try.Success)))) + (case> {#.Some _} #1 #.None #0) + [state] {#try.Success})))) (def: .public (define name definition) (-> Text Global (Operation Any)) @@ -122,26 +122,26 @@ (function (_ state) (case (plist.value name (value@ #.definitions self)) #.None - (#try.Success [(revised@ #.modules + {#try.Success [(revised@ #.modules (plist.has self_name (revised@ #.definitions (: (-> (List [Text Global]) (List [Text Global])) - (|>> (#.Item [name definition]))) + (|>> {#.Item [name definition]})) self)) state) - []]) + []]} - (#.Some already_existing) + {#.Some already_existing} ((/.except' ..cannot_define_more_than_once [[self_name name] already_existing]) state)))))) (def: .public (create hash name) (-> Nat Text (Operation Any)) (///extension.lifted (function (_ state) - (#try.Success [(revised@ #.modules + {#try.Success [(revised@ #.modules (plist.has name (..empty hash)) state) - []])))) + []]}))) (def: .public (with_module hash name action) (All (_ a) (-> Nat Text (Operation a) (Operation [Module a]))) @@ -158,15 +158,15 @@ (///extension.lifted (function (_ state) (case (|> state (value@ #.modules) (plist.value module_name)) - (#.Some module) + {#.Some module} (let [active? (case (value@ #.module_state module) #.Active #1 _ #0)] (if active? - (#try.Success [(revised@ #.modules + {#try.Success [(revised@ #.modules (plist.has module_name (with@ #.module_state <tag> module)) state) - []]) + []]} ((/.except' can_only_change_state_of_active_module [module_name <tag>]) state))) @@ -178,11 +178,11 @@ (///extension.lifted (function (_ state) (case (|> state (value@ #.modules) (plist.value module_name)) - (#.Some module) - (#try.Success [state + {#.Some module} + {#try.Success [state (case (value@ #.module_state module) <tag> #1 - _ #0)]) + _ #0)]} #.None ((/.except' unknown_module module_name) state)))))] @@ -197,8 +197,8 @@ (///extension.lifted (function (_ state) (case (|> state (value@ #.modules) (plist.value module_name)) - (#.Some module) - (#try.Success [state (value@ #.module_hash module)]) + {#.Some module} + {#try.Success [state (value@ #.module_hash module)]} #.None ((/.except' unknown_module module_name) state))))) @@ -208,7 +208,7 @@ (do [! ///.monad] [self_name (///extension.lifted meta.current_module_name) [type_module type_name] (case type - (#.Named type_name _) + {#.Named type_name _} (in type_name) _ @@ -218,6 +218,6 @@ (monad.each ! (function (_ [index short]) (..define (format "#" short) (if record? - (#.Slot [exported? type tags index]) - (#.Label [exported? type tags index])))) + {#.Slot [exported? type tags index]} + {#.Label [exported? type tags index]}))) (list.enumeration tags)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/primitive.lux index 17b41ba71..ad481b931 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/primitive.lux @@ -16,7 +16,7 @@ (-> <type> (Operation Analysis)) (do ///.monad [_ (//type.infer <type>)] - (in (#/.Primitive (<tag> value)))))] + (in {#/.Primitive {<tag> value}})))] [bit .Bit #/.Bit] [nat .Nat #/.Nat] @@ -30,4 +30,4 @@ (Operation Analysis) (do ///.monad [_ (//type.infer .Any)] - (in (#/.Primitive #/.Unit)))) + (in {#/.Primitive #/.Unit}))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux index f3bc9d282..26946da08 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux @@ -40,10 +40,10 @@ (do [! ///.monad] [constant (///extension.lifted (meta.definition def_name))] (case constant - (#.Alias real_def_name) + {#.Alias real_def_name} (definition real_def_name) - (#.Definition [exported? actualT _]) + {#.Definition [exported? actualT _]} (do ! [_ (//type.infer actualT) (^@ def_name [::module ::name]) (///extension.lifted (meta.normal def_name)) @@ -58,7 +58,7 @@ (/.except foreign_module_has_not_been_imported [current ::module]))) (/.except definition_has_not_been_exported def_name)))) - (#.Type [exported? value labels]) + {#.Type [exported? value labels]} (do ! [_ (//type.infer .Type) (^@ def_name [::module ::name]) (///extension.lifted (meta.normal def_name)) @@ -73,10 +73,10 @@ (/.except foreign_module_has_not_been_imported [current ::module]))) (/.except definition_has_not_been_exported def_name)))) - (#.Label _) + {#.Label _} (/.except labels_are_not_definitions [def_name]) - (#.Slot _) + {#.Slot _} (/.except labels_are_not_definitions [def_name]))))) (def: (variable var_name) @@ -84,10 +84,10 @@ (do [! ///.monad] [?var (//scope.find var_name)] (case ?var - (#.Some [actualT ref]) + {#.Some [actualT ref]} (do ! [_ (//type.infer actualT)] - (in (#.Some (|> ref ///reference.variable #/.Reference)))) + (in {#.Some (|> ref ///reference.variable #/.Reference)})) #.None (in #.None)))) @@ -99,7 +99,7 @@ (do [! ///.monad] [?var (variable simple_name)] (case ?var - (#.Some varA) + {#.Some varA} (in varA) #.None diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux index aa452e685..2b3e9f411 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux @@ -41,7 +41,7 @@ (value@ [#.locals #.mappings]) (plist.value name) (maybe\each (function (_ [type value]) - [type (#variable.Local value)])))) + [type {#variable.Local value}])))) (def: (captured? name scope) (-> Text Scope Bit) @@ -54,9 +54,9 @@ (loop [idx 0 mappings (value@ [#.captured #.mappings] scope)] (case mappings - (#.Item [_name [_source_type _source_ref]] mappings') + {#.Item [_name [_source_type _source_ref]] mappings'} (if (text\= name _name) - (#.Some [_source_type (#variable.Foreign idx)]) + {#.Some [_source_type {#variable.Foreign idx}]} (recur (++ idx) mappings')) #.End @@ -70,8 +70,8 @@ (def: (reference name scope) (-> Text Scope (Maybe [Type Variable])) (case (..local name scope) - (#.Some type) - (#.Some type) + {#.Some type} + {#.Some type} _ (..captured name scope))) @@ -85,25 +85,25 @@ (list.split_when (|>> (reference? name))))] (case outer #.End - (#.Right [state #.None]) + {#.Right [state #.None]} - (#.Item top_outer _) + {#.Item top_outer _} (let [[ref_type init_ref] (maybe.else (undefined) (..reference name top_outer)) [ref inner'] (list\mix (: (-> Scope [Variable (List Scope)] [Variable (List Scope)]) (function (_ scope ref+inner) - [(#variable.Foreign (value@ [#.captured #.counter] scope)) - (#.Item (revised@ #.captured + [{#variable.Foreign (value@ [#.captured #.counter] scope)} + {#.Item (revised@ #.captured (: (-> Foreign Foreign) (|>> (revised@ #.counter ++) (revised@ #.mappings (plist.has name [ref_type (product.left ref+inner)])))) scope) - (product.right ref+inner))])) + (product.right ref+inner)}])) [init_ref #.End] (list.reversed inner)) scopes (list\composite inner' outer)] - (#.Right [(with@ #.scopes scopes state) - (#.Some [ref_type ref])])) + {#.Right [(with@ #.scopes scopes state) + {#.Some [ref_type ref]}]}) ))))) (exception: .public cannot_create_local_binding_without_a_scope) @@ -113,7 +113,7 @@ (All (_ a) (-> [Text Type] (Operation a) (Operation a))) (function (_ [bundle state]) (case (value@ #.scopes state) - (#.Item head tail) + {#.Item head tail} (let [old_mappings (value@ [#.locals #.mappings] head) new_var_id (value@ [#.locals #.counter] head) new_head (revised@ #.locals @@ -121,21 +121,21 @@ (|>> (revised@ #.counter ++) (revised@ #.mappings (plist.has name [type new_var_id])))) head)] - (case (///.result' [bundle (with@ #.scopes (#.Item new_head tail) state)] + (case (///.result' [bundle (with@ #.scopes {#.Item new_head tail} state)] action) - (#try.Success [[bundle' state'] output]) + {#try.Success [[bundle' state'] output]} (case (value@ #.scopes state') - (#.Item head' tail') - (let [scopes' (#.Item (with@ #.locals (value@ #.locals head) head') - tail')] - (#try.Success [[bundle' (with@ #.scopes scopes' state')] - output])) + {#.Item head' tail'} + (let [scopes' {#.Item (with@ #.locals (value@ #.locals head) head') + tail'}] + {#try.Success [[bundle' (with@ #.scopes scopes' state')] + output]}) _ (exception.except ..invalid_scope_alteration [])) - (#try.Failure error) - (#try.Failure error))) + {#try.Failure error} + {#try.Failure error})) _ (exception.except ..cannot_create_local_binding_without_a_scope [])) @@ -165,19 +165,19 @@ #.End (list) - (#.Item top _) + {#.Item top _} (value@ #.name top))] (case (action [bundle (revised@ #.scopes - (|>> (#.Item (scope parent_name name))) + (|>> {#.Item (scope parent_name name)}) state)]) - (#try.Success [[bundle' state'] output]) - (#try.Success [[bundle' (revised@ #.scopes + {#try.Success [[bundle' state'] output]} + {#try.Success [[bundle' (revised@ #.scopes (|>> list.tail (maybe.else (list))) state')] - output]) + output]} - (#try.Failure error) - (#try.Failure error))))) + {#try.Failure error} + {#try.Failure error})))) (exception: .public cannot_get_next_reference_when_there_is_no_scope) @@ -186,8 +186,8 @@ (///extension.lifted (function (_ state) (case (value@ #.scopes state) - (#.Item top _) - (#try.Success [state (value@ [#.locals #.counter] top)]) + {#.Item top _} + {#try.Success [state (value@ [#.locals #.counter] top)]} #.End (exception.except ..cannot_get_next_reference_when_there_is_no_scope []))))) @@ -195,11 +195,11 @@ (def: (ref_variable ref) (-> Ref Variable) (case ref - (#.Local register) - (#variable.Local register) + {#.Local register} + {#variable.Local register} - (#.Captured register) - (#variable.Foreign register))) + {#.Captured register} + {#variable.Foreign register})) (def: .public (environment scope) (-> Scope (List Variable)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux index f6c226e9a..417fe9709 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux @@ -113,10 +113,10 @@ (check.clean expectedT))] (/.with_stack ..cannot_analyse_variant [expectedT' tag valueC] (case expectedT - (#.Sum _) + {#.Sum _} (let [flat (type.flat_variant expectedT)] (case (list.item tag flat) - (#.Some variant_type) + {#.Some variant_type} (do ! [valueA (//type.with_type variant_type (analyse archive valueC))] @@ -125,16 +125,16 @@ #.None (/.except //inference.variant_tag_out_of_bounds [(list.size flat) tag expectedT]))) - (#.Named name unnamedT) + {#.Named name unnamedT} (//type.with_type unnamedT (recur valueC)) - (#.Var id) + {#.Var id} (do ! [?expectedT' (//type.with_env (check.peek id))] (case ?expectedT' - (#.Some expectedT') + {#.Some expectedT'} (//type.with_type expectedT' (recur valueC)) @@ -145,7 +145,7 @@ (/.except ..cannot_infer_numeric_tag [expectedT tag valueC]))) (^template [<tag> <instancer>] - [(<tag> _) + [{<tag> _} (do ! [[instance_id instanceT] (//type.with_env <instancer>)] (//type.with_type (maybe.trusted (type.applied (list instanceT) expectedT)) @@ -153,15 +153,15 @@ ([#.UnivQ check.existential] [#.ExQ check.var]) - (#.Apply inputT funT) + {#.Apply inputT funT} (case funT - (#.Var funT_id) + {#.Var funT_id} (do ! [?funT' (//type.with_env (check.peek funT_id))] (case ?funT' - (#.Some funT') - (//type.with_type (#.Apply inputT funT') + {#.Some funT'} + (//type.with_type {#.Apply inputT funT'} (recur valueC)) _ @@ -169,7 +169,7 @@ _ (case (type.applied (list inputT) funT) - (#.Some outputT) + {#.Some outputT} (//type.with_type outputT (recur valueC)) @@ -187,26 +187,26 @@ (loop [membersT+ (type.flat_tuple expectedT) membersC+ members] (case [membersT+ membersC+] - [(#.Item memberT #.End) (#.Item memberC #.End)] + [{#.Item memberT #.End} {#.Item memberC #.End}] (do ! [memberA (//type.with_type memberT (analyse archive memberC))] (in (list memberA))) - [(#.Item memberT #.End) _] + [{#.Item memberT #.End} _] (//type.with_type memberT (\ ! each (|>> list) (analyse archive (code.tuple membersC+)))) - [_ (#.Item memberC #.End)] + [_ {#.Item memberC #.End}] (//type.with_type (type.tuple membersT+) (\ ! each (|>> list) (analyse archive memberC))) - [(#.Item memberT membersT+') (#.Item memberC membersC+')] + [{#.Item memberT membersT+'} {#.Item memberC membersC+'}] (do ! [memberA (//type.with_type memberT (analyse archive memberC)) memberA+ (recur membersT+' membersC+')] - (in (#.Item memberA memberA+))) + (in {#.Item memberA memberA+})) _ (/.except ..cannot_analyse_tuple [expectedT members]))))] @@ -218,19 +218,19 @@ [expectedT (///extension.lifted meta.expected_type)] (/.with_stack ..cannot_analyse_tuple [expectedT membersC] (case expectedT - (#.Product _) + {#.Product _} (..typed_product archive analyse membersC) - (#.Named name unnamedT) + {#.Named name unnamedT} (//type.with_type unnamedT (product archive analyse membersC)) - (#.Var id) + {#.Var id} (do ! [?expectedT' (//type.with_env (check.peek id))] (case ?expectedT' - (#.Some expectedT') + {#.Some expectedT'} (//type.with_type expectedT' (product archive analyse membersC)) @@ -245,7 +245,7 @@ (in (/.tuple (list\each product.right membersTA)))))) (^template [<tag> <instancer>] - [(<tag> _) + [{<tag> _} (do ! [[instance_id instanceT] (//type.with_env <instancer>)] (//type.with_type (maybe.trusted (type.applied (list instanceT) expectedT)) @@ -253,15 +253,15 @@ ([#.UnivQ check.existential] [#.ExQ check.var]) - (#.Apply inputT funT) + {#.Apply inputT funT} (case funT - (#.Var funT_id) + {#.Var funT_id} (do ! [?funT' (//type.with_env (check.peek funT_id))] (case ?funT' - (#.Some funT') - (//type.with_type (#.Apply inputT funT') + {#.Some funT'} + (//type.with_type {#.Apply inputT funT'} (product archive analyse membersC)) _ @@ -269,7 +269,7 @@ _ (case (type.applied (list inputT) funT) - (#.Some outputT) + {#.Some outputT} (//type.with_type outputT (product archive analyse membersC)) @@ -289,7 +289,7 @@ [lefts right?] (/.choice case_size idx)] expectedT (///extension.lifted meta.expected_type)] (case expectedT - (#.Var _) + {#.Var _} (do ! [inferenceT (//inference.variant idx case_size variantT) [inferredT valueA+] (//inference.general archive analyse inferenceT (list valueC))] @@ -308,13 +308,13 @@ output (: (List [Name Code]) #.End)] (case input - (^ (list& [_ (#.Tag slotH)] valueH tail)) + (^ (list& [_ {#.Tag slotH}] valueH tail)) (do ///.monad [slotH (///extension.lifted (meta.normal slotH))] - (recur tail (#.Item [slotH valueH] output))) + (recur tail {#.Item [slotH valueH] output})) #.End - (\ ///.monad in (#.Some output)) + (\ ///.monad in {#.Some output}) _ (\ ///.monad in #.None)))) @@ -327,16 +327,16 @@ (case record ... empty_record = empty_tuple = unit/any = [] #.End - (\ ///.monad in (#.Some [0 (list) Any])) + (\ ///.monad in {#.Some [0 (list) Any]}) - (#.Item [head_k head_v] _) + {#.Item [head_k head_v] _} (do [! ///.monad] [slotH' (///extension.lifted (do meta.monad [head_k (meta.normal head_k)] (meta.try (meta.slot head_k))))] (case slotH' - (#try.Success [_ slot_set recordT]) + {#try.Success [_ slot_set recordT]} (do ! [.let [size_record (list.size record) size_ts (list.size slot_set)] @@ -350,7 +350,7 @@ (do ! [key (///extension.lifted (meta.normal key))] (case (dictionary.value key tag->idx) - (#.Some idx) + {#.Some idx} (if (dictionary.key? idx->val idx) (/.except ..cannot_repeat_tag [key record]) (in (dictionary.has idx val idx->val))) @@ -363,9 +363,9 @@ .let [ordered_tuple (list\each (function (_ idx) (maybe.trusted (dictionary.value idx idx->val))) tuple_range)]] - (in (#.Some [size_ts ordered_tuple recordT]))) + (in {#.Some [size_ts ordered_tuple recordT]})) - (#try.Failure error) + {#try.Failure error} (in #.None))) )) @@ -378,12 +378,12 @@ (^ (list singletonC)) (analyse archive singletonC) - (^ (list [_ (#.Tag pseudo_slot)] singletonC)) + (^ (list [_ {#.Tag pseudo_slot}] singletonC)) (do [! ///.monad] [head_k (///extension.lifted (meta.normal pseudo_slot)) slot (///extension.lifted (meta.try (meta.slot head_k)))] (case slot - (#try.Success [_ slot_set recordT]) + {#try.Success [_ slot_set recordT]} (case (list.size slot_set) 1 (analyse archive singletonC) _ (..product archive analyse members)) @@ -398,18 +398,18 @@ #.None (..product archive analyse members) - (#.Some slots) + {#.Some slots} (do ! [record_size,membersC,recordT (..order slots)] (case record_size,membersC,recordT #.None (..product archive analyse members) - (#.Some [record_size membersC recordT]) + {#.Some [record_size membersC recordT]} (do ! [expectedT (///extension.lifted meta.expected_type)] (case expectedT - (#.Var _) + {#.Var _} (do ! [inferenceT (//inference.record record_size recordT) [inferredT membersA] (//inference.general archive analyse inferenceT membersC)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux index 7a5bde817..33a8715d5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux @@ -19,17 +19,17 @@ (def: .public (with_type expected) (All (_ a) (-> Type (Operation a) (Operation a))) (///extension.localized (value@ #.expected) (with@ #.expected) - (function.constant (#.Some expected)))) + (function.constant {#.Some expected}))) (def: .public (with_env action) (All (_ a) (-> (Check a) (Operation a))) (function (_ (^@ stateE [bundle state])) (case (action (value@ #.type_context state)) - (#try.Success [context' output]) - (#try.Success [[bundle (with@ #.type_context context' state)] - output]) + {#try.Success [context' output]} + {#try.Success [[bundle (with@ #.type_context context' state)] + output]} - (#try.Failure error) + {#try.Failure error} ((/.failure error) stateE)))) (def: .public with_fresh_env diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux index 3d3163553..dc47f7039 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux @@ -48,13 +48,13 @@ Eval) (function (_ type code lux) (case (compiler_eval archive type code [bundle lux]) - (#try.Success [[_bundle lux'] value]) - (#try.Success [lux' value]) + {#try.Success [[_bundle lux'] value]} + {#try.Success [lux' value]} - (#try.Failure error) - (#try.Failure error)))) + {#try.Failure error} + {#try.Failure error}))) -(with_expansions [<lux_def_module> (as_is [|form_location| (#.Form (list& [|text_location| (#.Text "lux def module")] annotations))])] +(with_expansions [<lux_def_module> (as_is [|form_location| {#.Form (list& [|text_location| {#.Text "lux def module"}] annotations)}])] (def: .public (phase wrapper expander) (-> //.Wrapper Expander Phase) (let [analysis (//analysis.phase expander)] @@ -70,10 +70,10 @@ extension_eval (:as Eval (wrapper (:expected compiler_eval)))] _ (//.set_state (with@ [#//extension.state #/.analysis #/.state #//extension.state #.eval] extension_eval state))] (case code - (^ [_ (#.Form (list& [_ (#.Text name)] inputs))]) + (^ [_ {#.Form (list& [_ {#.Text name}] inputs)}]) (//extension.apply archive recur [name inputs]) - (^ [_ (#.Form (list& macro inputs))]) + (^ [_ {#.Form (list& macro inputs)}]) (do ! [expansion (/.lifted_analysis (do ! @@ -84,7 +84,7 @@ (do ! [?macro (//extension.lifted (meta.macro macro_name)) macro (case ?macro - (#.Some macro) + {#.Some macro} (in macro) #.None diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux index d54049e4e..2fd695eef 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux @@ -98,8 +98,8 @@ (function (_ [bundle state]) (case (dictionary.value name bundle) #.None - (#try.Success [[(dictionary.has name (extender handler) bundle) state] - []]) + {#try.Success [[(dictionary.has name (extender handler) bundle) state] + []]} _ (exception.except ..cannot_overwrite name)))) @@ -119,7 +119,7 @@ (-> Archive (Phase s i o) (Extension i) (Operation s i o o))) (function (_ (^@ stateE [bundle state])) (case (dictionary.value name bundle) - (#.Some handler) + {#.Some handler} (((handler name phase) archive parameters) stateE) @@ -134,11 +134,11 @@ (function (_ [bundle state]) (let [old (get state)] (case (operation [bundle (set (transform old) state)]) - (#try.Success [[bundle' state'] output]) - (#try.Success [[bundle' (set old state')] output]) + {#try.Success [[bundle' state'] output]} + {#try.Success [[bundle' (set old state')] output]} - (#try.Failure error) - (#try.Failure error)))))) + {#try.Failure error} + {#try.Failure error}))))) (def: .public (temporary transform) (All (_ s i o v) @@ -147,11 +147,11 @@ (function (_ operation) (function (_ [bundle state]) (case (operation [bundle (transform state)]) - (#try.Success [[bundle' state'] output]) - (#try.Success [[bundle' state] output]) + {#try.Success [[bundle' state'] output]} + {#try.Success [[bundle' state] output]} - (#try.Failure error) - (#try.Failure error))))) + {#try.Failure error} + {#try.Failure error})))) (def: .public (with_state state) (All (_ s i o v) @@ -162,13 +162,13 @@ (All (_ s i o v) (-> (-> s v) (Operation s i o v))) (function (_ [bundle state]) - (#try.Success [[bundle state] (get state)]))) + {#try.Success [[bundle state] (get state)]})) (def: .public (update transform) (All (_ s i o) (-> (-> s s) (Operation s i o Any))) (function (_ [bundle state]) - (#try.Success [[bundle (transform state)] []]))) + {#try.Success [[bundle (transform state)] []]})) (def: .public (lifted action) (All (_ s i o v) @@ -176,8 +176,8 @@ (//.Operation [(Bundle s i o) s] v))) (function (_ [bundle state]) (case (action state) - (#try.Success [state' output]) - (#try.Success [[bundle state'] output]) + {#try.Success [state' output]} + {#try.Success [[bundle state'] output]} - (#try.Failure error) - (#try.Failure error)))) + {#try.Failure error} + {#try.Failure error}))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux index 66b58bf74..36578eb15 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux @@ -38,7 +38,7 @@ (phase archive lengthC)) [var_id varT] (analysis/type.with_env check.var) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list lengthA)))))])) + (in {#analysis.Extension extension (list lengthA)})))])) (def: array::length Handler @@ -50,7 +50,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer Nat)] - (in (#analysis.Extension extension (list arrayA)))))])) + (in {#analysis.Extension extension (list arrayA)})))])) (def: array::read Handler @@ -64,7 +64,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer varT)] - (in (#analysis.Extension extension (list indexA arrayA)))))])) + (in {#analysis.Extension extension (list indexA arrayA)})))])) (def: array::write Handler @@ -80,7 +80,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list indexA valueA arrayA)))))])) + (in {#analysis.Extension extension (list indexA valueA arrayA)})))])) (def: array::delete Handler @@ -94,7 +94,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list indexA arrayA)))))])) + (in {#analysis.Extension extension (list indexA arrayA)})))])) (def: bundle::array Bundle @@ -117,7 +117,7 @@ (phase archive constructorC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list& constructorA inputsA)))))])) + (in {#analysis.Extension extension (list& constructorA inputsA)})))])) (def: object::get Handler @@ -128,8 +128,8 @@ [objectA (analysis/type.with_type Any (phase archive objectC)) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list (analysis.text fieldC) - objectA)))))])) + (in {#analysis.Extension extension (list (analysis.text fieldC) + objectA)})))])) (def: object::do Handler @@ -141,9 +141,9 @@ (phase archive objectC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list& (analysis.text methodC) + (in {#analysis.Extension extension (list& (analysis.text methodC) objectA - inputsA)))))])) + inputsA)})))])) (def: bundle::object Bundle @@ -165,7 +165,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Any)] - (in (#analysis.Extension extension (list (analysis.text name))))))])) + (in {#analysis.Extension extension (list (analysis.text name))})))])) (def: js::apply Handler @@ -177,7 +177,7 @@ (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] - (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) + (in {#analysis.Extension extension (list& abstractionA inputsA)})))])) (def: js::type_of Handler @@ -188,7 +188,7 @@ [objectA (analysis/type.with_type Any (phase archive objectC)) _ (analysis/type.infer .Text)] - (in (#analysis.Extension extension (list objectA)))))])) + (in {#analysis.Extension extension (list objectA)})))])) (def: js::function Handler @@ -201,8 +201,8 @@ (phase archive abstractionC)) _ (analysis/type.infer (for [@.js ffi.Function] Any))] - (in (#analysis.Extension extension (list (analysis.nat arity) - abstractionA)))))])) + (in {#analysis.Extension extension (list (analysis.nat arity) + abstractionA)})))])) (def: .public bundle Bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index 9ea592c20..bc9151306 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -161,13 +161,13 @@ (def: inheritance_relationship_type_name "_jvm_inheritance") (def: .public (inheritance_relationship_type class super_class super_interfaces) (-> .Type .Type (List .Type) .Type) - (#.Primitive ..inheritance_relationship_type_name - (list& class super_class super_interfaces))) + {#.Primitive ..inheritance_relationship_type_name + (list& class super_class super_interfaces)}) ... TODO: Get rid of this template block and use the definition in ... lux/ffi.jvm.lux ASAP (template [<name> <class>] - [(def: .public <name> .Type (#.Primitive <class> #.End))] + [(def: .public <name> .Type {#.Primitive <class> #.End})] ... Boxes [Boolean box.boolean] @@ -355,23 +355,23 @@ (def: (jvm_type luxT) (-> .Type (Operation (Type Value))) (case luxT - (#.Named name anonymousT) + {#.Named name anonymousT} (jvm_type anonymousT) - (#.Apply inputT abstractionT) + {#.Apply inputT abstractionT} (case (type.applied (list inputT) abstractionT) - (#.Some outputT) + {#.Some outputT} (jvm_type outputT) #.None (/////analysis.except ..non_jvm_type luxT)) - (^ (#.Primitive (static array.type_name) (list elemT))) + (^ {#.Primitive (static array.type_name) (list elemT)}) (phase\each jvm.array (jvm_type elemT)) - (#.Primitive class parametersT) + {#.Primitive class parametersT} (case (dictionary.value class ..boxes) - (#.Some [_ primitive_type]) + {#.Some [_ primitive_type]} (case parametersT #.End (phase\in primitive_type) @@ -387,7 +387,7 @@ (do phase.monad [parameterJT (jvm_type parameterT)] (case (jvm_parser.parameter? parameterJT) - (#.Some parameterJT) + {#.Some parameterJT} (in parameterJT) #.None @@ -395,7 +395,7 @@ parametersT))] (in (jvm.class class parametersJT)))) - (#.Ex _) + {#.Ex _} (phase\in (jvm.class ..object_class (list))) _ @@ -417,11 +417,11 @@ (^ (list arrayC)) (do phase.monad [_ (typeA.infer ..int) - arrayA (typeA.with_type (#.Primitive (|> (jvm.array primitive_type) + arrayA (typeA.with_type {#.Primitive (|> (jvm.array primitive_type) ..reflection) - (list)) + (list)} (analyse archive arrayC))] - (in (#/////analysis.Extension extension_name (list arrayA)))) + (in {#/////analysis.Extension extension_name (list arrayA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -438,8 +438,8 @@ (analyse archive arrayC)) varT (typeA.with_env (check.clean varT)) arrayJT (jvm_array_type (.type (array.Array varT)))] - (in (#/////analysis.Extension extension_name (list (/////analysis.text (..signature arrayJT)) - arrayA)))) + (in {#/////analysis.Extension extension_name (list (/////analysis.text (..signature arrayJT)) + arrayA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -452,9 +452,9 @@ (do phase.monad [lengthA (typeA.with_type ..int (analyse archive lengthC)) - _ (typeA.infer (#.Primitive (|> (jvm.array primitive_type) ..reflection) - (list)))] - (in (#/////analysis.Extension extension_name (list lengthA)))) + _ (typeA.infer {#.Primitive (|> (jvm.array primitive_type) ..reflection) + (list)})] + (in {#/////analysis.Extension extension_name (list lengthA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -470,13 +470,13 @@ expectedT (///.lifted meta.expected_type) expectedJT (jvm_array_type expectedT) elementJT (case (jvm_parser.array? expectedJT) - (#.Some elementJT) + {#.Some elementJT} (in elementJT) #.None (/////analysis.except ..non_array expectedT))] - (in (#/////analysis.Extension extension_name (list (/////analysis.text (..signature elementJT)) - lengthA)))) + (in {#/////analysis.Extension extension_name (list (/////analysis.text (..signature elementJT)) + lengthA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -484,11 +484,11 @@ (def: (check_parameter objectT) (-> .Type (Operation (Type Parameter))) (case objectT - (^ (#.Primitive (static array.type_name) - (list elementT))) + (^ {#.Primitive (static array.type_name) + (list elementT)}) (/////analysis.except ..non_parameter objectT) - (#.Primitive name parameters) + {#.Primitive name parameters} (`` (cond (or (~~ (template [<type>] [(text\= (..reflection <type>) name)] @@ -506,24 +506,24 @@ ... else (phase\in (jvm.class name (list))))) - (#.Named name anonymous) + {#.Named name anonymous} (check_parameter anonymous) (^template [<tag>] - [(<tag> id) + [{<tag> id} (phase\in (jvm.class ..object_class (list)))]) ([#.Var] [#.Ex]) (^template [<tag>] - [(<tag> env unquantified) + [{<tag> env unquantified} (check_parameter unquantified)]) ([#.UnivQ] [#.ExQ]) - (#.Apply inputT abstractionT) + {#.Apply inputT abstractionT} (case (type.applied (list inputT) abstractionT) - (#.Some outputT) + {#.Some outputT} (check_parameter outputT) #.None @@ -535,7 +535,7 @@ (def: (check_jvm objectT) (-> .Type (Operation (Type Value))) (case objectT - (#.Primitive name #.End) + {#.Primitive name #.End} (`` (cond (~~ (template [<type>] [(text\= (..reflection <type>) name) (phase\in <type>)] @@ -565,34 +565,34 @@ (text.starts_with? descriptor.array_prefix name) (let [[_ unprefixed] (maybe.trusted (text.split_by descriptor.array_prefix name))] (\ phase.monad each jvm.array - (check_jvm (#.Primitive unprefixed (list))))) + (check_jvm {#.Primitive unprefixed (list)}))) ... else (phase\in (jvm.class name (list))))) - (^ (#.Primitive (static array.type_name) - (list elementT))) + (^ {#.Primitive (static array.type_name) + (list elementT)}) (|> elementT check_jvm (phase\each jvm.array)) - (#.Primitive name parameters) + {#.Primitive name parameters} (do [! phase.monad] [parameters (monad.each ! check_parameter parameters)] (phase\in (jvm.class name parameters))) - (#.Named name anonymous) + {#.Named name anonymous} (check_jvm anonymous) (^template [<tag>] - [(<tag> env unquantified) + [{<tag> env unquantified} (check_jvm unquantified)]) ([#.UnivQ] [#.ExQ]) - (#.Apply inputT abstractionT) + {#.Apply inputT abstractionT} (case (type.applied (list inputT) abstractionT) - (#.Some outputT) + {#.Some outputT} (check_jvm outputT) #.None @@ -624,10 +624,10 @@ [_ (typeA.infer lux_type) idxA (typeA.with_type ..int (analyse archive idxC)) - arrayA (typeA.with_type (#.Primitive (|> (jvm.array jvm_type) ..reflection) - (list)) + arrayA (typeA.with_type {#.Primitive (|> (jvm.array jvm_type) ..reflection) + (list)} (analyse archive arrayC))] - (in (#/////analysis.Extension extension_name (list idxA arrayA)))) + (in {#/////analysis.Extension extension_name (list idxA arrayA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) @@ -647,17 +647,17 @@ arrayJT (jvm_array_type (.type (array.Array varT))) idxA (typeA.with_type ..int (analyse archive idxC))] - (in (#/////analysis.Extension extension_name (list (/////analysis.text (..signature arrayJT)) + (in {#/////analysis.Extension extension_name (list (/////analysis.text (..signature arrayJT)) idxA - arrayA)))) + arrayA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) (def: (write_primitive_array_handler lux_type jvm_type) (-> .Type (Type Primitive) Handler) - (let [array_type (#.Primitive (|> (jvm.array jvm_type) ..reflection) - (list))] + (let [array_type {#.Primitive (|> (jvm.array jvm_type) ..reflection) + (list)}] (function (_ extension_name analyse archive args) (case args (^ (list idxC valueC arrayC)) @@ -669,9 +669,9 @@ (analyse archive valueC)) arrayA (typeA.with_type array_type (analyse archive arrayC))] - (in (#/////analysis.Extension extension_name (list idxA + (in {#/////analysis.Extension extension_name (list idxA valueA - arrayA)))) + arrayA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 3 (list.size args)]))))) @@ -693,10 +693,10 @@ (analyse archive idxC)) valueA (typeA.with_type varT (analyse archive valueC))] - (in (#/////analysis.Extension extension_name (list (/////analysis.text (..signature arrayJT)) + (in {#/////analysis.Extension extension_name (list (/////analysis.text (..signature arrayJT)) idxA valueA - arrayA)))) + arrayA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 3 (list.size args)])))) @@ -759,7 +759,7 @@ (do phase.monad [expectedT (///.lifted meta.expected_type) _ (check_object expectedT)] - (in (#/////analysis.Extension extension_name (list)))) + (in {#/////analysis.Extension extension_name (list)})) _ (/////analysis.except ///.incorrect_arity [extension_name 0 (list.size args)])))) @@ -774,7 +774,7 @@ [objectT objectA] (typeA.with_inference (analyse archive objectC)) _ (check_object objectT)] - (in (#/////analysis.Extension extension_name (list objectA)))) + (in {#/////analysis.Extension extension_name (list objectA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -789,7 +789,7 @@ (analyse archive monitorC)) _ (check_object monitorT) exprA (analyse archive exprC)] - (in (#/////analysis.Extension extension_name (list monitorA exprA)))) + (in {#/////analysis.Extension extension_name (list monitorA exprA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) @@ -809,7 +809,7 @@ (if ? (in []) (/////analysis.except non_throwable exception_class)))] - (in (#/////analysis.Extension extension_name (list exceptionA)))) + (in {#/////analysis.Extension extension_name (list exceptionA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -820,12 +820,12 @@ (case args (^ (list classC)) (case classC - [_ (#.Text class)] + [_ {#.Text class}] (do phase.monad [_ (..ensure_fresh_class! class_loader class) - _ (typeA.infer (#.Primitive "java.lang.Class" (list (#.Primitive class (list))))) + _ (typeA.infer {#.Primitive "java.lang.Class" (list {#.Primitive class (list)})}) _ (phase.lifted (reflection!.load class_loader class))] - (in (#/////analysis.Extension extension_name (list (/////analysis.text class))))) + (in {#/////analysis.Extension extension_name (list (/////analysis.text class))})) _ (/////analysis.except ///.invalid_syntax [extension_name %.code args])) @@ -846,18 +846,18 @@ object_class (check_object objectT) ? (phase.lifted (reflection!.sub? class_loader object_class sub_class))] (if ? - (in (#/////analysis.Extension extension_name (list (/////analysis.text sub_class) objectA))) + (in {#/////analysis.Extension extension_name (list (/////analysis.text sub_class) objectA)}) (/////analysis.except cannot_possibly_be_an_instance (format sub_class " !<= " object_class)))))])) (template [<name> <category> <parser>] [(def: .public (<name> mapping typeJ) (-> Mapping (Type <category>) (Operation .Type)) (case (|> typeJ ..signature (<text>.result (<parser> mapping))) - (#try.Success check) + {#try.Success check} (typeA.with_env check) - (#try.Failure error) + {#try.Failure error} (phase.failure error)))] [boxed_reflection_type Value luxT.boxed_type] @@ -880,19 +880,19 @@ superT (reflection_type mapping superJT)] (in [[super_name superT] (java/lang/Class::isAssignableFrom super_class target_class)]))) (case (java/lang/Class::getGenericSuperclass source_class) - (#.Some super) + {#.Some super} (list& super (array.list #.None (java/lang/Class::getGenericInterfaces source_class))) #.None (if (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers source_class)) - (#.Item (:as java/lang/reflect/Type (ffi.class_for java/lang/Object)) - (array.list #.None (java/lang/Class::getGenericInterfaces source_class))) + {#.Item (:as java/lang/reflect/Type (ffi.class_for java/lang/Object)) + (array.list #.None (java/lang/Class::getGenericInterfaces source_class))} (array.list #.None (java/lang/Class::getGenericInterfaces source_class))))))) (def: (inheritance_candidate_parents class_loader fromT target_class toT fromC) (-> java/lang/ClassLoader .Type (java/lang/Class java/lang/Object) .Type Code (Operation (List [[Text .Type] Bit]))) (case fromT - (^ (#.Primitive _ (list& self_classT super_classT super_interfacesT+))) + (^ {#.Primitive _ (list& self_classT super_classT super_interfacesT+)}) (monad.each phase.monad (function (_ superT) (do [! phase.monad] @@ -959,15 +959,15 @@ (case (|> candidate_parents (list.only product.right) (list\each product.left)) - (#.Item [next_name nextT] _) + {#.Item [next_name nextT] _} (recur [next_name nextT]) #.End (in false)))))))))] (if can_cast? - (in (#/////analysis.Extension extension_name (list (/////analysis.text source_name) + (in {#/////analysis.Extension extension_name (list (/////analysis.text source_name) (/////analysis.text target_name) - fromA))) + fromA)}) (/////analysis.except ..cannot_cast [fromT toT fromC]))) _ @@ -1001,7 +1001,7 @@ (not deprecated?)) fieldT (reflection_type luxT.fresh fieldJT) _ (typeA.infer fieldT)] - (in (<| (#/////analysis.Extension extension_name) + (in (<| {#/////analysis.Extension extension_name} (list (/////analysis.text class) (/////analysis.text field) (/////analysis.text (|> fieldJT ..reflection)))))))])) @@ -1025,7 +1025,7 @@ fieldT (reflection_type luxT.fresh fieldJT) valueA (typeA.with_type fieldT (analyse archive valueC))] - (in (<| (#/////analysis.Extension extension_name) + (in (<| {#/////analysis.Extension extension_name} (list (/////analysis.text class) (/////analysis.text field) valueA)))))])) @@ -1049,7 +1049,7 @@ (not deprecated?)) fieldT (reflection_type mapping fieldJT) _ (typeA.infer fieldT)] - (in (<| (#/////analysis.Extension extension_name) + (in (<| {#/////analysis.Extension extension_name} (list (/////analysis.text class) (/////analysis.text field) (/////analysis.text (..reflection fieldJT)) @@ -1078,7 +1078,7 @@ fieldT (reflection_type mapping fieldJT) valueA (typeA.with_type fieldT (analyse archive valueC))] - (in (<| (#/////analysis.Extension extension_name) + (in (<| {#/////analysis.Extension extension_name} (list (/////analysis.text class) (/////analysis.text field) (/////analysis.text (..reflection fieldJT)) @@ -1122,7 +1122,7 @@ (and prev (jvm\= expectedJC (: (Type Value) (case (jvm_parser.var? actualJC) - (#.Some name) + {#.Some name} (|> aliasing (dictionary.value name) (maybe.else name) @@ -1151,7 +1151,7 @@ (list.every? (function (_ [expectedJC actualJC]) (jvm\= expectedJC (: (Type Value) (case (jvm_parser.var? actualJC) - (#.Some name) + {#.Some name} (|> aliasing (dictionary.value name) (maybe.else name) @@ -1217,7 +1217,7 @@ inputsT _ - (list& (#.Primitive (java/lang/Class::getName owner) owner_tvarsT) + (list& {#.Primitive (java/lang/Class::getName owner) owner_tvarsT} inputsT))) outputT)]] (in [methodT @@ -1245,7 +1245,7 @@ (monad.each ! (|>> reflection!.type phase.lifted)) (phase\each (monad.each ! (reflection_type mapping))) phase\conjoint) - .let [objectT (#.Primitive (java/lang/Class::getName owner) owner_tvarsT) + .let [objectT {#.Primitive (java/lang/Class::getName owner) owner_tvarsT} constructorT (<| (type.univ_q (dictionary.size mapping)) (type.function inputsT) objectT)]] @@ -1255,14 +1255,14 @@ (type: Evaluation (Variant - (#Pass Method_Signature) - (#Hint Method_Signature))) + {#Pass Method_Signature} + {#Hint Method_Signature})) (template [<name> <tag>] [(def: <name> (-> Evaluation (Maybe Method_Signature)) - (|>> (case> (<tag> output) - (#.Some output) + (|>> (case> {<tag> output} + {#.Some output} _ #.None)))] @@ -1310,7 +1310,7 @@ (|>> #Hint)) (method_signature method_style method)))))))] (case (list.all pass! candidates) - (#.Item method #.End) + {#.Item method #.End} (in method) #.End @@ -1340,7 +1340,7 @@ (if passes? (|>> #Pass) (|>> #Hint)) (constructor_signature constructor))))))] (case (list.all pass! candidates) - (#.Item constructor #.End) + {#.Item constructor #.End} (in constructor) #.End @@ -1387,10 +1387,10 @@ (not deprecated?)) [outputT argsA] (inferenceA.general archive analyse methodT (list\each product.right argsTC)) outputJT (check_return outputT)] - (in (#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) + (in {#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) (/////analysis.text (..signature outputJT)) - (decorate_inputs argsT argsA))))))])) + (decorate_inputs argsT argsA))})))])) (def: (invoke::virtual class_loader) (-> java/lang/ClassLoader Handler) @@ -1405,17 +1405,17 @@ (not deprecated?)) [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\each product.right argsTC))) .let [[objectA argsA] (case allA - (#.Item objectA argsA) + {#.Item objectA argsA} [objectA argsA] _ (undefined))] outputJT (check_return outputT)] - (in (#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) + (in {#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) (/////analysis.text (..signature outputJT)) objectA - (decorate_inputs argsT argsA))))))])) + (decorate_inputs argsT argsA))})))])) (def: (invoke::special class_loader) (-> java/lang/ClassLoader Handler) @@ -1430,10 +1430,10 @@ (not deprecated?)) [outputT argsA] (inferenceA.general archive analyse methodT (list& objectC (list\each product.right argsTC))) outputJT (check_return outputT)] - (in (#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) + (in {#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) (/////analysis.text (..signature outputJT)) - (decorate_inputs argsT argsA))))))])) + (decorate_inputs argsT argsA))})))])) (def: (invoke::interface class_loader) (-> java/lang/ClassLoader Handler) @@ -1451,18 +1451,18 @@ (not deprecated?)) [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\each product.right argsTC))) .let [[objectA argsA] (case allA - (#.Item objectA argsA) + {#.Item objectA argsA} [objectA argsA] _ (undefined))] outputJT (check_return outputT)] - (in (#/////analysis.Extension extension_name - (list& (/////analysis.text (..signature (jvm.class class_name (list)))) - (/////analysis.text method) - (/////analysis.text (..signature outputJT)) - objectA - (decorate_inputs argsT argsA))))))])) + (in {#/////analysis.Extension extension_name + (list& (/////analysis.text (..signature (jvm.class class_name (list)))) + (/////analysis.text method) + (/////analysis.text (..signature outputJT)) + objectA + (decorate_inputs argsT argsA))})))])) (def: (invoke::constructor class_loader) (-> java/lang/ClassLoader Handler) @@ -1476,8 +1476,8 @@ _ (phase.assertion ..deprecated_method [class ..constructor_method methodT] (not deprecated?)) [outputT argsA] (inferenceA.general archive analyse methodT (list\each product.right argsTC))] - (in (#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) - (decorate_inputs argsT argsA))))))])) + (in {#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) + (decorate_inputs argsT argsA))})))])) (def: (bundle::member class_loader) (-> java/lang/ClassLoader Bundle) @@ -1693,7 +1693,7 @@ (in [name luxT]))) arguments) [scope bodyA] (|> arguments' - (#.Item [self_name selfT]) + {#.Item [self_name selfT]} list.reversed (list\mix scope.with_local (analyse archive body)) (typeA.with_type .Any) @@ -1707,10 +1707,10 @@ (/////analysis.tuple (list\each ..argument_analysis arguments)) (/////analysis.tuple (list\each class_analysis exceptions)) (/////analysis.tuple (list\each typed_analysis super_arguments)) - (#/////analysis.Function + {#/////analysis.Function (list\each (|>> /////analysis.variable) (scope.environment scope)) - (/////analysis.tuple (list bodyA))) + (/////analysis.tuple (list bodyA))} )))))) (type: .public (Virtual_Method a) @@ -1769,7 +1769,7 @@ (in [name luxT]))) arguments) [scope bodyA] (|> arguments' - (#.Item [self_name selfT]) + {#.Item [self_name selfT]} list.reversed (list\mix scope.with_local (analyse archive body)) (typeA.with_type returnT) @@ -1785,10 +1785,10 @@ (/////analysis.tuple (list\each ..argument_analysis arguments)) (return_analysis return) (/////analysis.tuple (list\each class_analysis exceptions)) - (#/////analysis.Function + {#/////analysis.Function (list\each (|>> /////analysis.variable) (scope.environment scope)) - (/////analysis.tuple (list bodyA))) + (/////analysis.tuple (list bodyA))} )))))) (type: .public (Static_Method a) @@ -1857,10 +1857,10 @@ (return_analysis return) (/////analysis.tuple (list\each class_analysis exceptions)) - (#/////analysis.Function + {#/////analysis.Function (list\each (|>> /////analysis.variable) (scope.environment scope)) - (/////analysis.tuple (list bodyA))) + (/////analysis.tuple (list bodyA))} )))))) (type: .public (Overriden_Method a) @@ -1914,10 +1914,10 @@ (case (list.one (function (_ super) (let [[super_name super_parameters] (jvm_parser.read_class super)] (if (text\= parent_name super_name) - (#.Some super_parameters) + {#.Some super_parameters} #.None))) supers) - (#.Some super_parameters) + {#.Some super_parameters} (let [expected_count (list.size parent_parameters) actual_count (list.size super_parameters)] (if (n.= expected_count actual_count) @@ -1966,25 +1966,25 @@ bodyA 2 - (#/////analysis.Case (/////analysis.unit) - [[#/////analysis.when - (#/////analysis.Bind 2) + {#/////analysis.Case (/////analysis.unit) + [[#/////analysis.when + {#/////analysis.Bind 2} - #/////analysis.then - bodyA] - (list)]) + #/////analysis.then + bodyA] + (list)]} _ - (#/////analysis.Case (/////analysis.unit) - [[#/////analysis.when - (#/////analysis.Complex - (#/////analysis.Tuple (|> arity - list.indices - (list\each (|>> (n.+ 2) #/////analysis.Bind))))) + {#/////analysis.Case (/////analysis.unit) + [[#/////analysis.when + {#/////analysis.Complex + {#/////analysis.Tuple (|> arity + list.indices + (list\each (|>> (n.+ 2) #/////analysis.Bind)))}} - #/////analysis.then - bodyA] - (list)])))) + #/////analysis.then + bodyA] + (list)]}))) (def: .public (analyse_overriden_method analyse archive selfT mapping supers method) (-> Phase Archive .Type Mapping (List (Type Class)) (Overriden_Method Code) (Operation Analysis)) @@ -2012,7 +2012,7 @@ arguments) returnT (boxed_reflection_return mapping return) [scope bodyA] (|> arguments' - (#.Item [self_name selfT]) + {#.Item [self_name selfT]} list.reversed (list\mix scope.with_local (analyse archive body)) (typeA.with_type returnT) @@ -2028,15 +2028,15 @@ (return_analysis return) (/////analysis.tuple (list\each class_analysis exceptions)) - (#/////analysis.Function + {#/////analysis.Function (list\each (|>> /////analysis.variable) (scope.environment scope)) - (..hide_method_body (list.size arguments) bodyA)) + (..hide_method_body (list.size arguments) bodyA)} )))))) (type: .public (Method_Definition a) (Variant - (#Overriden_Method (Overriden_Method a)))) + {#Overriden_Method (Overriden_Method a)})) (def: .public parameter_types (-> (List (Type Var)) (Check (List [(Type Var) .Type]))) @@ -2082,7 +2082,7 @@ (in (|> (list.zipped/2 expected_parameters actual_parameters) (list\mix (function (_ [expected actual] mapping) (case (jvm_parser.var? actual) - (#.Some actual) + {#.Some actual} (dictionary.has actual expected mapping) #.None @@ -2154,7 +2154,7 @@ selfT (///.lifted (do meta.monad [where meta.current_module_name id meta.seed] - (in (inheritance_relationship_type (#.Primitive (..anonymous_class_name where id) (list)) + (in (inheritance_relationship_type {#.Primitive (..anonymous_class_name where id) (list)} super_classT super_interfaceT+)))) _ (typeA.infer selfT) @@ -2165,14 +2165,14 @@ (analyse archive term))] (in [type termA]))) constructor_args) - .let [supers (#.Item super_class super_interfaces)] + .let [supers {#.Item super_class super_interfaces}] _ (..require_complete_method_concretion class_loader supers methods) methodsA (monad.each ! (analyse_overriden_method analyse archive selfT mapping supers) methods)] - (in (#/////analysis.Extension extension_name - (list (class_analysis super_class) - (/////analysis.tuple (list\each class_analysis super_interfaces)) - (/////analysis.tuple (list\each typed_analysis constructor_argsA+)) - (/////analysis.tuple methodsA))))))])) + (in {#/////analysis.Extension extension_name + (list (class_analysis super_class) + (/////analysis.tuple (list\each class_analysis super_interfaces)) + (/////analysis.tuple (list\each typed_analysis constructor_argsA+)) + (/////analysis.tuple methodsA))})))])) (def: (bundle::class class_loader) (-> java/lang/ClassLoader Bundle) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux index f7ed4ed54..c9c1dfb0b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux @@ -50,7 +50,7 @@ (phase archive lengthC)) [var_id varT] (analysis/type.with_env check.var) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list lengthA)))))])) + (in {#analysis.Extension extension (list lengthA)})))])) (def: array::length Handler @@ -62,7 +62,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer Nat)] - (in (#analysis.Extension extension (list arrayA)))))])) + (in {#analysis.Extension extension (list arrayA)})))])) (def: array::read Handler @@ -76,7 +76,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer varT)] - (in (#analysis.Extension extension (list indexA arrayA)))))])) + (in {#analysis.Extension extension (list indexA arrayA)})))])) (def: array::write Handler @@ -92,7 +92,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list indexA valueA arrayA)))))])) + (in {#analysis.Extension extension (list indexA valueA arrayA)})))])) (def: array::delete Handler @@ -106,7 +106,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list indexA arrayA)))))])) + (in {#analysis.Extension extension (list indexA arrayA)})))])) (def: bundle::array Bundle @@ -128,8 +128,8 @@ [objectA (analysis/type.with_type ..Object (phase archive objectC)) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list (analysis.text fieldC) - objectA)))))])) + (in {#analysis.Extension extension (list (analysis.text fieldC) + objectA)})))])) (def: object::do Handler @@ -141,9 +141,9 @@ (phase archive objectC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list& (analysis.text methodC) + (in {#analysis.Extension extension (list& (analysis.text methodC) objectA - inputsA)))))])) + inputsA)})))])) (def: bundle::object Bundle @@ -165,7 +165,7 @@ [inputA (analysis/type.with_type (type <fromT>) (phase archive inputC)) _ (analysis/type.infer (type <toT>))] - (in (#analysis.Extension extension (list inputA)))))]))] + (in {#analysis.Extension extension (list inputA)})))]))] [utf8::encode Text (array.Array (I64 Any))] [utf8::decode (array.Array (I64 Any)) Text] @@ -186,7 +186,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Any)] - (in (#analysis.Extension extension (list (analysis.text name))))))])) + (in {#analysis.Extension extension (list (analysis.text name))})))])) (def: lua::apply Handler @@ -198,7 +198,7 @@ (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] - (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) + (in {#analysis.Extension extension (list& abstractionA inputsA)})))])) (def: lua::power Handler @@ -211,7 +211,7 @@ baseA (analysis/type.with_type Frac (phase archive baseC)) _ (analysis/type.infer Frac)] - (in (#analysis.Extension extension (list powerA baseA)))))])) + (in {#analysis.Extension extension (list powerA baseA)})))])) (def: lua::import Handler @@ -220,7 +220,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer ..Object)] - (in (#analysis.Extension extension (list (analysis.text name))))))])) + (in {#analysis.Extension extension (list (analysis.text name))})))])) (def: lua::function Handler @@ -232,8 +232,8 @@ abstractionA (analysis/type.with_type (-> inputT Any) (phase archive abstractionC)) _ (analysis/type.infer ..Function)] - (in (#analysis.Extension extension (list (analysis.nat arity) - abstractionA)))))])) + (in {#analysis.Extension extension (list (analysis.nat arity) + abstractionA)})))])) (def: .public bundle Bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux index fb283bf9e..0609bee0a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux @@ -41,10 +41,10 @@ Handler)) (function (_ extension_name analyse archive args) (case (<code>.result syntax args) - (#try.Success inputs) + {#try.Success inputs} (handler extension_name analyse archive inputs) - (#try.Failure _) + {#try.Failure _} (////analysis.except ///.invalid_syntax [extension_name %.code args])))) (def: (simple inputsT+ outputT) @@ -60,7 +60,7 @@ (typeA.with_type argT (analyse archive argC))) (list.zipped/2 inputsT+ args))] - (in (#////analysis.Extension extension_name argsA))) + (in {#////analysis.Extension extension_name argsA})) (////analysis.except ///.incorrect_arity [extension_name num_expected num_actual])))))) (def: .public (nullary valueT) @@ -119,7 +119,7 @@ (list (////analysis.tuple (list\each (|>> ////analysis.nat) cases)) branch)))) (list& input else) - (#////analysis.Extension extension_name)))))]))) + {#////analysis.Extension extension_name}))))]))) ... "lux is" represents reference/pointer equality. (def: lux::is @@ -142,7 +142,7 @@ _ (typeA.infer (type (Either Text varT))) opA (typeA.with_type (type (-> .Any varT)) (analyse archive opC))] - (in (#////analysis.Extension extension_name (list opA)))) + (in {#////analysis.Extension extension_name (list opA)})) _ (////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -151,7 +151,7 @@ Handler (function (_ extension_name analyse archive argsC+) (case argsC+ - (^ (list [_ (#.Text module_name)] exprC)) + (^ (list [_ {#.Text module_name}] exprC)) (////analysis.with_current_module module_name (analyse archive exprC)) @@ -214,15 +214,15 @@ (do ! [input_type (///.lifted (meta.definition (name_of .Macro')))] (case input_type - (^or (#.Definition [exported? def_type def_value]) - (#.Type [exported? def_value labels])) + (^or {#.Definition [exported? def_type def_value]} + {#.Type [exported? def_value labels]}) (in (:as Type def_value)) - (^or (#.Label _) - (#.Slot _)) + (^or {#.Label _} + {#.Slot _}) (////.failure (exception.error ..not_a_type [(name_of .Macro')])) - (#.Alias real_name) + {#.Alias real_name} (recur real_name))))] (typeA.with_type input_type (phase archive valueC))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux index a52f8bb53..16717539b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux @@ -38,7 +38,7 @@ (phase archive lengthC)) [var_id varT] (analysis/type.with_env check.var) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list lengthA)))))])) + (in {#analysis.Extension extension (list lengthA)})))])) (def: array::length Handler @@ -50,7 +50,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer Nat)] - (in (#analysis.Extension extension (list arrayA)))))])) + (in {#analysis.Extension extension (list arrayA)})))])) (def: array::read Handler @@ -64,7 +64,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer varT)] - (in (#analysis.Extension extension (list indexA arrayA)))))])) + (in {#analysis.Extension extension (list indexA arrayA)})))])) (def: array::write Handler @@ -80,7 +80,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list indexA valueA arrayA)))))])) + (in {#analysis.Extension extension (list indexA valueA arrayA)})))])) (def: array::delete Handler @@ -94,7 +94,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list indexA arrayA)))))])) + (in {#analysis.Extension extension (list indexA arrayA)})))])) (def: bundle::array Bundle @@ -127,7 +127,7 @@ (do [! phase.monad] [inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list& (analysis.text constructor) inputsA)))))])) + (in {#analysis.Extension extension (list& (analysis.text constructor) inputsA)})))])) (def: object::get Handler @@ -138,8 +138,8 @@ [objectA (analysis/type.with_type ..Object (phase archive objectC)) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list (analysis.text fieldC) - objectA)))))])) + (in {#analysis.Extension extension (list (analysis.text fieldC) + objectA)})))])) (def: object::do Handler @@ -151,9 +151,9 @@ (phase archive objectC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list& (analysis.text methodC) + (in {#analysis.Extension extension (list& (analysis.text methodC) objectA - inputsA)))))])) + inputsA)})))])) (def: bundle::object Bundle @@ -173,7 +173,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Any)] - (in (#analysis.Extension extension (list (analysis.text name))))))])) + (in {#analysis.Extension extension (list (analysis.text name))})))])) (def: php::apply Handler @@ -185,7 +185,7 @@ (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] - (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) + (in {#analysis.Extension extension (list& abstractionA inputsA)})))])) (def: php::pack Handler @@ -198,7 +198,7 @@ dataA (analysis/type.with_type (type (Array (I64 Any))) (phase archive dataC)) _ (analysis/type.infer Text)] - (in (#analysis.Extension extension (list formatA dataA)))))])) + (in {#analysis.Extension extension (list formatA dataA)})))])) (def: .public bundle Bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux index 700f80163..ec21b45bc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux @@ -38,7 +38,7 @@ (phase archive lengthC)) [var_id varT] (analysis/type.with_env check.var) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list lengthA)))))])) + (in {#analysis.Extension extension (list lengthA)})))])) (def: array::length Handler @@ -50,7 +50,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer Nat)] - (in (#analysis.Extension extension (list arrayA)))))])) + (in {#analysis.Extension extension (list arrayA)})))])) (def: array::read Handler @@ -64,7 +64,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer varT)] - (in (#analysis.Extension extension (list indexA arrayA)))))])) + (in {#analysis.Extension extension (list indexA arrayA)})))])) (def: array::write Handler @@ -80,7 +80,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list indexA valueA arrayA)))))])) + (in {#analysis.Extension extension (list indexA valueA arrayA)})))])) (def: array::delete Handler @@ -94,7 +94,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list indexA arrayA)))))])) + (in {#analysis.Extension extension (list indexA arrayA)})))])) (def: bundle::array Bundle @@ -136,8 +136,8 @@ [objectA (analysis/type.with_type ..Object (phase archive objectC)) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list (analysis.text fieldC) - objectA)))))])) + (in {#analysis.Extension extension (list (analysis.text fieldC) + objectA)})))])) (def: object::do Handler @@ -149,9 +149,9 @@ (phase archive objectC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list& (analysis.text methodC) + (in {#analysis.Extension extension (list& (analysis.text methodC) objectA - inputsA)))))])) + inputsA)})))])) (def: bundle::object Bundle @@ -170,7 +170,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Any)] - (in (#analysis.Extension extension (list (analysis.text name))))))])) + (in {#analysis.Extension extension (list (analysis.text name))})))])) (def: python::import Handler @@ -179,7 +179,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer ..Object)] - (in (#analysis.Extension extension (list (analysis.text name))))))])) + (in {#analysis.Extension extension (list (analysis.text name))})))])) (def: python::apply Handler @@ -191,7 +191,7 @@ (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] - (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) + (in {#analysis.Extension extension (list& abstractionA inputsA)})))])) (def: python::function Handler @@ -203,8 +203,8 @@ abstractionA (analysis/type.with_type (-> inputT Any) (phase archive abstractionC)) _ (analysis/type.infer ..Function)] - (in (#analysis.Extension extension (list (analysis.nat arity) - abstractionA)))))])) + (in {#analysis.Extension extension (list (analysis.nat arity) + abstractionA)})))])) (def: python::exec Handler @@ -217,7 +217,7 @@ globalsA (analysis/type.with_type ..Dict (phase archive globalsC)) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list codeA globalsA)))))])) + (in {#analysis.Extension extension (list codeA globalsA)})))])) (def: .public bundle Bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux index 6bf24f1fa..525458cdd 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux @@ -38,7 +38,7 @@ (phase archive lengthC)) [var_id varT] (analysis/type.with_env check.var) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list lengthA)))))])) + (in {#analysis.Extension extension (list lengthA)})))])) (def: array::length Handler @@ -50,7 +50,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer Nat)] - (in (#analysis.Extension extension (list arrayA)))))])) + (in {#analysis.Extension extension (list arrayA)})))])) (def: array::read Handler @@ -64,7 +64,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer varT)] - (in (#analysis.Extension extension (list indexA arrayA)))))])) + (in {#analysis.Extension extension (list indexA arrayA)})))])) (def: array::write Handler @@ -80,7 +80,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list indexA valueA arrayA)))))])) + (in {#analysis.Extension extension (list indexA valueA arrayA)})))])) (def: array::delete Handler @@ -94,7 +94,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list indexA arrayA)))))])) + (in {#analysis.Extension extension (list indexA arrayA)})))])) (def: bundle::array Bundle @@ -128,8 +128,8 @@ [objectA (analysis/type.with_type ..Object (phase archive objectC)) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list (analysis.text fieldC) - objectA)))))])) + (in {#analysis.Extension extension (list (analysis.text fieldC) + objectA)})))])) (def: object::do Handler @@ -141,9 +141,9 @@ (phase archive objectC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in (#analysis.Extension extension (list& (analysis.text methodC) + (in {#analysis.Extension extension (list& (analysis.text methodC) objectA - inputsA)))))])) + inputsA)})))])) (def: bundle::object Bundle @@ -162,7 +162,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Any)] - (in (#analysis.Extension extension (list (analysis.text name))))))])) + (in {#analysis.Extension extension (list (analysis.text name))})))])) (def: ruby::apply Handler @@ -174,7 +174,7 @@ (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] - (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) + (in {#analysis.Extension extension (list& abstractionA inputsA)})))])) (def: ruby::import Handler @@ -183,7 +183,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Bit)] - (in (#analysis.Extension extension (list (analysis.text name))))))])) + (in {#analysis.Extension extension (list (analysis.text name))})))])) (def: .public bundle Bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux index 2075522d7..a0df81d93 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux @@ -38,7 +38,7 @@ (phase archive lengthC)) [var_id varT] (analysis/type.with_env check.var) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list lengthA)))))])) + (in {#analysis.Extension extension (list lengthA)})))])) (def: array::length Handler @@ -50,7 +50,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer Nat)] - (in (#analysis.Extension extension (list arrayA)))))])) + (in {#analysis.Extension extension (list arrayA)})))])) (def: array::read Handler @@ -64,7 +64,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer varT)] - (in (#analysis.Extension extension (list indexA arrayA)))))])) + (in {#analysis.Extension extension (list indexA arrayA)})))])) (def: array::write Handler @@ -80,7 +80,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list indexA valueA arrayA)))))])) + (in {#analysis.Extension extension (list indexA valueA arrayA)})))])) (def: array::delete Handler @@ -94,7 +94,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in (#analysis.Extension extension (list indexA arrayA)))))])) + (in {#analysis.Extension extension (list indexA arrayA)})))])) (def: bundle::array Bundle @@ -131,7 +131,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Any)] - (in (#analysis.Extension extension (list (analysis.text name))))))])) + (in {#analysis.Extension extension (list (analysis.text name))})))])) (def: scheme::apply Handler @@ -143,7 +143,7 @@ (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] - (in (#analysis.Extension extension (list& abstractionA inputsA)))))])) + (in {#analysis.Extension extension (list& abstractionA inputsA)})))])) (def: .public bundle Bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux index 6dc2b393d..76c66e37d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux @@ -144,8 +144,8 @@ ))) (type: Field - (#Constant Constant) - (#Variable Variable)) + {#Constant Constant} + {#Variable Variable}) (def: field (Parser Field) @@ -155,10 +155,10 @@ )) (type: Method_Definition - (#Constructor (jvm.Constructor Code)) - (#Virtual_Method (jvm.Virtual_Method Code)) - (#Static_Method (jvm.Static_Method Code)) - (#Overriden_Method (jvm.Overriden_Method Code))) + {#Constructor (jvm.Constructor Code)} + {#Virtual_Method (jvm.Virtual_Method Code)} + {#Static_Method (jvm.Static_Method Code)} + {#Overriden_Method (jvm.Overriden_Method Code)}) (def: method (Parser Method_Definition) @@ -186,10 +186,10 @@ (-> Field (Resource field.Field)) (case field ... TODO: Handle annotations. - (#Constant [name annotations type value]) + {#Constant [name annotations type value]} (case value (^template [<tag> <type> <constant>] - [[_ (<tag> value)] + [[_ {<tag> value}] (do pool.monad [constant (`` (|> value (~~ (template.spliced <constant>)))) attribute (attribute.constant constant)] @@ -210,7 +210,7 @@ (undefined)) ... TODO: Handle annotations. - (#Variable [name visibility state annotations type]) + {#Variable [name visibility state annotations type]} (field.field (modifier\composite visibility state) name type (row.row)))) @@ -225,16 +225,16 @@ [methodA (: (Operation analysis.Analysis) (directive.lifted_analysis (case methodC - (#Constructor method) + {#Constructor method} (jvm.analyse_constructor_method analyse selfT mapping method) - (#Virtual_Method method) + {#Virtual_Method method} (jvm.analyse_virtual_method analyse selfT mapping method) - (#Static_Method method) + {#Static_Method method} (jvm.analyse_static_method analyse mapping method) - (#Overriden_Method method) + {#Overriden_Method method} (jvm.analyse_overriden_method analyse selfT mapping method))))] (directive.lifted_synthesis (synthesize methodA))))) @@ -275,7 +275,7 @@ (monad.each check.monad (|>> ..signature (luxT.check (luxT.class mapping))) super_interfaces))) - .let [selfT (jvm.inheritance_relationship_type (#.Primitive name (list\each product.right parameters)) + .let [selfT (jvm.inheritance_relationship_type {#.Primitive name (list\each product.right parameters)} super_classT super_interfaceT+)] state (extension.lifted phase.get_state) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux index 0ebdde096..4ea0c4e7a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux @@ -54,10 +54,10 @@ (Handler anchor expression directive))) (function (_ extension_name phase archive inputs) (case (<code>.result syntax inputs) - (#try.Success inputs) + {#try.Success inputs} (handler extension_name phase archive inputs) - (#try.Failure error) + {#try.Failure error} (phase.except ///.invalid_syntax [extension_name %.code inputs])))) (def: (context [module_id artifact_id]) @@ -138,7 +138,7 @@ (check.clean code//type))] (in [code//type codeA])) - (#.Some expected) + {#.Some expected} (do ! [codeA (typeA.with_type expected (analyse archive codeC))] @@ -219,7 +219,7 @@ (-> Expander /////analysis.Bundle Handler) (function (_ extension_name phase archive inputsC+) (case inputsC+ - (^ (list [_ (#.Identifier ["" short_name])] valueC exported?C)) + (^ (list [_ {#.Identifier ["" short_name]}] valueC exported?C)) (do phase.monad [current_module (/////directive.lifted_analysis (///.lifted meta.current_module_name)) @@ -227,7 +227,7 @@ [type valueT value] (..definition archive full_name #.None valueC) [_ _ exported?] (evaluate! archive Bit exported?C) _ (/////directive.lifted_analysis - (module.define short_name (#.Definition [(:as Bit exported?) type value]))) + (module.define short_name {#.Definition [(:as Bit exported?) type value]})) _ (..refresh expander host_analysis) _ (..announce_definition! short_name type)] (in /////directive.no_requirements)) @@ -258,23 +258,23 @@ .let [full_name [current_module short_name]] [_ _ exported?] (evaluate! archive Bit exported?C) .let [exported? (:as Bit exported?)] - [type valueT value] (..definition archive full_name (#.Some .Type) valueC) + [type valueT value] (..definition archive full_name {#.Some .Type} valueC) labels (/////directive.lifted_analysis (do phase.monad [.let [[record? labels] (case labels - (#.Left tags) + {#.Left tags} [false tags] - (#.Right slots) + {#.Right slots} [true slots])] _ (case labels #.End - (module.define short_name (#.Definition [exported? type value])) + (module.define short_name {#.Definition [exported? type value]}) - (#.Item labels) - (module.define short_name (#.Type [exported? (:as .Type value) (if record? - (#.Right labels) - (#.Left labels))]))) + {#.Item labels} + (module.define short_name {#.Type [exported? (:as .Type value) (if record? + {#.Right labels} + {#.Left labels})]})) _ (module.declare_tags record? labels exported? (:as .Type value))] (in labels))) _ (..refresh expander host_analysis) @@ -325,15 +325,15 @@ [current_module (///.lifted meta.current_module_name) constant (///.lifted (meta.definition original))] (case constant - (#.Alias de_aliased) + {#.Alias de_aliased} (phase.except ..cannot_alias_an_alias [[current_module alias] original de_aliased]) - (^or (#.Definition _) - (#.Type _)) - (module.define alias (#.Alias original)) + (^or {#.Definition _} + {#.Type _}) + (module.define alias {#.Alias original}) - (^or (#.Label _) - (#.Slot _)) + (^or {#.Label _} + {#.Slot _}) (phase.except ..cannot_alias_a_label [[current_module alias] original])))) (def: def::alias diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux index facb40e7e..8c6df79fd 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux @@ -45,10 +45,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - (#try.Success input') + {#try.Success input'} (handler extension_name phase archive input') - (#try.Failure error) + {#try.Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) (template: (!unary function) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux index 1072bffe4..54b345e36 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux @@ -45,10 +45,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - (#try.Success input') + {#try.Success input'} (handler extension_name phase archive input') - (#try.Failure error) + {#try.Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) ... [Procedures] @@ -101,7 +101,7 @@ Phase! (case synthesis ... TODO: Get rid of this ASAP - (#synthesis.Extension "lux syntax char case!" parameters) + {#synthesis.Extension "lux syntax char case!" parameters} (do /////.monad [body (expression archive synthesis)] (in (:as Statement body))) @@ -115,9 +115,13 @@ [synthesis.text] [synthesis.variant] [synthesis.tuple] - [#synthesis.Reference] [synthesis.branch/get] - [synthesis.function/apply] + [synthesis.function/apply]) + + (^template [<tag>] + [(^ {<tag> value}) + (/////\each _.return (expression archive synthesis))]) + ([#synthesis.Reference] [#synthesis.Extension]) (^ (synthesis.branch/case case)) @@ -162,13 +166,13 @@ ... (in (_.apply/* (_.closure (list) ... (_.switch (_.the //runtime.i64_low_field inputG) ... conditionals! - ... (#.Some (_.return else!)))) + ... {#.Some (_.return else!)})) ... (list))) (in (<| (:as Expression) (: Statement) (_.switch (_.the //runtime.i64_low_field inputG) conditionals! - (#.Some else!))))))])) + {#.Some else!})))))])) ... [Bundles] (def: lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux index 2ff3fd02a..f3efd5f47 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux @@ -49,10 +49,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - (#try.Success input') + {#try.Success input'} (handler extension_name phase archive input') - (#try.Failure error) + {#try.Failure error} (/////.except /////extension.invalid_syntax [extension_name //////synthesis.%synthesis input])))) (def: $Boolean (type.class "java.lang.Boolean" (list))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux index e0626e0b6..b070a0a6b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux @@ -339,9 +339,9 @@ (do <>.monad [arrayJT (<t>.then parser.array <s>.text)] (case (parser.array? arrayJT) - (#.Some elementJT) + {#.Some elementJT} (case (parser.object? elementJT) - (#.Some elementJT) + {#.Some elementJT} (in elementJT) #.None @@ -644,7 +644,7 @@ (do //////.monad [.let [$class (type.class class (list))]] (case (dictionary.value unboxed ..primitives) - (#.Some primitive) + {#.Some primitive} (in (_.getstatic $class field primitive)) #.None @@ -661,7 +661,7 @@ [valueG (generate archive valueS) .let [$class (type.class class (list))]] (case (dictionary.value unboxed ..primitives) - (#.Some primitive) + {#.Some primitive} (in ($_ _.composite valueG (_.putstatic $class field primitive) @@ -683,7 +683,7 @@ [objectG (generate archive objectS) .let [$class (type.class class (list)) getG (case (dictionary.value unboxed ..primitives) - (#.Some primitive) + {#.Some primitive} (_.getfield $class field primitive) #.None @@ -703,7 +703,7 @@ objectG (generate archive objectS) .let [$class (type.class class (list)) putG (case (dictionary.value unboxed ..primitives) - (#.Some primitive) + {#.Some primitive} (_.putfield $class field primitive) #.None @@ -729,10 +729,10 @@ (do //////.monad [valueG (generate archive valueS)] (case (type.primitive? valueT) - (#.Right valueT) + {#.Right valueT} (in [valueT valueG]) - (#.Left valueT) + {#.Left valueT} (in [valueT ($_ _.composite valueG (_.checkcast valueT))])))) @@ -740,10 +740,10 @@ (def: (prepare_output outputT) (-> (Type Return) (Bytecode Any)) (case (type.void? outputT) - (#.Right outputT) + {#.Right outputT} ..unitG - (#.Left outputT) + {#.Left outputT} (\ _.monad in []))) (def: invoke::static @@ -855,13 +855,13 @@ (//////synthesis.path/then (normalize bodyS)) (^template [<tag>] - [(^ (<tag> leftP rightP)) - (<tag> (recur leftP) (recur rightP))]) + [(^ {<tag> leftP rightP}) + {<tag> (recur leftP) (recur rightP)}]) ([#//////synthesis.Alt] [#//////synthesis.Seq]) (^template [<tag>] - [(^ (<tag> value)) + [(^ {<tag> value}) path]) ([#//////synthesis.Pop] [#//////synthesis.Bind] @@ -875,7 +875,7 @@ (function (recur body) (case body (^template [<tag>] - [(^ (<tag> value)) + [(^ {<tag> value}) body]) ([#//////synthesis.Primitive] [//////synthesis.constant]) @@ -928,8 +928,8 @@ (^ (//////synthesis.function/apply [functionS inputsS+])) (//////synthesis.function/apply [(recur functionS) (list\each recur inputsS+)]) - (#//////synthesis.Extension [name inputsS+]) - (#//////synthesis.Extension [name (list\each recur inputsS+)])))) + {#//////synthesis.Extension [name inputsS+]} + {#//////synthesis.Extension [name (list\each recur inputsS+)]}))) (def: $Object (type.class "java.lang.Object" (list))) @@ -952,12 +952,12 @@ (_.putfield class (///reference.foreign_name register) $Object)))))] (method.method method.public "<init>" (anonymous_init_method env) (list) - (#.Some ($_ _.composite + {#.Some ($_ _.composite (_.aload 0) (monad.each _.monad product.right inputsTG) (_.invokespecial super_class "<init>" (type.method [(list\each product.left inputsTG) type.void (list)])) store_capturedG - _.return))))) + _.return)}))) (def: (anonymous_instance generate archive class env) (-> Phase Archive (Type category.Class) (Environment Synthesis) (Operation (Bytecode Any))) @@ -972,17 +972,17 @@ (def: (returnG returnT) (-> (Type Return) (Bytecode Any)) (case (type.void? returnT) - (#.Right returnT) + {#.Right returnT} _.return - (#.Left returnT) + {#.Left returnT} (case (type.primitive? returnT) - (#.Left returnT) + {#.Left returnT} ($_ _.composite (_.checkcast returnT) _.areturn) - (#.Right returnT) + {#.Right returnT} (cond (or (\ type.equivalence = type.boolean returnT) (\ type.equivalence = type.byte returnT) (\ type.equivalence = type.short returnT) @@ -1027,7 +1027,7 @@ ... Give them names as "foreign" variables. list.enumeration (list\each (function (_ [id capture]) - [capture (#//////variable.Foreign id)])) + [capture {#//////variable.Foreign id}])) (dictionary.from_list //////variable.hash)) normalized_methods (list\each (function (_ [environment [ownerT name @@ -1037,7 +1037,7 @@ (let [local_mapping (|> environment list.enumeration (list\each (function (_ [foreign_id capture]) - [(#//////variable.Foreign foreign_id) + [{#//////variable.Foreign foreign_id} (|> global_mapping (dictionary.value capture) maybe.trusted)])) @@ -1066,9 +1066,9 @@ returnT exceptionsT]) (list) - (#.Some ($_ _.composite + {#.Some ($_ _.composite bodyG - (returnG returnT))))))) + (returnG returnT))})))) normalized_methods) bytecode (<| (\ ! each (format.result class.writer)) //////.lifted diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux index 1be1bcfa5..3523c19fa 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux @@ -48,10 +48,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - (#try.Success input') + {#try.Success input'} (handler extension_name phase archive input') - (#try.Failure error) + {#try.Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) (template: (!unary function) @@ -61,7 +61,7 @@ Phase! (case synthesis ... TODO: Get rid of this ASAP - (#synthesis.Extension "lux syntax char case!" parameters) + {#synthesis.Extension "lux syntax char case!" parameters} (do /////.monad [body (expression archive synthesis)] (in (:as Statement body))) @@ -75,9 +75,13 @@ [synthesis.text] [synthesis.variant] [synthesis.tuple] - [#synthesis.Reference] [synthesis.branch/get] - [synthesis.function/apply] + [synthesis.function/apply]) + + (^template [<tag>] + [(^ {<tag> value}) + (/////\each _.return (expression archive synthesis))]) + ([#synthesis.Reference] [#synthesis.Extension]) (^ (synthesis.branch/case case)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux index d5f740ed4..9a06cd980 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux @@ -45,10 +45,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - (#try.Success input') + {#try.Success input'} (handler extension_name phase archive input') - (#try.Failure error) + {#try.Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) (template: (!unary function) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux index 03cb557dc..cbb7c557d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux @@ -47,7 +47,7 @@ Phase! (case synthesis ... TODO: Get rid of this ASAP - (#synthesis.Extension "lux syntax char case!" parameters) + {#synthesis.Extension "lux syntax char case!" parameters} (do /////.monad [body (expression archive synthesis)] (in (:as (Statement Any) body))) @@ -61,9 +61,13 @@ [synthesis.text] [synthesis.variant] [synthesis.tuple] - [#synthesis.Reference] [synthesis.branch/get] - [synthesis.function/apply] + [synthesis.function/apply]) + + (^template [<tag>] + [(^ {<tag> value}) + (/////\each _.return (expression archive synthesis))]) + ([#synthesis.Reference] [#synthesis.Extension]) (^ (synthesis.branch/case case)) @@ -88,10 +92,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<synthesis>.result parser input) - (#try.Success input') + {#try.Success input'} (handler extension_name phase archive input') - (#try.Failure error) + {#try.Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) ... TODO: Get rid of this ASAP @@ -124,10 +128,10 @@ ... .let [dependencies (//case.dependencies (list\mix (function (_ right left) ... (synthesis.path/seq left right)) ... (synthesis.path/then input) - ... (#.Item (synthesis.path/then else) - ... (list\each (|>> product.right - ... synthesis.path/then) - ... conditionals)))) + ... {#.Item (synthesis.path/then else) + ... (list\each (|>> product.right + ... synthesis.path/then) + ... conditionals)})) ... @closure (_.var (reference.artifact artifact_id)) ... closure (_.def @closure dependencies ... ($_ _.then diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux index 68725c83a..2e533b5bd 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux @@ -45,10 +45,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - (#try.Success input') + {#try.Success input'} (handler extension_name phase archive input') - (#try.Failure error) + {#try.Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) ... (template: (!unary function) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux index a253cb8de..6b6538363 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux @@ -48,17 +48,17 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - (#try.Success input') + {#try.Success input'} (handler extension_name phase archive input') - (#try.Failure error) + {#try.Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) (def: .public (statement expression archive synthesis) Phase! (case synthesis ... TODO: Get rid of this ASAP - (#synthesis.Extension "lux syntax char case!" parameters) + {#synthesis.Extension "lux syntax char case!" parameters} (do /////.monad [body (expression archive synthesis)] (in (:as Statement @@ -73,9 +73,13 @@ [synthesis.text] [synthesis.variant] [synthesis.tuple] - [#synthesis.Reference] [synthesis.branch/get] - [synthesis.function/apply] + [synthesis.function/apply]) + + (^template [<tag>] + [(^ {<tag> value}) + (/////\each _.return (expression archive synthesis))]) + ([#synthesis.Reference] [#synthesis.Extension]) (^ (synthesis.branch/case case)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux index bc2ad5cba..7161326e1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux @@ -45,10 +45,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - (#try.Success input') + {#try.Success input'} (handler extension_name phase archive input') - (#try.Failure error) + {#try.Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) (template: (!unary function) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux index 1b1f29f46..26a967a45 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux @@ -34,7 +34,7 @@ [////synthesis.f64 /primitive.f64] [////synthesis.text /primitive.text]) - (#////synthesis.Reference value) + {#////synthesis.Reference value} (//reference.reference /reference.system archive value) (^template [<tag> <generator>] @@ -52,6 +52,6 @@ [////synthesis.loop/recur /loop.recur] [////synthesis.function/abstraction /function.function]) - (#////synthesis.Extension extension) + {#////synthesis.Extension extension} (///extension.apply archive generate extension) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux index 90f67a68a..5442b7268 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux @@ -117,7 +117,7 @@ (_.go @fail) (..push! @temp))) (.case next! - (#.Some next!) + {#.Some next!} (list next!) #.None @@ -150,14 +150,14 @@ #/////synthesis.Pop (///////phase\in ..pop!) - (#/////synthesis.Bind register) + {#/////synthesis.Bind register} (///////phase\in (_.setq (..register register) ..peek)) - (#/////synthesis.Bit_Fork when thenP elseP) + {#/////synthesis.Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur [$output @done @fail thenP]) else! (.case elseP - (#.Some elseP) + {#.Some elseP} (recur [$output @done @fail elseP]) #.None @@ -171,7 +171,7 @@ then!)))) (^template [<tag> <format> <=>] - [(<tag> item) + [{<tag> item} (do [! ///////phase.monad] [clauses (monad.each ! (function (_ [match then]) (do ! @@ -179,7 +179,7 @@ (in [(<=> [(|> match <format>) ..peek]) then!]))) - (#.Item item))] + {#.Item item})] (in (list\mix (function (_ [when then] else) (_.if when then else)) (_.go @fail) @@ -195,7 +195,7 @@ (^ (<simple> idx nextP)) (|> nextP [$output @done @fail] recur - (\ ///////phase.monad each (|>> #.Some (<choice> @fail true idx))))]) + (\ ///////phase.monad each (|>> {#.Some} (<choice> @fail true idx))))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux index 0f7c76ed8..1c7fd4877 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux @@ -109,7 +109,7 @@ (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration - (#.Left name) + {#.Left name} (let [g!name (code.local_identifier name) code_nameC (code.local_identifier (format "@" name))] (in (list (` (def: .public (~ g!name) @@ -120,7 +120,7 @@ (_.Expression Any) (_.defparameter (~ runtime_name) (~ code))))))) - (#.Right [name inputs]) + {#.Right [name inputs]} (let [g!name (code.local_identifier name) code_nameC (code.local_identifier (format "@" name)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux index eb78e6402..2a5fa7c1c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux @@ -20,7 +20,7 @@ #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Item singletonS #.End) + {#.Item singletonS #.End} (expression archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux index e6aa9cdce..65b06ce16 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux @@ -49,7 +49,7 @@ (^ (synthesis.tuple members)) (/structure.tuple expression archive members) - (#synthesis.Reference value) + {#synthesis.Reference value} (//reference.reference /reference.system archive value) (^ (synthesis.branch/case case)) @@ -76,7 +76,7 @@ (^ (synthesis.function/apply application)) (/function.apply expression archive application) - (#synthesis.Extension extension) + {#synthesis.Extension extension} (///extension.apply archive expression extension))) (def: .public generate diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux index 5f634c533..8f98d44ab 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux @@ -171,7 +171,7 @@ [/////synthesis.simple_right_side ..right_choice]) (^ (/////synthesis.member/left 0)) - (///////phase\in (#.Some (push_cursor! (_.at (_.i32 +0) ..peek_cursor)))) + (///////phase\in {#.Some (push_cursor! (_.at (_.i32 +0) ..peek_cursor))}) ... Extra optimization (^ (/////synthesis.path/seq @@ -179,9 +179,9 @@ (/////synthesis.!bind_top register thenP))) (do ///////phase.monad [then! (recur thenP)] - (in (#.Some ($_ _.then + (in {#.Some ($_ _.then (_.define (..register register) (_.at (_.i32 +0) ..peek_cursor)) - then!)))) + then!)})) ... Extra optimization (^template [<pm> <getter>] @@ -190,26 +190,26 @@ (/////synthesis.!bind_top register thenP))) (do ///////phase.monad [then! (recur thenP)] - (in (#.Some ($_ _.then + (in {#.Some ($_ _.then (_.define (..register register) (<getter> (_.i32 (.int lefts)) ..peek_cursor)) - then!))))]) + then!)}))]) ([/////synthesis.member/left //runtime.tuple//left] [/////synthesis.member/right //runtime.tuple//right]) (^ (/////synthesis.!bind_top register thenP)) (do ///////phase.monad [then! (recur thenP)] - (in (#.Some ($_ _.then + (in {#.Some ($_ _.then (_.define (..register register) ..peek_and_pop_cursor) - then!)))) + then!)})) (^ (/////synthesis.!multi_pop nextP)) (.let [[extra_pops nextP'] (////synthesis/case.count_pops nextP)] (do ///////phase.monad [next! (recur nextP')] - (in (#.Some ($_ _.then + (in {#.Some ($_ _.then (multi_pop_cursor! (n.+ 2 extra_pops)) - next!))))) + next!)}))) _ (///////phase\in #.None))) @@ -221,25 +221,25 @@ (do ///////phase.monad [outcome (optimized_pattern_matching recur pathP)] (.case outcome - (#.Some outcome) + {#.Some outcome} (in outcome) #.None (.case pathP - (#/////synthesis.Then bodyS) + {#/////synthesis.Then bodyS} (statement expression archive bodyS) #/////synthesis.Pop (///////phase\in pop_cursor!) - (#/////synthesis.Bind register) + {#/////synthesis.Bind register} (///////phase\in (_.define (..register register) ..peek_cursor)) - (#/////synthesis.Bit_Fork when thenP elseP) + {#/////synthesis.Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - (#.Some elseP) + {#.Some elseP} (recur elseP) #.None @@ -252,7 +252,7 @@ else! then!)))) - (#/////synthesis.I64_Fork item) + {#/////synthesis.I64_Fork item} (do [! ///////phase.monad] [clauses (monad.each ! (function (_ [match then]) (do ! @@ -260,7 +260,7 @@ (in [(//runtime.i64//= (//primitive.i64 (.int match)) ..peek_cursor) then!]))) - (#.Item item))] + {#.Item item})] (in (_.cond clauses ..fail_pm!))) (^template [<tag> <format>] @@ -268,10 +268,10 @@ (do [! ///////phase.monad] [cases (monad.each ! (function (_ [match then]) (\ ! each (|>> [(list (<format> match))]) (recur then))) - (#.Item item))] + {#.Item item})] (in (_.switch ..peek_cursor cases - (#.Some ..fail_pm!))))]) + {#.Some ..fail_pm!})))]) ([#/////synthesis.F64_Fork //primitive.f64] [#/////synthesis.Text_Fork //primitive.text]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux index 58bf53a29..f2be9fda5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux @@ -104,7 +104,7 @@ (macro.with_identifiers [g!_ runtime] (let [runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration - (#.Left name) + {#.Left name} (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) Var @@ -116,7 +116,7 @@ (function ((~ g!_) (~ g!name)) (~ code)))))))) - (#.Right [name inputs]) + {#.Right [name inputs]} (let [g!name (code.local_identifier name) inputsC (list\each code.local_identifier inputs) inputs_typesC (list\each (function.constant (` _.Expression)) inputs)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux index c4284d345..88072200f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux @@ -20,7 +20,7 @@ #.End (///////phase\in //runtime.unit) - (#.Item singletonS #.End) + {#.Item singletonS #.End} (generate archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux index c2a125d4a..6a1a607cb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux @@ -36,12 +36,12 @@ (^ (synthesis.tuple members)) (/structure.tuple generate archive members) - (#synthesis.Reference reference) + {#synthesis.Reference reference} (case reference - (#reference.Variable variable) + {#reference.Variable variable} (/reference.variable archive variable) - (#reference.Constant constant) + {#reference.Constant constant} (/reference.constant archive constant)) (^ (synthesis.branch/case [valueS pathS])) @@ -68,6 +68,6 @@ (^ (synthesis.function/apply application)) (/function.apply generate archive application) - (#synthesis.Extension extension) + {#synthesis.Extension extension} (///extension.apply archive generate extension) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux index 075e8d68a..2da725141 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux @@ -95,12 +95,12 @@ #synthesis.Pop (operation\in ..pop) - (#synthesis.Bind register) + {#synthesis.Bind register} (operation\in ($_ _.composite ..peek (_.astore register))) - (#synthesis.Then bodyS) + {#synthesis.Then bodyS} (do phase.monad [bodyG (phase archive bodyS)] (in ($_ _.composite @@ -171,7 +171,7 @@ ([synthesis.member/left //runtime.left_projection] [synthesis.member/right //runtime.right_projection]) - (#synthesis.Alt leftP rightP) + {#synthesis.Alt leftP rightP} (do phase.monad [@alt_else //runtime.forge_label left! (path' (++ stack_depth) @alt_else @end phase archive leftP) @@ -183,7 +183,7 @@ _.pop right!))) - (#synthesis.Seq leftP rightP) + {#synthesis.Seq leftP rightP} (do phase.monad [left! (path' stack_depth @else @end phase archive leftP) right! (path' stack_depth @else @end phase archive rightP)] @@ -243,10 +243,10 @@ [recordG (phase archive recordS)] (in (list\mix (function (_ step so_far) (.let [next (.case step - (#.Left lefts) + {#.Left lefts} (..left_projection lefts) - (#.Right lefts) + {#.Right lefts} (..right_projection lefts))] (_.composite so_far next))) recordG diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux index d1785ac0a..b0833504c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux @@ -24,8 +24,8 @@ (file.get_file io.monad file.default file_path))] (\ file over_write bytecode))] (in (case outcome - (#try.Success definition) + {#try.Success definition} file_path - (#try.Failure error) + {#try.Failure error} error))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux index a16c047e7..994a9f33f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux @@ -85,7 +85,7 @@ (method.method //.modifier ////runtime.apply::name (////runtime.apply::type apply_arity) (list) - (#.Some (case num_partials + {#.Some (case num_partials 0 ($_ _.composite ////reference.this (..inputs ..this_offset apply_arity) @@ -97,7 +97,7 @@ @labelsT (|> _.new_label (list.repeated (-- num_partials)) (monad.all _.monad)) - .let [cases (|> (list\composite (#.Item [@labelsH @labelsT]) + .let [cases (|> (list\composite {#.Item [@labelsH @labelsT]} (list @default)) list.enumeration (list\each (function (_ [stage @case]) @@ -132,7 +132,7 @@ (apply (n.+ ..this_offset arity_inputs) additional_inputs) _.areturn)) - ... (i.< over_extent (.int stage)) +... (i.< over_extent (.int stage)) (let [current_environment (|> (list.indices (list.size environment)) (list\each (///foreign.get class)) (monad.all _.monad)) @@ -154,4 +154,4 @@ ($_ _.composite ///partial/count.value (_.tableswitch (try.trusted (signed.s4 +0)) @default [@labelsH @labelsT]) - cases))))))) + cases)))}))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux index ae02754ae..723ff6ce5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux @@ -31,11 +31,11 @@ (method.method //.modifier name (..type arity) (list) - (#.Some ($_ _.composite + {#.Some ($_ _.composite (_.set_label @begin) body _.areturn - )))) + )})) (def: .public method (-> Arity Label (Bytecode Any) (Resource Method)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux index e39e582db..91df54eca 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux @@ -94,9 +94,9 @@ (method.method //.modifier ..name (..type environment arity) (list) - (#.Some ($_ _.composite + {#.Some ($_ _.composite ////reference.this (..super environment_size arity) (store_all environment_size (///foreign.put class) offset_foreign) (store_all (-- arity) (///partial.put class) offset_partial) - _.return))))) + _.return)}))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux index 0e8365945..79926e5b8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux @@ -69,7 +69,7 @@ (method.method //.modifier //init.name (//init.type environment arity) (list) - (#.Some ($_ _.composite + {#.Some ($_ _.composite ////reference.this (//init.super environment_size arity) (monad.each _.monad (function (_ register) @@ -78,4 +78,4 @@ (monad.each _.monad (function (_ register) (///partial.put class register (_.aload (after_arity register)))) (list.indices (n.- ///arity.minimum arity))) - _.areturn))))) + _.areturn)}))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux index f406c2879..b5bdb1e1d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux @@ -43,8 +43,8 @@ (method.method //.modifier ..name (..type class) (list) - (#.Some ($_ _.composite + {#.Some ($_ _.composite (if (arity.multiary? arity) (//new.instance' (..current_environment class environment) class environment arity) ////reference.this) - _.areturn)))) + _.areturn)})) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux index 6e5030da6..0ffbbceb3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux @@ -81,20 +81,20 @@ (def: (class_value class_name class) (-> Text (java/lang/Class java/lang/Object) (Try Any)) (case (java/lang/Class::getField ..value::field class) - (#try.Success field) + {#try.Success field} (case (java/lang/reflect/Field::get #.None field) - (#try.Success ?value) + {#try.Success ?value} (case ?value - (#.Some value) - (#try.Success value) + {#.Some value} + {#try.Success value} #.None (exception.except ..invalid_value [class_name])) - (#try.Failure error) + {#try.Failure error} (exception.except ..cannot_load [class_name error])) - (#try.Failure error) + {#try.Failure error} (exception.except ..invalid_field [class_name ..value::field error]))) (def: class_path_separator @@ -110,11 +110,11 @@ (list (field.field ..value::modifier ..value::field ..value::type (row.row))) (list (method.method ..init::modifier "<clinit>" ..init::type (list) - (#.Some + {#.Some ($_ _.composite valueG (_.putstatic (type.class bytecode_name (list)) ..value::field ..value::type) - _.return)))) + _.return)})) (row.row))] (io.run! (do [! (try.with io.monad)] [bytecode (\ ! each (format.result class.writer) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux index 3edc41c03..9ed5eb48e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux @@ -51,21 +51,21 @@ value (case (signed.s1 value) - (#try.Success value) + {#try.Success value} (do _.monad [_ (_.bipush value) _ _.i2l] ..wrap_i64) - (#try.Failure _) + {#try.Failure _} (case (signed.s2 value) - (#try.Success value) + {#try.Success value} (do _.monad [_ (_.sipush value) _ _.i2l] ..wrap_i64) - (#try.Failure _) + {#try.Failure _} (do _.monad [_ (_.long value)] ..wrap_i64))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux index 8ba5655a1..4074cf6cc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux @@ -132,12 +132,12 @@ (let [super_class (|> ..^Object type.reflection reflection.reflection name.internal) main (method.method ..main::modifier "main" ..main::type (list) - (#.Some ($_ _.composite + {#.Some ($_ _.composite program ..input_list ..feed_inputs ..run_io - _.return)))] + _.return)})] [..class (<| (format.result class.writer) try.trusted diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux index 931f8fd72..778b23005 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux @@ -53,10 +53,10 @@ (def: .public (variable archive variable) (-> Archive Variable (Operation (Bytecode Any))) (case variable - (#variable.Local variable) + {#variable.Local variable} (operation\in (_.aload variable)) - (#variable.Foreign variable) + {#variable.Foreign variable} (..foreign archive variable))) (def: .public (constant archive name) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux index ad6166d3f..c3c8f518c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux @@ -151,12 +151,12 @@ (method.method ..modifier ..variant::name ..variant::type (list) - (#.Some ($_ _.composite - new_variant ... A[3] - (..set! ..variant_tag $tag) ... A[3] + {#.Some ($_ _.composite + new_variant ... A[3] + (..set! ..variant_tag $tag) ... A[3] (..set! ..variant_last? $last?) ... A[3] (..set! ..variant_value $value) ... A[3] - _.areturn))))) + _.areturn)}))) (def: .public left_flag _.aconst_null) (def: .public right_flag ..unit) @@ -213,13 +213,13 @@ (method.method ..modifier ..decode_frac::name ..decode_frac::type (list) - (#.Some + {#.Some (..risky ($_ _.composite _.aload_0 (_.invokestatic //type.frac "parseDouble" (type.method [(list) (list //type.text) type.double (list)])) (//value.wrap type.double) - ))))) + ))})) (def: .public log! (Bytecode Any) @@ -250,10 +250,10 @@ (method.method ..modifier name ..failure::type (list) - (#.Some + {#.Some ($_ _.composite (..illegal_state_exception message) - _.athrow)))) + _.athrow)})) (def: pm_failure::name "pm_failure") (def: .public pm_failure (..procedure ..pm_failure::name ..failure::type)) @@ -272,7 +272,7 @@ (method.method ..modifier ..push::name ..push::type (list) - (#.Some + {#.Some (let [new_stack_frame! ($_ _.composite _.iconst_2 (_.anewarray //type.value)) @@ -282,7 +282,7 @@ new_stack_frame! (..set! ..stack_head $head) (..set! ..stack_tail $tail) - _.areturn))))) + _.areturn))})) (def: case::name "case") (def: case::type (type.method [(list) (list //type.variant //type.tag //type.flag) //type.value (list)])) @@ -291,7 +291,7 @@ (def: case::method (method.method ..modifier ..case::name ..case::type (list) - (#.Some + {#.Some (do _.monad [@loop _.new_label @perfect_match! _.new_label @@ -320,7 +320,7 @@ ($_ _.composite ... tag, sumT update_$variant ... tag, sumT - update_$tag ... sub_tag + update_$tag ... sub_tag (_.goto @loop_start)))) super_nested_tag ($_ _.composite @@ -340,15 +340,15 @@ _.dup2 (_.if_icmpeq @tags_match!) _.dup2 (_.if_icmpgt @maybe_nested) $last? (_.ifnull @mismatch!) ... tag, sumT - super_nested ... super_variant + super_nested ... super_variant _.areturn (_.set_label @tags_match!) ... tag, sumT - $last? ... tag, sumT, wants_last? + $last? ... tag, sumT, wants_last? $variant ::last? ... tag, sumT, wants_last?, is_last? (_.if_acmpeq @perfect_match!) ... tag, sumT - (_.set_label @maybe_nested) ... tag, sumT - $variant ::last? ... tag, sumT, last? - (_.ifnull @mismatch!) ... tag, sumT + (_.set_label @maybe_nested) ... tag, sumT + $variant ::last? ... tag, sumT, last? + (_.ifnull @mismatch!) ... tag, sumT (recur @loop) (_.set_label @perfect_match!) ... tag, sumT ... _.pop2 @@ -358,7 +358,7 @@ ... _.pop2 not_found _.areturn - ))))) + ))})) (def: projection_type (type.method [(list) (list //type.tuple //type.offset) //type.value (list)])) @@ -395,7 +395,7 @@ left_projection::method (method.method ..modifier ..left_projection::name ..projection_type (list) - (#.Some + {#.Some (do _.monad [@loop _.new_label @recursive _.new_label @@ -408,12 +408,12 @@ _.areturn (_.set_label @recursive) ... Recursive - (recur @loop))))) + (recur @loop)))}) right_projection::method (method.method ..modifier ..right_projection::name ..projection_type (list) - (#.Some + {#.Some (do _.monad [@loop _.new_label @not_tail _.new_label @@ -443,7 +443,7 @@ (recur @loop) (_.set_label @slice) super_nested - _.areturn))))] + _.areturn))})] [left_projection::method right_projection::method])) @@ -466,7 +466,7 @@ (def: try::method (method.method ..modifier ..try::name ..try::type (list) - (#.Some + {#.Some (do _.monad [@try _.new_label @handler _.new_label @@ -501,7 +501,7 @@ (_.invokevirtual //type.error "printStackTrace" (type.method [(list) (list ^PrintWriter) type.void (list)])) ... W (_.invokevirtual ^StringWriter "toString" (type.method [(list) (list) //type.text (list)])) ... S ..left_injection _.areturn - ))))) + ))})) (def: reflection (All (_ category) @@ -549,7 +549,7 @@ (list\each (function (_ arity) (method.method method.public ..apply::name (..apply::type arity) (list) - (#.Some + {#.Some (let [previous_inputs (|> arity list.indices (monad.each _.monad _.aload))] @@ -559,14 +559,14 @@ (_.checkcast //function.class) (_.aload arity) (_.invokevirtual //function.class ..apply::name (..apply::type //function/arity.minimum)) - _.areturn)))))) + _.areturn))}))) (list& (method.method (modifier\composite method.public method.abstract) ..apply::name (..apply::type //function/arity.minimum) (list) #.None))) <init>::method (method.method method.public "<init>" //function.init (list) - (#.Some + {#.Some (let [$partials _.iload_1] ($_ _.composite ..this @@ -574,7 +574,7 @@ ..this $partials (_.putfield //function.class //function/count.field //function/count.type) - _.return)))) + _.return))}) modifier (: (Modifier Class) ($_ modifier\composite class.public diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux index c3bb19132..6b1a09aea 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux @@ -32,7 +32,7 @@ #.End (\ phase.monad in //runtime.unit) - (#.Item singletonS #.End) + {#.Item singletonS #.End} (generate archive singletonS) _ @@ -64,15 +64,15 @@ 4 _.iconst_4 5 _.iconst_5 tag (case (signed.s1 (.int tag)) - (#try.Success value) + {#try.Success value} (_.bipush value) - (#try.Failure _) + {#try.Failure _} (case (signed.s2 (.int tag)) - (#try.Success value) + {#try.Success value} (_.sipush value) - (#try.Failure _) + {#try.Failure _} (_.int (.i64 tag)))))) (def: .public (flag right?) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux index 7cc28fb4d..66472f114 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux @@ -49,7 +49,7 @@ (^ (synthesis.tuple members)) (/structure.tuple expression archive members) - (#synthesis.Reference value) + {#synthesis.Reference value} (//reference.reference /reference.system archive value) (^ (synthesis.branch/case case)) @@ -76,7 +76,7 @@ (^ (synthesis.function/apply application)) (/function.apply expression archive application) - (#synthesis.Extension extension) + {#synthesis.Extension extension} (///extension.apply archive expression extension))) (def: .public generate diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux index d21406763..7188a282c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux @@ -163,20 +163,20 @@ (-> Phase! Phase Archive Path (Operation Statement)) (function (recur pathP) (.case pathP - (#/////synthesis.Then bodyS) + {#/////synthesis.Then bodyS} (statement expression archive bodyS) #/////synthesis.Pop (///////phase\in ..pop!) - (#/////synthesis.Bind register) + {#/////synthesis.Bind register} (///////phase\in (_.local/1 (..register register) ..peek)) - (#/////synthesis.Bit_Fork when thenP elseP) + {#/////synthesis.Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - (#.Some elseP) + {#.Some elseP} (recur elseP) #.None @@ -190,7 +190,7 @@ then!)))) (^template [<tag> <format>] - [(<tag> item) + [{<tag> item} (do [! ///////phase.monad] [clauses (monad.each ! (function (_ [match then]) (do ! @@ -198,7 +198,7 @@ (in [(_.= (|> match <format>) ..peek) then!]))) - (#.Item item))] + {#.Item item})] (in (_.cond clauses ..fail!)))]) ([#/////synthesis.I64_Fork (<| _.int .int)] [#/////synthesis.F64_Fork _.float] @@ -254,10 +254,10 @@ set.list (list\each (function (_ variable) (.case variable - (#///////variable.Local register) + {#///////variable.Local register} (..register register) - (#///////variable.Foreign register) + {#///////variable.Foreign register} (..capture register)))))) (def: .public (case! statement expression archive [valueS pathP]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux index 9ed2c2624..a6e448433 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux @@ -127,7 +127,7 @@ (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration - (#.Left name) + {#.Left name} (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) @@ -140,7 +140,7 @@ (function ((~ g!_) (~ g!name)) (_.set (~ g!name) (~ code)))))))))) - (#.Right [name inputs]) + {#.Right [name inputs]} (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name) inputsC (list\each code.local_identifier inputs) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux index 10be9ba18..29a909d0e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux @@ -20,7 +20,7 @@ #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Item singletonS #.End) + {#.Item singletonS #.End} (generate archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux index fae8d8d61..9c16f64cb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux @@ -72,7 +72,7 @@ [////synthesis.f64 /primitive.f64] [////synthesis.text /primitive.text]) - (#////synthesis.Reference value) + {#////synthesis.Reference value} (//reference.reference /reference.system archive value) (^template [<tag> <generator>] @@ -95,7 +95,7 @@ (^ (////synthesis.loop/recur _)) (//////phase.except ..cannot_recur_as_an_expression []) - (#////synthesis.Extension extension) + {#////synthesis.Extension extension} (///extension.apply archive expression extension))) (def: .public generate diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux index 295d24457..a5532afc3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux @@ -163,20 +163,20 @@ (Generator! Path) (function (recur pathP) (.case pathP - (#/////synthesis.Then bodyS) + {#/////synthesis.Then bodyS} (statement expression archive bodyS) #/////synthesis.Pop (///////phase\in ..pop!) - (#/////synthesis.Bind register) + {#/////synthesis.Bind register} (///////phase\in (_.set! (..register register) ..peek)) - (#/////synthesis.Bit_Fork when thenP elseP) + {#/////synthesis.Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - (#.Some elseP) + {#.Some elseP} (recur elseP) #.None @@ -190,7 +190,7 @@ then!)))) (^template [<tag> <format>] - [(<tag> item) + [{<tag> item} (do [! ///////phase.monad] [clauses (monad.each ! (function (_ [match then]) (do ! @@ -198,7 +198,7 @@ (in [(_.=== (|> match <format>) ..peek) then!]))) - (#.Item item))] + {#.Item item})] (in (_.cond clauses ..fail!)))]) ([#/////synthesis.I64_Fork //primitive.i64] [#/////synthesis.F64_Fork //primitive.f64] @@ -264,10 +264,10 @@ set.list (list\each (function (_ variable) (.case variable - (#///////variable.Local register) + {#///////variable.Local register} (..register register) - (#///////variable.Foreign register) + {#///////variable.Foreign register} (..capture register)))))) (def: .public (case! statement expression archive [valueS pathP]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux index 0fe181b78..d8a418657 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux @@ -95,7 +95,7 @@ (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.constant (~ (code.text (%.code runtime)))))] (case declaration - (#.Left name) + {#.Left name} (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) @@ -108,7 +108,7 @@ (function ((~ g!_) (~ g!name)) (_.define (~ g!name) (~ code)))))))))) - (#.Right [name inputs]) + {#.Right [name inputs]} (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name) inputsC (list\each code.local_identifier inputs) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux index 69f687713..cb499a364 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux @@ -23,7 +23,7 @@ #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Item singletonS #.End) + {#.Item singletonS #.End} (expression archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux index 86433d927..b691c09d6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux @@ -49,7 +49,7 @@ (^ (////synthesis.tuple members)) (/structure.tuple expression archive members) - (#////synthesis.Reference value) + {#////synthesis.Reference value} (//reference.reference /reference.system archive value) (^ (////synthesis.branch/case case)) @@ -76,7 +76,7 @@ (^ (////synthesis.function/apply application)) (/function.apply expression archive application) - (#////synthesis.Extension extension) + {#////synthesis.Extension extension} (///extension.apply archive expression extension))) (def: .public generate diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux index c4f914d01..6cdabddd0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux @@ -163,7 +163,7 @@ ($_ _.then (_.set (list g!once) (_.bool false)) body!) - (#.Some _.continue))))) + {#.Some _.continue})))) (def: (alternation in_closure? g!once pre! post!) (-> Bit SVar (Statement Any) (Statement Any) (Statement Any)) @@ -179,34 +179,34 @@ (-> (-> Path (Operation (Statement Any))) (-> Path (Operation (Maybe (Statement Any))))) (.case pathP - (#/////synthesis.Bit_Fork when thenP elseP) + {#/////synthesis.Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - (#.Some elseP) + {#.Some elseP} (recur elseP) #.None (in ..fail_pm!))] - (in (#.Some (.if when + (in {#.Some (.if when (_.if ..peek then! else!) (_.if ..peek else! - then!))))) + then!))})) (^template [<tag> <format>] - [(<tag> item) + [{<tag> item} (do [! ///////phase.monad] [clauses (monad.each ! (function (_ [match then]) (\ ! each (|>> [(_.= (|> match <format>) ..peek)]) (recur then))) - (#.Item item))] - (in (#.Some (_.cond clauses - ..fail_pm!))))]) + {#.Item item})] + (in {#.Some (_.cond clauses + ..fail_pm!)}))]) ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] [#/////synthesis.F64_Fork (<| //primitive.f64)] [#/////synthesis.Text_Fork (<| //primitive.text)]) @@ -220,18 +220,18 @@ (do [! ///////phase.monad] [?output (primitive_pattern_matching recur pathP)] (.case ?output - (#.Some output) + {#.Some output} (in output) #.None (.case pathP - (#/////synthesis.Then bodyS) + {#/////synthesis.Then bodyS} (statement expression archive bodyS) #/////synthesis.Pop (///////phase\in ..pop!) - (#/////synthesis.Bind register) + {#/////synthesis.Bind register} (///////phase\in (_.set (list (..register register)) ..peek)) (^template [<complex> <simple> <choice>] @@ -302,10 +302,10 @@ set.list (list\each (function (_ variable) (.case variable - (#///////variable.Local register) + {#///////variable.Local register} (..register register) - (#///////variable.Foreign register) + {#///////variable.Foreign register} (..capture register)))))) (def: .public (case! in_closure? statement expression archive [valueS pathP]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux index 16283e2e9..c2055e2cc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux @@ -126,7 +126,7 @@ (<>.some <code>.local_identifier)))) code <code>.any]) (case declaration - (#.Left name) + {#.Left name} (macro.with_identifiers [g!_] (let [nameC (code.local_identifier name) code_nameC (code.local_identifier (format "@" name)) @@ -138,7 +138,7 @@ (function ((~ g!_) (~ g!_)) (_.set (list (~ g!_)) (~ code)))))))))) - (#.Right [name inputs]) + {#.Right [name inputs]} (macro.with_identifiers [g!_] (let [nameC (code.local_identifier name) code_nameC (code.local_identifier (format "@" name)) @@ -174,7 +174,7 @@ (runtime: (lux::exec code globals) ($_ _.then - (_.exec code (#.Some globals)) + (_.exec code {#.Some globals}) (_.return ..unit))) (def: runtime::lux diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux index 3d0903731..5950a81ff 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux @@ -20,7 +20,7 @@ #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Item singletonS #.End) + {#.Item singletonS #.End} (generate archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux index 4a6d95239..4e3e67097 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux @@ -36,7 +36,7 @@ [////synthesis.f64 /primitive.f64] [////synthesis.text /primitive.text]) - (#////synthesis.Reference value) + {#////synthesis.Reference value} (//reference.reference /reference.system archive value) (^template [<tag> <generator>] @@ -54,6 +54,6 @@ [////synthesis.loop/recur /loop.recur] [////synthesis.function/abstraction /function.function]) - (#////synthesis.Extension extension) + {#////synthesis.Extension extension} (///extension.apply archive generate extension) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux index 83859e8be..15e9c75e5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux @@ -135,20 +135,20 @@ (Generator Path) (function (recur pathP) (.case pathP - (#/////synthesis.Then bodyS) + {#/////synthesis.Then bodyS} (expression archive bodyS) #/////synthesis.Pop (///////phase\in ..pop_cursor!) - (#/////synthesis.Bind register) + {#/////synthesis.Bind register} (///////phase\in (_.set! (..register register) ..peek)) - (#/////synthesis.Bit_Fork when thenP elseP) + {#/////synthesis.Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - (#.Some elseP) + {#.Some elseP} (recur elseP) #.None @@ -162,7 +162,7 @@ then!)))) (^template [<tag> <format> <=>] - [(<tag> item) + [{<tag> item} (do [! ///////phase.monad] [clauses (monad.each ! (function (_ [match then]) (do ! @@ -170,7 +170,7 @@ (in [(<=> (|> match <format>) ..peek) then!]))) - (#.Item item))] + {#.Item item})] (in (list\mix (function (_ [when then] else) (_.if when then else)) ..fail! @@ -214,9 +214,9 @@ ..save_cursor! leftO) #.None - (#.Some (..catch ($_ _.then + {#.Some (..catch ($_ _.then ..restore_cursor! - rightO))) + rightO))} #.None))) ))) @@ -226,7 +226,7 @@ [pattern_matching! (pattern_matching' expression archive pathP)] (in (_.try pattern_matching! #.None - (#.Some (..catch (_.stop (_.string "Invalid expression for pattern-matching.")))) + {#.Some (..catch (_.stop (_.string "Invalid expression for pattern-matching.")))} #.None)))) (def: .public (case expression archive [valueS pathP]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux index d240e786b..9d2c878cf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux @@ -126,10 +126,10 @@ (function (_ proc_name) (function (_ translate inputsS) (case (s.result inputsS ($_ p.and s.nat (s.tuple (p.many s.any)) s.any)) - (#e.Success [offset initsS+ bodyS]) + {#e.Success [offset initsS+ bodyS]} (loopT.translate_loop translate offset initsS+ bodyS) - (#e.Error error) + {#e.Error error} (&.throw Wrong_Syntax (wrong_syntax proc_name inputsS))) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux index ea6f59abd..4975c0aec 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux @@ -25,7 +25,7 @@ ... (def: (lua//global proc translate inputs) ... (-> Text @.Proc) ... (case inputs -... (^ (list [_ (#.Text name)])) +... (^ (list [_ {#.Text name}])) ... (do macro.Monad<Meta> ... [] ... (in name)) @@ -56,7 +56,7 @@ ... (def: (table//call proc translate inputs) ... (-> Text @.Proc) ... (case inputs -... (^ (list& tableS [_ (#.Text field)] argsS+)) +... (^ (list& tableS [_ {#.Text field}] argsS+)) ... (do [@ macro.Monad<Meta>] ... [tableO (translate tableS) ... argsO+ (monad.each @ translate argsS+)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux index e7d794d5e..246a010c9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux @@ -98,7 +98,7 @@ (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration - (#.Left name) + {#.Left name} (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) _.SVar @@ -108,7 +108,7 @@ _.Expression (_.set! (~ runtime_name) (~ code))))))) - (#.Right [name inputs]) + {#.Right [name inputs]} (let [g!name (code.local_identifier name) inputsC (list\each code.local_identifier inputs) inputs_typesC (list\each (function.constant (` _.Expression)) @@ -524,9 +524,9 @@ (_.set! value (_.apply (list ..unit) op)) (..right value)) #.None - (#.Some (_.function (list error) + {#.Some (_.function (list error) (..left (_.item (_.string "message") - error)))) + error)))} #.None))) (runtime: (lux::program_args program_args) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux index 4d6562a4f..711366595 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux @@ -23,7 +23,7 @@ #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Item singletonS #.End) + {#.Item singletonS #.End} (expression archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux index 4913559a1..49389b109 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux @@ -73,18 +73,18 @@ (All (_ expression) (-> (System expression) Variable expression)) (case variable - (#variable.Local register) + {#variable.Local register} (..local system register) - (#variable.Foreign register) + {#variable.Foreign register} (..foreign system register))) (def: .public (reference system archive reference) (All (_ anchor expression directive) (-> (System expression) Archive Reference (////generation.Operation anchor expression directive expression))) (case reference - (#reference.Constant value) + {#reference.Constant value} (..constant system archive value) - (#reference.Variable value) + {#reference.Variable value} (phase\in (..variable system value)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux index 9202b75d3..b9202972d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux @@ -65,10 +65,10 @@ (^ (////synthesis.loop/recur _)) (//////phase.except ..cannot_recur_as_an_expression []) - (#////synthesis.Reference value) + {#////synthesis.Reference value} (//reference.reference /reference.system archive value) - (#////synthesis.Extension extension) + {#////synthesis.Extension extension} (///extension.apply archive expression extension))) (def: .public generate diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux index 8d19caff8..1e6cb7058 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux @@ -188,34 +188,34 @@ (-> (-> Path (Operation Statement)) (-> Path (Operation (Maybe Statement)))) (.case pathP - (#/////synthesis.Bit_Fork when thenP elseP) + {#/////synthesis.Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - (#.Some elseP) + {#.Some elseP} (recur elseP) #.None (in ..fail!))] - (in (#.Some (.if when + (in {#.Some (.if when (_.if ..peek then! else!) (_.if ..peek else! - then!))))) + then!))})) (^template [<tag> <format>] - [(<tag> item) + [{<tag> item} (do [! ///////phase.monad] [clauses (monad.each ! (function (_ [match then]) (\ ! each (|>> [(_.= (|> match <format>) ..peek)]) (recur then))) - (#.Item item))] - (in (#.Some (_.cond clauses - ..fail!))))]) + {#.Item item})] + (in {#.Some (_.cond clauses + ..fail!)}))]) ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] [#/////synthesis.F64_Fork (<| //primitive.f64)] [#/////synthesis.Text_Fork (<| //primitive.text)]) @@ -229,25 +229,25 @@ (do ///////phase.monad [?output (primitive_pattern_matching recur pathP)] (.case ?output - (#.Some output) + {#.Some output} (in output) #.None (.case pathP - (#/////synthesis.Then bodyS) + {#/////synthesis.Then bodyS} (statement expression archive bodyS) #/////synthesis.Pop (///////phase\in ..pop!) - (#/////synthesis.Bind register) + {#/////synthesis.Bind register} (///////phase\in (_.set (list (..register register)) ..peek)) - (#/////synthesis.Bit_Fork when thenP elseP) + {#/////synthesis.Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - (#.Some elseP) + {#.Some elseP} (recur elseP) #.None @@ -261,14 +261,14 @@ then!)))) (^template [<tag> <format>] - [(<tag> item) + [{<tag> item} (do [! ///////phase.monad] [clauses (monad.each ! (function (_ [match then]) (\ ! each (|>> [(_.= (|> match <format>) ..peek)]) (recur then))) - (#.Item item))] + {#.Item item})] (in (_.cond clauses ..fail!)))]) ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux index 108f98020..091d1fd31 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux @@ -84,7 +84,7 @@ initialize_self! (list.indices arity)) [declaration instatiation] (with_closure closureO+ function_name - (_.lambda (#.Some @self) (list (_.variadic @curried)) + (_.lambda {#.Some @self} (list (_.variadic @curried)) ($_ _.then (_.set (list @num_args) (_.the "length" @curried)) (_.cond (list [(|> @num_args (_.= arityO)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux index c5f424373..643bde0b2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux @@ -96,7 +96,7 @@ (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.local (~ (code.text (%.code runtime)))))] (case declaration - (#.Left name) + {#.Left name} (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) LVar (~ runtime_name))) @@ -106,7 +106,7 @@ (function ((~ g!_) (~ g!name)) (_.set (list (~ g!name)) (~ code)))))))))) - (#.Right [name inputs]) + {#.Right [name inputs]} (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name) inputsC (list\each code.local_identifier inputs) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux index a93fba45e..32ec74e4f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux @@ -20,7 +20,7 @@ #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Item singletonS #.End) + {#.Item singletonS #.End} (generate archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux index 079ef448c..20108a0cd 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux @@ -36,7 +36,7 @@ [////synthesis.f64 /primitive.f64] [////synthesis.text /primitive.text]) - (#////synthesis.Reference value) + {#////synthesis.Reference value} (//reference.reference /reference.system archive value) (^template [<tag> <generator>] @@ -54,6 +54,6 @@ [////synthesis.loop/recur /loop.recur] [////synthesis.function/abstraction /function.function]) - (#////synthesis.Extension extension) + {#////synthesis.Extension extension} (///extension.apply archive generate extension) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux index 16a00e907..bfdb9bf93 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux @@ -129,20 +129,20 @@ (Generator Path) (function (recur pathP) (.case pathP - (#/////synthesis.Then bodyS) + {#/////synthesis.Then bodyS} (expression archive bodyS) #/////synthesis.Pop (///////phase\in pop_cursor!) - (#/////synthesis.Bind register) + {#/////synthesis.Bind register} (///////phase\in (_.define_constant (..register register) ..peek)) - (#/////synthesis.Bit_Fork when thenP elseP) + {#/////synthesis.Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - (#.Some elseP) + {#.Some elseP} (recur elseP) #.None @@ -156,7 +156,7 @@ then!)))) (^template [<tag> <format> <=>] - [(<tag> item) + [{<tag> item} (do [! ///////phase.monad] [clauses (monad.each ! (function (_ [match then]) (do ! @@ -164,7 +164,7 @@ (in [(<=> (|> match <format>) ..peek) then!]))) - (#.Item item))] + {#.Item item})] (in (list\mix (function (_ [when then] else) (_.if when then else)) ..fail! diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux index d18881c4d..f0d2751f3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux @@ -76,7 +76,7 @@ @num_args (_.var "num_args") @self (_.var (///reference.artifact function_name))]] (with_closure closureO+ - (_.letrec (list [@self (_.lambda [(list) (#.Some @curried)] + (_.letrec (list [@self (_.lambda [(list) {#.Some @curried}] (_.let (list [@num_args (_.length/1 @curried)]) (<| (_.if (|> @num_args (_.=/2 arityO)) (<| (_.let (list [(//case.register 0) @self])) @@ -94,7 +94,7 @@ (apply_poly arity_args) (apply_poly output_func_args)))))) ... (|> @num_args (_.</2 arityO)) - (_.lambda [(list) (#.Some @missing)] + (_.lambda [(list) {#.Some @missing}] (|> @self (apply_poly (_.append/2 @curried @missing))))) ))]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux index 996f552b1..0f8ae8b9a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux @@ -80,7 +80,7 @@ (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration - (#.Left name) + {#.Left name} (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) Var @@ -90,7 +90,7 @@ _.Computation (_.define_constant (~ runtime_name) (~ code))))))) - (#.Right [name inputs]) + {#.Right [name inputs]} (let [g!name (code.local_identifier name) inputsC (list\each code.local_identifier inputs) inputs_typesC (list\each (function.constant (` _.Expression)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux index ad071de02..cc84cf77c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux @@ -23,7 +23,7 @@ #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Item singletonS #.End) + {#.Item singletonS #.End} (expression archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux index 5b5403a37..faa6739cb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux @@ -28,18 +28,18 @@ (-> ///analysis.Primitive /.Primitive) (case analysis #///analysis.Unit - (#/.Text /.unit) + {#/.Text /.unit} (^template [<analysis> <synthesis>] - [(<analysis> value) - (<synthesis> value)]) + [{<analysis> value} + {<synthesis> value}]) ([#///analysis.Bit #/.Bit] [#///analysis.Frac #/.F64] [#///analysis.Text #/.Text]) (^template [<analysis> <synthesis>] - [(<analysis> value) - (<synthesis> (.i64 value))]) + [{<analysis> value} + {<synthesis> (.i64 value)}]) ([#///analysis.Nat #/.I64] [#///analysis.Int #/.I64] [#///analysis.Rev #/.I64]))) @@ -48,48 +48,48 @@ Phase (function (optimization' analysis) (case analysis - (#///analysis.Primitive analysis') - (phase\in (#/.Primitive (..primitive analysis'))) + {#///analysis.Primitive analysis'} + (phase\in {#/.Primitive (..primitive analysis')}) - (#///analysis.Reference reference) - (phase\in (#/.Reference reference)) + {#///analysis.Reference reference} + (phase\in {#/.Reference reference}) - (#///analysis.Structure structure) + {#///analysis.Structure structure} (/.with_currying? false (case structure - (#///analysis.Variant variant) + {#///analysis.Variant variant} (do phase.monad [valueS (optimization' (value@ #///analysis.value variant))] (in (/.variant (with@ #///analysis.value valueS variant)))) - (#///analysis.Tuple tuple) + {#///analysis.Tuple tuple} (|> tuple (monad.each phase.monad optimization') (phase\each (|>> /.tuple))))) - (#///analysis.Case inputA branchesAB+) + {#///analysis.Case inputA branchesAB+} (/.with_currying? false (/case.synthesize optimization branchesAB+ archive inputA)) (^ (///analysis.no_op value)) (optimization' value) - (#///analysis.Apply _) + {#///analysis.Apply _} (/.with_currying? false (/function.apply optimization archive analysis)) - (#///analysis.Function environmentA bodyA) + {#///analysis.Function environmentA bodyA} (/function.abstraction optimization environmentA archive bodyA) - (#///analysis.Extension name args) + {#///analysis.Extension name args} (/.with_currying? false (function (_ state) (|> (//extension.apply archive optimization [name args]) (phase.result' state) - (case> (#try.Success output) - (#try.Success output) + (case> {#try.Success output} + {#try.Success output} - (#try.Failure _) + {#try.Failure _} (|> args (monad.each phase.monad optimization') (phase\each (|>> [name] #/.Extension)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux index d42f0da7e..50b89c2e2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -31,25 +31,25 @@ (def: clean_up (-> Path Path) - (|>> (#/.Seq #/.Pop))) + (|>> {#/.Seq #/.Pop})) (def: (path' pattern end? thenC) (-> Pattern Bit (Operation Path) (Operation Path)) (case pattern - (#///analysis.Simple simple) + {#///analysis.Simple simple} (case simple #///analysis.Unit thenC - (#///analysis.Bit when) + {#///analysis.Bit when} (///\each (function (_ then) - (#/.Bit_Fork when then #.None)) + {#/.Bit_Fork when then #.None}) thenC) (^template [<from> <to> <conversion>] - [(<from> test) + [{<from> test} (///\each (function (_ then) - (<to> [(<conversion> test) then] (list))) + {<to> [(<conversion> test) then] (list)}) thenC)]) ([#///analysis.Nat #/.I64_Fork .i64] [#///analysis.Int #/.I64_Fork .i64] @@ -57,32 +57,32 @@ [#///analysis.Frac #/.F64_Fork |>] [#///analysis.Text #/.Text_Fork |>])) - (#///analysis.Bind register) - (<| (\ ///.monad each (|>> (#/.Seq (#/.Bind register)))) + {#///analysis.Bind register} + (<| (\ ///.monad each (|>> {#/.Seq {#/.Bind register}})) /.with_new_local thenC) - (#///analysis.Complex (#///analysis.Variant [lefts right? value_pattern])) - (<| (///\each (|>> (#/.Seq (#/.Access (#/.Side (if right? - (#.Right lefts) - (#.Left lefts))))))) + {#///analysis.Complex {#///analysis.Variant [lefts right? value_pattern]}} + (<| (///\each (|>> {#/.Seq {#/.Access {#/.Side (if right? + {#.Right lefts} + {#.Left lefts})}}})) (path' value_pattern end?) (when> [(new> (not end?) [])] [(///\each ..clean_up)]) thenC) - (#///analysis.Complex (#///analysis.Tuple tuple)) + {#///analysis.Complex {#///analysis.Tuple tuple}} (let [tuple::last (-- (list.size tuple))] (list\mix (function (_ [tuple::lefts tuple::member] nextC) (.case tuple::member - (#///analysis.Simple #///analysis.Unit) + {#///analysis.Simple #///analysis.Unit} nextC _ (let [right? (n.= tuple::last tuple::lefts) end?' (and end? right?)] - (<| (///\each (|>> (#/.Seq (#/.Access (#/.Member (if right? - (#.Right (-- tuple::lefts)) - (#.Left tuple::lefts))))))) + (<| (///\each (|>> {#/.Seq {#/.Access {#/.Member (if right? + {#.Right (-- tuple::lefts)} + {#.Left tuple::lefts})}}})) (path' tuple::member end?') (when> [(new> (not end?') [])] [(///\each ..clean_up)]) nextC)))) @@ -104,74 +104,74 @@ #.End (list [new_test new_then]) - (#.Item old_item) - (#.Item (weave_branch weave equivalence [new_test new_then] old_item)))])) + {#.Item old_item} + {#.Item (weave_branch weave equivalence [new_test new_then] old_item)})])) (def: (weave_fork weave equivalence new_fork old_fork) (All (_ a) (-> (-> Path Path Path) (Equivalence a) (/.Fork a Path) (/.Fork a Path) (/.Fork a Path))) - (list\mix (..weave_branch weave equivalence) old_fork (#.Item new_fork))) + (list\mix (..weave_branch weave equivalence) old_fork {#.Item new_fork})) (def: (weave new old) (-> Path Path Path) - (with_expansions [<default> (as_is (#/.Alt old new))] + (with_expansions [<default> (as_is {#/.Alt old new})] (case [new old] [_ - (#/.Alt old_left old_right)] - (#/.Alt old_left - (weave new old_right)) + {#/.Alt old_left old_right}] + {#/.Alt old_left + (weave new old_right)} - [(#/.Seq preN postN) - (#/.Seq preO postO)] + [{#/.Seq preN postN} + {#/.Seq preO postO}] (case (weave preN preO) - (#/.Alt _) + {#/.Alt _} <default> woven - (#/.Seq woven (weave postN postO))) + {#/.Seq woven (weave postN postO)}) [#/.Pop #/.Pop] old - [(#/.Bit_Fork new_when new_then new_else) - (#/.Bit_Fork old_when old_then old_else)] + [{#/.Bit_Fork new_when new_then new_else} + {#/.Bit_Fork old_when old_then old_else}] (if (bit\= new_when old_when) - (#/.Bit_Fork old_when - (weave new_then old_then) - (case [new_else old_else] - [#.None #.None] - #.None - - (^or [(#.Some woven_then) #.None] - [#.None (#.Some woven_then)]) - (#.Some woven_then) - - [(#.Some new_else) (#.Some old_else)] - (#.Some (weave new_else old_else)))) - (#/.Bit_Fork old_when - (case new_else - #.None - old_then - - (#.Some new_else) - (weave new_else old_then)) - (#.Some (case old_else - #.None - new_then - - (#.Some old_else) - (weave new_then old_else))))) + {#/.Bit_Fork old_when + (weave new_then old_then) + (case [new_else old_else] + [#.None #.None] + #.None + + (^or [{#.Some woven_then} #.None] + [#.None {#.Some woven_then}]) + {#.Some woven_then} + + [{#.Some new_else} {#.Some old_else}] + {#.Some (weave new_else old_else)})} + {#/.Bit_Fork old_when + (case new_else + #.None + old_then + + {#.Some new_else} + (weave new_else old_then)) + {#.Some (case old_else + #.None + new_then + + {#.Some old_else} + (weave new_then old_else))}}) (^template [<tag> <equivalence>] - [[(<tag> new_fork) (<tag> old_fork)] - (<tag> (..weave_fork weave <equivalence> new_fork old_fork))]) + [[{<tag> new_fork} {<tag> old_fork}] + {<tag> (..weave_fork weave <equivalence> new_fork old_fork)}]) ([#/.I64_Fork i64.equivalence] [#/.F64_Fork frac.equivalence] [#/.Text_Fork text.equivalence]) (^template [<access> <side>] - [[(#/.Access (<access> (<side> newL))) - (#/.Access (<access> (<side> oldL)))] + [[{#/.Access {<access> {<side> newL}}} + {#/.Access {<access> {<side> oldL}}}] (if (n.= newL oldL) old <default>)]) @@ -180,7 +180,7 @@ [#/.Member #.Left] [#/.Member #.Right]) - [(#/.Bind newR) (#/.Bind oldR)] + [{#/.Bind newR} {#/.Bind oldR}] (if (n.= newR oldR) old <default>) @@ -196,23 +196,23 @@ <continue> (as_is (recur (++ lefts) tail)) <member> (as_is (if (list.empty? tail) - (#.Right (-- lefts)) - (#.Left lefts)))] + {#.Right (-- lefts)} + {#.Left lefts}))] (case patterns #.End <failure> - (#.Item head tail) + {#.Item head tail} (case head - (#///analysis.Simple #///analysis.Unit) + {#///analysis.Simple #///analysis.Unit} <continue> - (#///analysis.Bind register) + {#///analysis.Bind register} (if (n.= @selection register) (list <member>) <continue>) - (#///analysis.Complex (#///analysis.Tuple sub_patterns)) + {#///analysis.Complex {#///analysis.Tuple sub_patterns}} (case (get sub_patterns @selection) #.End <continue> @@ -231,8 +231,8 @@ (in (/.branch/case [input (list\mix weave headSP tailSP+)])))) (template: (!masking <variable> <output>) - [[[(#///analysis.Bind <variable>) - (#///analysis.Reference (///reference.local <output>))] + [[[{#///analysis.Bind <variable>} + {#///analysis.Reference (///reference.local <output>)}] (list)]]) (def: .public (synthesize_let synthesize archive input @variable body) @@ -246,7 +246,7 @@ (-> Phase Archive Synthesis Register Register (Operation Synthesis)) (if (n.= @variable @output) (///\in input) - (..synthesize_let synthesize archive input @variable (#///analysis.Reference (///reference.local @output))))) + (..synthesize_let synthesize archive input @variable {#///analysis.Reference (///reference.local @output)}))) (def: .public (synthesize_if synthesize archive test then else) (-> Phase Archive Synthesis Analysis Analysis (Operation Synthesis)) @@ -257,7 +257,7 @@ (template: (!get <patterns> <output>) [[[(///analysis.pattern/tuple <patterns>) - (#///analysis.Reference (///reference.local <output>))] + {#///analysis.Reference (///reference.local <output>)}] (.list)]]) (def: .public (synthesize_get synthesize archive input patterns @member) @@ -282,7 +282,7 @@ (^ (!masking @variable @output)) (..synthesize_masking synthesize^ archive inputS @variable @output) - [[(#///analysis.Bind @variable) body] + [[{#///analysis.Bind @variable} body] #.End] (..synthesize_let synthesize^ archive inputS @variable body) @@ -338,26 +338,26 @@ [path path path_storage ..empty] (case path - (^or #/.Pop (#/.Access Access)) + (^or #/.Pop {#/.Access Access}) path_storage (^ (/.path/bind register)) (revised@ #bindings (set.has register) path_storage) - (#/.Bit_Fork _ default otherwise) + {#/.Bit_Fork _ default otherwise} (|> (case otherwise #.None path_storage - (#.Some otherwise) + {#.Some otherwise} (for_path otherwise path_storage)) (for_path default)) - (^or (#/.I64_Fork forks) - (#/.F64_Fork forks) - (#/.Text_Fork forks)) - (|> (#.Item forks) + (^or {#/.I64_Fork forks} + {#/.F64_Fork forks} + {#/.Text_Fork forks}) + (|> {#.Item forks} (list\each product.right) (list\mix for_path path_storage)) @@ -376,16 +376,16 @@ (^ (/.tuple members)) (list\mix for_synthesis synthesis_storage members) - (#/.Reference (#///reference.Variable (#///reference/variable.Local register))) + {#/.Reference {#///reference.Variable {#///reference/variable.Local register}}} (if (set.member? (value@ #bindings synthesis_storage) register) synthesis_storage - (revised@ #dependencies (set.has (#///reference/variable.Local register)) synthesis_storage)) + (revised@ #dependencies (set.has {#///reference/variable.Local register}) synthesis_storage)) - (#/.Reference (#///reference.Variable var)) + {#/.Reference {#///reference.Variable var}} (revised@ #dependencies (set.has var) synthesis_storage) (^ (/.function/apply [functionS argsS])) - (list\mix for_synthesis synthesis_storage (#.Item functionS argsS)) + (list\mix for_synthesis synthesis_storage {#.Item functionS argsS}) (^ (/.function/abstraction [environment arity bodyS])) (list\mix for_synthesis synthesis_storage environment) @@ -423,7 +423,7 @@ (^ (/.loop/recur replacementsS+)) (list\mix for_synthesis synthesis_storage replacementsS+) - (#/.Extension [extension argsS]) + {#/.Extension [extension argsS]} (list\mix for_synthesis synthesis_storage argsS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 96139976a..278b6343e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -85,7 +85,7 @@ (def: (find_foreign environment register) (-> (Environment Synthesis) Register (Operation Synthesis)) (case (list.item register environment) - (#.Some aliased) + {#.Some aliased} (phase\in aliased) #.None @@ -94,30 +94,30 @@ (def: (grow_path grow path) (-> (-> Synthesis (Operation Synthesis)) Path (Operation Path)) (case path - (#/.Bind register) - (phase\in (#/.Bind (++ register))) + {#/.Bind register} + (phase\in {#/.Bind (++ register)}) (^template [<tag>] - [(<tag> left right) + [{<tag> left right} (do phase.monad [left' (grow_path grow left) right' (grow_path grow right)] - (in (<tag> left' right')))]) + (in {<tag> left' right'}))]) ([#/.Alt] [#/.Seq]) - (#/.Bit_Fork when then else) + {#/.Bit_Fork when then else} (do [! phase.monad] [then (grow_path grow then) else (case else - (#.Some else) - (\ ! each (|>> #.Some) (grow_path grow else)) + {#.Some else} + (\ ! each (|>> {#.Some}) (grow_path grow else)) #.None (in #.None))] - (in (#/.Bit_Fork when then else))) + (in {#/.Bit_Fork when then else})) (^template [<tag>] - [(<tag> [[test then] elses]) + [{<tag> [[test then] elses]} (do [! phase.monad] [then (grow_path grow then) elses (monad.each ! (function (_ [else_test else_then]) @@ -125,15 +125,15 @@ [else_then (grow_path grow else_then)] (in [else_test else_then]))) elses)] - (in (<tag> [[test then] elses])))]) + (in {<tag> [[test then] elses]}))]) ([#/.I64_Fork] [#/.F64_Fork] [#/.Text_Fork]) - (#/.Then thenS) + {#/.Then thenS} (|> thenS grow - (phase\each (|>> #/.Then))) + (phase\each (|>> {#/.Then}))) _ (phase\in path))) @@ -141,14 +141,14 @@ (def: (grow environment expression) (-> (Environment Synthesis) Synthesis (Operation Synthesis)) (case expression - (#/.Structure structure) + {#/.Structure structure} (case structure - (#////analysis.Variant [lefts right? subS]) + {#////analysis.Variant [lefts right? subS]} (|> subS (grow environment) (phase\each (|>> [lefts right?] /.variant))) - (#////analysis.Tuple membersS+) + {#////analysis.Tuple membersS+} (|> membersS+ (monad.each phase.monad (grow environment)) (phase\each (|>> /.tuple)))) @@ -156,66 +156,66 @@ (^ (..self_reference)) (phase\in (/.function/apply [expression (list (/.variable/local 1))])) - (#/.Reference reference) + {#/.Reference reference} (case reference - (#////reference.Variable variable) + {#////reference.Variable variable} (case variable - (#////reference/variable.Local register) + {#////reference/variable.Local register} (phase\in (/.variable/local (++ register))) - (#////reference/variable.Foreign register) + {#////reference/variable.Foreign register} (..find_foreign environment register)) - (#////reference.Constant constant) + {#////reference.Constant constant} (phase\in expression)) - (#/.Control control) + {#/.Control control} (case control - (#/.Branch branch) + {#/.Branch branch} (case branch - (#/.Let [inputS register bodyS]) + {#/.Let [inputS register bodyS]} (do phase.monad [inputS' (grow environment inputS) bodyS' (grow environment bodyS)] (in (/.branch/let [inputS' (++ register) bodyS']))) - (#/.If [testS thenS elseS]) + {#/.If [testS thenS elseS]} (do phase.monad [testS' (grow environment testS) thenS' (grow environment thenS) elseS' (grow environment elseS)] (in (/.branch/if [testS' thenS' elseS']))) - (#/.Get members inputS) + {#/.Get members inputS} (do phase.monad [inputS' (grow environment inputS)] (in (/.branch/get [members inputS']))) - (#/.Case [inputS pathS]) + {#/.Case [inputS pathS]} (do phase.monad [inputS' (grow environment inputS) pathS' (grow_path (grow environment) pathS)] (in (/.branch/case [inputS' pathS'])))) - (#/.Loop loop) + {#/.Loop loop} (case loop - (#/.Scope [start initsS+ iterationS]) + {#/.Scope [start initsS+ iterationS]} (do [! phase.monad] [initsS+' (monad.each ! (grow environment) initsS+) iterationS' (grow environment iterationS)] (in (/.loop/scope [(++ start) initsS+' iterationS']))) - (#/.Recur argumentsS+) + {#/.Recur argumentsS+} (|> argumentsS+ (monad.each phase.monad (grow environment)) (phase\each (|>> /.loop/recur)))) - (#/.Function function) + {#/.Function function} (case function - (#/.Abstraction [_env _arity _body]) + {#/.Abstraction [_env _arity _body]} (do [! phase.monad] [_env' (monad.each ! - (|>> (case> (#/.Reference (#////reference.Variable (#////reference/variable.Foreign register))) + (|>> (case> {#/.Reference {#////reference.Variable {#////reference/variable.Foreign register}}} (..find_foreign environment register) captured @@ -223,7 +223,7 @@ _env)] (in (/.function/abstraction [_env' _arity _body]))) - (#/.Apply funcS argsS+) + {#/.Apply funcS argsS+} (do [! phase.monad] [funcS (grow environment funcS) argsS+ (monad.each ! (grow environment) argsS+)] @@ -236,12 +236,12 @@ [funcS argsS+])))))) - (#/.Extension name argumentsS+) + {#/.Extension name argumentsS+} (|> argumentsS+ (monad.each phase.monad (grow environment)) - (phase\each (|>> (#/.Extension name)))) + (phase\each (|>> {#/.Extension name}))) - (#/.Primitive _) + {#/.Primitive _} (phase\in expression))) (def: .public (abstraction phase environment archive bodyA) @@ -269,7 +269,7 @@ (in (if currying? (/.function/abstraction abstraction) (case (//loop.optimization false 1 (list) abstraction) - (#.Some [startL initsL bodyL]) + {#.Some [startL initsL bodyL]} (/.function/abstraction [#/.environment environment #/.arity (value@ #/.arity abstraction) #/.body (/.loop/scope [startL initsL bodyL])]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux index 3b9d37fdd..c65c261e8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux @@ -30,30 +30,30 @@ (-> (Transform Synthesis) Register (Transform Path)) (function (recur path) (case path - (#/.Bind register) - (#.Some (#/.Bind (register_optimization offset register))) + {#/.Bind register} + {#.Some {#/.Bind (register_optimization offset register)}} (^template [<tag>] - [(<tag> left right) + [{<tag> left right} (do maybe.monad [left' (recur left) right' (recur right)] - (in (<tag> left' right')))]) + (in {<tag> left' right'}))]) ([#/.Alt] [#/.Seq]) - (#/.Bit_Fork when then else) + {#/.Bit_Fork when then else} (do [! maybe.monad] [then (recur then) else (case else - (#.Some else) + {#.Some else} (\ ! each (|>> #.Some) (recur else)) #.None (in #.None))] - (in (#/.Bit_Fork when then else))) + (in {#/.Bit_Fork when then else})) (^template [<tag>] - [(<tag> [[test then] elses]) + [{<tag> [[test then] elses]} (do [! maybe.monad] [then (recur then) elses (monad.each ! (function (_ [else_test else_then]) @@ -61,58 +61,58 @@ [else_then (recur else_then)] (in [else_test else_then]))) elses)] - (in (<tag> [[test then] elses])))]) + (in {<tag> [[test then] elses]}))]) ([#/.I64_Fork] [#/.F64_Fork] [#/.Text_Fork]) - (#/.Then body) + {#/.Then body} (|> body body_optimization - (maybe\each (|>> #/.Then))) + (maybe\each (|>> {#/.Then}))) _ - (#.Some path)))) + {#.Some path}))) (def: (body_optimization true_loop? offset scope_environment arity expr) (-> Bit Register (Environment Synthesis) Arity (Transform Synthesis)) (loop [return? true expr expr] (case expr - (#/.Primitive _) - (#.Some expr) + {#/.Primitive _} + {#.Some expr} - (#/.Structure structure) + {#/.Structure structure} (case structure - (#analysis.Variant variant) + {#analysis.Variant variant} (do maybe.monad [value' (|> variant (value@ #analysis.value) (recur false))] (in (|> variant (with@ #analysis.value value') /.variant))) - (#analysis.Tuple tuple) + {#analysis.Tuple tuple} (|> tuple (monad.each maybe.monad (recur false)) (maybe\each (|>> /.tuple)))) - (#/.Reference reference) + {#/.Reference reference} (case reference - (^ (#reference.Variable (variable.self))) + (^ {#reference.Variable (variable.self)}) (if true_loop? #.None - (#.Some expr)) + {#.Some expr}) (^ (reference.constant constant)) - (#.Some expr) + {#.Some expr} (^ (reference.local register)) - (#.Some (#/.Reference (reference.local (register_optimization offset register)))) + {#.Some {#/.Reference (reference.local (register_optimization offset register))}} (^ (reference.foreign register)) (if true_loop? (list.item register scope_environment) - (#.Some expr))) + {#.Some expr})) (^ (/.branch/case [input path])) (do maybe.monad @@ -165,7 +165,7 @@ [abstraction' (recur false abstraction)] (in (/.function/apply [abstraction' arguments']))))] (case abstraction - (^ (#/.Reference (#reference.Variable (variable.self)))) + (^ {#/.Reference {#reference.Variable (variable.self)}}) (if (and return? (n.= arity (list.size arguments))) (in (/.loop/recur arguments')) @@ -177,30 +177,30 @@ <application>))) ... TODO: Stop relying on this custom code. - (^ (#/.Extension ["lux syntax char case!" (list& input else matches)])) + (^ {#/.Extension ["lux syntax char case!" (list& input else matches)]}) (if return? (do [! maybe.monad] [input (recur false input) matches (monad.each ! (function (_ match) (case match - (^ (#/.Structure (#analysis.Tuple (list when then)))) + (^ {#/.Structure {#analysis.Tuple (list when then)}}) (do ! [when (recur false when) then (recur return? then)] - (in (#/.Structure (#analysis.Tuple (list when then))))) + (in {#/.Structure {#analysis.Tuple (list when then)}})) _ (recur false match))) matches) else (recur return? else)] - (in (#/.Extension ["lux syntax char case!" (list& input else matches)]))) + (in {#/.Extension ["lux syntax char case!" (list& input else matches)]})) #.None) - (#/.Extension [name args]) + {#/.Extension [name args]} (|> args (monad.each maybe.monad (recur false)) - (maybe\each (|>> [name] #/.Extension)))))) + (maybe\each (|>> [name] {#/.Extension})))))) (def: .public (optimization true_loop? offset inits functionS) (-> Bit Register (List Synthesis) Abstraction (Maybe [Register (List Synthesis) Synthesis])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux index 91e229d1a..757bdb4c3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux @@ -39,133 +39,133 @@ (-> (Remover Synthesis) (Remover Path)) (function (recur path) (case path - (#/.Seq (#/.Bind register) - post) + {#/.Seq {#/.Bind register} + post} (if (n.= redundant register) (recur post) - (#/.Seq (#/.Bind (if (n.> redundant register) + {#/.Seq {#/.Bind (if (n.> redundant register) (-- register) - register)) - (recur post))) + register)} + (recur post)}) - (^or (#/.Seq (#/.Access (#/.Member member)) - (#/.Seq (#/.Bind register) - post)) + (^or {#/.Seq {#/.Access {#/.Member member}} + {#/.Seq {#/.Bind register} + post}} ... This alternative form should never occur in practice. ... Yet, it is "technically" possible to construct it. - (#/.Seq (#/.Seq (#/.Access (#/.Member member)) - (#/.Bind register)) - post)) + {#/.Seq {#/.Seq {#/.Access {#/.Member member}} + {#/.Bind register}} + post}) (if (n.= redundant register) (recur post) - (#/.Seq (#/.Access (#/.Member member)) - (#/.Seq (#/.Bind (if (n.> redundant register) - (-- register) - register)) - (recur post)))) + {#/.Seq {#/.Access {#/.Member member}} + {#/.Seq {#/.Bind (if (n.> redundant register) + (-- register) + register)} + (recur post)}}) (^template [<tag>] - [(<tag> left right) - (<tag> (recur left) (recur right))]) + [{<tag> left right} + {<tag> (recur left) (recur right)}]) ([#/.Seq] [#/.Alt]) - (#/.Bit_Fork when then else) - (#/.Bit_Fork when (recur then) (maybe\each recur else)) + {#/.Bit_Fork when then else} + {#/.Bit_Fork when (recur then) (maybe\each recur else)} (^template [<tag>] - [(<tag> [[test then] tail]) - (<tag> [[test (recur then)] + [{<tag> [[test then] tail]} + {<tag> [[test (recur then)] (list\each (function (_ [test' then']) [test' (recur then')]) - tail)])]) + tail)]}]) ([#/.I64_Fork] [#/.F64_Fork] [#/.Text_Fork]) (^or #/.Pop - (#/.Access _)) + {#/.Access _}) path - (#/.Bind register) + {#/.Bind register} (undefined) - (#/.Then then) - (#/.Then (remove_local redundant then)) + {#/.Then then} + {#/.Then (remove_local redundant then)} ))) (def: (remove_local_from_variable redundant variable) (Remover Variable) (case variable - (#variable.Local register) - (#variable.Local (..prune redundant register)) + {#variable.Local register} + {#variable.Local (..prune redundant register)} - (#variable.Foreign register) + {#variable.Foreign register} variable)) (def: (remove_local redundant) (Remover Synthesis) (function (recur synthesis) (case synthesis - (#/.Primitive _) + {#/.Primitive _} synthesis - (#/.Structure structure) - (#/.Structure (case structure - (#analysis.Variant [lefts right value]) - (#analysis.Variant [lefts right (recur value)]) + {#/.Structure structure} + {#/.Structure (case structure + {#analysis.Variant [lefts right value]} + {#analysis.Variant [lefts right (recur value)]} - (#analysis.Tuple tuple) - (#analysis.Tuple (list\each recur tuple)))) + {#analysis.Tuple tuple} + {#analysis.Tuple (list\each recur tuple)})} - (#/.Reference reference) + {#/.Reference reference} (case reference - (#reference.Variable variable) + {#reference.Variable variable} (/.variable (..remove_local_from_variable redundant variable)) - (#reference.Constant constant) + {#reference.Constant constant} synthesis) - (#/.Control control) - (#/.Control (case control - (#/.Branch branch) - (#/.Branch (case branch - (#/.Let input register output) - (#/.Let (recur input) - (..prune redundant register) - (recur output)) + {#/.Control control} + {#/.Control (case control + {#/.Branch branch} + {#/.Branch (case branch + {#/.Let input register output} + {#/.Let (recur input) + (..prune redundant register) + (recur output)} - (#/.If test then else) - (#/.If (recur test) (recur then) (recur else)) + {#/.If test then else} + {#/.If (recur test) (recur then) (recur else)} - (#/.Get path record) - (#/.Get path (recur record)) + {#/.Get path record} + {#/.Get path (recur record)} - (#/.Case input path) - (#/.Case (recur input) (remove_local_from_path remove_local redundant path)))) + {#/.Case input path} + {#/.Case (recur input) (remove_local_from_path remove_local redundant path)})} - (#/.Loop loop) - (#/.Loop (case loop - (#/.Scope [start inits iteration]) - (#/.Scope [(..prune redundant start) + {#/.Loop loop} + {#/.Loop (case loop + {#/.Scope [start inits iteration]} + {#/.Scope [(..prune redundant start) (list\each recur inits) - (recur iteration)]) + (recur iteration)]} - (#/.Recur resets) - (#/.Recur (list\each recur resets)))) + {#/.Recur resets} + {#/.Recur (list\each recur resets)})} - (#/.Function function) - (#/.Function (case function - (#/.Abstraction [environment arity body]) - (#/.Abstraction [(list\each recur environment) + {#/.Function function} + {#/.Function (case function + {#/.Abstraction [environment arity body]} + {#/.Abstraction [(list\each recur environment) arity - body]) + body]} - (#/.Apply abstraction inputs) - (#/.Apply (recur abstraction) (list\each recur inputs)))))) + {#/.Apply abstraction inputs} + {#/.Apply (recur abstraction) (list\each recur inputs)})})} - (#/.Extension name inputs) - (#/.Extension name (list\each recur inputs))))) + {#/.Extension name inputs} + {#/.Extension name (list\each recur inputs)}))) (type: Redundancy (Dictionary Register Bit)) @@ -198,15 +198,15 @@ (function (recur [redundancy values]) (case values #.End - (#try.Success [redundancy - values]) + {#try.Success [redundancy + values]} - (#.Item head tail) + {#.Item head tail} (do try.monad [[redundancy head] (optimization [redundancy head]) [redundancy tail] (recur [redundancy tail])] (in [redundancy - (#.Item head tail)]))))) + {#.Item head tail}]))))) (template [<name>] [(exception: .public (<name> [register Register]) @@ -221,9 +221,9 @@ (-> Register Redundancy (Try Redundancy)) (case (dictionary.value register redundancy) #.None - (#try.Success (dictionary.has register ..redundant! redundancy)) + {#try.Success (dictionary.has register ..redundant! redundancy)} - (#.Some _) + {#.Some _} (exception.except ..redundant_declaration [register]))) (def: (observe register redundancy) @@ -232,8 +232,8 @@ #.None (exception.except ..unknown_register [register]) - (#.Some _) - (#try.Success (dictionary.has register ..necessary! redundancy)))) + {#.Some _} + {#try.Success (dictionary.has register ..necessary! redundancy)})) (def: (format redundancy) (%.Format Redundancy) @@ -248,26 +248,26 @@ (function (recur [redundancy path]) (case path (^or #/.Pop - (#/.Access _)) - (#try.Success [redundancy - path]) + {#/.Access _}) + {#try.Success [redundancy + path]} - (#/.Bit_Fork when then else) + {#/.Bit_Fork when then else} (do [! try.monad] [[redundancy then] (recur [redundancy then]) [redundancy else] (case else - (#.Some else) + {#.Some else} (\ ! each (function (_ [redundancy else]) - [redundancy (#.Some else)]) + [redundancy {#.Some else}]) (recur [redundancy else])) #.None (in [redundancy #.None]))] - (in [redundancy (#/.Bit_Fork when then else)])) + (in [redundancy {#/.Bit_Fork when then else}])) (^template [<tag> <type>] - [(<tag> [[test then] elses]) + [{<tag> [[test then] elses]} (do [! try.monad] [[redundancy then] (recur [redundancy then]) [redundancy elses] (..list_optimization (: (Optimization [<type> Path]) @@ -276,24 +276,24 @@ [[redundancy else_then] (recur [redundancy else_then])] (in [redundancy [else_test else_then]])))) [redundancy elses])] - (in [redundancy (<tag> [[test then] elses])]))]) + (in [redundancy {<tag> [[test then] elses]}]))]) ([#/.I64_Fork (I64 Any)] [#/.F64_Fork Frac] [#/.Text_Fork Text]) - (#/.Bind register) + {#/.Bind register} (do try.monad [redundancy (..declare register redundancy)] (in [redundancy path])) - (#/.Alt left right) + {#/.Alt left right} (do try.monad [[redundancy left] (recur [redundancy left]) [redundancy right] (recur [redundancy right])] - (in [redundancy (#/.Alt left right)])) + (in [redundancy {#/.Alt left right}])) - (#/.Seq pre post) + {#/.Seq pre post} (do try.monad [.let [baseline (|> redundancy dictionary.keys @@ -313,56 +313,56 @@ (in [(list\mix dictionary.lacks redundancy (set.list bindings)) (|> redundants (list.sorted n.>) - (list\mix (..remove_local_from_path ..remove_local) (#/.Seq pre post)))])) + (list\mix (..remove_local_from_path ..remove_local) {#/.Seq pre post}))])) - (#/.Then then) + {#/.Then then} (do try.monad [[redundancy then] (optimization [redundancy then])] - (in [redundancy (#/.Then then)])) + (in [redundancy {#/.Then then}])) ))) (def: (optimization' [redundancy synthesis]) (Optimization Synthesis) - (with_expansions [<no_op> (as_is (#try.Success [redundancy - synthesis]))] + (with_expansions [<no_op> (as_is {#try.Success [redundancy + synthesis]})] (case synthesis - (#/.Primitive _) + {#/.Primitive _} <no_op> - (#/.Structure structure) + {#/.Structure structure} (case structure - (#analysis.Variant [lefts right value]) + {#analysis.Variant [lefts right value]} (do try.monad [[redundancy value] (optimization' [redundancy value])] (in [redundancy - (#/.Structure (#analysis.Variant [lefts right value]))])) + {#/.Structure {#analysis.Variant [lefts right value]}}])) - (#analysis.Tuple tuple) + {#analysis.Tuple tuple} (do try.monad [[redundancy tuple] (..list_optimization optimization' [redundancy tuple])] (in [redundancy - (#/.Structure (#analysis.Tuple tuple))]))) + {#/.Structure {#analysis.Tuple tuple}}]))) - (#/.Reference reference) + {#/.Reference reference} (case reference - (#reference.Variable variable) + {#reference.Variable variable} (case variable - (#variable.Local register) + {#variable.Local register} (do try.monad [redundancy (..observe register redundancy)] <no_op>) - (#variable.Foreign register) + {#variable.Foreign register} <no_op>) - (#reference.Constant constant) + {#reference.Constant constant} <no_op>) - (#/.Control control) + {#/.Control control} (case control - (#/.Branch branch) + {#/.Branch branch} (case branch - (#/.Let input register output) + {#/.Let input register output} (do try.monad [[redundancy input] (optimization' [redundancy input]) redundancy (..declare register redundancy) @@ -371,70 +371,70 @@ (dictionary.value register) (maybe.else ..necessary!))]] (in [(dictionary.lacks register redundancy) - (#/.Control (if redundant? - (#/.Branch (#/.Case input - (#/.Seq #/.Pop - (#/.Then (..remove_local register output))))) - (#/.Branch (#/.Let input register output))))])) + {#/.Control (if redundant? + {#/.Branch {#/.Case input + {#/.Seq #/.Pop + {#/.Then (..remove_local register output)}}}} + {#/.Branch {#/.Let input register output}})}])) - (#/.If test then else) + {#/.If test then else} (do try.monad [[redundancy test] (optimization' [redundancy test]) [redundancy then] (optimization' [redundancy then]) [redundancy else] (optimization' [redundancy else])] (in [redundancy - (#/.Control (#/.Branch (#/.If test then else)))])) + {#/.Control {#/.Branch {#/.If test then else}}}])) - (#/.Get path record) + {#/.Get path record} (do try.monad [[redundancy record] (optimization' [redundancy record])] (in [redundancy - (#/.Control (#/.Branch (#/.Get path record)))])) + {#/.Control {#/.Branch {#/.Get path record}}}])) - (#/.Case input path) + {#/.Case input path} (do try.monad [[redundancy input] (optimization' [redundancy input]) [redundancy path] (..path_optimization optimization' [redundancy path])] (in [redundancy - (#/.Control (#/.Branch (#/.Case input path)))]))) + {#/.Control {#/.Branch {#/.Case input path}}}]))) - (#/.Loop loop) + {#/.Loop loop} (case loop - (#/.Scope [start inits iteration]) + {#/.Scope [start inits iteration]} (do try.monad [[redundancy inits] (..list_optimization optimization' [redundancy inits]) .let [[extension redundancy] (..extended start (list.size inits) redundancy)] [redundancy iteration] (optimization' [redundancy iteration])] (in [(list\mix dictionary.lacks redundancy extension) - (#/.Control (#/.Loop (#/.Scope [start inits iteration])))])) + {#/.Control {#/.Loop {#/.Scope [start inits iteration]}}}])) - (#/.Recur resets) + {#/.Recur resets} (do try.monad [[redundancy resets] (..list_optimization optimization' [redundancy resets])] (in [redundancy - (#/.Control (#/.Loop (#/.Recur resets)))]))) + {#/.Control {#/.Loop {#/.Recur resets}}}]))) - (#/.Function function) + {#/.Function function} (case function - (#/.Abstraction [environment arity body]) + {#/.Abstraction [environment arity body]} (do [! try.monad] [[redundancy environment] (..list_optimization optimization' [redundancy environment]) [_ body] (optimization' [(..default arity) body])] (in [redundancy - (#/.Control (#/.Function (#/.Abstraction [environment arity body])))])) + {#/.Control {#/.Function {#/.Abstraction [environment arity body]}}}])) - (#/.Apply abstraction inputs) + {#/.Apply abstraction inputs} (do try.monad [[redundancy abstraction] (optimization' [redundancy abstraction]) [redundancy inputs] (..list_optimization optimization' [redundancy inputs])] (in [redundancy - (#/.Control (#/.Function (#/.Apply abstraction inputs)))])))) + {#/.Control {#/.Function {#/.Apply abstraction inputs}}}])))) - (#/.Extension name inputs) + {#/.Extension name inputs} (do try.monad [[redundancy inputs] (..list_optimization optimization' [redundancy inputs])] (in [redundancy - (#/.Extension name inputs)]))))) + {#/.Extension name inputs}]))))) (def: .public optimization (-> Synthesis (Try Synthesis)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux index f085683fc..6b9fbfd09 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux @@ -48,7 +48,7 @@ [program_id (artifact.remember ..name registry)] (in [module_id program_id]))) registries) - (#.Some program_context) + {#.Some program_context} (in program_context) #.None diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux index ec444b003..b855ced2f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -171,12 +171,12 @@ ["Text" (%.text text)])) (template: (!failure parser where offset source_code) - [(#.Left [[where offset source_code] - (exception.error ..unrecognized_input [where (%.name (name_of parser)) source_code offset])])]) + [{#.Left [[where offset source_code] + (exception.error ..unrecognized_input [where (%.name (name_of parser)) source_code offset])]}]) (template: (!end_of_file where offset source_code current_module) - [(#.Left [[where offset source_code] - (exception.error ..end_of_file current_module)])]) + [{#.Left [[where offset source_code] + (exception.error ..end_of_file current_module)]}]) (type: (Parser a) (-> Source (Either [Source Text] [Source a]))) @@ -193,10 +193,10 @@ (template: (!letE <binding> <computation> <body>) [(case <computation> - (#.Right <binding>) + {#.Right <binding>} <body> - ... (#.Left error) + ... {#.Left error} <<otherwise>> (:expected <<otherwise>>))]) @@ -227,14 +227,14 @@ (loop [source (: Source [(!forward 1 where) offset source_code]) stack (: (List Code) #.End)] (case (parse source) - (#.Right [source' top]) - (recur source' (#.Item top stack)) + {#.Right [source' top]} + (recur source' {#.Item top stack}) - (#.Left [source' error]) + {#.Left [source' error]} (if (same? <close> error) - (#.Right [source' - [where (<tag> (list.reversed stack))]]) - (#.Left [source' error])))))] + {#.Right [source' + [where {<tag> (list.reversed stack)}]]} + {#.Left [source' error]}))))] ... Form and tuple syntax is mostly the same, differing only in the ... delimiters involved. @@ -250,15 +250,15 @@ (loop [source (: Source [(!forward 1 where) offset source_code]) stack (: (List [Code Code]) #.End)] (case (parse source) - (#.Right [sourceF field]) + {#.Right [sourceF field]} (!letE [sourceFV value] (parse sourceF) - (recur sourceFV (#.Item [field value] stack))) + (recur sourceFV {#.Item [field value] stack})) - (#.Left [source' error]) + {#.Left [source' error]} (if (same? ..close_variant error) - (#.Right [source' - [where (#.Record (list.reversed stack))]]) - (#.Left [source' error]))))) + {#.Right [source' + [where {#.Record (list.reversed stack)}]]} + {#.Left [source' error]})))) (template: (!guarantee_no_new_lines where offset source_code content body) [(case ("lux text index" 0 (static text.new_line) content) @@ -266,21 +266,21 @@ body g!_ - (#.Left [[where offset source_code] - (exception.error ..text_cannot_contain_new_lines content)]))]) + {#.Left [[where offset source_code] + (exception.error ..text_cannot_contain_new_lines content)]})]) (def: (text_parser where offset source_code) (-> Location Offset Text (Either [Source Text] [Source Code])) (case ("lux text index" offset (static ..text_delimiter) source_code) - (#.Some g!end) + {#.Some g!end} (<| (let [g!content (!clip offset g!end source_code)]) (!guarantee_no_new_lines where offset source_code g!content) - (#.Right [[(let [size (!n/- offset g!end)] + {#.Right [[(let [size (!n/- offset g!end)] (revised@ #.column (|>> (!n/+ size) (!n/+ 2)) where)) (!++ g!end) source_code] [where - (#.Text g!content)]])) + {#.Text g!content}]]}) _ (!failure ..text_parser where offset source_code))) @@ -338,16 +338,16 @@ (!clip <start> <end>) (text.replaced ..digit_separator "") (\ <codec> decoded)) - (#.Right output) - (#.Right [[(let [[where::file where::line where::column] where] + {#.Right output} + {#.Right [[(let [[where::file where::line where::column] where] [where::file where::line (!n/+ (!n/- <start> <end>) where::column)]) <end> <source_code>] - [where (<tag> output)]]) + [where {<tag> output}]]} - (#.Left error) - (#.Left [[where <start> <source_code>] - error]))]) + {#.Left error} + {#.Left [[where <start> <source_code>] + error]})]) (def: no_exponent Offset @@ -423,10 +423,10 @@ (signed_parser source_code//size offset where (!++/2 offset) source_code) (!full_name_parser offset [where (!++ offset) source_code] where @aliases #.Identifier)))]) -(with_expansions [<output> (#.Right [[(revised@ #.column (|>> (!n/+ (!n/- start end))) where) +(with_expansions [<output> {#.Right [[(revised@ #.column (|>> (!n/+ (!n/- start end))) where) end source_code] - (!clip start end source_code)])] + (!clip start end source_code)]}] (inline: (name_part_parser start where offset source_code) (-> Nat Location Offset Text (Either [Source Text] [Source Text])) @@ -440,7 +440,7 @@ (template: (!half_name_parser @offset @char @module) [(!if_name_char?|head @char (!letE [source' name] (..name_part_parser @offset (!forward 1 where) (!++ @offset) source_code) - (#.Right [source' [@module name]])) + {#.Right [source' [@module name]]}) (!failure ..!half_name_parser where @offset source_code))]) (`` (def: (short_name_parser source_code//size current_module [where offset/0 source_code]) @@ -456,9 +456,9 @@ (template: (!short_name_parser source_code//size @current_module @source @where @tag) [(!letE [source' name] (..short_name_parser source_code//size @current_module @source) - (#.Right [source' [@where (@tag name)]]))]) + {#.Right [source' [@where {@tag name}]]})]) -(with_expansions [<simple> (as_is (#.Right [source' ["" simple]]))] +(with_expansions [<simple> (as_is {#.Right [source' ["" simple]]})] (`` (def: (full_name_parser aliases start source) (-> Aliases Offset (Parser Name)) (<| (!letE [source' simple] (let [[where offset source_code] source] @@ -471,15 +471,15 @@ (if ("lux text =" "" complex) (let [[where offset source_code] source] (!failure ..full_name_parser where offset source_code)) - (#.Right [source'' [(|> aliases + {#.Right [source'' [(|> aliases (dictionary.value simple) (maybe.else simple)) - complex]]))) + complex]]})) <simple>))))) (template: (!full_name_parser @offset @source @where @aliases @tag) [(!letE [source' full_name] (..full_name_parser @aliases @offset @source) - (#.Right [source' [@where (@tag full_name)]]))]) + {#.Right [source' [@where {@tag full_name}]]})]) ... TODO: Grammar macro for specifying syntax. ... (grammar: lux_grammar @@ -492,14 +492,14 @@ <recur> (as_is (parse current_module aliases source_code//size))] (template: (!close closer) - [(#.Left [<move_1> closer])]) + [{#.Left [<move_1> closer]}]) (def: (bit_syntax value [where offset/0 source_code]) (-> Bit (Parser Code)) - (#.Right [[(revised@ #.column (|>> !++/2) where) + {#.Right [[(revised@ #.column (|>> !++/2) where) (!++/2 offset/0) source_code] - [where (#.Bit value)]])) + [where {#.Bit value}]]}) (def: .public (parse current_module aliases source_code//size) (-> Text Aliases Nat (Parser Code)) @@ -566,7 +566,7 @@ (with_expansions [<rev_parser> (rev_parser source_code//size offset/0 where (!++ offset/1) source_code) <short_name_parser> (!short_name_parser source_code//size current_module [where offset/1 source_code] where #.Identifier) <comment_parser> (case ("lux text index" (!++ offset/1) (static text.new_line) source_code) - (#.Some end) + {#.Some end} (recur (!vertical where end source_code)) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux index 2209cdcce..e718a2469 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -54,10 +54,10 @@ (type: .public Primitive (Variant - (#Bit Bit) - (#I64 (I64 Any)) - (#F64 Frac) - (#Text Text))) + {#Bit Bit} + {#I64 (I64 Any)} + {#F64 Frac} + {#Text Text})) (type: .public Side (Either Nat Nat)) @@ -67,8 +67,8 @@ (type: .public Access (Variant - (#Side Side) - (#Member Member))) + {#Side Side} + {#Member Member})) (type: .public (Fork value next) [[value next] (List [value next])]) @@ -76,15 +76,15 @@ (type: .public (Path' s) (Variant #Pop - (#Access Access) - (#Bind Register) - (#Bit_Fork Bit (Path' s) (Maybe (Path' s))) - (#I64_Fork (Fork (I64 Any) (Path' s))) - (#F64_Fork (Fork Frac (Path' s))) - (#Text_Fork (Fork Text (Path' s))) - (#Alt (Path' s) (Path' s)) - (#Seq (Path' s) (Path' s)) - (#Then s))) + {#Access Access} + {#Bind Register} + {#Bit_Fork Bit (Path' s) (Maybe (Path' s))} + {#I64_Fork (Fork (I64 Any) (Path' s))} + {#F64_Fork (Fork Frac (Path' s))} + {#Text_Fork (Fork Text (Path' s))} + {#Alt (Path' s) (Path' s)} + {#Seq (Path' s) (Path' s)} + {#Then s})) (type: .public (Abstraction' s) (Record @@ -99,10 +99,10 @@ (type: .public (Branch s) (Variant - (#Let s Register s) - (#If s s s) - (#Get (List Member) s) - (#Case s (Path' s)))) + {#Let s Register s} + {#If s s s} + {#Get (List Member) s} + {#Case s (Path' s)})) (type: .public (Scope s) (Record @@ -112,28 +112,28 @@ (type: .public (Loop s) (Variant - (#Scope (Scope s)) - (#Recur (List s)))) + {#Scope (Scope s)} + {#Recur (List s)})) (type: .public (Function s) (Variant - (#Abstraction (Abstraction' s)) - (#Apply s (List s)))) + {#Abstraction (Abstraction' s)} + {#Apply s (List s)})) (type: .public (Control s) (Variant - (#Branch (Branch s)) - (#Loop (Loop s)) - (#Function (Function s)))) + {#Branch (Branch s)} + {#Loop (Loop s)} + {#Function (Function s)})) (type: .public Synthesis (Rec Synthesis (Variant - (#Primitive Primitive) - (#Structure (Composite Synthesis)) - (#Reference Reference) - (#Control (Control Synthesis)) - (#Extension (Extension Synthesis))))) + {#Primitive Primitive} + {#Structure (Composite Synthesis)} + {#Reference Reference} + {#Control (Control Synthesis)} + {#Extension (Extension Synthesis)}))) (template [<special> <general>] [(type: .public <special> @@ -165,9 +165,9 @@ (template [<name> <kind> <side>] [(template: .public (<name> content) - [(.<| #..Access - <kind> - <side> + [(.<| {#..Access} + {<kind>} + {<side>} content)])] [side/left #..Side #.Left] @@ -178,7 +178,7 @@ (template [<name> <tag>] [(template: .public (<name> content) - [(<tag> content)])] + [{<tag> content}])] [path/bind #..Bind] [path/then #..Then] @@ -186,7 +186,7 @@ (template [<name> <tag>] [(template: .public (<name> left right) - [(<tag> [left right])])] + [{<tag> left right}])] [path/alt #..Alt] [path/seq #..Seq] @@ -223,7 +223,7 @@ (template [<name> <tag>] [(template: .public (<name> content) - [(#..Primitive (<tag> content))])] + [{#..Primitive {<tag> content}}])] [bit #..Bit] [i64 #..I64] @@ -233,8 +233,8 @@ (template [<name> <tag>] [(template: .public (<name> content) - [(<| #..Structure - <tag> + [(<| {#..Structure} + {<tag>} content)])] [variant #analysis.Variant] @@ -243,7 +243,7 @@ (template [<name> <tag>] [(template: .public (<name> content) - [(.<| #..Reference + [(.<| {#..Reference} <tag> content)])] @@ -255,9 +255,9 @@ (template [<name> <family> <tag>] [(template: .public (<name> content) - [(.<| #..Control - <family> - <tag> + [(.<| {#..Control} + {<family>} + {<tag>} content)])] [branch/case #..Branch #..Case] @@ -278,11 +278,11 @@ #Pop "_" - (#Bit_Fork when then else) + {#Bit_Fork when then else} (format "(?" " " (%.bit when) " " (%path' %then then) (case else - (#.Some else) + {#.Some else} (format " " (%.bit (not when)) " " (%path' %then else)) #.None @@ -290,8 +290,8 @@ ")") (^template [<tag> <format>] - [(<tag> item) - (|> (#.Item item) + [{<tag> item} + (|> {#.Item item} (list\each (function (_ [test then]) (format (<format> test) " " (%path' %then then)))) (text.interposed " ") @@ -300,125 +300,125 @@ [#F64_Fork %.frac] [#Text_Fork %.text]) - (#Access access) + {#Access access} (case access - (#Side side) + {#Side side} (case side - (#.Left lefts) + {#.Left lefts} (format "(" (%.nat lefts) " #0" ")") - (#.Right lefts) + {#.Right lefts} (format "(" (%.nat lefts) " #1" ")")) - (#Member member) + {#Member member} (case member - (#.Left lefts) + {#.Left lefts} (format "[" (%.nat lefts) " #0" "]") - (#.Right lefts) + {#.Right lefts} (format "[" (%.nat lefts) " #1" "]"))) - (#Bind register) + {#Bind register} (format "(@ " (%.nat register) ")") - (#Alt left right) + {#Alt left right} (format "(Variant " (%path' %then left) " " (%path' %then right) ")") - (#Seq left right) + {#Seq left right} (format "(Tuple " (%path' %then left) " " (%path' %then right) ")") - (#Then then) + {#Then then} (|> (%then then) (text.enclosed ["(! " ")"])))) (def: .public (%synthesis value) (Format Synthesis) (case value - (#Primitive primitive) + {#Primitive primitive} (case primitive (^template [<pattern> <format>] - [(<pattern> value) + [{<pattern> value} (<format> value)]) ([#Bit %.bit] [#F64 %.frac] [#Text %.text]) - (#I64 value) + {#I64 value} (%.int (.int value))) - (#Structure structure) + {#Structure structure} (case structure - (#analysis.Variant [lefts right? content]) + {#analysis.Variant [lefts right? content]} (|> (%synthesis content) (format (%.nat lefts) " " (%.bit right?) " ") - (text.enclosed ["(" ")"])) + (text.enclosed ["{" "}"])) - (#analysis.Tuple members) + {#analysis.Tuple members} (|> members (list\each %synthesis) (text.interposed " ") (text.enclosed ["[" "]"]))) - (#Reference reference) + {#Reference reference} (reference.format reference) - (#Control control) + {#Control control} (case control - (#Function function) + {#Function function} (case function - (#Abstraction [environment arity body]) + {#Abstraction [environment arity body]} (let [environment' (|> environment (list\each %synthesis) (text.interposed " ") (text.enclosed ["[" "]"]))] (|> (format environment' " " (%.nat arity) " " (%synthesis body)) - (text.enclosed ["(#function " ")"]))) + (text.enclosed ["{#function " "}"]))) - (#Apply func args) + {#Apply func args} (|> args (list\each %synthesis) (text.interposed " ") (format (%synthesis func) " ") (text.enclosed ["(" ")"]))) - (#Branch branch) + {#Branch branch} (case branch - (#Let input register body) + {#Let input register body} (|> (format (%.nat register) " " (%synthesis input) " " (%synthesis body)) - (text.enclosed ["(#let " ")"])) + (text.enclosed ["{#let " "}"])) - (#If test then else) + {#If test then else} (|> (format (%synthesis test) " " (%synthesis then) " " (%synthesis else)) - (text.enclosed ["(#if " ")"])) + (text.enclosed ["{#if " "}"])) - (#Get members record) + {#Get members record} (|> (format (%.list (%path' %synthesis) (list\each (|>> #Member #Access) members)) " " (%synthesis record)) - (text.enclosed ["(#get " ")"])) + (text.enclosed ["{#get " "}"])) - (#Case input path) + {#Case input path} (|> (format (%synthesis input) " " (%path' %synthesis path)) - (text.enclosed ["(#case " ")"]))) + (text.enclosed ["{#case " "}"]))) - (#Loop loop) + {#Loop loop} (case loop - (#Scope scope) + {#Scope scope} (|> (format (%.nat (value@ #start scope)) " " (|> (value@ #inits scope) (list\each %synthesis) (text.interposed " ") (text.enclosed ["[" "]"])) " " (%synthesis (value@ #iteration scope))) - (text.enclosed ["(#loop " ")"])) + (text.enclosed ["{#loop " "}"])) - (#Recur args) + {#Recur args} (|> args (list\each %synthesis) (text.interposed " ") - (text.enclosed ["(#recur " ")"])))) + (text.enclosed ["{#recur " "}"])))) - (#Extension [name args]) + {#Extension [name args]} (|> (list\each %synthesis args) (text.interposed " ") (format (%.text name) " ") @@ -434,13 +434,13 @@ (def: (= reference sample) (case [reference sample] (^template [<tag> <eq> <format>] - [[(<tag> reference') (<tag> sample')] + [[{<tag> reference'} {<tag> sample'}] (<eq> reference' sample')]) ([#Bit bit\= %.bit] [#F64 f.= %.frac] [#Text text\= %.text]) - [(#I64 reference') (#I64 sample')] + [{#I64 reference'} {#I64 sample'}] (i.= (.int reference') (.int sample')) _ @@ -453,7 +453,7 @@ (def: hash (|>> (case> (^template [<tag> <hash>] - [(<tag> value') + [{<tag> value'} (\ <hash> hash value')]) ([#Bit bit.hash] [#F64 f.hash] @@ -478,7 +478,7 @@ (def: (= reference sample) (case [reference sample] (^template [<tag> <equivalence>] - [[(<tag> reference) (<tag> sample)] + [[{<tag> reference} {<tag> sample}] (\ <equivalence> = reference sample)]) ([#Side ..side_equivalence] [#Member ..member_equivalence]) @@ -495,7 +495,7 @@ (let [sub_hash (sum.hash n.hash n.hash)] (case value (^template [<tag>] - [(<tag> value) + [{<tag> value} (\ sub_hash hash value)]) ([#Side] [#Member]))))) @@ -508,33 +508,33 @@ [#Pop #Pop] true - [(#Bit_Fork reference_when reference_then reference_else) - (#Bit_Fork sample_when sample_then sample_else)] + [{#Bit_Fork reference_when reference_then reference_else} + {#Bit_Fork sample_when sample_then sample_else}] (and (bit\= reference_when sample_when) (= reference_then sample_then) (\ (maybe.equivalence =) = reference_else sample_else)) (^template [<tag> <equivalence>] - [[(<tag> reference_item) - (<tag> sample_item)] + [[{<tag> reference_item} + {<tag> sample_item}] (\ (list.equivalence (product.equivalence <equivalence> =)) = - (#.Item reference_item) - (#.Item sample_item))]) + {#.Item reference_item} + {#.Item sample_item})]) ([#I64_Fork i64.equivalence] [#F64_Fork f.equivalence] [#Text_Fork text.equivalence]) (^template [<tag> <equivalence>] - [[(<tag> reference') (<tag> sample')] + [[{<tag> reference'} {<tag> sample'}] (\ <equivalence> = reference' sample')]) ([#Access ..access_equivalence] [#Then equivalence]) - [(#Bind reference') (#Bind sample')] + [{#Bind reference'} {#Bind sample'}] (n.= reference' sample') (^template [<tag>] - [[(<tag> leftR rightR) (<tag> leftS rightS)] + [[{<tag> leftR rightR} {<tag> leftS rightS}] (and (= leftR leftS) (= rightR rightS))]) ([#Alt] @@ -554,20 +554,20 @@ #Pop 2 - (#Access access) + {#Access access} (n.* 3 (\ ..access_hash hash access)) - (#Bind register) + {#Bind register} (n.* 5 (\ n.hash hash register)) - (#Bit_Fork when then else) + {#Bit_Fork when then else} ($_ n.* 7 (\ bit.hash hash when) (hash then) (\ (maybe.hash (path'_hash super)) hash else)) (^template [<factor> <tag> <hash>] - [(<tag> item) + [{<tag> item} (let [case_hash (product.hash <hash> (path'_hash super)) item_hash (product.hash case_hash (list.hash case_hash))] @@ -577,14 +577,14 @@ [17 #Text_Fork text.hash]) (^template [<factor> <tag>] - [(<tag> fork) + [{<tag> fork} (let [recur_hash (path'_hash super) fork_hash (product.hash recur_hash recur_hash)] (n.* <factor> (\ fork_hash hash fork)))]) ([19 #Alt] [23 #Seq]) - (#Then body) + {#Then body} (n.* 29 (\ super hash body)) ))) @@ -593,25 +593,25 @@ (def: (= reference sample) (case [reference sample] - [(#Let [reference_input reference_register reference_body]) - (#Let [sample_input sample_register sample_body])] + [{#Let [reference_input reference_register reference_body]} + {#Let [sample_input sample_register sample_body]}] (and (\= reference_input sample_input) (n.= reference_register sample_register) (\= reference_body sample_body)) - [(#If [reference_test reference_then reference_else]) - (#If [sample_test sample_then sample_else])] + [{#If [reference_test reference_then reference_else]} + {#If [sample_test sample_then sample_else]}] (and (\= reference_test sample_test) (\= reference_then sample_then) (\= reference_else sample_else)) - [(#Get [reference_path reference_record]) - (#Get [sample_path sample_record])] + [{#Get [reference_path reference_record]} + {#Get [sample_path sample_record]}] (and (\ (list.equivalence ..member_equivalence) = reference_path sample_path) (\= reference_record sample_record)) - [(#Case [reference_input reference_path]) - (#Case [sample_input sample_path])] + [{#Case [reference_input reference_path]} + {#Case [sample_input sample_path]}] (and (\= reference_input sample_input) (\ (path'_equivalence \=) = reference_path sample_path)) @@ -626,24 +626,24 @@ (def: (hash value) (case value - (#Let [input register body]) + {#Let [input register body]} ($_ n.* 2 (\ super hash input) (\ n.hash hash register) (\ super hash body)) - (#If [test then else]) + {#If [test then else]} ($_ n.* 3 (\ super hash test) (\ super hash then) (\ super hash else)) - (#Get [path record]) + {#Get [path record]} ($_ n.* 5 (\ (list.hash ..member_hash) hash path) (\ super hash record)) - (#Case [input path]) + {#Case [input path]} ($_ n.* 7 (\ super hash input) (\ (..path'_hash super) hash path)) @@ -654,13 +654,13 @@ (def: (= reference sample) (case [reference sample] - [(#Scope [reference_start reference_inits reference_iteration]) - (#Scope [sample_start sample_inits sample_iteration])] + [{#Scope [reference_start reference_inits reference_iteration]} + {#Scope [sample_start sample_inits sample_iteration]}] (and (n.= reference_start sample_start) (\ (list.equivalence \=) = reference_inits sample_inits) (\= reference_iteration sample_iteration)) - [(#Recur reference) (#Recur sample)] + [{#Recur reference} {#Recur sample}] (\ (list.equivalence \=) = reference sample) _ @@ -674,13 +674,13 @@ (def: (hash value) (case value - (#Scope [start inits iteration]) + {#Scope [start inits iteration]} ($_ n.* 2 (\ n.hash hash start) (\ (list.hash super) hash inits) (\ super hash iteration)) - (#Recur resets) + {#Recur resets} ($_ n.* 3 (\ (list.hash super) hash resets)) ))) @@ -690,14 +690,14 @@ (def: (= reference sample) (case [reference sample] - [(#Abstraction [reference_environment reference_arity reference_body]) - (#Abstraction [sample_environment sample_arity sample_body])] + [{#Abstraction [reference_environment reference_arity reference_body]} + {#Abstraction [sample_environment sample_arity sample_body]}] (and (\ (list.equivalence \=) = reference_environment sample_environment) (n.= reference_arity sample_arity) (\= reference_body sample_body)) - [(#Apply [reference_abstraction reference_arguments]) - (#Apply [sample_abstraction sample_arguments])] + [{#Apply [reference_abstraction reference_arguments]} + {#Apply [sample_abstraction sample_arguments]}] (and (\= reference_abstraction sample_abstraction) (\ (list.equivalence \=) = reference_arguments sample_arguments)) @@ -712,13 +712,13 @@ (def: (hash value) (case value - (#Abstraction [environment arity body]) + {#Abstraction [environment arity body]} ($_ n.* 2 (\ (list.hash super) hash environment) (\ n.hash hash arity) (\ super hash body)) - (#Apply [abstraction arguments]) + {#Apply [abstraction arguments]} ($_ n.* 3 (\ super hash abstraction) (\ (list.hash super) hash arguments)) @@ -730,7 +730,7 @@ (def: (= reference sample) (case [reference sample] (^template [<tag> <equivalence>] - [[(<tag> reference) (<tag> sample)] + [[{<tag> reference} {<tag> sample}] (\ (<equivalence> \=) = reference sample)]) ([#Branch ..branch_equivalence] [#Loop ..loop_equivalence] @@ -748,7 +748,7 @@ (def: (hash value) (case value (^template [<factor> <tag> <hash>] - [(<tag> value) + [{<tag> value} (n.* <factor> (\ (<hash> super) hash value))]) ([2 #Branch ..branch_hash] [3 #Loop ..loop_hash] @@ -761,7 +761,7 @@ (def: (= reference sample) (case [reference sample] (^template [<tag> <equivalence>] - [[(<tag> reference') (<tag> sample')] + [[{<tag> reference'} {<tag> sample'}] (\ <equivalence> = reference' sample')]) ([#Primitive ..primitive_equivalence] [#Structure (analysis.composite_equivalence =)] @@ -785,7 +785,7 @@ (let [recur_hash [..equivalence hash]] (case value (^template [<tag> <hash>] - [(<tag> value) + [{<tag> value} (\ <hash> hash value)]) ([#Primitive ..primitive_hash] [#Structure (analysis.composite_hash recur_hash)] @@ -795,14 +795,14 @@ (template: .public (!bind_top register thenP) [($_ ..path/seq - (#..Bind register) - #..Pop + {#..Bind register} + {#..Pop} thenP)]) (template: .public (!multi_pop nextP) [($_ ..path/seq - #..Pop - #..Pop + {#..Pop} + {#..Pop} nextP)]) ... TODO: There are sister patterns to the simple side checks for tuples. diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index d7d2fe237..83bbc51e9 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -92,8 +92,8 @@ (-> Module Archive (Try ID)) (let [(^slots [#..resolver]) (:representation archive)] (case (dictionary.value module resolver) - (#.Some [id _]) - (#try.Success id) + {#.Some [id _]} + {#try.Success id} #.None (exception.except ..unknown_document [module @@ -103,31 +103,31 @@ (-> Module Archive (Try [ID Archive])) (let [(^slots [#..next #..resolver]) (:representation archive)] (case (dictionary.value module resolver) - (#.Some _) + {#.Some _} (exception.except ..module_has_already_been_reserved [module]) #.None - (#try.Success [next + {#try.Success [next (|> archive :representation (revised@ #..resolver (dictionary.has module [next #.None])) (revised@ #..next ++) - :abstraction)])))) + :abstraction)]}))) (def: .public (has module [descriptor document output] archive) (-> Module [Descriptor (Document Any) Output] Archive (Try Archive)) (let [(^slots [#..resolver]) (:representation archive)] (case (dictionary.value module resolver) - (#.Some [id #.None]) - (#try.Success (|> archive + {#.Some [id #.None]} + {#try.Success (|> archive :representation - (revised@ #..resolver (dictionary.has module [id (#.Some [descriptor document output])])) - :abstraction)) + (revised@ #..resolver (dictionary.has module [id {#.Some [descriptor document output]}])) + :abstraction)} - (#.Some [id (#.Some [existing_descriptor existing_document existing_output])]) + {#.Some [id {#.Some [existing_descriptor existing_document existing_output]}]} (if (same? document existing_document) ... TODO: Find out why this code allows for the same module to be added more than once. It looks fishy... - (#try.Success archive) + {#try.Success archive} (exception.except ..cannot_replace_document [module existing_document document])) #.None @@ -137,10 +137,10 @@ (-> Module Archive (Try [Descriptor (Document Any) Output])) (let [(^slots [#..resolver]) (:representation archive)] (case (dictionary.value module resolver) - (#.Some [id (#.Some entry)]) - (#try.Success entry) + {#.Some [id {#.Some entry}]} + {#try.Success entry} - (#.Some [id #.None]) + {#.Some [id #.None]} (exception.except ..module_is_only_reserved [module]) #.None @@ -150,10 +150,10 @@ (def: .public (archived? archive module) (-> Archive Module Bit) (case (..find module archive) - (#try.Success _) + {#try.Success _} bit.yes - (#try.Failure _) + {#try.Failure _} bit.no)) (def: .public archived @@ -163,14 +163,14 @@ dictionary.entries (list.all (function (_ [module [id descriptor+document]]) (case descriptor+document - (#.Some _) (#.Some module) + {#.Some _} {#.Some module} #.None #.None))))) (def: .public (reserved? archive module) (-> Archive Module Bit) (let [(^slots [#..resolver]) (:representation archive)] (case (dictionary.value module resolver) - (#.Some [id _]) + {#.Some [id _]} bit.yes #.None @@ -199,7 +199,7 @@ (revised@ #resolver (function (_ resolver) (list\mix (function (_ [module [id entry]] resolver) (case entry - (#.Some _) + {#.Some _} (dictionary.has module [id entry] resolver) #.None @@ -235,7 +235,7 @@ dictionary.entries (list.all (function (_ [module [id descriptor+document]]) (case descriptor+document - (#.Some _) (#.Some [module id]) + {#.Some _} {#.Some [module id]} #.None #.None))) [version next] (binary.result ..writer)))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux index a9851c301..6c2662602 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux @@ -27,12 +27,12 @@ (type: .public Category (Variant #Anonymous - (#Definition Text) - (#Analyser Text) - (#Synthesizer Text) - (#Generator Text) - (#Directive Text) - (#Custom Text))) + {#Definition Text} + {#Analyser Text} + {#Synthesizer Text} + {#Generator Text} + {#Directive Text} + {#Custom Text})) (type: .public Artifact (Record @@ -75,7 +75,7 @@ (|> registry :representation (revised@ #artifacts (row.suffix [#id id - #category (<tag> name)])) + #category {<tag> name}])) (revised@ #resolver (dictionary.has name id)) :abstraction)])) @@ -86,7 +86,7 @@ (value@ #artifacts) row.list (list.all (|>> (value@ #category) - (case> (<tag> name) (#.Some name) + (case> {<tag> name} {#.Some name} _ #.None)))))] [#Definition definition definitions] @@ -109,7 +109,7 @@ (function (_ value) (case value (^template [<nat> <tag> <writer>] - [(<tag> value) ((binary.and binary.nat <writer>) [<nat> value])]) + [{<tag> value} ((binary.and binary.nat <writer>) [<nat> value])]) ([0 #Anonymous binary.any] [1 #Definition binary.text] [2 #Analyser binary.text] @@ -135,7 +135,7 @@ [tag <binary>.nat] (case tag (^template [<nat> <tag> <parser>] - [<nat> (\ ! each (|>> <tag>) <parser>)]) + [<nat> (\ ! each (|>> {<tag>}) <parser>)]) ([0 #Anonymous <binary>.any] [1 #Definition <binary>.text] [2 #Analyser <binary>.text] @@ -153,7 +153,7 @@ (..resource registry) (^template [<tag> <create>] - [(<tag> name) + [{<tag> name} (<create> name registry)]) ([#Definition ..definition] [#Analyser ..analyser] diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux index 3fcf381d3..96d5a9922 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux @@ -37,12 +37,12 @@ (if (\ signature.equivalence = (key.signature key) document//signature) - (#try.Success (:sharing [e] + {#try.Success (:sharing [e] (Key e) key e - (:expected document//content))) + (:expected document//content))} (exception.except ..invalid_signature [(key.signature key) document//signature])))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux index e839651e4..f586c398a 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux @@ -57,10 +57,10 @@ (function (_ recur module) (do [! state.monad] [.let [parents (case (archive.find module archive) - (#try.Success [descriptor document]) + {#try.Success [descriptor document]} (value@ #descriptor.references descriptor) - (#try.Failure error) + {#try.Failure error} ..fresh)] ancestors (monad.each ! recur (set.list parents))] (in (list\mix set.union parents ancestors))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux index 1d7baccbd..fe1e8d223 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -95,7 +95,7 @@ (do async.monad [? (\ fs directory? path)] (if ? - (in (#try.Success [])) + (in {#try.Success []}) (\ fs make_directory path)))) (def: .public (prepare fs static module_id) @@ -104,16 +104,16 @@ [.let [module (..module fs static module_id)] module_exists? (\ fs directory? module)] (if module_exists? - (in (#try.Success [])) + (in {#try.Success []}) (do (try.with !) [_ (ensure_directory fs (..unversioned_lux_archive fs static)) _ (ensure_directory fs (..versioned_lux_archive fs static))] (|> module (\ fs make_directory) - (\ ! each (|>> (case> (#try.Success output) - (#try.Success []) + (\ ! each (|>> (case> {#try.Success output} + {#try.Success []} - (#try.Failure error) + {#try.Failure error} (exception.except ..cannot_prepare [(..archive fs static) module_id error]))))))))) @@ -223,7 +223,7 @@ output (: Output row.empty)] (let [[analysers synthesizers generators directives] bundles] (case input - (#.Item [[artifact_id artifact_category] input']) + {#.Item [[artifact_id artifact_category] input']} (case (do ! [data (try.of_maybe (dictionary.value (format (%.nat artifact_id) extension) actual)) .let [context [module_id artifact_id] @@ -240,7 +240,7 @@ directives] output])) - (#artifact.Definition name) + {#artifact.Definition name} (let [output (row.suffix [artifact_id #.None data] output)] (if (text\= $/program.name name) (in [definitions @@ -258,7 +258,7 @@ directives] output])))) - (#artifact.Analyser extension) + {#artifact.Analyser extension} (do ! [.let [output (row.suffix [artifact_id #.None data] output)] value (\ host re_load context #.None directive)] @@ -269,7 +269,7 @@ directives] output])) - (#artifact.Synthesizer extension) + {#artifact.Synthesizer extension} (do ! [.let [output (row.suffix [artifact_id #.None data] output)] value (\ host re_load context #.None directive)] @@ -280,7 +280,7 @@ directives] output])) - (#artifact.Generator extension) + {#artifact.Generator extension} (do ! [.let [output (row.suffix [artifact_id #.None data] output)] value (\ host re_load context #.None directive)] @@ -291,7 +291,7 @@ directives] output])) - (#artifact.Directive extension) + {#artifact.Directive extension} (do ! [.let [output (row.suffix [artifact_id #.None data] output)] value (\ host re_load context #.None directive)] @@ -302,48 +302,48 @@ (dictionary.has extension (:as directive.Handler value) directives)] output])) - (#artifact.Custom name) + {#artifact.Custom name} (do ! - [.let [output (row.suffix [artifact_id (#.Some name) data] output)] - _ (\ host re_learn context (#.Some name) directive)] + [.let [output (row.suffix [artifact_id {#.Some name} data] output)] + _ (\ host re_learn context {#.Some name} directive)] (in [definitions [analysers synthesizers generators directives] output])))) - (#try.Success [definitions' bundles' output']) + {#try.Success [definitions' bundles' output']} (recur input' definitions' bundles' output') failure failure) #.End - (#try.Success [definitions bundles output]))))) + {#try.Success [definitions bundles output]})))) content (document.read $.key document) definitions (monad.each ! (function (_ [def_name def_global]) (case def_global (^template [<tag>] - [(<tag> payload) - (in [def_name (<tag> payload)])]) + [{<tag> payload} + (in [def_name {<tag> payload}])]) ([#.Alias] [#.Label] [#.Slot]) - (#.Definition [exported? type _]) + {#.Definition [exported? type _]} (|> definitions (dictionary.value def_name) try.of_maybe (\ ! each (|>> [exported? type] - #.Definition + {#.Definition} [def_name]))) - (#.Type [exported? _ labels]) + {#.Type [exported? _ labels]} (|> definitions (dictionary.value def_name) try.of_maybe (\ ! each (function (_ def_value) - [def_name (#.Type [exported? (:as .Type def_value) labels])]))))) + [def_name {#.Type [exported? (:as .Type def_value) labels]}]))))) (value@ #.definitions content))] (in [(document.write $.key (with@ #.definitions definitions content)) bundles]))) @@ -388,7 +388,7 @@ (|>> (list.all (function (_ [valid_cache? [module_name [module_id _]]]) (if valid_cache? #.None - (#.Some [module_name module_id])))) + {#.Some [module_name module_id]}))) (dictionary.of_list text.hash))) (def: (full_purge caches load_order) @@ -477,12 +477,12 @@ (do async.monad [binary (\ fs read (..general_descriptor fs static))] (case binary - (#try.Success binary) + {#try.Success binary} (do (try.with async.monad) [archive (async\in (archive.import ///.version binary))] (..load_every_reserved_module host_environment fs static import contexts archive)) - (#try.Failure error) - (in (#try.Success [archive.empty + {#try.Failure error} + (in {#try.Success [archive.empty (fresh_analysis_state (value@ #static.host static)) - ..empty_bundles]))))) + ..empty_bundles]})))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux index af43ef991..69a0858e6 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux @@ -61,12 +61,12 @@ #.End (async\in (exception.except ..cannot_find_module [importer module])) - (#.Item context contexts') + {#.Item context contexts'} (let [path (format (..path fs context module) extension)] (do async.monad [? (\ fs file? path)] (if ? - (in (#try.Success path)) + (in {#try.Success path}) (find_source_file fs importer contexts' module extension)))))) (def: (full_host_extension partial_host_extension) @@ -81,12 +81,12 @@ (do [! async.monad] [outcome (..find_source_file fs importer contexts module (..full_host_extension partial_host_extension))] (case outcome - (#try.Success path) + {#try.Success path} (|> path (\ fs read) (\ (try.with !) each (|>> [path]))) - (#try.Failure _) + {#try.Failure _} (do [! (try.with !)] [path (..find_source_file fs importer contexts module ..lux_extension)] (|> path @@ -97,14 +97,14 @@ (-> Module Import Extension Module (Try [file.Path Binary])) (let [path (format module (..full_host_extension partial_host_extension))] (case (dictionary.value path import) - (#.Some data) - (#try.Success [path data]) + {#.Some data} + {#try.Success [path data]} #.None (let [path (format module ..lux_extension)] (case (dictionary.value path import) - (#.Some data) - (#try.Success [path data]) + {#.Some data} + {#try.Success [path data]} #.None (exception.except ..cannot_find_module [importer module])))))) @@ -117,10 +117,10 @@ (do [! async.monad] [outcome (find_local_source_file fs importer import contexts partial_host_extension module)] (case outcome - (#try.Success [path data]) + {#try.Success [path data]} (in outcome) - (#try.Failure _) + {#try.Failure _} (in (..find_library_source_file importer import partial_host_extension module))))) (def: .public (read fs importer import contexts partial_host_extension module) @@ -129,13 +129,13 @@ (do (try.with async.monad) [[path binary] (..find_any_source_file fs importer import contexts partial_host_extension module)] (case (\ utf8.codec decoded binary) - (#try.Success code) + {#try.Success code} (in [#////.module module #////.file path #////.hash (text\hash code) #////.code code]) - (#try.Failure _) + {#try.Failure _} (async\in (exception.except ..cannot_read_module [module]))))) (type: .public Enumeration diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux index f8bb67b70..75eca1c30 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -208,29 +208,29 @@ duplicates duplicates sink sink] (case (java/util/jar/JarInputStream::getNextJarEntry input) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success ?entry) + {#try.Success ?entry} (case ?entry #.None (exec (java/io/Closeable::close input) - (#try.Success [entries duplicates sink])) + {#try.Success [entries duplicates sink]}) - (#.Some entry) + {#.Some entry} (let [entry_path (java/util/zip/ZipEntry::getName entry) entry_size (java/util/zip/ZipEntry::getSize entry)] (if (not (or (java/util/zip/ZipEntry::isDirectory entry) (text.starts_with? "META-INF/maven/" entry_path) (text.starts_with? "META-INF/leiningen/" entry_path))) (case (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new entry_path) sink) - (#try.Failure error) + {#try.Failure error} (recur entries (set.has entry_path duplicates) sink) - (#try.Success _) + {#try.Success _} (let [[entry_size entry_data] (read_jar_entry entry input)] (recur (set.has entry_path entries) duplicates diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux index b471a30f5..c78d07b6f 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux @@ -114,7 +114,7 @@ (\ encoding.utf8 encoded) tar.content)) module_file (tar.path (..module_file module_id))] - (in (#tar.Normal [module_file now ..mode ..ownership entry_content])))) + (in {#tar.Normal [module_file now ..mode ..ownership entry_content]}))) (def: .public (package now) (-> Instant Packager) diff --git a/stdlib/source/library/lux/tool/compiler/phase.lux b/stdlib/source/library/lux/tool/compiler/phase.lux index 3f6caddbf..4809e8ed9 100644 --- a/stdlib/source/library/lux/tool/compiler/phase.lux +++ b/stdlib/source/library/lux/tool/compiler/phase.lux @@ -53,13 +53,13 @@ (All (_ s o) (Operation s s)) (function (_ state) - (#try.Success [state state]))) + {#try.Success [state state]})) (def: .public (set_state state) (All (_ s o) (-> s (Operation s Any))) (function (_ _) - (#try.Success [state []]))) + {#try.Success [state []]})) (def: .public (sub [get set] operation) (All (_ s s' o) @@ -94,7 +94,7 @@ (def: .public identity (All (_ s a) (Phase s a a)) (function (_ archive input state) - (#try.Success [state input]))) + {#try.Success [state input]})) (def: .public (composite pre post) (All (_ s0 s1 i t o) diff --git a/stdlib/source/library/lux/tool/compiler/reference.lux b/stdlib/source/library/lux/tool/compiler/reference.lux index 4e48f1db9..0f345a12f 100644 --- a/stdlib/source/library/lux/tool/compiler/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/reference.lux @@ -21,8 +21,8 @@ (type: .public Reference (Variant - (#Variable Variable) - (#Constant Constant))) + {#Variable Variable} + {#Constant Constant})) (implementation: .public equivalence (Equivalence Reference) @@ -30,7 +30,7 @@ (def: (= reference sample) (case [reference sample] (^template [<tag> <equivalence>] - [[(<tag> reference) (<tag> sample)] + [[{<tag> reference} {<tag> sample}] (\ <equivalence> = reference sample)]) ([#Variable /variable.equivalence] [#Constant name.equivalence]) @@ -47,7 +47,7 @@ (def: (hash value) (case value (^template [<factor> <tag> <hash>] - [(<tag> value) + [{<tag> value} ($_ n.* <factor> (\ <hash> hash value))]) ([2 #Variable /variable.hash] @@ -57,7 +57,7 @@ (template [<name> <family> <tag>] [(template: .public (<name> content) [(<| <family> - <tag> + {<tag>} content)])] [local #..Variable #/variable.Local] @@ -66,7 +66,7 @@ (template [<name> <tag>] [(template: .public (<name> content) - [(<| <tag> + [(<| {<tag>} content)])] [variable #..Variable] @@ -79,8 +79,8 @@ (def: .public format (Format Reference) - (|>> (case> (#Variable variable) + (|>> (case> {#Variable variable} (/variable.format variable) - (#Constant constant) + {#Constant constant} (%.name constant)))) diff --git a/stdlib/source/library/lux/tool/compiler/reference/variable.lux b/stdlib/source/library/lux/tool/compiler/reference/variable.lux index eea52b976..bde1de15b 100644 --- a/stdlib/source/library/lux/tool/compiler/reference/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/reference/variable.lux @@ -19,8 +19,8 @@ (type: .public Variable (Variant - (#Local Register) - (#Foreign Register))) + {#Local Register} + {#Foreign Register})) (implementation: .public equivalence (Equivalence Variable) @@ -28,7 +28,7 @@ (def: (= reference sample) (case [reference sample] (^template [<tag>] - [[(<tag> reference') (<tag> sample')] + [[{<tag> reference'} {<tag> sample'}] (n.= reference' sample')]) ([#Local] [#Foreign]) @@ -43,14 +43,14 @@ (def: hash (|>> (case> (^template [<factor> <tag>] - [(<tag> register) + [{<tag> register} ($_ n.* <factor> (\ n.hash hash register))]) ([2 #Local] [3 #Foreign]))))) (template: .public (self) - [(#..Local 0)]) + [{#..Local 0}]) (def: .public self? (-> Variable Bit) @@ -62,8 +62,8 @@ (def: .public format (Format Variable) - (|>> (case> (#Local local) + (|>> (case> {#Local local} (%.format "+" (%.nat local)) - (#Foreign foreign) + {#Foreign foreign} (%.format "-" (%.nat foreign))))) diff --git a/stdlib/source/library/lux/tool/interpreter.lux b/stdlib/source/library/lux/tool/interpreter.lux index 79c8073f3..85020815f 100644 --- a/stdlib/source/library/lux/tool/interpreter.lux +++ b/stdlib/source/library/lux/tool/interpreter.lux @@ -135,10 +135,10 @@ <Interpretation> (interpret_directive code))) - (#try.Success [state' output]) - (#try.Success [state' output]) + {#try.Success [state' output]} + {#try.Success [state' output]} - (#try.Failure error) + {#try.Failure error} (if (ex.match? total.not_a_directive error) (<| (phase.result' state) (:sharing [anchor expression directive] @@ -147,7 +147,7 @@ <Interpretation> (interpret_expression code))) - (#try.Failure error))))) + {#try.Failure error})))) ) (def: (execute configuration code) @@ -218,12 +218,12 @@ (text\= ..exit_command line)) (\ Console<!> write ..farewell_message) (case (read_eval_print (revised@ #source (add_line line) context)) - (#try.Success [context' representation]) + {#try.Success [context' representation]} (do ! [_ (\ Console<!> write representation)] (recur context' #0)) - (#try.Failure error) + {#try.Failure error} (if (ex.match? syntax.end_of_file error) (recur context #1) (exec (log! (ex.error ..error error)) diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index 7c347bd0e..c99823da1 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -33,7 +33,7 @@ (loop [num_args 0 type type] (case type - (<tag> env sub_type) + {<tag> env sub_type} (recur (++ num_args) sub_type) _ @@ -46,7 +46,7 @@ (def: .public (flat_function type) (-> Type [(List Type) Type]) (case type - (#.Function in out') + {#.Function in out'} (let [[ins out] (flat_function out')] [(list& in ins) out]) @@ -56,7 +56,7 @@ (def: .public (flat_application type) (-> Type [Type (List Type)]) (case type - (#.Apply arg func') + {#.Apply arg func'} (let [[func args] (flat_application func')] [func (list\composite args (list arg))]) @@ -67,7 +67,7 @@ [(def: .public (<name> type) (-> Type (List Type)) (case type - (<tag> left right) + {<tag> left right} (list& left (<name> right)) _ @@ -80,7 +80,7 @@ (def: .public (format type) (-> Type Text) (case type - (#.Primitive name params) + {#.Primitive name params} ($_ text\composite "(primitive " (text.enclosed' text.double_quote name) @@ -90,7 +90,7 @@ ")") (^template [<tag> <open> <close> <flat>] - [(<tag> _) + [{<tag> _} ($_ text\composite <open> (|> (<flat> type) (list\each format) @@ -101,7 +101,7 @@ ([#.Sum "(Or " ")" flat_variant] [#.Product "[" "]" flat_tuple]) - (#.Function input output) + {#.Function input output} (let [[ins out] (flat_function type)] ($_ text\composite "(-> " (|> ins @@ -111,26 +111,26 @@ (list\mix text\composite "")) " " (format out) ")")) - (#.Parameter idx) + {#.Parameter idx} (n\encoded idx) - (#.Var id) + {#.Var id} ($_ text\composite "⌈v:" (n\encoded id) "⌋") - (#.Ex id) + {#.Ex id} ($_ text\composite "⟨e:" (n\encoded id) "⟩") - (#.Apply param fun) + {#.Apply param fun} (let [[type_func type_args] (flat_application type)] ($_ text\composite "(" (format type_func) " " (|> type_args (list\each format) list.reversed (list.interposed " ") (list\mix text\composite "")) ")")) (^template [<tag> <desc>] - [(<tag> env body) + [{<tag> env body} ($_ text\composite "(" <desc> " {" (|> env (list\each format) (text.interposed " ")) "} " (format body) ")")]) ([#.UnivQ "All"] [#.ExQ "Ex"]) - (#.Named [module name] type) + {#.Named [module name] type} ($_ text\composite module "." name) )) @@ -138,27 +138,27 @@ (def: (reduced env type) (-> (List Type) Type Type) (case type - (#.Primitive name params) - (#.Primitive name (list\each (reduced env) params)) + {#.Primitive name params} + {#.Primitive name (list\each (reduced env) params)} (^template [<tag>] - [(<tag> left right) - (<tag> (reduced env left) (reduced env right))]) + [{<tag> left right} + {<tag> (reduced env left) (reduced env right)}]) ([#.Sum] [#.Product] [#.Function] [#.Apply]) (^template [<tag>] - [(<tag> old_env def) + [{<tag> old_env def} (case old_env #.End - (<tag> env def) + {<tag> env def} _ - (<tag> (list\each (reduced env) old_env) def))]) + {<tag> (list\each (reduced env) old_env) def})]) ([#.UnivQ] [#.ExQ]) - (#.Parameter idx) + {#.Parameter idx} (maybe.else (panic! ($_ text\composite "Unknown type parameter" text.new_line " Index: " (n\encoded idx) text.new_line @@ -183,7 +183,7 @@ @.php false] (same? x y)) (case [x y] - [(#.Primitive xname xparams) (#.Primitive yname yparams)] + [{#.Primitive xname xparams} {#.Primitive yname yparams}] (and (text\= xname yname) (n.= (list.size yparams) (list.size xparams)) (list\mix (.function (_ [x y] prev) (and prev (= x y))) @@ -191,26 +191,26 @@ (list.zipped/2 xparams yparams))) (^template [<tag>] - [[(<tag> xid) (<tag> yid)] + [[{<tag> xid} {<tag> yid}] (n.= yid xid)]) ([#.Var] [#.Ex] [#.Parameter]) - (^or [(#.Function xleft xright) (#.Function yleft yright)] - [(#.Apply xleft xright) (#.Apply yleft yright)]) + (^or [{#.Function xleft xright} {#.Function yleft yright}] + [{#.Apply xleft xright} {#.Apply yleft yright}]) (and (= xleft yleft) (= xright yright)) - [(#.Named xname xtype) (#.Named yname ytype)] + [{#.Named xname xtype} {#.Named yname ytype}] (and (name\= xname yname) (= xtype ytype)) (^template [<tag>] - [[(<tag> xL xR) (<tag> yL yR)] + [[{<tag> xL xR} {<tag> yL yR}] (and (= xL yL) (= xR yR))]) ([#.Sum] [#.Product]) - (^or [(#.UnivQ xenv xbody) (#.UnivQ yenv ybody)] - [(#.ExQ xenv xbody) (#.ExQ yenv ybody)]) + (^or [{#.UnivQ xenv xbody} {#.UnivQ yenv ybody}] + [{#.ExQ xenv xbody} {#.ExQ yenv ybody}]) (and (n.= (list.size yenv) (list.size xenv)) (= xbody ybody) (list\mix (.function (_ [x y] prev) (and prev (= x y))) @@ -225,21 +225,21 @@ (-> (List Type) Type (Maybe Type)) (case params #.End - (#.Some func) + {#.Some func} - (#.Item param params') + {#.Item param params'} (case func (^template [<tag>] - [(<tag> env body) + [{<tag> env body} (|> body (reduced (list& func param env)) (applied params'))]) ([#.UnivQ] [#.ExQ]) - (#.Apply A F) + {#.Apply A F} (applied (list& A params) F) - (#.Named name unnamed) + {#.Named name unnamed} (applied params unnamed) _ @@ -248,36 +248,36 @@ (def: .public (code type) (-> Type Code) (case type - (#.Primitive name params) - (` (#.Primitive (~ (code.text name)) - (.list (~+ (list\each code params))))) + {#.Primitive name params} + (` {#.Primitive (~ (code.text name)) + (.list (~+ (list\each code params)))}) (^template [<tag>] - [(<tag> idx) - (` (<tag> (~ (code.nat idx))))]) + [{<tag> idx} + (` {<tag> (~ (code.nat idx))})]) ([#.Var] [#.Ex] [#.Parameter]) (^template [<tag>] - [(<tag> left right) - (` (<tag> (~ (code left)) - (~ (code right))))]) + [{<tag> left right} + (` {<tag> (~ (code left)) + (~ (code right))})]) ([#.Sum] [#.Product] [#.Function] [#.Apply]) - (#.Named name sub_type) + {#.Named name sub_type} (code.identifier name) (^template [<tag>] - [(<tag> env body) - (` (<tag> (.list (~+ (list\each code env))) - (~ (code body))))]) + [{<tag> env body} + (` {<tag> (.list (~+ (list\each code env))) + (~ (code body))})]) ([#.UnivQ] [#.ExQ]) )) (def: .public (de_aliased type) (-> Type Type) (case type - (#.Named _ (#.Named name type')) - (de_aliased (#.Named name type')) + {#.Named _ {#.Named name type'}} + (de_aliased {#.Named name type'}) _ type)) @@ -285,7 +285,7 @@ (def: .public (anonymous type) (-> Type Type) (case type - (#.Named name type') + {#.Named name type'} (anonymous type') _ @@ -298,11 +298,11 @@ #.End <base> - (#.Item type #.End) + {#.Item type #.End} type - (#.Item type types') - (<ctor> type (<name> types'))))] + {#.Item type types'} + {<ctor> type (<name> types')}))] [variant Nothing #.Sum] [tuple Any #.Product] @@ -314,8 +314,8 @@ #.End output - (#.Item input inputs') - (#.Function input (function inputs' output)))) + {#.Item input inputs'} + {#.Function input (function inputs' output)})) (def: .public (application params quant) (-> (List Type) Type Type) @@ -323,15 +323,15 @@ #.End quant - (#.Item param params') - (application params' (#.Apply param quant)))) + {#.Item param params'} + (application params' {#.Apply param quant}))) (template [<name> <tag>] [(def: .public (<name> size body) (-> Nat Type Type) (case size 0 body - _ (|> body (<name> (-- size)) (<tag> (list)))))] + _ (|> body (<name> (-- size)) {<tag> (list)})))] [univ_q #.UnivQ] [ex_q #.ExQ] @@ -340,15 +340,15 @@ (def: .public (quantified? type) (-> Type Bit) (case type - (#.Named [module name] _type) + {#.Named [module name] _type} (quantified? _type) - (#.Apply A F) + {#.Apply A F} (|> (..applied (list A) F) (\ maybe.monad each quantified?) (maybe.else #0)) - (^or (#.UnivQ _) (#.ExQ _)) + (^or {#.UnivQ _} {#.ExQ _}) #1 _ @@ -361,12 +361,12 @@ _ (|> element_type (array (-- depth)) (list) - (#.Primitive array.type_name)))) + {#.Primitive array.type_name}))) (def: .public (flat_array type) (-> Type [Nat Type]) (case type - (^multi (^ (#.Primitive name (list element_type))) + (^multi (^ {#.Primitive name (list element_type)}) (text\= array.type_name name)) (let [[depth element_type] (flat_array element_type)] [(++ depth) element_type]) @@ -391,7 +391,7 @@ (<>.maybe (<>.after (<code>.identifier! ..secret_marker) <code>.any))) <code>.any)]) (case input - (#.Left [valueN valueC]) + {#.Left [valueN valueC]} (do meta.monad [location meta.location valueT (meta.type valueN) @@ -399,7 +399,7 @@ ($_ text\composite (name\encoded (name_of ..:log!)) " " (location.format location) text.new_line "Expression: " (case valueC - (#.Some valueC) + {#.Some valueC} (code.format valueC) #.None @@ -408,7 +408,7 @@ " Type: " (..format valueT)))]] (in (list (code.identifier valueN)))) - (#.Right valueC) + {#.Right valueC} (macro.with_identifiers [g!value] (in (list (` (.let [(~ g!value) (~ valueC)] (..:log! (~ valueC) (~ (code.identifier ..secret_marker)) (~ g!value))))))))) @@ -429,7 +429,7 @@ #.None (in (list casterC)) - (#.Some value) + {#.Some value} (in (list (` ((~ casterC) (~ value))))))))) (type: Typed diff --git a/stdlib/source/library/lux/type/abstract.lux b/stdlib/source/library/lux/type/abstract.lux index 9a9e1d473..d3a6b5c35 100644 --- a/stdlib/source/library/lux/type/abstract.lux +++ b/stdlib/source/library/lux/type/abstract.lux @@ -28,7 +28,7 @@ (def: (push value stack) (All (_ a) (-> a (Stack a) (Stack a))) - (#.Item value stack)) + {#.Item value stack}) (def: pop (All (_ a) (-> (Stack a) (Maybe (Stack a)))) @@ -48,7 +48,7 @@ (template: (!peek <source> <reference> <then>) [(loop [entries <source>] (case entries - (#.Item [head_name head] tail) + {#.Item [head_name head] tail} (if (text\= <reference> head_name) <then> (recur tail)) @@ -60,13 +60,13 @@ (-> Text (List [Text Global]) (Stack Frame)) (!peek source reference (case head - (#.Definition [exported? frame_type frame_value]) + {#.Definition [exported? frame_type frame_value]} (:as (Stack Frame) frame_value) - (^or (#.Type _) - (#.Alias _) - (#.Label _) - (#.Slot _)) + (^or {#.Type _} + {#.Alias _} + {#.Label _} + {#.Slot _}) (undefined)))) (def: (peek_frames reference definition_reference source) @@ -82,15 +82,15 @@ (let [[reference definition_reference] (name_of ..frames) current_frames (peek_frames reference definition_reference (value@ #.modules compiler))] (case (case frame - (#.Some frame) + {#.Some frame} (list.example (function (_ [actual _]) (text\= frame actual)) current_frames) #.None (..peek current_frames)) - (#.Some frame) - (#.Right [compiler frame]) + {#.Some frame} + {#.Right [compiler frame]} #.None (exception.except ..no_active_frames []))))) @@ -101,17 +101,17 @@ (def: .public (specific name) (-> Text (Meta Frame)) - (..peek! (#.Some name))) + (..peek! {#.Some name})) (template: (!push <source> <reference> <then>) [(loop [entries <source>] (case entries - (#.Item [head_name head] tail) + {#.Item [head_name head] tail} (if (text\= <reference> head_name) - (#.Item [head_name <then>] - tail) - (#.Item [head_name head] - (recur tail))) + {#.Item [head_name <then>] + tail} + {#.Item [head_name head] + (recur tail)}) #.End (undefined)))]) @@ -120,15 +120,15 @@ (-> Text Frame (List [Text Global]) (List [Text Global])) (!push source reference (case head - (#.Definition [exported? frames_type frames_value]) - (#.Definition [exported? + {#.Definition [exported? frames_type frames_value]} + {#.Definition [exported? frames_type - (..push frame (:as (Stack Frame) frames_value))]) + (..push frame (:as (Stack Frame) frames_value))]} - (^or (#.Type _) - (#.Alias _) - (#.Label _) - (#.Slot _)) + (^or {#.Type _} + {#.Alias _} + {#.Label _} + {#.Slot _}) (undefined)))) (def: (push_frame [module_reference definition_reference] frame source) @@ -139,30 +139,30 @@ (def: (push! frame) (-> Frame (Meta Any)) (function (_ compiler) - (#.Right [(revised@ #.modules + {#.Right [(revised@ #.modules (..push_frame (name_of ..frames) frame) compiler) - []]))) + []]})) (def: (pop_frame_definition reference source) (-> Text (List [Text Global]) (List [Text Global])) (!push source reference (case head - (#.Definition [exported? frames_type frames_value]) - (#.Definition [exported? + {#.Definition [exported? frames_type frames_value]} + {#.Definition [exported? frames_type (let [current_frames (:as (Stack Frame) frames_value)] (case (..pop current_frames) - (#.Some current_frames') + {#.Some current_frames'} current_frames' #.None - current_frames))]) + current_frames))]} - (^or (#.Type _) - (#.Alias _) - (#.Label _) - (#.Slot _)) + (^or {#.Type _} + {#.Alias _} + {#.Label _} + {#.Slot _}) (undefined)))) (def: (pop_frame [module_reference definition_reference] source) @@ -172,10 +172,10 @@ (syntax: (pop! []) (function (_ compiler) - (#.Right [(revised@ #.modules + {#.Right [(revised@ #.modules (..pop_frame (name_of ..frames)) compiler) - (list)]))) + (list)]})) (def: cast (Parser [(Maybe Text) Code]) @@ -242,8 +242,8 @@ (type: (Selection a) (Variant - (#Specific Code a) - (#Current a))) + {#Specific Code a} + {#Current a})) (def: (selection parser) (All (_ a) (-> (Parser a) (Parser (Selection a)))) @@ -252,26 +252,26 @@ (syntax: .public (:transmutation [selection (..selection <code>.any)]) (case selection - (#Specific specific value) + {#Specific specific value} (in (list (` (.|> (~ value) (..:representation (~ specific)) (..:abstraction (~ specific)))))) - (#Current value) + {#Current value} (in (list (` (.|> (~ value) ..:representation ..:abstraction)))))) (syntax: .public (^:representation [selection (<code>.form (..selection <code>.local_identifier)) body <code>.any branches (<>.some <code>.any)]) (case selection - (#Specific specific name) + {#Specific specific name} (let [g!var (code.local_identifier name)] (in (list& g!var (` (.let [(~ g!var) (..:representation (~ specific) (~ g!var))] (~ body))) branches))) - (#Current name) + {#Current name} (let [g!var (code.local_identifier name)] (in (list& g!var (` (.let [(~ g!var) (..:representation (~ g!var))] diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index bf8210953..c7001e71f 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -76,11 +76,11 @@ (def: (each f fa) (function (_ context) (case (fa context) - (#try.Success [context' output]) - (#try.Success [context' (f output)]) + {#try.Success [context' output]} + {#try.Success [context' (f output)]} - (#try.Failure error) - (#try.Failure error))))) + {#try.Failure error} + {#try.Failure error})))) (implementation: .public apply (Apply Check) @@ -90,16 +90,16 @@ (def: (on fa ff) (function (_ context) (case (ff context) - (#try.Success [context' f]) + {#try.Success [context' f]} (case (fa context') - (#try.Success [context'' a]) - (#try.Success [context'' (f a)]) + {#try.Success [context'' a]} + {#try.Success [context'' (f a)]} - (#try.Failure error) - (#try.Failure error)) + {#try.Failure error} + {#try.Failure error}) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} ))) ) @@ -110,21 +110,21 @@ (def: (in x) (function (_ context) - (#try.Success [context x]))) + {#try.Success [context x]})) (def: (conjoint ffa) (function (_ context) (case (ffa context) - (#try.Success [context' fa]) + {#try.Success [context' fa]} (case (fa context') - (#try.Success [context'' a]) - (#try.Success [context'' a]) + {#try.Success [context'' a]} + {#try.Success [context'' a]} - (#try.Failure error) - (#try.Failure error)) + {#try.Failure error} + {#try.Failure error}) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} ))) ) @@ -132,15 +132,15 @@ (def: (var::new id plist) (-> Var Type_Vars Type_Vars) - (#.Item [id #.None] plist)) + {#.Item [id #.None] plist}) (def: (var::get id plist) (-> Var Type_Vars (Maybe (Maybe Type))) (case plist - (#.Item [var_id var_type] - plist') + {#.Item [var_id var_type] + plist'} (if (!n\= id var_id) - (#.Some var_type) + {#.Some var_type} (var::get id plist')) #.End @@ -152,34 +152,34 @@ #.End (list [id value]) - (#.Item [var_id var_type] - plist') + {#.Item [var_id var_type] + plist'} (if (!n\= id var_id) - (#.Item [var_id value] - plist') - (#.Item [var_id var_type] - (var::put id value plist'))))) + {#.Item [var_id value] + plist'} + {#.Item [var_id var_type] + (var::put id value plist')}))) (def: .public (result context proc) (All (_ a) (-> Type_Context (Check a) (Try a))) (case (proc context) - (#try.Success [context' output]) - (#try.Success output) + {#try.Success [context' output]} + {#try.Success output} - (#try.Failure error) - (#try.Failure error))) + {#try.Failure error} + {#try.Failure error})) (def: .public (failure message) (All (_ a) (-> Text (Check a))) (function (_ context) - (#try.Failure message))) + {#try.Failure message})) (def: .public (assertion message test) (-> Text Bit (Check Any)) (function (_ context) (if test - (#try.Success [context []]) - (#try.Failure message)))) + {#try.Success [context []]} + {#try.Failure message}))) (def: .public (except exception message) (All (_ e a) (-> (Exception e) e (Check a))) @@ -189,26 +189,26 @@ (Check [Nat Type]) (function (_ context) (let [id (value@ #.ex_counter context)] - (#try.Success [(revised@ #.ex_counter ++ context) - [id (#.Ex id)]])))) + {#try.Success [(revised@ #.ex_counter ++ context) + [id {#.Ex id}]]}))) (template [<name> <outputT> <fail> <succeed>] [(def: .public (<name> id) (-> Var (Check <outputT>)) (function (_ context) (case (|> context (value@ #.var_bindings) (var::get id)) - (^or (#.Some (#.Some (#.Var _))) - (#.Some #.None)) - (#try.Success [context <fail>]) + (^or {#.Some {#.Some {#.Var _}}} + {#.Some #.None}) + {#try.Success [context <fail>]} - (#.Some (#.Some bound)) - (#try.Success [context <succeed>]) + {#.Some {#.Some bound}} + {#try.Success [context <succeed>]} #.None (exception.except ..unknown_type_var id))))] [bound? Bit false true] - [peek (Maybe Type) #.None (#.Some bound)] + [peek (Maybe Type) #.None {#.Some bound}] ) (def: .public (read id) @@ -216,7 +216,7 @@ (do ..monad [?type (peek id)] (case ?type - (#.Some type) + {#.Some type} (in type) #.None @@ -226,10 +226,10 @@ (-> Var (Check Type)) (function (_ context) (case (|> context (value@ #.var_bindings) (var::get id)) - (#.Some (#.Some bound)) - (#try.Success [context bound]) + {#.Some {#.Some bound}} + {#try.Success [context bound]} - (#.Some _) + {#.Some _} (exception.except ..unbound_type_var id) _ @@ -239,11 +239,11 @@ (-> Type Var (Check Any)) (function (_ context) (case (|> context (value@ #.var_bindings) (var::get id)) - (#.Some #.None) - (#try.Success [(revised@ #.var_bindings (var::put id (#.Some type)) context) - []]) + {#.Some #.None} + {#try.Success [(revised@ #.var_bindings (var::put id {#.Some type}) context) + []]} - (#.Some (#.Some bound)) + {#.Some {#.Some bound}} (exception.except ..cannot_rebind_var [id type bound]) _ @@ -253,9 +253,9 @@ (-> Type Var (Check Any)) (function (_ context) (case (|> context (value@ #.var_bindings) (var::get id)) - (#.Some _) - (#try.Success [(revised@ #.var_bindings (var::put id (#.Some type)) context) - []]) + {#.Some _} + {#try.Success [(revised@ #.var_bindings (var::put id {#.Some type}) context) + []]} _ (exception.except ..unknown_type_var id)))) @@ -264,32 +264,32 @@ (Check [Var Type]) (function (_ context) (let [id (value@ #.var_counter context)] - (#try.Success [(|> context + {#try.Success [(|> context (revised@ #.var_counter ++) (revised@ #.var_bindings (var::new id))) - [id (#.Var id)]])))) + [id {#.Var id}]]}))) (def: (on argT funcT) (-> Type Type (Check Type)) (case funcT - (#.Var func_id) + {#.Var func_id} (do ..monad [?funcT' (peek func_id)] (case ?funcT' - (#.Some funcT') + {#.Some funcT'} (on argT funcT') _ (except ..invalid_type_application [funcT argT]))) - (#.Apply argT' funcT') + {#.Apply argT' funcT'} (do ..monad [funcT'' (on argT' funcT')] (on argT funcT'')) _ (case (//.applied (list argT) funcT) - (#.Some output) + {#.Some output} (check\in output) _ @@ -309,18 +309,18 @@ (loop [current start output (set.has start empty_ring)] (case (|> context (value@ #.var_bindings) (var::get current)) - (#.Some (#.Some type)) + {#.Some {#.Some type}} (case type - (#.Var post) + {#.Var post} (if (!n\= start post) - (#try.Success [context output]) + {#try.Success [context output]} (recur post (set.has post output))) _ - (#try.Success [context empty_ring])) + {#try.Success [context empty_ring]}) - (#.Some #.None) - (#try.Success [context output]) + {#.Some #.None} + {#try.Success [context output]} #.None (exception.except ..unknown_type_var current))))) @@ -335,17 +335,17 @@ (All (_ a) (-> (Check a) (Check (Maybe a)))) (function (_ context) (case (op context) - (#try.Success [context' output]) - (#try.Success [context' (#.Some output)]) + {#try.Success [context' output]} + {#try.Success [context' {#.Some output}]} - (#try.Failure _) - (#try.Success [context #.None])))) + {#try.Failure _} + {#try.Success [context #.None]}))) (def: (either left right) (All (_ a) (-> (Check a) (Check a) (Check a))) (function (_ context) (case (left context) - (#try.Failure _) + {#try.Failure _} (right context) output @@ -374,21 +374,21 @@ then) (do ..monad [?bound (peek id)] - (else (maybe.else (#.Var id) ?bound))))) + (else (maybe.else {#.Var id} ?bound))))) ... TODO: "link/2" can be optimized... (def: (link/2 left right) (-> Var Var (Check Any)) (do ..monad - [_ (..bind (#.Var right) left)] - (..bind (#.Var left) right))) + [_ (..bind {#.Var right} left)] + (..bind {#.Var left} right))) ... TODO: "link/3" can be optimized... (def: (link/3 interpose to from) (-> Var Var Var (Check Any)) (do ..monad - [_ (re_bind (#.Var interpose) from)] - (re_bind (#.Var to) interpose))) + [_ (re_bind {#.Var interpose} from)] + (re_bind {#.Var to} interpose))) ... TODO: "check_vars" can be optimized... (def: (check_vars check' assumptions idE idA) @@ -406,30 +406,30 @@ (in assumptions)) ... Interpose new variable between 2 existing links - [(#.Some etype) #.None] + [{#.Some etype} #.None] (case etype - (#.Var targetE) + {#.Var targetE} (do ! [_ (link/3 idA targetE idE)] (in assumptions)) _ - (check' assumptions etype (#.Var idA))) + (check' assumptions etype {#.Var idA})) ... Interpose new variable between 2 existing links - [#.None (#.Some atype)] + [#.None {#.Some atype}] (case atype - (#.Var targetA) + {#.Var targetA} (do ! [_ (link/3 idE targetA idA)] (in assumptions)) _ - (check' assumptions (#.Var idE) atype)) + (check' assumptions {#.Var idE} atype)) - [(#.Some etype) (#.Some atype)] + [{#.Some etype} {#.Some atype}] (case [etype atype] - [(#.Var targetE) (#.Var targetA)] + [{#.Var targetE} {#.Var targetA}] (do ! [ringE (..ring idE) ringA (..ring idA)] @@ -451,8 +451,8 @@ [ring (..ring <id>) _ (monad.each ! (re_bind <type>) (set.list ring))] (in assumptions))]) - ([[(#.Var _) _] idE atype] - [[_ (#.Var _)] idA etype]) + ([[{#.Var _} _] idE atype] + [[_ {#.Var _}] idA etype]) _ (check' assumptions etype atype)))))) @@ -467,54 +467,54 @@ (let [[expected_input expected_function] expected [actual_input actual_function] actual] (case [expected_function actual_function] - [(#.Ex exE) (#.Ex exA)] + [{#.Ex exE} {#.Ex exA}] (if (!n\= exE exA) (check' assumptions expected_input actual_input) ..silent_failure!) - [(#.UnivQ _ _) (#.Ex _)] + [{#.UnivQ _ _} {#.Ex _}] (do ..monad [expected' (..on expected_input expected_function)] - (check' assumptions expected' (#.Apply actual))) + (check' assumptions expected' {#.Apply actual})) - [(#.Ex _) (#.UnivQ _ _)] + [{#.Ex _} {#.UnivQ _ _}] (do ..monad [actual' (..on actual_input actual_function)] - (check' assumptions (#.Apply expected) actual')) + (check' assumptions {#.Apply expected} actual')) - [(#.Apply [expected_input' expected_function']) (#.Ex _)] + [{#.Apply [expected_input' expected_function']} {#.Ex _}] (do ..monad [expected_function'' (..on expected_input' expected_function')] - (check' assumptions (#.Apply [expected_input expected_function'']) (#.Apply actual))) + (check' assumptions {#.Apply [expected_input expected_function'']} {#.Apply actual})) - [(#.Ex _) (#.Apply [actual_input' actual_function'])] + [{#.Ex _} {#.Apply [actual_input' actual_function']}] (do ..monad [actual_function'' (..on actual_input' actual_function')] - (check' assumptions (#.Apply expected) (#.Apply [actual_input actual_function'']))) + (check' assumptions {#.Apply expected} {#.Apply [actual_input actual_function'']})) - (^or [(#.Ex _) _] [_ (#.Ex _)]) + (^or [{#.Ex _} _] [_ {#.Ex _}]) (do ..monad [assumptions (check' assumptions expected_function actual_function)] (check' assumptions expected_input actual_input)) - [(#.Var id) _] + [{#.Var id} _] (function (_ context) (case ((do ..monad [expected_function' (..read id)] - (check' assumptions (#.Apply expected_input expected_function') (#.Apply actual))) + (check' assumptions {#.Apply expected_input expected_function'} {#.Apply actual})) context) - (#try.Success output) - (#try.Success output) + {#try.Success output} + {#try.Success output} - (#try.Failure _) + {#try.Failure _} (case actual_function - (#.UnivQ _ _) + {#.UnivQ _ _} ((do ..monad [actual' (..on actual_input actual_function)] - (check' assumptions (#.Apply expected) actual')) + (check' assumptions {#.Apply expected} actual')) context) - (#.Ex exA) + {#.Ex exA} ((do ..monad [assumptions (check' assumptions expected_function actual_function)] (check' assumptions expected_input actual_input)) @@ -528,14 +528,14 @@ (check' assumptions expected' actual')) context)))) - [_ (#.Var id)] + [_ {#.Var id}] (function (_ context) (case ((do ..monad [actual_function' (read id)] - (check' assumptions (#.Apply expected) (#.Apply actual_input actual_function'))) + (check' assumptions {#.Apply expected} {#.Apply actual_input actual_function'})) context) - (#try.Success output) - (#try.Success output) + {#try.Success output} + {#try.Success output} _ ((do ..monad @@ -563,45 +563,45 @@ (check\in assumptions) (with ..type_check_failed [expected actual] (case [expected actual] - [(#.Var idE) (#.Var idA)] + [{#.Var idE} {#.Var idA}] (check_vars check' assumptions idE idA) - [(#.Var id) _] + [{#.Var id} _] (if_can_bind id actual (check\in assumptions) (function (_ bound) (check' assumptions bound actual))) - [_ (#.Var id)] + [_ {#.Var id}] (if_can_bind id expected (check\in assumptions) (function (_ bound) (check' assumptions expected bound))) (^template [<fE> <fA>] - [[(#.Apply aE <fE>) (#.Apply aA <fA>)] + [[{#.Apply aE <fE>} {#.Apply aA <fA>}] (check_apply check' assumptions [aE <fE>] [aA <fA>])]) - ([F1 (#.Ex ex)] - [(#.Ex exE) fA] - [fE (#.Var idA)] - [(#.Var idE) fA]) + ([F1 {#.Ex ex}] + [{#.Ex exE} fA] + [fE {#.Var idA}] + [{#.Var idE} fA]) - [(#.Apply A F) _] + [{#.Apply A F} _] (let [new_assumption [expected actual]] (if (assumed? new_assumption assumptions) (check\in assumptions) (do ..monad [expected' (..on A F)] - (check' (#.Item new_assumption assumptions) expected' actual)))) + (check' {#.Item new_assumption assumptions} expected' actual)))) - [_ (#.Apply A F)] + [_ {#.Apply A F}] (do ..monad [actual' (..on A F)] (check' assumptions expected actual')) ... TODO: Refactor-away as cold-code (^template [<tag> <instancer>] - [[(<tag> _) _] + [[{<tag> _} _] (do ..monad [[_ paramT] <instancer> expected' (..on paramT expected)] @@ -611,7 +611,7 @@ ... TODO: Refactor-away as cold-code (^template [<tag> <instancer>] - [[_ (<tag> _)] + [[_ {<tag> _}] (do ..monad [[_ paramT] <instancer> actual' (..on paramT actual)] @@ -619,7 +619,7 @@ ([#.UnivQ ..var] [#.ExQ ..existential]) - [(#.Primitive e_name e_params) (#.Primitive a_name a_params)] + [{#.Primitive e_name e_params} {#.Primitive a_name a_params}] (if (!text\= e_name a_name) (loop [assumptions assumptions e_params e_params @@ -628,7 +628,7 @@ [#.End #.End] (check\in assumptions) - [(#.Item e_head e_tail) (#.Item a_head a_tail)] + [{#.Item e_head e_tail} {#.Item a_head a_tail}] (do ..monad [assumptions' (check' assumptions e_head a_head)] (recur assumptions' e_tail a_tail)) @@ -638,27 +638,27 @@ ..silent_failure!) (^template [<composite>] - [[(<composite> eL eR) (<composite> aL aR)] + [[{<composite> eL eR} {<composite> aL aR}] (do ..monad [assumptions (check' assumptions eL aL)] (check' assumptions eR aR))]) ([#.Sum] [#.Product]) - [(#.Function eI eO) (#.Function aI aO)] + [{#.Function eI eO} {#.Function aI aO}] (do ..monad [assumptions (check' assumptions aI eI)] (check' assumptions eO aO)) - [(#.Ex e!id) (#.Ex a!id)] + [{#.Ex e!id} {#.Ex a!id}] (if (!n\= e!id a!id) (check\in assumptions) ..silent_failure!) - [(#.Named _ ?etype) _] + [{#.Named _ ?etype} _] (check' assumptions ?etype actual) - [_ (#.Named _ ?atype)] + [_ {#.Named _ ?atype}] (check' assumptions expected ?atype) _ @@ -672,50 +672,50 @@ (-> Type Type Bit) (case (..result ..fresh_context (..check expected actual)) - (#try.Failure _) + {#try.Failure _} false - (#try.Success _) + {#try.Success _} true)) (def: .public context (Check Type_Context) (function (_ context) - (#try.Success [context context]))) + {#try.Success [context context]})) (def: .public (clean inputT) (-> Type (Check Type)) (case inputT - (#.Primitive name paramsT+) + {#.Primitive name paramsT+} (|> paramsT+ (monad.each ..monad clean) - (check\each (|>> (#.Primitive name)))) + (check\each (|>> {#.Primitive name}))) - (^or (#.Parameter _) (#.Ex _) (#.Named _)) + (^or {#.Parameter _} {#.Ex _} {#.Named _}) (check\in inputT) (^template [<tag>] - [(<tag> leftT rightT) + [{<tag> leftT rightT} (do ..monad [leftT' (clean leftT)] (|> (clean rightT) - (check\each (|>> (<tag> leftT')))))]) + (check\each (|>> {<tag> leftT'}))))]) ([#.Sum] [#.Product] [#.Function] [#.Apply]) - (#.Var id) + {#.Var id} (do ..monad [?actualT (peek id)] (case ?actualT - (#.Some actualT) + {#.Some actualT} (clean actualT) _ (in inputT))) (^template [<tag>] - [(<tag> envT+ unquantifiedT) + [{<tag> envT+ unquantifiedT} (do [! ..monad] [envT+' (monad.each ! clean envT+)] - (in (<tag> envT+' unquantifiedT)))]) + (in {<tag> envT+' unquantifiedT}))]) ([#.UnivQ] [#.ExQ]) )) diff --git a/stdlib/source/library/lux/type/dynamic.lux b/stdlib/source/library/lux/type/dynamic.lux index 0709b67e2..d766c77a0 100644 --- a/stdlib/source/library/lux/type/dynamic.lux +++ b/stdlib/source/library/lux/type/dynamic.lux @@ -44,7 +44,7 @@ (: ((~! try.Try) (~ type)) (if (\ (~! type.equivalence) (~' =) (.type (~ type)) (~ g!type)) - (#try.Success (:as (~ type) (~ g!value))) + {#try.Success (:as (~ type) (~ g!value))} ((~! exception.except) ..wrong_type [(.type (~ type)) (~ g!type)]))))))))) (def: .public (format value) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index dc460e41d..03379a14e 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -30,15 +30,15 @@ (-> Nat Type_Context (Meta Type)) (case (list.example (|>> product.left (n.= id)) (value@ #.var_bindings env)) - (#.Some [_ (#.Some type)]) + {#.Some [_ {#.Some type}]} (case type - (#.Var id') + {#.Var id'} (type_var id' env) _ (\ meta.monad in type)) - (#.Some [_ #.None]) + {#.Some [_ #.None]} (meta.failure (format "Unbound type-var " (%.nat id))) #.None @@ -51,7 +51,7 @@ [raw_type (meta.type var_name) compiler meta.compiler_state] (case raw_type - (#.Var id) + {#.Var id} (type_var id (value@ #.type_context compiler)) _ @@ -60,18 +60,18 @@ (def: (member_type idx sig_type) (-> Nat Type (Check Type)) (case sig_type - (#.Named _ sig_type') + {#.Named _ sig_type'} (member_type idx sig_type') - (#.Apply arg func) + {#.Apply arg func} (case (type.applied (list arg) func) #.None (check.failure (format "Cannot apply type " (%.type func) " to type " (%.type arg))) - (#.Some sig_type') + {#.Some sig_type'} (member_type idx sig_type')) - (#.Product left right) + {#.Product left right} (if (n.= 0 idx) (\ check.monad in left) (member_type (-- idx) right)) @@ -100,7 +100,7 @@ #.End (meta.failure (format "Unknown tag: " (%.name member))) - (#.Item winner #.End) + {#.Item winner #.End} (in winner) _ @@ -139,7 +139,7 @@ (if (and (or (text\= target_module source_module) exported?) (compatible_type? sig_type def_type)) - (#.Item [[source_module name] def_type] aggregate) + {#.Item [[source_module name] def_type] aggregate} aggregate)) aggregate constants)) @@ -157,7 +157,7 @@ dictionary.entries (list.all (function (_ [name type]) (if (compatible_type? sig_type type) - (#.Some [["" name] type]) + {#.Some [["" name] type]} #.None))))))) (def: (local_structs sig_type) @@ -181,10 +181,10 @@ (def: (on_argument arg func) (-> Type Type (Check Type)) (case func - (#.Named _ func') + {#.Named _ func'} (on_argument arg func') - (#.UnivQ _) + {#.UnivQ _} (do check.monad [[id var] check.var] (|> func @@ -192,7 +192,7 @@ maybe.trusted (on_argument arg))) - (#.Function input output) + {#.Function input output} (do check.monad [_ (check.check input arg)] (in output)) @@ -203,11 +203,11 @@ (def: (concrete_type type) (-> Type (Check [(List Nat) Type])) (case type - (#.UnivQ _) + {#.UnivQ _} (do check.monad [[id var] check.var [ids final_output] (concrete_type (maybe.trusted (type.applied (list var) type)))] - (in [(#.Item id ids) + (in [{#.Item id ids} final_output])) _ @@ -241,10 +241,10 @@ context' check.context =deps (monad.each ! (provision compiler context') deps)] (in =deps))) - (#.Left error) + {#.Left error} (list) - (#.Right =deps) + {#.Right =deps} (list [alt_name =deps])))) list\conjoint) #.End @@ -260,15 +260,15 @@ (do meta.monad [alts (..local_env sig_type)] (..candidate_provision (provision sig_type) context dep alts)) (do meta.monad [alts (..local_structs sig_type)] (..candidate_provision (provision sig_type) context dep alts)) (do meta.monad [alts (..imported_structs sig_type)] (..candidate_provision (provision sig_type) context dep alts)))) - (#.Left error) + {#.Left error} (check.failure error) - (#.Right candidates) + {#.Right candidates} (case candidates #.End (check.failure (format "No candidates for provisioning: " (%.type dep))) - (#.Item winner #.End) + {#.Item winner #.End} (\ check.monad in winner) _ @@ -292,10 +292,10 @@ context' check.context =deps (monad.each ! (provision sig_type compiler context') deps)] (in =deps))) - (#.Left error) + {#.Left error} (list) - (#.Right =deps) + {#.Right =deps} (list [alt_name =deps])))) list\conjoint) #.End @@ -315,7 +315,7 @@ (def: (var? input) (-> Code Bit) (case input - [_ (#.Identifier _)] + [_ {#.Identifier _}] #1 _ @@ -338,7 +338,7 @@ args (<>.or (<>.and (<>.some <code>.identifier) <code>.end!) (<>.and (<>.some <code>.any) <code>.end!))]) (case args - (#.Left [args _]) + {#.Left [args _]} (do [! meta.monad] [[member_idx sig_type] (..implicit_member member) input_types (monad.each ! ..implicit_type args) @@ -348,7 +348,7 @@ #.End (meta.failure (format "No implementation could be found for member: " (%.name member))) - (#.Item chosen #.End) + {#.Item chosen #.End} (in (list (` (\ (~ (instance$ chosen)) (~ (code.local_identifier (product.right member))) (~+ (list\each code.identifier args)))))) @@ -360,7 +360,7 @@ (text.interposed ", ")) " --- for type: " (%.type sig_type))))) - (#.Right [args _]) + {#.Right [args _]} (do [! meta.monad] [labels (|> (macro.identifier "") (list.repeated (list.size args)) (monad.all !))] (in (list (` (let [(~+ (|> args (list.zipped/2 labels) (list\each ..pair_list) list\conjoint))] diff --git a/stdlib/source/library/lux/type/poly.lux b/stdlib/source/library/lux/type/poly.lux index 4f7a32f1c..64c5abe51 100644 --- a/stdlib/source/library/lux/type/poly.lux +++ b/stdlib/source/library/lux/type/poly.lux @@ -42,54 +42,54 @@ (function ((~ g!_) (~ g!name)) (~ body))) (.:as .Type (~ g!type)))) - (#.Left (~ g!output)) + {#.Left (~ g!output)} ((~! meta.failure) (~ g!output)) - (#.Right (~ g!output)) + {#.Right (~ g!output)} ((~' in) (.list (~ g!output)))))))))))) (def: .public (code env type) (-> Env Type Code) (`` (case type - (#.Primitive name params) - (` (#.Primitive (~ (code.text name)) - (.list (~+ (list\each (code env) params))))) + {#.Primitive name params} + (` {#.Primitive (~ (code.text name)) + (.list (~+ (list\each (code env) params)))}) (^template [<tag>] - [(<tag> idx) - (` (<tag> (~ (code.nat idx))))]) + [{<tag> idx} + (` {<tag> (~ (code.nat idx))})]) ([#.Var] [#.Ex]) - (#.Parameter idx) + {#.Parameter idx} (let [idx (<type>.adjusted_idx env idx)] (if (n.= 0 idx) (|> (dictionary.value idx env) maybe.trusted product.left (code env)) (` (.$ (~ (code.nat (-- idx))))))) - (#.Apply (#.Primitive "" #.End) - (#.Parameter idx)) + {#.Apply {#.Primitive "" #.End} + {#.Parameter idx}} (case (<type>.adjusted_idx env idx) 0 (|> env (dictionary.value 0) maybe.trusted product.left (code env)) idx (undefined)) (^template [<tag>] - [(<tag> left right) - (` (<tag> (~ (code env left)) - (~ (code env right))))]) + [{<tag> left right} + (` {<tag> (~ (code env left)) + (~ (code env right))})]) ([#.Function] [#.Apply]) (^template [<macro> <tag> <flattener>] - [(<tag> left right) + [{<tag> left right} (` (<macro> (~+ (list\each (code env) (<flattener> type)))))]) ([.Union #.Sum type.flat_variant] [.Tuple #.Product type.flat_tuple]) - (#.Named name sub_type) + {#.Named name sub_type} (code.identifier name) (^template [<tag>] - [(<tag> scope body) - (` (<tag> (.list (~+ (list\each (code env) scope))) - (~ (code env body))))]) + [{<tag> scope body} + (` {<tag> (.list (~+ (list\each (code env) scope))) + (~ (code env body))})]) ([#.UnivQ] [#.ExQ]) ))) diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux index 3bbe82935..bfa951ede 100644 --- a/stdlib/source/library/lux/type/refinement.lux +++ b/stdlib/source/library/lux/type/refinement.lux @@ -25,8 +25,8 @@ (-> (Predicate t) (Refiner t %)))) (function (_ value) (if (predicate value) - (#.Some (:abstraction [#value value - #predicate predicate])) + {#.Some (:abstraction [#value value + #predicate predicate])} #.None))) (template [<name> <output> <slot>] @@ -46,8 +46,8 @@ (let [(^slots [#value #predicate]) (:representation refined) value' (transform value)] (if (predicate value') - (#.Some (:abstraction [#value value' - #predicate predicate])) + {#.Some (:abstraction [#value value' + #predicate predicate])} #.None))))] ) @@ -58,10 +58,10 @@ #.End #.End - (#.Item head tail) + {#.Item head tail} (case (refiner head) - (#.Some refined) - (#.Item refined (only refiner tail)) + {#.Some refined} + {#.Item refined (only refiner tail)} #.None (only refiner tail)))) @@ -73,16 +73,16 @@ #.End [#.End #.End] - (#.Item head tail) + {#.Item head tail} (let [[yes no] (partition refiner tail)] (case (refiner head) - (#.Some refined) - [(#.Item refined yes) + {#.Some refined} + [{#.Item refined yes} no] #.None [yes - (#.Item head no)])))) + {#.Item head no}])))) (syntax: .public (type [refiner <code>.any]) (macro.with_identifiers [g!t g!%] diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux index 244644d57..d5c209cd7 100644 --- a/stdlib/source/library/lux/type/resource.lux +++ b/stdlib/source/library/lux/type/resource.lux @@ -132,7 +132,7 @@ #.End (in (list (` (~! no_op)))) - (#.Item head tail) + {#.Item head tail} (do [! meta.monad] [.let [max_idx (list\mix n.max head tail)] g!inputs (<| (monad.all !) (list.repeated (++ max_idx)) (macro.identifier "input")) diff --git a/stdlib/source/library/lux/world/console.lux b/stdlib/source/library/lux/world/console.lux index e3d156adf..7c974630f 100644 --- a/stdlib/source/library/lux/world/console.lux +++ b/stdlib/source/library/lux/world/console.lux @@ -74,7 +74,7 @@ #.None (in (exception.except ..cannot_open [])) - (#.Some jvm_console) + {#.Some jvm_console} (let [jvm_input (java/lang/System::in) jvm_output (java/lang/System::out)] (<| in @@ -122,13 +122,13 @@ (do [! io.monad] [|state| (atom.read! state)] (case (\ mock <mock> |state|) - (#try.Success [|state| output]) + {#try.Success [|state| output]} (do ! [_ (atom.write! |state| state)] - (in (#try.Success output))) + (in {#try.Success output})) - (#try.Failure error) - (in (#try.Failure error)))))] + {#try.Failure error} + (in {#try.Failure error}))))] [read on_read] [read_line on_read_line] @@ -138,23 +138,23 @@ (do [! io.monad] [|state| (atom.read! state)] (case (\ mock on_write input |state|) - (#try.Success |state|) + {#try.Success |state|} (do ! [_ (atom.write! |state| state)] - (in (#try.Success []))) + (in {#try.Success []})) - (#try.Failure error) - (in (#try.Failure error))))) + {#try.Failure error} + (in {#try.Failure error})))) (def: (close _) (do [! io.monad] [|state| (atom.read! state)] (case (\ mock on_close |state|) - (#try.Success |state|) + {#try.Success |state|} (do ! [_ (atom.write! |state| state)] - (in (#try.Success []))) + (in {#try.Success []})) - (#try.Failure error) - (in (#try.Failure error))))) + {#try.Failure error} + (in {#try.Failure error})))) )))) diff --git a/stdlib/source/library/lux/world/db/jdbc/input.lux b/stdlib/source/library/lux/world/db/jdbc/input.lux index 1819241b3..aa8a168af 100644 --- a/stdlib/source/library/lux/world/db/jdbc/input.lux +++ b/stdlib/source/library/lux/world/db/jdbc/input.lux @@ -64,12 +64,12 @@ (def: .public (fail error) (All (_ a) (-> Text (Input a))) (function (_ value [idx context]) - (#try.Failure error))) + {#try.Failure error})) (def: .public empty (Input Any) (function (_ value context) - (#try.Success context))) + {#try.Success context})) (template [<function> <type> <setter>] [(def: .public <function> diff --git a/stdlib/source/library/lux/world/db/jdbc/output.lux b/stdlib/source/library/lux/world/db/jdbc/output.lux index 25b4b0668..3772ff0e1 100644 --- a/stdlib/source/library/lux/world/db/jdbc/output.lux +++ b/stdlib/source/library/lux/world/db/jdbc/output.lux @@ -56,11 +56,11 @@ (def: (each f fa) (function (_ idx+rs) (case (fa idx+rs) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success [idx' value]) - (#try.Success [idx' (f value)]))))) + {#try.Success [idx' value]} + {#try.Success [idx' (f value)]})))) (implementation: .public apply (Apply Output) @@ -70,16 +70,16 @@ (def: (apply ff fa) (function (_ [idx rs]) (case (ff [idx rs]) - (#try.Success [idx' f]) + {#try.Success [idx' f]} (case (fa [idx' rs]) - (#try.Success [idx'' a]) - (#try.Success [idx'' (f a)]) + {#try.Success [idx'' a]} + {#try.Success [idx'' (f a)]} - (#try.Failure msg) - (#try.Failure msg)) + {#try.Failure msg} + {#try.Failure msg}) - (#try.Failure msg) - (#try.Failure msg))))) + {#try.Failure msg} + {#try.Failure msg})))) (implementation: .public monad (Monad Output) @@ -88,21 +88,21 @@ (def: (in a) (function (_ [idx rs]) - (#.Some [idx a]))) + {#.Some [idx a]})) (def: (conjoint mma) (function (_ [idx rs]) (case (mma [idx rs]) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success [idx' ma]) + {#try.Success [idx' ma]} (ma [idx' rs]))))) (def: .public (fail error) (All (_ a) (-> Text (Output a))) (function (_ [idx result_set]) - (#try.Failure error))) + {#try.Failure error})) (def: .public (and left right) (All (_ a b) @@ -117,11 +117,11 @@ (Output <type>) (function (_ [idx result_set]) (case (<method_name> [(.int idx)] result_set) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success value) - (#try.Success [(++ idx) value]))))] + {#try.Success value} + {#try.Success [(++ idx) value]})))] [boolean java/sql/ResultSet::getBoolean Bit] @@ -142,12 +142,12 @@ (Output Instant) (function (_ [idx result_set]) (case (<method_name> [(.int idx)] result_set) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success value) - (#try.Success [(++ idx) - (instant.from_millis (java/util/Date::getTime value))]))))] + {#try.Success value} + {#try.Success [(++ idx) + (instant.from_millis (java/util/Date::getTime value))]})))] [date java/sql/ResultSet::getDate] [time java/sql/ResultSet::getTime] @@ -157,24 +157,24 @@ (def: .public (rows output results) (All (_ a) (-> (Output a) java/sql/ResultSet (IO (Try (List a))))) (case (java/sql/ResultSet::next results) - (#try.Success has_next?) + {#try.Success has_next?} (if has_next? (case (output [1 results]) - (#.Some [_ head]) + {#.Some [_ head]} (do io.monad [?tail (rows output results)] (case ?tail - (#try.Success tail) - (in (#try.Success (#.Item head tail))) + {#try.Success tail} + (in {#try.Success {#.Item head tail}}) - (#try.Failure error) + {#try.Failure error} (do io.monad [temp (java/sql/ResultSet::close results)] (in (do try.monad [_ temp] (try.failure error)))))) - (#try.Failure error) + {#try.Failure error} (do io.monad [temp (java/sql/ResultSet::close results)] (in (do try.monad @@ -186,7 +186,7 @@ [_ temp] (in (list)))))) - (#try.Failure error) + {#try.Failure error} (do io.monad [temp (java/sql/ResultSet::close results)] (in (do try.monad diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 66c125a34..82796463c 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -84,7 +84,7 @@ #.None #.None - (#.Some last_separator) + {#.Some last_separator} (do maybe.monad [[parent temp] (text.split_at last_separator path) [_ child] (text.split_at (text.size /) temp)] @@ -230,7 +230,7 @@ (do [! (try.with io.monad)] [?children (java/io/File::listFiles (java/io/File::new path))] (case ?children - (#.Some children) + {#.Some children} (|> children (array.list #.None) (monad.only ! (|>> <method>)) @@ -354,8 +354,8 @@ io.run! write! (if (ffi.null? error) - (#try.Success []) - (#try.Failure (Error::toString [] (:as Error error)))))) + {#try.Success []} + {#try.Failure (Error::toString [] (:as Error error))}))) (def: (value_callback write!) (All (_ a) (-> (async.Resolver (Try a)) ffi.Function)) @@ -363,8 +363,8 @@ io.run! write! (if (ffi.null? error) - (#try.Success (:expected datum)) - (#try.Failure (Error::toString [] (:as Error error)))))) + {#try.Success (:expected datum)} + {#try.Failure (Error::toString [] (:as Error error))}))) (ffi.import: JsPath ["[1]::[0]" @@ -383,9 +383,9 @@ (def: (require _) (-> [] (-> ffi.String Any)) (case [(normal_require []) (global_require []) (process_load [])] - (^or [(#.Some require) _ _] - [_ (#.Some require) _] - [_ _ (#.Some require)]) + (^or [{#.Some require} _ _] + [_ {#.Some require} _] + [_ _ {#.Some require}]) require _ @@ -418,10 +418,10 @@ (Fs::stat [path (..value_callback write!)] (..node_fs [])))] (in (case ?stats - (#try.Success stats) + {#try.Success stats} (<method> [] stats) - (#try.Failure _) + {#try.Failure _} false))))] [file? Stats::isFile] @@ -437,10 +437,10 @@ (..any_callback write!)] node_fs))] (case outcome - (#try.Success _) + {#try.Success _} (in (exception.except ..cannot_make_directory [path])) - (#try.Failure _) + {#try.Failure _} (with_async write! (Try Any) (Fs::mkdir [path (..any_callback write!)] node_fs))))) @@ -487,10 +487,10 @@ (def: (can_execute? path) (let [node_fs (..node_fs [])] (\ async.monad each - (|>> (case> (#try.Success _) + (|>> (case> {#try.Success _} true - (#try.Failure _) + {#try.Failure _} false) #try.Success) (with_async write! (Try Any) @@ -733,11 +733,11 @@ #.End (in output) - (#.Item head tail) + {#.Item head tail} (do ! [verdict (<test> head)] (recur tail (if verdict - (#.Item head output) + {#.Item head output} output))))) _ (RubyDir::close [] self)] (in output)))] @@ -928,11 +928,11 @@ ... #.End ... (in output) - ... (#.Item head tail) + ... {#.Item head tail} ... (do ! ... [verdict (<test> head)] ... (if verdict - ... (recur tail (#.Item (<constructor> head) output)) + ... (recur tail {#.Item (<constructor> head) output}) ... (recur tail output)))))))] ... [files ..is_file ..file File] @@ -956,7 +956,7 @@ ... [verdict (<test> path)] ... (\ io.monad in ... (if verdict - ... (#try.Success (<constructor> path)) + ... {#try.Success (<constructor> path)} ... (exception.except <exception> [path])))))] ... [file ..is_file ..file ..cannot_find_file] @@ -968,7 +968,7 @@ ... [verdict (..touch [path (|> instant.now io.run! instant.relative duration.millis (i./ +1,000))])] ... (\ io.monad in ... (if verdict - ... (#try.Success (..file path)) + ... {#try.Success (..file path)} ... (exception.except ..cannot_make_file [path]))))) ... (def: (make_directory path) @@ -976,7 +976,7 @@ ... [verdict (..mkdir path)] ... (\ io.monad in ... (if verdict - ... (#try.Success (..directory path)) + ... {#try.Success (..directory path)} ... (exception.except ..cannot_make_directory [path]))))) ... (def: separator @@ -1013,17 +1013,17 @@ (loop [directory mock trail (text.all_split_by separator path)] (case trail - (#.Item head tail) + {#.Item head tail} (case (dictionary.value head directory) #.None (exception.except ..cannot_find_file [path]) - (#.Some node) + {#.Some node} (case [node tail] - [(#.Left file) #.End] - (#try.Success [head file]) + [{#.Left file} #.End] + {#try.Success [head file]} - [(#.Right sub_directory) (#.Item _)] + [{#.Right sub_directory} {#.Item _}] (recur sub_directory tail) _ @@ -1037,33 +1037,33 @@ (loop [directory mock trail (text.all_split_by / path)] (case trail - (#.Item head tail) + {#.Item head tail} (case (dictionary.value head directory) #.None (case tail #.End - (#try.Success (dictionary.has head - (#.Left [#mock_last_modified now + {#try.Success (dictionary.has head + {#.Left [#mock_last_modified now #mock_can_execute false - #mock_content content]) - directory)) + #mock_content content]} + directory)} - (#.Item _) + {#.Item _} (exception.except ..cannot_find_file [path])) - (#.Some node) + {#.Some node} (case [node tail] - [(#.Left file) #.End] - (#try.Success (dictionary.has head - (#.Left (|> file + [{#.Left file} #.End] + {#try.Success (dictionary.has head + {#.Left (|> file (with@ #mock_last_modified now) - (with@ #mock_content content))) - directory)) + (with@ #mock_content content))} + directory)} - [(#.Right sub_directory) (#.Item _)] + [{#.Right sub_directory} {#.Item _}] (do try.monad [sub_directory (recur sub_directory tail)] - (in (dictionary.has head (#.Right sub_directory) directory))) + (in (dictionary.has head {#.Right sub_directory} directory))) _ (exception.except ..cannot_find_file [path]))) @@ -1076,32 +1076,32 @@ (loop [directory mock trail (text.all_split_by / path)] (case trail - (#.Item head tail) + {#.Item head tail} (case (dictionary.value head directory) #.None (exception.except ..cannot_delete [path]) - (#.Some node) + {#.Some node} (case tail #.End (case node - (#.Left file) - (#try.Success (dictionary.lacks head directory)) + {#.Left file} + {#try.Success (dictionary.lacks head directory)} - (#.Right sub_directory) + {#.Right sub_directory} (if (dictionary.empty? sub_directory) - (#try.Success (dictionary.lacks head directory)) + {#try.Success (dictionary.lacks head directory)} (exception.except ..cannot_delete [path]))) - (#.Item _) + {#.Item _} (case node - (#.Left file) + {#.Left file} (exception.except ..cannot_delete [path]) - (#.Right sub_directory) + {#.Right sub_directory} (do try.monad [sub_directory' (recur sub_directory tail)] - (in (dictionary.has head (#.Right sub_directory') directory)))))) + (in (dictionary.has head {#.Right sub_directory'} directory)))))) #.End (exception.except ..cannot_delete [path])))) @@ -1111,35 +1111,35 @@ (do [! stm.monad] [|var| (stm.read var)] (case (transform |var|) - (#try.Success |var|) + {#try.Success |var|} (do ! [_ (stm.write |var| var)] - (in (#try.Success []))) + (in {#try.Success []})) - (#try.Failure error) - (in (#try.Failure error))))) + {#try.Failure error} + (in {#try.Failure error})))) (def: (make_mock_directory! / path mock) (-> Text Path Mock (Try Mock)) (loop [directory mock trail (text.all_split_by / path)] (case trail - (#.Item head tail) + {#.Item head tail} (case (dictionary.value head directory) #.None (case tail #.End - (#try.Success (dictionary.has head (#.Right ..empty_mock) directory)) + {#try.Success (dictionary.has head {#.Right ..empty_mock} directory)} - (#.Item _) + {#.Item _} (exception.except ..cannot_make_directory [path])) - (#.Some node) + {#.Some node} (case [node tail] - [(#.Right sub_directory) (#.Item _)] + [{#.Right sub_directory} {#.Item _}] (do try.monad [sub_directory (recur sub_directory tail)] - (in (dictionary.has head (#.Right sub_directory) directory))) + (in (dictionary.has head {#.Right sub_directory} directory))) _ (exception.except ..cannot_make_directory [path]))) @@ -1153,24 +1153,24 @@ trail (text.all_split_by / path)] (case trail #.End - (#try.Success directory) + {#try.Success directory} - (#.Item head tail) + {#.Item head tail} (case (dictionary.value head directory) #.None (exception.except ..cannot_find_directory [path]) - (#.Some node) + {#.Some node} (case node - (#.Left _) + {#.Left _} (exception.except ..cannot_find_directory [path]) - (#.Right sub_directory) + {#.Right sub_directory} (case tail #.End - (#try.Success sub_directory) + {#try.Success sub_directory} - (#.Item _) + {#.Item _} (recur sub_directory tail))))))) (def: .public (mock separator) @@ -1198,13 +1198,13 @@ (do [! stm.monad] [|store| (stm.read store)] (case (..make_mock_directory! separator path |store|) - (#try.Success |store|) + {#try.Success |store|} (do ! [_ (stm.write |store| store)] - (in (#try.Success []))) + (in {#try.Success []})) - (#try.Failure error) - (in (#try.Failure error)))))) + {#try.Failure error} + (in {#try.Failure error}))))) (~~ (template [<method> <tag>] [(def: (<method> path) @@ -1217,8 +1217,8 @@ dictionary.entries (list.all (function (_ [node_name node]) (case node - (<tag> _) - (#.Some (format path separator node_name)) + {<tag> _} + {#.Some (format path separator node_name)} _ #.None))))))))))] @@ -1304,13 +1304,13 @@ [[name file] (..retrieve_mock_file! separator origin |store|) |store| (..delete_mock_node! separator origin |store|)] (..update_mock_file! separator destination (value@ #mock_last_modified file) (value@ #mock_content file) |store|)) - (#try.Success |store|) + {#try.Success |store|} (do ! [_ (stm.write |store| store)] - (in (#try.Success []))) + (in {#try.Success []})) - (#try.Failure error) - (in (#try.Failure error)))))) + {#try.Failure error} + (in {#try.Failure error}))))) )))) (def: (check_or_make_directory monad fs path) @@ -1318,7 +1318,7 @@ (do monad [? (\ fs directory? path)] (if ? - (in (#try.Success [])) + (in {#try.Success []}) (\ fs make_directory path)))) (def: .public (make_directories monad fs path) @@ -1331,7 +1331,7 @@ #.End (\ monad in (exception.except ..cannot_make_directory [path])) - (#.Item head tail) + {#.Item head tail} (case head "" (\ monad in (exception.except ..cannot_make_directory [path])) _ (loop [current (if rooted? @@ -1341,17 +1341,17 @@ (do monad [? (..check_or_make_directory monad fs current)] (case ? - (#try.Success _) + {#try.Success _} (case next #.End - (in (#try.Success [])) + (in {#try.Success []}) - (#.Item head tail) + {#.Item head tail} (recur (format current (\ fs separator) head) tail)) - (#try.Failure error) - (in (#try.Failure error))))))))) + {#try.Failure error} + (in {#try.Failure error})))))))) (def: .public (make_file monad fs content path) (All (_ !) (-> (Monad !) (System !) Binary Path (! (Try Any)))) diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index 3af235af1..46308d6e3 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -112,7 +112,7 @@ (do [! stm.monad] [@tracker (stm.read tracker)] (case (dictionary.value path @tracker) - (#.Some [old_concern last_modified]) + {#.Some [old_concern last_modified]} (do ! [_ (stm.update (dictionary.has path [new_concern last_modified]) tracker)] (in true)) @@ -196,20 +196,20 @@ (do ! [updated? (stm.commit! (..update_watch! new_concern path tracker))] (if updated? - (in (#try.Success [])) + (in {#try.Success []}) (do (try.with !) [file_tracker (..file_tracker fs path)] (do ! [_ (stm.commit! (stm.update (dictionary.has path [new_concern file_tracker]) tracker))] - (in (#try.Success [])))))) + (in {#try.Success []}))))) (in (exception.except ..cannot_poll_a_non_existent_directory [path]))))) (def: (concern path) (stm.commit! (do stm.monad [@tracker (stm.read tracker)] (in (case (dictionary.value path @tracker) - (#.Some [concern file_tracker]) - (#try.Success concern) + {#.Some [concern file_tracker]} + {#try.Success concern} #.None (exception.except ..not_being_watched [path])))))) @@ -218,10 +218,10 @@ (do [! stm.monad] [@tracker (stm.read tracker)] (case (dictionary.value path @tracker) - (#.Some [concern file_tracker]) + {#.Some [concern file_tracker]} (do ! [_ (stm.update (dictionary.lacks path) tracker)] - (in (#try.Success concern))) + (in {#try.Success concern})) #.None (in (exception.except ..not_being_watched [path])))))) @@ -237,7 +237,7 @@ (list\each product.left) (dictionary.of_list text.hash)) tracker))] - (in (#try.Success []))) + (in {#try.Success []})) .let [[creations modifications deletions] (list\mix (function (_ [_ [creations modifications deletions]] [all_creations all_modifications all_deletions]) @@ -278,8 +278,8 @@ output #.End] (if (n.< size idx) (recur (++ idx) - (#.Item (java/util/List::get (.int idx) list) - output)) + {#.Item (java/util/List::get (.int idx) list) + output}) output)))) (import: (java/nio/file/WatchEvent$Kind a)) @@ -375,7 +375,7 @@ (do (try.with io.monad) [?key (java/nio/file/WatchService::poll watcher)] (case ?key - (#.Some key) + {#.Some key} (do [! io.monad] [valid? (java/nio/file/WatchKey::reset key)] (if valid? @@ -386,8 +386,8 @@ java/nio/file/Path::toString (:as //.Path))] concern (..default_key_concern key)] - (recur (#.Item [concern path] - output))) + (recur {#.Item [concern path] + output})) (recur output))) #.None @@ -420,12 +420,12 @@ (do [! async.monad] [@tracker (stm.commit! (stm.read tracker))] (case (dictionary.value path @tracker) - (#.Some [concern key]) + {#.Some [concern key]} (do ! [_ (async.future (java/nio/file/WatchKey::cancel key)) _ (stm.commit! (stm.update (dictionary.lacks path) tracker))] - (in (#try.Success concern))) + (in {#try.Success concern})) #.None (in (exception.except ..not_being_watched [path]))))))]] @@ -441,13 +441,13 @@ path)] (do async.monad [_ (stm.commit! (stm.update (dictionary.has path [concern key]) tracker))] - (in (#try.Success [])))))) + (in {#try.Success []}))))) (def: (concern path) (do async.monad [@tracker (stm.commit! (stm.read tracker))] (case (dictionary.value path @tracker) - (#.Some [concern key]) - (in (#try.Success concern)) + {#.Some [concern key]} + (in {#try.Success concern}) #.None (in (exception.except ..not_being_watched [path]))))) diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux index c5af6d11f..472c49a52 100644 --- a/stdlib/source/library/lux/world/net/http/client.lux +++ b/stdlib/source/library/lux/world/net/http/client.lux @@ -172,7 +172,7 @@ (do [! (try.with io.monad)] [?name (java/net/URLConnection::getHeaderFieldKey index connection)] (case ?name - (#.Some name) + {#.Some name} (do ! [?value (java/net/URLConnection::getHeaderField index connection)] (recur (++ index) @@ -194,7 +194,7 @@ (java/net/URLConnection::setRequestProperty name value connection)) (dictionary.entries headers)) _ (case data - (#.Some data) + {#.Some data} (do ! [_ (java/net/URLConnection::setDoOutput true connection) stream (java/net/URLConnection::getOutputStream connection) @@ -224,14 +224,14 @@ (|> (\ client request method url headers data) async.future (\ async.monad each - (|>> (case> (#try.Success [status message]) - (#try.Success [status (revised@ #//.body (: (-> (//.Body IO) (//.Body Async)) + (|>> (case> {#try.Success [status message]} + {#try.Success [status (revised@ #//.body (: (-> (//.Body IO) (//.Body Async)) (function (_ body) (|>> body async.future))) - message)]) + message)]} - (#try.Failure error) - (#try.Failure error))))))) + {#try.Failure error} + {#try.Failure error})))))) (def: .public headers (-> (List [Text Text]) //.Headers) diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index 9ab4b1d32..c6185bc09 100644 --- a/stdlib/source/library/lux/world/net/http/request.lux +++ b/stdlib/source/library/lux/world/net/http/request.lux @@ -61,10 +61,10 @@ [raw ?raw content (\ json.codec decoded raw)] (json.result content reader)) - (#try.Success input) + {#try.Success input} (server input request) - (#try.Failure error) + {#try.Failure error} (async.resolved ..failure))))) (def: .public (text server) @@ -73,10 +73,10 @@ (do async.monad [?raw (read_text_body (value@ #//.body message))] (case ?raw - (#try.Success content) + {#try.Success content} (server content request) - (#try.Failure error) + {#try.Failure error} (async.resolved ..failure))))) (def: .public (query property server) @@ -91,10 +91,10 @@ input (context.result query property)] (in [[identification protocol (with@ #//.uri uri resource) message] input])) - (#try.Success [request input]) + {#try.Success [request input]} (server input request) - (#try.Failure error) + {#try.Failure error} (async.resolved ..failure))))) (def: .public (form property server) @@ -106,10 +106,10 @@ [body ?body form (//query.parameters body)] (context.result form property)) - (#try.Success input) + {#try.Success input} (server input request) - (#try.Failure error) + {#try.Failure error} (async.resolved ..failure))))) (def: .public (cookies property server) @@ -121,8 +121,8 @@ (maybe.else "") //cookie.get)] (context.result cookies property)) - (#try.Success input) + {#try.Success input} (server input request) - (#try.Failure error) + {#try.Failure error} (async.resolved ..failure)))) diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index feb95fff9..eb0fe35cf 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -62,10 +62,10 @@ (in (|> entries (list.all (function (_ [name value]) (case value - (#try.Success value) - (#.Some [name value]) + {#try.Success value} + {#.Some [name value]} - (#try.Failure _) + {#try.Failure _} #.None))) (dictionary.of_list text.hash))))) @@ -97,8 +97,8 @@ (function.constant (io.io (dictionary.keys environment)))) (def: (variable name) (io.io (case (dictionary.value name environment) - (#.Some value) - (#try.Success value) + {#.Some value} + {#try.Success value} #.None (exception.except ..unknown_environment_variable [name])))) @@ -137,8 +137,8 @@ (def: (jvm\\consume iterator) (All (_ a) (-> (java/util/Iterator a) (List a))) (if (java/util/Iterator::hasNext iterator) - (#.Item (java/util/Iterator::next iterator) - (jvm\\consume iterator)) + {#.Item (java/util/Iterator::next iterator) + (jvm\\consume iterator)} #.End)) )] (for [@.old (as_is <jvm>) @@ -155,7 +155,7 @@ (def: (exit_node_js! code) (-> Exit (IO Nothing)) (case (ffi.constant ..NodeJs_Process [process]) - (#.Some process) + {#.Some process} (NodeJs_Process::exit (i.frac code) process) #.None @@ -173,18 +173,18 @@ (-> Exit (IO Nothing)) (case [(ffi.constant ..Browser_Window [window]) (ffi.constant ..Browser_Location [location])] - [(#.Some window) (#.Some location)] + [{#.Some window} {#.Some location}] (exec (Browser_Window::close [] window) (Browser_Location::reload [] location) (..default_exit! code)) - [(#.Some window) #.None] + [{#.Some window} #.None] (exec (Browser_Window::close [] window) (..default_exit! code)) - [#.None (#.Some location)] + [#.None {#.Some location}] (exec (Browser_Location::reload [] location) (..default_exit! code)) @@ -213,9 +213,9 @@ (def: (require _) (-> [] (-> ffi.String Any)) (case [(normal_require []) (global_require []) (process_load [])] - (^or [(#.Some require) _ _] - [_ (#.Some require) _] - [_ _ (#.Some require)]) + (^or [{#.Some require} _ _] + [_ {#.Some require} _] + [_ _ {#.Some require}]) require _ @@ -247,9 +247,9 @@ (do [! io.monad] [outcome (io/popen [command])] (case outcome - (#try.Success outcome) + {#try.Success outcome} (case outcome - (#.Some file) + {#.Some file} (do ! [?output (LuaFile::read ["*l"] file) _ (LuaFile::close [] file)] @@ -258,7 +258,7 @@ #.None (in default)) - (#try.Failure _) + {#try.Failure _} (in default))))) @.ruby (as_is (ffi.import: Env "as" RubyEnv ["[1]::[0]" @@ -314,7 +314,7 @@ @.jvm <jvm> @.js (io.io (if ffi.on_node_js? (case (ffi.constant Object [process env]) - (#.Some process/env) + {#.Some process/env} (|> (Object::entries [process/env]) (array.list #.None) (list\each (|>> (array.read! 0) maybe.trusted))) @@ -352,8 +352,8 @@ [(do io.monad [value (<method> name)] (in (case value - (#.Some value) - (#try.Success value) + {#.Some value} + {#try.Success value} #.None (exception.except ..unknown_environment_variable [name]))))]] @@ -365,8 +365,8 @@ [process/env (ffi.constant Object [process env])] (array.read! (:as Nat name) (:as (Array Text) process/env))) - (#.Some value) - (#try.Success value) + {#.Some value} + {#try.Success value} #.None (exception.except ..unknown_environment_variable [name])) @@ -407,7 +407,7 @@ @.jvm <jvm> @.js (if ffi.on_node_js? (case (ffi.constant ..NodeJs_Process [process]) - (#.Some process) + {#.Some process} (NodeJs_Process::cwd [] process) #.None diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index 5c0fdfbc7..3fd76261b 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -249,7 +249,7 @@ (do ! [output (java/io/BufferedReader::readLine <stream>)] (case output - (#.Some output) + {#.Some output} (in output) #.None @@ -331,13 +331,13 @@ (do [! io.monad] [|state| (atom.read! state)] (case (\ mock <mock> |state|) - (#try.Success [|state| output]) + {#try.Success [|state| output]} (do ! [_ (atom.write! |state| state)] - (in (#try.Success output))) + (in {#try.Success output})) - (#try.Failure error) - (in (#try.Failure error)))))] + {#try.Failure error} + (in {#try.Failure error}))))] [read on_read] [error on_error] @@ -347,24 +347,24 @@ (do [! io.monad] [|state| (atom.read! state)] (case (\ mock on_write message |state|) - (#try.Success |state|) + {#try.Success |state|} (do ! [_ (atom.write! |state| state)] - (in (#try.Success []))) + (in {#try.Success []})) - (#try.Failure error) - (in (#try.Failure error))))) + {#try.Failure error} + (in {#try.Failure error})))) (def: (destroy _) (do [! io.monad] [|state| (atom.read! state)] (case (\ mock on_destroy |state|) - (#try.Success |state|) + {#try.Success |state|} (do ! [_ (atom.write! |state| state)] - (in (#try.Success []))) + (in {#try.Success []})) - (#try.Failure error) - (in (#try.Failure error))))))) + {#try.Failure error} + (in {#try.Failure error})))))) (implementation: .public (mock mock init) (All (_ s) |