diff options
Diffstat (limited to '')
148 files changed, 1672 insertions, 1521 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 881848963..9f2b0a697 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -52,14 +52,14 @@ #1) ## (type: (List a) -## #Nil -## (#Cons a (List a))) +## #End +## (#Item a (List a))) ("lux def type tagged" List (9 #1 ["library/lux" "List"] (7 #0 (0 #0) - (1 #0 ## "lux.Nil" + (1 #0 ## "lux.End" Any - ## "lux.Cons" + ## "lux.Item" (2 #0 (4 #0 1) (9 #0 (4 #0 1) (4 #0 0)))))) [dummy_location @@ -68,82 +68,82 @@ (0 #1 [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "A potentially empty list of values.")]] (0 #0))))] - ["Nil" "Cons"] + ["End" "Item"] #1) ("lux def" Bit ("lux type check type" (9 #1 ["library/lux" "Bit"] - (0 #0 "#Bit" #Nil))) + (0 #0 "#Bit" #End))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "doc"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "Your standard, run-of-the-mill boolean values (as bits).")]] - #Nil))] + #End))] #1) ("lux def" I64 ("lux type check type" (9 #1 ["library/lux" "I64"] (7 #0 (0 #0) - (0 #0 "#I64" (#Cons (4 #0 1) #Nil))))) + (0 #0 "#I64" (#Item (4 #0 1) #End))))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "doc"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "64-bit integers without any semantics.")]] - #Nil))] + #End))] #1) ("lux def" Nat ("lux type check type" (9 #1 ["library/lux" "Nat"] - (0 #0 "#I64" (#Cons (0 #0 "#Nat" #Nil) #Nil)))) + (0 #0 "#I64" (#Item (0 #0 "#Nat" #End) #End)))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "doc"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 ("lux text concat" ("lux text concat" "Natural numbers (unsigned integers)." __paragraph) "They start at zero (0) and extend in the positive direction."))]] - #Nil))] + #End))] #1) ("lux def" Int ("lux type check type" (9 #1 ["library/lux" "Int"] - (0 #0 "#I64" (#Cons (0 #0 "#Int" #Nil) #Nil)))) + (0 #0 "#I64" (#Item (0 #0 "#Int" #End) #End)))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "doc"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "Your standard, run-of-the-mill integer numbers.")]] - #Nil))] + #End))] #1) ("lux def" Rev ("lux type check type" (9 #1 ["library/lux" "Rev"] - (0 #0 "#I64" (#Cons (0 #0 "#Rev" #Nil) #Nil)))) + (0 #0 "#I64" (#Item (0 #0 "#Rev" #End) #End)))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "doc"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 ("lux text concat" ("lux text concat" "Fractional numbers that live in the interval [0,1)." __paragraph) "Useful for probability, and other domains that work within that interval."))]] - #Nil))] + #End))] #1) ("lux def" Frac ("lux type check type" (9 #1 ["library/lux" "Frac"] - (0 #0 "#Frac" #Nil))) + (0 #0 "#Frac" #End))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "doc"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "Your standard, run-of-the-mill floating-point (fractional) numbers.")]] - #Nil))] + #End))] #1) ("lux def" Text ("lux type check type" (9 #1 ["library/lux" "Text"] - (0 #0 "#Text" #Nil))) + (0 #0 "#Text" #End))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "doc"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "Your standard, run-of-the-mill string values.")]] - #Nil))] + #End))] #1) ("lux def" Name @@ -151,9 +151,9 @@ (9 #1 ["library/lux" "Name"] (2 #0 Text Text))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "doc"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "A name. It is used as part of Lux syntax to represent identifiers and tags.")]] - #Nil))] + #End))] #1) ## (type: (Maybe a) @@ -161,17 +161,17 @@ ## (#Some a)) ("lux def type tagged" Maybe (9 #1 ["library/lux" "Maybe"] - (7 #0 #Nil + (7 #0 #End (1 #0 ## "lux.None" Any ## "lux.Some" (4 #0 1)))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "type-args"])] - [dummy_location (9 #0 (#Cons [dummy_location (5 #0 "a")] #Nil))]] - (#Cons [[dummy_location (7 #0 ["library/lux" "doc"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type-args"])] + [dummy_location (9 #0 (#Item [dummy_location (5 #0 "a")] #End))]] + (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "A potentially missing value.")]] - #Nil)))] + #End)))] ["None" "Some"] #1) @@ -194,7 +194,7 @@ ({Type_List ({Type_Pair (9 #0 Nothing - (7 #0 #Nil + (7 #0 #End (1 #0 ## "lux.Primitive" (2 #0 Text Type_List) (1 #0 ## "lux.Sum" @@ -221,11 +221,11 @@ ("lux type check type" (9 #0 Type List)))} ("lux type check type" (9 #0 (4 #0 1) (4 #0 0))))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "doc"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "This type represents the data-structures that are used to specify types themselves.")]] - (#Cons [[dummy_location (7 #0 ["library/lux" "type-rec?"])] + (#Item [[dummy_location (7 #0 ["library/lux" "type-rec?"])] [dummy_location (0 #0 #1)]] - #Nil)))] + #End)))] ["Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"] #1) @@ -237,9 +237,9 @@ (#Named ["library/lux" "Location"] (#Product Text (#Product Nat Nat))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "doc"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "Locations are for specifying the location of Code nodes in Lux files during compilation.")]] - #Nil))] + #End))] ["module" "line" "column"] #1) @@ -248,16 +248,16 @@ ## #datum v}) ("lux def type tagged" Ann (#Named ["library/lux" "Ann"] - (#UnivQ #Nil - (#UnivQ #Nil + (#UnivQ #End + (#UnivQ #End (#Product (#Parameter 3) (#Parameter 1))))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "doc"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "The type of things that can be annotated with meta-data of arbitrary types.")]] - (#Cons [[dummy_location (7 #0 ["library/lux" "type-args"])] - [dummy_location (9 #0 (#Cons [dummy_location (5 #0 "m")] (#Cons [dummy_location (5 #0 "v")] #Nil)))]] - #Nil)))] + (#Item [[dummy_location (7 #0 ["library/lux" "type-args"])] + [dummy_location (9 #0 (#Item [dummy_location (5 #0 "m")] (#Item [dummy_location (5 #0 "v")] #End)))]] + #End)))] ["meta" "datum"] #1) @@ -277,7 +277,7 @@ (#Named ["library/lux" "Code'"] ({Code ({Code_List - (#UnivQ #Nil + (#UnivQ #End (#Sum ## "lux.Bit" Bit (#Sum ## "lux.Nat" @@ -307,9 +307,9 @@ (#Parameter 0)) (#Parameter 1))))) [dummy_location - (9 #1 (#Cons [[dummy_location (7 #0 ["library/lux" "type-args"])] - [dummy_location (9 #0 (#Cons [dummy_location (5 #0 "w")] #Nil))]] - #Nil))] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type-args"])] + [dummy_location (9 #0 (#Item [dummy_location (5 #0 "w")] #End))]] + #End))] ["Bit" "Nat" "Int" "Rev" "Frac" "Text" "Identifier" "Tag" "Form" "Tuple" "Record"] #1) @@ -321,9 +321,9 @@ (#Apply (#Apply w Code') w)} ("lux type check type" (#Apply Location Ann)))) [dummy_location - (#Record (#Cons [[dummy_location (#Tag ["library/lux" "doc"])] + (#Record (#Item [[dummy_location (#Tag ["library/lux" "doc"])] [dummy_location (#Text "The type of Code nodes for Lux syntax.")]] - #Nil))] + #End))] #1) ("lux def" _ann @@ -333,85 +333,85 @@ Code) ([_ data] [dummy_location data])) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" bit$ ("lux type check" (#Function Bit Code) ([_ value] (_ann (#Bit value)))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" nat$ ("lux type check" (#Function Nat Code) ([_ value] (_ann (#Nat value)))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" int$ ("lux type check" (#Function Int Code) ([_ value] (_ann (#Int value)))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" rev$ ("lux type check" (#Function Rev Code) ([_ value] (_ann (#Rev value)))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" frac$ ("lux type check" (#Function Frac Code) ([_ value] (_ann (#Frac value)))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" text$ ("lux type check" (#Function Text Code) ([_ text] (_ann (#Text text)))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" identifier$ ("lux type check" (#Function Name Code) ([_ name] (_ann (#Identifier name)))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" local_identifier$ ("lux type check" (#Function Text Code) ([_ name] (_ann (#Identifier ["" name])))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" tag$ ("lux type check" (#Function Name Code) ([_ name] (_ann (#Tag name)))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" local_tag$ ("lux type check" (#Function Text Code) ([_ name] (_ann (#Tag ["" name])))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" form$ ("lux type check" (#Function (#Apply Code List) Code) ([_ tokens] (_ann (#Form tokens)))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" tuple$ ("lux type check" (#Function (#Apply Code List) Code) ([_ tokens] (_ann (#Tuple tokens)))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ("lux def" record$ ("lux type check" (#Function (#Apply (#Product Code Code) List) Code) ([_ tokens] (_ann (#Record tokens)))) - [dummy_location (#Record #Nil)] + [dummy_location (#Record #End)] #0) ## (type: Definition @@ -420,9 +420,9 @@ ("lux type check type" (#Named ["library/lux" "Definition"] (#Product Bit (#Product Type (#Product Code Any))))) - (record$ (#Cons [(tag$ ["library/lux" "doc"]) + (record$ (#Item [(tag$ ["library/lux" "doc"]) (text$ "Represents all the data associated with a definition: its type, its annotations, and its value.")] - #Nil)) + #End)) #1) ## (type: Alias @@ -431,7 +431,7 @@ ("lux type check type" (#Named ["library/lux" "Alias"] Name)) - (record$ #Nil) + (record$ #End) #1) ## (type: Global @@ -441,9 +441,9 @@ (#Named ["library/lux" "Global"] (#Sum Alias Definition)) - (record$ (#Cons [(tag$ ["library/lux" "doc"]) + (record$ (#Item [(tag$ ["library/lux" "doc"]) (text$ "Represents all the data associated with a global constant.")] - #Nil)) + #End)) ["Alias" "Definition"] #1) @@ -452,17 +452,17 @@ ## #mappings (List [k v])}) ("lux def type tagged" Bindings (#Named ["library/lux" "Bindings"] - (#UnivQ #Nil - (#UnivQ #Nil + (#UnivQ #End + (#UnivQ #End (#Product ## "lux.counter" Nat ## "lux.mappings" (#Apply (#Product (#Parameter 3) (#Parameter 1)) List))))) - (record$ (#Cons [(tag$ ["library/lux" "type-args"]) - (tuple$ (#Cons (text$ "k") (#Cons (text$ "v") #Nil)))] - #Nil)) + (record$ (#Item [(tag$ ["library/lux" "type-args"]) + (tuple$ (#Item (text$ "k") (#Item (text$ "v") #End)))] + #End)) ["counter" "mappings"] #1) @@ -475,7 +475,7 @@ Nat ## Captured Nat)) - (record$ #Nil) + (record$ #End) ["Local" "Captured"] #1) @@ -494,14 +494,14 @@ (#Apply (#Product Type Nat) (#Apply Text Bindings)) ## captured (#Apply (#Product Type Ref) (#Apply Text Bindings)))))) - (record$ #Nil) + (record$ #End) ["name" "inner" "locals" "captured"] #1) ("lux def" Code_List ("lux type check type" (#Apply Code List)) - (record$ #Nil) + (record$ #End) #0) ## (type: (Either l r) @@ -509,17 +509,17 @@ ## (#Right r)) ("lux def type tagged" Either (#Named ["library/lux" "Either"] - (#UnivQ #Nil - (#UnivQ #Nil + (#UnivQ #End + (#UnivQ #End (#Sum ## "lux.Left" (#Parameter 3) ## "lux.Right" (#Parameter 1))))) - (record$ (#Cons [(tag$ ["library/lux" "type-args"]) - (tuple$ (#Cons (text$ "l") (#Cons (text$ "r") #Nil)))] - (#Cons [(tag$ ["library/lux" "doc"]) + (record$ (#Item [(tag$ ["library/lux" "type-args"]) + (tuple$ (#Item (text$ "l") (#Item (text$ "r") #End)))] + (#Item [(tag$ ["library/lux" "doc"]) (text$ "A choice between two values of different types.")] - #Nil))) + #End))) ["Left" "Right"] #1) @@ -529,7 +529,7 @@ ("lux type check type" (#Named ["library/lux" "Source"] (#Product Location (#Product Nat Text)))) - (record$ #Nil) + (record$ #End) #1) ## (type: Module_State @@ -546,7 +546,7 @@ Any ## #Cached Any))) - (record$ #Nil) + (record$ #End) ["Active" "Compiled" "Cached"] #1) @@ -586,9 +586,9 @@ (#Apply Code Maybe) Module_State)) )))))) - (record$ (#Cons [(tag$ ["library/lux" "doc"]) + (record$ (#Item [(tag$ ["library/lux" "doc"]) (text$ "All the information contained within a Lux module.")] - #Nil)) + #End)) ["module_hash" "module_aliases" "definitions" "imports" "tags" "types" "module_annotations" "module_state"] #1) @@ -605,7 +605,7 @@ ## var_bindings (#Apply (#Product Nat (#Apply Type Maybe)) List)))) - (record$ #Nil) + (record$ #End) ["ex_counter" "var_counter" "var_bindings"] #1) @@ -621,9 +621,9 @@ Any ## Interpreter Any))) - (record$ (#Cons [(tag$ ["library/lux" "doc"]) + (record$ (#Item [(tag$ ["library/lux" "doc"]) (text$ "A sign that shows the conditions under which the compiler is running.")] - #Nil)) + #End)) ["Build" "Eval" "Interpreter"] #1) @@ -641,9 +641,9 @@ Text ## mode Mode))) - (record$ (#Cons [(tag$ ["library/lux" "doc"]) + (record$ (#Item [(tag$ ["library/lux" "doc"]) (text$ "Information about the current version and type of compiler that is running.")] - #Nil)) + #End)) ["target" "version" "mode"] #1) @@ -686,13 +686,13 @@ Any ## "lux.host" Any)))))))))))) - (record$ (#Cons [(tag$ ["library/lux" "doc"]) + (record$ (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "Represents the state of the Lux compiler during a run." __paragraph) ("lux text concat" ("lux text concat" "It is provided to macros during their invocation, so they can access compiler data." __paragraph) "Caveat emptor: Avoid fiddling with it, unless you know what you're doing.")))] - #Nil)) + #End)) ["info" "source" "location" "current_module" "modules" "scopes" "type_context" "expected" "seed" "scope_type_vars" "extensions" "host"] #1) @@ -701,17 +701,17 @@ ("lux def" Meta ("lux type check type" (#Named ["library/lux" "Meta"] - (#UnivQ #Nil + (#UnivQ #End (#Function Lux (#Apply (#Product Lux (#Parameter 1)) (#Apply Text Either)))))) - (record$ (#Cons [(tag$ ["library/lux" "doc"]) + (record$ (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "Computations that can have access to the state of the compiler." __paragraph) "These computations may fail, or modify the state of the compiler."))] - (#Cons [(tag$ ["library/lux" "type-args"]) - (tuple$ (#Cons (text$ "a") #Nil))] - #Nil))) + (#Item [(tag$ ["library/lux" "type-args"]) + (tuple$ (#Item (text$ "a") #End))] + #End))) #1) ## (type: Macro' @@ -720,7 +720,7 @@ ("lux type check type" (#Named ["library/lux" "Macro'"] (#Function Code_List (#Apply Code_List Meta)))) - (record$ #Nil) + (record$ #End) #1) ## (type: Macro @@ -728,16 +728,16 @@ ("lux def" Macro ("lux type check type" (#Named ["library/lux" "Macro"] - (#Primitive "#Macro" #Nil))) - (record$ (#Cons [(tag$ ["library/lux" "doc"]) + (#Primitive "#Macro" #End))) + (record$ (#Item [(tag$ ["library/lux" "doc"]) (text$ "Functions that run at compile-time and allow you to transform and extend the language in powerful ways.")] - #Nil)) + #End)) #1) ## Base functions & macros ("lux def" return ("lux type check" - (#UnivQ #Nil + (#UnivQ #End (#Function (#Parameter 1) (#Function Lux (#Apply (#Product Lux @@ -746,12 +746,12 @@ ([_ val] ([_ state] (#Right state val)))) - (record$ #Nil) + (record$ #End) #0) ("lux def" failure ("lux type check" - (#UnivQ #Nil + (#UnivQ #End (#Function Text (#Function Lux (#Apply (#Product Lux @@ -760,266 +760,266 @@ ([_ msg] ([_ state] (#Left msg)))) - (record$ #Nil) + (record$ #End) #0) ("lux def" let'' ("lux macro" ([_ tokens] - ({(#Cons lhs (#Cons rhs (#Cons body #Nil))) - (return (#Cons (form$ (#Cons (record$ (#Cons [lhs body] #Nil)) (#Cons rhs #Nil))) - #Nil)) + ({(#Item lhs (#Item rhs (#Item body #End))) + (return (#Item (form$ (#Item (record$ (#Item [lhs body] #End)) (#Item rhs #End))) + #End)) _ (failure "Wrong syntax for let''")} tokens))) - (record$ #.Nil) + (record$ #.End) #0) ("lux def" function'' ("lux macro" ([_ tokens] - ({(#Cons [_ (#Tuple (#Cons arg args'))] (#Cons body #Nil)) - (return (#Cons (_ann (#Form (#Cons (_ann (#Tuple (#Cons (_ann (#Identifier ["" ""])) - (#Cons arg #Nil)))) - (#Cons ({#Nil + ({(#Item [_ (#Tuple (#Item arg args'))] (#Item body #End)) + (return (#Item (_ann (#Form (#Item (_ann (#Tuple (#Item (_ann (#Identifier ["" ""])) + (#Item arg #End)))) + (#Item ({#End body _ - (_ann (#Form (#Cons (_ann (#Identifier ["library/lux" "function''"])) - (#Cons (_ann (#Tuple args')) - (#Cons body #Nil)))))} + (_ann (#Form (#Item (_ann (#Identifier ["library/lux" "function''"])) + (#Item (_ann (#Tuple args')) + (#Item body #End)))))} args') - #Nil)))) - #Nil)) + #End)))) + #End)) - (#Cons [_ (#Identifier ["" self])] (#Cons [_ (#Tuple (#Cons arg args'))] (#Cons body #Nil))) - (return (#Cons (_ann (#Form (#Cons (_ann (#Tuple (#Cons (_ann (#Identifier ["" self])) - (#Cons arg #Nil)))) - (#Cons ({#Nil + (#Item [_ (#Identifier ["" self])] (#Item [_ (#Tuple (#Item arg args'))] (#Item body #End))) + (return (#Item (_ann (#Form (#Item (_ann (#Tuple (#Item (_ann (#Identifier ["" self])) + (#Item arg #End)))) + (#Item ({#End body _ - (_ann (#Form (#Cons (_ann (#Identifier ["library/lux" "function''"])) - (#Cons (_ann (#Tuple args')) - (#Cons body #Nil)))))} + (_ann (#Form (#Item (_ann (#Identifier ["library/lux" "function''"])) + (#Item (_ann (#Tuple args')) + (#Item body #End)))))} args') - #Nil)))) - #Nil)) + #End)))) + #End)) _ (failure "Wrong syntax for function''")} tokens))) - (record$ #.Nil) + (record$ #.End) #0) ("lux def" location_code ("lux type check" Code - (tuple$ (#Cons (text$ "") (#Cons (nat$ 0) (#Cons (nat$ 0) #Nil))))) - (record$ #Nil) + (tuple$ (#Item (text$ "") (#Item (nat$ 0) (#Item (nat$ 0) #End))))) + (record$ #End) #0) ("lux def" meta_code ("lux type check" (#Function Name (#Function Code Code)) ([_ tag] ([_ value] - (tuple$ (#Cons location_code - (#Cons (form$ (#Cons (tag$ tag) (#Cons value #Nil))) - #Nil)))))) - (record$ #Nil) + (tuple$ (#Item location_code + (#Item (form$ (#Item (tag$ tag) (#Item value #End))) + #End)))))) + (record$ #End) #0) ("lux def" flag_meta ("lux type check" (#Function Text Code) ([_ tag] - (tuple$ (#Cons [(meta_code ["library/lux" "Tag"] (tuple$ (#Cons (text$ "library/lux") (#Cons (text$ tag) #Nil)))) - (#Cons [(meta_code ["library/lux" "Bit"] (bit$ #1)) - #Nil])])))) - (record$ #Nil) + (tuple$ (#Item [(meta_code ["library/lux" "Tag"] (tuple$ (#Item (text$ "library/lux") (#Item (text$ tag) #End)))) + (#Item [(meta_code ["library/lux" "Bit"] (bit$ #1)) + #End])])))) + (record$ #End) #0) ("lux def" doc_meta ("lux type check" (#Function Text (#Product Code Code)) (function'' [doc] [(tag$ ["library/lux" "doc"]) (text$ doc)])) - (record$ #Nil) + (record$ #End) #0) ("lux def" as_def ("lux type check" (#Function Code (#Function Code (#Function Code (#Function Bit Code)))) (function'' [name value annotations exported?] - (form$ (#Cons (text$ "lux def") (#Cons name (#Cons value (#Cons annotations (#Cons (bit$ exported?) #Nil)))))))) - (record$ #Nil) + (form$ (#Item (text$ "lux def") (#Item name (#Item value (#Item annotations (#Item (bit$ exported?) #End)))))))) + (record$ #End) #0) ("lux def" as_checked ("lux type check" (#Function Code (#Function Code Code)) (function'' [type value] - (form$ (#Cons (text$ "lux type check") (#Cons type (#Cons value #Nil)))))) - (record$ #Nil) + (form$ (#Item (text$ "lux type check") (#Item type (#Item value #End)))))) + (record$ #End) #0) ("lux def" as_function ("lux type check" (#Function Code (#Function (#Apply Code List) (#Function Code Code))) (function'' [self inputs output] - (form$ (#Cons (identifier$ ["library/lux" "function''"]) - (#Cons self - (#Cons (tuple$ inputs) - (#Cons output #Nil))))))) - (record$ #Nil) + (form$ (#Item (identifier$ ["library/lux" "function''"]) + (#Item self + (#Item (tuple$ inputs) + (#Item output #End))))))) + (record$ #End) #0) ("lux def" as_macro ("lux type check" (#Function Code Code) (function'' [expression] - (form$ (#Cons (text$ "lux macro") - (#Cons expression - #Nil))))) - (record$ #Nil) + (form$ (#Item (text$ "lux macro") + (#Item expression + #End))))) + (record$ #End) #0) ("lux def" def:'' ("lux macro" (function'' [tokens] - ({(#Cons [[_ (#Tag ["" "export"])] - (#Cons [[_ (#Form (#Cons [name args]))] - (#Cons [meta (#Cons [type (#Cons [body #Nil])])])])]) - (return (#Cons [(as_def name (as_checked type (as_function name args body)) - (form$ (#Cons (identifier$ ["library/lux" "record$"]) - (#Cons meta - #Nil))) + ({(#Item [[_ (#Tag ["" "export"])] + (#Item [[_ (#Form (#Item [name args]))] + (#Item [meta (#Item [type (#Item [body #End])])])])]) + (return (#Item [(as_def name (as_checked type (as_function name args body)) + (form$ (#Item (identifier$ ["library/lux" "record$"]) + (#Item meta + #End))) #1) - #Nil])) + #End])) - (#Cons [[_ (#Tag ["" "export"])] (#Cons [name (#Cons [meta (#Cons [type (#Cons [body #Nil])])])])]) - (return (#Cons [(as_def name (as_checked type body) - (form$ (#Cons (identifier$ ["library/lux" "record$"]) - (#Cons meta - #Nil))) + (#Item [[_ (#Tag ["" "export"])] (#Item [name (#Item [meta (#Item [type (#Item [body #End])])])])]) + (return (#Item [(as_def name (as_checked type body) + (form$ (#Item (identifier$ ["library/lux" "record$"]) + (#Item meta + #End))) #1) - #Nil])) - - (#Cons [[_ (#Form (#Cons [name args]))] - (#Cons [meta (#Cons [type (#Cons [body #Nil])])])]) - (return (#Cons [(as_def name (as_checked type (as_function name args body)) - (form$ (#Cons (identifier$ ["library/lux" "record$"]) - (#Cons meta - #Nil))) + #End])) + + (#Item [[_ (#Form (#Item [name args]))] + (#Item [meta (#Item [type (#Item [body #End])])])]) + (return (#Item [(as_def name (as_checked type (as_function name args body)) + (form$ (#Item (identifier$ ["library/lux" "record$"]) + (#Item meta + #End))) #0) - #Nil])) + #End])) - (#Cons [name (#Cons [meta (#Cons [type (#Cons [body #Nil])])])]) - (return (#Cons [(as_def name (as_checked type body) - (form$ (#Cons (identifier$ ["library/lux" "record$"]) - (#Cons meta - #Nil))) + (#Item [name (#Item [meta (#Item [type (#Item [body #End])])])]) + (return (#Item [(as_def name (as_checked type body) + (form$ (#Item (identifier$ ["library/lux" "record$"]) + (#Item meta + #End))) #0) - #Nil])) + #End])) _ (failure "Wrong syntax for def''")} tokens))) - (record$ #.Nil) + (record$ #.End) #0) ("lux def" macro:' ("lux macro" (function'' [tokens] - ({(#Cons [_ (#Form (#Cons name args))] (#Cons body #Nil)) - (return (#Cons (as_def name (as_macro (as_function name args body)) - (form$ (#Cons (identifier$ ["library/lux" "record$"]) - (#Cons (tag$ ["library/lux" "Nil"]) - #Nil))) + ({(#Item [_ (#Form (#Item name args))] (#Item body #End)) + (return (#Item (as_def name (as_macro (as_function name args body)) + (form$ (#Item (identifier$ ["library/lux" "record$"]) + (#Item (tag$ ["library/lux" "End"]) + #End))) #0) - #Nil)) + #End)) - (#Cons [_ (#Tag ["" "export"])] (#Cons [_ (#Form (#Cons name args))] (#Cons body #Nil))) - (return (#Cons (as_def name (as_macro (as_function name args body)) - (form$ (#Cons (identifier$ ["library/lux" "record$"]) - (#Cons (tag$ ["library/lux" "Nil"]) - #Nil))) + (#Item [_ (#Tag ["" "export"])] (#Item [_ (#Form (#Item name args))] (#Item body #End))) + (return (#Item (as_def name (as_macro (as_function name args body)) + (form$ (#Item (identifier$ ["library/lux" "record$"]) + (#Item (tag$ ["library/lux" "End"]) + #End))) #1) - #Nil)) + #End)) - (#Cons [_ (#Tag ["" "export"])] (#Cons [_ (#Form (#Cons name args))] (#Cons meta_data (#Cons body #Nil)))) - (return (#Cons (as_def name (as_macro (as_function name args body)) - (form$ (#Cons (identifier$ ["library/lux" "record$"]) - (#Cons meta_data - #Nil))) + (#Item [_ (#Tag ["" "export"])] (#Item [_ (#Form (#Item name args))] (#Item meta_data (#Item body #End)))) + (return (#Item (as_def name (as_macro (as_function name args body)) + (form$ (#Item (identifier$ ["library/lux" "record$"]) + (#Item meta_data + #End))) #1) - #Nil)) + #End)) _ (failure "Wrong syntax for macro:'")} tokens))) - (record$ #.Nil) + (record$ #.End) #0) (macro:' #export (comment tokens) - (#Cons [(tag$ ["library/lux" "doc"]) + (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Throws away any code given to it." __paragraph) ("lux text concat" ("lux text concat" "## Great for commenting-out code, while retaining syntax high-lighting and formatting in your text editor." __paragraph) "(comment +1 +2 +3 +4)")))] - #Nil) - (return #Nil)) + #End) + (return #End)) (macro:' ($' tokens) - ({(#Cons x #Nil) + ({(#Item x #End) (return tokens) - (#Cons x (#Cons y xs)) - (return (#Cons (form$ (#Cons (identifier$ ["library/lux" "$'"]) - (#Cons (form$ (#Cons (tag$ ["library/lux" "Apply"]) - (#Cons y (#Cons x #Nil)))) + (#Item x (#Item y xs)) + (return (#Item (form$ (#Item (identifier$ ["library/lux" "$'"]) + (#Item (form$ (#Item (tag$ ["library/lux" "Apply"]) + (#Item y (#Item x #End)))) xs))) - #Nil)) + #End)) _ (failure "Wrong syntax for $'")} tokens)) (def:'' (list\map f xs) - #Nil - (#UnivQ #Nil - (#UnivQ #Nil + #End + (#UnivQ #End + (#UnivQ #End (#Function (#Function (#Parameter 3) (#Parameter 1)) (#Function ($' List (#Parameter 3)) ($' List (#Parameter 1)))))) - ({#Nil - #Nil + ({#End + #End - (#Cons x xs') - (#Cons (f x) (list\map f xs'))} + (#Item x xs') + (#Item (f x) (list\map f xs'))} xs)) (def:'' RepEnv - #Nil + #End Type ($' List (#Product Text Code))) (def:'' (make_env xs ys) - #Nil + #End (#Function ($' List Text) (#Function ($' List Code) RepEnv)) - ({[(#Cons x xs') (#Cons y ys')] - (#Cons [x y] (make_env xs' ys')) + ({[(#Item x xs') (#Item y ys')] + (#Item [x y] (make_env xs' ys')) _ - #Nil} + #End} [xs ys])) (def:'' (text\= reference sample) - #Nil + #End (#Function Text (#Function Text Bit)) ("lux text =" reference sample)) (def:'' (get_rep key env) - #Nil + #End (#Function Text (#Function RepEnv ($' Maybe Code))) - ({#Nil + ({#End #None - (#Cons [k v] env') + (#Item [k v] env') ({#1 (#Some v) @@ -1029,7 +1029,7 @@ env)) (def:'' (replace_syntax reps syntax) - #Nil + #End (#Function RepEnv (#Function Code Code)) ({[_ (#Identifier "" name)] ({(#Some replacement) @@ -1058,7 +1058,7 @@ syntax)) (def:'' (n/* param subject) - (#.Cons (doc_meta "Nat(ural) multiplication.") #.Nil) + (#.Item (doc_meta "Nat(ural) multiplication.") #.End) (#Function Nat (#Function Nat Nat)) ("lux type as" Nat ("lux i64 *" @@ -1066,7 +1066,7 @@ ("lux type as" Int subject)))) (def:'' (update_parameters code) - #Nil + #End (#Function Code Code) ({[_ (#Tuple members)] (tuple$ (list\map update_parameters members)) @@ -1078,8 +1078,8 @@ [name (update_parameters val)]))) pairs)) - [_ (#Form (#Cons [_ (#Tag "library/lux" "Parameter")] (#Cons [_ (#Nat idx)] #Nil)))] - (form$ (#Cons (tag$ ["library/lux" "Parameter"]) (#Cons (nat$ ("lux i64 +" 2 idx)) #Nil))) + [_ (#Form (#Item [_ (#Tag "library/lux" "Parameter")] (#Item [_ (#Nat idx)] #End)))] + (form$ (#Item (tag$ ["library/lux" "Parameter"]) (#Item (nat$ ("lux i64 +" 2 idx)) #End))) [_ (#Form members)] (form$ (list\map update_parameters members)) @@ -1089,51 +1089,51 @@ code)) (def:'' (quantified_args_parser args next) - #Nil + #End ## (-> (List Code) (-> (List Text) (Meta (List Code))) (Meta (List Code))) (#Function ($' List Code) (#Function (#Function ($' List Text) (#Apply ($' List Code) Meta)) (#Apply ($' List Code) Meta) )) - ({#Nil - (next #Nil) + ({#End + (next #End) - (#Cons [_ (#Identifier "" arg_name)] args') - (quantified_args_parser args' (function'' [names] (next (#Cons arg_name names)))) + (#Item [_ (#Identifier "" arg_name)] args') + (quantified_args_parser args' (function'' [names] (next (#Item arg_name names)))) _ (failure "Expected identifier.")} args)) (def:'' (make_parameter idx) - #Nil + #End (#Function Nat Code) - (form$ (#Cons (tag$ ["library/lux" "Parameter"]) (#Cons (nat$ idx) #Nil)))) + (form$ (#Item (tag$ ["library/lux" "Parameter"]) (#Item (nat$ idx) #End)))) (def:'' (list\fold f init xs) - #Nil + #End ## (All [a b] (-> (-> b a a) a (List b) a)) - (#UnivQ #Nil (#UnivQ #Nil (#Function (#Function (#Parameter 1) + (#UnivQ #End (#UnivQ #End (#Function (#Function (#Parameter 1) (#Function (#Parameter 3) (#Parameter 3))) (#Function (#Parameter 3) (#Function ($' List (#Parameter 1)) (#Parameter 3)))))) - ({#Nil + ({#End init - (#Cons x xs') + (#Item x xs') (list\fold f (f x init) xs')} xs)) (def:'' (list\size list) - #Nil - (#UnivQ #Nil + #End + (#UnivQ #End (#Function ($' List (#Parameter 1)) Nat)) (list\fold (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list)) (macro:' #export (All tokens) - (#Cons [(tag$ ["library/lux" "doc"]) + (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Universal quantification." __paragraph) ("lux text concat" @@ -1141,43 +1141,43 @@ ("lux text concat" ("lux text concat" "## A name can be provided, to specify a recursive type." __paragraph) "(All List [a] (| Any [a (List a)]))"))))] - #Nil) - (let'' [self_name tokens] ({(#Cons [_ (#Identifier "" self_name)] tokens) + #End) + (let'' [self_name tokens] ({(#Item [_ (#Identifier "" self_name)] tokens) [self_name tokens] _ ["" tokens]} tokens) - ({(#Cons [_ (#Tuple args)] (#Cons body #Nil)) + ({(#Item [_ (#Tuple args)] (#Item body #End)) (quantified_args_parser args (function'' [names] (let'' body' (list\fold ("lux type check" (#Function Text (#Function Code Code)) (function'' [name' body'] - (form$ (#Cons (tag$ ["library/lux" "UnivQ"]) - (#Cons (tag$ ["library/lux" "Nil"]) - (#Cons (replace_syntax (#Cons [name' (make_parameter 1)] #Nil) - (update_parameters body')) #Nil)))))) + (form$ (#Item (tag$ ["library/lux" "UnivQ"]) + (#Item (tag$ ["library/lux" "End"]) + (#Item (replace_syntax (#Item [name' (make_parameter 1)] #End) + (update_parameters body')) #End)))))) body names) - (return (#Cons ({[#1 _] + (return (#Item ({[#1 _] body' - [_ #Nil] + [_ #End] body' [#0 _] - (replace_syntax (#Cons [self_name (make_parameter (n/* 2 ("lux i64 -" 1 (list\size names))))] - #Nil) + (replace_syntax (#Item [self_name (make_parameter (n/* 2 ("lux i64 -" 1 (list\size names))))] + #End) body')} [(text\= "" self_name) names]) - #Nil))))) + #End))))) _ (failure "Wrong syntax for All")} tokens))) (macro:' #export (Ex tokens) - (#Cons [(tag$ ["library/lux" "doc"]) + (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Existential quantification." __paragraph) ("lux text concat" @@ -1185,93 +1185,93 @@ ("lux text concat" ("lux text concat" "## A name can be provided, to specify a recursive type." __paragraph) "(Ex Self [a] [(Codec Text a) a (List (Self a))])"))))] - #Nil) - (let'' [self_name tokens] ({(#Cons [_ (#Identifier "" self_name)] tokens) + #End) + (let'' [self_name tokens] ({(#Item [_ (#Identifier "" self_name)] tokens) [self_name tokens] _ ["" tokens]} tokens) - ({(#Cons [_ (#Tuple args)] (#Cons body #Nil)) + ({(#Item [_ (#Tuple args)] (#Item body #End)) (quantified_args_parser args (function'' [names] (let'' body' (list\fold ("lux type check" (#Function Text (#Function Code Code)) (function'' [name' body'] - (form$ (#Cons (tag$ ["library/lux" "ExQ"]) - (#Cons (tag$ ["library/lux" "Nil"]) - (#Cons (replace_syntax (#Cons [name' (make_parameter 1)] #Nil) - (update_parameters body')) #Nil)))))) + (form$ (#Item (tag$ ["library/lux" "ExQ"]) + (#Item (tag$ ["library/lux" "End"]) + (#Item (replace_syntax (#Item [name' (make_parameter 1)] #End) + (update_parameters body')) #End)))))) body names) - (return (#Cons ({[#1 _] + (return (#Item ({[#1 _] body' - [_ #Nil] + [_ #End] body' [#0 _] - (replace_syntax (#Cons [self_name (make_parameter (n/* 2 ("lux i64 -" 1 (list\size names))))] - #Nil) + (replace_syntax (#Item [self_name (make_parameter (n/* 2 ("lux i64 -" 1 (list\size names))))] + #End) body')} [(text\= "" self_name) names]) - #Nil))))) + #End))))) _ (failure "Wrong syntax for Ex")} tokens))) (def:'' (list\reverse list) - #Nil + #End (All [a] (#Function ($' List a) ($' List a))) (list\fold ("lux type check" (All [a] (#Function a (#Function ($' List a) ($' List a)))) - (function'' [head tail] (#Cons head tail))) - #Nil + (function'' [head tail] (#Item head tail))) + #End list)) (macro:' #export (-> tokens) - (#Cons [(tag$ ["library/lux" "doc"]) + (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Function types:" __paragraph) ("lux text concat" ("lux text concat" "(-> Int Int Int)" __paragraph) "## This is the type of a function that takes 2 Ints and returns an Int.")))] - #Nil) - ({(#Cons output inputs) - (return (#Cons (list\fold ("lux type check" (#Function Code (#Function Code Code)) - (function'' [i o] (form$ (#Cons (tag$ ["library/lux" "Function"]) (#Cons i (#Cons o #Nil)))))) + #End) + ({(#Item output inputs) + (return (#Item (list\fold ("lux type check" (#Function Code (#Function Code Code)) + (function'' [i o] (form$ (#Item (tag$ ["library/lux" "Function"]) (#Item i (#Item o #End)))))) output inputs) - #Nil)) + #End)) _ (failure "Wrong syntax for ->")} (list\reverse tokens))) (macro:' #export (list xs) - (#Cons [(tag$ ["library/lux" "doc"]) + (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## List-construction macro." __paragraph) "(list +1 +2 +3)"))] - #Nil) - (return (#Cons (list\fold (function'' [head tail] - (form$ (#Cons (tag$ ["library/lux" "Cons"]) - (#Cons (tuple$ (#Cons [head (#Cons [tail #Nil])])) - #Nil)))) - (tag$ ["library/lux" "Nil"]) + #End) + (return (#Item (list\fold (function'' [head tail] + (form$ (#Item (tag$ ["library/lux" "Item"]) + (#Item (tuple$ (#Item [head (#Item [tail #End])])) + #End)))) + (tag$ ["library/lux" "End"]) (list\reverse xs)) - #Nil))) + #End))) (macro:' #export (list& xs) - (#Cons [(tag$ ["library/lux" "doc"]) + (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## List-construction macro, with the last element being a tail-list." __paragraph) ("lux text concat" ("lux text concat" "## In other words, this macro prepends elements to another list." __paragraph) "(list& +1 +2 +3 (list +4 +5 +6))")))] - #Nil) - ({(#Cons last init) + #End) + ({(#Item last init) (return (list (list\fold (function'' [head tail] - (form$ (list (tag$ ["library/lux" "Cons"]) + (form$ (list (tag$ ["library/lux" "Item"]) (tuple$ (list head tail))))) last init))) @@ -1281,7 +1281,7 @@ (list\reverse xs))) (macro:' #export (& tokens) - (#Cons [(tag$ ["library/lux" "doc"]) + (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Tuple types:" __paragraph) ("lux text concat" @@ -1289,18 +1289,18 @@ ("lux text concat" ("lux text concat" "## Any." __paragraph) "(&)"))))] - #Nil) - ({#Nil + #End) + ({#End (return (list (identifier$ ["library/lux" "Any"]))) - (#Cons last prevs) + (#Item last prevs) (return (list (list\fold (function'' [left right] (form$ (list (tag$ ["library/lux" "Product"]) left right))) last prevs)))} (list\reverse tokens))) (macro:' #export (| tokens) - (#Cons [(tag$ ["library/lux" "doc"]) + (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Variant types:" __paragraph) ("lux text concat" @@ -1308,28 +1308,28 @@ ("lux text concat" ("lux text concat" "## Nothing." __paragraph) "(|)"))))] - #Nil) - ({#Nil + #End) + ({#End (return (list (identifier$ ["library/lux" "Nothing"]))) - (#Cons last prevs) + (#Item last prevs) (return (list (list\fold (function'' [left right] (form$ (list (tag$ ["library/lux" "Sum"]) left right))) last prevs)))} (list\reverse tokens))) (macro:' (function' tokens) - (let'' [name tokens'] ({(#Cons [[_ (#Identifier ["" name])] tokens']) + (let'' [name tokens'] ({(#Item [[_ (#Identifier ["" name])] tokens']) [name tokens'] _ ["" tokens]} tokens) - ({(#Cons [[_ (#Tuple args)] (#Cons [body #Nil])]) - ({#Nil + ({(#Item [[_ (#Tuple args)] (#Item [body #End])]) + ({#End (failure "function' requires a non-empty arguments tuple.") - (#Cons [harg targs]) + (#Item [harg targs]) (return (list (form$ (list (tuple$ (list (local_identifier$ name) harg)) (list\fold (function'' [arg body'] @@ -1345,9 +1345,9 @@ tokens'))) (macro:' (def:''' tokens) - ({(#Cons [[_ (#Tag ["" "export"])] - (#Cons [[_ (#Form (#Cons [name args]))] - (#Cons [meta (#Cons [type (#Cons [body #Nil])])])])]) + ({(#Item [[_ (#Tag ["" "export"])] + (#Item [[_ (#Form (#Item [name args]))] + (#Item [meta (#Item [type (#Item [body #End])])])])]) (return (list (form$ (list (text$ "lux def") name (form$ (list (text$ "lux type check") @@ -1356,24 +1356,24 @@ name (tuple$ args) body)))) - (form$ (#Cons (identifier$ ["library/lux" "record$"]) - (#Cons meta - #Nil))) + (form$ (#Item (identifier$ ["library/lux" "record$"]) + (#Item meta + #End))) (bit$ #1))))) - (#Cons [[_ (#Tag ["" "export"])] (#Cons [name (#Cons [meta (#Cons [type (#Cons [body #Nil])])])])]) + (#Item [[_ (#Tag ["" "export"])] (#Item [name (#Item [meta (#Item [type (#Item [body #End])])])])]) (return (list (form$ (list (text$ "lux def") name (form$ (list (text$ "lux type check") type body)) - (form$ (#Cons (identifier$ ["library/lux" "record$"]) - (#Cons meta - #Nil))) + (form$ (#Item (identifier$ ["library/lux" "record$"]) + (#Item meta + #End))) (bit$ #1))))) - (#Cons [[_ (#Form (#Cons [name args]))] - (#Cons [meta (#Cons [type (#Cons [body #Nil])])])]) + (#Item [[_ (#Form (#Item [name args]))] + (#Item [meta (#Item [type (#Item [body #End])])])]) (return (list (form$ (list (text$ "lux def") name (form$ (list (text$ "lux type check") @@ -1382,18 +1382,18 @@ name (tuple$ args) body)))) - (form$ (#Cons (identifier$ ["library/lux" "record$"]) - (#Cons meta - #Nil))) + (form$ (#Item (identifier$ ["library/lux" "record$"]) + (#Item meta + #End))) (bit$ #0))))) - (#Cons [name (#Cons [meta (#Cons [type (#Cons [body #Nil])])])]) + (#Item [name (#Item [meta (#Item [type (#Item [body #End])])])]) (return (list (form$ (list (text$ "lux def") name (form$ (list (text$ "lux type check") type body)) - (form$ (#Cons (identifier$ ["library/lux" "record$"]) - (#Cons meta - #Nil))) + (form$ (#Item (identifier$ ["library/lux" "record$"]) + (#Item meta + #End))) (bit$ #0))))) _ @@ -1401,17 +1401,17 @@ tokens)) (def:''' (as_pairs xs) - #Nil + #End (All [a] (-> ($' List a) ($' List (& a a)))) - ({(#Cons x (#Cons y xs')) - (#Cons [x y] (as_pairs xs')) + ({(#Item x (#Item y xs')) + (#Item [x y] (as_pairs xs')) _ - #Nil} + #End} xs)) (macro:' (let' tokens) - ({(#Cons [[_ (#Tuple bindings)] (#Cons [body #Nil])]) + ({(#Item [[_ (#Tuple bindings)] (#Item [body #End])]) (return (list (list\fold ("lux type check" (-> (& Code Code) Code Code) (function' [binding body] @@ -1426,46 +1426,46 @@ tokens)) (def:''' (any? p xs) - #Nil + #End (All [a] (-> (-> a Bit) ($' List a) Bit)) - ({#Nil + ({#End #0 - (#Cons x xs') + (#Item x xs') ({#1 #1 #0 (any? p xs')} (p x))} xs)) (def:''' (wrap_meta content) - #Nil + #End (-> Code Code) (tuple$ (list (tuple$ (list (text$ "") (nat$ 0) (nat$ 0))) content))) (def:''' (untemplated_list tokens) - #Nil + #End (-> ($' List Code) Code) - ({#Nil - (_ann (#Tag ["library/lux" "Nil"])) + ({#End + (_ann (#Tag ["library/lux" "End"])) - (#Cons [token tokens']) - (_ann (#Form (list (_ann (#Tag ["library/lux" "Cons"])) token (untemplated_list tokens'))))} + (#Item [token tokens']) + (_ann (#Form (list (_ann (#Tag ["library/lux" "Item"])) token (untemplated_list tokens'))))} tokens)) (def:''' (list\compose xs ys) - #Nil + #End (All [a] (-> ($' List a) ($' List a) ($' List a))) - ({(#Cons x xs') - (#Cons x (list\compose xs' ys)) + ({(#Item x xs') + (#Item x (list\compose xs' ys)) - #Nil + #End ys} xs)) (def:''' (_$_joiner op a1 a2) - #Nil + #End (-> Code Code Code Code) ({[_ (#Form parts)] (form$ (list\compose parts (list a1 a2))) @@ -1475,14 +1475,14 @@ op)) (def:''' (function/flip func) - #Nil + #End (All [a b c] (-> (-> a b c) (-> b a c))) (function' [right left] (func left right))) (macro:' #export (_$ tokens) - (#Cons [(tag$ ["library/lux" "doc"]) + (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Left-association for the application of binary functions over variadic arguments." ..\n) ("lux text concat" @@ -1490,9 +1490,9 @@ ("lux text concat" ("lux text concat" "## =>" ..\n) "(text\compose (text\compose ''Hello, '' name) ''. How are you?'')"))))] - #Nil) - ({(#Cons op tokens') - ({(#Cons first nexts) + #End) + ({(#Item op tokens') + ({(#Item first nexts) (return (list (list\fold (function/flip (_$_joiner op)) first nexts))) _ @@ -1504,7 +1504,7 @@ tokens)) (macro:' #export ($_ tokens) - (#Cons [(tag$ ["library/lux" "doc"]) + (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Right-association for the application of binary functions over variadic arguments." ..\n) ("lux text concat" @@ -1512,9 +1512,9 @@ ("lux text concat" ("lux text concat" "## =>" ..\n) "(text\compose ''Hello, '' (text\compose name ''. How are you?''))"))))] - #Nil) - ({(#Cons op tokens') - ({(#Cons last prevs) + #End) + ({(#Item op tokens') + ({(#Item last prevs) (return (list (list\fold (_$_joiner op) last prevs))) _ @@ -1542,7 +1542,7 @@ #0) (def:''' maybe_monad - #Nil + #End ($' Monad Maybe) {#in (function' [x] (#Some x)) @@ -1554,7 +1554,7 @@ ma))}) (def:''' meta_monad - #Nil + #End ($' Monad Meta) {#in (function' [x] @@ -1572,7 +1572,7 @@ (ma state))))}) (macro:' (do tokens) - ({(#Cons monad (#Cons [_ (#Tuple bindings)] (#Cons body #Nil))) + ({(#Item monad (#Item [_ (#Tuple bindings)] (#Item body #End))) (let' [g!in (local_identifier$ "in") g!bind (local_identifier$ " bind ") body' (list\fold ("lux type check" (-> (& Code Code) Code Code) @@ -1597,7 +1597,7 @@ tokens)) (def:''' (monad\map m f xs) - #Nil + #End ## (All [m a b] ## (-> (Monad m) (-> a (m b)) (List a) (m (List b)))) (All [m a b] @@ -1606,18 +1606,18 @@ ($' List a) ($' m ($' List b)))) (let' [{#in in #bind _} m] - ({#Nil - (in #Nil) + ({#End + (in #End) - (#Cons x xs') + (#Item x xs') (do m [y (f x) ys (monad\map m f xs')] - (in (#Cons y ys)))} + (in (#Item y ys)))} xs))) (def:''' (monad\fold m f y xs) - #Nil + #End ## (All [m a b] ## (-> (Monad m) (-> a b (m b)) b (List a) (m b))) (All [m a b] @@ -1627,10 +1627,10 @@ ($' List a) ($' m b))) (let' [{#in in #bind _} m] - ({#Nil + ({#End (in y) - (#Cons x xs') + (#Item x xs') (do m [y' (f x y)] (monad\fold m f y' xs'))} @@ -1642,7 +1642,7 @@ "Picks which expression to evaluate based on a bit test value." __paragraph "(if #1 ''Oh, yeah!'' ''Aw hell naw!'')" __paragraph "=> ''Oh, yeah!''"))]) - ({(#Cons test (#Cons then (#Cons else #Nil))) + ({(#Item test (#Item then (#Item else #End))) (return (list (form$ (list (record$ (list [(bit$ #1) then] [(bit$ #0) else])) test)))) @@ -1652,38 +1652,38 @@ tokens)) (def:''' (get k plist) - #Nil + #End (All [a] (-> Text ($' List (& Text a)) ($' Maybe a))) - ({(#Cons [[k' v] plist']) + ({(#Item [[k' v] plist']) (if (text\= k k') (#Some v) (get k plist')) - #Nil + #End #None} plist)) (def:''' (put k v dict) - #Nil + #End (All [a] (-> Text a ($' List (& Text a)) ($' List (& Text a)))) - ({#Nil + ({#End (list [k v]) - (#Cons [[k' v'] dict']) + (#Item [[k' v'] dict']) (if (text\= k k') - (#Cons [[k' v] dict']) - (#Cons [[k' v'] (put k v dict')]))} + (#Item [[k' v] dict']) + (#Item [[k' v'] (put k v dict')]))} dict)) (def:''' (text\compose x y) - #Nil + #End (-> Text Text Text) ("lux text concat" x y)) (def:''' (name\encode full_name) - #Nil + #End (-> Name Text) (let' [[module name] full_name] ({"" name @@ -1691,11 +1691,11 @@ module))) (def:''' (get_meta tag def_meta) - #Nil + #End (-> Name Code ($' Maybe Code)) (let' [[prefix name] tag] ({[_ (#Record def_meta)] - ({(#Cons [key value] def_meta') + ({(#Item [key value] def_meta') ({[_ (#Tag [prefix' name'])] ({[#1 #1] (#Some value) @@ -1709,7 +1709,7 @@ (get_meta tag (record$ def_meta'))} key) - #Nil + #End #None} def_meta) @@ -1718,7 +1718,7 @@ def_meta))) (def:''' (resolve_global_identifier full_name state) - #Nil + #End (-> Name ($' Meta Name)) (let' [[module name] full_name {#info info #source source #current_module _ #modules modules @@ -1743,7 +1743,7 @@ (get module modules)))) (def:''' (as_code_list expression) - #Nil + #End (-> Code Code) (let' [type (form$ (list (tag$ ["library/lux" "Apply"]) (identifier$ ["library/lux" "Code"]) @@ -1751,26 +1751,26 @@ (form$ (list (text$ "lux type check") type expression)))) (def:''' (spliced replace? untemplate elems) - #Nil + #End (-> Bit (-> Code ($' Meta Code)) ($' List Code) ($' Meta Code)) ({#1 - ({#Nil - (return (tag$ ["library/lux" "Nil"])) + ({#End + (return (tag$ ["library/lux" "End"])) - (#Cons lastI inits) + (#Item lastI inits) (do meta_monad - [lastO ({[_ (#Form (#Cons [[_ (#Identifier ["" "~+"])] (#Cons [spliced #Nil])]))] + [lastO ({[_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))] (in (as_code_list spliced)) _ (do meta_monad [lastO (untemplate lastI)] - (in (as_code_list (form$ (list (tag$ ["library/lux" "Cons"]) - (tuple$ (list lastO (tag$ ["library/lux" "Nil"]))))))))} + (in (as_code_list (form$ (list (tag$ ["library/lux" "Item"]) + (tuple$ (list lastO (tag$ ["library/lux" "End"]))))))))} lastI)] (monad\fold meta_monad (function' [leftI rightO] - ({[_ (#Form (#Cons [[_ (#Identifier ["" "~+"])] (#Cons [spliced #Nil])]))] + ({[_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))] (let' [g!in-module (form$ (list (text$ "lux in-module") (text$ "library/lux") (identifier$ ["library/lux" "list\compose"])))] @@ -1779,7 +1779,7 @@ _ (do meta_monad [leftO (untemplate leftI)] - (in (form$ (list (tag$ ["library/lux" "Cons"]) (tuple$ (list leftO rightO))))))} + (in (form$ (list (tag$ ["library/lux" "Item"]) (tuple$ (list leftO rightO))))))} leftI)) lastO inits))} @@ -1791,12 +1791,12 @@ replace?)) (def:''' (untemplated_text value) - #Nil + #End (-> Text Code) (wrap_meta (form$ (list (tag$ ["library/lux" "Text"]) (text$ value))))) (def:''' (untemplate replace? subst token) - #Nil + #End (-> Bit Text Code ($' Meta Code)) ({[_ [_ (#Bit value)]] (return (wrap_meta (form$ (list (tag$ ["library/lux" "Bit"]) (bit$ value))))) @@ -1844,12 +1844,12 @@ [#0 [_ (#Identifier [module name])]] (return (wrap_meta (form$ (list (tag$ ["library/lux" "Identifier"]) (tuple$ (list (text$ module) (text$ name))))))) - [#1 [_ (#Form (#Cons [[_ (#Identifier ["" "~"])] (#Cons [unquoted #Nil])]))]] + [#1 [_ (#Form (#Item [[_ (#Identifier ["" "~"])] (#Item [unquoted #End])]))]] (return (form$ (list (text$ "lux type check") (identifier$ ["library/lux" "Code"]) unquoted))) - [#1 [_ (#Form (#Cons [[_ (#Identifier ["" "~!"])] (#Cons [dependent #Nil])]))]] + [#1 [_ (#Form (#Item [[_ (#Identifier ["" "~!"])] (#Item [dependent #End])]))]] (do meta_monad [independent (untemplate replace? subst dependent)] (in (wrap_meta (form$ (list (tag$ ["library/lux" "Form"]) @@ -1857,7 +1857,7 @@ (untemplated_text subst) independent))))))) - [#1 [_ (#Form (#Cons [[_ (#Identifier ["" "~'"])] (#Cons [keep_quoted #Nil])]))]] + [#1 [_ (#Form (#Item [[_ (#Identifier ["" "~'"])] (#Item [keep_quoted #End])]))]] (untemplate #0 subst keep_quoted) [_ [meta (#Form elems)]] @@ -1892,10 +1892,10 @@ "## Macro to treat define new primitive types." __paragraph "(primitive ''java.lang.Object'')" __paragraph "(primitive ''java.util.List'' [(primitive ''java.lang.Long'')])"))]) - ({(#Cons [_ (#Text class_name)] #Nil) - (return (list (form$ (list (tag$ ["library/lux" "Primitive"]) (text$ class_name) (tag$ ["library/lux" "Nil"]))))) + ({(#Item [_ (#Text class_name)] #End) + (return (list (form$ (list (tag$ ["library/lux" "Primitive"]) (text$ class_name) (tag$ ["library/lux" "End"]))))) - (#Cons [_ (#Text class_name)] (#Cons [_ (#Tuple params)] #Nil)) + (#Item [_ (#Text class_name)] (#Item [_ (#Tuple params)] #End)) (return (list (form$ (list (tag$ ["library/lux" "Primitive"]) (text$ class_name) (untemplated_list params))))) _ @@ -1903,7 +1903,7 @@ tokens)) (def:'' (current_module_name state) - #Nil + #End ($' Meta Text) ({{#info info #source source #current_module current_module #modules modules #scopes scopes #type_context types #host host @@ -1923,7 +1923,7 @@ "## Hygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms." __paragraph "## All unprefixed macros will receive their parent module's prefix if imported; otherwise will receive the prefix of the module on which the quasi-quote is being used." __paragraph "(` (def: (~ name) (function ((~' _) (~+ args)) (~ body))))"))]) - ({(#Cons template #Nil) + ({(#Item template #End) (do meta_monad [current_module current_module_name =template (untemplate #1 current_module template)] @@ -1940,7 +1940,7 @@ (text$ ($_ "lux text concat" "## Unhygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms." __paragraph "(`' (def: (~ name) (function (_ (~+ args)) (~ body))))"))]) - ({(#Cons template #Nil) + ({(#Item template #End) (do meta_monad [=template (untemplate #1 "" template)] (in (list (form$ (list (text$ "lux type check") (identifier$ ["library/lux" "Code"]) =template))))) @@ -1954,7 +1954,7 @@ (text$ ($_ "lux text concat" "## Quotation as a macro." __paragraph "(' YOLO)"))]) - ({(#Cons template #Nil) + ({(#Item template #End) (do meta_monad [=template (untemplate #0 "" template)] (in (list (form$ (list (text$ "lux type check") (identifier$ ["library/lux" "Code"]) =template))))) @@ -1970,7 +1970,7 @@ "(|> elems (list\map int\encode) (interpose '' '') (fold text\compose ''''))" __paragraph "## =>" __paragraph "(fold text\compose '''' (interpose '' '' (list\map int\encode elems)))"))]) - ({(#Cons [init apps]) + ({(#Item [init apps]) (return (list (list\fold ("lux type check" (-> Code Code Code) (function' [app acc] ({[_ (#Tuple parts)] @@ -1996,7 +1996,7 @@ "(<| (fold text\compose '''') (interpose '' '') (list\map int\encode) elems)" __paragraph "## =>" __paragraph "(fold text\compose '''' (interpose '' '' (list\map int\encode elems)))"))]) - ({(#Cons [init apps]) + ({(#Item [init apps]) (return (list (list\fold ("lux type check" (-> Code Code Code) (function' [app acc] ({[_ (#Tuple parts)] @@ -2023,7 +2023,7 @@ (function' [x] (f (g x)))) (def:''' (get_name x) - #Nil + #End (-> Code ($' Maybe Name)) ({[_ (#Identifier sname)] (#Some sname) @@ -2033,7 +2033,7 @@ x)) (def:''' (get_tag x) - #Nil + #End (-> Code ($' Maybe Name)) ({[_ (#Tag sname)] (#Some sname) @@ -2043,7 +2043,7 @@ x)) (def:''' (get_short x) - #Nil + #End (-> Code ($' Maybe Text)) ({[_ (#Identifier "" sname)] (#Some sname) @@ -2053,7 +2053,7 @@ x)) (def:''' (tuple_to_list tuple) - #Nil + #End (-> Code ($' Maybe ($' List Code))) ({[_ (#Tuple members)] (#Some members) @@ -2063,7 +2063,7 @@ tuple)) (def:''' (apply_template env template) - #Nil + #End (-> RepEnv Code Code) ({[_ (#Identifier "" sname)] ({(#Some subst) @@ -2091,7 +2091,7 @@ template)) (def:''' (every? p xs) - #Nil + #End (All [a] (-> (-> a Bit) ($' List a) Bit)) (list\fold (function' [_2 _1] (if _1 (p _2) #0)) #1 xs)) @@ -2132,10 +2132,10 @@ ("lux i64 =" reference sample))) (def:''' (list\join xs) - #Nil + #End (All [a] (-> ($' List ($' List a)) ($' List a))) - (list\fold list\compose #Nil (list\reverse xs))) + (list\fold list\compose #End (list\reverse xs))) (macro:' #export (template tokens) (list [(tag$ ["library/lux" "doc"]) @@ -2145,7 +2145,7 @@ " " "[(def: #export <name> (-> Int Int) (+ <diff>))]" __paragraph " " "[inc +1]" ..\n " " "[dec -1]"))]) - ({(#Cons [[_ (#Tuple bindings)] (#Cons [[_ (#Tuple templates)] data])]) + ({(#Item [[_ (#Tuple bindings)] (#Item [[_ (#Tuple templates)] data])]) ({[(#Some bindings') (#Some data')] (let' [apply ("lux type check" (-> RepEnv ($' List Code)) (function' [env] (list\map (apply_template env) templates))) @@ -2202,12 +2202,12 @@ right)) (def:''' (bit\encode x) - #Nil + #End (-> Bit Text) (if x "#1" "#0")) (def:''' (digit::format digit) - #Nil + #End (-> Nat Text) ({0 "0" 1 "1" 2 "2" 3 "3" @@ -2217,7 +2217,7 @@ digit)) (def:''' (nat\encode value) - #Nil + #End (-> Nat Text) ({0 "0" @@ -2234,14 +2234,14 @@ value)) (def:''' (int\abs value) - #Nil + #End (-> Int Int) (if ("lux i64 <" +0 value) ("lux i64 *" -1 value) value)) (def:''' (int\encode value) - #Nil + #End (-> Int Text) (if ("lux i64 =" +0 value) "+0" @@ -2259,12 +2259,12 @@ (|> value ("lux i64 %" +10) int\abs ("lux type as" Nat) digit::format))))) (def:''' (frac\encode x) - #Nil + #End (-> Frac Text) ("lux f64 encode" x)) (def:''' (multiple? div n) - #Nil + #End (-> Nat Nat Bit) (|> n (n/% div) ("lux i64 =" 0))) @@ -2280,7 +2280,7 @@ (def:''' (macro_type? type) (list) (-> Type Bit) - ({(#Named ["library/lux" "Macro"] (#Primitive "#Macro" #Nil)) + ({(#Named ["library/lux" "Macro"] (#Primitive "#Macro" #End)) #1 _ @@ -2288,7 +2288,7 @@ type)) (def:''' (macro' modules current_module module name) - #Nil + #End (-> ($' List (& Text Module)) Text Text Text ($' Maybe Macro)) @@ -2310,7 +2310,7 @@ ("lux type check" Global gdef)))) (def:''' (normalize name) - #Nil + #End (-> Name ($' Meta Name)) ({["" name] (do meta_monad @@ -2322,7 +2322,7 @@ name)) (def:''' (macro full_name) - #Nil + #End (-> Name ($' Meta ($' Maybe Macro))) (do meta_monad [current_module current_module_name] @@ -2337,7 +2337,7 @@ state))))) (def:''' (macro? name) - #Nil + #End (-> Name ($' Meta Bit)) (do meta_monad [name (normalize name) @@ -2347,23 +2347,23 @@ output)))) (def:''' (interpose sep xs) - #Nil + #End (All [a] (-> a ($' List a) ($' List a))) - ({#Nil + ({#End xs - (#Cons [x #Nil]) + (#Item [x #End]) xs - (#Cons [x xs']) + (#Item [x xs']) (list& x sep (interpose sep xs'))} xs)) (def:''' (macro_expand_once token) - #Nil + #End (-> Code ($' Meta ($' List Code))) - ({[_ (#Form (#Cons [_ (#Identifier macro_name)] args))] + ({[_ (#Form (#Item [_ (#Identifier macro_name)] args))] (do meta_monad [macro_name' (normalize macro_name) ?macro (macro macro_name')] @@ -2379,9 +2379,9 @@ token)) (def:''' (macro_expand token) - #Nil + #End (-> Code ($' Meta ($' List Code))) - ({[_ (#Form (#Cons [_ (#Identifier macro_name)] args))] + ({[_ (#Form (#Item [_ (#Identifier macro_name)] args))] (do meta_monad [macro_name' (normalize macro_name) ?macro (macro macro_name')] @@ -2400,9 +2400,9 @@ token)) (def:''' (macro_expand_all syntax) - #Nil + #End (-> Code ($' Meta ($' List Code))) - ({[_ (#Form (#Cons [_ (#Identifier macro_name)] args))] + ({[_ (#Form (#Item [_ (#Identifier macro_name)] args))] (do meta_monad [macro_name' (normalize macro_name) ?macro (macro macro_name')] @@ -2415,7 +2415,7 @@ #None (do meta_monad [args' (monad\map meta_monad macro_expand_all args)] - (in (list (form$ (#Cons (identifier$ macro_name) (list\join args'))))))} + (in (list (form$ (#Item (identifier$ macro_name) (list\join args'))))))} ?macro)) [_ (#Form members)] @@ -2435,7 +2435,7 @@ (let' [[key val] kv] (do meta_monad [val' (macro_expand_all val)] - ({(#Cons val'' #Nil) + ({(#Item val'' #End) (return [key val'']) _ @@ -2449,24 +2449,24 @@ syntax)) (def:''' (walk_type type) - #Nil + #End (-> Code Code) - ({[_ (#Form (#Cons [_ (#Tag tag)] parts))] - (form$ (#Cons [(tag$ tag) (list\map walk_type parts)])) + ({[_ (#Form (#Item [_ (#Tag tag)] parts))] + (form$ (#Item [(tag$ tag) (list\map walk_type parts)])) [_ (#Tuple members)] (` (& (~+ (list\map walk_type members)))) - [_ (#Form (#Cons [_ (#Text "lux in-module")] - (#Cons [_ (#Text module)] - (#Cons type' - #Nil))))] + [_ (#Form (#Item [_ (#Text "lux in-module")] + (#Item [_ (#Text module)] + (#Item type' + #End))))] (` ("lux in-module" (~ (text$ module)) (~ (walk_type type')))) - [_ (#Form (#Cons [_ (#Identifier ["" ":~"])] (#Cons expression #Nil)))] + [_ (#Form (#Item [_ (#Identifier ["" ":~"])] (#Item expression #End)))] expression - [_ (#Form (#Cons type_fn args))] + [_ (#Form (#Item type_fn args))] (list\fold ("lux type check" (-> Code Code Code) (function' [arg type_fn] (` (#.Apply (~ arg) (~ type_fn))))) (walk_type type_fn) @@ -2481,10 +2481,10 @@ (text$ ($_ "lux text concat" "## Takes a type expression and returns it's representation as data-structure." __paragraph "(type (All [a] (Maybe (List a))))"))]) - ({(#Cons type #Nil) + ({(#Item type #End) (do meta_monad [type+ (macro_expand_all type)] - ({(#Cons type' #Nil) + ({(#Item type' #End) (in (list (walk_type type'))) _ @@ -2500,7 +2500,7 @@ (text$ ($_ "lux text concat" "## The type-annotation macro." __paragraph "(: (List Int) (list +1 +2 +3))"))]) - ({(#Cons type (#Cons value #Nil)) + ({(#Item type (#Item value #End)) (return (list (` ("lux type check" (type (~ type)) (~ value))))) _ @@ -2512,7 +2512,7 @@ (text$ ($_ "lux text concat" "## The type-coercion macro." __paragraph "(:as Dinosaur (list +1 +2 +3))"))]) - ({(#Cons type (#Cons value #Nil)) + ({(#Item type (#Item value #End)) (return (list (` ("lux type as" (type (~ type)) (~ value))))) _ @@ -2520,15 +2520,15 @@ tokens)) (def:''' (empty? xs) - #Nil + #End (All [a] (-> ($' List a) Bit)) - ({#Nil #1 + ({#End #1 _ #0} xs)) (template [<name> <type> <value>] [(def:''' (<name> xy) - #Nil + #End (All [a b] (-> (& a b) <type>)) (let' [[x y] xy] <value>))] @@ -2536,9 +2536,9 @@ [second b y]) (def:''' (unfold_type_def type_codes) - #Nil + #End (-> ($' List Code) ($' Meta (& Code ($' Maybe ($' List Text))))) - ({(#Cons [_ (#Record pairs)] #Nil) + ({(#Item [_ (#Record pairs)] #End) (do meta_monad [members (monad\map meta_monad (: (-> [Code Code] (Meta [Text Code])) @@ -2553,18 +2553,18 @@ (return [(` (& (~+ (list\map second members)))) (#Some (list\map first members))])) - (#Cons type #Nil) + (#Item type #End) ({[_ (#Tag "" member_name)] (return [(` .Any) (#Some (list member_name))]) - [_ (#Form (#Cons [_ (#Tag "" member_name)] member_types))] + [_ (#Form (#Item [_ (#Tag "" member_name)] member_types))] (return [(` (& (~+ member_types))) (#Some (list member_name))]) _ (return [type #None])} type) - (#Cons case cases) + (#Item case cases) (do meta_monad [members (monad\map meta_monad (: (-> Code (Meta [Text Code])) @@ -2572,10 +2572,10 @@ ({[_ (#Tag "" member_name)] (return [member_name (` .Any)]) - [_ (#Form (#Cons [_ (#Tag "" member_name)] (#Cons member_type #Nil)))] + [_ (#Form (#Item [_ (#Tag "" member_name)] (#Item member_type #End)))] (return [member_name member_type]) - [_ (#Form (#Cons [_ (#Tag "" member_name)] member_types))] + [_ (#Form (#Item [_ (#Tag "" member_name)] member_types))] (return [member_name (` (& (~+ member_types)))]) _ @@ -2590,7 +2590,7 @@ type_codes)) (def:''' (gensym prefix state) - #Nil + #End (-> Text ($' Meta Code)) ({{#info info #source source #current_module _ #modules modules #scopes scopes #type_context types #host host @@ -2611,10 +2611,10 @@ "## Parameter-less recursive types." __paragraph "## A name has to be given to the whole type, to use it within its body." __paragraph "(Rec Self [Int (List Self)])"))]) - ({(#Cons [_ (#Identifier "" name)] (#Cons body #Nil)) + ({(#Item [_ (#Identifier "" name)] (#Item body #End)) (let' [body' (replace_syntax (list [name (` (#.Apply (~ (make_parameter 1)) (~ (make_parameter 0))))]) (update_parameters body))] - (return (list (` (#.Apply .Nothing (#.UnivQ #.Nil (~ body'))))))) + (return (list (` (#.Apply .Nothing (#.UnivQ #.End (~ body'))))))) _ (failure "Wrong syntax for Rec")} @@ -2629,7 +2629,7 @@ " " "(log! ''#2'')" ..\n " " "(log! ''#3'')" ..\n "''YOLO'')"))]) - ({(#Cons value actions) + ({(#Item value actions) (let' [dummy (local_identifier$ "")] (return (list (list\fold ("lux type check" (-> Code Code Code) (function' [pre post] (` ({(~ dummy) (~ post)} @@ -2642,30 +2642,30 @@ (list\reverse tokens))) (macro:' (def:' tokens) - (let' [[export? tokens'] ({(#Cons [_ (#Tag ["" "export"])] tokens') + (let' [[export? tokens'] ({(#Item [_ (#Tag ["" "export"])] tokens') [#1 tokens'] _ [#0 tokens]} tokens) parts (: (Maybe [Code (List Code) (Maybe Code) Code]) - ({(#Cons [_ (#Form (#Cons name args))] (#Cons type (#Cons body #Nil))) + ({(#Item [_ (#Form (#Item name args))] (#Item type (#Item body #End))) (#Some name args (#Some type) body) - (#Cons name (#Cons type (#Cons body #Nil))) - (#Some name #Nil (#Some type) body) + (#Item name (#Item type (#Item body #End))) + (#Some name #End (#Some type) body) - (#Cons [_ (#Form (#Cons name args))] (#Cons body #Nil)) + (#Item [_ (#Form (#Item name args))] (#Item body #End)) (#Some name args #None body) - (#Cons name (#Cons body #Nil)) - (#Some name #Nil #None body) + (#Item name (#Item body #End)) + (#Some name #End #None body) _ #None} tokens'))] ({(#Some name args ?type body) - (let' [body' ({#Nil + (let' [body' ({#End body _ @@ -2680,7 +2680,7 @@ (return (list (` ("lux def" (~ name) (~ body'') [(~ location_code) - (#.Record #.Nil)] + (#.Record #.End)] (~ (bit$ export?))))))) #None @@ -2751,8 +2751,8 @@ (def:' (expander branches) (-> (List Code) (Meta (List Code))) - ({(#Cons [_ (#Form (#Cons [_ (#Identifier macro_name)] macro_args))] - (#Cons body + ({(#Item [_ (#Form (#Item [_ (#Identifier macro_name)] macro_args))] + (#Item body branches')) (do meta_monad [??? (macro? macro_name)] @@ -2766,12 +2766,12 @@ body sub_expansion))))) - (#Cons pattern (#Cons body branches')) + (#Item pattern (#Item body branches')) (do meta_monad [sub_expansion (expander branches')] (in (list& pattern body sub_expansion))) - #Nil + #End (do meta_monad [] (in (list))) _ @@ -2788,11 +2788,11 @@ "## The pattern-matching macro." ..\n "## Allows the usage of macros within the patterns to provide custom syntax." ..\n "(case (: (List Int) (list +1 +2 +3))" ..\n - " " "(#Cons x (#Cons y (#Cons z #Nil)))" ..\n + " " "(#Item x (#Item y (#Item z #End)))" ..\n " " "(#Some ($_ * x y z))" __paragraph " " "_" ..\n " " "#None)"))]) - ({(#Cons value branches) + ({(#Item value branches) (do meta_monad [expansion (expander branches)] (in (list (` ((~ (record$ (as_pairs expansion))) (~ value)))))) @@ -2813,11 +2813,11 @@ " _" ..\n " #None)"))]) (case tokens - (#Cons [_ (#Form (#Cons pattern #Nil))] (#Cons body branches)) + (#Item [_ (#Form (#Item pattern #End))] (#Item body branches)) (do meta_monad [pattern+ (macro_expand_all pattern)] (case pattern+ - (#Cons pattern' #Nil) + (#Item pattern' #End) (in (list& pattern' body branches)) _ @@ -2844,7 +2844,7 @@ (case tokens (^ (list& [_ (#Form patterns)] body branches)) (case patterns - #Nil + #End (failure "^or cannot have 0 patterns") _ @@ -2899,7 +2899,7 @@ " (function (_ x y) x))" __paragraph "(: (All [a b] (-> a b a))" ..\n - " (function (const x y) x))"))]) + " (function (constant x y) x))"))]) (case (: (Maybe [Text Code (List Code) Code]) (case tokens (^ (list [_ (#Form (list& [_ (#Identifier ["" name])] head tail))] body)) @@ -2976,11 +2976,11 @@ (def:' (with_func_args args meta) (-> (List Code) Code Code) (case args - #Nil + #End meta _ - (` (#.Cons [[(~ location_code) (#.Tag ["library/lux" "func-args"])] + (` (#.Item [[(~ location_code) (#.Tag ["library/lux" "func-args"])] [(~ location_code) (#.Tuple (.list (~+ (list\map (function (_ arg) (` [(~ location_code) (#.Text (~ (text$ (code\encode arg))))])) args))))]] @@ -2994,7 +2994,7 @@ (def:' (export^ tokens) (-> (List Code) [Bit (List Code)]) (case tokens - (#Cons [_ (#Tag [_ "export"])] tokens') + (#Item [_ (#Tag [_ "export"])] tokens') [#1 tokens'] _ @@ -3021,36 +3021,36 @@ (let [[exported? tokens'] (export^ tokens) parts (: (Maybe [Code (List Code) (Maybe Code) Code (List [Code Code])]) (case tokens' - (^ (list [_ (#Form (#Cons name args))] [_ (#Record meta_kvs)] type body)) + (^ (list [_ (#Form (#Item name args))] [_ (#Record meta_kvs)] type body)) (#Some [name args (#Some type) body meta_kvs]) (^ (list name [_ (#Record meta_kvs)] type body)) - (#Some [name #Nil (#Some type) body meta_kvs]) + (#Some [name #End (#Some type) body meta_kvs]) - (^ (list [_ (#Form (#Cons name args))] [_ (#Record meta_kvs)] body)) + (^ (list [_ (#Form (#Item name args))] [_ (#Record meta_kvs)] body)) (#Some [name args #None body meta_kvs]) (^ (list name [_ (#Record meta_kvs)] body)) - (#Some [name #Nil #None body meta_kvs]) + (#Some [name #End #None body meta_kvs]) - (^ (list [_ (#Form (#Cons name args))] type body)) - (#Some [name args (#Some type) body #Nil]) + (^ (list [_ (#Form (#Item name args))] type body)) + (#Some [name args (#Some type) body #End]) (^ (list name type body)) - (#Some [name #Nil (#Some type) body #Nil]) + (#Some [name #End (#Some type) body #End]) - (^ (list [_ (#Form (#Cons name args))] body)) - (#Some [name args #None body #Nil]) + (^ (list [_ (#Form (#Item name args))] body)) + (#Some [name args #None body #End]) (^ (list name body)) - (#Some [name #Nil #None body #Nil]) + (#Some [name #End #None body #End]) _ #None))] (case parts (#Some name args ?type body meta) (let [body (case args - #Nil + #End body _ @@ -3075,7 +3075,7 @@ (-> [Code Code] Code Code) (case [addition meta] [[name value] [location (#Record pairs)]] - [location (#Record (#Cons [name value] pairs))] + [location (#Record (#Item [name value] pairs))] _ meta)) @@ -3109,13 +3109,13 @@ (#Some [name args (list) body]) (^ (list [_ (#Identifier name)] body)) - (#Some [name #Nil (list) body]) + (#Some [name #End (list) body]) (^ (list [_ (#Form (list& [_ (#Identifier name)] args))] [_ (#Record meta_rec_parts)] body)) (#Some [name args meta_rec_parts body]) (^ (list [_ (#Identifier name)] [_ (#Record meta_rec_parts)] body)) - (#Some [name #Nil meta_rec_parts body]) + (#Some [name #End meta_rec_parts body]) _ #None))] @@ -3123,7 +3123,7 @@ (#Some [name args meta body]) (let [name (identifier$ name) body (case args - #Nil + #End body _ @@ -3160,13 +3160,13 @@ (#Some name args [meta_rec_location (#Record meta_rec_parts)] sigs) (^ (list& [_ (#Identifier name)] [meta_rec_location (#Record meta_rec_parts)] sigs)) - (#Some name #Nil [meta_rec_location (#Record meta_rec_parts)] sigs) + (#Some name #End [meta_rec_location (#Record meta_rec_parts)] sigs) (^ (list& [_ (#Form (list& [_ (#Identifier name)] args))] sigs)) (#Some name args (` {}) sigs) (^ (list& [_ (#Identifier name)] sigs)) - (#Some name #Nil (` {}) sigs) + (#Some name #End (` {}) sigs) _ #None))] @@ -3195,7 +3195,7 @@ sig_meta (meta_code_merge (` {#.sig? #1}) meta) usage (case args - #Nil + #End def_name _ @@ -3209,10 +3209,10 @@ (All [a b] (-> (-> a (Maybe b)) (List a) (Maybe b))) (case xs - #Nil + #End #None - (#Cons x xs') + (#Item x xs') (case (f x) #None (find f xs') @@ -3288,10 +3288,10 @@ (All [a] (-> Nat (List a) (Maybe a))) (case xs - #Nil + #End #None - (#Cons x xs') + (#Item x xs') (if ("lux i64 =" 0 idx) (#Some x) (nth ("lux i64 -" 1 idx) xs')))) @@ -3311,7 +3311,7 @@ (#UnivQ ?local_env ?local_def) (case ?local_env - #Nil + #End (#UnivQ env ?local_def) _ @@ -3319,7 +3319,7 @@ (#ExQ ?local_env ?local_def) (case ?local_env - #Nil + #End (#ExQ env ?local_def) _ @@ -3383,7 +3383,7 @@ (case type (#Apply head func') (let [[func tail] (flat_app func')] - [func (#Cons head tail)]) + [func (#Item head tail)]) _ [type (list)])) @@ -3527,10 +3527,10 @@ (def: (text\join_with separator parts) (-> Text (List Text) Text) (case parts - #Nil + #End "" - (#Cons head tail) + (#Item head tail) (list\fold (function (_ right left) ($_ text\compose left separator right)) head @@ -3558,20 +3558,20 @@ (#Some name args type [meta_rec_location (#Record meta_rec_parts)] definitions) (^ (list& name [meta_rec_location (#Record meta_rec_parts)] type definitions)) - (#Some name #Nil type [meta_rec_location (#Record meta_rec_parts)] definitions) + (#Some name #End type [meta_rec_location (#Record meta_rec_parts)] definitions) (^ (list& [_ (#Form (list& name args))] type definitions)) (#Some name args type (` {}) definitions) (^ (list& name type definitions)) - (#Some name #Nil type (` {}) definitions) + (#Some name #End type (` {}) definitions) _ #None))] (case ?parts (#Some [name args type meta definitions]) (let [usage (case args - #Nil + #End name _ @@ -3590,10 +3590,10 @@ (macro: #export (type: tokens) {#.doc (text$ ($_ "lux text concat" "## The type-definition macro." ..\n - "(type: (List a) #Nil (#Cons a (List a)))"))} + "(type: (List a) #End (#Item a (List a)))"))} (let [[exported? tokens'] (export^ tokens) [rec? tokens'] (case tokens' - (#Cons [_ (#Tag [_ "rec"])] tokens') + (#Item [_ (#Tag [_ "rec"])] tokens') [#1 tokens'] _ @@ -3601,21 +3601,21 @@ parts (: (Maybe [Text (List Code) (List [Code Code]) (List Code)]) (case tokens' (^ (list [_ (#Identifier "" name)] [meta_location (#Record meta_parts)] [type_location (#Record type_parts)])) - (#Some [name #Nil meta_parts (list [type_location (#Record type_parts)])]) + (#Some [name #End meta_parts (list [type_location (#Record type_parts)])]) (^ (list& [_ (#Identifier "" name)] [meta_location (#Record meta_parts)] type_code1 type_codes)) - (#Some [name #Nil meta_parts (#Cons type_code1 type_codes)]) + (#Some [name #End meta_parts (#Item type_code1 type_codes)]) (^ (list& [_ (#Identifier "" name)] type_codes)) - (#Some [name #Nil (list) type_codes]) + (#Some [name #End (list) type_codes]) - (^ (list [_ (#Form (#Cons [_ (#Identifier "" name)] args))] [meta_location (#Record meta_parts)] [type_location (#Record type_parts)])) + (^ (list [_ (#Form (#Item [_ (#Identifier "" name)] args))] [meta_location (#Record meta_parts)] [type_location (#Record type_parts)])) (#Some [name args meta_parts (list [type_location (#Record type_parts)])]) - (^ (list& [_ (#Form (#Cons [_ (#Identifier "" name)] args))] [meta_location (#Record meta_parts)] type_code1 type_codes)) - (#Some [name args meta_parts (#Cons type_code1 type_codes)]) + (^ (list& [_ (#Form (#Item [_ (#Identifier "" name)] args))] [meta_location (#Record meta_parts)] type_code1 type_codes)) + (#Some [name args meta_parts (#Item type_code1 type_codes)]) - (^ (list& [_ (#Form (#Cons [_ (#Identifier "" name)] args))] type_codes)) + (^ (list& [_ (#Form (#Item [_ (#Identifier "" name)] args))] type_codes)) (#Some [name args (list) type_codes]) _ @@ -3637,14 +3637,14 @@ .Nothing)))) #None) (case args - #Nil + #End (#Some type) _ (#Some (` (.All (~ type_name) [(~+ args)] (~ type))))))) total_meta (let [meta (process_def_meta meta) meta (if rec? - (` (#.Cons (~ (flag_meta "type-rec?")) (~ meta))) + (` (#.Item (~ (flag_meta "type-rec?")) (~ meta))) meta)] (` [(~ location_code) (#.Record (~ meta))]))] @@ -3747,8 +3747,8 @@ (def: (openings_parser parts) (-> (List Code) (Meta [(List Openings) (List Code)])) (case parts - #.Nil - (return [#.Nil #.Nil]) + #.End + (return [#.End #.End]) (^ (list& [_ (#Form (list& [_ (#Text prefix)] structs))] parts')) (do meta_monad @@ -3763,11 +3763,11 @@ structs) next+remainder (openings_parser parts')] (let [[next remainder] next+remainder] - (return [(#.Cons [prefix structs'] next) + (return [(#.Item [prefix structs'] next) remainder]))) _ - (return [#.Nil parts]))) + (return [#.End parts]))) (def: (text\split! at x) (-> Nat Text [Text Text]) @@ -3845,19 +3845,19 @@ (def: (list\take amount list) (All [a] (-> Nat (List a) (List a))) (case [amount list] - (^or [0 _] [_ #Nil]) - #Nil + (^or [0 _] [_ #End]) + #End - [_ (#Cons head tail)] - (#Cons head (list\take ("lux i64 -" 1 amount) tail)))) + [_ (#Item head tail)] + (#Item head (list\take ("lux i64 -" 1 amount) tail)))) (def: (list\drop amount list) (All [a] (-> Nat (List a) (List a))) (case [amount list] - (^or [0 _] [_ #Nil]) + (^or [0 _] [_ #End]) list - [_ (#Cons _ tail)] + [_ (#Item _ tail)] (list\drop ("lux i64 -" 1 amount) tail))) (def: (clean_module nested? relative_root module) @@ -3934,7 +3934,7 @@ #let [[openings extra] openings+extra] sub_imports (imports_parser #1 import_name context_alias extra)] (in (case [referral openings] - [#Nothing #Nil] + [#Nothing #End] sub_imports _ @@ -3959,7 +3959,7 @@ de_aliased (de_alias context_alias m_name alias)] sub_imports (imports_parser #1 import_name de_aliased extra)] (in (case [referral openings] - [#Ignore #Nil] + [#Ignore #End] sub_imports _ @@ -4023,12 +4023,12 @@ (def: (only p xs) (All [a] (-> (-> a Bit) (List a) (List a))) (case xs - #Nil + #End (list) - (#Cons x xs') + (#Item x xs') (if (p x) - (#Cons x (only p xs')) + (#Item x (only p xs')) (only p xs')))) (def: (is_member? cases name) @@ -4121,10 +4121,10 @@ (def: (type_variable idx bindings) (-> Nat (List [Nat (Maybe Type)]) (Maybe Type)) (case bindings - #Nil - #Nil + #End + #End - (#Cons [var bound] bindings') + (#Item [var bound] bindings') (if ("lux i64 =" idx var) bound (type_variable idx bindings')))) @@ -4174,9 +4174,9 @@ (def: (zipped/2 xs ys) (All [a b] (-> (List a) (List b) (List [a b]))) (case xs - (#Cons x xs') + (#Item x xs') (case ys - (#Cons y ys') + (#Item y ys') (list& [x y] (zipped/2 xs' ys')) _ @@ -4190,7 +4190,7 @@ (case type (#Primitive name params) (case params - #Nil + #End name _ @@ -4307,11 +4307,11 @@ (def: (enumeration' idx xs) (All [a] (-> Nat (List a) (List [Nat a]))) (case xs - (#Cons x xs') - (#Cons [idx x] (enumeration' ("lux i64 +" 1 idx) xs')) + (#Item x xs') + (#Item [idx x] (enumeration' ("lux i64 +" 1 idx) xs')) - #Nil - #Nil)) + #End + #End)) (def: (enumeration xs) (All [a] (-> (List a) (List [Nat a]))) @@ -4393,7 +4393,7 @@ _ (return (list (` ("lux def" (~ (local_identifier$ (de_alias "" short alias))) (~ source+) - [(~ location_code) (#.Record #Nil)] + [(~ location_code) (#.Record #End)] #0))))))) (macro: #export (open: tokens) @@ -4432,7 +4432,7 @@ (do meta_monad [g!struct (gensym "struct")] (return (list (` ("lux def" (~ g!struct) (~ struct) - [(~ location_code) (#.Record #Nil)] + [(~ location_code) (#.Record #End)] #0)) (` (..open: (~ (text$ alias)) (~ g!struct))))))) @@ -4477,7 +4477,7 @@ #let [[openings options] openings+options] current_module current_module_name] (case options - #Nil + #End (in {#refer_defs referral #refer_open openings}) @@ -4613,7 +4613,7 @@ =module (` ("lux def module" [(~ location_code) (#.Record (~ (process_def_meta _meta)))] (~ =imports)))]] - (in (#Cons =module =refers)))) + (in (#Item =module =refers)))) (macro: #export (\ tokens) {#.doc (text$ ($_ "lux text concat" @@ -4678,7 +4678,7 @@ (^ (list [_ (#Tuple slots)] value record)) (case slots - #Nil + #End (failure "Wrong syntax for set@") _ @@ -4696,8 +4696,8 @@ [_ accesses'] (list\fold (: (-> [Code Code] [Code (List (List Code))] [Code (List (List Code))]) (function (_ [new_slot new_binding] [old_record accesses']) [(` (get@ (~ new_slot) (~ new_binding))) - (#Cons (list new_binding old_record) accesses')])) - [record (: (List (List Code)) #Nil)] + (#Item (list new_binding old_record) accesses')])) + [record (: (List (List Code)) #End)] pairs) accesses (list\join (list\reverse accesses'))]] (in (list (` (let [(~+ accesses)] @@ -4767,7 +4767,7 @@ (^ (list [_ (#Tuple slots)] fun record)) (case slots - #Nil + #End (failure "Wrong syntax for update@") _ @@ -4818,7 +4818,7 @@ " (^template [<tag>]" ..\n " [(<tag> old_env def)" ..\n " (case old_env" ..\n - " #.Nil" ..\n + " #.End" ..\n " (<tag> env def)" __paragraph " _" ..\n @@ -4916,8 +4916,8 @@ (def: (repeat n x) (All [a] (-> Int a (List a))) (if ("lux i64 <" n +0) - (#Cons x (repeat ("lux i64 +" -1 n) x)) - #Nil)) + (#Item x (repeat ("lux i64 +" -1 n) x)) + #End)) (def: (location_padding baseline [_ old_line old_column] [_ new_line new_column]) (-> Nat Location Location Text) @@ -5020,15 +5020,15 @@ (def: (interleave xs ys) (All [a] (-> (List a) (List a) (List a))) (case xs - #Nil - #Nil + #End + #End - (#Cons x xs') + (#Item x xs') (case ys - #Nil - #Nil + #End + #End - (#Cons y ys') + (#Item y ys') (list& x y (interleave xs' ys'))))) (def: (type_to_code type) @@ -5233,7 +5233,7 @@ _ (failure "[with_expansions] Improper macro expansion."))) - #Nil + #End (return bodies) _ @@ -5341,10 +5341,10 @@ (def: (multi_level_case^ levels) (-> (List Code) (Meta Multi_Level_Case)) (case levels - #Nil + #End (failure "Multi-level patterns cannot be empty.") - (#Cons init extras) + (#Item init extras) (do meta_monad [extras' (monad\map meta_monad case_level^ extras)] (in [init extras'])))) @@ -5545,7 +5545,7 @@ (-> Int Int) (undefined)))} (case tokens - #Nil + #End (do meta_monad [location ..location #let [[module line column] location @@ -5710,8 +5710,8 @@ type+value (..definition_value identifier) #let [[type value] type+value]] (case (..flat_alias type) - (^or (#Primitive "#Text" #Nil) - (#Named ["library/lux" "Text"] (#Primitive "#Text" #Nil))) + (^or (#Primitive "#Text" #End) + (#Named ["library/lux" "Text"] (#Primitive "#Text" #End))) (in (:as ..Text value)) _ @@ -5727,7 +5727,7 @@ (def: (target_pick target options default) (-> Text (List [Code Code]) (Maybe Code) (Meta (List Code))) (case options - #Nil + #End (case default #.None (failure ($_ text\compose "No code for target platform: " target)) @@ -5735,7 +5735,7 @@ (#.Some default) (return (list default))) - (#Cons [key pick] options') + (#Item [key pick] options') (do meta_monad [platform (..resolve_target key)] (if (text\= target platform) @@ -5819,11 +5819,11 @@ (def: (untemplated_list& last inits) (-> Code (List Code) Code) (case inits - #Nil + #End last - (#Cons [init inits']) - (` (#.Cons (~ init) (~ (untemplated_list& last inits')))))) + (#Item [init inits']) + (` (#.Item (~ init) (~ (untemplated_list& last inits')))))) (def: (untemplated_record g!meta untemplated_pattern fields) (-> Code (-> Code (Meta Code)) @@ -5843,7 +5843,7 @@ (-> Code (-> Code (Meta Code)) (-> (List Code) (Meta Code))) (case (list\reverse elems) - (#Cons [_ (#Form (#Cons [[_ (#Identifier ["" "~+"])] (#Cons [spliced #Nil])]))] + (#Item [_ (#Form (#Item [[_ (#Identifier ["" "~+"])] (#Item [spliced #End])]))] inits) (do meta_monad [=inits (monad\map meta_monad untemplated_pattern (list\reverse inits))] @@ -5875,10 +5875,10 @@ [#.Tag name$] [#.Identifier name$]) - [_ (#Form (#Cons [[_ (#Identifier ["" "~"])] (#Cons [unquoted #Nil])]))] + [_ (#Form (#Item [[_ (#Identifier ["" "~"])] (#Item [unquoted #End])]))] (return unquoted) - [_ (#Form (#Cons [[_ (#Identifier ["" "~+"])] (#Cons [spliced #Nil])]))] + [_ (#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> <untemplate>] diff --git a/stdlib/source/library/lux/abstract/enum.lux b/stdlib/source/library/lux/abstract/enum.lux index e80975172..4cb27558a 100644 --- a/stdlib/source/library/lux/abstract/enum.lux +++ b/stdlib/source/library/lux/abstract/enum.lux @@ -15,12 +15,12 @@ (All [a] (-> (Enum a) a a (List a))) (let [(^open "/\.") enum] (loop [end to - output #.Nil] + output #.End] (cond (/\< end from) - (recur (/\pred end) (#.Cons end output)) + (recur (/\pred end) (#.Item end output)) (/\< from end) - (recur (/\succ end) (#.Cons end output)) + (recur (/\succ end) (#.Item end output)) ## (/\= end from) - (#.Cons end output))))) + (#.Item end output))))) diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index 4dc1e1477..e4d739638 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -10,10 +10,10 @@ (All [a b] (-> (-> b a a) a (List b) a)) (case xs - #.Nil + #.End init - (#.Cons x xs') + (#.Item x xs') (list\fold f (f x init) xs'))) (def: (list\size xs) @@ -21,27 +21,27 @@ (loop [counter 0 xs xs] (case xs - #.Nil + #.End counter - (#.Cons _ xs') + (#.Item _ xs') (recur (inc counter) xs')))) (def: (reverse xs) (All [a] (-> (List a) (List a))) - (list\fold (function (_ head tail) (#.Cons head tail)) - #.Nil + (list\fold (function (_ head tail) (#.Item head tail)) + #.End xs)) (def: (as_pairs xs) (All [a] (-> (List a) (List [a a]))) (case xs - (#.Cons x1 (#.Cons x2 xs')) - (#.Cons [x1 x2] (as_pairs xs')) + (#.Item x1 (#.Item x2 xs')) + (#.Item [x1 x2] (as_pairs xs')) _ - #.Nil)) + #.End)) (interface: #export (Monad m) {#.doc (doc "A monad is a monoid in the category of endofunctors." @@ -126,13 +126,13 @@ (let [(^open "!\.") monad] (function (recur xs) (case xs - #.Nil - (!\in #.Nil) + #.End + (!\in #.End) - (#.Cons x xs') + (#.Item x xs') (|> x (!\map (function (_ _x) - (!\map (|>> (#.Cons _x)) (recur xs')))) + (!\map (|>> (#.Item _x)) (recur xs')))) !\join))))) (def: #export (map monad f) @@ -143,13 +143,13 @@ (let [(^open "!\.") monad] (function (recur xs) (case xs - #.Nil - (!\in #.Nil) + #.End + (!\in #.End) - (#.Cons x xs') + (#.Item x xs') (|> (f x) (!\map (function (_ _x) - (!\map (|>> (#.Cons _x)) (recur xs')))) + (!\map (|>> (#.Item _x)) (recur xs')))) !\join))))) (def: #export (only monad f) @@ -160,15 +160,15 @@ (let [(^open "!\.") monad] (function (recur xs) (case xs - #.Nil - (!\in #.Nil) + #.End + (!\in #.End) - (#.Cons head xs') + (#.Item head xs') (|> (f head) (!\map (function (_ verdict) (!\map (function (_ tail) (if verdict - (#.Cons head tail) + (#.Item head tail) tail)) (recur xs')))) !\join))))) @@ -179,10 +179,10 @@ (-> (Monad M) (-> b a (M a)) a (List b) (M a))) (case xs - #.Nil + #.End (\ monad in init) - (#.Cons x xs') + (#.Item x xs') (do monad [init' (f x init)] (fold monad f init' xs')))) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index f8426ebb7..88ac4f0b9 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -12,6 +12,7 @@ ["." list ("#\." fold functor)]]] ["." macro (#+ with_gensyms) ["." code] + ["." template] [syntax (#+ syntax:) ["|.|" export] ["|.|" annotations]]] @@ -61,7 +62,7 @@ (monad.do meta.monad [expansion expander] (case expansion - (#.Cons singleton #.Nil) + (#.Item singleton #.End) (in singleton) _ @@ -71,6 +72,15 @@ (syntax: #export (=> {aliases aliases^} {inputs stack^} {outputs stack^}) + {#.doc (doc "Concatenative function types." + (=> [Nat] [Nat]) + (All [a] (-> a (=> [] [a]))) + (All [t] (=> [t] [])) + (All [a b c] (=> [a b c] [b c a])) + (All [___a ___z] + (=> {then (=> ___a ___z) + else (=> ___a ___z)} + ___a [Bit then else] ___z)))} (let [de_alias (function (_ aliased) (list\fold (function (_ [from to] pre) (code.replace (code.local_identifier from) to pre)) @@ -102,6 +112,13 @@ top)) (syntax: #export (||> {commands (<>.some <c>.any)}) + {#.doc (doc "A self-contained sequence of concatenative instructions." + (is? value + (||> (..push sample))) + + (||> (push 123) + dup + n/=))} (in (list (` (|> (~! ..begin!) (~+ commands) ((~! ..end!))))))) (syntax: #export (word: @@ -110,12 +127,21 @@ {annotations (<>.default |annotations|.empty |annotations|.parser)} type {commands (<>.some <c>.any)}) + {#.doc (doc "A named concatenative function." + (word: square + (=> [Nat] [Nat]) + + dup + (apply/2 n.*)))} (in (list (` (def: (~+ (|export|.format export)) (~ (code.local_identifier name)) (~ (|annotations|.format annotations)) (~ type) (|>> (~+ commands))))))) (syntax: #export (apply {arity (|> <c>.nat (<>.only (n.> 0)))}) + {#.doc (doc "A generator for functions that turn arity N functions into arity N concatenative functions." + (: (=> [Nat] [Nat]) + ((apply 1) inc)))} (with_gensyms [g! g!func g!stack g!output] (monad.do {! meta.monad} [g!inputs (|> (macro.gensym "input") (list.repeat arity) (monad.seq !))] @@ -126,70 +152,84 @@ (function ((~ g!) (~ (stack_fold g!inputs g!stack))) [(~ g!stack) ((~ g!func) (~+ g!inputs))]))))))))) -(def: #export apply/1 (apply 1)) -(def: #export apply/2 (apply 2)) -(def: #export apply/3 (apply 3)) -(def: #export apply/4 (apply 4)) -(def: #export apply/5 (apply 5)) -(def: #export apply/6 (apply 6)) -(def: #export apply/7 (apply 7)) -(def: #export apply/8 (apply 8)) +(template [<arity>] + [(with_expansions [<name> (template.identifier ["apply/" <arity>]) + <doc> (template.text ["Lift a function of arity " <arity> + " into a concatenative function of arity " <arity> "."])] + (def: #export <name> + {#.doc (doc <doc>)} + (apply <arity>)))] + + [1] [2] [3] [4] + [5] [6] [7] [8] + ) (def: #export (push x) + {#.doc (doc "Push a value onto the stack.")} (All [a] (-> a (=> [] [a]))) (function (_ stack) [stack x])) (def: #export drop + {#.doc (doc "Drop/pop a value from the top of the stack.")} (All [t] (=> [t] [])) (function (_ [stack top]) stack)) (def: #export nip + {#.doc (doc "Drop the second-to-last value from the top of the stack.")} (All [_ a] (=> [_ a] [a])) (function (_ [[stack _] top]) [stack top])) (def: #export dup + {#.doc (doc "Duplicate the top of the stack.")} (All [a] (=> [a] [a a])) (function (_ [stack top]) [[stack top] top])) (def: #export swap + {#.doc (doc "Swaps the 2 topmost stack values.")} (All [a b] (=> [a b] [b a])) (function (_ [[stack l] r]) [[stack r] l])) (def: #export rotL + {#.doc (doc "Rotes the 3 topmost stack values to the left.")} (All [a b c] (=> [a b c] [b c a])) (function (_ [[[stack a] b] c]) [[[stack b] c] a])) (def: #export rotR + {#.doc (doc "Rotes the 3 topmost stack values to the right.")} (All [a b c] (=> [a b c] [c a b])) (function (_ [[[stack a] b] c]) [[[stack c] a] b])) (def: #export && + {#.doc (doc "Groups the 2 topmost stack values as a 2-tuple.")} (All [a b] (=> [a b] [(& a b)])) (function (_ [[stack l] r]) [stack [l r]])) (def: #export ||L + {#.doc (doc "Left-injects the top into sum.")} (All [a b] (=> [a] [(| a b)])) (function (_ [stack l]) [stack (0 #0 l)])) (def: #export ||R + {#.doc (doc "Right-injects the top into sum.")} (All [a b] (=> [b] [(| a b)])) (function (_ [stack r]) [stack (0 #1 r)])) (template [<input> <output> <word> <func>] - [(def: #export <word> - (=> [<input> <input>] [<output>]) - (function (_ [[stack subject] param]) - [stack (<func> param subject)]))] + [(`` (def: #export <word> + {#.doc (doc (~~ (template.text [<func> " for " <input> " arithmetic."])))} + (=> [<input> <input>] [<output>]) + (function (_ [[stack subject] param]) + [stack (<func> param subject)])))] [Nat Nat n/+ n.+] [Nat Nat n/- n.-] @@ -237,6 +277,12 @@ ) (def: #export if + {#.doc (doc "If expression." + (is? "then" + (||> (push true) + (push "then") + (push "else") + if)))} (All [___a ___z] (=> {then (=> ___a ___z) else (=> ___a ___z)} @@ -247,6 +293,7 @@ (else stack)))) (def: #export call + {#.doc (doc "Executes an anonymous block on the stack.")} (All [___a ___z] (=> {quote (=> ___a ___z)} ___a [quote] ___z)) @@ -254,6 +301,7 @@ (quote stack))) (def: #export loop + {#.doc (doc "Executes a block as a loop until it yields #0 to stop.")} (All [___] (=> {test (=> ___ ___ [Bit])} ___ [test] ___)) @@ -264,6 +312,7 @@ stack')))) (def: #export dip + {#.doc (doc "Executes a block on the stack, save for the topmost value.")} (All [___ a] (=> ___ [a (=> ___ ___)] ___ [a])) @@ -271,6 +320,7 @@ [(quote stack) a])) (def: #export dip/2 + {#.doc (doc "Executes a block on the stack, save for the 2 topmost values.")} (All [___ a b] (=> ___ [a b (=> ___ ___)] ___ [a b])) @@ -278,6 +328,12 @@ [[(quote stack) a] b])) (def: #export do + {#.doc (doc "Do-while loop expression." + (n.= (inc sample) + (||> (push sample) + (push (push false)) + (push (|>> (push 1) n/+)) + do while)))} (All [___a ___z] (=> {body (=> ___a ___z) pred (=> ___z ___a [Bit])} @@ -287,6 +343,14 @@ [[(body stack) pred] body])) (def: #export while + {#.doc (doc "While loop expression." + (n.= (n.+ distance start) + (||> (push start) + (push (|>> dup + (push start) n/- + (push distance) n/<)) + (push (|>> (push 1) n/+)) + while)))} (All [___a ___z] (=> {body (=> ___z ___a) pred (=> ___a ___z [Bit])} @@ -299,13 +363,27 @@ stack')))) (def: #export compose + {#.doc (doc "Function composition." + (n.= (n.+ 2 sample) + (||> (push sample) + (push (|>> (push 1) n/+)) + (push (|>> (push 1) n/+)) + compose + call)))} (All [___a ___ ___z] (=> [(=> ___a ___) (=> ___ ___z)] [(=> ___a ___z)])) (function (_ [[stack f] g]) [stack (|>> f g)])) -(def: #export curry +(def: #export partial + {#.doc (doc "Partial application." + (n.= (n.+ sample sample) + (||> (push sample) + (push sample) + (push n/+) + partial + call)))} (All [___a ___z a] (=> ___a [a (=> ___a [a] ___z)] ___a [(=> ___a ___z)])) @@ -313,19 +391,21 @@ [stack (|>> (push arg) quote)])) (word: #export when + {#.doc (doc "Only execute the block when #1.")} (All [___] (=> {body (=> ___ ___)} ___ [Bit body] ___)) swap - (push (|>> call)) - (push (|>> drop)) + (push ..call) + (push ..drop) if) (word: #export ? + {#.doc (doc "Choose the top value when #0 and the second-to-top when #1.")} (All [a] (=> [Bit a a] [a])) rotL - (push (|>> drop)) - (push (|>> nip)) + (push ..drop) + (push ..nip) if) diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index 5b954efcd..72d28a0b7 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -58,11 +58,11 @@ [current (async.poll read)] (case current (#.Some [head tail]) - (\ ! map (|>> (#.Cons head)) + (\ ! map (|>> (#.Item head)) (pending tail)) #.None - (in #.Nil)))) + (in #.End)))) (abstract: #export (Actor s) {#obituary [(Async <Obituary>) @@ -106,7 +106,7 @@ (exec (io.run (do io.monad [pending (..pending tail)] - (resolve [error state (#.Cons head pending)]))) + (resolve [error state (#.Item head pending)]))) (in []))) (#try.Success state') @@ -270,7 +270,7 @@ (message: #export (push {value a} state self) (List a) - (let [state' (#.Cons value state)] + (let [state' (#.Item value state)] (async.resolved (#try.Success [state' state']))))) (actor: #export Counter diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index 68a586914..4f96b2122 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -78,7 +78,7 @@ (f value) #.None - (let [new [_value (#.Cons f _observers)]] + (let [new [_value (#.Item f _observers)]] (do ! [swapped? (atom.compare_and_swap old new async)] (if swapped? diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index 9bda3c334..beecb2511 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -102,9 +102,9 @@ (def: (apply ff fa) (do async.monad - [cons_f ff - cons_a fa] - (case [cons_f cons_a] + [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) (apply tail_f tail_a)])) @@ -157,8 +157,8 @@ (io (exec (: (Async Any) (loop [channel channel] (do async.monad - [cons channel] - (case cons + [item channel] + (case item (#.Some [head tail]) (case (io.run (subscriber head)) (#.Some _) @@ -176,8 +176,8 @@ "that pass the test.")} (All [a] (-> (-> a Bit) (Channel a) (Channel a))) (do async.monad - [cons channel] - (case cons + [item channel] + (case item (#.Some [head tail]) (let [tail' (only pass? tail)] (if (pass? head) @@ -200,8 +200,8 @@ (-> (-> b a (Async a)) a (Channel b) (Async a))) (do {! async.monad} - [cons channel] - (case cons + [item channel] + (case item #.None (in init) @@ -215,8 +215,8 @@ (-> (-> b a (Async a)) a (Channel b) (Channel a))) (do {! async.monad} - [cons channel] - (case cons + [item channel] + (case item #.None (in (#.Some [init (in #.None)])) @@ -254,8 +254,8 @@ (def: (distinct' equivalence previous channel) (All [a] (-> (Equivalence a) a (Channel a) (Channel a))) (do async.monad - [cons channel] - (case cons + [item channel] + (case item (#.Some [head tail]) (if (\ equivalence = previous head) (distinct' equivalence previous tail) @@ -267,8 +267,8 @@ (def: #export (distinct equivalence channel) (All [a] (-> (Equivalence a) (Channel a) (Channel a))) (do async.monad - [cons channel] - (case cons + [item channel] + (case item (#.Some [head tail]) (in (#.Some [head (distinct' equivalence head tail)])) @@ -278,23 +278,23 @@ (def: #export (consume channel) (All [a] (-> (Channel a) (Async (List a)))) (do {! async.monad} - [cons channel] - (case cons + [item channel] + (case item (#.Some [head tail]) - (\ ! map (|>> (#.Cons head)) + (\ ! map (|>> (#.Item head)) (consume tail)) #.None - (in #.Nil)))) + (in #.End)))) (def: #export (sequential milli_seconds values) {#.doc (doc "Transforms the given list into a channel with the same elements.")} (All [a] (-> Nat (List a) (Channel a))) (case values - #.Nil + #.End ..empty - (#.Cons head tail) + (#.Item head tail) (async.resolved (#.Some [head (do async.monad [_ (async.wait milli_seconds)] (sequential milli_seconds tail))])))) diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux index da01d2db8..183558265 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -72,7 +72,7 @@ (do io.monad [#let [[channel sink] (frp.channel [])] _ (atom.update (function (_ [value observers]) - [value (#.Cons sink observers)]) + [value (#.Item sink observers)]) (:representation target))] (in [channel sink]))) ) @@ -109,23 +109,23 @@ #.None (let [value (..read! var)] - [(#.Cons [var value value] tx) + [(#.Item [var value value] tx) value])))) (def: (update_tx_value var value tx) (All [a] (-> (Var a) a Tx Tx)) (case tx - #.Nil - #.Nil + #.End + #.End - (#.Cons [_var _original _current] tx') + (#.Item [_var _original _current] tx') (if (is? (:as (Var Any) var) (:as (Var Any) _var)) - (#.Cons {#var (:as (Var Any) _var) + (#.Item {#var (:as (Var Any) _var) #original (:as Any _original) #current (:as Any value)} tx') - (#.Cons {#var _var + (#.Item {#var _var #original _original #current _current} (update_tx_value var value tx'))))) @@ -139,7 +139,7 @@ []] #.None - [(#.Cons [var (..read! var) value] tx) + [(#.Item [var (..read! var) value] tx) []]))) (implementation: #export functor diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index 36f65d0ea..9a6f3a7b1 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -130,7 +130,7 @@ ## Default (do {! io.monad} [now (\ ! map (|>> instant.to_millis .nat) instant.now) - _ (atom.update (|>> (#.Cons {#creation now + _ (atom.update (|>> (#.Item {#creation now #delay milli_seconds #action action})) ..runner)] @@ -153,7 +153,7 @@ [threads (atom.read ..runner)] (case threads ## And... we're done! - #.Nil + #.End (in []) _ diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index 22b882f85..c57c9877b 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -34,6 +34,7 @@ #constructor (-> a Text)}) (def: #export (match? exception error) + {#.doc (doc "Is this exception the cause of the error message?")} (All [e] (-> (Exception e) Text Bit)) (text.starts_with? (get@ #label exception) error)) @@ -100,7 +101,7 @@ (exception: #export some_exception) "" "Complex case:" - (exception: #export [optional type variables] (some_exception {optional Text} {arguments Int}) + (exception: #export [arbitrary type variables] (some_exception {optional Text} {arguments Int}) optional_body))} (macro.with_gensyms [g!descriptor] (do meta.monad @@ -140,29 +141,37 @@ (text.replace_all text.new_line on_new_line) ($_ text\compose padding header header_separator)))))] (case entries - #.Nil + #.End "" - (#.Cons head tail) + (#.Item head tail) (list\fold (function (_ post pre) ($_ text\compose pre text.new_line (on_entry post))) (on_entry head) tail)))) (syntax: #export (report {entries (p.many (s.tuple (p.and s.any s.any)))}) + {#.doc (doc "An error report." + (: Text + (report ["Row 0" value/0] + ["Row 1" value/1] + ,,, + ["Row N" value/N])))} (in (list (` ((~! report') (list (~+ (|> entries (list\map (function (_ [header message]) (` [(~ header) (~ message)]))))))))))) (def: #export (enumerate format entries) + {#.doc (doc "A numbered report of the entries on a list." + "NOTE: 0-based numbering.")} (All [a] (-> (-> a Text) (List a) Text)) (|> entries (list\fold (function (_ entry [index next]) [(inc index) - (#.Cons [(n\encode index) (format entry)] + (#.Item [(n\encode index) (format entry)] next)]) - [0 #.Nil]) + [0 #.End]) product.right list.reverse ..report')) @@ -183,6 +192,7 @@ error)) (def: #export (with exception message computation) + {#.doc (doc "If a computation fails, prepends the exception to the error.")} (All [e a] (-> (Exception e) e (Try a) (Try a))) (case computation (#//.Failure error) diff --git a/stdlib/source/library/lux/control/function.lux b/stdlib/source/library/lux/control/function.lux index 2f880a872..32d3633ef 100644 --- a/stdlib/source/library/lux/control/function.lux +++ b/stdlib/source/library/lux/control/function.lux @@ -36,6 +36,7 @@ (function (_ x y) (f y x))) (def: #export (apply input function) + {#.doc (doc "Simple 1-argument function application.")} (All [i o] (-> i (-> i o) o)) (function input)) diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index 73407a7f1..d53249897 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -70,10 +70,10 @@ (and (even? 4) (odd? 5))))} (case functions - #.Nil + #.End (in (list body)) - (#.Cons mutual #.Nil) + (#.Item mutual #.End) (.let [g!name (|> mutual (get@ [#declaration #declaration.name]) code.local_identifier)] (in (list (` (.let [(~ g!name) (: (~ (get@ #type mutual)) (function (~ (declaration.format (get@ #declaration mutual))) @@ -134,10 +134,10 @@ 0 false _ (even? (dec number)))]))} (case functions - #.Nil + #.End (in (list)) - (#.Cons definition #.Nil) + (#.Item definition #.End) (.let [(^slots [#exported? #mutual]) definition (^slots [#declaration #type #body]) mutual] (in (list (` (.def: diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index f473208a9..d38044ec1 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -90,6 +90,9 @@ (#try.Success [input' (#.Some x)])))) (def: #export (run parser input) + {#.doc (doc "Executes the parser on the input." + "Does not verify that all of the input has been consumed by the parser." + "Returns both the parser's output, and a value that represents the remaining input.")} (All [s a] (-> (Parser s a) s (Try [s a]))) (parser input)) @@ -151,7 +154,7 @@ (-> (Parser s a) (Parser s (List a)))) (|> (..some parser) (..and parser) - (\ ..monad map (|>> #.Cons)))) + (\ ..monad map (|>> #.Item)))) (def: #export (exactly amount parser) {#.doc "Parse exactly N times."} @@ -162,7 +165,7 @@ [x parser] (|> parser (exactly (dec amount)) - (\ ! map (|>> (#.Cons x))))))) + (\ ! map (|>> (#.Item x))))))) (def: #export (at_least amount parser) {#.doc "Parse at least N times."} @@ -182,7 +185,7 @@ (#try.Success [input (list)]) (#try.Success [input' x]) - (..run (\ ..monad map (|>> (#.Cons x)) + (..run (\ ..monad map (|>> (#.Item x)) (at_most (dec amount) parser)) input'))))) @@ -197,21 +200,22 @@ (in minimum)))) (def: #export (separated_by separator parser) - {#.doc "Parsers instances of 'parser' that are separated by instances of 'separator'."} + {#.doc "Parses instances of 'parser' that are separated by instances of 'separator'."} (All [s a b] (-> (Parser s b) (Parser s a) (Parser s (List a)))) (do {! ..monad} [?x (..maybe parser)] (case ?x #.None - (in #.Nil) + (in #.End) (#.Some x) (|> parser (..and separator) ..some - (\ ! map (|>> (list\map product.right) (#.Cons x))))))) + (\ ! map (|>> (list\map product.right) (#.Item x))))))) (def: #export (not parser) + {#.doc (doc "Only succeeds when the underlying parser fails.")} (All [s a] (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) @@ -222,11 +226,13 @@ (#try.Failure "Expected to fail; yet succeeded.")))) (def: #export (failure message) + {#.doc (doc "Always fail with this 'message'.")} (All [s a] (-> Text (Parser s a))) (function (_ input) (#try.Failure message))) (def: #export (lift operation) + {#.doc (doc "Lift a potentially failed computation into a parser.")} (All [s a] (-> (Try a) (Parser s a))) (function (_ input) (case operation @@ -248,23 +254,26 @@ (#try.Success [input' output])))) (def: #export remaining + {#.doc (doc "Yield the remaining input (without consuming it).")} (All [s] (Parser s s)) (function (_ inputs) (#try.Success [inputs inputs]))) (def: #export (rec parser) - {#.doc "Combinator for recursive parser."} + {#.doc "Combinator for recursive parsers."} (All [s a] (-> (-> (Parser s a) (Parser s a)) (Parser s a))) (function (_ inputs) (..run (parser (rec parser)) inputs))) (def: #export (after param subject) + {#.doc (doc "Run the parser after another one (whose output is ignored).")} (All [s _ a] (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [_ param] subject)) (def: #export (before param subject) + {#.doc (doc "Run the parser before another one (whose output is ignored).")} (All [s _ a] (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [output subject @@ -272,6 +281,7 @@ (in output))) (def: #export (only test parser) + {#.doc (doc "Only succeed when the parser's output passes a test.")} (All [s a] (-> (-> a Bit) (Parser s a) (Parser s a))) (do ..monad [output parser @@ -279,6 +289,7 @@ (in output))) (def: #export (parses? parser) + {#.doc (doc "Ignore a parser's output and just verify that it succeeds.")} (All [s a] (-> (Parser s a) (Parser s Bit))) (function (_ input) (case (parser input) @@ -289,6 +300,7 @@ (#try.Success [input' true])))) (def: #export (parses parser) + {#.doc (doc "Ignore a parser's output and just execute it.")} (All [s a] (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) @@ -299,6 +311,8 @@ (#try.Success [input' []])))) (def: #export (speculative parser) + {#.doc (doc "Executes a parser, without actually consuming the input." + "That way, the same input can be consumed again by another parser.")} (All [s a] (-> (Parser s a) (Parser s a))) (function (_ input) (case (parser input) @@ -309,6 +323,7 @@ output))) (def: #export (codec codec parser) + {#.doc (doc "Decode the output of a parser using a codec.")} (All [s a z] (-> (Codec a z) (Parser s a) (Parser s z))) (function (_ input) (case (parser input) diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/library/lux/control/parser/analysis.lux index 2b585c31e..b94490a95 100644 --- a/stdlib/source/library/lux/control/parser/analysis.lux +++ b/stdlib/source/library/lux/control/parser/analysis.lux @@ -59,7 +59,7 @@ (#try.Failure error) (#try.Failure error) - (#try.Success [#.Nil value]) + (#try.Success [#.End value]) (#try.Success value) (#try.Success [unconsumed _]) @@ -70,10 +70,10 @@ (Parser Analysis) (function (_ input) (case input - #.Nil + #.End (exception.except ..cannot_parse input) - (#.Cons [head tail]) + (#.Item [head tail]) (#try.Success [tail head])))) (def: #export end! @@ -81,7 +81,7 @@ (Parser Any) (function (_ tokens) (case tokens - #.Nil (#try.Success [tokens []]) + #.End (#try.Success [tokens []]) _ (#try.Failure (format "Expected list of tokens to be empty!" (remaining_inputs tokens)))))) @@ -90,7 +90,7 @@ (Parser Bit) (function (_ tokens) (#try.Success [tokens (case tokens - #.Nil true + #.End true _ false)]))) (template [<query> <assertion> <tag> <type> <eq>] diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/library/lux/control/parser/cli.lux index e8796ff1b..df59dbd44 100644 --- a/stdlib/source/library/lux/control/parser/cli.lux +++ b/stdlib/source/library/lux/control/parser/cli.lux @@ -20,7 +20,7 @@ (case (//.run parser inputs) (#try.Success [remaining output]) (case remaining - #.Nil + #.End (#try.Success output) _ @@ -34,7 +34,7 @@ (Parser Text) (function (_ inputs) (case inputs - (#.Cons arg inputs') + (#.Item arg inputs') (#try.Success [inputs' arg]) _ @@ -70,13 +70,13 @@ (#try.Failure try) (case immediate - #.Nil + #.End (#try.Failure try) - (#.Cons to_omit immediate') + (#.Item to_omit immediate') (do try.monad [[remaining output] (recur immediate')] - (in [(#.Cons to_omit remaining) + (in [(#.Item to_omit remaining) output]))))))) (def: #export end @@ -84,7 +84,7 @@ (Parser Any) (function (_ inputs) (case inputs - #.Nil (#try.Success [inputs []]) + #.End (#try.Success [inputs []]) _ (#try.Failure (format "Unknown parameters: " (text.join_with " " inputs)))))) (def: #export (named name value) diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index 6f52b23d9..7dd43ffa4 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -24,8 +24,8 @@ (def: (join_pairs pairs) (All [a] (-> (List [a a]) (List a))) (case pairs - #.Nil #.Nil - (#.Cons [[x y] pairs']) (list& x y (join_pairs pairs')))) + #.End #.End + (#.Item [[x y] pairs']) (list& x y (join_pairs pairs')))) (type: #export Parser {#.doc "A Lux code parser."} @@ -41,10 +41,10 @@ (Parser Code) (function (_ tokens) (case tokens - #.Nil + #.End (#try.Failure "There are no tokens to parse!") - (#.Cons [t tokens']) + (#.Item [t tokens']) (#try.Success [tokens' t])))) (template [<query> <check> <type> <tag> <eq> <desc>] @@ -54,7 +54,7 @@ (Parser <type>) (function (_ tokens) (case tokens - (#.Cons [[_ (<tag> x)] tokens']) + (#.Item [[_ (<tag> x)] tokens']) (#try.Success [tokens' x]) _ @@ -65,7 +65,7 @@ (-> <type> (Parser Any)) (function (_ tokens) (case tokens - (#.Cons [[_ (<tag> actual)] tokens']) + (#.Item [[_ (<tag> actual)] tokens']) (if (\ <eq> = expected actual) (#try.Success [tokens' []]) <failure>) @@ -88,7 +88,7 @@ (-> Code (Parser Any)) (function (_ tokens) (case tokens - (#.Cons [token tokens']) + (#.Item [token tokens']) (if (code\= code token) (#try.Success [tokens' []]) (#try.Failure ($_ text\compose "Expected a " (code.format code) " but instead got " (code.format token) @@ -104,7 +104,7 @@ (Parser Text) (function (_ tokens) (case tokens - (#.Cons [[_ (<tag> ["" x])] tokens']) + (#.Item [[_ (<tag> ["" x])] tokens']) (#try.Success [tokens' x]) _ @@ -115,7 +115,7 @@ (-> Text (Parser Any)) (function (_ tokens) (case tokens - (#.Cons [[_ (<tag> ["" actual])] tokens']) + (#.Item [[_ (<tag> ["" actual])] tokens']) (if (\ <eq> = expected actual) (#try.Success [tokens' []]) <failure>) @@ -134,9 +134,9 @@ (-> (Parser a) (Parser a))) (function (_ tokens) (case tokens - (#.Cons [[_ (<tag> members)] tokens']) + (#.Item [[_ (<tag> members)] tokens']) (case (p members) - (#try.Success [#.Nil x]) (#try.Success [tokens' x]) + (#try.Success [#.End x]) (#try.Success [tokens' x]) _ (#try.Failure ($_ text\compose "Parser was expected to fully consume " <desc> (remaining_inputs tokens)))) _ @@ -152,9 +152,9 @@ (-> (Parser a) (Parser a))) (function (_ tokens) (case tokens - (#.Cons [[_ (#.Record pairs)] tokens']) + (#.Item [[_ (#.Record pairs)] tokens']) (case (p (join_pairs pairs)) - (#try.Success [#.Nil x]) (#try.Success [tokens' x]) + (#try.Success [#.End x]) (#try.Success [tokens' x]) _ (#try.Failure ($_ text\compose "Parser was expected to fully consume record" (remaining_inputs tokens)))) _ @@ -165,7 +165,7 @@ (Parser Any) (function (_ tokens) (case tokens - #.Nil (#try.Success [tokens []]) + #.End (#try.Success [tokens []]) _ (#try.Failure ($_ text\compose "Expected list of tokens to be empty!" (remaining_inputs tokens)))))) (def: #export end? @@ -173,7 +173,7 @@ (Parser Bit) (function (_ tokens) (#try.Success [tokens (case tokens - #.Nil true + #.End true _ false)]))) (def: #export (run parser inputs) @@ -185,7 +185,7 @@ (#try.Success [unconsumed value]) (case unconsumed - #.Nil + #.End (#try.Success value) _ diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/library/lux/control/parser/json.lux index cc20f6512..f186a315a 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -39,7 +39,7 @@ (case (//.run parser (list json)) (#try.Success [remainder output]) (case remainder - #.Nil + #.End (#try.Success output) _ @@ -53,10 +53,10 @@ (Parser JSON) (<| (function (_ inputs)) (case inputs - #.Nil + #.End (exception.except ..empty_input []) - (#.Cons head tail) + (#.Item head tail) (#try.Success [tail head])))) (exception: #export (unexpected_value {value JSON}) @@ -138,7 +138,7 @@ (#try.Success [remainder output]) (case remainder - #.Nil + #.End (in output) _ @@ -166,7 +166,7 @@ (#try.Success [remainder output]) (case remainder - #.Nil + #.End (in output) _ @@ -184,7 +184,7 @@ (^ (list& (#/.String key) value inputs')) (if (text\= key field_name) (case (//.run parser (list value)) - (#try.Success [#.Nil output]) + (#try.Success [#.End output]) (#try.Success [inputs' output]) (#try.Success [inputs'' _]) @@ -197,7 +197,7 @@ (in [(list& (#/.String key) value inputs'') output]))) - #.Nil + #.End (exception.except ..empty_input []) _ diff --git a/stdlib/source/library/lux/control/parser/synthesis.lux b/stdlib/source/library/lux/control/parser/synthesis.lux index 3496fde42..b902d4b81 100644 --- a/stdlib/source/library/lux/control/parser/synthesis.lux +++ b/stdlib/source/library/lux/control/parser/synthesis.lux @@ -60,7 +60,7 @@ (#try.Failure error) (#try.Failure error) - (#try.Success [#.Nil value]) + (#try.Success [#.End value]) (#try.Success value) (#try.Success [unconsumed _]) @@ -71,10 +71,10 @@ (Parser Synthesis) (.function (_ input) (case input - #.Nil + #.End (exception.except ..empty_input []) - (#.Cons [head tail]) + (#.Item [head tail]) (#try.Success [tail head])))) (def: #export end! @@ -82,7 +82,7 @@ (Parser Any) (.function (_ tokens) (case tokens - #.Nil (#try.Success [tokens []]) + #.End (#try.Success [tokens []]) _ (exception.except ..expected_empty_input [tokens])))) (def: #export end? @@ -90,7 +90,7 @@ (Parser Bit) (.function (_ tokens) (#try.Success [tokens (case tokens - #.Nil true + #.End true _ false)]))) (template [<query> <assertion> <tag> <type> <eq>] diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index d8177a553..c4438fbf8 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -81,7 +81,7 @@ (#try.Success [[env' remaining] output]) (case remaining - #.Nil + #.End (#try.Success output) _ @@ -114,10 +114,10 @@ (Parser Type) (.function (_ [env inputs]) (case inputs - #.Nil + #.End (exception.except ..empty_input []) - (#.Cons headT tail) + (#.Item headT tail) (#try.Success [[env inputs] headT])))) (def: #export any @@ -125,10 +125,10 @@ (Parser Type) (.function (_ [env inputs]) (case inputs - #.Nil + #.End (exception.except ..empty_input []) - (#.Cons headT tail) + (#.Item headT tail) (#try.Success [[env tail] headT])))) (def: #export (local types poly) @@ -202,7 +202,7 @@ (|> env' (dictionary.put funcI [headT funcL]) (dictionary.put (inc funcI) [(#.Parameter (inc funcI)) varL])) - (#.Cons varL all_varsL))) + (#.Item varL all_varsL))) (let [partialI (|> current_arg (n.* 2) (n.+ funcI)) partial_varI (inc partialI) partial_varL (label partial_varI) @@ -213,7 +213,7 @@ (|> env' (dictionary.put partialI [.Nothing partialC]) (dictionary.put partial_varI [(#.Parameter partial_varI) partial_varL])) - (#.Cons partial_varL all_varsL)))) + (#.Item partial_varL all_varsL)))) [all_varsL env']))]] (<| (with_env env') (local (list non_poly)) @@ -240,7 +240,7 @@ #let [[funcT paramsT] (type.flat_application (type.anonymous headT))]] (if (n.= 0 (list.size paramsT)) (//.failure (exception.construct ..not_application headT)) - (..local (#.Cons funcT paramsT) poly)))) + (..local (#.Item funcT paramsT) poly)))) (template [<name> <test> <doc>] [(def: #export (<name> expected) @@ -324,7 +324,7 @@ (`` (template: (|nothing|) (#.Named [(~~ (static .prelude_module)) "Nothing"] - (#.UnivQ #.Nil + (#.UnivQ #.End (#.Parameter 1))))) (def: #export (recursive poly) diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/library/lux/control/parser/xml.lux index eb11fb3fd..4af88b9b3 100644 --- a/stdlib/source/library/lux/control/parser/xml.lux +++ b/stdlib/source/library/lux/control/parser/xml.lux @@ -60,10 +60,10 @@ (Parser Text) (function (_ [attrs documents]) (case documents - #.Nil + #.End (exception.except ..empty_input []) - (#.Cons head tail) + (#.Item head tail) (case head (#/.Text value) (#try.Success [[attrs tail] value]) @@ -76,10 +76,10 @@ (Parser Tag) (function (_ [attrs documents]) (case documents - #.Nil + #.End (exception.except ..empty_input []) - (#.Cons head _) + (#.Item head _) (case head (#/.Text _) (exception.except ..unexpected_input []) @@ -103,10 +103,10 @@ (All [a] (-> Tag (Parser a) (Parser a))) (function (_ [attrs documents]) (case documents - #.Nil + #.End (exception.except ..empty_input []) - (#.Cons head tail) + (#.Item head tail) (case head (#/.Text _) (exception.except ..unexpected_input []) @@ -123,10 +123,10 @@ (Parser Any) (function (_ [attrs documents]) (case documents - #.Nil + #.End (exception.except ..empty_input []) - (#.Cons head tail) + (#.Item head tail) (#try.Success [[attrs tail] []])))) (exception: #export nowhere) @@ -141,11 +141,11 @@ (#try.Failure error) (case input - #.Nil + #.End (exception.except ..nowhere []) - (#.Cons head tail) + (#.Item head tail) (do try.monad [[[attrs tail'] output] (recur [attrs tail])] - (in [[attrs (#.Cons 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 1945eec59..128c8f036 100644 --- a/stdlib/source/library/lux/control/pipe.lux +++ b/stdlib/source/library/lux/control/pipe.lux @@ -68,11 +68,26 @@ (|> (~ g!temp) (~+ else))))))))) (syntax: #export (if> {test body^} {then body^} {else body^} prev) + {#.doc (doc "If-branching." + (is? (if (n.even? sample) + "even" + "odd") + (|> sample + (if> [n.even?] + [(new> "even" [])] + [(new> "odd" [])]))))} (in (list (` (cond> [(~+ test)] [(~+ then)] [(~+ else)] (~ prev)))))) (syntax: #export (when> {test body^} {then body^} prev) + {#.doc (doc "Only execute the body when the test passes." + (is? (if (n.even? sample) + (n.* 2 sample) + sample) + (|> sample + (when> [n.even?] + [(n.* 2)]))))} (in (list (` (cond> [(~+ test)] [(~+ then)] [] (~ prev)))))) diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index cf565cd22..8c46ef9a8 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -2,8 +2,8 @@ [library [lux #* [abstract - ["." functor (#+ Functor)] [apply (#+ Apply)] + ["." functor (#+ Functor)] ["." monad (#+ Monad do)]]]]) (type: #export (Reader r a) @@ -21,6 +21,7 @@ (|>> change proc)) (def: #export (run env proc) + {#.doc (doc "Executes the reader against the given environment.")} (All [r a] (-> r (Reader r a) a)) (proc env)) diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index 98250983a..281c8d19e 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -19,6 +19,8 @@ (-> r (! (Try Any)))) (type: #export (Region r ! a) + {#.doc (doc "A region where resources may be be claimed and where a side-effecting computation may be performed." + "Every resource is paired with a function that knows how to clean/reclaim it, to make sure there are no leaks.")} (-> [r (List (Cleaner r !))] (! [(List (Cleaner r !)) (Try a)]))) @@ -52,6 +54,7 @@ (exception.except ..clean_up_error [error output]))) (def: #export (run monad computation) + {#.doc (doc "Executes a region-based computation, with a side-effect determined by the monad.")} (All [! a] (-> (Monad !) (All [r] (Region r ! a)) (! (Try a)))) @@ -62,10 +65,11 @@ (in (list\fold combine_outcomes output results)))) (def: #export (acquire monad cleaner value) + {#.doc (doc "Acquire a resource while pairing it a function that knows how to reclaim it.")} (All [! a] (-> (Monad !) (-> a (! (Try Any))) a (All [r] (Region r ! a)))) (function (_ [region cleaners]) - (\ monad in [(#.Cons (function (_ region) (cleaner value)) + (\ monad in [(#.Item (function (_ region) (cleaner value)) cleaners) (#try.Success value)]))) @@ -136,6 +140,7 @@ (in [cleaners (#try.Failure error)])))))) (def: #export (failure monad error) + {#.doc (doc "Immediately fail with this 'message'.")} (All [! a] (-> (Monad !) Text (All [r] (Region r ! a)))) @@ -143,16 +148,18 @@ (\ monad in [cleaners (#try.Failure error)]))) (def: #export (except monad exception message) + {#.doc (doc "Fail by throwing/raising an exception.")} (All [! e a] (-> (Monad !) (Exception e) e (All [r] (Region r ! a)))) (failure monad (exception.construct exception message))) (def: #export (lift monad operation) + {#.doc (doc "Lift an effectful computation into a region-based computation.")} (All [! a] (-> (Monad !) (! a) (All [r] (Region r ! a)))) (function (_ [region cleaners]) - (do monad - [output operation] - (in [cleaners (#try.Success output)])))) + (\ monad map + (|>> #try.Success [cleaners]) + operation))) diff --git a/stdlib/source/library/lux/control/remember.lux b/stdlib/source/library/lux/control/remember.lux index d8a6dc8a7..659c1cc39 100644 --- a/stdlib/source/library/lux/control/remember.lux +++ b/stdlib/source/library/lux/control/remember.lux @@ -18,6 +18,7 @@ ["." meta] [macro ["." code] + ["." template] [syntax (#+ syntax:)]]]]) (exception: #export (must_remember {deadline Date} {today Date} {message Text} {focus (Maybe Code)}) @@ -47,6 +48,13 @@ (<>.failure message))))) (syntax: #export (remember {deadline ..deadline} {message <c>.text} {focus (<>.maybe <c>.any)}) + {#.doc (doc "A message with an expiration date." + "Can have an optional piece of code to focus on." + (remember "2022-04-01" + "Do this, that and the other.") + (remember "2022-04-01" + "Improve the performace." + (some (complicated (computation 123)))))} (let [now (io.run instant.now) today (instant.date now)] (if (date\< deadline today) @@ -59,15 +67,22 @@ (meta.failure (exception.construct ..must_remember [deadline today message focus]))))) (template [<name> <message>] - [(syntax: #export (<name> {deadline ..deadline} {message <c>.text} {focus (<>.maybe <c>.any)}) - (in (list (` (..remember (~ (code.text (%.date deadline))) - (~ (code.text (format <message> " " message))) - (~+ (case focus - (#.Some focus) - (list focus) + [(`` (syntax: #export (<name> {deadline ..deadline} {message <c>.text} {focus (<>.maybe <c>.any)}) + {#.doc (doc (~~ (template.text ["A " <message> " message with an expiration date."])) + "Can have an optional piece of code to focus on." + (<name> "2022-04-01" + "Do this, that and the other.") + (<name> "2022-04-01" + "Improve the performace." + (some (complicated (computation 123)))))} + (in (list (` (..remember (~ (code.text (%.date deadline))) + (~ (code.text (format <message> " " message))) + (~+ (case focus + (#.Some focus) + (list focus) - #.None - (list))))))))] + #.None + (list)))))))))] [to_do "TODO"] [fix_me "FIXME"] diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index 661c081d8..447b6428e 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -29,13 +29,13 @@ [(change state) []])) (def: #export (use user) - {#.doc "Run function on current state."} + {#.doc "Run a function on the current state."} (All [s a] (-> (-> s a) (State s a))) (function (_ state) [state (user state)])) (def: #export (local change action) - {#.doc "Run computation with a locally-modified state."} + {#.doc "Run the computation with a locally-modified state."} (All [s a] (-> (-> s s) (State s a) (State s a))) (function (_ state) (let [[state' output] (action (change state))] @@ -80,6 +80,7 @@ (ma state'))))) (def: #export (while condition body) + {#.doc (doc "A stateful while loop.")} (All [s] (-> (State s Bit) (State s Any) (State s Any))) (do {! ..monad} [execute? condition] @@ -90,6 +91,7 @@ (in [])))) (def: #export (do_while condition body) + {#.doc (doc "A stateful do-while loop.")} (All [s] (-> (State s Bit) (State s Any) (State s Any))) (do ..monad [_ body] @@ -120,7 +122,7 @@ (-> s (M [s a]))) (def: #export (run' state action) - {#.doc "Run a stateful computation decorated by a monad."} + {#.doc "Execute a stateful computation decorated by a monad."} (All [M s a] (-> s (State' M s a) (M [s a]))) (action state)) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index ac34275aa..c1b5cd7bc 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -22,7 +22,7 @@ (type: #export (Array a) {#.doc "Mutable arrays."} - (#.Primitive ..type_name (#.Cons a #.Nil))) + (#.Primitive ..type_name (#.Item a #.End))) (with_expansions [<index_type> (primitive "java.lang.Long") <elem_type> (primitive "java.lang.Object") @@ -279,13 +279,13 @@ (def: #export (to_list array) (All [a] (-> (Array a) (List a))) (loop [idx (dec (size array)) - output #.Nil] + output #.End] (if (n.= ..underflow idx) output (recur (dec idx) (case (read idx array) (#.Some head) - (#.Cons head output) + (#.Item head output) #.None output))))) @@ -293,11 +293,11 @@ (def: #export (to_list' default array) (All [a] (-> a (Array a) (List a))) (loop [idx (dec (size array)) - output #.Nil] + output #.End] (if (n.= ..underflow idx) output (recur (dec idx) - (#.Cons (maybe.default default (read idx array)) + (#.Item (maybe.default default (read idx array)) output))))) (implementation: #export (equivalence (^open ",\.")) diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index 490f3f3e0..81ad72fbd 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -533,7 +533,7 @@ (case node (#Hierarchy _size hierarchy) (array\fold (function (_ sub_node tail) (list\compose (entries' sub_node) tail)) - #.Nil + #.End hierarchy) (#Base bitmap base) @@ -543,13 +543,13 @@ (list\compose (entries' sub_node) tail) (#.Right [key' val']) - (#.Cons [key' val'] tail))) - #.Nil + (#.Item [key' val'] tail))) + #.End base) (#Collisions hash colls) - (array\fold (function (_ [key' val'] tail) (#.Cons [key' val'] tail)) - #.Nil + (array\fold (function (_ [key' val'] tail) (#.Item [key' val'] tail)) + #.End colls))) (type: #export (Dictionary k v) @@ -639,8 +639,8 @@ (All [k v] (-> (Dictionary k v) (List <side>))) (|>> ..entries (list\fold (function (_ [k v] bundle) - (#.Cons <side> bundle)) - #.Nil)))] + (#.Item <side> bundle)) + #.End)))] [keys k] [values v] diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index cb187b477..fcac55d8a 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -572,10 +572,10 @@ (loop [entriesR (entries reference) entriesS (entries sample)] (case [entriesR entriesS] - [#.Nil #.Nil] + [#.End #.End] #1 - [(#.Cons [keyR valueR] entriesR') (#.Cons [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 f3f51c779..ac7cbcf6f 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux @@ -17,7 +17,7 @@ (def: #export empty PList - #.Nil) + #.End) (def: #export size (All [a] (-> (PList a) Nat)) @@ -30,10 +30,10 @@ (def: #export (get key properties) (All [a] (-> Text (PList a) (Maybe a))) (case properties - #.Nil + #.End #.None - (#.Cons [k' v'] properties') + (#.Item [k' v'] properties') (if (text\= key k') (#.Some v') (get key properties')))) @@ -59,37 +59,37 @@ (def: #export (put key val properties) (All [a] (-> Text a (PList a) (PList a))) (case properties - #.Nil + #.End (list [key val]) - (#.Cons [k' v'] properties') + (#.Item [k' v'] properties') (if (text\= key k') - (#.Cons [key val] + (#.Item [key val] properties') - (#.Cons [k' v'] + (#.Item [k' v'] (put key val properties'))))) (def: #export (update key f properties) (All [a] (-> Text (-> a a) (PList a) (PList a))) (case properties - #.Nil - #.Nil + #.End + #.End - (#.Cons [k' v'] properties') + (#.Item [k' v'] properties') (if (text\= key k') - (#.Cons [k' (f v')] properties') - (#.Cons [k' v'] (update key f properties'))))) + (#.Item [k' (f v')] properties') + (#.Item [k' v'] (update key f properties'))))) (def: #export (remove key properties) (All [a] (-> Text (PList a) (PList a))) (case properties - #.Nil + #.End properties - (#.Cons [k' v'] properties') + (#.Item [k' v'] properties') (if (text\= key k') properties' - (#.Cons [k' v'] + (#.Item [k' v'] (remove key properties'))))) (def: #export equivalence diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index e1661f1a4..feaebb373 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -20,60 +20,60 @@ ["n" nat]]]]]) ## (type: (List a) -## #Nil -## (#Cons a (List a))) +## #End +## (#Item a (List a))) (implementation: #export fold (Fold List) (def: (fold f init xs) (case xs - #.Nil + #.End init - (#.Cons x xs') + (#.Item x xs') (fold f (f x init) xs')))) (def: #export (folds f init inputs) (All [a b] (-> (-> a b b) b (List a) (List b))) (case inputs - #.Nil + #.End (list init) - (#.Cons [head tail]) - (#.Cons [init (folds f (f head init) tail)]))) + (#.Item [head tail]) + (#.Item [init (folds f (f head init) tail)]))) (def: #export (reverse xs) (All [a] (-> (List a) (List a))) - (fold (function (_ head tail) (#.Cons head tail)) - #.Nil + (fold (function (_ head tail) (#.Item head tail)) + #.End xs)) (def: #export (only keep? xs) (All [a] (-> (Predicate a) (List a) (List a))) (case xs - #.Nil - #.Nil + #.End + #.End - (#.Cons x xs') + (#.Item x xs') (if (keep? x) - (#.Cons x (only keep? xs')) + (#.Item x (only keep? xs')) (only keep? xs')))) (def: #export (partition satisfies? list) {#.doc "Divide the list into all elements that satisfy a predicate, and all elements that do not."} (All [a] (-> (Predicate a) (List a) [(List a) (List a)])) (case list - #.Nil - [#.Nil #.Nil] + #.End + [#.End #.End] - (#.Cons head tail) + (#.Item head tail) (let [[in out] (partition satisfies? tail)] (if (satisfies? head) - [(#.Cons head in) out] - [in (#.Cons head out)])))) + [(#.Item head in) out] + [in (#.Item head out)])))) (def: #export (as_pairs xs) {#.doc (doc "Cut the list into pairs of 2." @@ -81,10 +81,10 @@ (All [a] (-> (List a) (List [a a]))) (case xs (^ (list& x1 x2 xs')) - (#.Cons [x1 x2] (as_pairs xs')) + (#.Item [x1 x2] (as_pairs xs')) _ - #.Nil)) + #.End)) (template [<name> <then> <else>] [(def: #export (<name> n xs) @@ -92,14 +92,14 @@ (-> Nat (List a) (List a))) (if (n.> 0 n) (case xs - #.Nil - #.Nil + #.End + #.End - (#.Cons x xs') + (#.Item x xs') <then>) <else>))] - [take (#.Cons x (take (dec n) xs')) #.Nil] + [take (#.Item x (take (dec n) xs')) #.End] [drop (drop (dec n) xs') xs] ) @@ -108,15 +108,15 @@ (All [a] (-> (Predicate a) (List a) (List a))) (case xs - #.Nil - #.Nil + #.End + #.End - (#.Cons x xs') + (#.Item x xs') (if (predicate x) <then> <else>)))] - [take_while (#.Cons x (take_while predicate xs')) #.Nil] + [take_while (#.Item x (take_while predicate xs')) #.End] [drop_while (drop_while predicate xs') xs] ) @@ -125,58 +125,58 @@ (-> Nat (List a) [(List a) (List a)])) (if (n.> 0 n) (case xs - #.Nil - [#.Nil #.Nil] + #.End + [#.End #.End] - (#.Cons x xs') + (#.Item x xs') (let [[tail rest] (split (dec n) xs')] - [(#.Cons x tail) rest])) - [#.Nil xs])) + [(#.Item x tail) rest])) + [#.End xs])) (def: (split_with' predicate ys xs) (All [a] (-> (Predicate a) (List a) (List a) [(List a) (List a)])) (case xs - #.Nil + #.End [ys xs] - (#.Cons x xs') + (#.Item x xs') (if (predicate x) - (split_with' predicate (#.Cons x ys) xs') + (split_with' predicate (#.Item x ys) xs') [ys xs]))) (def: #export (split_with predicate xs) {#.doc "Segment the list by using a predicate to tell when to cut."} (All [a] (-> (Predicate a) (List a) [(List a) (List a)])) - (let [[ys' xs'] (split_with' predicate #.Nil xs)] + (let [[ys' xs'] (split_with' predicate #.End xs)] [(reverse ys') xs'])) (def: #export (chunk n xs) {#.doc "Segment the list in chunks of size N."} (All [a] (-> Nat (List a) (List (List a)))) (case xs - #.Nil + #.End (list) _ (let [[pre post] (split n xs)] - (#.Cons pre (chunk n post))))) + (#.Item pre (chunk n post))))) (def: #export (repeat n x) {#.doc "A list of the value x, repeated n times."} (All [a] (-> Nat a (List a))) (if (n.> 0 n) - (#.Cons x (repeat (dec n) x)) - #.Nil)) + (#.Item x (repeat (dec n) x)) + #.End)) (def: (iterate' f x) (All [a] (-> (-> a (Maybe a)) a (List a))) (case (f x) (#.Some x') - (#.Cons x (iterate' f x')) + (#.Item x (iterate' f x')) #.None (list))) @@ -187,7 +187,7 @@ (-> (-> a (Maybe a)) a (List a))) (case (f x) (#.Some x') - (#.Cons x (iterate' f x')) + (#.Item x (iterate' f x')) #.None (list x))) @@ -196,10 +196,10 @@ (All [a b] (-> (-> a (Maybe b)) (List a) (Maybe b))) (case xs - #.Nil + #.End #.None - (#.Cons x xs') + (#.Item x xs') (case (check x) (#.Some output) (#.Some output) @@ -215,20 +215,20 @@ (fold (function (_ head tail) (case (check head) (#.Some head) - (#.Cons head tail) + (#.Item head tail) #.None tail)) - #.Nil + #.End (reverse xs))} (case xs - #.Nil - #.Nil + #.End + #.End - (#.Cons x xs') + (#.Item x xs') (case (check x) (#.Some output) - (#.Cons output (all check xs')) + (#.Item output (all check xs')) #.None (all check xs'))))) @@ -248,13 +248,13 @@ (All [a] (-> a (List a) (List a))) (case xs - #.Nil + #.End xs - (#.Cons x #.Nil) + (#.Item x #.End) xs - (#.Cons x xs') + (#.Item x xs') (list& x sep (interpose sep xs')))) (def: #export (size list) @@ -267,10 +267,10 @@ (-> (Predicate a) (List a) Bit)) (loop [xs xs] (case xs - #.Nil + #.End <init> - (#.Cons x xs') + (#.Item x xs') (case (predicate x) <init> (recur xs') @@ -287,10 +287,10 @@ (All [a] (-> Nat (List a) (Maybe a))) (case xs - #.Nil + #.End #.None - (#.Cons x xs') + (#.Item x xs') (if (n.= 0 i) (#.Some x) (nth (dec i) xs')))) @@ -300,10 +300,10 @@ (def: (= xs ys) (case [xs ys] - [#.Nil #.Nil] + [#.End #.End] #1 - [(#.Cons x xs') (#.Cons y ys')] + [(#.Item x xs') (#.Item y ys')] (and (\ Equivalence<a> = x y) (= xs' ys')) @@ -326,14 +326,14 @@ (implementation: #export monoid (All [a] (Monoid (List a))) - (def: identity #.Nil) + (def: identity #.End) (def: (compose xs ys) (case xs - #.Nil + #.End ys - (#.Cons x xs') - (#.Cons x (compose xs' ys))))) + (#.Item x xs') + (#.Item x (compose xs' ys))))) (open: "." ..monoid) @@ -342,11 +342,11 @@ (def: (map f ma) (case ma - #.Nil - #.Nil + #.End + #.End - (#.Cons a ma') - (#.Cons (f a) (map f ma'))))) + (#.Item a ma') + (#.Item (f a) (map f ma'))))) (open: "." ..functor) @@ -357,10 +357,10 @@ (def: (apply ff fa) (case ff - #.Nil - #.Nil + #.End + #.End - (#.Cons f ff') + (#.Item f ff') (compose (map f fa) (apply ff' fa))))) (implementation: #export monad @@ -369,21 +369,21 @@ (def: &functor ..functor) (def: (in a) - (#.Cons a #.Nil)) + (#.Item a #.End)) (def: join (|>> reverse (fold compose identity)))) (def: #export (sort < xs) (All [a] (-> (-> a a Bit) (List a) (List a))) (case xs - #.Nil + #.End (list) - (#.Cons x xs') + (#.Item x xs') (let [[pre post] (fold (function (_ x' [pre post]) (if (< x x') - [(#.Cons x' pre) post] - [pre (#.Cons x' post)])) + [(#.Item x' pre) post] + [pre (#.Item x' post)])) [(list) (list)] xs')] ($_ compose (sort < pre) (list x) (sort < post))))) @@ -391,7 +391,7 @@ (def: #export (empty? xs) (All [a] (Predicate (List a))) (case xs - #.Nil + #.End true _ @@ -400,10 +400,10 @@ (def: #export (member? eq xs x) (All [a] (-> (Equivalence a) (List a) a Bit)) (case xs - #.Nil + #.End #0 - (#.Cons x' xs') + (#.Item x' xs') (or (\ eq = x x') (member? eq xs' x)))) @@ -412,10 +412,10 @@ {#.doc <doc>} (All [a] (-> (List a) (Maybe <output>))) (case xs - #.Nil + #.End #.None - (#.Cons x xs') + (#.Item x xs') (#.Some <side>)))] [head a x "Returns the first element of a list."] @@ -476,7 +476,7 @@ (let [base (nat@encode idx)] [(identifier$ base) (identifier$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (map (function (_ [v vs]) (` (#.Cons (~ v) (~ vs)))) + pattern (` [(~+ (map (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) vars+lists))]) g!step (identifier$ "0step0") g!blank (identifier$ "0,0") @@ -485,11 +485,11 @@ (function ((~ g!step) (~+ list_vars)) (case [(~+ list_vars)] (~ pattern) - (#.Cons [(~+ (map product.left vars+lists))] + (#.Item [(~+ (map product.left vars+lists))] ((~ g!step) (~+ list_vars))) (~ g!blank) - #.Nil))))] + #.End))))] (#.Right [state (list code)])) (#.Left "Cannot zipped 0 lists.")) @@ -523,7 +523,7 @@ (let [base (nat@encode idx)] [(identifier$ base) (identifier$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (map (function (_ [v vs]) (` (#.Cons (~ v) (~ vs)))) + pattern (` [(~+ (map (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) vars+lists))]) g!step (identifier$ "0step0") g!blank (identifier$ "0,0") @@ -532,11 +532,11 @@ (function ((~ g!step) (~ g!func) (~+ list_vars)) (case [(~+ list_vars)] (~ pattern) - (#.Cons ((~ g!func) (~+ (map product.left vars+lists))) + (#.Item ((~ g!func) (~+ (map product.left vars+lists))) ((~ g!step) (~ g!func) (~+ list_vars))) (~ g!blank) - #.Nil))))] + #.End))))] (#.Right [state (list code)])) (#.Left "Cannot zipped_with 0 lists.")) @@ -549,13 +549,13 @@ (def: #export (last xs) (All [a] (-> (List a) (Maybe a))) (case xs - #.Nil + #.End #.None - (#.Cons x #.Nil) + (#.Item x #.End) (#.Some x) - (#.Cons x xs') + (#.Item x xs') (last xs'))) (def: #export (inits xs) @@ -563,19 +563,19 @@ "Empty lists will result in a #.None value being returned instead.")} (All [a] (-> (List a) (Maybe (List a)))) (case xs - #.Nil + #.End #.None - (#.Cons x #.Nil) - (#.Some #.Nil) + (#.Item x #.End) + (#.Some #.End) - (#.Cons x xs') + (#.Item x xs') (case (inits xs') #.None (undefined) (#.Some tail) - (#.Some (#.Cons x tail))) + (#.Some (#.Item x tail))) )) (def: #export (concat xss) @@ -609,8 +609,8 @@ (loop [idx 0 xs xs] (case xs - #.Nil - #.Nil + #.End + #.End - (#.Cons x xs') - (#.Cons [idx x] (recur (inc idx) xs'))))) + (#.Item x xs') + (#.Item [idx x] (recur (inc idx) xs'))))) diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index e107fd98d..5fc4b333d 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -71,11 +71,11 @@ (def: #export (push val queue) (All [a] (-> a (Queue a) (Queue a))) (case (get@ #front queue) - #.Nil + #.End (set@ #front (list val) queue) _ - (update@ #rear (|>> (#.Cons val)) queue))) + (update@ #rear (|>> (#.Item val)) queue))) (implementation: #export (equivalence super) (All [a] (-> (Equivalence a) (Equivalence (Queue a)))) diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index 6447d96fe..a53c7fb0e 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -180,7 +180,7 @@ array.to_list list.reverse (list\fold (function (_ sub acc) (list\compose (to_list' sub) acc)) - #.Nil)))) + #.End)))) (type: #export (Row a) {#level Level diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index 3fe88a087..d36ca16c4 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -43,10 +43,10 @@ (loop [head start tail next] (//.pending [head (case tail - #.Nil + #.End (recur start next) - (#.Cons head' tail') + (#.Item head' tail') (recur head' tail'))]))) (template [<name> <return>] @@ -89,7 +89,7 @@ (let [[x xs'] (//.run xs)] (if <pred_test> (let [[tail next] (<splitter> <pred_step> xs')] - [(#.Cons [x tail]) next]) + [(#.Item [x tail]) next]) [(list) xs])))] [take_while drop_while split_while (-> a Bit) (pred x) pred] diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index c078c4df1..14ee02181 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -63,7 +63,7 @@ dictionary.entries (list\fold (function (_ [elem multiplicity] output) (list\compose (list.repeat multiplicity elem) output)) - #.Nil))) + #.End))) (template [<name> <compose>] [(def: #export (<name> parameter subject) diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux index c81240c29..53b608c2c 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -28,24 +28,24 @@ (def: #export (peek stack) (All [a] (-> (Stack a) (Maybe a))) (case (:representation stack) - #.Nil + #.End #.None - (#.Cons value _) + (#.Item value _) (#.Some value))) (def: #export (pop stack) (All [a] (-> (Stack a) (Maybe [a (Stack a)]))) (case (:representation stack) - #.Nil + #.End #.None - (#.Cons top stack') + (#.Item top stack') (#.Some [top (:abstraction stack')]))) (def: #export (push value stack) (All [a] (-> a (Stack a) (Stack a))) - (:abstraction (#.Cons value (:representation stack)))) + (:abstraction (#.Item value (:representation stack)))) (implementation: #export (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 444ab32e2..7a14946c5 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -22,8 +22,11 @@ (def: #export (flatten tree) (All [a] (-> (Tree a) (List a))) - (#.Cons (get@ #value tree) - (list\join (list\map flatten (get@ #children tree))))) + (|> tree + (get@ #children) + (list\map flatten) + list\join + (#.Item (get@ #value tree)))) (def: #export (leaf value) (All [a] (-> a (Tree a))) diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index 9803124a4..998b75c3e 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -86,12 +86,12 @@ (def: #export (down zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) (case (..children zipper) - #.Nil + #.End #.None - (#.Cons head tail) + (#.Item head tail) (#.Some {#family (#.Some {#parent (set@ [#node #//.children] (list) zipper) - #lefts #.Nil + #lefts #.End #rights tail}) #node head}))) @@ -103,12 +103,12 @@ (for {@.old (update@ #node (: (-> (Tree ($ 0)) (Tree ($ 0))) (set@ #//.children (list\compose (list.reverse lefts) - (#.Cons (get@ #node zipper) + (#.Item (get@ #node zipper) rights)))) parent)} (set@ [#node #//.children] (list\compose (list.reverse lefts) - (#.Cons (get@ #node zipper) + (#.Item (get@ #node zipper) rights)) parent)))))) @@ -118,20 +118,20 @@ (case (get@ #family zipper) (#.Some family) (case (get@ <side> family) - (#.Cons next side') + (#.Item next side') (#.Some (for {@.old {#family (#.Some (|> family (set@ <side> side') - (update@ <op_side> (|>> (#.Cons (get@ #node zipper)))))) + (update@ <op_side> (|>> (#.Item (get@ #node zipper)))))) #node next}} (let [move (: (All [a] (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ side' zipper) (|>> (set@ <side> side') - (update@ <op_side> (|>> (#.Cons (get@ #node zipper)))))))] + (update@ <op_side> (|>> (#.Item (get@ #node zipper)))))))] {#family (#.Some (move side' zipper family)) #node next}))) - #.Nil + #.End #.None) #.None @@ -145,19 +145,19 @@ (#.Some family) (case (list.reverse (get@ <side> family)) - #.Nil + #.End #.None - (#.Cons last prevs) + (#.Item last prevs) (#.Some (for {@.old {#family (#.Some (|> family - (set@ <side> #.Nil) - (update@ <op_side> (|>> (#.Cons (get@ #node zipper)) + (set@ <side> #.End) + (update@ <op_side> (|>> (#.Item (get@ #node zipper)) (list\compose prevs))))) #node last}} (let [move (: (All [a] (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ prevs zipper) - (|>> (set@ <side> #.Nil) - (update@ <op_side> (|>> (#.Cons (get@ #node zipper)) + (|>> (set@ <side> #.End) + (update@ <op_side> (|>> (#.Item (get@ #node zipper)) (list\compose prevs))))))] {#family (#.Some (move prevs zipper family)) #node last}))))))] @@ -249,7 +249,7 @@ (def: #export (adopt value zipper) (All [a] (-> a (Zipper a) (Zipper a))) (update@ [#node #//.children] - (|>> (#.Cons (//.leaf value))) + (|>> (#.Item (//.leaf value))) zipper)) (def: #export (remove zipper) @@ -257,12 +257,12 @@ (do maybe.monad [family (get@ #family zipper)] (case (get@ #lefts family) - #.Nil + #.End (in (set@ [#node #//.children] (get@ #rights family) (get@ #parent family))) - (#.Cons next side) + (#.Item next side) (in (|> zipper (set@ #family (|> family (set@ #lefts side) @@ -278,7 +278,7 @@ (#.Some family) (#.Some (set@ #family - (#.Some (update@ <side> (|>> (#.Cons (//.leaf value))) family)) + (#.Some (update@ <side> (|>> (#.Item (//.leaf value))) family)) zipper))))] [insert_left #lefts] diff --git a/stdlib/source/library/lux/data/format/css/font.lux b/stdlib/source/library/lux/data/format/css/font.lux index c153ec0b8..9856d19e4 100644 --- a/stdlib/source/library/lux/data/format/css/font.lux +++ b/stdlib/source/library/lux/data/format/css/font.lux @@ -11,16 +11,16 @@ [world [net (#+ URL)]]]] ["." // #_ - ["#." value (#+ Value Font-Stretch Font-Style Font-Weight)]]) + ["#." value (#+ Value Font_Stretch Font_Style Font_Weight)]]) -(type: #export Unicode-Range +(type: #export Unicode_Range {#start Nat #end Nat}) (type: #export Font {#family Text #source URL - #stretch (Maybe (Value Font-Stretch)) - #style (Maybe (Value Font-Style)) - #weight (Maybe (Value Font-Weight)) - #unicode-range (Maybe Unicode-Range)}) + #stretch (Maybe (Value Font_Stretch)) + #style (Maybe (Value Font_Style)) + #weight (Maybe (Value Font_Weight)) + #unicode_range (Maybe Unicode_Range)}) diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index 85a775440..1b69f1496 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -1155,13 +1155,13 @@ (def: #export (font_family options) (-> (List Font) (Value Font)) (case options - (#.Cons _) + (#.Item _) (|> options (list\map ..font_name) (text.join_with ",") (:abstraction Value)) - #.Nil + #.End ..initial))]) (def: #export font_size diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index 6cd460f9d..a96a6df84 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -210,7 +210,7 @@ (def: #export (image source attributes) (-> URL Attributes Image) (|> attributes - (#.Cons ["src" source]) + (#.Item ["src" source]) (..simple "img"))) (def: #export (svg attributes content) @@ -292,10 +292,10 @@ ($_ ..and for (case (list\map (product.uncurry ..area) areas) - #.Nil + #.End (..empty "map" attributes) - (#.Cons head tail) + (#.Item head tail) (..tag "map" attributes (list\fold (function.flip ..and) head tail))))) @@ -457,10 +457,10 @@ (..term term) (..description description))) descriptions) - #.Nil + #.End (..empty "dl" attributes) - (#.Cons head tail) + (#.Item head tail) (..tag "dl" attributes (list\fold (function.flip ..and) head tail)))) @@ -515,10 +515,10 @@ (-> Attributes (Maybe Content) (Maybe Column) Header (List Cell) (Maybe Cell) Element) (let [head (..table_head (..table_row headers)) content (case (list\map table_row rows) - #.Nil + #.End head - (#.Cons first rest) + (#.Item first rest) (..and head (..table_body (list\fold (function.flip ..and) first rest)))) diff --git a/stdlib/source/library/lux/data/maybe.lux b/stdlib/source/library/lux/data/maybe.lux index d51bfed90..155254f2e 100644 --- a/stdlib/source/library/lux/data/maybe.lux +++ b/stdlib/source/library/lux/data/maybe.lux @@ -145,7 +145,7 @@ (All [a] (-> (Maybe a) (List a))) (case value #.None - #.Nil + #.End (#.Some value) - (#.Cons value #.Nil))) + (#.Item value #.End))) diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux index 7a439fc54..2f0fddee9 100644 --- a/stdlib/source/library/lux/data/sum.lux +++ b/stdlib/source/library/lux/data/sum.lux @@ -36,13 +36,13 @@ [(def: #export (<name> es) (All [a b] (-> (List (| a b)) (List <side>))) (case es - #.Nil - #.Nil + #.End + #.End - (#.Cons (0 <right?> x) es') - (#.Cons [x (<name> es')]) + (#.Item (0 <right?> x) es') + (#.Item [x (<name> es')]) - (#.Cons _ es') + (#.Item _ es') (<name> es')))] [lefts a #0] @@ -52,14 +52,14 @@ (def: #export (partition xs) (All [a b] (-> (List (| a b)) [(List a) (List b)])) (case xs - #.Nil - [#.Nil #.Nil] + #.End + [#.End #.End] - (#.Cons x xs') + (#.Item x xs') (let [[lefts rights] (partition xs')] (case x - (0 #0 x') [(#.Cons x' lefts) rights] - (0 #1 x') [lefts (#.Cons x' rights)])))) + (0 #0 x') [(#.Item x' lefts) rights] + (0 #1 x') [lefts (#.Item x' rights)])))) (def: #export (equivalence left right) (All [l r] (-> (Equivalence l) (Equivalence r) (Equivalence (| l r)))) diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index 15dd8ec04..1ab453032 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -181,12 +181,12 @@ (case (..split_with token input) (#.Some [pre post]) (|> output - (#.Cons pre) + (#.Item pre) (recur post)) #.None (|> output - (#.Cons input) + (#.Item input) list.reverse)))) (def: #export (replace_once pattern replacement template) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index c57394dd3..2778746ea 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -125,8 +125,8 @@ (loop [idx 0] (let [member ("lua array read" idx tuple)] (if ("lua object nil?" member) - #.Nil - (#.Cons member (recur (inc idx))))))))} + #.End + (#.Item member (recur (inc idx))))))))} (as_is)) (def: (tuple_inspection inspection) @@ -449,18 +449,18 @@ representations membersR+ variantV variantV] (case representations - (#.Cons leftR (#.Cons rightR extraR+)) + (#.Item leftR (#.Item rightR extraR+)) (case (:as (| Any Any) variantV) (#.Left left) [lefts #0 (leftR left)] (#.Right right) (case extraR+ - #.Nil + #.End [lefts #1 (rightR right)] _ - (recur (inc lefts) (#.Cons rightR extraR+) right))) + (recur (inc lefts) (#.Item rightR extraR+) right))) _ (undefined)))] @@ -474,13 +474,13 @@ (let [tuple_body (loop [representations membersR+ tupleV tupleV] (case representations - #.Nil + #.End "" - (#.Cons lastR #.Nil) + (#.Item lastR #.End) (lastR tupleV) - (#.Cons headR tailR) + (#.Item headR tailR) (let [[leftV rightV] (:as [Any Any] tupleV)] (%.format (headR leftV) " " (recur tailR rightV)))))] (%.format "[" tuple_body "]")))))) @@ -571,7 +571,7 @@ (dictionary.of_list text.hash))] targets (: (Meta (List Target)) (case targets - #.Nil + #.End (|> environment dictionary.keys (list\map (function (_ local) [local #.None])) diff --git a/stdlib/source/library/lux/extension.lux b/stdlib/source/library/lux/extension.lux index add1ec871..4347cec39 100644 --- a/stdlib/source/library/lux/extension.lux +++ b/stdlib/source/library/lux/extension.lux @@ -61,7 +61,7 @@ {[name extension phase archive inputs] (..declaration (` <any>))} body) (let [g!parser (case (list\map product.right inputs) - #.Nil + #.End (` <end>) parsers diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux index 629d2f4f5..81ecf4d82 100644 --- a/stdlib/source/library/lux/ffi.js.lux +++ b/stdlib/source/library/lux/ffi.js.lux @@ -327,7 +327,7 @@ (with_gensyms [g!_] (let [constant (` ("js constant" (~ (code.text head))))] (case tail - #.Nil + #.End (in (list (` (: (.Maybe (~ type)) (case (..type_of (~ constant)) "undefined" @@ -336,7 +336,7 @@ (~ g!_) (#.Some (:as (~ type) (~ constant)))))))) - (#.Cons [next tail]) + (#.Item [next tail]) (let [separator "."] (in (list (` (: (.Maybe (~ type)) (case (..type_of (~ constant)) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index ff3215f6a..ba8499262 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -57,7 +57,7 @@ (template [<name> <class>] [(def: #export <name> .Type - (#.Primitive <class> #.Nil))] + (#.Primitive <class> #.End))] [Boolean box.boolean] [Byte box.byte] @@ -72,7 +72,7 @@ (template [<name> <class>] [(def: #export <name> .Type - (#.Primitive (reflection.reflection <class>) #.Nil))] + (#.Primitive (reflection.reflection <class>) #.End))] ## Primitives [boolean reflection.boolean] @@ -378,11 +378,11 @@ [parser.primitive? type (primitive_type mode type)] [parser.array? elementT (case (parser.primitive? elementT) (#.Some elementT) - (` (#.Primitive (~ (code.text (..reflection (type.array elementT)))) #.Nil)) + (` (#.Primitive (~ (code.text (..reflection (type.array elementT)))) #.End)) #.None (` (#.Primitive (~ (code.text array.type_name)) - (#.Cons (~ (value_type mode elementT)) #.Nil))))])) + (#.Item (~ (value_type mode elementT)) #.End))))])) (undefined) ))) @@ -437,7 +437,7 @@ (def: (parser->replacer p ast) (-> (Parser Code) (-> Code Code)) (case (<>.run p (list ast)) - (#.Right [#.Nil ast']) + (#.Right [#.End ast']) ast' _ @@ -1512,7 +1512,7 @@ #.None refined)] (case post - #.Nil + #.End unboxed/boxed _ @@ -1574,7 +1574,7 @@ (do meta.monad [#let [enum_type (: Code (case class_tvars - #.Nil + #.End (` (primitive (~ (code.text full_name)))) _ @@ -1843,7 +1843,7 @@ (`` (cond (~~ (template [<type>] [(text\= (..reflection <type>) name) (case params - #.Nil + #.End (\ meta.monad in <type>) _ @@ -1861,7 +1861,7 @@ (~~ (template [<type>] [(text\= (..reflection (type.array <type>)) name) (case params - #.Nil + #.End (\ meta.monad in (type.array <type>)) _ @@ -1878,7 +1878,7 @@ (text\= array.type_name name) (case params - (#.Cons elementLT #.Nil) + (#.Item elementLT #.End) (\ meta.monad map type.array (lux_type->jvm_type elementLT)) @@ -1887,7 +1887,7 @@ (text.starts_with? descriptor.array_prefix name) (case params - #.Nil + #.End (let [[_ unprefixed] (maybe.assume (text.split_with descriptor.array_prefix name))] (\ meta.monad map type.array (lux_type->jvm_type (#.Primitive unprefixed (list))))) diff --git a/stdlib/source/library/lux/ffi.lua.lux b/stdlib/source/library/lux/ffi.lua.lux index a1481fa45..7a4825ea7 100644 --- a/stdlib/source/library/lux/ffi.lua.lux +++ b/stdlib/source/library/lux/ffi.lua.lux @@ -140,7 +140,7 @@ (#.Some (~ g!temp)) (~ g!temp) - #.Nil + #.None ("lua object nil"))) input)) @@ -226,14 +226,14 @@ g!type (code.local_identifier class) real_class (text.replace_all "/" "." class) imported (case (text.split_all_with "/" class) - (#.Cons head tail) + (#.Item head tail) (list\fold (function (_ sub super) (` ("lua object get" (~ (code.text sub)) (:as (..Object .Any) (~ super))))) (` ("lua import" (~ (code.text head)))) tail) - #.Nil + #.End (` ("lua import" (~ (code.text class)))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text real_class)))))) diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index ff9ef9f31..5187df976 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -274,11 +274,11 @@ (-> Primitive_Mode (List Type_Parameter) Bit GenericType Code) Code) (case [name+params mode in_array?] - (^multi [[prim #.Nil] #ManualPrM #0] + (^multi [[prim #.End] #ManualPrM #0] {(manual_primitive_to_type prim) (#.Some output)}) output - (^multi [[prim #.Nil] #AutoPrM #0] + (^multi [[prim #.End] #AutoPrM #0] {(auto_primitive_to_type prim) (#.Some output)}) output @@ -329,10 +329,10 @@ (let [=params (list\map (: (-> Type_Parameter Code) (function (_ [pname pbounds]) (case pbounds - #.Nil + #.End (code.identifier ["" pname]) - (#.Cons bound1 _) + (#.Item bound1 _) (class_to_type #ManualPrM class_params bound1)))) class_params)] (` (primitive (~ (code.text (safe class_name))) @@ -369,7 +369,7 @@ (format "[" (simple_class$ env param)) (^template [<prim> <class>] - [(#GenericClass <prim> #.Nil) + [(#GenericClass <prim> #.End) <class>]) (["boolean" "[Z"] ["byte" "[B"] @@ -427,7 +427,7 @@ (def: (parser_to_replacer p ast) (-> (Parser Code) (-> Code Code)) (case (<>.run p (list ast)) - (#.Right [#.Nil ast']) + (#.Right [#.End ast']) ast' _ @@ -551,7 +551,7 @@ [component recur^] (case component (^template [<class> <name>] - [(#GenericClass <name> #.Nil) + [(#GenericClass <name> #.End) (in (#GenericClass <class> (list)))]) (["[Z" "boolean"] ["[B" "byte"] @@ -1446,7 +1446,7 @@ (def: (free_type_param? [name bounds]) (-> Type_Parameter Bit) (case bounds - #.Nil #1 + #.End #1 _ #0)) (def: (type_param_to_type_arg [name _]) @@ -1504,7 +1504,7 @@ (do {! meta.monad} [#let [enum_type (: Code (case class_tvars - #.Nil + #.End (` (primitive (~ (code.text full_name)))) _ diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux index 150cbf578..436f1c729 100644 --- a/stdlib/source/library/lux/ffi.py.lux +++ b/stdlib/source/library/lux/ffi.py.lux @@ -226,14 +226,14 @@ g!type (code.local_identifier class) real_class (text.replace_all "/" "." class) imported (case (text.split_all_with "/" class) - (#.Cons head tail) + (#.Item head tail) (list\fold (function (_ sub super) (` ("python object get" (~ (code.text sub)) (:as (..Object .Any) (~ super))))) (` ("python import" (~ (code.text head)))) tail) - #.Nil + #.End (` ("python import" (~ (code.text class)))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text real_class)))))) diff --git a/stdlib/source/library/lux/ffi.rb.lux b/stdlib/source/library/lux/ffi.rb.lux index ba63ac1b1..d22138957 100644 --- a/stdlib/source/library/lux/ffi.rb.lux +++ b/stdlib/source/library/lux/ffi.rb.lux @@ -148,7 +148,7 @@ (#.Some (~ g!temp)) (~ g!temp) - #.Nil + #.None ("ruby object nil"))) input)) diff --git a/stdlib/source/library/lux/ffi.scm.lux b/stdlib/source/library/lux/ffi.scm.lux index 69559353f..dddce2ebc 100644 --- a/stdlib/source/library/lux/ffi.scm.lux +++ b/stdlib/source/library/lux/ffi.scm.lux @@ -122,7 +122,7 @@ (#.Some (~ g!temp)) (~ g!temp) - #.Nil + #.None ("scheme object nil"))) input)) diff --git a/stdlib/source/library/lux/macro.lux b/stdlib/source/library/lux/macro.lux index 242ed8a85..e80b1d665 100644 --- a/stdlib/source/library/lux/macro.lux +++ b/stdlib/source/library/lux/macro.lux @@ -23,7 +23,7 @@ "Otherwise, returns the code as-is.")} (-> Code (Meta (List Code))) (case syntax - [_ (#.Form (#.Cons [[_ (#.Identifier name)] args]))] + [_ (#.Form (#.Item [[_ (#.Identifier name)] args]))] (do //.monad [?macro (//.macro name)] (case ?macro @@ -41,7 +41,7 @@ "Otherwise, returns the code as-is.")} (-> Code (Meta (List Code))) (case syntax - [_ (#.Form (#.Cons [[_ (#.Identifier name)] args]))] + [_ (#.Form (#.Item [[_ (#.Identifier name)] args]))] (do //.monad [?macro (//.macro name)] (case ?macro @@ -61,7 +61,7 @@ {#.doc "Expands all macro-calls everywhere recursively, until only primitive/base code remains."} (-> Code (Meta (List Code))) (case syntax - [_ (#.Form (#.Cons [[_ (#.Identifier name)] args]))] + [_ (#.Form (#.Item [[_ (#.Identifier name)] args]))] (do //.monad [?macro (//.macro name)] (case ?macro @@ -76,7 +76,7 @@ [parts' (monad.map //.monad expand_all (list& (code.identifier name) args))] (in (list (code.form (list\join parts'))))))) - [_ (#.Form (#.Cons [harg targs]))] + [_ (#.Form (#.Item [harg targs]))] (do //.monad [harg+ (expand_all harg) targs+ (monad.map //.monad expand_all targs)] @@ -95,7 +95,7 @@ [left (expand_all left) right (expand_all right)] (case [left right] - [(#.Cons left #.Nil) (#.Cons right #.Nil)] + [(#.Item left #.End) (#.Item right #.End)] (in [left right]) _ diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index 1ba0c4f9f..4108f7ced 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -38,8 +38,8 @@ (def: (join_pairs pairs) (All [a] (-> (List [a a]) (List a))) (case pairs - #.Nil #.Nil - (#.Cons [[x y] pairs']) (list& x y (join_pairs pairs')))) + #.End #.End + (#.Item [[x y] pairs']) (list& x y (join_pairs pairs')))) (macro: #export (syntax: tokens) {#.doc (doc "A more advanced way to define macros than 'macro:'." diff --git a/stdlib/source/library/lux/macro/syntax/declaration.lux b/stdlib/source/library/lux/macro/syntax/declaration.lux index 75098a7b9..550c3a4b0 100644 --- a/stdlib/source/library/lux/macro/syntax/declaration.lux +++ b/stdlib/source/library/lux/macro/syntax/declaration.lux @@ -40,7 +40,7 @@ (-> Declaration Code) (let [g!name (code.local_identifier (get@ #name value))] (case (get@ #arguments value) - #.Nil + #.End g!name arguments diff --git a/stdlib/source/library/lux/macro/syntax/definition.lux b/stdlib/source/library/lux/macro/syntax/definition.lux index a97abb278..3b8bab1d5 100644 --- a/stdlib/source/library/lux/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/macro/syntax/definition.lux @@ -55,11 +55,11 @@ (def: (annotations_format value) (-> Annotations Code) (case value - #.Nil - (` #.Nil) + #.End + (` #.End) - (#.Cons [name value] tail) - (` (#.Cons [(~ (..tag_format name)) + (#.Item [name value] tail) + (` (#.Item [(~ (..tag_format name)) (~ value)] (~ (annotations_format tail)))))) @@ -91,9 +91,9 @@ (<>.rec (function (_ recur) ($_ <>.or - (<code>.tag! (name_of #.Nil)) + (<code>.tag! (name_of #.End)) (<code>.form (do <>.monad - [_ (<code>.tag! (name_of #.Cons)) + [_ (<code>.tag! (name_of #.Item)) [head tail] (<>.and (<code>.tuple (<>.and tag_parser <code>.any)) recur)] (in [head tail]))) diff --git a/stdlib/source/library/lux/math/number.lux b/stdlib/source/library/lux/math/number.lux index dd03f37b3..288afd703 100644 --- a/stdlib/source/library/lux/math/number.lux +++ b/stdlib/source/library/lux/math/number.lux @@ -49,7 +49,7 @@ [(macro: #export (<macro> tokens state) {#.doc <doc>} (case tokens - (#.Cons [meta (#.Text repr')] #.Nil) + (#.Item [meta (#.Text repr')] #.End) (if (..separator_prefixed? repr') (#try.Failure <error>) (let [repr (..without_separators repr')] diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux index ebec1b4e9..7599e221f 100644 --- a/stdlib/source/library/lux/math/number/nat.lux +++ b/stdlib/source/library/lux/math/number/nat.lux @@ -299,7 +299,7 @@ ["d" "D" 13] ["e" "E" 14] ["f" "F" 15]) _ #.None)) -(template [<shift> <struct> <to-character> <to-value> <error>] +(template [<shift> <struct> <to_character> <to_value> <error>] [(implementation: #export <struct> (Codec Text Nat) @@ -309,7 +309,7 @@ (loop [input value output ""] (let [output' ("lux text concat" - (<to-character> ("lux i64 and" mask input)) + (<to_character> ("lux i64 and" mask input)) output)] (case (: Nat ("lux i64 right-shift" <shift> input)) 0 @@ -319,17 +319,17 @@ (recur input' output'))))))) (def: (decode repr) - (let [input-size ("lux text size" repr)] - (if (..> 0 input-size) + (let [input_size ("lux text size" repr)] + (if (..> 0 input_size) (loop [idx 0 output 0] - (if (..< input-size idx) - (case (<to-value> ("lux text char" idx repr)) - (#.Some digit-value) + (if (..< input_size idx) + (case (<to_value> ("lux text char" idx repr)) + (#.Some digit_value) (recur (inc idx) (|> output ("lux i64 left-shift" <shift>) - ("lux i64 or" digit-value))) + ("lux i64 or" digit_value))) _ (#try.Failure ("lux text concat" <error> repr))) @@ -357,19 +357,19 @@ (recur input' output'))))) (def: (decode repr) - (let [input-size ("lux text size" repr)] + (let [input_size ("lux text size" repr)] (with_expansions [<failure> (#try.Failure ("lux text concat" "Invalid decimal syntax for Nat: " repr))] - (if (..> 0 input-size) + (if (..> 0 input_size) (loop [idx 0 output 0] - (if (..< input-size idx) + (if (..< input_size idx) (case (decimal_value ("lux text char" idx repr)) #.None <failure> - (#.Some digit-value) + (#.Some digit_value) (recur (inc idx) - (|> output (..* 10) (..+ digit-value)))) + (|> output (..* 10) (..+ digit_value)))) (#try.Success output))) <failure>))))) diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index 9df9cbc53..f0a912431 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -253,7 +253,7 @@ (in (<plus> x xs))) (\ ..monad in <zero>)))] - [list List (.list) #.Cons] + [list List (.list) #.Item] [row Row row.empty row.add] ) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index ec154caaf..3a6174cda 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -147,7 +147,7 @@ (def: (macro_type? type) (-> Type Bit) (`` (case type - (#.Named [(~~ (static .prelude_module)) "Macro"] (#.Primitive "#Macro" #.Nil)) + (#.Named [(~~ (static .prelude_module)) "Macro"] (#.Primitive "#Macro" #.End)) true _ @@ -224,10 +224,10 @@ (def: (type_variable idx bindings) (-> Nat (List [Nat (Maybe Type)]) (Maybe Type)) (case bindings - #.Nil + #.End #.None - (#.Cons [var bound] bindings') + (#.Item [var bound] bindings') (if (n.= idx var) bound (type_variable idx bindings')))) diff --git a/stdlib/source/library/lux/meta/annotation.lux b/stdlib/source/library/lux/meta/annotation.lux index 14f55f106..27512d5f6 100644 --- a/stdlib/source/library/lux/meta/annotation.lux +++ b/stdlib/source/library/lux/meta/annotation.lux @@ -16,7 +16,7 @@ [_ (#.Record ann)] (loop [ann ann] (case ann - (#.Cons [key value] ann') + (#.Item [key value] ann') (case key [_ (#.Tag tag')] (if (name\= tag tag') @@ -26,7 +26,7 @@ _ (recur ann')) - #.Nil + #.End #.None)) _ diff --git a/stdlib/source/library/lux/meta/location.lux b/stdlib/source/library/lux/meta/location.lux index ddc40b147..8738d873a 100644 --- a/stdlib/source/library/lux/meta/location.lux +++ b/stdlib/source/library/lux/meta/location.lux @@ -20,7 +20,7 @@ (macro: #export (here tokens compiler) (case tokens - #.Nil + #.End (let [location (get@ #.location compiler)] (#.Right [compiler (list (` [(~ [..dummy (#.Text (get@ #.module location))]) diff --git a/stdlib/source/library/lux/target/common_lisp.lux b/stdlib/source/library/lux/target/common_lisp.lux index 9fb5dfaa3..ecc778d98 100644 --- a/stdlib/source/library/lux/target/common_lisp.lux +++ b/stdlib/source/library/lux/target/common_lisp.lux @@ -152,10 +152,10 @@ (def: #export (args& singles rest) (-> (List Var/1) Var/1 Var/*) (|> (case singles - #.Nil + #.End "" - (#.Cons _) + (#.Item _) (|> singles (list\map ..code) (text.join_with " ") @@ -173,7 +173,7 @@ (def: #export (call/* func) (-> (Expression Any) (-> (List (Expression Any)) (Computation Any))) - (|>> (#.Cons func) ..form)) + (|>> (#.Item func) ..form)) (template [<name> <function>] [(def: #export <name> @@ -401,10 +401,10 @@ [(def: #export (<name> conditions expression) (-> (List Text) (Expression Any) (Expression Any)) (case conditions - #.Nil + #.End expression - (#.Cons single #.Nil) + (#.Item single #.End) (:abstraction (format <prefix> single " " (:representation expression))) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index a77eb88a4..c2532933a 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -632,12 +632,12 @@ _ (binary.write/32 offset (///signed.value maximum) binary)] (loop [offset (n.+ (///unsigned.value ..integer_size) offset) afterwards (: (List Big_Jump) - (#.Cons at_minimum afterwards))] + (#.Item at_minimum afterwards))] (case afterwards - #.Nil + #.End (in binary) - (#.Cons head tail) + (#.Item head tail) (do ! [_ (binary.write/32 offset (///signed.value head) binary)] (recur (n.+ (///unsigned.value ..big_jump_size) offset) @@ -693,10 +693,10 @@ (loop [offset (n.+ (///unsigned.value ..integer_size) offset) cases cases] (case cases - #.Nil + #.End (in binary) - (#.Cons [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/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index 3224c9a24..6b6fc2b5f 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>) #.Nil)))))] + (<>\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> #.Nil)))))] + (<>\in (check\in (#.Primitive <box> #.End)))))] [boxed_boolean //parser.boolean //box.boolean] [boxed_byte //parser.byte //box.byte] @@ -173,7 +173,7 @@ (-> (Parser (Check Type)) (Parser (Check Type))) (|>> (<>\map (check\map (function (_ elementT) (case elementT - (#.Primitive name #.Nil) + (#.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) #.Nil) + (#.Primitive (|> name //reflection.class //reflection.array //reflection.reflection) #.End) (|> elementT array.Array .type)) _ diff --git a/stdlib/source/library/lux/target/jvm/type/signature.lux b/stdlib/source/library/lux/target/jvm/type/signature.lux index 570ec8e73..7e1164671 100644 --- a/stdlib/source/library/lux/target/jvm/type/signature.lux +++ b/stdlib/source/library/lux/target/jvm/type/signature.lux @@ -85,7 +85,7 @@ (format //descriptor.class_prefix (|> name ///name.internal ///name.read) (case parameters - #.Nil + #.End "" _ @@ -122,7 +122,7 @@ (Signature Method)) (:abstraction (format (case type_variables - #.Nil + #.End "" _ (|> type_variables diff --git a/stdlib/source/library/lux/target/php.lux b/stdlib/source/library/lux/target/php.lux index 10ef0dbd3..7cc266b98 100644 --- a/stdlib/source/library/lux/target/php.lux +++ b/stdlib/source/library/lux/target/php.lux @@ -214,7 +214,7 @@ (def: #export (closure uses arguments body!) (-> (List Argument) (List Argument) Statement Literal) (let [uses (case uses - #.Nil + #.End "" _ diff --git a/stdlib/source/library/lux/target/scheme.lux b/stdlib/source/library/lux/target/scheme.lux index cb6878cb4..f03f876b8 100644 --- a/stdlib/source/library/lux/target/scheme.lux +++ b/stdlib/source/library/lux/target/scheme.lux @@ -77,7 +77,7 @@ (case rest (#.Some rest) (case mandatory - #.Nil + #.End rest _ @@ -155,20 +155,20 @@ (def: form (-> (List (Code Any)) Code) (.let [nested_new_line (format text.new_line text.tab)] - (|>> (case> #.Nil + (|>> (case> #.End (:abstraction "()") - (#.Cons head tail) + (#.Item head tail) (|> tail (list\map (|>> :representation nest)) - (#.Cons (:representation head)) + (#.Item (:representation head)) (text.join_with nested_new_line) (text.enclose ["(" ")"]) :abstraction))))) (def: #export (apply/* args func) (-> (List Expression) Expression Computation) - (..form (#.Cons func args))) + (..form (#.Item func args))) (template [<name> <function>] [(def: #export (<name> members) @@ -339,7 +339,7 @@ (-> Var Arguments Expression Computation) (..form (list (..var "define") (|> arguments - (update@ #mandatory (|>> (#.Cons name))) + (update@ #mandatory (|>> (#.Item name))) ..arguments) body))) @@ -349,7 +349,7 @@ (def: #export begin (-> (List Expression) Computation) - (|>> (#.Cons (..var "begin")) ..form)) + (|>> (#.Item (..var "begin")) ..form)) (def: #export (set! name value) (-> Var Expression Computation) diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index 2faf51dd2..8af624e4c 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -358,9 +358,9 @@ #let [coverage (|> definitions (list\fold (function (_ [short [exported? _]] aggregate) (if exported? - (#.Cons short aggregate) + (#.Item short aggregate) aggregate)) - #.Nil) + #.End) ..encode_coverage)]] (in (list (` ((~! ..covering') (~ (code.text module)) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index 8a3d4a1cd..cde736979 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -555,10 +555,10 @@ recur))] (do ! [[archive state] (case new_dependencies - #.Nil + #.End (in [archive state]) - (#.Cons _) + (#.Item _) (do ! [archive,document+ (|> new_dependencies (list\map (import! 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 b2b7b6c18..f5e65f9bb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux @@ -205,7 +205,7 @@ [(#Case [reference_analysis reference_match]) (#Case [sample_analysis sample_match])] (and (= reference_analysis sample_analysis) - (\ (list.equivalence (branch_equivalence =)) = (#.Cons reference_match) (#.Cons sample_match))) + (\ (list.equivalence (branch_equivalence =)) = (#.Item reference_match) (#.Item sample_match))) [(#Function [reference_environment reference_analysis]) (#Function [sample_environment sample_analysis])] @@ -273,7 +273,7 @@ inputs (list)] (case abstraction (#Apply input next) - (recur next (#.Cons input inputs)) + (recur next (#.Item input inputs)) _ [abstraction inputs]))) @@ -376,7 +376,7 @@ (#Apply _) (|> analysis ..application - #.Cons + #.Item (list\map %analysis) (text.join_with " ") (text.enclose ["(" ")"])) @@ -426,14 +426,14 @@ (def: #export (with_scope action) (All [a] (-> (Operation a) (Operation [Scope a]))) (function (_ [bundle state]) - (case (action [bundle (update@ #.scopes (|>> (#.Cons fresh_scope)) state)]) + (case (action [bundle (update@ #.scopes (|>> (#.Item fresh_scope)) state)]) (#try.Success [[bundle' state'] output]) (case (get@ #.scopes state') - (#.Cons head tail) + (#.Item head tail) (#try.Success [[bundle' (set@ #.scopes tail state')] [head output]]) - #.Nil + #.End (#try.Failure "Impossible error: Drained scopes!")) (#try.Failure error) 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 b2a5e9fc6..faa4089a1 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 @@ -59,7 +59,7 @@ (^ (#.Form (list& [_ (#.Tag tag)] values))) (case values - (#.Cons value #.Nil) + (#.Item value #.End) (/structure.tagged_sum compile tag archive value) _ @@ -68,7 +68,7 @@ (^ (#.Form (list& [_ (#.Nat lefts)] [_ (#.Bit right?)] values))) (case values - (#.Cons value #.Nil) + (#.Item value #.End) (/structure.sum compile lefts right? archive value) _ 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 fb8d67bf5..e48d2b1f8 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 @@ -62,10 +62,10 @@ (def: (re_quantify envs baseT) (-> (List (List Type)) Type Type) (.case envs - #.Nil + #.End baseT - (#.Cons head tail) + (#.Item head tail) (re_quantify tail (#.UnivQ head baseT)))) ## Type-checking on the input value is done during the analysis of a @@ -96,7 +96,7 @@ (recur envs unnamedT) (#.UnivQ env unquantifiedT) - (recur (#.Cons env envs) unquantifiedT) + (recur (#.Item env envs) unquantifiedT) (#.ExQ _) (do ///.monad @@ -182,7 +182,7 @@ [Rev (#.Rev pattern_value) (#/.Rev pattern_value)] [Frac (#.Frac pattern_value) (#/.Frac pattern_value)] [Text (#.Text pattern_value) (#/.Text pattern_value)] - [Any (#.Tuple #.Nil) #/.Unit]) + [Any (#.Tuple #.End) #/.Unit]) (^ [location (#.Tuple (list singleton))]) (analyse_pattern #.None inputT singleton next) @@ -301,7 +301,7 @@ (def: #export (case analyse branches archive inputC) (-> Phase (List [Code Code]) Phase) (.case branches - (#.Cons [patternH bodyH] branchesT) + (#.Item [patternH bodyH] branchesT) (do {! ///.monad} [[inputT inputA] (//type.with_inference (analyse archive inputC)) @@ -321,5 +321,5 @@ (/.failure error))] (in (#/.Case inputA [outputH outputT]))) - #.Nil + #.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 37177e7ba..9a34b72aa 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 @@ -122,10 +122,10 @@ ## their sub-patterns. (#/.Complex (#/.Tuple membersP+)) (case (list.reverse membersP+) - (^or #.Nil (#.Cons _ #.Nil)) + (^or #.End (#.Item _ #.End)) (/.except ..invalid_tuple_pattern []) - (#.Cons lastP prevsP+) + (#.Item lastP prevsP+) (do ////.monad [lastC (determine lastP)] (monad.fold ////.monad @@ -328,17 +328,17 @@ (function (_ coverageA possibilitiesSF) (loop [altsSF possibilitiesSF] (case altsSF - #.Nil + #.End (in [#.None (list coverageA)]) - (#.Cons altSF altsSF') + (#.Item altSF altsSF') (case (merge coverageA altSF) (#try.Success altMSF) (case altMSF (#Alt _) (do ! [[success altsSF+] (recur altsSF')] - (in [success (#.Cons altSF altsSF+)])) + (in [success (#.Item altSF altsSF+)])) _ (in [(#.Some altMSF) altsSF'])) @@ -357,12 +357,12 @@ #.None (case (list.reverse possibilitiesSF) - (#.Cons last prevs) + (#.Item last prevs) (in (list\fold (function (_ left right) (#Alt left right)) last prevs)) - #.Nil + #.End (undefined))))) _ 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 abdf5b806..05a147c3d 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 @@ -110,12 +110,12 @@ (def: #export (general archive analyse inferT args) (-> Archive Phase Type (List Code) (Operation [Type (List Analysis)])) (case args - #.Nil + #.End (do ///.monad [_ (//type.infer inferT)] (in [inferT (list)])) - (#.Cons argC args') + (#.Item argC args') (case inferT (#.Named name unnamedT) (general archive analyse unnamedT args) 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 1ae1152bd..eccae999a 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 @@ -106,7 +106,7 @@ (if (list.any? (text\= module) current) current - (#.Cons module current))))) + (#.Item module current))))) state) []]))))) @@ -118,7 +118,7 @@ (function (_ state) (#try.Success [(update@ #.modules (plist.update self_name (update@ #.module_aliases (: (-> (List [Text Text]) (List [Text Text])) - (|>> (#.Cons [alias module]))))) + (|>> (#.Item [alias module]))))) state) []]))))) @@ -145,7 +145,7 @@ (plist.put self_name (update@ #.definitions (: (-> (List [Text Global]) (List [Text Global])) - (|>> (#.Cons [name definition]))) + (|>> (#.Item [name definition]))) self)) state) []]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux index ab202ed61..863975408 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 @@ -51,12 +51,12 @@ (loop [idx 0 mappings (get@ [#.captured #.mappings] scope)] (case mappings - (#.Cons [_name [_source_type _source_ref]] mappings') + (#.Item [_name [_source_type _source_ref]] mappings') (if (text\= name _name) (#.Some [_source_type (#variable.Foreign idx)]) (recur (inc idx) mappings')) - #.Nil + #.End #.None))) (def: (reference? name scope) @@ -81,22 +81,22 @@ (get@ #.scopes) (list.split_with (|>> (reference? name) not)))] (case outer - #.Nil + #.End (#.Right [state #.None]) - (#.Cons top_outer _) + (#.Item top_outer _) (let [[ref_type init_ref] (maybe.default (undefined) (..reference name top_outer)) [ref inner'] (list\fold (: (-> Scope [Variable (List Scope)] [Variable (List Scope)]) (function (_ scope ref+inner) [(#variable.Foreign (get@ [#.captured #.counter] scope)) - (#.Cons (update@ #.captured + (#.Item (update@ #.captured (: (-> Foreign Foreign) (|>> (update@ #.counter inc) (update@ #.mappings (plist.put name [ref_type (product.left ref+inner)])))) scope) (product.right ref+inner))])) - [init_ref #.Nil] + [init_ref #.End] (list.reverse inner)) scopes (list\compose inner' outer)] (#.Right [(set@ #.scopes scopes state) @@ -110,7 +110,7 @@ (All [a] (-> [Text Type] (Operation a) (Operation a))) (function (_ [bundle state]) (case (get@ #.scopes state) - (#.Cons head tail) + (#.Item head tail) (let [old_mappings (get@ [#.locals #.mappings] head) new_var_id (get@ [#.locals #.counter] head) new_head (update@ #.locals @@ -118,12 +118,12 @@ (|>> (update@ #.counter inc) (update@ #.mappings (plist.put name [type new_var_id])))) head)] - (case (///.run' [bundle (set@ #.scopes (#.Cons new_head tail) state)] + (case (///.run' [bundle (set@ #.scopes (#.Item new_head tail) state)] action) (#try.Success [[bundle' state'] output]) (case (get@ #.scopes state') - (#.Cons head' tail') - (let [scopes' (#.Cons (set@ #.locals (get@ #.locals head) head') + (#.Item head' tail') + (let [scopes' (#.Item (set@ #.locals (get@ #.locals head) head') tail')] (#try.Success [[bundle' (set@ #.scopes scopes' state')] output])) @@ -159,13 +159,13 @@ (All [a] (-> Text (Operation a) (Operation a))) (function (_ [bundle state]) (let [parent_name (case (get@ #.scopes state) - #.Nil + #.End (list) - (#.Cons top _) + (#.Item top _) (get@ #.name top))] (case (action [bundle (update@ #.scopes - (|>> (#.Cons (scope parent_name name))) + (|>> (#.Item (scope parent_name name))) state)]) (#try.Success [[bundle' state'] output]) (#try.Success [[bundle' (update@ #.scopes @@ -184,10 +184,10 @@ (///extension.lift (function (_ state) (case (get@ #.scopes state) - (#.Cons top _) + (#.Item top _) (#try.Success [state (get@ [#.locals #.counter] top)]) - #.Nil + #.End (exception.except ..cannot_get_next_reference_when_there_is_no_scope []))))) (def: (ref_to_variable ref) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux index 449ac9606..f3e9d30a1 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 @@ -173,20 +173,20 @@ (loop [membersT+ (type.flat_tuple expectedT) membersC+ members] (case [membersT+ membersC+] - [(#.Cons memberT #.Nil) _] + [(#.Item memberT #.End) _] (//type.with_type memberT (\ ! map (|>> list) (analyse archive (code.tuple membersC+)))) - [_ (#.Cons memberC #.Nil)] + [_ (#.Item memberC #.End)] (//type.with_type (type.tuple membersT+) (\ ! map (|>> list) (analyse archive memberC))) - [(#.Cons memberT membersT+') (#.Cons memberC membersC+')] + [(#.Item memberT membersT+') (#.Item memberC membersC+')] (do ! [memberA (//type.with_type memberT (analyse archive memberC)) memberA+ (recur membersT+' membersC+')] - (in (#.Cons memberA memberA+))) + (in (#.Item memberA memberA+))) _ (/.except ..cannot_analyse_tuple [expectedT members]))))] @@ -302,10 +302,10 @@ (-> (List [Name Code]) (Operation [(List Code) Type])) (case record ## empty_record = empty_tuple = unit = [] - #.Nil + #.End (\ ///.monad in [(list) Any]) - (#.Cons [head_k head_v] _) + (#.Item [head_k head_v] _) (do {! ///.monad} [head_k (///extension.lift (meta.normal head_k)) [_ tag_set recordT] (///extension.lift (meta.resolve_tag head_k)) 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 6ff584f36..b34743db7 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 @@ -164,7 +164,7 @@ ## TODO: Get rid of this template block and use the definition in ## lux/ffi.jvm.lux ASAP (template [<name> <class>] - [(def: #export <name> .Type (#.Primitive <class> #.Nil))] + [(def: #export <name> .Type (#.Primitive <class> #.End))] ## Boxes [Boolean box.boolean] @@ -366,7 +366,7 @@ (case (dictionary.get class ..boxes) (#.Some [_ primitive_type]) (case parametersT - #.Nil + #.End (phase\in primitive_type) _ @@ -528,7 +528,7 @@ (def: (check_jvm objectT) (-> .Type (Operation (Type Value))) (case objectT - (#.Primitive name #.Nil) + (#.Primitive name #.End) (`` (cond (~~ (template [<type>] [(text\= (..reflection <type>) name) (phase\in <type>)] @@ -878,7 +878,7 @@ #.None (if (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers from_class)) - (#.Cons (:as java/lang/reflect/Type (ffi.class_for java/lang/Object)) + (#.Item (:as java/lang/reflect/Type (ffi.class_for java/lang/Object)) (array.to_list (java/lang/Class::getGenericInterfaces from_class))) (array.to_list (java/lang/Class::getGenericInterfaces from_class))))))) @@ -952,10 +952,10 @@ (case (|> candidate_parents (list.only product.right) (list\map product.left)) - (#.Cons [next_name nextT] _) + (#.Item [next_name nextT] _) (recur [next_name nextT]) - #.Nil + #.End (in false)))))))))] (if can_cast? (in (#/////analysis.Extension extension_name (list (/////analysis.text from_name) @@ -1303,10 +1303,10 @@ (|>> #Hint)) (method_signature method_style method)))))))] (case (list.all pass! candidates) - (#.Cons method #.Nil) + (#.Item method #.End) (in method) - #.Nil + #.End (/////analysis.except ..no_candidates [class_name method_name inputsJT (list.all hint! candidates)]) candidates @@ -1333,10 +1333,10 @@ (if passes? (|>> #Pass) (|>> #Hint)) (constructor_signature constructor))))))] (case (list.all pass! candidates) - (#.Cons constructor #.Nil) + (#.Item constructor #.End) (in constructor) - #.Nil + #.End (/////analysis.except ..no_candidates [class_name ..constructor_method inputsJT (list.all hint! candidates)]) candidates @@ -1398,7 +1398,7 @@ (not deprecated?)) [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\map product.right argsTC))) #let [[objectA argsA] (case allA - (#.Cons objectA argsA) + (#.Item objectA argsA) [objectA argsA] _ @@ -1444,7 +1444,7 @@ (not deprecated?)) [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\map product.right argsTC))) #let [[objectA argsA] (case allA - (#.Cons objectA argsA) + (#.Item objectA argsA) [objectA argsA] _ @@ -1685,7 +1685,7 @@ (in [name luxT]))) arguments) [scope bodyA] (|> arguments' - (#.Cons [self_name selfT]) + (#.Item [self_name selfT]) list.reverse (list\fold scope.with_local (analyse archive body)) (typeA.with_type .Any) @@ -1761,7 +1761,7 @@ (in [name luxT]))) arguments) [scope bodyA] (|> arguments' - (#.Cons [self_name selfT]) + (#.Item [self_name selfT]) list.reverse (list\fold scope.with_local (analyse archive body)) (typeA.with_type returnT) @@ -2001,7 +2001,7 @@ arguments) returnT (boxed_reflection_return mapping return) [scope bodyA] (|> arguments' - (#.Cons [self_name selfT]) + (#.Item [self_name selfT]) list.reverse (list\fold scope.with_local (analyse archive body)) (typeA.with_type returnT) @@ -2153,7 +2153,7 @@ (analyse archive term))] (in [type termA]))) constructor_args) - #let [supers (#.Cons super_class super_interfaces)] + #let [supers (#.Item super_class super_interfaces)] _ (..require_complete_method_concretion class_loader supers methods) methodsA (monad.map ! (analyse_overriden_method analyse archive selfT mapping supers) methods)] (in (#/////analysis.Extension extension_name 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 ec91d1e10..4fd8d5842 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 @@ -110,7 +110,7 @@ (/.install "/" (binary _.floor/2)) (/.install "%" (binary _.rem/2)) ## (/.install "f64" (unary (_.//2 (_.float +1.0)))) - (/.install "char" (unary (|>> _.code-char/1 _.string/1))) + (/.install "char" (unary (|>> _.code_char/1 _.string/1))) ))) (def: f64_procs @@ -125,7 +125,7 @@ ## (/.install "/" (binary (product.uncurry _.//2))) ## (/.install "%" (binary (product.uncurry _.rem/2))) ## (/.install "i64" (unary _.truncate/1)) - (/.install "encode" (unary _.write-to-string/1)) + (/.install "encode" (unary _.write_to_string/1)) ## (/.install "decode" (unary //runtime.f64//decode)) ))) @@ -139,7 +139,7 @@ (def: (text//char [index text]) (Binary (Expression Any)) - (_.char-code/1 (_.char/2 [text index]))) + (_.char_code/1 (_.char/2 [text index]))) (def: text_procs Bundle @@ -157,7 +157,7 @@ (def: (io//log! message) (Unary (Expression Any)) - (_.progn (list (_.write-line/1 message) + (_.progn (list (_.write_line/1 message) //runtime.unit))) (def: io_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux index 2025fe4e2..3663f845a 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 @@ -110,7 +110,7 @@ (/.install "/" (binary (product.uncurry //runtime.i64//division))) (/.install "%" (binary (product.uncurry _.remainder/2))) (/.install "f64" (unary (_.//2 (_.float +1.0)))) - (/.install "char" (unary (|>> _.integer->char/1 (_.make-string/2 (_.int +1))))) + (/.install "char" (unary (|>> _.integer->char/1 (_.make_string/2 (_.int +1))))) ))) (def: f64_procs @@ -142,9 +142,9 @@ (|> /.empty (/.install "=" (binary (product.uncurry _.string=?/2))) (/.install "<" (binary (product.uncurry _.string<?/2))) - (/.install "concat" (binary (product.uncurry _.string-append/2))) + (/.install "concat" (binary (product.uncurry _.string_append/2))) (/.install "index" (trinary ..text//index)) - (/.install "size" (unary _.string-length/1)) + (/.install "size" (unary _.string_length/1)) (/.install "char" (binary (product.uncurry //runtime.text//char))) (/.install "clip" (trinary ..text//clip)) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux index 33a9624c3..23f6056ae 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux @@ -35,15 +35,15 @@ (def: (array::new size) (Unary Expression) - (_.make-vector/2 size _.nil)) + (_.make_vector/2 size _.nil)) (def: array::length (Unary Expression) - _.vector-length/1) + _.vector_length/1) (def: (array::read [indexG arrayG]) (Binary Expression) - (_.vector-ref/2 arrayG indexG)) + (_.vector_ref/2 arrayG indexG)) (def: (array::write [indexG valueG arrayG]) (Trinary Expression) 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 45e2a3bba..098674e45 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 @@ -171,7 +171,7 @@ then!)))) (^template [<tag> <format> <=>] - [(<tag> cons) + [(<tag> item) (do {! ///////phase.monad} [clauses (monad.map ! (function (_ [match then]) (do ! @@ -179,7 +179,7 @@ (in [(<=> [(|> match <format>) ..peek]) then!]))) - (#.Cons cons))] + (#.Item item))] (in (list\fold (function (_ [when then] else) (_.if when then else)) (_.go @fail) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux index baac3e891..1853971a6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux @@ -12,7 +12,7 @@ [collection ["." dictionary]]] [target - ["_" common-lisp (#+ Expression)]]]] + ["_" common_lisp (#+ Expression)]]]] ["." /// #_ ["#." runtime (#+ Operation Phase Handler Bundle)] ["#." primitive] @@ -23,35 +23,35 @@ [extension ["." bundle]]]]]) -(def: lux-procs +(def: lux_procs Bundle (|> bundle.empty (bundle.install "is" (binary (product.uncurry _.eq))) (bundle.install "try" (unary ///runtime.lux//try)))) -(def: (i64//left-shift [paramG subjectG]) +(def: (i64//left_shift [paramG subjectG]) (Binary (Expression Any)) (_.ash (_.rem (_.int +64) paramG) subjectG)) -(def: (i64//arithmetic-right-shift [paramG subjectG]) +(def: (i64//arithmetic_right_shift [paramG subjectG]) (Binary (Expression Any)) (_.ash (|> paramG (_.rem (_.int +64)) (_.* (_.int -1))) subjectG)) -(def: (i64//logic-right-shift [paramG subjectG]) +(def: (i64//logic_right_shift [paramG subjectG]) (Binary (Expression Any)) - (///runtime.i64//logic-right-shift (_.rem (_.int +64) paramG) subjectG)) + (///runtime.i64//logic_right_shift (_.rem (_.int +64) paramG) subjectG)) -(def: i64-procs +(def: i64_procs Bundle (<| (bundle.prefix "i64") (|> bundle.empty (bundle.install "and" (binary (product.uncurry _.logand))) (bundle.install "or" (binary (product.uncurry _.logior))) (bundle.install "xor" (binary (product.uncurry _.logxor))) - (bundle.install "left-shift" (binary i64//left-shift)) - (bundle.install "logical-right-shift" (binary i64//logic-right-shift)) - (bundle.install "arithmetic-right-shift" (binary i64//arithmetic-right-shift)) + (bundle.install "left-shift" (binary i64//left_shift)) + (bundle.install "logical-right-shift" (binary i64//logic_right_shift)) + (bundle.install "arithmetic-right-shift" (binary i64//arithmetic_right_shift)) (bundle.install "=" (binary (product.uncurry _.=))) (bundle.install "<" (binary (product.uncurry _.<))) (bundle.install "+" (binary (product.uncurry _.+))) @@ -61,10 +61,10 @@ (bundle.install "%" (binary (product.uncurry _.rem))) (bundle.install "f64" (unary (function (_ value) (_.coerce/2 [value (_.symbol "double-float")])))) - (bundle.install "char" (unary (|>> _.code-char/1 _.string/1))) + (bundle.install "char" (unary (|>> _.code_char/1 _.string/1))) ))) -(def: f64-procs +(def: f64_procs Bundle (<| (bundle.prefix "f64") (|> bundle.empty @@ -76,12 +76,12 @@ (bundle.install "=" (binary (product.uncurry _.=))) (bundle.install "<" (binary (product.uncurry _.<))) (bundle.install "i64" (unary _.floor/1)) - (bundle.install "encode" (unary _.write-to-string/1)) + (bundle.install "encode" (unary _.write_to_string/1)) (bundle.install "decode" (unary (let [@temp (_.var "temp")] (function (_ input) - (_.let (list [@temp (_.read-from-string/1 input)]) + (_.let (list [@temp (_.read_from_string/1 input)]) (_.if (_.equal (_.symbol "DOUBLE-FLOAT") - (_.type-of/1 @temp)) + (_.type_of/1 @temp)) (///runtime.some @temp) ///runtime.none))))))))) @@ -99,7 +99,7 @@ (Trinary (Expression Any)) (///runtime.text//index textO partO startO)) -(def: text-procs +(def: text_procs Bundle (<| (bundle.prefix "text") (|> bundle.empty @@ -108,7 +108,7 @@ (bundle.install "concat" (binary _.concatenate/2|string)) (bundle.install "index" (trinary text//index)) (bundle.install "size" (unary _.length/1)) - (bundle.install "char" (binary (|>> _.char/2 _.char-int/1))) + (bundle.install "char" (binary (|>> _.char/2 _.char_int/1))) (bundle.install "clip" (trinary text//clip)) ))) @@ -118,7 +118,7 @@ code ///runtime.unit)) -(def: io-procs +(def: io_procs Bundle (<| (bundle.prefix "io") (|> bundle.empty @@ -129,9 +129,9 @@ (def: #export bundle Bundle (<| (bundle.prefix "lux") - (|> lux-procs - (dictionary.merge i64-procs) - (dictionary.merge f64-procs) - (dictionary.merge text-procs) - (dictionary.merge io-procs) + (|> lux_procs + (dictionary.merge i64_procs) + (dictionary.merge f64_procs) + (dictionary.merge text_procs) + (dictionary.merge io_procs) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux index a43c24bc8..fab6fe24c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux @@ -43,7 +43,7 @@ (def: (with_closure inits function_definition) (-> (List (Expression Any)) (Expression Any) (Operation (Expression Any))) (case inits - #.Nil + #.End (\ ///////phase.monad in function_definition) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux index 5d7faa8f8..bbb46cba2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux @@ -36,7 +36,7 @@ (Generator (Scope Synthesis)) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (expression archive bodyS) ## true loop 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 b9b97fdbe..fd0e7a780 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 @@ -139,7 +139,7 @@ (runtime: (lux//try op) (with_vars [error] - (_.handler-case + (_.handler_case (list [(_.bool true) error (..left (_.format/3 [_.nil (_.string "~A") error]))]) (..right (_.funcall/+ [op (list ..unit)]))))) 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 6cfd16cc4..a0b6b78e9 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 @@ -17,10 +17,10 @@ (def: #export (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.Nil + #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Cons singletonS #.Nil) + (#.Item singletonS #.End) (expression archive singletonS) _ 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 8c0ef681a..7beef96cb 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 @@ -251,7 +251,7 @@ else! then!)))) - (#/////synthesis.I64_Fork cons) + (#/////synthesis.I64_Fork item) (do {! ///////phase.monad} [clauses (monad.map ! (function (_ [match then]) (do ! @@ -259,15 +259,15 @@ (in [(//runtime.i64//= (//primitive.i64 (.int match)) ..peek_cursor) then!]))) - (#.Cons cons))] + (#.Item item))] (in (_.cond clauses ..fail_pm!))) (^template [<tag> <format>] - [(<tag> cons) + [(<tag> item) (do {! ///////phase.monad} [cases (monad.map ! (function (_ [match then]) (\ ! map (|>> [(list (<format> match))]) (recur then))) - (#.Cons cons))] + (#.Item item))] (in (_.switch ..peek_cursor cases (#.Some ..fail_pm!))))]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux index b06f9e347..d4b81f29b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux @@ -41,7 +41,7 @@ (def: (with_closure @self inits body!) (-> Var (List Expression) Statement [Statement Expression]) (case inits - #.Nil + #.End [(_.function! @self (list) body!) @self] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux index 8e9f4265c..de6b0a500 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux @@ -45,7 +45,7 @@ (Generator! (Scope Synthesis)) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (statement expression archive bodyS) ## true loop @@ -64,7 +64,7 @@ (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (expression archive bodyS) ## true loop 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 1b3f8e526..5cbacf111 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 @@ -17,10 +17,10 @@ (def: #export (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.Nil + #.End (///////phase\in //runtime.unit) - (#.Cons singletonS #.Nil) + (#.Item singletonS #.End) (generate archive singletonS) _ 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 cfe49a36b..d3e13091a 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 @@ -97,7 +97,7 @@ @labelsT (|> _.new_label (list.repeat (dec num_partials)) (monad.seq _.monad)) - #let [cases (|> (list\compose (#.Cons [@labelsH @labelsT]) + #let [cases (|> (list\compose (#.Item [@labelsH @labelsT]) (list @default)) list.enumeration (list\map (function (_ [stage @case]) 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 b997af01d..06b60b6c1 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 @@ -29,10 +29,10 @@ (def: #export (tuple generate archive membersS) (Generator (Tuple Synthesis)) (case membersS - #.Nil + #.End (\ phase.monad in //runtime.unit) - (#.Cons singletonS #.Nil) + (#.Item singletonS #.End) (generate archive singletonS) _ 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 94b086149..2114acc89 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 @@ -190,7 +190,7 @@ then!)))) (^template [<tag> <format>] - [(<tag> cons) + [(<tag> item) (do {! ///////phase.monad} [clauses (monad.map ! (function (_ [match then]) (do ! @@ -198,7 +198,7 @@ (in [(_.= (|> match <format>) ..peek) then!]))) - (#.Cons cons))] + (#.Item item))] (in (_.cond clauses ..fail!)))]) ([#/////synthesis.I64_Fork (<| _.int .int)] [#/////synthesis.F64_Fork _.float] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux index 66f2aa0c4..9affe12f6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux @@ -43,7 +43,7 @@ (def: (with_closure inits @self @args body!) (-> (List Expression) Var (List Var) Statement [Statement Expression]) (case inits - #.Nil + #.End [(_.function @self @args body!) @self] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux index 7d063fa09..5d44bcc3c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux @@ -53,7 +53,7 @@ (Operation [(List Expression) Statement])) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (|> bodyS (statement expression archive) (\ ///////phase.monad map (|>> [(list)]))) @@ -75,7 +75,7 @@ (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (expression archive bodyS) ## true loop @@ -93,7 +93,7 @@ (set.of_list _.hash) (set.difference (set.of_list _.hash locals)) set.to_list) - #.Nil + #.End [(_.function @loop locals scope!) @loop] 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 56954873e..8b070c7a3 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 @@ -17,10 +17,10 @@ (def: #export (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.Nil + #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Cons singletonS #.Nil) + (#.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 12714b2cd..aad40560a 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 @@ -59,7 +59,7 @@ (//////phase\map _.return (/function.function statement expression archive abstraction)) )) -(exception: #export cannot-recur-as-an-expression) +(exception: #export cannot_recur_as_an_expression) (def: #export (expression archive synthesis) Phase @@ -93,7 +93,7 @@ [////synthesis.function/abstraction /function.function]) (^ (////synthesis.loop/recur _)) - (//////phase.except ..cannot-recur-as-an-expression []) + (//////phase.except ..cannot_recur_as_an_expression []) (#////synthesis.Extension extension) (///extension.apply archive expression extension))) 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 48a05b104..af27eb9fc 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 @@ -190,7 +190,7 @@ then!)))) (^template [<tag> <format>] - [(<tag> cons) + [(<tag> item) (do {! ///////phase.monad} [clauses (monad.map ! (function (_ [match then]) (do ! @@ -198,7 +198,7 @@ (in [(_.=== (|> match <format>) ..peek) then!]))) - (#.Cons cons))] + (#.Item item))] (in (_.cond clauses ..fail!)))]) ([#/////synthesis.I64_Fork //primitive.i64] [#/////synthesis.F64_Fork //primitive.f64] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux index 5eaccf0aa..8da358393 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux @@ -24,28 +24,28 @@ [extension ["." bundle]]]]]) -(def: lux-procs +(def: lux_procs Bundle (|> bundle.empty (bundle.install "is" (binary (product.uncurry _.=))) (bundle.install "try" (unary ///runtime.lux//try)))) -(def: i64-procs +(def: i64_procs Bundle (<| (bundle.prefix "i64") (|> bundle.empty - (bundle.install "and" (binary (product.uncurry _.bit-and))) - (bundle.install "or" (binary (product.uncurry _.bit-or))) - (bundle.install "xor" (binary (product.uncurry _.bit-xor))) - (bundle.install "left-shift" (binary (product.uncurry _.bit-shl))) - (bundle.install "logical-right-shift" (binary (product.uncurry ///runtime.i64//logic-right-shift))) - (bundle.install "arithmetic-right-shift" (binary (product.uncurry _.bit-shr))) + (bundle.install "and" (binary (product.uncurry _.bit_and))) + (bundle.install "or" (binary (product.uncurry _.bit_or))) + (bundle.install "xor" (binary (product.uncurry _.bit_xor))) + (bundle.install "left-shift" (binary (product.uncurry _.bit_shl))) + (bundle.install "logical-right-shift" (binary (product.uncurry ///runtime.i64//logic_right_shift))) + (bundle.install "arithmetic-right-shift" (binary (product.uncurry _.bit_shr))) (bundle.install "=" (binary (product.uncurry _.=))) (bundle.install "+" (binary (product.uncurry _.+))) (bundle.install "-" (binary (product.uncurry _.-))) ))) -(def: int-procs +(def: int_procs Bundle (<| (bundle.prefix "int") (|> bundle.empty @@ -56,7 +56,7 @@ (bundle.install "frac" (unary _.floatval/1)) (bundle.install "char" (unary _.chr/1))))) -(def: frac-procs +(def: frac_procs Bundle (<| (bundle.prefix "frac") (|> bundle.empty @@ -76,7 +76,7 @@ (Trinary (Expression Any)) (///runtime.text//index textO partO startO)) -(def: text-procs +(def: text_procs Bundle (<| (bundle.prefix "text") (|> bundle.empty @@ -91,11 +91,11 @@ (_.substr/3 [text from (_.- from to)])))) ))) -(def: io-procs +(def: io_procs Bundle (<| (bundle.prefix "io") (|> bundle.empty - (bundle.install "log" (unary (|>> (_.concat (_.string text.new-line)) _.print/1))) + (bundle.install "log" (unary (|>> (_.concat (_.string text.new_line)) _.print/1))) (bundle.install "error" (unary ///runtime.io//throw!)) (bundle.install "exit" (unary _.exit/1)) (bundle.install "current-time" (nullary (|>> _.time/0 (_.* (_.int +1,000)))))))) @@ -103,10 +103,10 @@ (def: #export bundle Bundle (<| (bundle.prefix "lux") - (|> lux-procs - (dictionary.merge i64-procs) - (dictionary.merge int-procs) - (dictionary.merge frac-procs) - (dictionary.merge text-procs) - (dictionary.merge io-procs) + (|> lux_procs + (dictionary.merge i64_procs) + (dictionary.merge int_procs) + (dictionary.merge frac_procs) + (dictionary.merge text_procs) + (dictionary.merge io_procs) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux index d1cfcea2e..9f02325d3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux @@ -50,7 +50,7 @@ (def: (with_closure inits @selfG @selfL body!) (-> (List Expression) Global Var Statement [Statement Expression]) (case inits - #.Nil + #.End [($_ _.then (_.set! @selfL (_.closure (list (_.reference @selfL)) (list) body!)) (_.set! @selfG @selfL)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux index 4952b71ab..82fe69b94 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux @@ -51,7 +51,7 @@ (Generator! (Scope Synthesis)) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (statement expression archive bodyS) ## true loop @@ -70,7 +70,7 @@ (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (expression archive bodyS) ## true loop @@ -92,7 +92,7 @@ (list\fold set.union (referenced_variables bodyS)) (set.difference loop_variables) set.to_list) - #.Nil + #.End [(_.define_function @loop (list) scope!) @loop] 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 5d01a16c6..601361f31 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 @@ -20,10 +20,10 @@ (def: #export (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.Nil + #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Cons singletonS #.Nil) + (#.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 d88f2eb0c..1d01ba8b0 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 @@ -59,7 +59,7 @@ (//////phase\map _.return (/function.function statement expression archive abstraction)) )) -(exception: #export cannot-recur-as-an-expression) +(exception: #export cannot_recur_as_an_expression) (def: #export (expression archive synthesis) Phase @@ -97,7 +97,7 @@ (/loop.scope ..statement expression archive scope) (^ (////synthesis.loop/recur updates)) - (//////phase.except ..cannot-recur-as-an-expression []) + (//////phase.except ..cannot_recur_as_an_expression []) (^ (////synthesis.function/abstraction abstraction)) (/function.function ..statement expression archive abstraction) 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 71e856034..a3f993150 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 @@ -197,14 +197,14 @@ then!))))) (^template [<tag> <format>] - [(<tag> cons) + [(<tag> item) (do {! ///////phase.monad} [clauses (monad.map ! (function (_ [match then]) (\ ! map (|>> [(_.= (|> match <format>) ..peek)]) (recur then))) - (#.Cons cons))] + (#.Item item))] (in (#.Some (_.cond clauses ..fail_pm!))))]) ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux index 3c114a935..58d814dcc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux @@ -45,7 +45,7 @@ (def: (with_closure function_id @function inits function_definition) (-> artifact.ID SVar (List (Expression Any)) (Statement Any) (Operation (Expression Any))) (case inits - #.Nil + #.End (do ///////phase.monad [_ (/////generation.execute! function_definition) _ (/////generation.save! function_id #.None function_definition)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux index 45dbaf999..066925e96 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux @@ -51,7 +51,7 @@ (Generator! (Scope Synthesis)) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (statement expression archive bodyS) ## true loop @@ -68,7 +68,7 @@ (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (expression archive bodyS) ## true loop @@ -91,7 +91,7 @@ (set.of_list _.hash) (set.difference (set.of_list _.hash locals)) set.to_list) - #.Nil + #.End [actual_loop @loop] 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 394804f3e..4e7bc841d 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 @@ -17,10 +17,10 @@ (def: #export (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.Nil + #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Cons singletonS #.Nil) + (#.Item singletonS #.End) (generate archive singletonS) _ 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 1026bd0fe..133ce1fa8 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 @@ -162,7 +162,7 @@ then!)))) (^template [<tag> <format> <=>] - [(<tag> cons) + [(<tag> item) (do {! ///////phase.monad} [clauses (monad.map ! (function (_ [match then]) (do ! @@ -170,7 +170,7 @@ (in [(<=> (|> match <format>) ..peek) then!]))) - (#.Cons cons))] + (#.Item item))] (in (list\fold (function (_ [when then] else) (_.if when then else)) ..fail! diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux index ed2ef6a5d..a6497d206 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux @@ -42,7 +42,7 @@ (def: (with_closure function_id $function inits function_definition) (-> artifact.ID SVar (List Expression) Expression (Operation Expression)) (case inits - #.Nil + #.End (do ///////phase.monad [_ (/////generation.execute! function_definition) _ (/////generation.save! (%.nat function_id) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux index 84d61fb44..47bb19e87 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux @@ -37,7 +37,7 @@ (Generator (Scope Synthesis)) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (expression archive bodyS) ## true loop 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 557d5b572..225d32a81 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 @@ -10,7 +10,7 @@ [number] (coll [list "list/" Functor<List>] (dictionary ["dict" unordered #+ Dict]))) - [macro #+ with-gensyms] + [macro #+ with_gensyms] (macro [code] ["s" syntax #+ syntax:]) [host]) @@ -54,19 +54,19 @@ (|> bundle dict.entries (list/map (function (_ [key val]) [(format prefix " " key) val])) - (dict.from-list text.Hash<Text>))) + (dict.from_list text.Hash<Text>))) -(def: (wrong-arity proc expected actual) +(def: (wrong_arity proc expected actual) (-> Text Nat Nat Text) (format "Wrong number of arguments for " (%t proc) "\n" "Expected: " (|> expected .int %i) "\n" " Actual: " (|> actual .int %i))) -(syntax: (arity: {name s.local-identifier} {arity s.nat}) - (with-gensyms [g!_ g!proc g!name g!translate g!inputs] +(syntax: (arity: {name s.local_identifier} {arity s.nat}) + (with_gensyms [g!_ g!proc g!name g!translate g!inputs] (do {@ macro.monad} [g!input+ (monad.seq @ (list.repeat arity (macro.gensym "input")))] - (in (list (` (def: #export ((~ (code.local-identifier name)) (~ g!proc)) + (in (list (` (def: #export ((~ (code.local_identifier name)) (~ g!proc)) (-> (-> (..Vector (~ (code.nat arity)) Expression) Expression) (-> Text ..Proc)) (function ((~ g!_) (~ g!name)) @@ -81,7 +81,7 @@ ((~' in) ((~ g!proc) [(~+ g!input+)]))) (~' _) - (macro.failure (wrong-arity (~ g!name) +1 (list.size (~ g!inputs)))))))))))))) + (macro.failure (wrong_arity (~ g!name) +1 (list.size (~ g!inputs)))))))))))))) (arity: nullary +0) (arity: unary +1) @@ -90,7 +90,7 @@ (def: #export (variadic proc) (-> Variadic (-> Text Proc)) - (function (_ proc-name) + (function (_ proc_name) (function (_ translate inputsS) (do {@ macro.Monad<Meta>} [inputsI (monad.map @ translate inputsS)] @@ -105,39 +105,39 @@ (def: (lux//if [testO thenO elseO]) Trinary - (caseT.translate-if testO thenO elseO)) + (caseT.translate_if testO thenO elseO)) (def: (lux//try riskyO) Unary (runtimeT.lux//try riskyO)) -(exception: #export (Wrong-Syntax {message Text}) +(exception: #export (Wrong_Syntax {message Text}) message) -(def: #export (wrong-syntax procedure args) +(def: #export (wrong_syntax procedure args) (-> Text (List ls.Synthesis) Text) (format "Procedure: " procedure "\n" "Arguments: " (%code (code.tuple args)))) (def: lux//loop (-> Text Proc) - (function (_ proc-name) + (function (_ proc_name) (function (_ translate inputsS) (case (s.run inputsS ($_ p.seq s.nat (s.tuple (p.many s.any)) s.any)) (#e.Success [offset initsS+ bodyS]) - (loopT.translate-loop translate offset initsS+ bodyS) + (loopT.translate_loop translate offset initsS+ bodyS) (#e.Error error) - (&.throw Wrong-Syntax (wrong-syntax proc-name inputsS))) + (&.throw Wrong_Syntax (wrong_syntax proc_name inputsS))) ))) (def: lux//recur (-> Text Proc) - (function (_ proc-name) + (function (_ proc_name) (function (_ translate inputsS) - (loopT.translate-recur translate inputsS)))) + (loopT.translate_recur translate inputsS)))) -(def: lux-procs +(def: lux_procs Bundle (|> (dict.new text.Hash<Text>) (install "is" (binary lux//is)) @@ -161,23 +161,23 @@ (template [<name> <op>] [(def: (<name> [subjectO paramO]) Binary - (<op> (runtimeT.int64-low paramO) subjectO))] + (<op> (runtimeT.int64_low paramO) subjectO))] - [bit//left-shift runtimeT.bit//left-shift] - [bit//arithmetic-right-shift runtimeT.bit//arithmetic-right-shift] - [bit//logical-right-shift runtimeT.bit//logical-right-shift] + [bit//left_shift runtimeT.bit//left_shift] + [bit//arithmetic_right_shift runtimeT.bit//arithmetic_right_shift] + [bit//logical_right_shift runtimeT.bit//logical_right_shift] ) -(def: bit-procs +(def: bit_procs Bundle (<| (prefix "bit") (|> (dict.new text.Hash<Text>) (install "and" (binary bit//and)) (install "or" (binary bit//or)) (install "xor" (binary bit//xor)) - (install "left-shift" (binary bit//left-shift)) - (install "logical-right-shift" (binary bit//logical-right-shift)) - (install "arithmetic-right-shift" (binary bit//arithmetic-right-shift)) + (install "left-shift" (binary bit//left_shift)) + (install "logical-right-shift" (binary bit//logical_right_shift)) + (install "arithmetic-right-shift" (binary bit//arithmetic_right_shift)) ))) ## [[Numbers]] @@ -238,9 +238,9 @@ (function (_ value) (r.apply (list value) func))) -(def: int//char (|>> runtimeT.int64-low (apply1 (r.global "intToUtf8")))) +(def: int//char (|>> runtimeT.int64_low (apply1 (r.global "intToUtf8")))) -(def: int-procs +(def: int_procs Bundle (<| (prefix "int") (|> (dict.new text.Hash<Text>) @@ -251,14 +251,14 @@ (install "%" (binary int//rem)) (install "=" (binary int//=)) (install "<" (binary int//<)) - (install "to-frac" (unary runtimeT.int//to-float)) + (install "to-frac" (unary runtimeT.int//to_float)) (install "char" (unary int//char))))) (def: (frac//encode value) (-> Expression Expression) (r.apply (list (r.string "%f") value) (r.global "sprintf"))) -(def: frac-procs +(def: frac_procs Bundle (<| (prefix "frac") (|> (dict.new text.Hash<Text>) @@ -293,7 +293,7 @@ Trinary (runtimeT.text//index textO partO startO)) -(def: text-procs +(def: text_procs Bundle (<| (prefix "text") (|> (dict.new text.Hash<Text>) @@ -301,7 +301,7 @@ (install "<" (binary text//<)) (install "concat" (binary text//concat)) (install "index" (trinary text//index)) - (install "size" (unary (|>> (apply1 (r.global "nchar")) runtimeT.int//from-float))) + (install "size" (unary (|>> (apply1 (r.global "nchar")) runtimeT.int//from_float))) (install "char" (binary text//char)) (install "clip" (trinary text//clip)) ))) @@ -309,15 +309,15 @@ ## [[IO]] (def: (io//exit input) Unary - (r.apply-kw (list) - (list ["status" (runtimeT.int//to-float input)]) + (r.apply_kw (list) + (list ["status" (runtimeT.int//to_float input)]) (r.global "quit"))) (def: (void code) (-> Expression Expression) (r.block (r.then code runtimeT.unit))) -(def: io-procs +(def: io_procs Bundle (<| (prefix "io") (|> (dict.new text.Hash<Text>) @@ -325,16 +325,16 @@ (install "error" (unary r.stop)) (install "exit" (unary io//exit)) (install "current-time" (nullary (function (_ _) - (runtimeT.io//current-time! runtimeT.unit))))))) + (runtimeT.io//current_time! runtimeT.unit))))))) ## [Bundles] (def: #export procedures Bundle (<| (prefix "lux") - (|> lux-procs - (dict.merge bit-procs) - (dict.merge int-procs) - (dict.merge frac-procs) - (dict.merge text-procs) - (dict.merge io-procs) + (|> lux_procs + (dict.merge bit_procs) + (dict.merge int_procs) + (dict.merge frac_procs) + (dict.merge text_procs) + (dict.merge io_procs) ))) 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 74dc0231e..cb0f5e48d 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 @@ -31,7 +31,7 @@ ## (in name)) ## _ -## (&.throw @.Wrong-Syntax (@.wrong-syntax proc inputs)))) +## (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) ## (def: (lua//call proc translate inputs) ## (-> Text @.Proc) @@ -43,9 +43,9 @@ ## (in (lua.apply functionO argsO+))) ## _ -## (&.throw @.Wrong-Syntax (@.wrong-syntax proc inputs)))) +## (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) -## (def: lua-procs +## (def: lua_procs ## @.Bundle ## (|> (dict.new text.Hash<Text>) ## (@.install "nil" (@.nullary lua//nil)) @@ -63,7 +63,7 @@ ## (in (lua.method field tableO argsO+))) ## _ -## (&.throw @.Wrong-Syntax (@.wrong-syntax proc inputs)))) +## (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) ## (def: (table//get [fieldO tableO]) ## @.Binary @@ -73,7 +73,7 @@ ## @.Trinary ## (runtimeT.lua//set tableO fieldO valueO)) -## (def: table-procs +## (def: table_procs ## @.Bundle ## (<| (@.prefix "table") ## (|> (dict.new text.Hash<Text>) @@ -85,6 +85,6 @@ @.Bundle (<| (@.prefix "lua") (dict.new text.Hash<Text>) - ## (|> lua-procs - ## (dict.merge table-procs)) + ## (|> lua_procs + ## (dict.merge table_procs)) )) 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 1853aa963..4ea0f31a2 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 @@ -20,10 +20,10 @@ (def: #export (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.Nil + #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Cons singletonS #.Nil) + (#.Item singletonS #.End) (expression archive singletonS) _ 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 f4c393a19..3a80031eb 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 @@ -59,7 +59,7 @@ (//////phase\map _.return (/function.function statement expression archive abstraction)) )) -(exception: #export cannot-recur-as-an-expression) +(exception: #export cannot_recur_as_an_expression) (def: (expression archive synthesis) Phase @@ -92,7 +92,7 @@ [////synthesis.function/abstraction /function.function]) (^ (////synthesis.loop/recur _)) - (//////phase.except ..cannot-recur-as-an-expression []) + (//////phase.except ..cannot_recur_as_an_expression []) (#////synthesis.Reference value) (//reference.reference /reference.system archive value) 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 edb00ae21..69df6f104 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 @@ -206,14 +206,14 @@ then!))))) (^template [<tag> <format>] - [(<tag> cons) + [(<tag> item) (do {! ///////phase.monad} [clauses (monad.map ! (function (_ [match then]) (\ ! map (|>> [(_.= (|> match <format>) ..peek)]) (recur then))) - (#.Cons cons))] + (#.Item item))] (in (#.Some (_.cond clauses ..fail!))))]) ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] @@ -261,14 +261,14 @@ then!)))) (^template [<tag> <format>] - [(<tag> cons) + [(<tag> item) (do {! ///////phase.monad} [clauses (monad.map ! (function (_ [match then]) (\ ! map (|>> [(_.= (|> match <format>) ..peek)]) (recur then))) - (#.Cons cons))] + (#.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 eae79b459..8c849da68 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 @@ -45,7 +45,7 @@ (def: (with_closure inits self function_definition) (-> (List Expression) Text Expression [Statement Expression]) (case inits - #.Nil + #.End (let [@self (_.global self)] [(_.set (list @self) function_definition) @self]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux index 14f55ae91..ed5370a68 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux @@ -52,7 +52,7 @@ (Generator! (Scope Synthesis)) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (statement expression archive bodyS) ## true loop @@ -69,7 +69,7 @@ (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (expression archive bodyS) ## true loop 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 e5d1da1ea..eaf6add62 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 @@ -17,10 +17,10 @@ (def: #export (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.Nil + #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Cons singletonS #.Nil) + (#.Item singletonS #.End) (generate archive singletonS) _ 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 43409b31d..9d9c62b18 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 @@ -156,7 +156,7 @@ then!)))) (^template [<tag> <format> <=>] - [(<tag> cons) + [(<tag> item) (do {! ///////phase.monad} [clauses (monad.map ! (function (_ [match then]) (do ! @@ -164,7 +164,7 @@ (in [(<=> (|> match <format>) ..peek) then!]))) - (#.Cons cons))] + (#.Item item))] (in (list\fold (function (_ [when then] else) (_.if when then else)) ..fail! diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux index 74362d6ad..6b976b9b6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux @@ -15,7 +15,7 @@ [collection ["." list ("#\." functor)] ["dict" dictionary (#+ Dictionary)]]] - ["." macro (#+ with-gensyms) + ["." macro (#+ with_gensyms) ["." code] [syntax (#+ syntax:)]] [target @@ -37,11 +37,11 @@ (type: #export Trinary (-> (Vector 3 Expression) Computation)) (type: #export Variadic (-> (List Expression) Computation)) -(syntax: (arity: {name s.local-identifier} {arity s.nat}) - (with-gensyms [g!_ g!extension g!name g!phase g!inputs] +(syntax: (arity: {name s.local_identifier} {arity s.nat}) + (with_gensyms [g!_ g!extension g!name g!phase g!inputs] (do {! macro.monad} [g!input+ (monad.seq ! (list.repeat arity (macro.gensym "input")))] - (in (list (` (def: #export ((~ (code.local-identifier name)) (~ g!extension)) + (in (list (` (def: #export ((~ (code.local_identifier name)) (~ g!extension)) (-> (-> (..Vector (~ (code.nat arity)) Expression) Computation) Handler) (function ((~ g!_) (~ g!name) (~ g!phase) (~ g!inputs)) @@ -55,7 +55,7 @@ ((~' in) ((~ g!extension) [(~+ g!input+)]))) (~' _) - (/////.except /////extension.incorrect-arity [(~ g!name) 1 (list.size (~ g!inputs))])))))))))) + (/////.except /////extension.incorrect_arity [(~ g!name) 1 (list.size (~ g!inputs))])))))))))) (arity: nullary 0) (arity: unary 1) @@ -64,7 +64,7 @@ (def: #export (variadic extension) (-> Variadic Handler) - (function (_ extension-name) + (function (_ extension_name) (function (_ phase inputsS) (do {! /////.monad} [inputsI (monad.map ! phase inputsS)] @@ -81,24 +81,24 @@ Binary (<op> paramO subjectO))] - [i64::and _.bit-and/2] - [i64::or _.bit-or/2] - [i64::xor _.bit-xor/2] + [i64::and _.bit_and/2] + [i64::or _.bit_or/2] + [i64::xor _.bit_xor/2] ) -(def: (i64::left-shift [subjectO paramO]) +(def: (i64::left_shift [subjectO paramO]) Binary - (_.arithmetic-shift/2 (_.remainder/2 (_.int +64) paramO) + (_.arithmetic_shift/2 (_.remainder/2 (_.int +64) paramO) subjectO)) -(def: (i64::arithmetic-right-shift [subjectO paramO]) +(def: (i64::arithmetic_right_shift [subjectO paramO]) Binary - (_.arithmetic-shift/2 (|> paramO (_.remainder/2 (_.int +64)) (_.*/2 (_.int -1))) + (_.arithmetic_shift/2 (|> paramO (_.remainder/2 (_.int +64)) (_.*/2 (_.int -1))) subjectO)) -(def: (i64::logical-right-shift [subjectO paramO]) +(def: (i64::logical_right_shift [subjectO paramO]) Binary - (///runtime.i64//logical-right-shift (_.remainder/2 (_.int +64) paramO) subjectO)) + (///runtime.i64//logical_right_shift (_.remainder/2 (_.int +64) paramO) subjectO)) (template [<name> <op>] [(def: (<name> [subjectO paramO]) @@ -147,9 +147,9 @@ (bundle.install "and" (binary i64::and)) (bundle.install "or" (binary i64::or)) (bundle.install "xor" (binary i64::xor)) - (bundle.install "left-shift" (binary i64::left-shift)) - (bundle.install "logical-right-shift" (binary i64::logical-right-shift)) - (bundle.install "arithmetic-right-shift" (binary i64::arithmetic-right-shift)) + (bundle.install "left-shift" (binary i64::left_shift)) + (bundle.install "logical-right-shift" (binary i64::logical_right_shift)) + (bundle.install "arithmetic-right-shift" (binary i64::arithmetic_right_shift)) (bundle.install "+" (binary i64::+)) (bundle.install "-" (binary i64::-)) (bundle.install "*" (binary i64::*)) @@ -177,7 +177,7 @@ (def: (text::char [subjectO paramO]) Binary - (_.string/1 (_.string-ref/2 subjectO paramO))) + (_.string/1 (_.string_ref/2 subjectO paramO))) (def: (text::clip [subjectO startO endO]) Trinary @@ -189,8 +189,8 @@ (|> bundle.empty (bundle.install "=" (binary text::=)) (bundle.install "<" (binary text::<)) - (bundle.install "concat" (binary (product.uncurry _.string-append/2))) - (bundle.install "size" (unary _.string-length/1)) + (bundle.install "concat" (binary (product.uncurry _.string_append/2))) + (bundle.install "size" (unary _.string_length/1)) (bundle.install "char" (binary text::char)) (bundle.install "clip" (trinary text::clip))))) @@ -210,7 +210,7 @@ (bundle.install "log" (unary (|>> io::log ..void))) (bundle.install "error" (unary _.raise/1)) (bundle.install "exit" (unary _.exit/1)) - (bundle.install "current-time" (nullary (function (_ _) (///runtime.io//current-time (_.string //////synthesis.unit)))))))) + (bundle.install "current-time" (nullary (function (_ _) (///runtime.io//current_time (_.string //////synthesis.unit)))))))) (def: #export bundle Bundle 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 dbf2c47b9..dd19db665 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 @@ -44,7 +44,7 @@ (-> (List Expression) Computation (Operation Computation)) (///////phase\in (case inits - #.Nil + #.End function_definition _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux index 3010bf016..25b0feb46 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux @@ -40,7 +40,7 @@ (Generator (Scope Synthesis)) (case initsS+ ## function/false/non-independent loop - #.Nil + #.End (expression archive bodyS) ## true loop 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 de05f8c6e..140b72106 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 @@ -115,10 +115,10 @@ (list (_.define_constant last_index_right (..last_index tuple)) (_.if (_.>/2 lefts last_index_right) ## No need for recursion - (_.vector-ref/2 tuple lefts) + (_.vector_ref/2 tuple lefts) ## Needs recursion (tuple//left (_.-/2 last_index_right lefts) - (_.vector-ref/2 tuple last_index_right))))))) + (_.vector_ref/2 tuple last_index_right))))))) (runtime: (tuple//right lefts tuple) (with_vars [last_index_right right_index @slice] @@ -126,14 +126,14 @@ (list (_.define_constant last_index_right (..last_index tuple)) (_.define_constant right_index (_.+/2 (_.int +1) lefts)) (<| (_.if (_.=/2 last_index_right right_index) - (_.vector-ref/2 tuple right_index)) + (_.vector_ref/2 tuple right_index)) (_.if (_.>/2 last_index_right right_index) ## Needs recursion. (tuple//right (_.-/2 last_index_right lefts) - (_.vector-ref/2 tuple last_index_right))) + (_.vector_ref/2 tuple last_index_right))) (_.begin - (list (_.define_constant @slice (_.make-vector/1 (_.-/2 right_index (_.length/1 tuple)))) - (_.vector-copy!/5 @slice (_.int +0) tuple right_index (_.length/1 tuple)) + (list (_.define_constant @slice (_.make_vector/1 (_.-/2 right_index (_.length/1 tuple)))) + (_.vector_copy!/5 @slice (_.int +0) tuple right_index (_.length/1 tuple)) @slice)))) ))) @@ -267,7 +267,7 @@ (runtime: (i64//left_shift param subject) (|> subject - (_.arithmetic-shift/2 (_.remainder/2 (_.int +64) param)) + (_.arithmetic_shift/2 (_.remainder/2 (_.int +64) param)) ..i64//64)) (def: as_nat @@ -279,15 +279,15 @@ subject (|> subject ..as_nat - (_.arithmetic-shift/2 (_.-/2 shift (_.int +0))))))) + (_.arithmetic_shift/2 (_.-/2 shift (_.int +0))))))) (template [<runtime> <host>] [(runtime: (<runtime> left right) (..i64//64 (<host> (..as_nat left) (..as_nat right))))] - [i64//or _.bitwise-ior/2] - [i64//xor _.bitwise-xor/2] - [i64//and _.bitwise-and/2] + [i64//or _.bitwise_ior/2] + [i64//xor _.bitwise_xor/2] + [i64//and _.bitwise_and/2] ) (runtime: (i64//division param subject) @@ -319,7 +319,7 @@ (runtime: (text//index offset sub text) (with_vars [index] - (_.let (list [index (_.string-contains/3 text sub offset)]) + (_.let (list [index (_.string_contains/3 text sub offset)]) (_.if index (..some index) ..none)))) @@ -328,7 +328,7 @@ (_.substring/3 text offset (_.+/2 offset length))) (runtime: (text//char index text) - (_.char->integer/1 (_.string-ref/2 text index))) + (_.char->integer/1 (_.string_ref/2 text index))) (def: runtime//text (_.begin (list @text//index @@ -336,7 +336,7 @@ @text//char))) (runtime: (array//write idx value array) - (_.begin (list (_.vector-set!/3 array idx value) + (_.begin (list (_.vector_set!/3 array idx value) array))) (def: runtime//array 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 46237d2a2..3cf04831b 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 @@ -20,10 +20,10 @@ (def: #export (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.Nil + #.End (///////phase\in (//primitive.text /////synthesis.unit)) - (#.Cons singletonS #.Nil) + (#.Item singletonS #.End) (expression archive singletonS) _ 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 d004e97ef..dc22dc355 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 @@ -101,16 +101,16 @@ [[old_test (weave new_then old_then)] old_tail] [[old_test old_then] (case old_tail - #.Nil + #.End (list [new_test new_then]) - (#.Cons old_cons) - (#.Cons (weave_branch weave equivalence [new_test new_then] old_cons)))])) + (#.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\fold (..weave_branch weave equivalence) old_fork (#.Cons new_fork))) + (list\fold (..weave_branch weave equivalence) old_fork (#.Item new_fork))) (def: (weave new old) (-> Path Path Path) @@ -199,10 +199,10 @@ (#.Right (dec lefts)) (#.Left lefts)))] (case patterns - #.Nil + #.End <failure> - (#.Cons head tail) + (#.Item head tail) (case head (#///analysis.Simple #///analysis.Unit) <continue> @@ -214,7 +214,7 @@ (#///analysis.Complex (#///analysis.Tuple sub_patterns)) (case (get sub_patterns @selection) - #.Nil + #.End <continue> sub_members @@ -263,7 +263,7 @@ (def: #export (synthesize_get synthesize archive input patterns @member) (-> Phase Archive Synthesis (///analysis.Tuple ///analysis.Pattern) Register (Operation Synthesis)) (case (..get patterns @member) - #.Nil + #.End (..synthesize_case synthesize archive input (!get patterns @member)) path @@ -283,7 +283,7 @@ (..synthesize_masking synthesize^ archive inputS @variable @output) [[(#///analysis.Bind @variable) body] - #.Nil] + #.End] (..synthesize_let synthesize^ archive inputS @variable body) (^or (^ [[(///analysis.pattern/bit #1) then] @@ -356,7 +356,7 @@ (^or (#/.I64_Fork forks) (#/.F64_Fork forks) (#/.Text_Fork forks)) - (|> (#.Cons forks) + (|> (#.Item forks) (list\map product.right) (list\fold for_path path_storage)) @@ -384,7 +384,7 @@ (update@ #dependencies (set.add var) synthesis_storage) (^ (/.function/apply [functionS argsS])) - (list\fold for_synthesis synthesis_storage (#.Cons functionS argsS)) + (list\fold for_synthesis synthesis_storage (#.Item functionS argsS)) (^ (/.function/abstraction [environment arity bodyS])) (list\fold for_synthesis synthesis_storage environment) 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 074790e37..956c59cd6 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 @@ -197,16 +197,16 @@ (All [a] (-> (Optimization a) (Optimization (List a)))) (function (recur [redundancy values]) (case values - #.Nil + #.End (#try.Success [redundancy values]) - (#.Cons head tail) + (#.Item head tail) (do try.monad [[redundancy head] (optimization [redundancy head]) [redundancy tail] (recur [redundancy tail])] (in [redundancy - (#.Cons head tail)]))))) + (#.Item head tail)]))))) (template [<name>] [(exception: #export (<name> {register Register}) 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 e5329f36a..87be39c2a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -222,10 +222,10 @@ (-> (Parser Code) Location Offset Text (Either [Source Text] [Source Code])) (loop [source (: Source [(!forward 1 where) offset source_code]) - stack (: (List Code) #.Nil)] + stack (: (List Code) #.End)] (case (parse source) (#.Right [source' top]) - (recur source' (#.Cons top stack)) + (recur source' (#.Item top stack)) (#.Left [source' error]) (if (is? <close> error) @@ -244,11 +244,11 @@ (-> (Parser Code) Location Offset Text (Either [Source Text] [Source Code])) (loop [source (: Source [(!forward 1 where) offset source_code]) - stack (: (List [Code Code]) #.Nil)] + stack (: (List [Code Code]) #.End)] (case (parse source) (#.Right [sourceF field]) (!letE [sourceFV value] (parse sourceF) - (recur sourceFV (#.Cons [field value] stack))) + (recur sourceFV (#.Item [field value] stack))) (#.Left [source' error]) (if (is? ..close_record error) 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 cec608916..fdfebb72c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -275,8 +275,8 @@ ")") (^template [<tag> <format>] - [(<tag> cons) - (|> (#.Cons cons) + [(<tag> item) + (|> (#.Item item) (list\map (function (_ [test then]) (format (<format> test) " " (%path' %then then)))) (text.join_with " ") @@ -500,11 +500,11 @@ (\ (maybe.equivalence =) = reference_else sample_else)) (^template [<tag> <equivalence>] - [[(<tag> reference_cons) - (<tag> sample_cons)] + [[(<tag> reference_item) + (<tag> sample_item)] (\ (list.equivalence (product.equivalence <equivalence> =)) = - (#.Cons reference_cons) - (#.Cons sample_cons))]) + (#.Item reference_item) + (#.Item sample_item))]) ([#I64_Fork i64.equivalence] [#F64_Fork f.equivalence] [#Text_Fork text.equivalence]) @@ -552,11 +552,11 @@ (\ (maybe.hash (path'_hash super)) hash else)) (^template [<factor> <tag> <hash>] - [(<tag> cons) + [(<tag> item) (let [case_hash (product.hash <hash> (path'_hash super)) - cons_hash (product.hash case_hash (list.hash case_hash))] - (n.* <factor> (\ cons_hash hash cons)))]) + item_hash (product.hash case_hash (list.hash case_hash))] + (n.* <factor> (\ item_hash hash item)))]) ([11 #I64_Fork i64.hash] [13 #F64_Fork f.hash] [17 #Text_Fork text.hash]) 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 ee2e507e8..7290b74a5 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -223,7 +223,7 @@ output (: Output row.empty)] (let [[analysers synthesizers generators directives] bundles] (case input - (#.Cons [[artifact_id artifact_category] input']) + (#.Item [[artifact_id artifact_category] input']) (case (do ! [data (try.of_maybe (dictionary.get (format (%.nat artifact_id) extension) actual)) #let [context [module_id artifact_id] @@ -318,7 +318,7 @@ failure failure) - #.Nil + #.End (#try.Success [definitions bundles output]))))) content (document.read $.key document) definitions (monad.map ! (function (_ [def_name def_global]) 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 b7838a270..aae528bda 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux @@ -55,10 +55,10 @@ (-> (file.System Async) Module (List Context) Module Extension (Async (Try file.Path))) (case contexts - #.Nil + #.End (async\in (exception.except ..cannot_find_module [importer module])) - (#.Cons context contexts') + (#.Item context contexts') (let [path (format (..path fs context module) extension)] (do async.monad [? (\ fs file? path)] diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index 596272af0..6b16939e4 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -151,7 +151,7 @@ (^template [<tag>] [(<tag> old_env def) (case old_env - #.Nil + #.End (<tag> env def) _ @@ -224,10 +224,10 @@ (def: #export (applied params func) (-> (List Type) Type (Maybe Type)) (case params - #.Nil + #.End (#.Some func) - (#.Cons param params') + (#.Item param params') (case func (^template [<tag>] [(<tag> env body) @@ -295,13 +295,13 @@ [(def: #export (<name> types) (-> (List Type) Type) (case types - #.Nil + #.End <base> - (#.Cons type #.Nil) + (#.Item type #.End) type - (#.Cons type types') + (#.Item type types') (<ctor> type (<name> types'))))] [variant Nothing #.Sum] @@ -311,19 +311,19 @@ (def: #export (function inputs output) (-> (List Type) Type Type) (case inputs - #.Nil + #.End output - (#.Cons input inputs') + (#.Item input inputs') (#.Function input (function inputs' output)))) (def: #export (application params quant) (-> (List Type) Type Type) (case params - #.Nil + #.End quant - (#.Cons param params') + (#.Item param params') (application params' (#.Apply param quant)))) (template [<name> <tag>] diff --git a/stdlib/source/library/lux/type/abstract.lux b/stdlib/source/library/lux/type/abstract.lux index a918db8e5..f6b6b35ac 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))) - (#.Cons value stack)) + (#.Item value stack)) (def: pop (All [a] (-> (Stack a) (Maybe (Stack a)))) @@ -42,17 +42,17 @@ (def: frames (Stack Frame) - #.Nil) + #.End) (template: (!peek <source> <reference> <then>) (loop [entries <source>] (case entries - (#.Cons [head_name head] tail) + (#.Item [head_name head] tail) (if (text\= <reference> head_name) <then> (recur tail)) - #.Nil + #.End (undefined)))) (def: (peek_frames_definition reference source) @@ -102,14 +102,14 @@ (template: (!push <source> <reference> <then>) (loop [entries <source>] (case entries - (#.Cons [head_name head] tail) + (#.Item [head_name head] tail) (if (text\= <reference> head_name) - (#.Cons [head_name <then>] + (#.Item [head_name <then>] tail) - (#.Cons [head_name head] + (#.Item [head_name head] (recur tail))) - #.Nil + #.End (undefined)))) (def: (push_frame_definition reference frame source) diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index fc3b31347..4e6bcdc3d 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -129,32 +129,32 @@ (def: (var::new id plist) (-> Var Type_Vars Type_Vars) - (#.Cons [id #.None] plist)) + (#.Item [id #.None] plist)) (def: (var::get id plist) (-> Var Type_Vars (Maybe (Maybe Type))) (case plist - (#.Cons [var_id var_type] + (#.Item [var_id var_type] plist') (if (!n\= id var_id) (#.Some var_type) (var::get id plist')) - #.Nil + #.End #.None)) (def: (var::put id value plist) (-> Var (Maybe Type) Type_Vars Type_Vars) (case plist - #.Nil + #.End (list [id value]) - (#.Cons [var_id var_type] + (#.Item [var_id var_type] plist') (if (!n\= id var_id) - (#.Cons [var_id value] + (#.Item [var_id value] plist') - (#.Cons [var_id var_type] + (#.Item [var_id var_type] (var::put id value plist'))))) (def: #export (run context proc) @@ -358,7 +358,7 @@ (def: (assume! assumption assumptions) (-> Assumption (List Assumption) (List Assumption)) - (#.Cons assumption assumptions)) + (#.Item assumption assumptions)) ## TODO: "if_bind" can be optimized... (def: (if_bind id type then else) @@ -625,10 +625,10 @@ e_params e_params a_params a_params] (case [e_params a_params] - [#.Nil #.Nil] + [#.End #.End] (check\in assumptions) - [(#.Cons e_head e_tail) (#.Cons 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)) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index 59b8288ed..f44509aaa 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -98,10 +98,10 @@ candidates (list.only (|>> product.right (text\= simple_name)) tag_lists)]] (case candidates - #.Nil + #.End (meta.failure (format "Unknown tag: " (%.name member))) - (#.Cons winner #.Nil) + (#.Item winner #.End) (in winner) _ @@ -123,7 +123,7 @@ (if (and (annotation.implementation? def_anns) (or (text\= target_module source_module) exported?)) - (#.Cons [[source_module name] def_type] aggregate) + (#.Item [[source_module name] def_type] aggregate) aggregate)) aggregate constants)) @@ -146,7 +146,7 @@ (do {! meta.monad} [this_module_name meta.current_module_name definitions (meta.definitions this_module_name)] - (in (prepare_definitions this_module_name this_module_name definitions #.Nil)))) + (in (prepare_definitions this_module_name this_module_name definitions #.End)))) (def: imported_structs (Meta (List [Name Type])) @@ -156,7 +156,7 @@ accessible_definitions (monad.map ! meta.definitions imported_modules)] (in (list\fold (function (_ [imported_module definitions] tail) (prepare_definitions imported_module this_module_name definitions tail)) - #.Nil + #.End (list.zipped/2 imported_modules accessible_definitions))))) (def: (apply_function_type func arg) @@ -186,7 +186,7 @@ (do check.monad [[id var] check.var [ids final_output] (concrete_type (maybe.assume (type.applied (list var) type)))] - (in [(#.Cons id ids) + (in [(#.Item id ids) final_output])) _ @@ -228,7 +228,7 @@ (#.Right =deps) (list [alt_name =deps])))) list\join) - #.Nil + #.End (meta.failure (format "No candidates for provisioning: " (%.type dep))) found @@ -246,10 +246,10 @@ (#.Right candidates) (case candidates - #.Nil + #.End (check.failure (format "No candidates for provisioning: " (%.type dep))) - (#.Cons winner #.Nil) + (#.Item winner #.End) (\ check.monad in winner) _ @@ -279,7 +279,7 @@ (#.Right =deps) (list [alt_name =deps])))) list\join) - #.Nil + #.End (meta.failure (format "No alternatives for " (%.type (type.function input_types output_type)))) found @@ -309,7 +309,7 @@ (def: (instance$ [constructor dependencies]) (-> Instance Code) (case dependencies - #.Nil + #.End (code.identifier constructor) _ @@ -350,10 +350,10 @@ output_type meta.expected_type chosen_ones (alternatives sig_type member_idx input_types output_type)] (case chosen_ones - #.Nil + #.End (meta.failure (format "No implementation could be found for member: " (%.name member))) - (#.Cons chosen #.Nil) + (#.Item chosen #.End) (in (list (` (\ (~ (instance$ chosen)) (~ (code.local_identifier (product.right member))) (~+ (list\map code.identifier args)))))) diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux index 1b9d94381..f2709d5e2 100644 --- a/stdlib/source/library/lux/type/refinement.lux +++ b/stdlib/source/library/lux/type/refinement.lux @@ -52,13 +52,13 @@ (def: #export (only refiner values) (All [t %] (-> (Refiner t %) (List t) (List (Refined t %)))) (case values - #.Nil - #.Nil + #.End + #.End - (#.Cons head tail) + (#.Item head tail) (case (refiner head) (#.Some refined) - (#.Cons refined (only refiner tail)) + (#.Item refined (only refiner tail)) #.None (only refiner tail)))) @@ -66,19 +66,19 @@ (def: #export (partition refiner values) (All [t %] (-> (Refiner t %) (List t) [(List (Refined t %)) (List t)])) (case values - #.Nil - [#.Nil #.Nil] + #.End + [#.End #.End] - (#.Cons head tail) + (#.Item head tail) (let [[yes no] (partition refiner tail)] (case (refiner head) (#.Some refined) - [(#.Cons refined yes) + [(#.Item refined yes) no] #.None [yes - (#.Cons head no)])))) + (#.Item head no)])))) (syntax: #export (type refiner) (macro.with_gensyms [g!t g!%] diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux index dc321578e..d0cee7d42 100644 --- a/stdlib/source/library/lux/type/resource.lux +++ b/stdlib/source/library/lux/type/resource.lux @@ -157,10 +157,10 @@ [(syntax: #export (<name> {swaps ..indices}) (macro.with_gensyms [g!_ g!context] (case swaps - #.Nil + #.End (in (list (` ((~! no_op) <monad>)))) - (#.Cons head tail) + (#.Item head tail) (do {! meta.monad} [#let [max_idx (list\fold n.max head tail)] g!inputs (<| (monad.seq !) (list.repeat (inc max_idx)) (macro.gensym "input")) diff --git a/stdlib/source/library/lux/world/db/jdbc.lux b/stdlib/source/library/lux/world/db/jdbc.lux index ccc9d91af..0d1112282 100644 --- a/stdlib/source/library/lux/world/db/jdbc.lux +++ b/stdlib/source/library/lux/world/db/jdbc.lux @@ -66,27 +66,27 @@ [(capability: #export (<name> ! i) (<forge> (Statement i) (! (Try <output>))))] - [Can-Execute can-execute Nat] - [Can-Insert can-insert (List ID)] + [Can_Execute can_execute Nat] + [Can_Insert can_insert (List ID)] ) -(capability: #export (Can-Query ! i o) - (can-query [(Statement i) (Output o)] (! (Try (List o))))) +(capability: #export (Can_Query ! i o) + (can_query [(Statement i) (Output o)] (! (Try (List o))))) -(capability: #export (Can-Close !) - (can-close Any (! (Try Any)))) +(capability: #export (Can_Close !) + (can_close Any (! (Try Any)))) (interface: #export (DB !) - (: (Can-Execute !) + (: (Can_Execute !) execute) - (: (Can-Insert !) + (: (Can_Insert !) insert) - (: (Can-Query !) + (: (Can_Query !) query) - (: (Can-Close !) + (: (Can_Close !) close)) -(def: (with-statement statement conn action) +(def: (with_statement statement conn action) (All [i a] (-> (Statement i) java/sql/Connection (-> java/sql/PreparedStatement (IO (Try a))) @@ -106,10 +106,10 @@ (~~ (template [<name> <forge>] [(def: <name> (<forge> (|>> (!.use (\ db <name>)) async.future)))] - [execute can-execute] - [insert can-insert] - [close can-close] - [query can-query]))))) + [execute can_execute] + [insert can_insert] + [close can_close] + [query can_query]))))) (def: #export (connect creds) (-> Credentials (IO (Try (DB IO)))) @@ -120,40 +120,40 @@ (in (: (DB IO) (implementation (def: execute - (..can-execute + (..can_execute (function (execute statement) - (with-statement statement connection + (with_statement statement connection (function (_ prepared) (do (try.with io.monad) - [row-count (java/sql/PreparedStatement::executeUpdate prepared)] - (in (.nat row-count)))))))) + [row_count (java/sql/PreparedStatement::executeUpdate prepared)] + (in (.nat row_count)))))))) (def: insert - (..can-insert + (..can_insert (function (insert statement) - (with-statement statement connection + (with_statement statement connection (function (_ prepared) (do (try.with io.monad) [_ (java/sql/PreparedStatement::executeUpdate prepared) - result-set (io.io (java/sql/Statement::getGeneratedKeys prepared))] - (/output.rows /output.long result-set))))))) + result_set (io.io (java/sql/Statement::getGeneratedKeys prepared))] + (/output.rows /output.long result_set))))))) (def: close - (..can-close + (..can_close (function (close _) (java/sql/Connection::close connection)))) (def: query - (..can-query + (..can_query (function (query [statement output]) - (with-statement statement connection + (with_statement statement connection (function (_ prepared) (do (try.with io.monad) - [result-set (java/sql/PreparedStatement::executeQuery prepared)] - (/output.rows output result-set))))))) + [result_set (java/sql/PreparedStatement::executeQuery prepared)] + (/output.rows output result_set))))))) ))))) -(def: #export (with-db creds action) +(def: #export (with_db creds action) (All [a] (-> Credentials (-> (DB IO) (IO (Try a))) @@ -164,7 +164,7 @@ _ (!.use (\ db close) [])] (in result))) -(def: #export (with-async-db creds action) +(def: #export (with_async_db creds action) (All [a] (-> Credentials (-> (DB Async) (Async (Try a))) diff --git a/stdlib/source/library/lux/world/db/jdbc/input.lux b/stdlib/source/library/lux/world/db/jdbc/input.lux index 7388e1334..10cf48c86 100644 --- a/stdlib/source/library/lux/world/db/jdbc/input.lux +++ b/stdlib/source/library/lux/world/db/jdbc/input.lux @@ -97,11 +97,11 @@ (function (_ value [idx statement]) (do try.monad [_ (<setter> (.int idx) - (<constructor> (instant.to-millis value)) + (<constructor> (instant.to_millis value)) statement)] (in [(.inc idx) statement]))))] [date java/sql/PreparedStatement::setDate java/sql/Date::new] [time java/sql/PreparedStatement::setTime java/sql/Time::new] - [time-stamp java/sql/PreparedStatement::setTimestamp java/sql/Timestamp::new] + [time_stamp java/sql/PreparedStatement::setTimestamp java/sql/Timestamp::new] ) diff --git a/stdlib/source/library/lux/world/db/jdbc/output.lux b/stdlib/source/library/lux/world/db/jdbc/output.lux index 4ddc8ea2d..29f1d86a5 100644 --- a/stdlib/source/library/lux/world/db/jdbc/output.lux +++ b/stdlib/source/library/lux/world/db/jdbc/output.lux @@ -24,8 +24,8 @@ (import: java/sql/Timestamp) (`` (import: java/sql/ResultSet - (~~ (template [<method-name> <return-class>] - [(<method-name> [int] #try <return-class>)] + (~~ (template [<method_name> <return_class>] + [(<method_name> [int] #try <return_class>)] [getBoolean boolean] @@ -101,7 +101,7 @@ (def: #export (fail error) (All [a] (-> Text (Output a))) - (function (_ [idx result-set]) + (function (_ [idx result_set]) (#try.Failure error))) (def: #export (and left right) @@ -112,11 +112,11 @@ =right right] (in [=left =right]))) -(template [<func-name> <method-name> <type>] - [(def: #export <func-name> +(template [<func_name> <method_name> <type>] + [(def: #export <func_name> (Output <type>) - (function (_ [idx result-set]) - (case (<method-name> [(.int idx)] result-set) + (function (_ [idx result_set]) + (case (<method_name> [(.int idx)] result_set) (#try.Failure error) (#try.Failure error) @@ -137,35 +137,35 @@ [bytes java/sql/ResultSet::getBytes Binary] ) -(template [<func-name> <method-name>] - [(def: #export <func-name> +(template [<func_name> <method_name>] + [(def: #export <func_name> (Output Instant) - (function (_ [idx result-set]) - (case (<method-name> [(.int idx)] result-set) + (function (_ [idx result_set]) + (case (<method_name> [(.int idx)] result_set) (#try.Failure error) (#try.Failure error) (#try.Success value) (#try.Success [(inc idx) - (instant.from-millis (java/util/Date::getTime value))]))))] + (instant.from_millis (java/util/Date::getTime value))]))))] [date java/sql/ResultSet::getDate] [time java/sql/ResultSet::getTime] - [time-stamp java/sql/ResultSet::getTimestamp] + [time_stamp java/sql/ResultSet::getTimestamp] ) (def: #export (rows output results) (All [a] (-> (Output a) java/sql/ResultSet (IO (Try (List a))))) (case (java/sql/ResultSet::next results) - (#try.Success has-next?) - (if has-next? + (#try.Success has_next?) + (if has_next? (case (output [1 results]) (#.Some [_ head]) (do io.monad [?tail (rows output results)] (case ?tail (#try.Success tail) - (in (ex.return (#.Cons head tail))) + (in (ex.return (#.Item head tail))) (#try.Failure error) (do io.monad diff --git a/stdlib/source/library/lux/world/db/sql.lux b/stdlib/source/library/lux/world/db/sql.lux index 99f3f027d..93cd86b48 100644 --- a/stdlib/source/library/lux/world/db/sql.lux +++ b/stdlib/source/library/lux/world/db/sql.lux @@ -210,7 +210,7 @@ (format <op> " " (case columns - #.Nil + #.End "*" _ @@ -288,7 +288,7 @@ (Query where having No-Order group limit offset) (Query where having With-Order group limit offset))) (case pairs - #.Nil + #.End (|> query :representation :abstraction) _ @@ -306,7 +306,7 @@ (Query where having order No-Group limit offset) (Query where having order With-Group limit offset))) (case pairs - #.Nil + #.End (|> query :representation :abstraction) _ @@ -331,7 +331,7 @@ (-> Table (List [Column Value]) (Command No-Where No-Having)) (:abstraction (format "UPDATE " (:representation table) (case pairs - #.Nil + #.End "" _ diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index f66458f87..962636aa9 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -726,14 +726,14 @@ output (: (List ..Path) (list))] (case input - #.Nil + #.End (in output) - (#.Cons head tail) + (#.Item head tail) (do ! [verdict (<test> head)] (recur tail (if verdict - (#.Cons head output) + (#.Item head output) output))))) _ (RubyDir::close [] self)] (in output)))] @@ -921,14 +921,14 @@ ## output (: (List (<capability> IO)) ## (list))] ## (case input - ## #.Nil + ## #.End ## (in output) - ## (#.Cons head tail) + ## (#.Item head tail) ## (do ! ## [verdict (<test> head)] ## (if verdict - ## (recur tail (#.Cons (<constructor> head) output)) + ## (recur tail (#.Item (<constructor> head) output)) ## (recur tail output)))))))] ## [files ..is_file ..file File] @@ -1007,23 +1007,23 @@ (loop [directory mock trail (text.split_all_with separator path)] (case trail - (#.Cons head tail) + (#.Item head tail) (case (dictionary.get head directory) #.None (exception.except ..cannot_find_file [path]) (#.Some node) (case [node tail] - [(#.Left file) #.Nil] + [(#.Left file) #.End] (#try.Success [head file]) - [(#.Right sub_directory) (#.Cons _)] + [(#.Right sub_directory) (#.Item _)] (recur sub_directory tail) _ (exception.except ..cannot_find_file [path]))) - #.Nil + #.End (exception.except ..cannot_find_file [path])))) (def: (update_mock_file! / path now content mock) @@ -1031,30 +1031,30 @@ (loop [directory mock trail (text.split_all_with / path)] (case trail - (#.Cons head tail) + (#.Item head tail) (case (dictionary.get head directory) #.None (case tail - #.Nil + #.End (#try.Success (dictionary.put head (#.Left {#mock_last_modified now #mock_can_execute false #mock_content content}) directory)) - (#.Cons _) + (#.Item _) (exception.except ..cannot_find_file [path])) (#.Some node) (case [node tail] - [(#.Left file) #.Nil] + [(#.Left file) #.End] (#try.Success (dictionary.put head (#.Left (|> file (set@ #mock_last_modified now) (set@ #mock_content content))) directory)) - [(#.Right sub_directory) (#.Cons _)] + [(#.Right sub_directory) (#.Item _)] (do try.monad [sub_directory (recur sub_directory tail)] (in (dictionary.put head (#.Right sub_directory) directory))) @@ -1062,7 +1062,7 @@ _ (exception.except ..cannot_find_file [path]))) - #.Nil + #.End (exception.except ..cannot_find_file [path])))) (def: (mock_delete! / path mock) @@ -1070,14 +1070,14 @@ (loop [directory mock trail (text.split_all_with / path)] (case trail - (#.Cons head tail) + (#.Item head tail) (case (dictionary.get head directory) #.None (exception.except ..cannot_delete [path]) (#.Some node) (case tail - #.Nil + #.End (case node (#.Left file) (#try.Success (dictionary.remove head directory)) @@ -1087,7 +1087,7 @@ (#try.Success (dictionary.remove head directory)) (exception.except ..cannot_delete [path]))) - (#.Cons _) + (#.Item _) (case node (#.Left file) (exception.except ..cannot_delete [path]) @@ -1097,7 +1097,7 @@ [sub_directory' (recur sub_directory tail)] (in (dictionary.put head (#.Right sub_directory') directory)))))) - #.Nil + #.End (exception.except ..cannot_delete [path])))) (def: (try_update! transform var) @@ -1118,19 +1118,19 @@ (loop [directory mock trail (text.split_all_with / path)] (case trail - (#.Cons head tail) + (#.Item head tail) (case (dictionary.get head directory) #.None (case tail - #.Nil + #.End (#try.Success (dictionary.put head (#.Right ..empty_mock) directory)) - (#.Cons _) + (#.Item _) (exception.except ..cannot_make_directory [path])) (#.Some node) (case [node tail] - [(#.Right sub_directory) (#.Cons _)] + [(#.Right sub_directory) (#.Item _)] (do try.monad [sub_directory (recur sub_directory tail)] (in (dictionary.put head (#.Right sub_directory) directory))) @@ -1138,7 +1138,7 @@ _ (exception.except ..cannot_make_directory [path]))) - #.Nil + #.End (exception.except ..cannot_make_directory [path])))) (def: (retrieve_mock_directory! / path mock) @@ -1146,10 +1146,10 @@ (loop [directory mock trail (text.split_all_with / path)] (case trail - #.Nil + #.End (#try.Success directory) - (#.Cons head tail) + (#.Item head tail) (case (dictionary.get head directory) #.None (exception.except ..cannot_find_directory [path]) @@ -1161,10 +1161,10 @@ (#.Right sub_directory) (case tail - #.Nil + #.End (#try.Success sub_directory) - (#.Cons _) + (#.Item _) (recur sub_directory tail))))))) (def: #export (mock separator) @@ -1322,10 +1322,10 @@ (case (if rooted? (list.drop 1 segments) segments) - #.Nil + #.End (\ monad in (exception.except ..cannot_make_directory [path])) - (#.Cons head tail) + (#.Item head tail) (case head "" (\ monad in (exception.except ..cannot_make_directory [path])) _ (loop [current (if rooted? @@ -1337,10 +1337,10 @@ (case ? (#try.Success _) (case next - #.Nil + #.End (in (#try.Success [])) - (#.Cons head tail) + (#.Item head tail) (recur (format current (\ fs separator) head) tail)) diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index daa1380a4..eea669a47 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -273,10 +273,10 @@ (All [a] (-> (java/util/List a) (List a))) (let [size (.nat (java/util/List::size list))] (loop [idx 0 - output #.Nil] + output #.End] (if (n.< size idx) (recur (inc idx) - (#.Cons (java/util/List::get (.int idx) list) + (#.Item (java/util/List::get (.int idx) list) output)) output)))) @@ -384,7 +384,7 @@ java/nio/file/Path::toString (:as //.Path))] concern (..default_key_concern key)] - (recur (#.Cons [concern path] + (recur (#.Item [concern path] output))) (recur output))) diff --git a/stdlib/source/library/lux/world/net/http/header.lux b/stdlib/source/library/lux/world/net/http/header.lux index e5b1882ad..1d84b3318 100644 --- a/stdlib/source/library/lux/world/net/http/header.lux +++ b/stdlib/source/library/lux/world/net/http/header.lux @@ -22,11 +22,11 @@ previous (format previous "," value))))) -(def: #export content-length +(def: #export content_length (-> Nat Header) (|>> %.nat (..add "Content-Length"))) -(def: #export content-type +(def: #export content_type (-> MIME Header) (|>> mime.name (..add "Content-Type"))) diff --git a/stdlib/source/library/lux/world/net/http/mime.lux b/stdlib/source/library/lux/world/net/http/mime.lux index 859b0840e..445796038 100644 --- a/stdlib/source/library/lux/world/net/http/mime.lux +++ b/stdlib/source/library/lux/world/net/http/mime.lux @@ -26,20 +26,20 @@ (template [<name> <type>] [(def: #export <name> MIME (..mime <type>))] - [aac-audio "audio/aac"] + [aac_audio "audio/aac"] [abiword "application/x-abiword"] [avi "video/x-msvideo"] - [amazon-kindle-ebook "application/vnd.amazon.ebook"] + [amazon_kindle_ebook "application/vnd.amazon.ebook"] [binary "application/octet-stream"] [bitmap "image/bmp"] [bzip "application/x-bzip"] [bzip2 "application/x-bzip2"] - [c-shell "application/x-csh"] + [c_shell "application/x-csh"] [css "text/css"] [csv "text/csv"] - [microsoft-word "application/msword"] - [microsoft-word-openxml "application/vnd.openxmlformats-officedocument.wordprocessingml.document"] - [ms-embedded-opentype-fonts "application/vnd.ms-fontobject"] + [microsoft_word "application/msword"] + [microsoft_word_openxml "application/vnd.openxmlformats-officedocument.wordprocessingml.document"] + [ms_embedded_opentype_fonts "application/vnd.ms-fontobject"] [epub "application/epub+zip"] [ecmascript "application/ecmascript"] [gif "image/gif"] @@ -52,49 +52,51 @@ [json "application/json"] [midi "audio/midi"] [mpeg "video/mpeg"] - [apple-installer-package "application/vnd.apple.installer+xml"] - [opendocument-presentation "application/vnd.oasis.opendocument.presentation"] - [opendocument-spreadsheet "application/vnd.oasis.opendocument.spreadsheet"] - [opendocument-text "application/vnd.oasis.opendocument.text"] - [ogg-audio "audio/ogg"] - [ogg-video "video/ogg"] + [apple_installer_package "application/vnd.apple.installer+xml"] + [opendocument_presentation "application/vnd.oasis.opendocument.presentation"] + [opendocument_spreadsheet "application/vnd.oasis.opendocument.spreadsheet"] + [opendocument_text "application/vnd.oasis.opendocument.text"] + [ogg_audio "audio/ogg"] + [ogg_video "video/ogg"] [ogg "application/ogg"] - [opentype-font "font/otf"] + [opentype_font "font/otf"] [png "image/png"] [pdf "application/pdf"] - [microsoft-powerpoint "application/vnd.ms-powerpoint"] - [microsoft-powerpoint-openxml "application/vnd.openxmlformats-officedocument.presentationml.presentation"] + [microsoft_powerpoint "application/vnd.ms-powerpoint"] + [microsoft_powerpoint_openxml "application/vnd.openxmlformats-officedocument.presentationml.presentation"] [rar "application/x-rar-compressed"] [rtf "application/rtf"] - [bourne-shell "application/x-sh"] + [bourne_shell "application/x-sh"] [svg "image/svg+xml"] [flash "application/x-shockwave-flash"] [tar "application/x-tar"] [tiff "image/tiff"] [typescript "application/typescript"] - [truetype-font "font/ttf"] - [microsoft-visio "application/vnd.visio"] + [truetype_font "font/ttf"] + [microsoft_visio "application/vnd.visio"] [wav "audio/wav"] - [webm-audio "audio/webm"] - [webm-video "video/webm"] + [webm_audio "audio/webm"] + [webm_video "video/webm"] [webp "image/webp"] [woff "font/woff"] [woff2 "font/woff2"] [xhtml "application/xhtml+xml"] - [microsoft-excel "application/vnd.ms-excel"] - [microsoft-excel-openxml "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"] + [microsoft_excel "application/vnd.ms-excel"] + [microsoft_excel_openxml "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"] [xml "application/xml"] [xul "application/vnd.mozilla.xul+xml"] [zip "application/zip"] - [!3gpp-audio "audio/3gpp"] + [!3gpp_audio "audio/3gpp"] [!3gpp "video/3gpp"] - [!3gpp2-audio "audio/3gpp2"] + [!3gpp2_audio "audio/3gpp2"] [!3gpp2 "video/3gpp2"] [!7z "application/x-7z-compressed"] ) (def: #export (text encoding) (-> Encoding MIME) - (..mime (format "text/plain; charset=" text.double-quote (encoding.name encoding) text.double-quote))) + (..mime (format "text/plain; charset=" text.double_quote (encoding.name encoding) text.double_quote))) -(def: #export utf-8 MIME (..text encoding.utf-8)) +(def: #export utf_8 + MIME + (..text encoding.utf_8)) diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index 2c08a7cca..a65f5b2c0 100644 --- a/stdlib/source/library/lux/world/net/http/request.lux +++ b/stdlib/source/library/lux/world/net/http/request.lux @@ -44,19 +44,19 @@ inputs))] output)) -(def: (read-text-body body) +(def: (read_text_body body) (-> Body (Async (Try Text))) (do async.monad [blobs (frp.consume body)] (in (\ encoding.utf8 decode (merge blobs))))) -(def: failure (//response.bad-request "")) +(def: failure (//response.bad_request "")) (def: #export (json reader server) (All [a] (-> (<json>.Reader a) (-> a Server) Server)) (function (_ (^@ request [identification protocol resource message])) (do async.monad - [?raw (read-text-body (get@ #//.body message))] + [?raw (read_text_body (get@ #//.body message))] (case (do try.monad [raw ?raw content (\ json.codec decode raw)] @@ -71,7 +71,7 @@ (-> (-> Text Server) Server) (function (_ (^@ request [identification protocol resource message])) (do async.monad - [?raw (read-text-body (get@ #//.body message))] + [?raw (read_text_body (get@ #//.body message))] (case ?raw (#try.Success content) (server content request) @@ -84,7 +84,7 @@ (function (_ [identification protocol resource message]) (let [full (get@ #//.uri resource) [uri query] (|> full - (text.split-with "?") + (text.split_with "?") (maybe.default [full ""]))] (case (do try.monad [query (//query.parameters query) @@ -101,7 +101,7 @@ (All [a] (-> (Property a) (-> a Server) Server)) (function (_ (^@ request [identification protocol resource message])) (do async.monad - [?body (read-text-body (get@ #//.body message))] + [?body (read_text_body (get@ #//.body message))] (case (do try.monad [body ?body form (//query.parameters body)] diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index e90307894..730a2001a 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -136,9 +136,9 @@ (def: (jvm\\consume iterator) (All [a] (-> (java/util/Iterator a) (List a))) (if (java/util/Iterator::hasNext iterator) - (#.Cons (java/util/Iterator::next iterator) + (#.Item (java/util/Iterator::next iterator) (jvm\\consume iterator)) - #.Nil)) + #.End)) )] (for {@.old (as_is <jvm>) @.jvm (as_is <jvm>) |