diff options
Diffstat (limited to '')
300 files changed, 3111 insertions, 2849 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index ec1eac721..5e27a94c4 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -23,8 +23,8 @@ [dummy_location (9 #1 (0 #0))] #1) -## (type: .public Any -## (Ex [a] a)) +... (type: .public Any +... (Ex [a] a)) ("lux def" Any ("lux type check type" (9 #1 ["library/lux" "Any"] @@ -37,8 +37,8 @@ (0 #0)))] #1) -## (type: .public Nothing -## (All [a] a)) +... (type: .public Nothing +... (All [a] a)) ("lux def" Nothing ("lux type check type" (9 #1 ["library/lux" "Nothing"] @@ -51,15 +51,15 @@ (0 #0)))] #1) -## (type: .public (List a) -## #End -## (#Item a (List a))) +... (type: .public (List a) +... #End +... (#Item a (List a))) ("lux def type tagged" List (9 #1 ["library/lux" "List"] (7 #0 (0 #0) - (1 #0 ## "lux.End" + (1 #0 ... "lux.End" Any - ## "lux.Item" + ... "lux.Item" (2 #0 (4 #0 1) (9 #0 (4 #0 1) (4 #0 0)))))) [dummy_location @@ -156,15 +156,15 @@ #End))] #1) -## (type: .public (Maybe a) -## #None -## (#Some a)) +... (type: .public (Maybe a) +... #None +... (#Some a)) ("lux def type tagged" Maybe (9 #1 ["library/lux" "Maybe"] (7 #0 #End - (1 #0 ## "lux.None" + (1 #0 ... "lux.None" Any - ## "lux.Some" + ... "lux.Some" (4 #0 1)))) [dummy_location (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type_args"])] @@ -175,19 +175,19 @@ ["None" "Some"] #1) -## (type: .public #rec Type -## (#Primitive Text (List Type)) -## (#Sum Type Type) -## (#Product Type Type) -## (#Function Type Type) -## (#Parameter Nat) -## (#Var Nat) -## (#Ex Nat) -## (#UnivQ (List Type) Type) -## (#ExQ (List Type) Type) -## (#Apply Type Type) -## (#Named Name Type) -## ) +... (type: .public #rec Type +... (#Primitive Text (List Type)) +... (#Sum Type Type) +... (#Product Type Type) +... (#Function Type Type) +... (#Parameter Nat) +... (#Var Nat) +... (#Ex Nat) +... (#UnivQ (List Type) Type) +... (#ExQ (List Type) Type) +... (#Apply Type Type) +... (#Named Name Type) +... ) ("lux def type tagged" Type (9 #1 ["library/lux" "Type"] ({Type @@ -195,27 +195,27 @@ ({Type_Pair (9 #0 Nothing (7 #0 #End - (1 #0 ## "lux.Primitive" + (1 #0 ... "lux.Primitive" (2 #0 Text Type_List) - (1 #0 ## "lux.Sum" + (1 #0 ... "lux.Sum" Type_Pair - (1 #0 ## "lux.Product" + (1 #0 ... "lux.Product" Type_Pair - (1 #0 ## "lux.Function" + (1 #0 ... "lux.Function" Type_Pair - (1 #0 ## "lux.Parameter" + (1 #0 ... "lux.Parameter" Nat - (1 #0 ## "lux.Var" + (1 #0 ... "lux.Var" Nat - (1 #0 ## "lux.Ex" + (1 #0 ... "lux.Ex" Nat - (1 #0 ## "lux.UnivQ" + (1 #0 ... "lux.UnivQ" (2 #0 Type_List Type) - (1 #0 ## "lux.ExQ" + (1 #0 ... "lux.ExQ" (2 #0 Type_List Type) - (1 #0 ## "lux.Apply" + (1 #0 ... "lux.Apply" Type_Pair - ## "lux.Named" + ... "lux.Named" (2 #0 Name Type)))))))))))))} ("lux type check type" (2 #0 Type Type)))} ("lux type check type" (9 #0 Type List)))} @@ -229,10 +229,10 @@ ["Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"] #1) -## (type: .public Location -## {#module Text -## #line Nat -## #column Nat}) +... (type: .public Location +... {#module Text +... #line Nat +... #column Nat}) ("lux def type tagged" Location (#Named ["library/lux" "Location"] (#Product Text (#Product Nat Nat))) @@ -243,9 +243,9 @@ ["module" "line" "column"] #1) -## (type: .public (Ann m v) -## {#meta m -## #datum v}) +... (type: .public (Ann m v) +... {#meta m +... #datum v}) ("lux def type tagged" Ann (#Named ["library/lux" "Ann"] (#UnivQ #End @@ -261,44 +261,44 @@ ["meta" "datum"] #1) -## (type: .public (Code' w) -## (#Bit Bit) -## (#Nat Nat) -## (#Int Int) -## (#Rev Rev) -## (#Frac Frac) -## (#Text Text) -## (#Identifier Name) -## (#Tag Name) -## (#Form (List (w (Code' w)))) -## (#Tuple (List (w (Code' w)))) -## (#Record (List [(w (Code' w)) (w (Code' w))]))) +... (type: .public (Code' w) +... (#Bit Bit) +... (#Nat Nat) +... (#Int Int) +... (#Rev Rev) +... (#Frac Frac) +... (#Text Text) +... (#Identifier Name) +... (#Tag Name) +... (#Form (List (w (Code' w)))) +... (#Tuple (List (w (Code' w)))) +... (#Record (List [(w (Code' w)) (w (Code' w))]))) ("lux def type tagged" Code' (#Named ["library/lux" "Code'"] ({Code ({Code_List (#UnivQ #End - (#Sum ## "lux.Bit" + (#Sum ... "lux.Bit" Bit - (#Sum ## "lux.Nat" + (#Sum ... "lux.Nat" Nat - (#Sum ## "lux.Int" + (#Sum ... "lux.Int" Int - (#Sum ## "lux.Rev" + (#Sum ... "lux.Rev" Rev - (#Sum ## "lux.Frac" + (#Sum ... "lux.Frac" Frac - (#Sum ## "lux.Text" + (#Sum ... "lux.Text" Text - (#Sum ## "lux.Identifier" + (#Sum ... "lux.Identifier" Name - (#Sum ## "lux.Tag" + (#Sum ... "lux.Tag" Name - (#Sum ## "lux.Form" + (#Sum ... "lux.Form" Code_List - (#Sum ## "lux.Tuple" + (#Sum ... "lux.Tuple" Code_List - ## "lux.Record" + ... "lux.Record" (#Apply (#Product Code Code) List) )))))))))) )} @@ -313,8 +313,8 @@ ["Bit" "Nat" "Int" "Rev" "Frac" "Text" "Identifier" "Tag" "Form" "Tuple" "Record"] #1) -## (type: .public Code -## (Ann Location (Code' (Ann Location)))) +... (type: .public Code +... (Ann Location (Code' (Ann Location)))) ("lux def" Code (#Named ["library/lux" "Code"] ({w @@ -446,8 +446,8 @@ [dummy_location (#Record #End)] #0) -## (type: .public Definition -## [Bit Type Code Any]) +... (type: .public Definition +... [Bit Type Code Any]) ("lux def" Definition ("lux type check type" (#Named ["library/lux" "Definition"] @@ -457,8 +457,8 @@ #End)) #1) -## (type: .public Alias -## Name) +... (type: .public Alias +... Name) ("lux def" Alias ("lux type check type" (#Named ["library/lux" "Alias"] @@ -466,9 +466,9 @@ (record$ #End) #1) -## (type: .public Global -## (#Alias Alias) -## (#Definition Definition)) +... (type: .public Global +... (#Alias Alias) +... (#Definition Definition)) ("lux def type tagged" Global (#Named ["library/lux" "Global"] (#Sum Alias @@ -479,16 +479,16 @@ ["Alias" "Definition"] #1) -## (type: .public (Bindings k v) -## {#counter Nat -## #mappings (List [k v])}) +... (type: .public (Bindings k v) +... {#counter Nat +... #mappings (List [k v])}) ("lux def type tagged" Bindings (#Named ["library/lux" "Bindings"] (#UnivQ #End (#UnivQ #End - (#Product ## "lux.counter" + (#Product ... "lux.counter" Nat - ## "lux.mappings" + ... "lux.mappings" (#Apply (#Product (#Parameter 3) (#Parameter 1)) List))))) @@ -498,33 +498,33 @@ ["counter" "mappings"] #1) -## (type: .public Ref -## (#Local Nat) -## (#Captured Nat)) +... (type: .public Ref +... (#Local Nat) +... (#Captured Nat)) ("lux def type tagged" Ref (#Named ["library/lux" "Ref"] - (#Sum ## Local + (#Sum ... Local Nat - ## Captured + ... Captured Nat)) (record$ #End) ["Local" "Captured"] #1) -## (type: .public Scope -## {#name (List Text) -## #inner Nat -## #locals (Bindings Text [Type Nat]) -## #captured (Bindings Text [Type Ref])}) +... (type: .public Scope +... {#name (List Text) +... #inner Nat +... #locals (Bindings Text [Type Nat]) +... #captured (Bindings Text [Type Ref])}) ("lux def type tagged" Scope (#Named ["library/lux" "Scope"] - (#Product ## name + (#Product ... name (#Apply Text List) - (#Product ## inner + (#Product ... inner Nat - (#Product ## locals + (#Product ... locals (#Apply (#Product Type Nat) (#Apply Text Bindings)) - ## captured + ... captured (#Apply (#Product Type Ref) (#Apply Text Bindings)))))) (record$ #End) ["name" "inner" "locals" "captured"] @@ -536,16 +536,16 @@ (record$ #End) #0) -## (type: .public (Either l r) -## (#Left l) -## (#Right r)) +... (type: .public (Either l r) +... (#Left l) +... (#Right r)) ("lux def type tagged" Either (#Named ["library/lux" "Either"] (#UnivQ #End (#UnivQ #End - (#Sum ## "lux.Left" + (#Sum ... "lux.Left" (#Parameter 3) - ## "lux.Right" + ... "lux.Right" (#Parameter 1))))) (record$ (#Item [(tag$ ["library/lux" "type_args"]) (tuple$ (#Item (text$ "l") (#Item (text$ "r") #End)))] @@ -555,8 +555,8 @@ ["Left" "Right"] #1) -## (type: .public Source -## [Location Nat Text]) +... (type: .public Source +... [Location Nat Text]) ("lux def" Source ("lux type check type" (#Named ["library/lux" "Source"] @@ -564,57 +564,57 @@ (record$ #End) #1) -## (type: .public Module_State -## #Active -## #Compiled -## #Cached) +... (type: .public Module_State +... #Active +... #Compiled +... #Cached) ("lux def type tagged" Module_State (#Named ["library/lux" "Module_State"] (#Sum - ## #Active + ... #Active Any (#Sum - ## #Compiled + ... #Compiled Any - ## #Cached + ... #Cached Any))) (record$ #End) ["Active" "Compiled" "Cached"] #1) -## (type: .public Module -## {#module_hash Nat -## #module_aliases (List [Text Text]) -## #definitions (List [Text Global]) -## #imports (List Text) -## #tags (List [Text [Nat (List Name) Bit Type]]) -## #types (List [Text [(List Name) Bit Type]]) -## #module_annotations (Maybe Code) -## #module_state Module_State}) +... (type: .public Module +... {#module_hash Nat +... #module_aliases (List [Text Text]) +... #definitions (List [Text Global]) +... #imports (List Text) +... #tags (List [Text [Nat (List Name) Bit Type]]) +... #types (List [Text [(List Name) Bit Type]]) +... #module_annotations (Maybe Code) +... #module_state Module_State}) ("lux def type tagged" Module (#Named ["library/lux" "Module"] - (#Product ## "lux.module_hash" + (#Product ... "lux.module_hash" Nat - (#Product ## "lux.module_aliases" + (#Product ... "lux.module_aliases" (#Apply (#Product Text Text) List) - (#Product ## "lux.definitions" + (#Product ... "lux.definitions" (#Apply (#Product Text Global) List) - (#Product ## "lux.imports" + (#Product ... "lux.imports" (#Apply Text List) - (#Product ## "lux.tags" + (#Product ... "lux.tags" (#Apply (#Product Text (#Product Nat (#Product (#Apply Name List) (#Product Bit Type)))) List) - (#Product ## "lux.types" + (#Product ... "lux.types" (#Apply (#Product Text (#Product (#Apply Name List) (#Product Bit Type))) List) - (#Product ## "lux.module_annotations" + (#Product ... "lux.module_annotations" (#Apply Code Maybe) Module_State)) )))))) @@ -624,34 +624,34 @@ ["module_hash" "module_aliases" "definitions" "imports" "tags" "types" "module_annotations" "module_state"] #1) -## (type: .public Type_Context -## {#ex_counter Nat -## #var_counter Nat -## #var_bindings (List [Nat (Maybe Type)])}) +... (type: .public Type_Context +... {#ex_counter Nat +... #var_counter Nat +... #var_bindings (List [Nat (Maybe Type)])}) ("lux def type tagged" Type_Context (#Named ["library/lux" "Type_Context"] - (#Product ## ex_counter + (#Product ... ex_counter Nat - (#Product ## var_counter + (#Product ... var_counter Nat - ## var_bindings + ... var_bindings (#Apply (#Product Nat (#Apply Type Maybe)) List)))) (record$ #End) ["ex_counter" "var_counter" "var_bindings"] #1) -## (type: .public Mode -## #Build -## #Eval -## #Interpreter) +... (type: .public Mode +... #Build +... #Eval +... #Interpreter) ("lux def type tagged" Mode (#Named ["library/lux" "Mode"] - (#Sum ## Build + (#Sum ... Build Any - (#Sum ## Eval + (#Sum ... Eval Any - ## Interpreter + ... Interpreter Any))) (record$ (#Item [(tag$ ["library/lux" "doc"]) (text$ "A sign that shows the conditions under which the compiler is running.")] @@ -659,19 +659,19 @@ ["Build" "Eval" "Interpreter"] #1) -## (type: .public Info -## {#target Text -## #version Text -## #mode Mode}) +... (type: .public Info +... {#target Text +... #version Text +... #mode Mode}) ("lux def type tagged" Info (#Named ["library/lux" "Info"] (#Product - ## target + ... target Text (#Product - ## version + ... version Text - ## mode + ... mode Mode))) (record$ (#Item [(tag$ ["library/lux" "doc"]) (text$ "Information about the current version and type of compiler that is running.")] @@ -679,44 +679,44 @@ ["target" "version" "mode"] #1) -## (type: .public Lux -## {#info Info -## #source Source -## #location Location -## #current_module (Maybe Text) -## #modules (List [Text Module]) -## #scopes (List Scope) -## #type_context Type_Context -## #expected (Maybe Type) -## #seed Nat -## #scope_type_vars (List Nat) -## #extensions Any -## #host Any}) +... (type: .public Lux +... {#info Info +... #source Source +... #location Location +... #current_module (Maybe Text) +... #modules (List [Text Module]) +... #scopes (List Scope) +... #type_context Type_Context +... #expected (Maybe Type) +... #seed Nat +... #scope_type_vars (List Nat) +... #extensions Any +... #host Any}) ("lux def type tagged" Lux (#Named ["library/lux" "Lux"] - (#Product ## "lux.info" + (#Product ... "lux.info" Info - (#Product ## "lux.source" + (#Product ... "lux.source" Source - (#Product ## "lux.location" + (#Product ... "lux.location" Location - (#Product ## "lux.current_module" + (#Product ... "lux.current_module" (#Apply Text Maybe) - (#Product ## "lux.modules" + (#Product ... "lux.modules" (#Apply (#Product Text Module) List) - (#Product ## "lux.scopes" + (#Product ... "lux.scopes" (#Apply Scope List) - (#Product ## "lux.type_context" + (#Product ... "lux.type_context" Type_Context - (#Product ## "lux.expected" + (#Product ... "lux.expected" (#Apply Type Maybe) - (#Product ## "lux.seed" + (#Product ... "lux.seed" Nat - (#Product ## scope_type_vars + (#Product ... scope_type_vars (#Apply Nat List) - (#Product ## extensions + (#Product ... extensions Any - ## "lux.host" + ... "lux.host" Any)))))))))))) (record$ (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" @@ -728,8 +728,8 @@ ["info" "source" "location" "current_module" "modules" "scopes" "type_context" "expected" "seed" "scope_type_vars" "extensions" "host"] #1) -## (type: .public (Meta a) -## (-> Lux (Either Text [Lux a]))) +... (type: .public (Meta a) +... (-> Lux (Either Text [Lux a]))) ("lux def" Meta ("lux type check type" (#Named ["library/lux" "Meta"] @@ -746,8 +746,8 @@ #End))) #1) -## (type: .public Macro' -## (-> (List Code) (Meta (List Code)))) +... (type: .public Macro' +... (-> (List Code) (Meta (List Code)))) ("lux def" Macro' ("lux type check type" (#Named ["library/lux" "Macro'"] @@ -755,8 +755,8 @@ (record$ #End) #1) -## (type: .public Macro -## (primitive "#Macro")) +... (type: .public Macro +... (primitive "#Macro")) ("lux def" Macro ("lux type check type" (#Named ["library/lux" "Macro"] @@ -766,7 +766,7 @@ #End)) #1) -## Base functions & macros +... Base functions & macros ("lux def" in_meta ("lux type check" (#UnivQ #End @@ -958,9 +958,9 @@ (macro:' .public (comment tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" - ("lux text concat" "## Throws away any code given to it." __paragraph) + ("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) + ("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)")))] #End) (in_meta #End)) @@ -1091,7 +1091,7 @@ (def:'' .private (quantified_args_parser args next) #End - ## (-> (List Code) (-> (List Text) (Meta (List Code))) (Meta (List Code))) + ... (-> (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) @@ -1113,7 +1113,7 @@ (def:'' .private (list\fold f init xs) #End - ## (All [a b] (-> (-> b a a) a (List b) a)) + ... (All [a b] (-> (-> b a a) a (List b) a)) (#UnivQ #End (#UnivQ #End (#Function (#Function (#Parameter 1) (#Function (#Parameter 3) (#Parameter 3))) @@ -1136,11 +1136,11 @@ (macro:' .public (All tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" - ("lux text concat" "## Universal quantification." __paragraph) + ("lux text concat" "... Universal quantification." __paragraph) ("lux text concat" ("lux text concat" "(All [a] (-> a a))" __paragraph) ("lux text concat" - ("lux text concat" "## A name can be provided, to specify a recursive type." __paragraph) + ("lux text concat" "... A name can be provided, to specify a recursive type." __paragraph) "(All List [a] (Variant Any [a (List a)]))"))))] #End) (let'' [self_name tokens] ({(#Item [_ (#Identifier "" self_name)] tokens) @@ -1181,11 +1181,11 @@ (macro:' .public (Ex tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" - ("lux text concat" "## Existential quantification." __paragraph) + ("lux text concat" "... Existential quantification." __paragraph) ("lux text concat" ("lux text concat" "(Ex [a] [(Codec Text a) a])" __paragraph) ("lux text concat" - ("lux text concat" "## A name can be provided, to specify a recursive type." __paragraph) + ("lux text concat" "... A name can be provided, to specify a recursive type." __paragraph) "(Ex Self [a] [(Codec Text a) a (List (Self a))])"))))] #End) (let'' [self_name tokens] ({(#Item [_ (#Identifier "" self_name)] tokens) @@ -1234,10 +1234,10 @@ (macro:' .public (-> tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" - ("lux text concat" "## Function types:" __paragraph) + ("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.")))] + "... This is the type of a function that takes 2 Ints and returns an Int.")))] #End) ({(#Item output inputs) (in_meta (#Item (list\fold ("lux type check" (#Function Code (#Function Code Code)) @@ -1253,7 +1253,7 @@ (macro:' .public (list xs) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" - ("lux text concat" "## List-construction macro." __paragraph) + ("lux text concat" "... List-construction macro." __paragraph) "(list +1 +2 +3)"))] #End) (in_meta (#Item (list\fold (function'' [head tail] @@ -1267,9 +1267,9 @@ (macro:' .public (list& xs) (#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" "... 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) + ("lux text concat" "... In other words, this macro prepends elements to another list." __paragraph) "(list& +1 +2 +3 (list +4 +5 +6))")))] #End) ({(#Item last init) @@ -1286,11 +1286,11 @@ (macro:' .public (Tuple tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" - ("lux text concat" "## Tuple types:" __paragraph) + ("lux text concat" "... Tuple types:" __paragraph) ("lux text concat" ("lux text concat" "(Tuple Text Int Bit)" __paragraph) ("lux text concat" - ("lux text concat" "## Any." __paragraph) + ("lux text concat" "... Any." __paragraph) "(&)"))))] #End) ({#End @@ -1305,11 +1305,11 @@ (macro:' .public (Variant tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" - ("lux text concat" "## Variant types:" __paragraph) + ("lux text concat" "... Variant types:" __paragraph) ("lux text concat" ("lux text concat" "(Variant Text Int Bit)" __paragraph) ("lux text concat" - ("lux text concat" "## Nothing." __paragraph) + ("lux text concat" "... Nothing." __paragraph) "(Variant)"))))] #End) ({#End @@ -1473,11 +1473,11 @@ (macro:' .public (_$ tokens) (#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" "... Left-association for the application of binary functions over variadic arguments." ..\n) ("lux text concat" ("lux text concat" "(_$ text\compose ''Hello, '' name ''. How are you?'')" ..\n) ("lux text concat" - ("lux text concat" "## =>" ..\n) + ("lux text concat" "... =>" ..\n) "(text\compose (text\compose ''Hello, '' name) ''. How are you?'')"))))] #End) ({(#Item op tokens') @@ -1495,11 +1495,11 @@ (macro:' .public ($_ tokens) (#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" "... Right-association for the application of binary functions over variadic arguments." ..\n) ("lux text concat" ("lux text concat" "($_ text\compose ''Hello, '' name ''. How are you?'')" ..\n) ("lux text concat" - ("lux text concat" "## =>" ..\n) + ("lux text concat" "... =>" ..\n) "(text\compose ''Hello, '' (text\compose name ''. How are you?''))"))))] #End) ({(#Item op tokens') @@ -1514,11 +1514,11 @@ (failure "Wrong syntax for $_")} tokens)) -## (interface: (Monad m) -## (: (All [a] (-> a (m a))) -## in) -## (: (All [a b] (-> (-> a (m b)) (m a) (m b))) -## bind)) +... (interface: (Monad m) +... (: (All [a] (-> a (m a))) +... in) +... (: (All [a b] (-> (-> a (m b)) (m a) (m b))) +... bind)) ("lux def type tagged" Monad (#Named ["library/lux" "Monad"] (All [m] @@ -1595,8 +1595,8 @@ (def:''' .private (monad\map m f xs) #End - ## (All [m a b] - ## (-> (Monad m) (-> a (m b)) (List a) (m (List b)))) + ... (All [m a b] + ... (-> (Monad m) (-> a (m b)) (List a) (m (List b)))) (All [m a b] (-> ($' Monad m) (-> a ($' m b)) @@ -1615,8 +1615,8 @@ (def:''' .private (monad\fold m f y xs) #End - ## (All [m a b] - ## (-> (Monad m) (-> a b (m b)) b (List a) (m b))) + ... (All [m a b] + ... (-> (Monad m) (-> a b (m b)) b (List a) (m b))) (All [m a b] (-> ($' Monad m) (-> a b ($' m b)) @@ -1695,16 +1695,16 @@ (def:''' .private (get_meta tag def_meta) #End (-> Name Code ($' Maybe Code)) - (let' [[prefix name] tag] + (let' [[module name] tag] ({[_ (#Record def_meta)] ({(#Item [key value] def_meta') - ({[_ (#Tag [prefix' name'])] + ({[_ (#Tag [module' name'])] ({[#1 #1] (#Some value) _ (get_meta tag (record$ def_meta'))} - [(text\= prefix prefix') + [(text\= module module') (text\= name name')]) _ @@ -1891,7 +1891,7 @@ (macro:' .public (primitive tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Macro to treat define new primitive types." __paragraph + "... Macro to treat define new primitive types." __paragraph "(primitive ''java.lang.Object'')" __paragraph "(primitive ''java.util.List'' [(primitive ''java.lang.Long'')])"))]) ({(#Item [_ (#Text class_name)] #End) @@ -1922,8 +1922,8 @@ (macro:' .public (` tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## 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 + "... 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))))"))]) ({(#Item template #End) (do meta_monad @@ -1940,7 +1940,7 @@ (macro:' .public (`' tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Unhygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms." __paragraph + "... Unhygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms." __paragraph "(`' (def: (~ name) (function (_ (~+ args)) (~ body))))"))]) ({(#Item template #End) (do meta_monad @@ -1954,7 +1954,7 @@ (macro:' .public (' tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Quotation as a macro." __paragraph + "... Quotation as a macro." __paragraph "(' YOLO)"))]) ({(#Item template #End) (do meta_monad @@ -1968,9 +1968,9 @@ (macro:' .public (|> tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Piping macro." __paragraph + "... Piping macro." __paragraph "(|> elems (list\map int\encode) (interpose '' '') (fold text\compose ''''))" __paragraph - "## =>" __paragraph + "... =>" __paragraph "(fold text\compose '''' (interpose '' '' (list\map int\encode elems)))"))]) ({(#Item [init apps]) (in_meta (list (list\fold ("lux type check" (-> Code Code Code) @@ -1994,9 +1994,9 @@ (macro:' .public (<| tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Reverse piping macro." __paragraph + "... Reverse piping macro." __paragraph "(<| (fold text\compose '''') (interpose '' '') (list\map int\encode) elems)" __paragraph - "## =>" __paragraph + "... =>" __paragraph "(fold text\compose '''' (interpose '' '' (list\map int\encode elems)))"))]) ({(#Item [init apps]) (in_meta (list (list\fold ("lux type check" (-> Code Code Code) @@ -2142,7 +2142,7 @@ (macro:' .public (template tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## By specifying a pattern (with holes), and the input data to fill those holes, repeats the pattern as many times as necessary." __paragraph + "... By specifying a pattern (with holes), and the input data to fill those holes, repeats the pattern as many times as necessary." __paragraph "(template [<name> <diff>]" ..\n " " "[(def: .public <name> (-> Int Int) (+ <diff>))]" __paragraph " " "[inc +1]" ..\n @@ -2273,7 +2273,7 @@ (def:''' .public (not x) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Bit negation." __paragraph + "... Bit negation." __paragraph "(not #1) => #0" __paragraph "(not #0) => #1"))]) (-> Bit Bit) @@ -2481,7 +2481,7 @@ (macro:' .public (type tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Takes a type expression and returns its representation as data-structure." __paragraph + "... Takes a type expression and returns its representation as data-structure." __paragraph "(type (All [a] (Maybe (List a))))"))]) ({(#Item type #End) (do meta_monad @@ -2500,7 +2500,7 @@ (macro:' .public (: tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## The type-annotation macro." __paragraph + "... The type-annotation macro." __paragraph "(: (List Int) (list +1 +2 +3))"))]) ({(#Item type (#Item value #End)) (in_meta (list (` ("lux type check" (type (~ type)) (~ value))))) @@ -2512,7 +2512,7 @@ (macro:' .public (:as tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## The type-coercion macro." __paragraph + "... The type-coercion macro." __paragraph "(:as Dinosaur (list +1 +2 +3))"))]) ({(#Item type (#Item value #End)) (in_meta (list (` ("lux type as" (type (~ type)) (~ value))))) @@ -2610,8 +2610,8 @@ (macro:' .public (Rec tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Parameter-less recursive types." __paragraph - "## A name has to be given to the whole type, to use it within its body." __paragraph + "... 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)])"))]) ({(#Item [_ (#Identifier "" name)] (#Item body #End)) (let' [body' (|> body @@ -2626,7 +2626,7 @@ (macro:' .public (exec tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Sequential execution of expressions (great for side-effects)." __paragraph + "... Sequential execution of expressions (great for side-effects)." __paragraph "(exec" ..\n " " "(log! ''#1'')" ..\n " " "(log! ''#2'')" ..\n @@ -2708,15 +2708,15 @@ [_ (#Text value)] (text\encode value) - [_ (#Identifier [prefix name])] - (if (text\= "" prefix) + [_ (#Identifier [module name])] + (if (text\= "" module) name - ($_ text\compose prefix "." name)) + ($_ text\compose module "." name)) - [_ (#Tag [prefix name])] - (if (text\= "" prefix) + [_ (#Tag [module name])] + (if (text\= "" module) ($_ text\compose "#" name) - ($_ text\compose "#" prefix "." name)) + ($_ text\compose "#" module "." name)) [_ (#Form xs)] ($_ text\compose "(" (|> xs @@ -2777,8 +2777,8 @@ (macro:' .public (case tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## The pattern-matching macro." ..\n - "## Allows the usage of macros within the patterns to provide custom syntax." ..\n + "... 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 " " "(#Item x (#Item y (#Item z #End)))" ..\n " " "(#Some ($_ * x y z))" __paragraph @@ -2796,8 +2796,8 @@ (macro:' .public (^ tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Macro-expanding patterns." ..\n - "## It's a special macro meant to be used with 'case'." ..\n + "... Macro-expanding patterns." ..\n + "... It's a special macro meant to be used with 'case'." ..\n "(case (: (List Int) (list +1 +2 +3))" ..\n " (^ (list x y z))" ..\n " (#Some ($_ * x y z))" @@ -2821,8 +2821,8 @@ (macro:' .public (^or tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Or-patterns." ..\n - "## It's a special macro meant to be used with 'case'." ..\n + "... Or-patterns." ..\n + "... It's a special macro meant to be used with 'case'." ..\n "(type: Weekday #Monday #Tuesday #Wednesday #Thursday #Friday #Saturday #Sunday)" __paragraph "(def: (weekend? day)" ..\n @@ -2859,8 +2859,8 @@ (macro:' .public (let tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Creates local bindings." ..\n - "## Can (optionally) use pattern-matching macros when binding." ..\n + "... Creates local bindings." ..\n + "... Can (optionally) use pattern-matching macros when binding." ..\n "(let [x (foo bar)" ..\n " y (baz quux)]" ..\n " (op x y))"))]) @@ -2885,8 +2885,8 @@ (macro:' .public (function tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Syntax for creating functions." ..\n - "## Allows for giving the function itself a name, for the sake of recursion." ..\n + "... Syntax for creating functions." ..\n + "... Allows for giving the function itself a name, for the sake of recursion." ..\n "(: (All [a b] (-> a b a))" ..\n " (function (_ x y) x))" __paragraph @@ -2935,8 +2935,8 @@ [_ (#Text value)] (meta_code ["library/lux" "Text"] (text$ value)) - [_ (#Tag [prefix name])] - (meta_code ["library/lux" "Tag"] (` [(~ (text$ prefix)) (~ (text$ name))])) + [_ (#Tag [module name])] + (meta_code ["library/lux" "Tag"] (` [(~ (text$ module)) (~ (text$ name))])) (^or [_ (#Form _)] [_ (#Identifier _)]) code @@ -3075,11 +3075,11 @@ (def:' .private (bodyP tokens) (-> (List Code) (Maybe [(List Code) [(Maybe Code) Code]])) (case tokens - ## TB + ... TB (^ (list& type body tokens')) (#Some [tokens' [(#Some type) body]]) - ## B + ... B (^ (list& body tokens')) (#Some [tokens' [#None body]]) @@ -3114,8 +3114,8 @@ .let' [[tokens [?type body]] %] _ (endP tokens)] (in [export_policy name parameters annotations ?type body])) - ## (^ (list _export_policy _declaration _annotations _type _body)) - ## (^ (list _export_policy _declaration _annotations _body)) + ... (^ (list _export_policy _declaration _annotations _type _body)) + ... (^ (list _export_policy _declaration _annotations _body)) (maybe\else' (do maybe_monad [% (enhanced_local_declarationP tokens) .let' [[tokens [name parameters]] %] @@ -3123,8 +3123,8 @@ .let' [[tokens [?type body]] %] _ (endP tokens)] (in [(` ..private) name parameters #End ?type body]))) - ## (^ (list _declaration _type _body)) - ## (^ (list _declaration _body)) + ... (^ (list _declaration _type _body)) + ... (^ (list _declaration _body)) (maybe\else' (do maybe_monad [% (enhanced_local_declarationP tokens) .let' [[tokens [name parameters]] %] @@ -3134,8 +3134,8 @@ .let' [[tokens [?type body]] %] _ (endP tokens)] (in [(` ..private) name parameters annotations ?type body]))) - ## (^ (list _declaration _annotations _type _body)) - ## (^ (list _declaration _annotations _body)) + ... (^ (list _declaration _annotations _type _body)) + ... (^ (list _declaration _annotations _body)) (maybe\else' (do maybe_monad [% (enhanced_declarationP tokens) .let' [[tokens [export_policy name parameters]] %] @@ -3143,14 +3143,14 @@ .let' [[tokens [?type body]] %] _ (endP tokens)] (in [export_policy name parameters #End ?type body]))) - ## (^ (list _export_policy _declaration _type _body)) - ## (^ (list _export_policy _declaration _body)) + ... (^ (list _export_policy _declaration _type _body)) + ... (^ (list _export_policy _declaration _body)) )) (macro:' .public (def: tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Defines global constants/functions." ..\n + "... Defines global constants/functions." ..\n "(def: (pair_list pair)" ..\n " (-> [Code Code] (List Code))" ..\n " (let [[left right] pair]" ..\n @@ -3216,7 +3216,7 @@ .let' [[tokens body] %] _ (endP tokens)] (in [export_policy name parameters annotations body])) - ## (^ (list _export_policy _declaration _annotations _body)) + ... (^ (list _export_policy _declaration _annotations _body)) (maybe\else' (do maybe_monad [% (local_declarationP tokens) .let' [[tokens [name parameters]] %] @@ -3224,7 +3224,7 @@ .let' [[tokens body] %] _ (endP tokens)] (in [(` ..private) name parameters #End body]))) - ## (^ (list _declaration _body)) + ... (^ (list _declaration _body)) (maybe\else' (do maybe_monad [% (local_declarationP tokens) .let' [[tokens [name parameters]] %] @@ -3234,7 +3234,7 @@ .let' [[tokens body] %] _ (endP tokens)] (in [(` ..private) name parameters annotations body]))) - ## (^ (list _declaration _annotations _body)) + ... (^ (list _declaration _annotations _body)) (maybe\else' (do maybe_monad [% (declarationP tokens) .let' [[tokens [export_policy name parameters]] %] @@ -3242,18 +3242,18 @@ .let' [[tokens body] %] _ (endP tokens)] (in [export_policy name parameters #End body]))) - ## (^ (list _export_policy _declaration _body)) + ... (^ (list _export_policy _declaration _body)) )) (macro:' .public (macro: tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" - "## Macro-definition macro." ..\n + "... Macro-definition macro." ..\n "(macro: .public (name_of tokens)" ..\n " (case tokens" ..\n " (^template [<tag>]" ..\n - " [(^ (list [_ (<tag> [prefix name])]))" ..\n - " (in (list (` [(~ (text$ prefix)) (~ (text$ name))])))])" ..\n + " [(^ (list [_ (<tag> [module name])]))" ..\n + " (in (list (` [(~ (text$ module)) (~ (text$ name))])))])" ..\n " ([#Identifier] [#Tag])" __paragraph " _" ..\n @@ -3306,8 +3306,8 @@ _ (failure <message>)))] - [and (if (~ pre) (~ post) #0) "'and' requires >=1 clauses." "Short-circuiting 'and': (and #1 #0 #1) ## => #0"] - [or (if (~ pre) #1 (~ post)) "'or' requires >=1 clauses." "Short-circuiting 'or': (or #1 #0 #1) ## => #1"]) + [and (if (~ pre) (~ post) #0) "'and' requires >=1 clauses." "Short-circuiting 'and': (and #1 #0 #1) ... => #0"] + [or (if (~ pre) #1 (~ post)) "'or' requires >=1 clauses." "Short-circuiting 'or': (or #1 #0 #1) ... => #1"]) (def: (index part text) (-> Text Text (Maybe Nat)) @@ -3315,19 +3315,19 @@ (def: .public (error! message) {#.doc (text$ ($_ "lux text concat" - "## Causes an error, with the given error message." ..\n + "... Causes an error, with the given error message." ..\n "(error! ''OH NO!'')"))} (-> Text Nothing) ("lux io error" message)) (macro: (else tokens state) {#.doc (text$ ($_ "lux text concat" - "## Allows you to provide a default value that will be used" ..\n - "## if a (Maybe x) value turns out to be #.None." + "... Allows you to provide a default value that will be used" ..\n + "... if a (Maybe x) value turns out to be #.None." __paragraph - "(else +20 (#.Some +10)) ## => +10" + "(else +20 (#.Some +10)) ... => +10" __paragraph - "(else +20 #.None) ## => +20"))} + "(else +20 #.None) ... => +20"))} (case tokens (^ (list else maybe)) (let [g!temp (: Code [dummy_location (#Identifier ["" ""])]) @@ -3369,7 +3369,7 @@ (#Some x) (item ("lux i64 -" 1 idx) xs')))) -## https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction +... https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction (def: (reduced env type) (-> (List Type) Type Type) (case type @@ -3629,8 +3629,8 @@ .let' [[tokens type] %] tokens (remainderP tokens)] (in [export_policy name parameters annotations type tokens])) - ## (^ (list _export_policy _declaration _annotations _type _body)) - ## (^ (list _declaration _annotations _type _body)) + ... (^ (list _export_policy _declaration _annotations _type _body)) + ... (^ (list _declaration _annotations _type _body)) (maybe\else' (do maybe_monad [% (enhanced_local_declarationP tokens) .let' [[tokens [name parameters]] %] @@ -3638,7 +3638,7 @@ .let' [[tokens type] %] tokens (remainderP tokens)] (in [(` ..private) name parameters #End type tokens]))) - ## (^ (list _declaration _type _body)) + ... (^ (list _declaration _type _body)) (maybe\else' (do maybe_monad [% (anyP tokens) .let' [[tokens export_policy] %] @@ -3648,12 +3648,12 @@ .let' [[tokens type] %] tokens (remainderP tokens)] (in [export_policy name parameters #End type tokens]))) - ## (^ (list _export_policy _declaration _type _body)) + ... (^ (list _export_policy _declaration _type _body)) )) (macro: .public (implementation: tokens) {#.doc (text$ ($_ "lux text concat" - "## Definition of structures ala ML." ..\n + "... Definition of structures ala ML." ..\n "(implementation: .public order" ..\n " (Order Int)" ..\n " (def: &equivalence equivalence)" ..\n @@ -3709,8 +3709,8 @@ .let' [[tokens annotations] %] tokens (remainderP tokens)] (in [export_policy rec? name parameters annotations tokens])) - ## (^ (list _export_policy _rec _declaration _annotations _body)) - ## (^ (list _export_policy _declaration _annotations _body)) + ... (^ (list _export_policy _rec _declaration _annotations _body)) + ... (^ (list _export_policy _declaration _annotations _body)) (maybe\else' (do maybe_monad [.let' [[tokens rec?] (recP tokens)] % (local_declarationP tokens) @@ -3719,16 +3719,16 @@ .let' [[tokens annotations] %] tokens (remainderP tokens)] (in [(` ..private) rec? name parameters annotations tokens]))) - ## (^ (list _rec _declaration _annotations _body)) - ## (^ (list _declaration _annotations _body)) + ... (^ (list _rec _declaration _annotations _body)) + ... (^ (list _declaration _annotations _body)) (maybe\else' (do maybe_monad [.let' [[tokens rec?] (recP tokens)] % (local_declarationP tokens) .let' [[tokens [name parameters]] %] tokens (remainderP tokens)] (in [(` ..private) rec? name parameters #End tokens]))) - ## (^ (list _rec _declaration _body)) - ## (^ (list _declaration _body)) + ... (^ (list _rec _declaration _body)) + ... (^ (list _declaration _body)) (maybe\else' (do maybe_monad [% (anyP tokens) .let' [[tokens export_policy] %] @@ -3737,13 +3737,13 @@ .let' [[tokens [name parameters]] %] tokens (remainderP tokens)] (in [export_policy rec? name parameters #End tokens]))) - ## (^ (list _export_policy _rec _declaration _body)) - ## (^ (list _export_policy _declaration _body)) + ... (^ (list _export_policy _rec _declaration _body)) + ... (^ (list _export_policy _declaration _body)) )) (macro: .public (type: tokens) {#.doc (text$ ($_ "lux text concat" - "## The type-definition macro." ..\n + "... The type-definition macro." ..\n "(type: (List a)" ..\n " {#.doc (doc (: (List Nat) (list 0 1 2 3)))}" ..\n " #End" ..\n @@ -3811,23 +3811,23 @@ % (annotationsP tokens) .let' [[tokens annotations] %]] (in [export_policy name parameters annotations tokens])) - ## (^ (list _export_policy _declaration _annotations _body)) - ## (^ (list _declaration _annotations _body)) + ... (^ (list _export_policy _declaration _annotations _body)) + ... (^ (list _declaration _annotations _body)) (maybe\else' (do maybe_monad [% (local_declarationP tokens) .let' [[tokens [name parameters]] %]] (in [(` ..private) name parameters #End tokens]))) - ## (^ (list _declaration _body)) + ... (^ (list _declaration _body)) (maybe\else' (do maybe_monad [% (declarationP tokens) .let' [[tokens [export_policy name parameters]] %]] (in [export_policy name parameters #End tokens]))) - ## (^ (list _export_policy _declaration _body)) + ... (^ (list _export_policy _declaration _body)) )) (macro: .public (interface: tokens) {#.doc (text$ ($_ "lux text concat" - "## Definition of interfaces/signatures ala ML." ..\n + "... Definition of interfaces/signatures ala ML." ..\n "(interface: .public (Order a)" ..\n " (: (Equivalence a)" ..\n " &equivalence)" ..\n @@ -3973,7 +3973,7 @@ [_ post] (text\split! ("lux text size" token) post')]] (in [pre post]))) -(def: (replace_all pattern replacement template) +(def: (replaced pattern replacement template) (-> Text Text Text Text) ((: (-> Text Text Text) (function (recur left right) @@ -3991,8 +3991,8 @@ (def: (module_alias context self aliased) (-> Text Text Text Text) (|> aliased - (replace_all ..self_reference self) - (replace_all ..contextual_reference context))) + (replaced ..self_reference self) + (replaced ..contextual_reference context))) (def: .public module_separator "/") @@ -4086,7 +4086,7 @@ (: (-> Code (Meta (List Importation))) (function (_ token) (case token - ## Simple + ... Simple [_ (#Identifier ["" module_name])] (do meta_monad [absolute_module_name (..absolute_module_name nested? relative_root module_name)] @@ -4095,7 +4095,7 @@ #import_refer {#refer_defs #All #refer_open (list)}}))) - ## Nested + ... Nested (^ [_ (#Tuple (list& [_ (#Identifier ["" module_name])] extra))]) (do meta_monad [absolute_module_name (case (normal_parallel_path relative_root module_name) @@ -4145,7 +4145,7 @@ #refer_open openings}} sub_imports)))) - ## Unrecognized syntax. + ... Unrecognized syntax. _ (do meta_monad [current_module current_module_name] @@ -4248,12 +4248,12 @@ (def: (definition_type name state) (-> Name Lux (Maybe Type)) - (let [[v_prefix v_name] name + (let [[v_module v_name] name {#info info #source source #current_module _ #modules modules #scopes scopes #type_context types #host host #seed seed #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars} state] - (case (get v_prefix modules) + (case (get v_module modules) #None #None @@ -4272,12 +4272,12 @@ (def: (definition_value name state) (-> Name (Meta [Type Any])) - (let [[v_prefix v_name] name + (let [[v_module v_name] name {#info info #source source #current_module _ #modules modules #scopes scopes #type_context types #host host #seed seed #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars} state] - (case (get v_prefix modules) + (case (get v_module modules) #None (#Left (text\compose "Unknown definition: " (name\encode name))) @@ -4409,8 +4409,8 @@ (macro: .public (^open tokens) {#.doc (text$ ($_ "lux text concat" - "## Same as the 'open' macro, but meant to be used as a pattern-matching macro for generating local bindings." ..\n - "## Takes an 'alias' text for the generated local bindings." ..\n + "... Same as the 'open' macro, but meant to be used as a pattern-matching macro for generating local bindings." ..\n + "... Takes an 'alias' text for the generated local bindings." ..\n "(def: .public (range (^open ''.'') minimum additional)" ..\n " (All [a] (-> (Enum a) a a (List a)))" ..\n " (range' <= succ minimum additional))"))} @@ -4460,11 +4460,11 @@ (macro: .public (cond tokens) {#.doc (text$ ($_ "lux text concat" - "## Branching structures with multiple test conditions." ..\n + "... Branching structures with multiple test conditions." ..\n "(cond (even? num) ''even''" ..\n " (odd? num) ''odd''" __paragraph - " ## else_branch" ..\n + " ... else_branch" ..\n " ''???'')"))} (if ("lux i64 =" 0 (n/% 2 (list\size tokens))) (failure "cond requires an uneven number of arguments.") @@ -4495,13 +4495,13 @@ (macro: .public (get@ tokens) {#.doc (text$ ($_ "lux text concat" - "## Accesses the value of a record at a given tag." ..\n + "... Accesses the value of a record at a given tag." ..\n "(get@ #field my_record)" __paragraph - "## Can also work with multiple levels of nesting:" ..\n + "... Can also work with multiple levels of nesting:" ..\n "(get@ [#foo #bar #baz] my_record)" __paragraph - "## And, if only the slot/path is given, generates an accessor function:" ..\n + "... And, if only the slot/path is given, generates an accessor function:" ..\n "(let [getter (get@ [#foo #bar #baz])]" ..\n " (getter my_record))"))} (case tokens @@ -4515,8 +4515,8 @@ (case (interface_methods type) (#Some members) (let [pattern (record$ (list\map (: (-> [Name [Nat Type]] [Code Code]) - (function (_ [[r_prefix r_name] [r_idx r_type]]) - [(tag$ [r_prefix r_name]) + (function (_ [[r_module r_name] [r_idx r_type]]) + [(tag$ [r_module r_name]) (if ("lux i64 =" idx r_idx) g!output g!_)])) @@ -4574,12 +4574,12 @@ (macro: .public (open: tokens) {#.doc (text$ ($_ "lux text concat" - "## Opens a implementation and generates a definition for each of its members (including nested members)." + "... Opens a implementation and generates a definition for each of its members (including nested members)." __paragraph - "## For example:" ..\n + "... For example:" ..\n "(open: ''i:.'' number)" __paragraph - "## Will generate:" ..\n + "... Will generate:" ..\n "(def: i:+ (\ number +))" ..\n "(def: i:- (\ number -))" ..\n "(def: i:* (\ number *))" ..\n @@ -4617,9 +4617,9 @@ (macro: .public (|>> tokens) {#.doc (text$ ($_ "lux text concat" - "## Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n + "... Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n "(|>> (list\map int\encode) (interpose '' '') (fold text\compose ''''))" ..\n - "## =>" ..\n + "... =>" ..\n "(function (_ <arg>) (fold text\compose '''' (interpose '' '' (list\map int\encode <arg>))))"))} (do meta_monad [g!_ (gensym "_") @@ -4628,9 +4628,9 @@ (macro: .public (<<| tokens) {#.doc (text$ ($_ "lux text concat" - "## Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n + "... Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n "(<<| (fold text\compose '''') (interpose '' '') (list\map int\encode))" ..\n - "## =>" ..\n + "... =>" ..\n "(function (_ <arg>) (fold text\compose '''' (interpose '' '' (list\map int\encode <arg>))))"))} (do meta_monad [g!_ (gensym "_") @@ -4741,7 +4741,7 @@ #Nothing (list))) openings (list\map (function (_ [alias structs]) - (form$ (list& (text$ (..replace_all ..contextual_reference module_alias alias)) + (form$ (list& (text$ (..replaced ..contextual_reference module_alias alias)) (list\map local_identifier$ structs)))) r_opens)] (` (..refer (~ (text$ module_name)) @@ -4750,11 +4750,11 @@ (macro: .public (module: tokens) {#.doc (text$ ($_ "lux text concat" - "## Module_definition macro." + "... Module_definition macro." __paragraph - "## Can take optional annotations and allows the specification of modules to import." + "... Can take optional annotations and allows the specification of modules to import." __paragraph - "## Example" ..\n + "... Example" ..\n "(.module: {#.doc ''Some documentation...''}" ..\n " [lux #*" ..\n " [control" ..\n @@ -4792,10 +4792,10 @@ (macro: .public (\ tokens) {#.doc (text$ ($_ "lux text concat" - "## Allows accessing the value of a implementation's member." ..\n + "... Allows accessing the value of a implementation's member." ..\n "(\ codec encode)" __paragraph - "## Also allows using that value as a function." ..\n + "... Also allows using that value as a function." ..\n "(\ codec encode +123)"))} (case tokens (^ (list struct [_ (#Identifier member)])) @@ -4809,13 +4809,13 @@ (macro: .public (set@ tokens) {#.doc (text$ ($_ "lux text concat" - "## Sets the value of a record at a given tag." ..\n + "... Sets the value of a record at a given tag." ..\n "(set@ #name ''Lux'' lang)" __paragraph - "## Can also work with multiple levels of nesting:" ..\n + "... Can also work with multiple levels of nesting:" ..\n "(set@ [#foo #bar #baz] value my_record)" __paragraph - "## And, if only the slot/path and (optionally) the value are given, generates a mutator function:" ..\n + "... And, if only the slot/path and (optionally) the value are given, generates a mutator function:" ..\n "(let [setter (set@ [#foo #bar #baz] value)] (setter my_record))" ..\n "(let [setter (set@ [#foo #bar #baz])] (setter value my_record))"))} (case tokens @@ -4898,13 +4898,13 @@ (macro: .public (update@ tokens) {#.doc (text$ ($_ "lux text concat" - "## Modifies the value of a record at a given tag, based on some function." ..\n + "... Modifies the value of a record at a given tag, based on some function." ..\n "(update@ #age inc person)" __paragraph - "## Can also work with multiple levels of nesting:" ..\n + "... Can also work with multiple levels of nesting:" ..\n "(update@ [#foo #bar #baz] func my_record)" __paragraph - "## And, if only the slot/path and (optionally) the value are given, generates a mutator function:" ..\n + "... And, if only the slot/path and (optionally) the value are given, generates a mutator function:" ..\n "(let [updater (update@ [#foo #bar #baz] func)] (updater my_record))" ..\n "(let [updater (update@ [#foo #bar #baz])] (updater func my_record))"))} (case tokens @@ -4973,7 +4973,7 @@ (macro: .public (^template tokens) {#.doc (text$ ($_ "lux text concat" - "## It's similar to template, but meant to be used during pattern-matching." ..\n + "... It's similar to template, but meant to be used during pattern-matching." ..\n "(def: (reduced env type)" ..\n " (-> (List Type) Type Type)" ..\n " (case type" ..\n @@ -5088,18 +5088,18 @@ (-> Name Text) (|>> name\encode (text\compose "#"))) -(def: (repeat n x) +(def: (repeated n x) (All [a] (-> Int a (List a))) (if ("lux i64 <" n +0) - (#Item x (repeat ("lux i64 +" -1 n) x)) + (#Item x (repeated ("lux i64 +" -1 n) x)) #End)) (def: (location_padding baseline [_ old_line old_column] [_ new_line new_column]) (-> Nat Location Location Text) (if ("lux i64 =" old_line new_line) - (text\join_with "" (repeat (.int ("lux i64 -" old_column new_column)) " ")) - (let [extra_lines (text\join_with "" (repeat (.int ("lux i64 -" old_line new_line)) ..\n)) - space_padding (text\join_with "" (repeat (.int ("lux i64 -" baseline new_column)) " "))] + (text\join_with "" (repeated (.int ("lux i64 -" old_column new_column)) " ")) + (let [extra_lines (text\join_with "" (repeated (.int ("lux i64 -" old_line new_line)) ..\n)) + space_padding (text\join_with "" (repeated (.int ("lux i64 -" baseline new_column)) " "))] (text\compose extra_lines space_padding)))) (def: (text\size x) @@ -5170,7 +5170,7 @@ (#Documentation_Comment comment) (|> comment (text\split_all_with ..\n) - (list\map (function (_ line) ($_ text\compose "## " line ..\n))) + (list\map (function (_ line) ($_ text\compose "... " line ..\n))) (text\join_with "")) (#Documentation_Example example) @@ -5181,9 +5181,9 @@ (macro: .public (doc tokens) {#.doc (text$ ($_ "lux text concat" - "## Creates code documentation, embedding text as comments and properly formatting the forms it's being given." + "... Creates code documentation, embedding text as comments and properly formatting the forms it's being given." __paragraph - "## For Example:" ..\n + "... For Example:" ..\n "(doc ''Allows arbitrary looping, using the 'recur' form to re-start the loop.''" ..\n " ''Can be used in monadic code to create monadic loops.''" ..\n " (loop [count +0" ..\n @@ -5236,10 +5236,10 @@ ([#.UnivQ] [#.ExQ]) (#Named [module name] anonymous) - ## TODO: Generate the explicit type definition instead of using - ## the "identifier$" shortcut below. - ## (` (#.Named [(~ (text$ module)) (~ (text$ name))] - ## (~ (type_code anonymous)))) + ... TODO: Generate the explicit type definition instead of using + ... the "identifier$" shortcut below. + ... (` (#.Named [(~ (text$ module)) (~ (text$ name))] + ... (~ (type_code anonymous)))) (identifier$ [module name]))) (macro: .public (loop tokens) @@ -5346,8 +5346,8 @@ (^or [_ (#Bit _)] [_ (#Nat _)] [_ (#Int _)] [_ (#Rev _)] [_ (#Frac _)] [_ (#Text _)] [_ (#Tag _)]) (#Some (list target)) - [_ (#Identifier [prefix name])] - (if (and (text\= "" prefix) + [_ (#Identifier [module name])] + (if (and (text\= "" module) (text\= label name)) (#Some tokens) (#Some (list target))) @@ -5463,12 +5463,12 @@ (def: (static_literal token) (-> Code (Meta Code)) (case token - [_ (#Identifier [def_prefix def_name])] - (if (text\= "" def_prefix) + [_ (#Identifier [def_module def_name])] + (if (text\= "" def_module) (do meta_monad [current_module current_module_name] (static_simple_literal [current_module def_name])) - (static_simple_literal [def_prefix def_name])) + (static_simple_literal [def_module def_name])) (^template [<tag>] [[meta (<tag> parts)] @@ -5491,8 +5491,8 @@ _ (\ meta_monad in_meta token) - ## TODO: Figure out why this doesn't work: - ## (\ meta_monad in token) + ... TODO: Figure out why this doesn't work: + ... (\ meta_monad in token) )) (macro: .public (static tokens) @@ -5601,23 +5601,23 @@ _ (failure "Wrong syntax for ^multi"))) -## TODO: Allow asking the compiler for the name of the definition -## currently being defined. That name can then be fed into -## 'wrong_syntax_error' for easier maintenance of the error_messages. +... TODO: Allow asking the compiler for the name of the definition +... currently being defined. That name can then be fed into +... 'wrong_syntax_error' for easier maintenance of the error_messages. (def: wrong_syntax_error (-> Name Text) (|>> name\encode (text\compose "Wrong syntax for "))) (macro: .public (name_of tokens) - {#.doc (doc "Given an identifier or a tag, gives back a 2 tuple with the prefix and name parts, both as Text." + {#.doc (doc "Given an identifier or a tag, gives back a 2 tuple with the module and name parts, both as Text." (name_of #.doc) "=>" ["library/lux" "doc"])} (case tokens (^template [<tag>] - [(^ (list [_ (<tag> [prefix name])])) - (in_meta (list (` [(~ (text$ prefix)) (~ (text$ name))])))]) + [(^ (list [_ (<tag> [module name])])) + (in_meta (list (` [(~ (text$ module)) (~ (text$ name))])))]) ([#Identifier] [#Tag]) _ @@ -5783,8 +5783,8 @@ .let' [[tokens templates] %] _ (endP tokens)] (in [export_policy name parameters annotations templates])) - ## (^ (list _export_policy _declaration _annotations _body)) - ## (^ (list _declaration _annotations _body)) + ... (^ (list _export_policy _declaration _annotations _body)) + ... (^ (list _declaration _annotations _body)) (maybe\else' (do maybe_monad [% (declarationP tokens) .let' [[tokens [export_policy name parameters]] %] @@ -5792,7 +5792,7 @@ .let' [[tokens templates] %] _ (endP tokens)] (in [export_policy name parameters #End templates]))) - ## (^ (list _export_policy _declaration _body)) + ... (^ (list _export_policy _declaration _body)) (maybe\else' (do maybe_monad [% (local_declarationP tokens) .let' [[tokens [name parameters]] %] @@ -5800,7 +5800,7 @@ .let' [[tokens templates] %] _ (endP tokens)] (in [(` ..private) name parameters #End templates]))) - ## (^ (list _declaration _body)) + ... (^ (list _declaration _body)) )) (macro: .public (template: tokens) diff --git a/stdlib/source/library/lux/abstract/apply.lux b/stdlib/source/library/lux/abstract/apply.lux index dc9d71f0f..051809cc0 100644 --- a/stdlib/source/library/lux/abstract/apply.lux +++ b/stdlib/source/library/lux/abstract/apply.lux @@ -17,21 +17,21 @@ {#.doc "Applicative functor composition."} (All [F G] (-> (Monad F) (Apply F) (Apply G) - ## TODO: Replace (All [a] (F (G a))) with (functor.Then F G) + ... TODO: Replace (All [a] (F (G a))) with (functor.Then F G) (Apply (All [a] (F (G a)))))) (def: &functor (functor.compose (get@ #&functor f_apply) (get@ #&functor g_apply))) (def: (apply fgf fgx) - ## TODO: Switch from this version to the one below (in comments) ASAP. + ... TODO: Switch from this version to the one below (in comments) ASAP. (let [fgf' (\ f_apply apply (\ f_monad in (\ g_apply apply)) fgf)] (\ f_apply apply fgf' fgx)) - ## (let [applyF (\ f_apply apply) - ## applyG (\ g_apply apply)] - ## ($_ applyF - ## (\ f_monad in applyG) - ## fgf - ## fgx)) + ... (let [applyF (\ f_apply apply) + ... applyG (\ g_apply apply)] + ... ($_ applyF + ... (\ f_monad in applyG) + ... fgf + ... fgx)) )) diff --git a/stdlib/source/library/lux/abstract/enum.lux b/stdlib/source/library/lux/abstract/enum.lux index d1fec7f7f..0cb26b8a4 100644 --- a/stdlib/source/library/lux/abstract/enum.lux +++ b/stdlib/source/library/lux/abstract/enum.lux @@ -22,5 +22,5 @@ (/\< from end) (recur (/\succ end) (#.Item end output)) - ## (/\= end from) + ... (/\= end from) (#.Item end output))))) diff --git a/stdlib/source/library/lux/abstract/interval.lux b/stdlib/source/library/lux/abstract/interval.lux index 7c2b2ca35..acd7be087 100644 --- a/stdlib/source/library/lux/abstract/interval.lux +++ b/stdlib/source/library/lux/abstract/interval.lux @@ -1,4 +1,4 @@ -## https://en.wikipedia.org/wiki/Interval_(mathematics) +... https://en.wikipedia.org/wiki/Interval_(mathematics) (.module: [library [lux #*]] @@ -55,7 +55,7 @@ (or (order.>= ,\&order ,\bottom elem) (order.<= ,\&order ,\top elem)) - ## singleton + ... singleton (and (,\= ,\bottom elem) (,\= ,\top elem))))) @@ -169,7 +169,7 @@ (and (inner? reference) (outer? sample))) #0 - ## (and (outer? reference) (inner? sample)) + ... (and (outer? reference) (inner? sample)) (let [(^open ",\.") reference] (or (and (order.>= ,\&order (\ reference bottom) (\ sample bottom)) (order.> ,\&order (\ reference bottom) (\ sample top))) @@ -192,10 +192,10 @@ (or (order.>= ,\&order (\ reference bottom) (\ sample top)) (order.<= ,\&order (\ reference top) (\ sample bottom))) - ## both inner + ... both inner (inner? sample) (inner? (intersection reference sample)) - ## both outer + ... both outer (not (nested? reference sample)) )))) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index 3005596ee..91dd6740d 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -82,7 +82,7 @@ ___a [Bit then else] ___z)))} (let [de_alias (function (_ aliased) (list\fold (function (_ [from to] pre) - (code.replace (code.local_identifier from) to pre)) + (code.replaced (code.local_identifier from) to pre)) aliased aliases))] (case [(|> inputs (get@ #bottom) (maybe\map (|>> code.nat (~) #.Parameter (`)))) @@ -152,7 +152,7 @@ ((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 !))] + [g!inputs (|> (macro.gensym "input") (list.repeated arity) (monad.seq !))] (in (list (` (: (All [(~+ g!inputs) (~ g!output)] (-> (-> (~+ g!inputs) (~ g!output)) (=> [(~+ g!inputs)] [(~ g!output)]))) diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index 74dab7eda..ee3a1e5d3 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -95,7 +95,7 @@ (:abstraction {#obituary (async.async []) #mailbox (atom (async.async []))})) process (loop [state (on_init init) - [|mailbox| _] (io.run (atom.read (get@ #mailbox (:representation self))))] + [|mailbox| _] (io.run (atom.read! (get@ #mailbox (:representation self))))] (do {! async.monad} [[head tail] |mailbox| ?state' (on_mail head state self)] @@ -124,13 +124,13 @@ _ bit.no)))))) - (def: .public (obituary actor) + (def: .public (obituary' actor) (All [s] (-> (Actor s) (IO (Maybe (Obituary s))))) (let [[obituary _] (get@ #obituary (:representation actor))] (async.poll obituary))) - (def: .public await - {#.doc (doc "Await for an actor to end working.")} + (def: .public obituary + {#.doc (doc "Await for an actor to stop working.")} (All [s] (-> (Actor s) (Async (Obituary s)))) (|>> :representation (get@ #obituary) @@ -144,7 +144,7 @@ (if alive? (let [entry [mail (async.async [])]] (do ! - [|mailbox|&resolve (atom.read (get@ #mailbox (:representation actor)))] + [|mailbox|&resolve (atom.read! (get@ #mailbox (:representation actor)))] (loop [[|mailbox| resolve] |mailbox|&resolve] (do ! [|mailbox| (async.poll |mailbox|)] @@ -154,8 +154,8 @@ [resolved? (resolve entry)] (if resolved? (do ! - [_ (atom.write (product.right entry) (get@ #mailbox (:representation actor)))] - (in (exception.return []))) + [_ (atom.write! (product.right entry) (get@ #mailbox (:representation actor)))] + (in (#try.Success []))) (recur |mailbox|&resolve))) (#.Some [_ |mailbox|']) @@ -411,7 +411,7 @@ (def: continue! true) (def: stop! false) -(def: .public (observe action channel actor) +(def: .public (observe! action channel actor) {#.doc (doc "Use an actor to observe a channel by transforming each datum" "flowing through the channel into mail the actor can process." "Can stop observing the channel by executing the Stop value.")} @@ -419,10 +419,10 @@ (let [signal (: (Atom Bit) (atom.atom ..continue!)) stop (: Stop - (atom.write ..stop! signal))] + (atom.write! ..stop! signal))] (frp.subscribe (function (_ event) (do {! io.monad} - [continue? (atom.read signal)] + [continue? (atom.read! signal)] (if continue? (|> actor (..mail! (action event stop)) diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index cc1757a31..72736ef94 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -33,7 +33,7 @@ (function (resolve value) (let [async (:representation async)] (do {! io.monad} - [(^@ old [_value _observers]) (atom.read async)] + [(^@ old [_value _observers]) (atom.read! async)] (case _value (#.Some _) (in #0) @@ -41,7 +41,7 @@ #.None (do ! [.let [new [(#.Some value) #.None]] - succeeded? (atom.compare_and_swap old new async)] + succeeded? (atom.compare_and_swap! old new async)] (if succeeded? (do ! [_ (monad.map ! (function (_ f) (f value)) @@ -64,15 +64,15 @@ {#.doc "Polls an async for its value."} (All [a] (-> (Async a) (IO (Maybe a)))) (|>> :representation - atom.read + atom.read! (\ io.functor map product.left))) - (def: .public (await f async) + (def: .public (upon! f async) {#.doc (doc "Executes the given function as soon as the async has been resolved.")} (All [a] (-> (-> a (IO Any)) (Async a) (IO Any))) (do {! io.monad} [.let [async (:representation async)] - (^@ old [_value _observers]) (atom.read async)] + (^@ old [_value _observers]) (atom.read! async)] (case _value (#.Some value) (f value) @@ -80,10 +80,10 @@ #.None (let [new [_value (#.Item f _observers)]] (do ! - [swapped? (atom.compare_and_swap old new async)] + [swapped? (atom.compare_and_swap! old new async)] (if swapped? (in []) - (await f (:abstraction async)))))))) + (upon! f (:abstraction async)))))))) ) (def: .public resolved? @@ -102,7 +102,7 @@ (def: (map f fa) (let [[fb resolve] (..async [])] - (exec (io.run (..await (|>> f resolve) fa)) + (exec (io.run (..upon! (|>> f resolve) fa)) fb)))) (implementation: .public apply @@ -112,8 +112,8 @@ (def: (apply ff fa) (let [[fb resolve] (..async [])] - (exec (io.run (..await (function (_ f) - (..await (|>> f resolve) fa)) + (exec (io.run (..upon! (function (_ f) + (..upon! (|>> f resolve) fa)) ff)) fb)))) @@ -126,7 +126,7 @@ (def: (join mma) (let [[ma resolve] (async [])] - (exec (io.run (..await (..await resolve) mma)) + (exec (io.run (..upon! (..upon! resolve) mma)) ma)))) (def: .public (and left right) @@ -139,8 +139,8 @@ [(Async [a b]) (Resolver [a b])] (..async [])) - _ (io.run (..await (function (_ left) - (..await (function (_ right) + _ (io.run (..upon! (function (_ left) + (..upon! (function (_ right) (write! [left right])) right)) left))] @@ -153,7 +153,7 @@ (let [[a|b resolve] (..async [])] (with_expansions [<sides> (template [<async> <tag>] - [(io.run (await (|>> <tag> resolve) <async>))] + [(io.run (upon! (|>> <tag> resolve) <async>))] [left #.Left] [right #.Right] @@ -167,21 +167,21 @@ (All [a] (-> (Async a) (Async a) (Async a))) (let [[left||right resolve] (..async [])] (`` (exec (~~ (template [<async>] - [(io.run (await resolve <async>))] + [(io.run (upon! resolve <async>))] [left] [right])) left||right)))) -(def: .public (schedule millis_delay computation) +(def: .public (schedule! millis_delay computation) {#.doc (doc "Runs an I/O computation on its own thread (after a specified delay)." - "Returns a aromise that will eventually host its result.")} + "Returns an async that will eventually host its result.")} (All [a] (-> Nat (IO a) (Async a))) (let [[!out resolve] (..async [])] (exec (|> (do io.monad [value computation] (resolve value)) - (thread.schedule millis_delay) + (thread.schedule! millis_delay) io.run) !out))) @@ -189,19 +189,19 @@ {#.doc (doc "Runs an I/O computation on its own thread." "Returns an async that will eventually host its result.")} (All [a] (-> (IO a) (Async a))) - (..schedule 0)) + (..schedule! 0)) -(def: .public (delay time_millis value) +(def: .public (delayed time_millis value) {#.doc "Delivers a value after a certain period has passed."} (All [a] (-> Nat a (Async a))) - (..schedule time_millis (io value))) + (..schedule! time_millis (io value))) -(def: .public (wait time_millis) - {#.doc "Returns an async that will be resolved after the specified amount of milliseconds."} +(def: .public (delay time_millis) + {#.doc "An async that will be resolved after the specified amount of milliseconds."} (-> Nat (Async Any)) - (..delay time_millis [])) + (..delayed time_millis [])) (def: .public (time_out time_millis async) {#.doc "Wait for an async to be resolved within the specified amount of milliseconds."} (All [a] (-> Nat (Async a) (Async (Maybe a)))) - (..or (wait time_millis) async)) + (..or (..delay time_millis) async)) diff --git a/stdlib/source/library/lux/control/concurrency/atom.lux b/stdlib/source/library/lux/control/concurrency/atom.lux index c6c993561..a607fa8d3 100644 --- a/stdlib/source/library/lux/control/concurrency/atom.lux +++ b/stdlib/source/library/lux/control/concurrency/atom.lux @@ -61,14 +61,14 @@ @.jvm <jvm>} (<write> 0 value (<new> 1)))))) - (def: .public (read atom) + (def: .public (read! atom) (All [a] (-> (Atom a) (IO a))) (io (with_expansions [<jvm> (java/util/concurrent/atomic/AtomicReference::get (:representation atom))] (for {@.old <jvm> @.jvm <jvm>} (<read> 0 (:representation atom)))))) - (def: .public (compare_and_swap current new atom) + (def: .public (compare_and_swap! current new atom) {#.doc (doc "Only mutates an atom if you can present its current value." "That guarantees that atom was not updated since you last read from it.")} (All [a] (-> a a (Atom a) (IO Bit))) @@ -82,24 +82,24 @@ false)))))) )) -(def: .public (update f atom) +(def: .public (update! f atom) {#.doc (doc "Updates an atom by applying a function to its current value." "If it fails to update it (because some other process wrote to it first), it will retry until it succeeds." "The retries will be done with the new values of the atom, as they show up.")} (All [a] (-> (-> a a) (Atom a) (IO [a a]))) (loop [_ []] (do io.monad - [old (read atom) + [old (read! atom) .let [new (f old)] - swapped? (..compare_and_swap old new atom)] + swapped? (compare_and_swap! old new atom)] (if swapped? (in [old new]) (recur []))))) -(def: .public (write value atom) +(def: .public (write! value atom) {#.doc (doc "Writes the given value to an atom." "If it fails to write it (because some other process wrote to it first), it will retry until it succeeds.")} (All [a] (-> a (Atom a) (IO a))) (|> atom - (..update (function.constant value)) + (..update! (function.constant value)) (io\map product.left))) diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index 3b1a0a4bd..7d22b5924 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -40,24 +40,24 @@ (def: close (loop [_ []] (do {! io.monad} - [current (atom.read sink) + [current (atom.read! sink) stopped? (current #.None)] (if stopped? - ## I closed the sink. - (in (exception.return [])) - ## Someone else interacted with the sink. + ... I closed the sink. + (in (#try.Success [])) + ... Someone else interacted with the sink. (do ! - [latter (atom.read sink)] + [latter (atom.read! sink)] (if (is? current latter) - ## Someone else closed the sink. + ... Someone else closed the sink. (in (exception.except ..channel_is_already_closed [])) - ## Someone else fed the sink while I was closing it. + ... Someone else fed the sink while I was closing it. (recur []))))))) (def: (feed value) (loop [_ []] (do {! io.monad} - [current (atom.read sink) + [current (atom.read! sink) .let [[next resolve_next] (:sharing [a] (async.Resolver (Maybe [a (Channel a)])) current @@ -67,17 +67,17 @@ (async.async []))] fed? (current (#.Some [value next]))] (if fed? - ## I fed the sink. + ... I fed the sink. (do ! - [_ (atom.compare_and_swap current resolve_next sink)] - (in (exception.return []))) - ## Someone else interacted with the sink. + [_ (atom.compare_and_swap! current resolve_next sink)] + (in (#try.Success []))) + ... Someone else interacted with the sink. (do ! - [latter (atom.read sink)] + [latter (atom.read! sink)] (if (is? current latter) - ## Someone else closed the sink while I was feeding it. + ... Someone else closed the sink while I was feeding it. (in (exception.except ..channel_is_already_closed [])) - ## Someone else fed the sink. + ... Someone else fed the sink. (recur [])))))))))) (def: .public (channel _) @@ -233,7 +233,7 @@ (do io.monad [value action _ (\ sink feed value)] - (async.await recur (async.wait milli_seconds))))) + (async.upon! recur (async.delay milli_seconds))))) [output sink]))) (def: .public (periodic milli_seconds) @@ -296,5 +296,5 @@ (#.Item head tail) (async.resolved (#.Some [head (do async.monad - [_ (async.wait milli_seconds)] + [_ (async.delay milli_seconds)] (sequential milli_seconds tail))])))) diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index f01af9336..046651c1b 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -55,11 +55,11 @@ (exec (io.run (with_expansions [<had_open_position?> (as_is (get@ #open_positions) (i.> -1))] (do io.monad - [[_ state'] (atom.update (|>> (update@ #open_positions dec) - (if> [<had_open_position?>] - [] - [(update@ #waiting_list (queue.push sink))])) - semaphore)] + [[_ state'] (atom.update! (|>> (update@ #open_positions dec) + (if> [<had_open_position?>] + [] + [(update@ #waiting_list (queue.push sink))])) + semaphore)] (with_expansions [<go_ahead> (sink []) <get_in_line> (in false)] (if (|> state' <had_open_position?>) @@ -77,14 +77,14 @@ (let [semaphore (:representation semaphore)] (async.future (do {! io.monad} - [[pre post] (atom.update (function (_ state) - (if (i.= (.int (get@ #max_positions state)) - (get@ #open_positions state)) - state - (|> state - (update@ #open_positions inc) - (update@ #waiting_list queue.pop)))) - semaphore)] + [[pre post] (atom.update! (function (_ state) + (if (i.= (.int (get@ #max_positions state)) + (get@ #open_positions state)) + state + (|> state + (update@ #open_positions inc) + (update@ #waiting_list queue.pop)))) + semaphore)] (if (is? pre post) (in (exception.except ..semaphore_is_maxed_out [(get@ #max_positions pre)])) (do ! @@ -127,7 +127,7 @@ (def: .public limit {#.doc (doc "Produce a limit for a barrier.")} - (refinement.refinement (n.> 0))) + (refinement.refiner (n.> 0))) (type: .public Limit {#.doc (doc "A limit for barriers.")} @@ -163,7 +163,7 @@ (do async.monad [.let [limit (refinement.value (get@ #limit barrier)) goal <goal> - [_ count] (io.run (atom.update <update> (get@ #count barrier))) + [_ count] (io.run (atom.update! <update> (get@ #count barrier))) reached? (n.= goal count)]] (if reached? (..un_block (dec limit) (get@ <turnstile> barrier)) diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux index 6308a2c84..1ad5d9ac0 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -35,22 +35,22 @@ (def: read! (All [a] (-> (Var a) a)) - (|>> :representation atom.read io.run product.left)) + (|>> :representation atom.read! io.run product.left)) (def: (un_follow sink var) (All [a] (-> (Sink a) (Var a) (IO Any))) (do io.monad - [_ (atom.update (function (_ [value observers]) - [value (list.only (|>> (is? sink) not) observers)]) - (:representation var))] + [_ (atom.update! (function (_ [value observers]) + [value (list.only (|>> (is? sink) not) observers)]) + (:representation var))] (in []))) (def: (write! new_value var) (All [a] (-> a (Var a) (IO Any))) (do {! io.monad} [.let [var' (:representation var)] - (^@ old [old_value observers]) (atom.read var') - succeeded? (atom.compare_and_swap old [new_value observers] var')] + (^@ old [old_value observers]) (atom.read! var') + succeeded? (atom.compare_and_swap! old [new_value observers] var')] (if succeeded? (do ! [_ (monad.map ! (function (_ sink) @@ -71,9 +71,9 @@ (All [a] (-> (Var a) (IO [(Channel a) (Sink a)]))) (do io.monad [.let [[channel sink] (frp.channel [])] - _ (atom.update (function (_ [value observers]) - [value (#.Item sink observers)]) - (:representation target))] + _ (atom.update! (function (_ [value observers]) + [value (#.Item sink observers)]) + (:representation target))] (in [channel sink]))) ) @@ -217,7 +217,7 @@ (All [a] (-> (Commit a) (IO Any))) (let [entry [commit (async.async [])]] (do {! io.monad} - [|commits|&resolve (atom.read pending_commits)] + [|commits|&resolve (atom.read! pending_commits)] (loop [[|commits| resolve] |commits|&resolve] (do ! [|commits| (async.poll |commits|)] @@ -226,7 +226,7 @@ (do io.monad [resolved? (resolve entry)] (if resolved? - (atom.write (product.right entry) pending_commits) + (atom.write! (product.right entry) pending_commits) (recur |commits|&resolve))) (#.Some [head tail]) @@ -245,18 +245,18 @@ (def: init_processor! (IO Any) (do {! io.monad} - [flag (atom.read commit_processor_flag)] + [flag (atom.read! commit_processor_flag)] (if flag (in []) (do ! - [was_first? (atom.compare_and_swap flag #1 commit_processor_flag)] + [was_first? (atom.compare_and_swap! flag #1 commit_processor_flag)] (if was_first? (do ! - [[async resolve] (atom.read pending_commits)] - (async.await (function (recur [head [tail _resolve]]) + [[async resolve] (atom.read! pending_commits)] + (async.upon! (function (recur [head [tail _resolve]]) (do ! [_ (process_commit head)] - (async.await recur tail))) + (async.upon! recur tail))) async)) (in []))) ))) diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index 8c3a273d4..767107af7 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -57,7 +57,7 @@ (new [ffi.Float ffi.Function]) (start [] #io #? Any)])} - ## Default + ... Default (type: Thread {#creation Nat #delay Nat @@ -72,7 +72,7 @@ .nat)] (for {@.old <jvm> @.jvm <jvm>} - ## Default + ... Default 1))) (with_expansions [<jvm> (as_is (def: runner @@ -83,7 +83,7 @@ @.js (as_is) @.python (as_is)} - ## Default + ... Default (def: runner (Atom (List Thread)) (atom.atom (list))))) @@ -101,7 +101,7 @@ (#try.Success _) [])) -(def: .public (schedule milli_seconds action) +(def: .public (schedule! milli_seconds action) {#.doc (doc "Executes an I/O procedure after some milli-seconds.")} (-> Nat (IO Any) (IO Any)) (with_expansions [<jvm> (as_is (let [runnable (ffi.object [] [java/lang/Runnable] @@ -127,13 +127,13 @@ (threading/Timer::start []))] (in []))} - ## Default + ... Default (do {! io.monad} [now (\ ! map (|>> instant.millis .nat) instant.now) - _ (atom.update (|>> (#.Item {#creation now - #delay milli_seconds - #action action})) - ..runner)] + _ (atom.update! (|>> (#.Item {#creation now + #delay milli_seconds + #action action})) + ..runner)] (in []))))) (for {@.old (as_is) @@ -141,18 +141,18 @@ @.js (as_is) @.python (as_is)} - ## Default + ... Default (as_is (exception: .public cannot_continue_running_threads) - ## https://en.wikipedia.org/wiki/Event_loop + ... https://en.wikipedia.org/wiki/Event_loop (def: .public run! {#.doc (doc "Starts the event-loop.")} (IO Any) (loop [_ []] (do {! io.monad} - [threads (atom.read ..runner)] + [threads (atom.read! ..runner)] (case threads - ## And... we're done! + ... And... we're done! #.End (in []) @@ -164,7 +164,7 @@ (n.+ (get@ #delay thread)) (n.<= now))) threads)] - swapped? (atom.compare_and_swap threads pending ..runner)] + swapped? (atom.compare_and_swap! threads pending ..runner)] (if swapped? (do ! [_ (monad.map ! (|>> (get@ #action) ..execute! io.io) ready)] diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index a7d5a5871..1edd4bc04 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -37,7 +37,7 @@ (All [e] (-> (Exception e) Text Bit)) (text.starts_with? (get@ #label exception) error)) -(def: .public (catch exception then try) +(def: .public (when exception then try) {#.doc (doc "If a particular exception is detected on a possibly-erroneous value, handle it." "If no exception was detected, or a different one from the one being checked, then pass along the original value.")} (All [e a] @@ -67,11 +67,6 @@ (#//.Failure error) (else error))) -(def: .public (return value) - {#.doc "A way to lift normal values into the error-handling context."} - (All [a] (-> a (Try a))) - (#//.Success value)) - (def: .public (error exception message) {#.doc "Constructs an error message from an exception."} (All [e] (-> (Exception e) e Text)) @@ -135,18 +130,18 @@ 0 entries) on_new_line (|> " " - (list.repeat (n.+ (text.size header_separator) - largest_header_size)) + (list.repeated (n.+ (text.size header_separator) + largest_header_size)) (text.join_with "") (text\compose text.new_line)) on_entry (: (-> [Text Text] Text) (function (_ [header message]) (let [padding (|> " " - (list.repeat (n.- (text.size header) - largest_header_size)) + (list.repeated (n.- (text.size header) + largest_header_size)) (text.join_with ""))] (|> message - (text.replace_all text.new_line on_new_line) + (text.replaced text.new_line on_new_line) ($_ text\compose padding header header_separator)))))] (case entries #.End @@ -186,13 +181,13 @@ (def: separator (let [gap ($_ "lux text concat" text.new_line text.new_line) - horizontal_line (|> "-" (list.repeat 64) (text.join_with ""))] + horizontal_line (|> "-" (list.repeated 64) (text.join_with ""))] ($_ "lux text concat" gap horizontal_line gap))) -(def: (decorate prelude error) +(def: (decorated prelude error) (-> Text Text Text) ($_ "lux text concat" prelude @@ -209,7 +204,7 @@ (..error exception message) _ - (..decorate (..error exception message) error))) + (..decorated (..error exception message) error))) success success)) diff --git a/stdlib/source/library/lux/control/function/memo.lux b/stdlib/source/library/lux/control/function/memo.lux index 311f1e433..87131ad57 100644 --- a/stdlib/source/library/lux/control/function/memo.lux +++ b/stdlib/source/library/lux/control/function/memo.lux @@ -1,5 +1,5 @@ -## Inspired by; -## "The Different Aspects of Monads and Mixins" by Bruno C. d. S. Oliveira +... Inspired by; +... "The Different Aspects of Monads and Mixins" by Bruno C. d. S. Oliveira (.module: [library diff --git a/stdlib/source/library/lux/control/function/mixin.lux b/stdlib/source/library/lux/control/function/mixin.lux index 50e26ef55..25ca0240b 100644 --- a/stdlib/source/library/lux/control/function/mixin.lux +++ b/stdlib/source/library/lux/control/function/mixin.lux @@ -1,5 +1,5 @@ -## Inspired by; -## "The Different Aspects of Monads and Mixins" by Bruno C. d. S. Oliveira +... Inspired by; +... "The Different Aspects of Monads and Mixins" by Bruno C. d. S. Oliveira (.module: [library diff --git a/stdlib/source/library/lux/control/io.lux b/stdlib/source/library/lux/control/io.lux index 843170c4c..801be1c2a 100644 --- a/stdlib/source/library/lux/control/io.lux +++ b/stdlib/source/library/lux/control/io.lux @@ -30,7 +30,7 @@ computation)))]) (template: (!run io) - ## creatio ex nihilo + ... creatio ex nihilo [((:representation io) [])]) (syntax: .public (io computation) diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index fe10ed1ee..1018e7683 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -90,10 +90,10 @@ (#try.Failure error) (#try.Failure error))))] - [bits/8 ..size/8 /.read/8] - [bits/16 ..size/16 /.read/16] - [bits/32 ..size/32 /.read/32] - [bits/64 ..size/64 /.read/64] + [bits/8 ..size/8 /.read/8!] + [bits/16 ..size/16 /.read/16!] + [bits/32 ..size/32 /.read/32!] + [bits/64 ..size/64 /.read/64!] ) (template [<name> <type>] diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index fe7c0ea59..b83ef9165 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -38,7 +38,7 @@ (function (_ environment) (case (dictionary.get name environment) (#.Some value) - (exception.return [environment value]) + (#try.Success [environment value]) #.None (exception.except ..unknown_property [name])))) diff --git a/stdlib/source/library/lux/control/security/capability.lux b/stdlib/source/library/lux/control/security/capability.lux index 4834e172c..b0123dc68 100644 --- a/stdlib/source/library/lux/control/security/capability.lux +++ b/stdlib/source/library/lux/control/security/capability.lux @@ -4,9 +4,9 @@ [abstract [monad (#+ do)]] [control + ["." io (#+ IO)] ["<>" parser ["<c>" code]] - ["." io (#+ IO)] [concurrency ["." async (#+ Async)]]] [data @@ -30,7 +30,7 @@ (-> input output) - (def: forge + (def: capability (All [brand input output] (-> (-> input output) (Capability brand input output))) @@ -44,10 +44,12 @@ output)) ((:representation capability) input)) - (syntax: .public (capability: {export |export|.parser} - {declaration |declaration|.parser} - {annotations (<>.maybe |annotations|.parser)} - {[forge input output] (<c>.form ($_ <>.and <c>.local_identifier <c>.any <c>.any))}) + (syntax: .public (capability: {[export_policy declaration annotations [forger input output]] + (|export|.parser + ($_ <>.and + |declaration|.parser + (<>.maybe |annotations|.parser) + (<c>.form ($_ <>.and <c>.local_identifier <c>.any <c>.any))))}) {#.doc (doc "Defines a capability as a unique type, and a constructor for instances." (capability: (Can_Duplicate a) @@ -64,14 +66,14 @@ g!brand (\ ! map (|>> %.code code.text) (macro.gensym (format (%.name [this_module name])))) .let [capability (` (..Capability (.primitive (~ g!brand)) (~ input) (~ output)))]] - (in (list (` (type: (~+ (|export|.format export)) + (in (list (` (type: (~ export_policy) (~ (|declaration|.format declaration)) (~ capability))) - (` (def: (~ (code.local_identifier forge)) + (` (def: (~ (code.local_identifier forger)) (All [(~+ (list\map code.local_identifier vars))] (-> (-> (~ input) (~ output)) (~ capability))) - (~! ..forge))) + (~! ..capability))) )))) (def: .public (async capability) @@ -79,5 +81,5 @@ (All [brand input output] (-> (Capability brand input (IO output)) (Capability brand input (Async output)))) - (..forge (|>> ((:representation capability)) async.future))) + (..capability (|>> ((:representation capability)) async.future))) ) diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index fa02b452a..6d547f778 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -61,7 +61,7 @@ (implementation: .public (with monad) {#.doc (doc "Enhances a monad with error-handling functionality.")} - ## TODO: Replace (All [a] (! (Try a))) with (functor.Then ! Try) + ... TODO: Replace (All [a] (! (Try a))) with (functor.Then ! Try) (All [!] (-> (Monad !) (Monad (All [a] (! (Try a)))))) (def: &functor diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index b4ea701cb..c02d6f8bb 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -67,7 +67,7 @@ [[l1 Mla] (for {@.old (: ((:parameter 1) (Writer (:parameter 0) ((:parameter 1) (Writer (:parameter 0) (:parameter 2))))) MlMla)} - ## On new compiler + ... On new compiler MlMla) [l2 a] Mla] (in [(\ monoid compose l1 l2) a])))) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index 59c5c026a..ef3ad5f91 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -96,7 +96,7 @@ (ffi.import: (bytevector-u8-set! [Binary Nat (I64 Any)] Any)) (ffi.import: (bytevector-length [Binary] Nat)))} - ## Default + ... Default (type: .public Binary <documentation> (array.Array (I64 Any))))) @@ -118,7 +118,7 @@ @.scheme (..bytevector-length [binary])} - ## Default + ... Default (array.size binary))]) (template: (!read index binary) @@ -141,7 +141,7 @@ @.scheme (..bytevector-u8-ref [binary index])} - ## Default + ... Default (|> binary (array.read index) (maybe.else (: (I64 Any) 0)) @@ -163,7 +163,7 @@ @.scheme (exec (..bytevector-u8-set! [binary index value]) binary)} - ## Default + ... Default (array.write! index (|> value .nat (n.% (hex "100"))) binary))]) (def: .public size @@ -187,7 +187,7 @@ @.scheme (..make-bytevector size)} - ## Default + ... Default (array.empty size))) (def: .public (fold f init binary) @@ -199,14 +199,14 @@ (recur (inc index) (f (!read index binary) output)) output)))) -(def: .public (read/8 index binary) +(def: .public (read/8! index binary) {#.doc (doc "Read 1 byte (8 bits) at the given index.")} (-> Nat Binary (Try I64)) (if (n.< (..!size binary) index) (#try.Success (!read index binary)) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: .public (read/16 index binary) +(def: .public (read/16! index binary) {#.doc (doc "Read 2 bytes (16 bits) at the given index.")} (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 1 index)) @@ -215,7 +215,7 @@ (!read (n.+ 1 index) binary))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: .public (read/32 index binary) +(def: .public (read/32! index binary) {#.doc (doc "Read 4 bytes (32 bits) at the given index.")} (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 3 index)) @@ -226,7 +226,7 @@ (!read (n.+ 3 index) binary))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: .public (read/64 index binary) +(def: .public (read/64! index binary) {#.doc (doc "Read 8 bytes (64 bits) at the given index.")} (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 7 index)) @@ -241,7 +241,7 @@ (!read (n.+ 7 index) binary))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: .public (write/8 index value binary) +(def: .public (write/8! index value binary) {#.doc (doc "Write 1 byte (8 bits) at the given index.")} (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) index) @@ -249,7 +249,7 @@ (!write index value))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: .public (write/16 index value binary) +(def: .public (write/16! index value binary) {#.doc (doc "Write 2 bytes (16 bits) at the given index.")} (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 1 index)) @@ -258,7 +258,7 @@ (!write (n.+ 1 index) value))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: .public (write/32 index value binary) +(def: .public (write/32! index value binary) {#.doc (doc "Write 4 bytes (32 bits) at the given index.")} (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 3 index)) @@ -269,7 +269,7 @@ (!write (n.+ 3 index) value))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: .public (write/64 index value binary) +(def: .public (write/64! index value binary) {#.doc (doc "Write 8 bytes (64 bits) at the given index.")} (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 7 index)) @@ -313,7 +313,7 @@ (for {@.old (as_is) @.jvm (as_is)} - ## Default + ... Default (exception: .public (cannot_copy_bytes {bytes Nat} {source_input Nat} {target_output Nat}) @@ -331,7 +331,7 @@ (for {@.old <jvm> @.jvm <jvm>} - ## Default + ... Default (let [source_input (n.- source_offset (!size source)) target_output (n.- target_offset (!size target))] (if (n.> source_input bytes) @@ -355,7 +355,7 @@ (for {@.old <jvm> @.jvm <jvm>} - ## Default + ... Default (..copy length offset binary 0 (..create length))))))) (def: .public (drop bytes binary) diff --git a/stdlib/source/library/lux/data/collection/bits.lux b/stdlib/source/library/lux/data/collection/bits.lux index 01296c8a2..d88827cf1 100644 --- a/stdlib/source/library/lux/data/collection/bits.lux +++ b/stdlib/source/library/lux/data/collection/bits.lux @@ -75,11 +75,11 @@ (cond> [(new> (n.= chunk_index idx|output) [])] [(<op> bit_index)] - ## else + ... else []) .nat) 0 - ## TODO: Remove 'no_op' once new-luxc is the official compiler. + ... TODO: Remove 'no_op' once new-luxc is the official compiler. (let [no_op (recur (dec size|output) output)] no_op) diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index 6ed3c4f4f..49c684929 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -19,43 +19,43 @@ ["n" nat] ["." i64]]]]]) -## This implementation of Hash Array Mapped Trie (HAMT) is based on -## Clojure's PersistentHashMap implementation. -## That one is further based on Phil Bagwell's Hash Array Mapped Trie. +... This implementation of Hash Array Mapped Trie (HAMT) is based on +... Clojure's PersistentHashMap implementation. +... That one is further based on Phil Bagwell's Hash Array Mapped Trie. -## Bitmaps are used to figure out which branches on a #Base node are -## populated. The number of bits that are 1s in a bitmap signal the -## size of the #Base node. +... Bitmaps are used to figure out which branches on a #Base node are +... populated. The number of bits that are 1s in a bitmap signal the +... size of the #Base node. (type: Bit_Map Nat) -## Represents the position of a node in a Bit_Map. -## It's meant to be a single bit set on a 32-bit word. -## The position of the bit reflects whether an entry in an analogous -## position exists within a #Base, as reflected in its Bit_Map. +... Represents the position of a node in a Bit_Map. +... It's meant to be a single bit set on a 32-bit word. +... The position of the bit reflects whether an entry in an analogous +... position exists within a #Base, as reflected in its Bit_Map. (type: Bit_Position Nat) -## An index into an array. +... An index into an array. (type: Index Nat) -## A hash-code derived from a key during tree-traversal. +... A hash-code derived from a key during tree-traversal. (type: Hash_Code Nat) -## Represents the nesting level of a leaf or node, when looking-it-up -## while exploring the tree. -## Changes in levels are done by right-shifting the hashes of keys by -## the appropriate multiple of the branching-exponent. -## A shift of 0 means root level. -## A shift of (* branching_exponent 1) means level 2. -## A shift of (* branching_exponent N) means level N+1. +... Represents the nesting level of a leaf or node, when looking-it-up +... while exploring the tree. +... Changes in levels are done by right-shifting the hashes of keys by +... the appropriate multiple of the branching-exponent. +... A shift of 0 means root level. +... A shift of (* branching_exponent 1) means level 2. +... A shift of (* branching_exponent N) means level N+1. (type: Level Nat) -## Nodes for the tree data-structure that organizes the data inside -## Dictionaries. +... Nodes for the tree data-structure that organizes the data inside +... Dictionaries. (type: (Node k v) (#Hierarchy Nat (Array (Node k v))) (#Base Bit_Map @@ -63,73 +63,73 @@ [k v]))) (#Collisions Hash_Code (Array [k v]))) -## #Hierarchy nodes are meant to point down only to lower-level nodes. +... #Hierarchy nodes are meant to point down only to lower-level nodes. (type: (Hierarchy k v) [Nat (Array (Node k v))]) -## #Base nodes may point down to other nodes, but also to leaves, -## which are KV-pairs. +... #Base nodes may point down to other nodes, but also to leaves, +... which are KV-pairs. (type: (Base k v) (Array (Either (Node k v) [k v]))) -## #Collisions are collections of KV-pairs for which the key is -## different on each case, but their hashes are all the same (thus -## causing a collision). +... #Collisions are collections of KV-pairs for which the key is +... different on each case, but their hashes are all the same (thus +... causing a collision). (type: (Collisions k v) (Array [k v])) -## That bitmap for an empty #Base is 0. -## Which is the same as 0000 0000 0000 0000 0000 0000 0000 0000. -## Or 0x00000000. -## Which is 32 zeroes, since the branching factor is 32. +... That bitmap for an empty #Base is 0. +... Which is the same as 0000 0000 0000 0000 0000 0000 0000 0000. +... Or 0x00000000. +... Which is 32 zeroes, since the branching factor is 32. (def: clean_bitmap Bit_Map 0) -## Bitmap position (while looking inside #Base nodes) is determined by -## getting 5 bits from a hash of the key being looked up and using -## them as an index into the array inside #Base. -## Since the data-structure can have multiple levels (and the hash has -## more than 5 bits), the binary-representation of the hash is shifted -## by 5 positions on each step (2^5 = 32, which is the branching -## factor). -## The initial shifting level, though, is 0 (which corresponds to the -## shift in the shallowest node on the tree, which is the root node). +... Bitmap position (while looking inside #Base nodes) is determined by +... getting 5 bits from a hash of the key being looked up and using +... them as an index into the array inside #Base. +... Since the data-structure can have multiple levels (and the hash has +... more than 5 bits), the binary-representation of the hash is shifted +... by 5 positions on each step (2^5 = 32, which is the branching +... factor). +... The initial shifting level, though, is 0 (which corresponds to the +... shift in the shallowest node on the tree, which is the root node). (def: root_level Level 0) -## The exponent to which 2 must be elevated, to reach the branching -## factor of the data-structure. +... The exponent to which 2 must be elevated, to reach the branching +... factor of the data-structure. (def: branching_exponent Nat 5) -## The threshold on which #Hierarchy nodes are demoted to #Base nodes, -## which is 1/4 of the branching factor (or a left-shift 2). +... The threshold on which #Hierarchy nodes are demoted to #Base nodes, +... which is 1/4 of the branching factor (or a left-shift 2). (def: demotion_threshold Nat (i64.left_shifted (n.- 2 branching_exponent) 1)) -## The threshold on which #Base nodes are promoted to #Hierarchy nodes, -## which is 1/2 of the branching factor (or a left-shift 1). +... The threshold on which #Base nodes are promoted to #Hierarchy nodes, +... which is 1/2 of the branching factor (or a left-shift 1). (def: promotion_threshold Nat (i64.left_shifted (n.- 1 branching_exponent) 1)) -## The size of hierarchy-nodes, which is 2^(branching-exponent). +... The size of hierarchy-nodes, which is 2^(branching-exponent). (def: hierarchy_nodes_size Nat (i64.left_shifted branching_exponent 1)) -## The cannonical empty node, which is just an empty #Base node. +... The cannonical empty node, which is just an empty #Base node. (def: empty_node Node (#Base clean_bitmap (array.empty 0))) -## Expands a copy of the array, to have 1 extra slot, which is used -## for storing the value. +... Expands a copy of the array, to have 1 extra slot, which is used +... for storing the value. (def: (insert! idx value old_array) (All [a] (-> Index a (Array a) (Array a))) (let [old_size (array.size old_array)] @@ -138,17 +138,17 @@ (array.write! idx value) (array.copy! (n.- idx old_size) idx old_array (inc idx))))) -## Creates a copy of an array with an index set to a particular value. +... Creates a copy of an array with an index set to a particular value. (def: (update! idx value array) (All [a] (-> Index a (Array a) (Array a))) (|> array array.clone (array.write! idx value))) -## Creates a clone of the array, with an empty position at index. +... Creates a clone of the array, with an empty position at index. (def: (vacant! idx array) (All [a] (-> Index (Array a) (Array a))) (|> array array.clone (array.delete! idx))) -## Shrinks a copy of the array by removing the space at index. +... Shrinks a copy of the array by removing the space at index. (def: (remove! idx array) (All [a] (-> Index (Array a) (Array a))) (let [new_size (dec (array.size array))] @@ -156,8 +156,8 @@ (array.copy! idx 0 array 0) (array.copy! (n.- idx new_size) (inc idx) array idx)))) -## Increases the level-shift by the branching-exponent, to explore -## levels further down the tree. +... Increases the level-shift by the branching-exponent, to explore +... levels further down the tree. (def: level_up (-> Level Level) (n.+ branching_exponent)) @@ -166,19 +166,19 @@ Bit_Map (dec hierarchy_nodes_size)) -## Gets the branching-factor sized section of the hash corresponding -## to a particular level, and uses that as an index into the array. +... Gets the branching-factor sized section of the hash corresponding +... to a particular level, and uses that as an index into the array. (def: (level_index level hash) (-> Level Hash_Code Index) (i64.and ..hierarchy_mask (i64.right_shifted level hash))) -## A mechanism to go from indices to bit-positions. +... A mechanism to go from indices to bit-positions. (def: (to_bit_position index) (-> Index Bit_Position) (i64.left_shifted index 1)) -## The bit-position within a base that a given hash-code would have. +... The bit-position within a base that a given hash-code would have. (def: (level_bit_position level hash) (-> Level Hash_Code Bit_Position) (to_bit_position (level_index level hash))) @@ -190,7 +190,7 @@ (n.= clean_bitmap) not)) -## Figures out whether a bitmap only contains a single bit-position. +... Figures out whether a bitmap only contains a single bit-position. (def: only_bit_position? (-> Bit_Position Bit_Map Bit) n.=) @@ -203,26 +203,26 @@ (-> Bit_Position Bit_Map Bit_Map) i64.xor) -## Figures out the size of a bitmap-indexed array by counting all the -## 1s within the bitmap. +... Figures out the size of a bitmap-indexed array by counting all the +... 1s within the bitmap. (def: bitmap_size (-> Bit_Map Nat) i64.count) -## A mask that, for a given bit position, only allows all the 1s prior -## to it, which would indicate the bitmap-size (and, thus, index) -## associated with it. +... A mask that, for a given bit position, only allows all the 1s prior +... to it, which would indicate the bitmap-size (and, thus, index) +... associated with it. (def: bit_position_mask (-> Bit_Position Bit_Map) dec) -## The index on the base array, based on its bit-position. +... The index on the base array, based on its bit-position. (def: (base_index bit_position bitmap) (-> Bit_Position Bit_Map Index) (bitmap_size (i64.and (bit_position_mask bit_position) bitmap))) -## Produces the index of a KV-pair within a #Collisions node. +... Produces the index of a KV-pair within a #Collisions node. (def: (collision_index key_hash key colls) (All [k v] (-> (Hash k) k (Collisions k v) (Maybe Index))) (\ maybe.monad map product.left @@ -230,8 +230,8 @@ (\ key_hash = key key')) colls))) -## When #Hierarchy nodes grow too small, they're demoted to #Base -## nodes to save space. +... When #Hierarchy nodes grow too small, they're demoted to #Base +... nodes to save space. (def: (demotion except_idx [h_size h_array]) (All [k v] (-> Index (Hierarchy k v) [Bit_Map (Base k v)])) (product.right (list\fold (function (_ idx [insertion_idx node]) @@ -248,8 +248,8 @@ (array.empty (dec h_size))]] (list.indices (array.size h_array))))) -## When #Base nodes grow too large, they're promoted to #Hierarchy to -## add some depth to the tree and help keep its balance. +... When #Base nodes grow too large, they're promoted to #Hierarchy to +... add some depth to the tree and help keep its balance. (def: hierarchy_indices (List Index) (list.indices hierarchy_nodes_size)) @@ -280,9 +280,9 @@ (array.empty hierarchy_nodes_size)] hierarchy_indices))) -## All empty nodes look the same (a #Base node with clean bitmap is -## used). -## So, this test is introduced to detect them. +... All empty nodes look the same (a #Base node with clean bitmap is +... used). +... So, this test is introduced to detect them. (def: (empty?' node) (All [k v] (-> (Node k v) Bit)) (`` (case node @@ -295,8 +295,8 @@ (def: (put' level hash key val key_hash node) (All [k v] (-> Level Hash_Code k v (Hash k) (Node k v) (Node k v))) (case node - ## For #Hierarchy nodes, check whether one can add the element to - ## a sub-node. If impossible, introduce a new singleton sub-node. + ... For #Hierarchy nodes, check whether one can add the element to + ... a sub-node. If impossible, introduce a new singleton sub-node. (#Hierarchy _size hierarchy) (let [idx (level_index level hash) [_size' sub_node] (case (array.read idx hierarchy) @@ -309,40 +309,40 @@ (update! idx (put' (level_up level) hash key val key_hash sub_node) hierarchy))) - ## For #Base nodes, check if the corresponding Bit_Position has - ## already been used. + ... For #Base nodes, check if the corresponding Bit_Position has + ... already been used. (#Base bitmap base) (let [bit (level_bit_position level hash)] (if (with_bit_position? bit bitmap) - ## If so... + ... If so... (let [idx (base_index bit bitmap)] (case (array.read idx base) - ## If it's being used by a node, add the KV to it. + ... If it's being used by a node, add the KV to it. (#.Some (#.Left sub_node)) (let [sub_node' (put' (level_up level) hash key val key_hash sub_node)] (#Base bitmap (update! idx (#.Left sub_node') base))) - ## Otherwise, if it's being used by a KV, compare the keys. + ... Otherwise, if it's being used by a KV, compare the keys. (#.Some (#.Right key' val')) (if (\ key_hash = key key') - ## If the same key is found, replace the value. + ... If the same key is found, replace the value. (#Base bitmap (update! idx (#.Right key val) base)) - ## Otherwise, compare the hashes of the keys. + ... Otherwise, compare the hashes of the keys. (#Base bitmap (update! idx (#.Left (let [hash' (\ key_hash hash key')] (if (n.= hash hash') - ## If the hashes are - ## the same, a new - ## #Collisions node - ## is added. + ... If the hashes are + ... the same, a new + ... #Collisions node + ... is added. (#Collisions hash (|> (array.empty 2) (array.write! 0 [key' val']) (array.write! 1 [key val]))) - ## Otherwise, one can - ## just keep using - ## #Base nodes, so - ## add both KV-pairs - ## to the empty one. + ... Otherwise, one can + ... just keep using + ... #Base nodes, so + ... add both KV-pairs + ... to the empty one. (let [next_level (level_up level)] (|> empty_node (put' next_level hash' key' val' key_hash) @@ -351,38 +351,38 @@ #.None (undefined))) - ## However, if the Bit_Position has not been used yet, check - ## whether this #Base node is ready for a promotion. + ... However, if the Bit_Position has not been used yet, check + ... whether this #Base node is ready for a promotion. (let [base_count (bitmap_size bitmap)] (if (n.>= ..promotion_threshold base_count) - ## If so, promote it to a #Hierarchy node, and add the new - ## KV-pair as a singleton node to it. + ... If so, promote it to a #Hierarchy node, and add the new + ... KV-pair as a singleton node to it. (#Hierarchy (inc base_count) (|> base (promotion put' key_hash level bitmap) (array.write! (level_index level hash) (put' (level_up level) hash key val key_hash empty_node)))) - ## Otherwise, just resize the #Base node to accommodate the - ## new KV-pair. + ... Otherwise, just resize the #Base node to accommodate the + ... new KV-pair. (#Base (with_bit_position bit bitmap) (insert! (base_index bit bitmap) (#.Right [key val]) base)))))) - ## For #Collisions nodes, compare the hashes. + ... For #Collisions nodes, compare the hashes. (#Collisions _hash _colls) (if (n.= hash _hash) - ## If they're equal, that means the new KV contributes to the - ## collisions. + ... If they're equal, that means the new KV contributes to the + ... collisions. (case (collision_index key_hash key _colls) - ## If the key was already present in the collisions-list, its - ## value gets updated. + ... If the key was already present in the collisions-list, its + ... value gets updated. (#.Some coll_idx) (#Collisions _hash (update! coll_idx [key val] _colls)) - ## Otherwise, the KV-pair is added to the collisions-list. + ... Otherwise, the KV-pair is added to the collisions-list. #.None (#Collisions _hash (insert! (array.size _colls) [key val] _colls))) - ## If the hashes are not equal, create a new #Base node that - ## contains the old #Collisions node, plus the new KV-pair. + ... If the hashes are not equal, create a new #Base node that + ... contains the old #Collisions node, plus the new KV-pair. (|> (#Base (level_bit_position level _hash) (|> (array.empty 1) (array.write! 0 (#.Left node)))) @@ -392,105 +392,105 @@ (def: (remove' level hash key key_hash node) (All [k v] (-> Level Hash_Code k (Hash k) (Node k v) (Node k v))) (case node - ## For #Hierarchy nodes, find out if there's a valid sub-node for - ## the Hash-Code. + ... For #Hierarchy nodes, find out if there's a valid sub-node for + ... the Hash-Code. (#Hierarchy h_size h_array) (let [idx (level_index level hash)] (case (array.read idx h_array) - ## If not, there's nothing to remove. + ... If not, there's nothing to remove. #.None node - ## But if there is, try to remove the key from the sub-node. + ... But if there is, try to remove the key from the sub-node. (#.Some sub_node) (let [sub_node' (remove' (level_up level) hash key key_hash sub_node)] - ## Then check if a removal was actually done. + ... Then check if a removal was actually done. (if (is? sub_node sub_node') - ## If not, then there's nothing to change here either. + ... If not, then there's nothing to change here either. node - ## But if the sub_removal yielded an empty sub_node... + ... But if the sub_removal yielded an empty sub_node... (if (empty?' sub_node') - ## Check if it's due time for a demotion. + ... Check if it's due time for a demotion. (if (n.<= demotion_threshold h_size) - ## If so, perform it. + ... If so, perform it. (#Base (demotion idx [h_size h_array])) - ## Otherwise, just clear the space. + ... Otherwise, just clear the space. (#Hierarchy (dec h_size) (vacant! idx h_array))) - ## But if the sub_removal yielded a non_empty node, then - ## just update the hiearchy branch. + ... But if the sub_removal yielded a non_empty node, then + ... just update the hiearchy branch. (#Hierarchy h_size (update! idx sub_node' h_array))))))) - ## For #Base nodes, check whether the Bit_Position is set. + ... For #Base nodes, check whether the Bit_Position is set. (#Base bitmap base) (let [bit (level_bit_position level hash)] (if (with_bit_position? bit bitmap) (let [idx (base_index bit bitmap)] (case (array.read idx base) - ## If set, check if it's a sub_node, and remove the KV - ## from it. + ... If set, check if it's a sub_node, and remove the KV + ... from it. (#.Some (#.Left sub_node)) (let [sub_node' (remove' (level_up level) hash key key_hash sub_node)] - ## Verify that it was removed. + ... Verify that it was removed. (if (is? sub_node sub_node') - ## If not, there's also nothing to change here. + ... If not, there's also nothing to change here. node - ## But if it came out empty... + ... But if it came out empty... (if (empty?' sub_node') - ### ... figure out whether that's the only position left. + ...# ... figure out whether that's the only position left. (if (only_bit_position? bit bitmap) - ## If so, removing it leaves this node empty too. + ... If so, removing it leaves this node empty too. empty_node - ## But if not, then just unset the position and - ## remove the node. + ... But if not, then just unset the position and + ... remove the node. (#Base (without_bit_position bit bitmap) (remove! idx base))) - ## But, if it did not come out empty, then the - ## position is kept, and the node gets updated. + ... But, if it did not come out empty, then the + ... position is kept, and the node gets updated. (#Base bitmap (update! idx (#.Left sub_node') base))))) - ## If, however, there was a KV-pair instead of a sub-node. + ... If, however, there was a KV-pair instead of a sub-node. (#.Some (#.Right [key' val'])) - ## Check if the keys match. + ... Check if the keys match. (if (\ key_hash = key key') - ## If so, remove the KV-pair and unset the Bit_Position. + ... If so, remove the KV-pair and unset the Bit_Position. (#Base (without_bit_position bit bitmap) (remove! idx base)) - ## Otherwise, there's nothing to remove. + ... Otherwise, there's nothing to remove. node) #.None (undefined))) - ## If the Bit_Position is not set, there's nothing to remove. + ... If the Bit_Position is not set, there's nothing to remove. node)) - ## For #Collisions nodes, It need to find out if the key already existst. + ... For #Collisions nodes, It need to find out if the key already existst. (#Collisions _hash _colls) (case (collision_index key_hash key _colls) - ## If not, then there's nothing to remove. + ... If not, then there's nothing to remove. #.None node - ## But if so, then check the size of the collisions list. + ... But if so, then check the size of the collisions list. (#.Some idx) (if (n.= 1 (array.size _colls)) - ## If there's only one left, then removing it leaves us with - ## an empty node. + ... If there's only one left, then removing it leaves us with + ... an empty node. empty_node - ## Otherwise, just shrink the array by removing the KV-pair. + ... Otherwise, just shrink the array by removing the KV-pair. (#Collisions _hash (remove! idx _colls)))) )) (def: (get' level hash key key_hash node) (All [k v] (-> Level Hash_Code k (Hash k) (Node k v) (Maybe v))) (case node - ## For #Hierarchy nodes, just look-up the key on its children. + ... For #Hierarchy nodes, just look-up the key on its children. (#Hierarchy _size hierarchy) (case (array.read (level_index level hash) hierarchy) #.None #.None (#.Some sub_node) (get' (level_up level) hash key key_hash sub_node)) - ## For #Base nodes, check the leaves, and recursively check the branches. + ... For #Base nodes, check the leaves, and recursively check the branches. (#Base bitmap base) (let [bit (level_bit_position level hash)] (if (with_bit_position? bit bitmap) @@ -507,7 +507,7 @@ (undefined)) #.None)) - ## For #Collisions nodes, do a linear scan of all the known KV-pairs. + ... For #Collisions nodes, do a linear scan of all the known KV-pairs. (#Collisions _hash _colls) (\ maybe.monad map product.right (array.find (|>> product.left (\ key_hash = key)) diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index 8d91b5cfb..b64cf7067 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -55,11 +55,11 @@ {#&order order #root #.None}) -## TODO: Doing inneficient access of Order functions due to compiler bug. -## TODO: Must improve it as soon as bug is fixed. +... TODO: Doing inneficient access of Order functions due to compiler bug. +... TODO: Must improve it as soon as bug is fixed. (def: .public (get key dict) (All [k v] (-> k (Dictionary k v) (Maybe v))) - (let [## (^open "_\.") (get@ #&order dict) + (let [... (^open "_\.") (get@ #&order dict) ] (loop [node (get@ #root dict)] (case node @@ -69,22 +69,22 @@ (#.Some node) (let [node_key (get@ #key node)] (cond (\ dict = node_key key) - ## (_\= node_key key) + ... (_\= node_key key) (#.Some (get@ #value node)) (\ dict < node_key key) - ## (_\< node_key key) + ... (_\< node_key key) (recur (get@ #left node)) - ## (_\> (get@ #key node) key) + ... (_\> (get@ #key node) key) (recur (get@ #right node)))) )))) -## TODO: Doing inneficient access of Order functions due to compiler bug. -## TODO: Must improve it as soon as bug is fixed. +... TODO: Doing inneficient access of Order functions due to compiler bug. +... TODO: Must improve it as soon as bug is fixed. (def: .public (key? dict key) (All [k v] (-> (Dictionary k v) k Bit)) - (let [## (^open "_\.") (get@ #&order dict) + (let [... (^open "_\.") (get@ #&order dict) ] (loop [node (get@ #root dict)] (case node @@ -94,9 +94,9 @@ (#.Some node) (let [node_key (get@ #key node)] (or (\ dict = node_key key) - ## (_\= node_key key) + ... (_\= node_key key) (if (\ dict < node_key key) - ## (_\< node_key key) + ... (_\< node_key key) (recur (get@ #left node)) (recur (get@ #right node))))))))) @@ -272,7 +272,7 @@ [(order.> (get@ #&order dict)) #right ..with_right] )) - ## (_\= reference key) + ... (_\= reference key) (#.Some (set@ #value value root)) ))) ))] diff --git a/stdlib/source/library/lux/data/collection/dictionary/plist.lux b/stdlib/source/library/lux/data/collection/dictionary/plist.lux index 10c831700..a834e3036 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux @@ -12,7 +12,7 @@ [number ["n" nat]]]]]) -## https://en.wikipedia.org/wiki/Property_list +... https://en.wikipedia.org/wiki/Property_list (type: .public (PList a) {#.doc (doc "A property list." "It's a simple dictionary-like structure with Text keys.")} diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index 1c8294dc0..1056c034b 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -19,9 +19,9 @@ [number ["n" nat]]]]]) -## (type: (List a) -## #End -## (#Item a (List a))) +... (type: (List a) +... #End +... (#Item a (List a))) (implementation: .public fold (Fold List) @@ -164,13 +164,13 @@ (let [[pre post] (split size list)] (#.Item pre (chunk size post))))) -(def: .public (repeat n x) +(def: .public (repeated n x) {#.doc "A list of the value x, repeated n times."} (All [a] (-> Nat a (List a))) - (if (n.> 0 n) - (#.Item x (repeat (dec n) x)) - #.End)) + (case n + 0 #.End + _ (#.Item x (repeated (dec n) x)))) (def: (iterations' f x) (All [a] @@ -211,7 +211,7 @@ (def: .public (all check xs) (All [a b] (-> (-> a (Maybe b)) (List a) (List b))) - (for {## TODO: Stop relying on this ASAP. + (for {... TODO: Stop relying on this ASAP. @.js (fold (function (_ head tail) (case (check head) @@ -599,7 +599,7 @@ (def: (join MlMla) (do {! monad} [lMla MlMla - ## TODO: Remove this version ASAP and use one below. + ... TODO: Remove this version ASAP and use one below. lla (for {@.old (: ((:parameter 0) (List (List (:parameter 1)))) (monad.seq ! lMla))} diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index 31c8222a2..80b454c58 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -55,17 +55,17 @@ (def: .public (pop queue) (All [a] (-> (Queue a) (Queue a))) (case (get@ #front queue) - ## Empty... + ... Empty... (^ (.list)) queue - ## Front has dried up... + ... Front has dried up... (^ (.list _)) (|> queue (set@ #front (list.reversed (get@ #rear queue))) (set@ #rear (.list))) - ## Consume front! + ... Consume front! (^ (.list& _ front')) (|> queue (set@ #front front')))) diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index 43d41cc2c..b81cb2534 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -1,6 +1,6 @@ -## https://hypirion.com/musings/understanding-persistent-vector-pt-1 -## https://hypirion.com/musings/understanding-persistent-vector-pt-2 -## https://hypirion.com/musings/understanding-persistent-vector-pt-3 +... https://hypirion.com/musings/understanding-persistent-vector-pt-1 +... https://hypirion.com/musings/understanding-persistent-vector-pt-2 +... https://hypirion.com/musings/understanding-persistent-vector-pt-3 (.module: [library [lux (#- list) @@ -100,16 +100,16 @@ (def: (with_tail size level tail parent) (All [a] (-> Nat Level (Base a) (Hierarchy a) (Hierarchy a))) (let [sub_idx (branch_idx (i64.right_shifted level (dec size))) - ## If we're currently on a bottom node + ... If we're currently on a bottom node sub_node (if (n.= branching_exponent level) - ## Just add the tail to it + ... Just add the tail to it (#Base tail) - ## Otherwise, check whether there's a vacant spot + ... Otherwise, check whether there's a vacant spot (case (array.read sub_idx parent) - ## If so, set the path to the tail + ... If so, set the path to the tail #.None (..path (level_down level) tail) - ## If not, push the tail onto the sub_node. + ... If not, push the tail onto the sub_node. (#.Some (#Hierarchy sub_node)) (#Hierarchy (with_tail size (level_down level) tail sub_node)) @@ -163,7 +163,7 @@ (array.write! sub_idx (#Hierarchy sub)) #.Some)) - ## Else... + ... Else... (|> (array.clone hierarchy) (array.delete! sub_idx) #.Some) @@ -202,20 +202,20 @@ (def: .public (add val row) (All [a] (-> a (Row a) (Row a))) - ## Check if there is room in the tail. + ... Check if there is room in the tail. (let [row_size (get@ #size row)] (if (|> row_size (n.- (tail_off row_size)) (n.< full_node_size)) - ## If so, append to it. + ... If so, append to it. (|> row (update@ #size inc) (update@ #tail (..expanded_tail val))) - ## Otherwise, push tail into the tree - ## -------------------------------------------------------- - ## Will the root experience an overflow with this addition? + ... Otherwise, push tail into the tree + ... -------------------------------------------------------- + ... Will the root experience an overflow with this addition? (|> (if (n.> (i64.left_shifted (get@ #level row) 1) (i64.right_shifted branching_exponent row_size)) - ## If so, a brand-new root must be established, that is - ## 1-level taller. + ... If so, a brand-new root must be established, that is + ... 1-level taller. (|> row (set@ #root (|> (for {@.old (: (Hierarchy (:parameter 0)) @@ -224,11 +224,11 @@ (array.write! 0 (#Hierarchy (get@ #root row))) (array.write! 1 (..path (get@ #level row) (get@ #tail row))))) (update@ #level level_up)) - ## Otherwise, just push the current tail onto the root. + ... Otherwise, just push the current tail onto the root. (|> row (update@ #root (..with_tail row_size (get@ #level row) (get@ #tail row))))) - ## Finally, update the size of the row and grow a new - ## tail with the new element as it's sole member. + ... Finally, update the size of the row and grow a new + ... tail with the new element as it's sole member. (update@ #size inc) (set@ #tail (..tail val))) ))) @@ -328,8 +328,8 @@ [#.None (#.Some (#Hierarchy sub_node))] (recur (level_down level) sub_node) - ## [#.None (#.Some (#Base _))] - ## (undefined) + ... [#.None (#.Some (#Base _))] + ... (undefined) _ [level root]) diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index 98869531f..5decabfde 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -29,11 +29,11 @@ (-> (-> a a) a (Sequence a))) (//.pending [x (iterations f (f x))])) -(def: .public (repeat x) +(def: .public (repeated x) {#.doc "Repeat a value forever."} (All [a] (-> a (Sequence a))) - (//.pending [x (repeat x)])) + (//.pending [x (repeated x)])) (def: .public (cycle [start next]) {#.doc (doc "Go over the elements of a list forever." diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index 05c02d4cf..9d7d956de 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -1,4 +1,4 @@ -## https://en.wikipedia.org/wiki/Multiset +... https://en.wikipedia.org/wiki/Multiset (.module: [library [lux (#- list) @@ -64,7 +64,7 @@ (|>> :representation dictionary.entries (list\fold (function (_ [elem multiplicity] output) - (list\compose (list.repeat multiplicity elem) output)) + (list\compose (list.repeated multiplicity elem) output)) #.End))) (template [<name> <compose>] diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index 157b6657e..207d3bc41 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -10,7 +10,7 @@ [type [abstract (#+ abstract: :abstraction :representation)]]]]) -## https://en.wikipedia.org/wiki/Finger_tree +... https://en.wikipedia.org/wiki/Finger_tree (abstract: .public (Tree @ t v) {#.doc (doc "A finger tree.")} diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index 6d7e0f9e4..874c63ee8 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -21,7 +21,7 @@ #lefts (List (Tree a)) #rights (List (Tree a))}) -## https://en.wikipedia.org/wiki/Zipper_(data_structure) +... https://en.wikipedia.org/wiki/Zipper_(data_structure) (type: .public (Zipper a) {#.doc "Tree zippers, for easy navigation and editing of trees."} {#family (Maybe (Family Zipper a)) diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux index f99dbfbd9..ef2bff638 100644 --- a/stdlib/source/library/lux/data/color.lux +++ b/stdlib/source/library/lux/data/color.lux @@ -158,11 +158,11 @@ min ($_ f.min red green blue) luminance (|> (f.+ max min) (f./ +2.0))] (if (f.= max min) - ## Achromatic + ... Achromatic [+0.0 +0.0 luminance] - ## Chromatic + ... Chromatic (let [diff (|> max (f.- min)) saturation (|> diff (f./ (if (f.> +0.5 luminance) @@ -176,7 +176,7 @@ (|> blue (f.- red) (f./ diff) (f.+ +2.0)) - ## (f.= blue max) + ... (f.= blue max) (|> red (f.- green) (f./ diff) (f.+ +4.0)))] [(|> hue' (f./ +6.0)) @@ -187,7 +187,7 @@ (-> Frac Frac Frac Nat) (let [t (cond (f.< +0.0 t) (f.+ +1.0 t) (f.> +1.0 t) (f.- +1.0 t) - ## else + ... else t) f2/3 (f./ +3.0 +2.0)] (..up (cond (f.< (f./ +6.0 +1.0) t) @@ -199,18 +199,18 @@ (f.< f2/3 t) (|> q (f.- p) (f.* (|> f2/3 (f.- t))) (f.* +6.0) (f.+ p)) - ## else + ... else p)))) (def: .public (of_hsl [hue saturation luminance]) (-> HSL Color) (if (f.= +0.0 saturation) - ## Achromatic + ... Achromatic (let [intensity (..up luminance)] (of_rgb {#red intensity #green intensity #blue intensity})) - ## Chromatic + ... Chromatic (let [q (if (f.< +0.5 luminance) (|> saturation (f.+ +1.0) (f.* luminance)) (|> luminance (f.+ saturation) (f.- (f.* saturation luminance)))) @@ -234,9 +234,9 @@ +0.0 (|> diff (f./ max)))] (if (f.= max min) - ## Achromatic + ... Achromatic [+0.0 saturation brightness] - ## Chromatic + ... Chromatic (let [hue (cond (f.= red max) (|> green (f.- blue) (f./ diff) (f.+ (if (f.< blue green) +6.0 +0.0))) @@ -245,7 +245,7 @@ (|> blue (f.- red) (f./ diff) (f.+ +2.0)) - ## (f.= blue max) + ... (f.= blue max) (|> red (f.- green) (f./ diff) (f.+ +4.0)))] [(|> hue (f./ +6.0)) @@ -311,7 +311,7 @@ (f.< +0.0 ratio) (|> ratio (f.% +1.0) (f.+ +1.0)) - ## else + ... else ratio)) (def: .public (interpolated ratio end start) @@ -361,7 +361,7 @@ luminance]))) (syntax: (color_scheme_documentation {name <code>.local_identifier}) - (let [name (text.replace_all "_" "-" name) + (let [name (text.replaced "_" "-" name) g!documentation (code.text (format "A " name " color scheme."))] (in (list (` {#.doc (.doc (~ g!documentation))}))))) @@ -410,7 +410,7 @@ (-> Spread Nat Color (List Color))) (syntax: (palette_documentation {name <code>.local_identifier}) - (let [name (text.replace_all "_" "-" name) + (let [name (text.replaced "_" "-" name) g!documentation (code.text (format "A " name " palette."))] (in (list (` {#.doc (.doc (~ g!documentation))}))))) diff --git a/stdlib/source/library/lux/data/color/named.lux b/stdlib/source/library/lux/data/color/named.lux index b64c9cbcc..7637e1514 100644 --- a/stdlib/source/library/lux/data/color/named.lux +++ b/stdlib/source/library/lux/data/color/named.lux @@ -19,7 +19,7 @@ {<blue> <code>.text} {<name> <code>.local_identifier}) (|> <name> - (text.replace_all "_" " ") + (text.replaced "_" " ") (format <red> <green> <blue> " | ") code.text list diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux index 8d8c388c5..aac550b8b 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -80,10 +80,10 @@ (<write> offset value) try.assumed)])]))] - [bits/8 /.size/8 binary.write/8] - [bits/16 /.size/16 binary.write/16] - [bits/32 /.size/32 binary.write/32] - [bits/64 /.size/64 binary.write/64] + [bits/8 /.size/8 binary.write/8!] + [bits/16 /.size/16 binary.write/16!] + [bits/32 /.size/32 binary.write/32!] + [bits/64 /.size/64 binary.write/64!] ) (def: .public (or left right) @@ -96,7 +96,7 @@ [(.inc caseS) (function (_ [offset binary]) (|> binary - (binary.write/8 offset <number>) + (binary.write/8! offset <number>) try.assumed [(.inc offset)] caseT))])]) @@ -164,10 +164,10 @@ [_ (<write> offset size binary)] (binary.copy size 0 value (n.+ <size> offset) binary)))])]))))] - [binary/8 ..bits/8 /.size/8 binary.write/8] - [binary/16 ..bits/16 /.size/16 binary.write/16] - [binary/32 ..bits/32 /.size/32 binary.write/32] - [binary/64 ..bits/64 /.size/64 binary.write/64] + [binary/8 ..bits/8 /.size/8 binary.write/8!] + [binary/16 ..bits/16 /.size/16 binary.write/16!] + [binary/32 ..bits/32 /.size/32 binary.write/32!] + [binary/64 ..bits/64 /.size/64 binary.write/64!] ) (template [<name> <binary>] @@ -207,10 +207,10 @@ [_ (<write> offset capped_count binary)] (in (mutation [(n.+ <size> offset) binary])))))])))] - [row/8 /.size/8 binary.write/8] - [row/16 /.size/16 binary.write/16] - [row/32 /.size/32 binary.write/32] - [row/64 /.size/64 binary.write/64] + [row/8 /.size/8 binary.write/8!] + [row/16 /.size/16 binary.write/16!] + [row/32 /.size/32 binary.write/32!] + [row/64 /.size/64 binary.write/64!] ) (def: .public maybe @@ -246,7 +246,7 @@ [(.inc caseS) (function (_ [offset binary]) (|> binary - (binary.write/8 offset <number>) + (binary.write/8! offset <number>) try.assumed [(.inc offset)] caseT))])]) @@ -281,7 +281,7 @@ [(.inc caseS) (function (_ [offset binary]) (|> binary - (binary.write/8 offset <number>) + (binary.write/8! offset <number>) try.assumed [(.inc offset)] caseT))])]) diff --git a/stdlib/source/library/lux/data/format/css/property.lux b/stdlib/source/library/lux/data/format/css/property.lux index de5197de3..3c9bfbb3e 100644 --- a/stdlib/source/library/lux/data/format/css/property.lux +++ b/stdlib/source/library/lux/data/format/css/property.lux @@ -53,7 +53,7 @@ Z_Index)]]) (syntax: (text_identifier {identifier s.text}) - (in (list (code.local_identifier (text.replace_all "-" "_" identifier))))) + (in (list (code.local_identifier (text.replaced "-" "_" identifier))))) (abstract: .public (Property brand) {} diff --git a/stdlib/source/library/lux/data/format/css/query.lux b/stdlib/source/library/lux/data/format/css/query.lux index 5366e1013..698938f15 100644 --- a/stdlib/source/library/lux/data/format/css/query.lux +++ b/stdlib/source/library/lux/data/format/css/query.lux @@ -22,7 +22,7 @@ Light Scripting Motion Color_Scheme)]]) (syntax: (text_identifier {identifier s.text}) - (in (list (code.local_identifier (text.replace_all "-" "_" identifier))))) + (in (list (code.local_identifier (text.replaced "-" "_" identifier))))) (abstract: .public Media {} diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index ed2d75319..b0f7aa086 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -29,7 +29,7 @@ [selector (#+ Label)]]) (syntax: (text_identifier {identifier s.text}) - (in (list (code.local_identifier (text.replace_all "-" "_" identifier))))) + (in (list (code.local_identifier (text.replaced "-" "_" identifier))))) (template: (enumeration: <abstraction> <representation> <out> <sample>+ <definition>+) (abstract: .public <abstraction> diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index 33500a7ac..bcda0d2f3 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -52,12 +52,12 @@ (def: safe {#.doc "Properly formats text to ensure no injection can happen on the HTML."} (-> Text Text) - (|>> (text.replace_all "&" "&") - (text.replace_all "<" "<") - (text.replace_all ">" ">") - (text.replace_all text.double_quote """) - (text.replace_all "'" "'") - (text.replace_all "/" "/"))) + (|>> (text.replaced "&" "&") + (text.replaced "<" "<") + (text.replaced ">" ">") + (text.replaced text.double_quote """) + (text.replaced "'" "'") + (text.replaced "/" "/"))) (def: attributes (-> Attributes Text) diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index 3f7789e70..5dd7e9c81 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -205,9 +205,9 @@ _ #0))) -############################################################ -############################################################ -############################################################ +............................................................ +............................................................ +............................................................ (def: (null_format _) (-> Null Text) @@ -233,7 +233,7 @@ (def: string_format (-> String Text) - (|>> (text.replace_all text.double_quote ..escaped_dq) + (|>> (text.replaced text.double_quote ..escaped_dq) (text.enclosed [text.double_quote text.double_quote]))) (template [<token> <name>] @@ -287,9 +287,9 @@ [#Object (..object_format format)]) )) -############################################################ -############################################################ -############################################################ +............................................................ +............................................................ +............................................................ (def: space_parser (Parser Text) diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux index 5fe9a9a9d..fba6167b9 100644 --- a/stdlib/source/library/lux/data/format/markdown.lux +++ b/stdlib/source/library/lux/data/format/markdown.lux @@ -11,25 +11,25 @@ [world [net (#+ URL)]]]]) -## https://www.markdownguide.org/basic-syntax/ +... https://www.markdownguide.org/basic-syntax/ (def: safe (-> Text Text) - (|>> (text.replace_all "\" "\\") - (text.replace_all "`" "\`") - (text.replace_all "*" "\*") - (text.replace_all "_" "\_") - (text.replace_all "{" "\{") - (text.replace_all "}" "\}") - (text.replace_all "[" "\[") - (text.replace_all "]" "\]") - (text.replace_all "(" "\(") - (text.replace_all ")" "\)") - (text.replace_all "#" "\#") - (text.replace_all "+" "\+") - (text.replace_all "-" "\-") - (text.replace_all "." "\.") - (text.replace_all "!" "\!"))) + (|>> (text.replaced "\" "\\") + (text.replaced "`" "\`") + (text.replaced "*" "\*") + (text.replaced "_" "\_") + (text.replaced "{" "\{") + (text.replaced "}" "\}") + (text.replaced "[" "\[") + (text.replaced "]" "\]") + (text.replaced "(" "\(") + (text.replaced ")" "\)") + (text.replaced "#" "\#") + (text.replaced "+" "\+") + (text.replaced "-" "\-") + (text.replaced "." "\.") + (text.replaced "!" "\!"))) (abstract: .public Span {} Any) (abstract: .public Block {} Any) diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index e60c13e05..802b7e03d 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -43,7 +43,7 @@ (let [padding_size (n.- (text.size number) max_size) padding (|> "0" - (list.repeat padding_size) + (list.repeated padding_size) (text.join_with ""))] (format padding number))) @@ -59,7 +59,7 @@ [(def: .public <limit> Nat (|> ..octal_size - (list.repeat <size>) + (list.repeated <size>) (list\fold n.* 1) inc)) @@ -236,7 +236,7 @@ (case end 0 (#try.Success (\ utf8.codec encode "")) _ (do try.monad - [last_char (binary.read/8 end string)] + [last_char (binary.read/8! end string)] (`` (case (.nat last_char) (^ (char (~~ (static ..null)))) (recur (dec end)) @@ -361,33 +361,33 @@ (def: header_size ($_ n.+ - ## name + ... name (..string ..path_size) - ## mode + ... mode (..small_number ..mode_size) - ## uid + ... uid (..small_number ..owner_id_size) - ## gid + ... gid (..small_number ..owner_id_size) - ## size + ... size (..big_number ..content_size) - ## mtime + ... mtime (..big_number ..modification_time_size) - ## chksum + ... chksum (..small_number ..checksum_size) - ## linkflag + ... linkflag ..link_flag_size - ## linkname + ... linkname (..string ..path_size) - ## magic + ... magic (..string ..magic_size) - ## uname + ... uname (..string ..name_size) - ## gname + ... gname (..string ..name_size) - ## devmajor + ... devmajor (..small_number ..device_size) - ## devminor + ... devminor (..small_number ..device_size))) (abstract: Link_Flag @@ -527,7 +527,7 @@ (def: maximum_content_size Nat (|> ..octal_size - (list.repeat ..content_size) + (list.repeated ..content_size) (list\fold n.* 1))) (abstract: .public Content @@ -651,7 +651,7 @@ (def: modification_time (-> Instant Big) (|>> instant.relative - (duration.query duration.second) + (duration.ticks duration.second) .nat ..as_big)) @@ -749,12 +749,12 @@ (def: header_padding_size (n.- header_size block_size)) -## When the checksum gets originally calculated, the assumption is that all the characters in the checksum field -## of the header will be spaces. -## This means that just calculating the checksum of the 512 bytes of the header, when reading them, would yield -## an incorrect result, as the contents of the checksum field would be an actual checksum, instead of just spaces. -## To correct for this, it is necessary to calculate the checksum of just the checksum field, subtract that, and then -## add-in the checksum of the spaces. +... When the checksum gets originally calculated, the assumption is that all the characters in the checksum field +... of the header will be spaces. +... This means that just calculating the checksum of the 512 bytes of the header, when reading them, would yield +... an incorrect result, as the contents of the checksum field would be an actual checksum, instead of just spaces. +... To correct for this, it is necessary to calculate the checksum of just the checksum field, subtract that, and then +... add-in the checksum of the spaces. (def: (expected_checksum checksum header) (-> Checksum Binary Nat) (let [|checksum| (|> checksum @@ -857,8 +857,8 @@ (\ <>.monad map (|>> #..Contiguous) (..file_parser ..contiguous)))) -## It's safe to implement the parser this way because the range of values for Nat is 2^64 -## Whereas the maximum possible value for the checksum of a 512 block is (256 × 512) = 131,072 +... It's safe to implement the parser this way because the range of values for Nat is 2^64 +... Whereas the maximum possible value for the checksum of a 512 block is (256 × 512) = 131,072 (def: end_of_archive_block_parser (Parser Any) (do <>.monad diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index 54e544583..b978eb195 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -200,11 +200,11 @@ (def: (sanitize_value input) (-> Text Text) (|> input - (text.replace_all "&" "&") - (text.replace_all "<" "<") - (text.replace_all ">" ">") - (text.replace_all "'" "'") - (text.replace_all text.double_quote """))) + (text.replaced "&" "&") + (text.replaced "<" "<") + (text.replaced ">" ">") + (text.replaced "'" "'") + (text.replaced text.double_quote """))) (def: .public (tag [namespace name]) {#.doc (doc "The text format of a XML tag.")} diff --git a/stdlib/source/library/lux/data/lazy.lux b/stdlib/source/library/lux/data/lazy.lux index 1fa45e583..9b0efc9f7 100644 --- a/stdlib/source/library/lux/data/lazy.lux +++ b/stdlib/source/library/lux/data/lazy.lux @@ -27,13 +27,13 @@ (All [a] (-> (-> [] a) (Lazy a))) (let [cache (atom.atom #.None)] (:abstraction (function (_ _) - (case (io.run (atom.read cache)) + (case (io.run (atom.read! cache)) (#.Some value) value _ (let [value (generator [])] - (exec (io.run (atom.compare_and_swap _ (#.Some value) cache)) + (exec (io.run (atom.compare_and_swap! _ (#.Some value) cache)) value))))))) (def: .public (value lazy) diff --git a/stdlib/source/library/lux/data/maybe.lux b/stdlib/source/library/lux/data/maybe.lux index a34bf2948..a019a4c79 100644 --- a/stdlib/source/library/lux/data/maybe.lux +++ b/stdlib/source/library/lux/data/maybe.lux @@ -11,9 +11,9 @@ [meta ["." location]]]]) -## (type: (Maybe a) -## #.None -## (#.Some a)) +... (type: (Maybe a) +... #.None +... (#.Some a)) (implementation: .public monoid (All [a] (Monoid (Maybe a))) diff --git a/stdlib/source/library/lux/data/name.lux b/stdlib/source/library/lux/data/name.lux index 1cc1d321c..901de118e 100644 --- a/stdlib/source/library/lux/data/name.lux +++ b/stdlib/source/library/lux/data/name.lux @@ -10,8 +10,8 @@ ["." text ("#\." equivalence monoid)] ["." product]]]]) -## (type: Name -## [Text Text]) +... (type: Name +... [Text Text]) (template [<name> <doc>] [(def: .public (<name> name) diff --git a/stdlib/source/library/lux/data/product.lux b/stdlib/source/library/lux/data/product.lux index 9a8d5da7d..91358313b 100644 --- a/stdlib/source/library/lux/data/product.lux +++ b/stdlib/source/library/lux/data/product.lux @@ -18,7 +18,7 @@ [right "The right side of a pair."] ) -## https://en.wikipedia.org/wiki/Currying +... https://en.wikipedia.org/wiki/Currying (def: .public (curry f) {#.doc (doc "Converts a 2-argument function into nested single-argument functions.")} (All [a b c] diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index f58365d66..c6a418bb7 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -22,8 +22,8 @@ {#.doc (doc "A character code number.")} Nat) -## TODO: Instead of ints, chars should be produced fron nats. -## (The JVM specifies chars as 16-bit unsigned integers) +... TODO: Instead of ints, chars should be produced fron nats. +... (The JVM specifies chars as 16-bit unsigned integers) (def: .public of_char (-> Char Text) (|>> .int "lux i64 char")) @@ -185,14 +185,14 @@ (#.Item input) list.reversed)))) -(def: .public (replace_once pattern replacement template) +(def: .public (replaced/1 pattern replacement template) (-> Text Text Text Text) (<| (maybe.else template) (do maybe.monad [[pre post] (..split_with pattern template)] (in ($_ "lux text concat" pre replacement post))))) -(def: .public (replace_all pattern replacement template) +(def: .public (replaced pattern replacement template) (-> Text Text Text Text) (for {@.old (:as Text @@ -206,14 +206,14 @@ (:as (primitive "java.lang.String") template) ["Ljava/lang/CharSequence;" (:as (primitive "java.lang.CharSequence") pattern)] ["Ljava/lang/CharSequence;" (:as (primitive "java.lang.CharSequence") replacement)])) - ## TODO: Comment/turn-off when generating a JS compiler using a JVM-based compiler because Nashorn's implementation of "replaceAll" is incorrect. + ... TODO: Comment/turn-off when generating a JS compiler using a JVM-based compiler because Nashorn's implementation of "replaceAll" is incorrect. @.js (:as Text ("js object do" "replaceAll" template [pattern replacement])) @.python (:as Text ("python object do" "replace" template pattern replacement)) - ## TODO @.lua + ... TODO @.lua @.ruby (:as Text ("ruby object do" "gsub" template pattern replacement)) @@ -221,11 +221,11 @@ (:as Text ("php apply" (:assume ("php constant" "str_replace")) pattern replacement template)) - ## TODO @.scheme - ## TODO @.common_lisp - ## TODO @.r + ... TODO @.scheme + ... TODO @.common_lisp + ... TODO @.r } - ## Inefficient default + ... Inefficient default (loop [left "" right template] (case (..split_with pattern right) @@ -278,7 +278,7 @@ "jvm object cast" (: (primitive "java.lang.Long")) (:as Nat))} - ## Platform-independent default. + ... Platform-independent default. (let [length ("lux text size" input)] (loop [index 0 hash 0] diff --git a/stdlib/source/library/lux/data/text/buffer.lux b/stdlib/source/library/lux/data/text/buffer.lux index 332504d08..2d8708c58 100644 --- a/stdlib/source/library/lux/data/text/buffer.lux +++ b/stdlib/source/library/lux/data/text/buffer.lux @@ -41,9 +41,9 @@ (push [a] a) (join [Text] Text)])) @.lua (as_is (import: (table/concat [(array.Array Text) Text] Text)) - ##https://www.lua.org/manual/5.3/manual.html#pdf-table.concat + ...https://www.lua.org/manual/5.3/manual.html#pdf-table.concat (import: (table/insert [(array.Array Text) Text] #? Nothing)) - ## https://www.lua.org/manual/5.3/manual.html#pdf-table.insert + ... https://www.lua.org/manual/5.3/manual.html#pdf-table.insert )} (as_is)))) @@ -54,7 +54,7 @@ @.jvm [Nat (-> java/lang/StringBuilder java/lang/StringBuilder)] @.js [Nat (-> (JS_Array Text) (JS_Array Text))] @.lua [Nat (-> (array.Array Text) (array.Array Text))]} - ## default + ... default (Row Text)) (def: .public empty @@ -64,7 +64,7 @@ @.jvm <jvm> @.js [0 function.identity] @.lua [0 function.identity]} - ## default + ... default row.empty)))) (def: .public (append chunk buffer) @@ -96,7 +96,7 @@ array)))] (:abstraction [(n.+ (//.size chunk) capacity) (|>> transform append!)]))} - ## default + ... default (|> buffer :representation (row.add chunk) :abstraction)))) (def: .public size @@ -106,7 +106,7 @@ @.jvm <jvm> @.js <jvm> @.lua <jvm>} - ## default + ... default (|>> :representation (row\fold (function (_ chunk total) (n.+ (//.size chunk) total)) @@ -127,7 +127,7 @@ (JS_Array::join [""]))) @.lua (let [[capacity transform] (:representation buffer)] (table/concat [(transform (array.empty 0)) ""]))} - ## default + ... default (row\fold (function (_ chunk total) (format total chunk)) "" diff --git a/stdlib/source/library/lux/data/text/encoding.lux b/stdlib/source/library/lux/data/text/encoding.lux index 7f94a8c08..673abe522 100644 --- a/stdlib/source/library/lux/data/text/encoding.lux +++ b/stdlib/source/library/lux/data/text/encoding.lux @@ -4,7 +4,7 @@ [type abstract]]]) -## https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html +... https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html (abstract: .public Encoding {} diff --git a/stdlib/source/library/lux/data/text/encoding/utf8.lux b/stdlib/source/library/lux/data/text/encoding/utf8.lux index 5892d403d..d65231922 100644 --- a/stdlib/source/library/lux/data/text/encoding/utf8.lux +++ b/stdlib/source/library/lux/data/text/encoding/utf8.lux @@ -21,14 +21,14 @@ @.js (as_is (ffi.import: Uint8Array) - ## On Node + ... On Node (ffi.import: Buffer ["#::." (#static from #as from|encode [ffi.String ffi.String] Buffer) (#static from #as from|decode [Uint8Array] Buffer) (toString [ffi.String] ffi.String)]) - ## On the browser + ... On the browser (ffi.import: TextEncoder ["#::." (new [ffi.String]) @@ -57,7 +57,7 @@ (def: php_byte_array_format "C*")) @.scheme - ## https://srfi.schemers.org/srfi-140/srfi-140.html + ... https://srfi.schemers.org/srfi-140/srfi-140.html (as_is (ffi.import: (string->utf8 [Text] Binary)) (ffi.import: (utf8->string [Binary] Text)))} (as_is))) @@ -66,10 +66,10 @@ (-> Text Binary) (for {@.old (java/lang/String::getBytes (//.name //.utf_8) - ## TODO: Remove coercion below. - ## The coercion below may seem - ## gratuitous, but removing it - ## causes a grave compilation problem. + ... TODO: Remove coercion below. + ... The coercion below may seem + ... gratuitous, but removing it + ... causes a grave compilation problem. (:as java/lang/String value)) @.jvm @@ -81,11 +81,11 @@ ffi.on_node_js? (|> (Buffer::from|encode [value "utf8"]) - ## This coercion is valid as per NodeJS's documentation: - ## https://nodejs.org/api/buffer.html#buffer_buffers_and_typedarrays + ... This coercion is valid as per NodeJS's documentation: + ... https://nodejs.org/api/buffer.html#buffer_buffers_and_typedarrays (:as Uint8Array)) - ## On the browser + ... On the browser (|> (TextEncoder::new [(//.name //.utf_8)]) (TextEncoder::encode [value])) ) @@ -128,7 +128,7 @@ (Buffer::toString ["utf8"]) #try.Success) - ## On the browser + ... On the browser (|> (TextDecoder::new [(//.name //.utf_8)]) (TextDecoder::decode [value]) #try.Success)) diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux index 7e02459e1..f7fbaaf46 100644 --- a/stdlib/source/library/lux/data/text/escape.lux +++ b/stdlib/source/library/lux/data/text/escape.lux @@ -70,19 +70,20 @@ (def: .public (escapable? char) (-> Char Bit) - (case char - (^template [<char>] - [(^ (static <char>)) - true]) - ([..\0] [..\a] [..\b] [..\t] - [..\n] [..\v] [..\f] [..\r] - [..\''] [..\\]) - - _ - (or (n.< ..ascii_bottom char) - (n.> ..ascii_top char)))) - -(def: (ascii_escape replacement pre_offset pre_limit previous current) + (or (n.< ..ascii_bottom char) + (n.> ..ascii_top char) + (case char + (^template [<char>] + [(^ (static <char>)) + true]) + ([..\0] [..\a] [..\b] [..\t] + [..\n] [..\v] [..\f] [..\r] + [..\''] [..\\]) + + _ + false))) + +(def: (ascii_escaped replacement pre_offset pre_limit previous current) (-> Text Nat Nat Text Text [Text Text Nat]) (let [post_offset (inc pre_offset) post_limit (n.- post_offset pre_limit)] @@ -92,7 +93,7 @@ ("lux text clip" post_offset post_limit current) post_limit])) -(def: (unicode_escape char pre_offset pre_limit previous current) +(def: (unicode_escaped char pre_offset pre_limit previous current) (-> Char Nat Nat Text Text [Text Text Nat]) (let [code (\ n.hex encode char) replacement (format ..sigil "u" @@ -109,7 +110,7 @@ ("lux text clip" post_offset post_limit current) post_limit])) -(def: .public (escape text) +(def: .public (escaped text) {#.doc (doc "Yields a escaped version of the text.")} (-> Text Text) (loop [offset 0 @@ -120,7 +121,7 @@ (case ("lux text char" offset current) (^template [<char> <replacement>] [(^ (static <char>)) - (let [[previous' current' limit'] (ascii_escape <replacement> offset limit previous current)] + (let [[previous' current' limit'] (ascii_escaped <replacement> offset limit previous current)] (recur 0 previous' current' limit'))]) ([..\0 ..escaped_\0] [..\a ..escaped_\a] @@ -136,7 +137,7 @@ char (if (or (n.< ..ascii_bottom char) (n.> ..ascii_top char)) - (let [[previous' current' limit'] (unicode_escape char offset limit previous current)] + (let [[previous' current' limit'] (unicode_escaped char offset limit previous current)] (recur 0 previous' current' limit')) (recur (inc offset) previous current limit))) (format previous current)))) @@ -166,7 +167,7 @@ (def: unicode_escape_offset (n.+ ..ascii_escape_offset ..code_size)) -(def: (ascii_un_escape replacement offset previous current limit) +(def: (ascii_un_escaped replacement offset previous current limit) (-> Text Nat Text Text Nat [Text Text Nat]) (let [limit' (|> limit (n.- offset) (n.- ..ascii_escape_offset))] [(format previous @@ -175,7 +176,7 @@ ("lux text clip" (n.+ ..ascii_escape_offset offset) limit' current) limit'])) -(def: (unicode_un_escape offset previous current limit) +(def: (unicode_un_escaped offset previous current limit) (-> Nat Text Text Nat (Try [Text Text Nat])) (case (|> current ("lux text clip" (n.+ ..ascii_escape_offset offset) ..code_size) @@ -191,7 +192,7 @@ (#try.Failure error) (exception.except ..invalid_unicode_escape [current offset]))) -(def: .public (un_escape text) +(def: .public (un_escaped text) {#.doc (doc "Yields an un-escaped text." "Fails if it was improperly escaped.")} (-> Text (Try Text)) @@ -207,7 +208,7 @@ (case ("lux text char" @sigil current) (^template [<sigil> <un_escaped>] [(^ (static <sigil>)) - (let [[previous' current' limit'] (..ascii_un_escape <un_escaped> offset previous current limit)] + (let [[previous' current' limit'] (..ascii_un_escaped <un_escaped> offset previous current limit)] (recur 0 previous' current' limit'))]) ([..\0_sigil //.\0] [..\a_sigil //.\a] @@ -224,7 +225,7 @@ (let [@unicode (n.+ code_size @sigil)] (if (n.< limit @unicode) (do try.monad - [[previous' current' limit'] (..unicode_un_escape offset previous current limit)] + [[previous' current' limit'] (..unicode_un_escaped offset previous current limit)] (recur 0 previous' current' limit')) (exception.except ..invalid_unicode_escape [text offset]))) @@ -238,9 +239,9 @@ "" current _ (format previous current)))))) -(syntax: .public (escaped {literal <code>.text}) +(syntax: .public (literal {literal <code>.text}) {#.doc (doc "If given a escaped text literal, expands to an un-escaped version.")} - (case (..un_escape literal) + (case (..un_escaped literal) (#try.Success un_escaped) (in (list (code.text un_escaped))) diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index defbaf3e1..ff9f48eee 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -225,7 +225,7 @@ "*" (in (` ((~! join_text^) ((~! <>.some) (~ base))))) - ## "+" + ... "+" _ (in (` ((~! join_text^) ((~! <>.many) (~ base))))) ))) diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux index e1a4a4de6..e9c1298fe 100644 --- a/stdlib/source/library/lux/data/text/unicode/block.lux +++ b/stdlib/source/library/lux/data/text/unicode/block.lux @@ -81,7 +81,7 @@ (..end value)))) (syntax: (block_name {name <code>.local_identifier}) - (in (list (code.text (///.replace_all "_" " " name))))) + (in (list (code.text (///.replaced "_" " " name))))) (template [<name> <start> <end>] [(with_expansions [<block_name> (..block_name <name>) @@ -93,7 +93,7 @@ end (hex <end>)] (..block start (n.- start end)))))] - ## Normal blocks + ... Normal blocks [basic_latin "0000" "007F"] [latin_1_supplement "00A0" "00FF"] [latin_extended_a "0100" "017F"] @@ -199,25 +199,25 @@ [arabic_presentation_forms_b "FE70" "FEFF"] [halfwidth_and_fullwidth_forms "FF00" "FFEF"] [specials "FFF0" "FFFF"] - ## [linear_b_syllabary "10000" "1007F"] - ## [linear_b_ideograms "10080" "100FF"] - ## [aegean_numbers "10100" "1013F"] - ## [old_italic "10300" "1032F"] - ## [gothic "10330" "1034F"] - ## [ugaritic "10380" "1039F"] - ## [deseret "10400" "1044F"] - ## [shavian "10450" "1047F"] - ## [osmanya "10480" "104AF"] - ## [cypriot_syllabary "10800" "1083F"] - ## [byzantine_musical_symbols "1D000" "1D0FF"] - ## [musical_symbols "1D100" "1D1FF"] - ## [tai_xuan_jing_symbols "1D300" "1D35F"] - ## [mathematical_alphanumeric_symbols "1D400" "1D7FF"] - ## [cjk_unified_ideographs_extension_b "20000" "2A6DF"] - ## [cjk_compatibility_ideographs_supplement "2F800" "2FA1F"] - ## [tags "E0000" "E007F"] + ... [linear_b_syllabary "10000" "1007F"] + ... [linear_b_ideograms "10080" "100FF"] + ... [aegean_numbers "10100" "1013F"] + ... [old_italic "10300" "1032F"] + ... [gothic "10330" "1034F"] + ... [ugaritic "10380" "1039F"] + ... [deseret "10400" "1044F"] + ... [shavian "10450" "1047F"] + ... [osmanya "10480" "104AF"] + ... [cypriot_syllabary "10800" "1083F"] + ... [byzantine_musical_symbols "1D000" "1D0FF"] + ... [musical_symbols "1D100" "1D1FF"] + ... [tai_xuan_jing_symbols "1D300" "1D35F"] + ... [mathematical_alphanumeric_symbols "1D400" "1D7FF"] + ... [cjk_unified_ideographs_extension_b "20000" "2A6DF"] + ... [cjk_compatibility_ideographs_supplement "2F800" "2FA1F"] + ... [tags "E0000" "E007F"] - ## Specialized blocks + ... Specialized blocks [basic_latin/decimal "0030" "0039"] [basic_latin/upper "0041" "005A"] [basic_latin/lower "0061" "007A"] diff --git a/stdlib/source/library/lux/data/text/unicode/set.lux b/stdlib/source/library/lux/data/text/unicode/set.lux index ab5d978b6..ab3c1672b 100644 --- a/stdlib/source/library/lux/data/text/unicode/set.lux +++ b/stdlib/source/library/lux/data/text/unicode/set.lux @@ -176,23 +176,23 @@ //block.arabic_presentation_forms_b //block.halfwidth_and_fullwidth_forms //block.specials - ## //block.linear_b_syllabary - ## //block.linear_b_ideograms - ## //block.aegean_numbers - ## //block.old_italic - ## //block.gothic - ## //block.ugaritic - ## //block.deseret - ## //block.shavian - ## //block.osmanya - ## //block.cypriot_syllabary - ## //block.byzantine_musical_symbols - ## //block.musical_symbols - ## //block.tai_xuan_jing_symbols - ## //block.mathematical_alphanumeric_symbols - ## //block.cjk_unified_ideographs_extension_b - ## //block.cjk_compatibility_ideographs_supplement - ## //block.tags + ... //block.linear_b_syllabary + ... //block.linear_b_ideograms + ... //block.aegean_numbers + ... //block.old_italic + ... //block.gothic + ... //block.ugaritic + ... //block.deseret + ... //block.shavian + ... //block.osmanya + ... //block.cypriot_syllabary + ... //block.byzantine_musical_symbols + ... //block.musical_symbols + ... //block.tai_xuan_jing_symbols + ... //block.mathematical_alphanumeric_symbols + ... //block.cjk_unified_ideographs_extension_b + ... //block.cjk_compatibility_ideographs_supplement + ... //block.tags )])) (def: .public full diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index cc09e996e..235528c6b 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -209,7 +209,7 @@ (Array::isArray value) (tuple_inspection inspection value) - ## else + ... else (JSON::stringify value))) _ @@ -317,7 +317,7 @@ (is? (class_of [[] []]) value_class) (tuple_inspection inspection value) - ## else + ... else (to_s value))))) @.php @@ -373,7 +373,7 @@ (text.enclosed ["(" ")"]))) (..format ["~s" value]))) - ## else + ... else (..format ["~s" value]) )) }))) @@ -565,8 +565,8 @@ locals meta.locals .let [environment (|> locals list.concat - ## The list is reversed to make sure that, when building the dictionary, - ## later bindings overshadow earlier ones if they have the same name. + ... The list is reversed to make sure that, when building the dictionary, + ... later bindings overshadow earlier ones if they have the same name. list.reversed (dictionary.of_list text.hash))] targets (: (Meta (List Target)) diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux index 069e38123..9cd8c739c 100644 --- a/stdlib/source/library/lux/ffi.js.lux +++ b/stdlib/source/library/lux/ffi.js.lux @@ -240,13 +240,13 @@ (let [qualify (: (-> Text Code) (function (_ member_name) (|> format - (text.replace_all "#" class_name) - (text.replace_all "." member_name) + (text.replaced "#" class_name) + (text.replaced "." member_name) code.local_identifier))) class_parameters (list\map code.local_identifier class_parameters) declaration (` ((~ (code.local_identifier class_name)) (~+ class_parameters))) - real_class (text.replace_all "/" "." class_name)] + real_class (text.replaced "/" "." class_name)] (in (list& (` (type: (~ declaration) (..Object (primitive (~ (code.text real_class)))))) (list\map (function (_ member) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index bda7e8484..70eafbd8d 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -74,7 +74,7 @@ .Type (#.Primitive (reflection.reflection <class>) #.End))] - ## Primitives + ... Primitives [boolean reflection.boolean] [byte reflection.byte] [short reflection.short] @@ -322,7 +322,7 @@ (\ type.equivalence = type.float type) (` ..Float) (\ type.equivalence = type.double type) (` ..Double) (\ type.equivalence = type.char type) (` ..Character) - ## else + ... else (undefined)) #AutoPrM @@ -342,7 +342,7 @@ (\ type.equivalence = type.char type) (` .Nat) - ## else + ... else (undefined)))) (def: (parameter_type type) @@ -361,7 +361,7 @@ [parser.class? [name parameters] (` (.primitive (~ (code.text name)) [(~+ (list\map parameter_type parameters))]))])) - ## else + ... else (undefined) ))) @@ -1213,11 +1213,11 @@ {#.doc (doc "Allows defining JVM classes in Lux code." "For example:" (class: #final (TestClass A) [Runnable] - ## Fields + ... Fields (#private foo boolean) (#private bar A) (#private baz java/lang/Object) - ## Methods + ... Methods (#public [] (new [value A]) [] (exec (:= ::foo #1) @@ -1449,7 +1449,7 @@ (get@ #import_member_maybe? commons) (` (??? (~ return_term))) - ## else + ... else (let [g!temp (` ((~' ~') (~ (code.identifier ["" " Ω "]))))] (` (let [(~ g!temp) (~ return_term)] (if (not (..null? (:as (primitive "java.lang.Object") @@ -1498,7 +1498,7 @@ <special+>')] (cond <cond_cases> - ## else + ... else [unboxed (if <input?> (` ("jvm object cast" (~ raw))) @@ -1562,8 +1562,8 @@ (def: (import_name format class member) (-> Text Text Text Text) (|> format - (text.replace_all "#" class) - (text.replace_all "." member))) + (text.replaced "#" class) + (text.replaced "." member))) (def: (member_def_interop vars kind class [arg_function_inputs input_jvm_types arg_types] member method_prefix import_format) (-> (List (Type Var)) Class_Kind (Type Declaration) [(List [Bit Code]) (List (Type Value)) (List Code)] Import_Member_Declaration Text Text (Meta (List Code))) @@ -1824,7 +1824,7 @@ [type.float "jvm array new float"] [type.double "jvm array new double"] [type.char "jvm array new char"])) - ## else + ... else (in (list (` (: (~ (value_type #ManualPrM (type.array type))) ("jvm array new object" (~ g!size)))))))))) @@ -1894,7 +1894,7 @@ _ <failure>) - ## else + ... else (\ meta.monad map (type.class name) (: (Meta (List (Type Parameter))) (monad.map meta.monad @@ -1946,7 +1946,7 @@ [type.double "jvm array length double"] [type.char "jvm array length char"])) - ## else + ... else "jvm array length object")))]] (in (list (` (.|> ((~ g!extension) (~ array)) "jvm conversion int-to-long" @@ -1989,7 +1989,7 @@ [type.double "jvm array read double" box.double] [type.char "jvm array read char" box.char])) - ## else + ... else (in (list (` ("jvm array read object" (~ g!idx) (~ array)))))))) _ @@ -2028,7 +2028,7 @@ [type.double "jvm array write double" box.double] [type.char "jvm array write char" box.char])) - ## else + ... else (in (list (` ("jvm array write object" (~ g!idx) (~ value) (~ array)))))))) _ diff --git a/stdlib/source/library/lux/ffi.lua.lux b/stdlib/source/library/lux/ffi.lua.lux index fc6266d78..a0ee4ab01 100644 --- a/stdlib/source/library/lux/ffi.lua.lux +++ b/stdlib/source/library/lux/ffi.lua.lux @@ -220,11 +220,11 @@ (let [qualify (: (-> Text Code) (function (_ member_name) (|> format - (text.replace_all "#" class) - (text.replace_all "." member_name) + (text.replaced "#" class) + (text.replaced "." member_name) code.local_identifier))) g!type (code.local_identifier class) - real_class (text.replace_all "/" "." class) + real_class (text.replaced "/" "." class) imported (case (text.split_all_with "/" class) (#.Item head tail) (list\fold (function (_ sub super) @@ -289,7 +289,7 @@ (#Function [name alias inputsT io? try? outputT]) (in (list (..make_function (code.local_identifier (maybe.else name alias)) g!temp - (` ("lua constant" (~ (code.text (text.replace_all "/" "." name))))) + (` ("lua constant" (~ (code.text (text.replaced "/" "." name))))) inputsT io? try? @@ -299,7 +299,7 @@ (in (list (` ((~! syntax:) ((~ (code.local_identifier name))) (\ (~! meta.monad) (~' in) (list (` (.:as (~ (nilable_type fieldT)) - ("lua constant" (~ (code.text (text.replace_all "/" "." name)))))))))))) + ("lua constant" (~ (code.text (text.replaced "/" "." name)))))))))))) ))) (template: .public (closure <inputs> <output>) diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index d81d48c39..8c20e8ae2 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -65,11 +65,11 @@ [char_to_long "jvm convert char-to-long" "java.lang.Character" "java.lang.Long"] ) -## [Utils] +... [Utils] (def: constructor_method_name "<init>") (def: member_separator "::") -## Types +... Types (type: JVM_Code Text) (type: BoundKind @@ -226,7 +226,7 @@ (#MethodDecl [ImportMethodCommons ImportMethodDecl]) (#FieldAccessDecl ImportFieldDecl)) -## Utils +... Utils (def: (manual_primitive_type class) (-> Text (Maybe Code)) (case class @@ -266,7 +266,7 @@ (def: safe (-> Text Text) - (text.replace_all "/" ".")) + (text.replaced "/" ".")) (def: (generic_class_type' mode type_params in_array? name+params class_type') @@ -500,7 +500,7 @@ (#NativeMethod type_vars args return_type exs) (virtual_method_parser params class_name method_name args))) -## Parsers +... Parsers (def: privacy_modifier^ (Parser Privacy) (let [(^open ".") <>.monad] @@ -938,7 +938,7 @@ (<>.and <code>.text) <code>.tuple)) -## Generators +... Generators (def: with_parens (-> JVM_Code JVM_Code) (text.enclosed ["(" ")"])) @@ -1159,7 +1159,7 @@ (-> Code Partial_Call Code) (` ((~ (code.identifier method)) (~+ args) (~ g!obj)))) -## [Syntax] +... [Syntax] (def: object_super_class Super_Class_Decl {#super_class_name "java/lang/Object" @@ -1180,11 +1180,11 @@ {#.doc (doc "Allows defining JVM classes in Lux code." "For example:" (class: #final (TestClass A) [Runnable] - ## Fields + ... Fields (#private foo boolean) (#private bar A) (#private baz java/lang/Object) - ## Methods + ... Methods (#public [] (new [value A]) [] (exec (:= ::foo #1) (:= ::bar value) @@ -1489,8 +1489,8 @@ (def: (import_name format class member) (-> Text Text Text Text) (|> format - (text.replace_all "#" class) - (text.replace_all "." member))) + (text.replaced "#" class) + (text.replaced "." member))) (def: (member_def_interop type_params kind class [arg_function_inputs arg_classes arg_types] member method_prefix import_format) (-> (List Type_Parameter) Class_Kind Class_Declaration [(List [Bit Code]) (List Text) (List Code)] Import_Member_Declaration Text Text (Meta (List Code))) diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux index 114dfce7b..1097cacf5 100644 --- a/stdlib/source/library/lux/ffi.php.lux +++ b/stdlib/source/library/lux/ffi.php.lux @@ -240,8 +240,8 @@ (let [qualify (: (-> Text Code) (function (_ member_name) (|> format - (text.replace_all "#" (maybe.else class alias)) - (text.replace_all "." member_name) + (text.replaced "#" (maybe.else class alias)) + (text.replaced "." member_name) code.local_identifier))) g!type (code.local_identifier (maybe.else class alias)) class_import (` ("php constant" (~ (code.text class))))] diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux index d1a81dc6a..8878c85a2 100644 --- a/stdlib/source/library/lux/ffi.py.lux +++ b/stdlib/source/library/lux/ffi.py.lux @@ -220,11 +220,11 @@ (let [qualify (: (-> Text Code) (function (_ member_name) (|> format - (text.replace_all "#" class) - (text.replace_all "." member_name) + (text.replaced "#" class) + (text.replaced "." member_name) code.local_identifier))) g!type (code.local_identifier class) - real_class (text.replace_all "/" "." class) + real_class (text.replaced "/" "." class) imported (case (text.split_all_with "/" class) (#.Item head tail) (list\fold (function (_ sub super) diff --git a/stdlib/source/library/lux/ffi.rb.lux b/stdlib/source/library/lux/ffi.rb.lux index dfb8aabc4..26fea6c27 100644 --- a/stdlib/source/library/lux/ffi.rb.lux +++ b/stdlib/source/library/lux/ffi.rb.lux @@ -233,8 +233,8 @@ (let [qualify (: (-> Text Code) (function (_ member_name) (|> format - (text.replace_all "#" (maybe.else class alias)) - (text.replace_all "." member_name) + (text.replaced "#" (maybe.else class alias)) + (text.replaced "." member_name) code.local_identifier))) g!type (code.local_identifier (maybe.else class alias)) module_import (: (List Code) diff --git a/stdlib/source/library/lux/locale/language.lux b/stdlib/source/library/lux/locale/language.lux index cf6b38e99..7204c4823 100644 --- a/stdlib/source/library/lux/locale/language.lux +++ b/stdlib/source/library/lux/locale/language.lux @@ -11,7 +11,7 @@ [macro ["." template]]]]) -## https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes +... https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes (abstract: .public Language {#.doc (doc "An ISO 639 language.")} diff --git a/stdlib/source/library/lux/locale/territory.lux b/stdlib/source/library/lux/locale/territory.lux index 862c10bb6..279cb1148 100644 --- a/stdlib/source/library/lux/locale/territory.lux +++ b/stdlib/source/library/lux/locale/territory.lux @@ -11,7 +11,7 @@ [macro ["." template]]]]) -## https://en.wikipedia.org/wiki/ISO_3166-1 +... https://en.wikipedia.org/wiki/ISO_3166-1 (abstract: .public Territory {#.doc (doc "An ISO 3166 territory.")} diff --git a/stdlib/source/library/lux/macro/code.lux b/stdlib/source/library/lux/macro/code.lux index 916e82dee..7e09ceb96 100644 --- a/stdlib/source/library/lux/macro/code.lux +++ b/stdlib/source/library/lux/macro/code.lux @@ -19,21 +19,21 @@ [meta ["." location]]]]) -## (type: (Code' w) -## (#.Bit Bit) -## (#.Nat Nat) -## (#.Int Int) -## (#.Rev Rev) -## (#.Frac Frac) -## (#.Text Text) -## (#.Identifier Name) -## (#.Tag Name) -## (#.Form (List (w (Code' w)))) -## (#.Tuple (List (w (Code' w)))) -## (#.Record (List [(w (Code' w)) (w (Code' w))]))) - -## (type: Code -## (Ann Location (Code' (Ann Location)))) +... (type: (Code' w) +... (#.Bit Bit) +... (#.Nat Nat) +... (#.Int Int) +... (#.Rev Rev) +... (#.Frac Frac) +... (#.Text Text) +... (#.Identifier Name) +... (#.Tag Name) +... (#.Form (List (w (Code' w)))) +... (#.Tuple (List (w (Code' w)))) +... (#.Record (List [(w (Code' w)) (w (Code' w))]))) + +... (type: Code +... (Ann Location (Code' (Ann Location)))) (template [<name> <type> <tag>] [(def: .public (<name> x) @@ -139,7 +139,7 @@ "}") )) -(def: .public (replace original substitute ast) +(def: .public (replaced original substitute ast) {#.doc "Replaces all code that looks like the 'original' with the 'substitute'."} (-> Code Code Code Code) (if (\ ..equivalence = original ast) @@ -147,14 +147,14 @@ (case ast (^template [<tag>] [[location (<tag> parts)] - [location (<tag> (list\map (replace original substitute) parts))]]) + [location (<tag> (list\map (replaced original substitute) parts))]]) ([#.Form] [#.Tuple]) [location (#.Record parts)] [location (#.Record (list\map (function (_ [left right]) - [(replace original substitute left) - (replace original substitute right)]) + [(replaced original substitute left) + (replaced original substitute right)]) parts))] _ diff --git a/stdlib/source/library/lux/macro/syntax/export.lux b/stdlib/source/library/lux/macro/syntax/export.lux index 03f96a2a0..56ee91491 100644 --- a/stdlib/source/library/lux/macro/syntax/export.lux +++ b/stdlib/source/library/lux/macro/syntax/export.lux @@ -6,17 +6,11 @@ ["<>" parser ("#\." monad) ["<.>" code (#+ Parser)]]]]]) -(def: token - (' #export)) +(def: .public default_policy + Code + (` .private)) -(def: .public (format exported?) - (-> Bit (List Code)) - (if exported? - (list ..token) - (list))) - -(def: .public parser - (Parser Bit) - (<>.either (<>.after (<code>.this! ..token) - (<>\in true)) - (<>\in false))) +(def: .public (parser un_exported) + (All [a] (-> (Parser a) (Parser [Code a]))) + (<>.either (<>.and <code>.any un_exported) + (<>.and (<>\in ..default_policy) un_exported))) diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index 8a7c9feff..7f19f1a85 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -13,9 +13,9 @@ <value>)] [e +2.7182818284590452354 "The base of the natural logarithm."] - ## ["π is wrong!" by Bob Palais](https://www.math.utah.edu/~palais/pi.html) + ... ["π is wrong!" by Bob Palais](https://www.math.utah.edu/~palais/pi.html) [pi +3.14159265358979323846 "The ratio of a circle's circumference to its diameter."] - ## [The Tau Manifesto](https://tauday.com/tau-manifesto) + ... [The Tau Manifesto](https://tauday.com/tau-manifesto) [tau +6.28318530717958647692 "The ratio of a circle's circumference to its radius."] ) @@ -295,7 +295,7 @@ ("lux f64 <" -0.5 diff) ("lux f64 +" -1.0 floored) - ## else + ... else floored))) (def: .public (atan/2 x y) @@ -309,14 +309,14 @@ (|> y ("lux f64 /" x) atan ("lux f64 +" pi)) (|> y ("lux f64 /" x) atan ("lux f64 -" pi))) - ## ("lux f64 =" +0.0 x) + ... ("lux f64 =" +0.0 x) (cond ("lux f64 <" y +0.0) (|> pi ("lux f64 /" +2.0)) ("lux f64 <" +0.0 y) (|> pi ("lux f64 /" -2.0)) - ## ("lux f64 =" +0.0 y) + ... ("lux f64 =" +0.0 y) ("lux f64 /" +0.0 +0.0)))) (def: .public (log' base input) @@ -339,8 +339,8 @@ (..pow +2.0 catA) (..pow +2.0 catB)))) -## Hyperbolic functions -## https://en.wikipedia.org/wiki/Hyperbolic_function#Definitions +... Hyperbolic functions +... https://en.wikipedia.org/wiki/Hyperbolic_function#Definitions (template [<name> <comp> <inverse>] [(def: .public (<name> x) (-> Frac Frac) @@ -367,7 +367,7 @@ [coth cosh' sinh'] ) -## https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions#Definitions_in_terms_of_logarithms +... https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions#Definitions_in_terms_of_logarithms (template [<name> <comp>] [(def: .public (<name> x) (-> Frac Frac) diff --git a/stdlib/source/library/lux/math/logic/continuous.lux b/stdlib/source/library/lux/math/logic/continuous.lux index 691890917..0d36f9968 100644 --- a/stdlib/source/library/lux/math/logic/continuous.lux +++ b/stdlib/source/library/lux/math/logic/continuous.lux @@ -1,4 +1,4 @@ -## https://en.wikipedia.org/wiki/Many-valued_logic +... https://en.wikipedia.org/wiki/Many-valued_logic (.module: {#.doc (.doc "Continuous logic using Rev values." "Continuous logic is logic in the interval [0,1] instead of just the binary #0 and #1 options." diff --git a/stdlib/source/library/lux/math/logic/fuzzy.lux b/stdlib/source/library/lux/math/logic/fuzzy.lux index d36b7cfd2..9e8e1835c 100644 --- a/stdlib/source/library/lux/math/logic/fuzzy.lux +++ b/stdlib/source/library/lux/math/logic/fuzzy.lux @@ -1,4 +1,4 @@ -## https://en.wikipedia.org/wiki/Fuzzy_logic +... https://en.wikipedia.org/wiki/Fuzzy_logic (.module: {#.doc (.doc "Fuzzy logic, implemented on top of the Rev type.")} [library @@ -81,16 +81,16 @@ (let [measure (/.- from to)] (function (_ elem) (cond (/.< from elem) - ## below + ... below //.false (/.< to elem) - ## in the middle... + ... in the middle... (|> elem (/.- from) (/./ measure)) - ## above + ... above //.true)))) (def: (descending from to) diff --git a/stdlib/source/library/lux/math/number.lux b/stdlib/source/library/lux/math/number.lux index d1e8144ab..0aba205b5 100644 --- a/stdlib/source/library/lux/math/number.lux +++ b/stdlib/source/library/lux/math/number.lux @@ -43,7 +43,7 @@ (def: without_separators (-> Text Text) - (text.replace_all ..separator "")) + (text.replaced ..separator "")) (template [<macro> <nat> <int> <rev> <frac> <error> <doc>] [(macro: .public (<macro> tokens state) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index 729d9b5b7..977c5a8b7 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -91,7 +91,7 @@ (-> Frac Frac) (cond (..= +0.0 x) +0.0 (..< +0.0 x) -1.0 - ## else + ... else +1.0)) (def: min_exponent -1022) @@ -261,12 +261,12 @@ (..= +0.0 input) (let [reciprocal (../ input +1.0)] (if (..= positive_infinity reciprocal) - ## Positive zero + ... Positive zero ..positive_zero_bits - ## Negative zero + ... Negative zero ..negative_zero_bits)) - ## else + ... else (let [sign_bit (if (..< -0.0 input) 1 0) @@ -324,9 +324,9 @@ (^ [(static ..special_exponent_bits) _ _]) ..not_a_number - ## Positive zero + ... Positive zero [0 0 0] +0.0 - ## Negative zero + ... Negative zero [0 0 1] (..* -1.0 +0.0) [E M S] diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index c6b8a69d8..4f44826f9 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -35,7 +35,7 @@ [Nat right_shifted "lux i64 right-shift" "Unsigned/logic bitwise right-shift."] ) -## https://en.wikipedia.org/wiki/Mask_(computing) +... https://en.wikipedia.org/wiki/Mask_(computing) (type: .public Mask {#.doc (doc "A pattern of bits that can be imposed on I64 values.")} I64) diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index dbef9c89c..afe1e7745 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -106,10 +106,10 @@ (-> Int Int) (cond (..= +0 x) +0 (..< +0 x) -1 - ## else + ... else +1)) -## https://rob.conery.io/2018/08/21/mod-and-remainder-are-not-the-same/ +... https://rob.conery.io/2018/08/21/mod-and-remainder-are-not-the-same/ (def: .public (mod divisor dividend) {#.doc (doc "Integer modulo." "Note: The modulo and the remainder are not the same.")} @@ -130,7 +130,7 @@ (-> Int Bit) (|>> ..even? not)) -## https://en.wikipedia.org/wiki/Greatest_common_divisor +... https://en.wikipedia.org/wiki/Greatest_common_divisor (def: .public (gcd a b) {#.doc "Greatest Common Divisor."} (-> Int Int Int) @@ -142,7 +142,7 @@ (-> Int Int Bit) (..= +1 (..gcd a b))) -## https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm +... https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm (def: .public (extended_gcd a b) {#.doc "Extended euclidean algorithm."} (-> Int Int [[Int Int] Int]) @@ -156,7 +156,7 @@ y1 (- (* q y1) y) b1 (- (* q b1) a1)))))) -## https://en.wikipedia.org/wiki/Least_common_multiple +... https://en.wikipedia.org/wiki/Least_common_multiple (def: .public (lcm a b) {#.doc "Least Common Multiple."} (-> Int Int Int) @@ -189,18 +189,18 @@ (def: succ inc) (def: pred dec)) -## TODO: Find out why the numeric literals fail during JS compilation. +... TODO: Find out why the numeric literals fail during JS compilation. (implementation: .public interval (Interval Int) (def: &enum ..enum) (def: top - ## +9,223,372,036,854,775,807 + ... +9,223,372,036,854,775,807 (let [half (//i64.left_shifted 62 +1)] (+ half (dec half)))) (def: bottom - ## -9,223,372,036,854,775,808 + ... -9,223,372,036,854,775,808 (//i64.left_shifted 63 +1))) (template [<name> <compose> <identity>] diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index dadb71641..917f2ad72 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -275,16 +275,16 @@ [hex //nat.hex 4 "Invalid hexadecimal syntax: "] ) -## The following code allows one to encode/decode Rev numbers as text. -## This is not a simple algorithm, and it requires subverting the Rev -## abstraction a bit. -## It takes into account the fact that Rev numbers are represented by -## Lux as 64-bit integers. -## A valid way to model them is as Lux's Nat type. -## This is a somewhat hackish way to do things, but it allows one to -## write the encoding/decoding algorithm once, in pure Lux, rather -## than having to implement it on the compiler for every platform -## targeted by Lux. +... The following code allows one to encode/decode Rev numbers as text. +... This is not a simple algorithm, and it requires subverting the Rev +... abstraction a bit. +... It takes into account the fact that Rev numbers are represented by +... Lux as 64-bit integers. +... A valid way to model them is as Lux's Nat type. +... This is a somewhat hackish way to do things, but it allows one to +... write the encoding/decoding algorithm once, in pure Lux, rather +... than having to implement it on the compiler for every platform +... targeted by Lux. (type: Digits (Array Nat)) @@ -449,7 +449,7 @@ (if (//nat.< //i64.width idx) (let [power (power_digits idx)] (if (digits\< power digits) - ## Skip power + ... Skip power (recur digits (inc idx) output) (recur (digits\-! power digits) (inc idx) diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index a0f8f66a1..a6dbe75d4 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -382,8 +382,8 @@ (i64.left_rotated 36 s01)])) ("lux i64 +" s0 s1)])) -## https://en.wikipedia.org/wiki/Xorshift#Initialization -## http://xorshift.di.unimi.it/splitmix64.c +... https://en.wikipedia.org/wiki/Xorshift#Initialization +... http://xorshift.di.unimi.it/splitmix64.c (def: .public split_mix_64 {#.doc (doc "An implementation of the SplitMix64 algorithm.")} (-> Nat PRNG) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index c3b66e3fc..f966b9d9f 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -26,8 +26,8 @@ [/ ["." location]]) -## (type: (Meta a) -## (-> Lux (Try [Lux a]))) +... (type: (Meta a) +... (-> Lux (Try [Lux a]))) (implementation: .public functor (Functor Meta) diff --git a/stdlib/source/library/lux/target.lux b/stdlib/source/library/lux/target.lux index c2da2412f..a040fe442 100644 --- a/stdlib/source/library/lux/target.lux +++ b/stdlib/source/library/lux/target.lux @@ -10,15 +10,15 @@ Target <value>)] - ## TODO: Delete ASAP. + ... TODO: Delete ASAP. [old "{old}"] - ## Available. + ... Available. [js "JavaScript"] [jvm "JVM"] [lua "Lua"] [python "Python"] [ruby "Ruby"] - ## Not available yet. + ... Not available yet. [common_lisp "Common Lisp"] [php "PHP"] [r "R"] diff --git a/stdlib/source/library/lux/target/common_lisp.lux b/stdlib/source/library/lux/target/common_lisp.lux index 3bd089fa6..b57326480 100644 --- a/stdlib/source/library/lux/target/common_lisp.lux +++ b/stdlib/source/library/lux/target/common_lisp.lux @@ -95,7 +95,7 @@ [f.not_a_number?] [(new> "(/ 0.0 0.0)" [])] - ## else + ... else [%.frac]) :abstraction)) @@ -111,16 +111,16 @@ (f.not_a_number? value) "(/ 0.0d0 0.0d0)" - ## else + ... else (.let [raw (%.frac value)] (.if (text.contains? "E" raw) - (text.replace_once "E" "d" raw) + (text.replaced/1 "E" "d" raw) (format raw "d0")))))) (def: safe (-> Text Text) (`` (|>> (~~ (template [<find> <replace>] - [(text.replace_all <find> <replace>)] + [(text.replaced <find> <replace>)] ["\" "\\"] [text.tab "\t"] diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux index 27e77e1fd..2e3d62147 100644 --- a/stdlib/source/library/lux/target/js.lux +++ b/stdlib/source/library/lux/target/js.lux @@ -26,7 +26,7 @@ (def: nested (-> Text Text) (|>> (format text.new_line) - (text.replace_all text.new_line (format text.new_line text.tab)))) + (text.replaced text.new_line (format text.new_line text.tab)))) (abstract: .public (Code brand) {} @@ -86,13 +86,13 @@ (f.= f.negative_infinity value) "-Infinity" - ## else + ... else (|> value %.frac ..expression)))) (def: safe (-> Text Text) (`` (|>> (~~ (template [<replace> <find>] - [(text.replace_all <find> <replace>)] + [(text.replaced <find> <replace>)] ["\\" "\"] ["\t" text.tab] diff --git a/stdlib/source/library/lux/target/jvm/attribute.lux b/stdlib/source/library/lux/target/jvm/attribute.lux index 0aa919723..72e054d5f 100644 --- a/stdlib/source/library/lux/target/jvm/attribute.lux +++ b/stdlib/source/library/lux/target/jvm/attribute.lux @@ -69,9 +69,9 @@ (def: common_attribute_length ($_ n.+ - ## u2 attribute_name_index; + ... u2 attribute_name_index; //unsigned.bytes/2 - ## u4 attribute_length; + ... u4 attribute_length; //unsigned.bytes/4 )) @@ -83,7 +83,7 @@ (|> length //unsigned.value (n.+ ..common_attribute_length))]) ([#Constant] [#Code]))) -## TODO: Inline ASAP +... TODO: Inline ASAP (def: (constant' @name index) (-> (Index UTF8) (Constant Any) Attribute) (#Constant {#name @name @@ -96,11 +96,11 @@ [@name (//constant/pool.utf8 "ConstantValue")] (in (constant' @name index)))) -## TODO: Inline ASAP +... TODO: Inline ASAP (def: (code' @name specification) (-> (Index UTF8) Code Attribute) (#Code {#name @name - ## https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 + ... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 #length (|> specification (/code.length ..length) //unsigned.u4 diff --git a/stdlib/source/library/lux/target/jvm/attribute/code.lux b/stdlib/source/library/lux/target/jvm/attribute/code.lux index 733fd4d7c..1c1cb95a9 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code.lux @@ -31,23 +31,23 @@ (def: .public (length length code) (All [Attribute] (-> (-> Attribute Nat) (Code Attribute) Nat)) ($_ n.+ - ## u2 max_stack; - ## u2 max_locals; + ... u2 max_stack; + ... u2 max_locals; ///limit.length - ## u4 code_length; + ... u4 code_length; ///unsigned.bytes/4 - ## u1 code[code_length]; + ... u1 code[code_length]; (binary.size (get@ #code code)) - ## u2 exception_table_length; + ... u2 exception_table_length; ///unsigned.bytes/2 - ## exception_table[exception_table_length]; + ... exception_table[exception_table_length]; (|> code (get@ #exception_table) row.size (n.* /exception.length)) - ## u2 attributes_count; + ... u2 attributes_count; ///unsigned.bytes/2 - ## attribute_info attributes[attributes_count]; + ... attribute_info attributes[attributes_count]; (|> code (get@ #attributes) (row\map length) @@ -63,20 +63,20 @@ (row.equivalence attribute_equivalence) )) -## https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 +... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 (def: .public (writer writer code) (All [Attribute] (-> (Writer Attribute) (Writer (Code Attribute)))) ($_ binaryF\compose - ## u2 max_stack; - ## u2 max_locals; + ... u2 max_stack; + ... u2 max_locals; (///limit.writer (get@ #limit code)) - ## u4 code_length; - ## u1 code[code_length]; + ... u4 code_length; + ... u1 code[code_length]; (binaryF.binary/32 (get@ #code code)) - ## u2 exception_table_length; - ## exception_table[exception_table_length]; + ... u2 exception_table_length; + ... exception_table[exception_table_length]; ((binaryF.row/16 /exception.writer) (get@ #exception_table code)) - ## u2 attributes_count; - ## attribute_info attributes[attributes_count]; + ... u2 attributes_count; + ... attribute_info attributes[attributes_count]; ((binaryF.row/16 writer) (get@ #attributes code)) )) diff --git a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux index 42bb8ebb9..5ba6db613 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux @@ -34,17 +34,17 @@ ////index.equivalence )) -## https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 +... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 (def: .public length Nat ($_ n.+ - ## u2 start_pc; + ... u2 start_pc; ////unsigned.bytes/2 - ## u2 end_pc; + ... u2 end_pc; ////unsigned.bytes/2 - ## u2 handler_pc; + ... u2 handler_pc; ////unsigned.bytes/2 - ## u2 catch_type; + ... u2 catch_type; ////unsigned.bytes/2 )) diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index fa48223ae..2891e83fa 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -89,7 +89,7 @@ (is? ..relative_identity right) left - ## else + ... else (function (_ resolver) (do try.monad [[left_exceptions left_instruction] (left resolver) @@ -923,7 +923,7 @@ [(def: .public (<name> class) (-> (Type <category>) (Bytecode Any)) (do ..monad - [## TODO: Make sure it's impossible to have indexes greater than U2. + [... TODO: Make sure it's impossible to have indexes greater than U2. index (..lift (//constant/pool.class (//name.internal (..reflection class))))] (..bytecode <consumption> <production> @_ <instruction> [index])))] @@ -961,7 +961,7 @@ (is? type.double type)) 2 - ## else + ... else 1)) (template [<static?> <name> <instruction> <method>] diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux index d426726e3..6a09af8fd 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux @@ -81,8 +81,8 @@ (def: .public (consumes amount) (-> U2 Condition) - ## TODO: Revisit this definition once lenses/optics have been implemented, - ## since it can probably be simplified with them. + ... TODO: Revisit this definition once lenses/optics have been implemented, + ... since it can probably be simplified with them. (function (_ environment) (do try.monad [previous (..stack environment) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux index d8117947e..48bdffd82 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux @@ -38,9 +38,9 @@ (def: .public length ($_ n.+ - ## u2 max_stack; + ... u2 max_stack; /stack.length - ## u2 max_locals; + ... u2 max_locals; /registry.length)) (def: .public equivalence diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index 5aee5816a..7d76f4c78 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -75,7 +75,7 @@ [(n.+ (///unsigned.value ..opcode_size) offset) (try.assumed - (binary.write/8 offset opcode binary))])) + (binary.write/8! offset opcode binary))])) (def: nullary [Estimator (-> Opcode Instruction)] @@ -105,7 +105,7 @@ [(n.+ (///unsigned.value <shift>) offset) (try.assumed (do try.monad - [_ (binary.write/8 offset opcode binary)] + [_ (binary.write/8! offset opcode binary)] (<writer> (n.+ (///unsigned.value ..opcode_size) offset) (<unwrap> input0) binary)))])) @@ -117,10 +117,10 @@ [(n.+ (///unsigned.value <shift>) size) (|>> mutation ((<private> opcode input0)))])]))] - [..size/1 unary/1 U1 binary.write/8 ///unsigned.value] - [..size/2 unary/2 U2 binary.write/16 ///unsigned.value] - [..size/2 jump/2 Jump binary.write/16 ///signed.value] - [..size/4 jump/4 Big_Jump binary.write/32 ///signed.value] + [..size/1 unary/1 U1 binary.write/8! ///unsigned.value] + [..size/2 unary/2 U2 binary.write/16! ///unsigned.value] + [..size/2 jump/2 Jump binary.write/16! ///signed.value] + [..size/4 jump/4 Big_Jump binary.write/32! ///signed.value] ) (template [<shift> <name> <inputT> <writer>] @@ -131,7 +131,7 @@ [(n.+ (///unsigned.value <shift>) offset) (try.assumed (do try.monad - [_ (binary.write/8 offset opcode binary)] + [_ (binary.write/8! offset opcode binary)] (<writer> (n.+ (///unsigned.value ..opcode_size) offset) (///signed.value input0) binary)))])) @@ -143,8 +143,8 @@ [(n.+ (///unsigned.value <shift>) size) (|>> mutation ((<private> opcode input0)))])]))] - [..size/1 unary/1' S1 binary.write/8] - [..size/2 unary/2' S2 binary.write/16] + [..size/1 unary/1' S1 binary.write/8!] + [..size/2 unary/2' S2 binary.write/16!] ) (def: size/11 @@ -159,13 +159,13 @@ [(n.+ (///unsigned.value ..size/11) offset) (try.assumed (do try.monad - [_ (binary.write/8 offset opcode binary) - _ (binary.write/8 (n.+ (///unsigned.value ..opcode_size) offset) - (///unsigned.value input0) - binary)] - (binary.write/8 (n.+ (///unsigned.value ..size/1) offset) - (///unsigned.value input1) - binary)))])) + [_ (binary.write/8! offset opcode binary) + _ (binary.write/8! (n.+ (///unsigned.value ..opcode_size) offset) + (///unsigned.value input0) + binary)] + (binary.write/8! (n.+ (///unsigned.value ..size/1) offset) + (///unsigned.value input1) + binary)))])) (def: binary/11 [Estimator (-> Opcode U1 U1 Instruction)] @@ -186,13 +186,13 @@ [(n.+ (///unsigned.value ..size/21) offset) (try.assumed (do try.monad - [_ (binary.write/8 offset opcode binary) - _ (binary.write/16 (n.+ (///unsigned.value ..opcode_size) offset) - (///unsigned.value input0) - binary)] - (binary.write/8 (n.+ (///unsigned.value ..size/2) offset) - (///unsigned.value input1) - binary)))])) + [_ (binary.write/8! offset opcode binary) + _ (binary.write/16! (n.+ (///unsigned.value ..opcode_size) offset) + (///unsigned.value input0) + binary)] + (binary.write/8! (n.+ (///unsigned.value ..size/2) offset) + (///unsigned.value input1) + binary)))])) (def: binary/21 [Estimator (-> Opcode U2 U1 Instruction)] @@ -214,16 +214,16 @@ [(n.+ (///unsigned.value ..size/211) offset) (try.assumed (do try.monad - [_ (binary.write/8 offset opcode binary) - _ (binary.write/16 (n.+ (///unsigned.value ..opcode_size) offset) - (///unsigned.value input0) - binary) - _ (binary.write/8 (n.+ (///unsigned.value ..size/2) offset) - (///unsigned.value input1) - binary)] - (binary.write/8 (n.+ (///unsigned.value ..size/21) offset) - (///unsigned.value input2) - binary)))])) + [_ (binary.write/8! offset opcode binary) + _ (binary.write/16! (n.+ (///unsigned.value ..opcode_size) offset) + (///unsigned.value input0) + binary) + _ (binary.write/8! (n.+ (///unsigned.value ..size/2) offset) + (///unsigned.value input1) + binary)] + (binary.write/8! (n.+ (///unsigned.value ..size/21) offset) + (///unsigned.value input2) + binary)))])) (def: trinary/211 [Estimator (-> Opcode U2 U1 U1 Instruction)] @@ -254,7 +254,7 @@ [11 t_long] )) -## https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5 +... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5 (with_expansions [<constants> (template [<code> <name>] [[<code> <name> [] []]] @@ -617,21 +617,21 @@ (do {! try.monad} [amount_of_afterwards (|> amount_of_afterwards .int ///signed.s4) maximum (///signed.+/4 minimum amount_of_afterwards) - _ (binary.write/8 offset (hex "AA") binary) + _ (binary.write/8! offset (hex "AA") binary) .let [offset (n.+ (///unsigned.value ..opcode_size) offset)] _ (case padding 3 (do ! - [_ (binary.write/8 offset 0 binary)] - (binary.write/16 (inc offset) 0 binary)) - 2 (binary.write/16 offset 0 binary) - 1 (binary.write/8 offset 0 binary) + [_ (binary.write/8! offset 0 binary)] + (binary.write/16! (inc offset) 0 binary)) + 2 (binary.write/16! offset 0 binary) + 1 (binary.write/8! offset 0 binary) _ (in binary)) .let [offset (n.+ padding offset)] - _ (binary.write/32 offset (///signed.value default) binary) + _ (binary.write/32! offset (///signed.value default) binary) .let [offset (n.+ (///unsigned.value ..big_jump_size) offset)] - _ (binary.write/32 offset (///signed.value minimum) binary) + _ (binary.write/32! offset (///signed.value minimum) binary) .let [offset (n.+ (///unsigned.value ..integer_size) offset)] - _ (binary.write/32 offset (///signed.value maximum) binary)] + _ (binary.write/32! offset (///signed.value maximum) binary)] (loop [offset (n.+ (///unsigned.value ..integer_size) offset) afterwards (: (List Big_Jump) (#.Item at_minimum afterwards))] @@ -641,7 +641,7 @@ (#.Item head tail) (do ! - [_ (binary.write/32 offset (///signed.value head) binary)] + [_ (binary.write/32! offset (///signed.value head) binary)] (recur (n.+ (///unsigned.value ..big_jump_size) offset) tail))))))]))] [(n.+ tableswitch_size @@ -679,19 +679,19 @@ [(n.+ lookupswitch_size offset) (try.assumed (do {! try.monad} - [_ (binary.write/8 offset (hex "AB") binary) + [_ (binary.write/8! offset (hex "AB") binary) .let [offset (n.+ (///unsigned.value ..opcode_size) offset)] _ (case padding 3 (do ! - [_ (binary.write/8 offset 0 binary)] - (binary.write/16 (inc offset) 0 binary)) - 2 (binary.write/16 offset 0 binary) - 1 (binary.write/8 offset 0 binary) + [_ (binary.write/8! offset 0 binary)] + (binary.write/16! (inc offset) 0 binary)) + 2 (binary.write/16! offset 0 binary) + 1 (binary.write/8! offset 0 binary) _ (in binary)) .let [offset (n.+ padding offset)] - _ (binary.write/32 offset (///signed.value default) binary) + _ (binary.write/32! offset (///signed.value default) binary) .let [offset (n.+ (///unsigned.value ..big_jump_size) offset)] - _ (binary.write/32 offset amount_of_cases binary)] + _ (binary.write/32! offset amount_of_cases binary)] (loop [offset (n.+ (///unsigned.value ..integer_size) offset) cases cases] (case cases @@ -700,8 +700,8 @@ (#.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)] + [_ (binary.write/32! offset (///signed.value value) binary) + _ (binary.write/32! (n.+ (///unsigned.value ..integer_size) offset) (///signed.value jump) binary)] (recur (n.+ case_size offset) tail))))))]))] [(n.+ lookupswitch_size diff --git a/stdlib/source/library/lux/target/jvm/constant.lux b/stdlib/source/library/lux/target/jvm/constant.lux index 229dd247f..5916d245d 100644 --- a/stdlib/source/library/lux/target/jvm/constant.lux +++ b/stdlib/source/library/lux/target/jvm/constant.lux @@ -179,8 +179,8 @@ (def: .public equivalence (Equivalence Constant) - ## TODO: Delete the explicit "implementation" and use the combinator - ## version below as soon as the new format for variants is implemented. + ... TODO: Delete the explicit "implementation" and use the combinator + ... version below as soon as the new format for variants is implemented. (implementation (def: (= reference sample) (case [reference sample] @@ -201,26 +201,26 @@ _ false))) - ## ($_ sum.equivalence - ## ## #UTF8 - ## text.equivalence - ## ## #Long - ## (..value_equivalence int.equivalence) - ## ## #Double - ## (..value_equivalence frac.equivalence) - ## ## #Class - ## ..class_equivalence - ## ## #String - ## (..value_equivalence //index.equivalence) - ## ## #Field - ## ..reference_equivalence - ## ## #Method - ## ..reference_equivalence - ## ## #Interface_Method - ## ..reference_equivalence - ## ## #Name_And_Type - ## ..name_and_type_equivalence - ## ) + ... ($_ sum.equivalence + ... ... #UTF8 + ... text.equivalence + ... ... #Long + ... (..value_equivalence int.equivalence) + ... ... #Double + ... (..value_equivalence frac.equivalence) + ... ... #Class + ... ..class_equivalence + ... ... #String + ... (..value_equivalence //index.equivalence) + ... ... #Field + ... ..reference_equivalence + ... ... #Method + ... ..reference_equivalence + ... ... #Interface_Method + ... ..reference_equivalence + ... ... #Name_And_Type + ... ..name_and_type_equivalence + ... ) ) (def: .public writer @@ -236,9 +236,9 @@ [#Method /tag.method ..reference_writer] [#Interface_Method /tag.interface_method ..reference_writer] [#Name_And_Type /tag.name_and_type ..name_and_type_writer] - ## TODO: Method_Handle - ## TODO: Method_Type - ## TODO: Invoke_Dynamic + ... TODO: Method_Handle + ... TODO: Method_Type + ... TODO: Invoke_Dynamic )] (function (_ value) (case value diff --git a/stdlib/source/library/lux/target/jvm/encoding/name.lux b/stdlib/source/library/lux/target/jvm/encoding/name.lux index a0761950e..16efc410a 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/name.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/name.lux @@ -19,8 +19,8 @@ (def: .public internal (-> External Internal) - (|>> (text.replace_all ..external_separator - ..internal_separator) + (|>> (text.replaced ..external_separator + ..internal_separator) :abstraction)) (def: .public read @@ -30,8 +30,8 @@ (def: .public external (-> Internal External) (|>> :representation - (text.replace_all ..internal_separator - ..external_separator)))) + (text.replaced ..internal_separator + ..external_separator)))) (def: .public safe (-> Text External) diff --git a/stdlib/source/library/lux/target/jvm/loader.lux b/stdlib/source/library/lux/target/jvm/loader.lux index 3a38d9bb8..5676f1f4a 100644 --- a/stdlib/source/library/lux/target/jvm/loader.lux +++ b/stdlib/source/library/lux/target/jvm/loader.lux @@ -113,7 +113,7 @@ (java/lang/Class [? < java/lang/Object]) #throws [java/lang/ClassNotFoundException] (let [class_name (:as Text class_name) - classes (|> library atom.read io.run)] + classes (|> library atom.read! io.run)] (case (dictionary.get class_name classes) (#.Some bytecode) (case (..define class_name bytecode (<| <cast> self)) @@ -129,11 +129,11 @@ (def: .public (store name bytecode library) (-> Text Binary Library (IO (Try Any))) (do {! io.monad} - [library' (atom.read library)] + [library' (atom.read! library)] (if (dictionary.key? library' name) (in (exception.except ..already_stored name)) (do ! - [_ (atom.update (dictionary.put name bytecode) library)] + [_ (atom.update! (dictionary.put name bytecode) library)] (in (#try.Success [])))))) (def: .public (load name loader) diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index bdb8249f2..256fc2863 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -184,7 +184,7 @@ _ (exception.except ..not_a_class raw))) _) - ## else + ... else (exception.except ..cannot_convert_to_a_lux_type reflection))) (def: .public (parameter reflection) @@ -195,16 +195,16 @@ _) (case (ffi.check java/lang/reflect/WildcardType reflection) (#.Some reflection) - ## TODO: Instead of having single lower/upper bounds, should - ## allow for multiple ones. + ... TODO: Instead of having single lower/upper bounds, should + ... allow for multiple ones. (case [(array.read 0 (java/lang/reflect/WildcardType::getLowerBounds reflection)) (array.read 0 (java/lang/reflect/WildcardType::getUpperBounds reflection))] (^template [<pattern> <kind>] [<pattern> (case (ffi.check java/lang/reflect/GenericArrayType bound) (#.Some _) - ## TODO: Array bounds should not be "erased" as they - ## are right now. + ... TODO: Array bounds should not be "erased" as they + ... are right now. (#try.Success /.wildcard) _ @@ -253,7 +253,7 @@ type (\ try.monad map /.array)) _) - ## else + ... else (..parameter reflection))) (def: .public (return reflection) diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index 5a58e3dc0..dc10d216a 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -144,8 +144,8 @@ [(def: <name> (-> (Parser (Check Type)) (Parser (Check Type))) (|> (<>.after (<text>.this <prefix>)) - ## TODO: Re-enable Lower and Upper, instead of using the simplified limit. - ## (<>\map (check\map (|>> <ctor> .type))) + ... TODO: Re-enable Lower and Upper, instead of using the simplified limit. + ... (<>\map (check\map (|>> <ctor> .type))) ))] [lower //signature.lower_prefix ..Lower] diff --git a/stdlib/source/library/lux/target/jvm/type/reflection.lux b/stdlib/source/library/lux/target/jvm/type/reflection.lux index f92b41ae5..f525e56f6 100644 --- a/stdlib/source/library/lux/target/jvm/type/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/type/reflection.lux @@ -80,8 +80,8 @@ (|> element' //descriptor.class //descriptor.descriptor - (text.replace_all //name.internal_separator - //name.external_separator))))] + (text.replaced //name.internal_separator + //name.external_separator))))] (|> elementR (format //descriptor.array_prefix) :abstraction))) diff --git a/stdlib/source/library/lux/target/jvm/type/signature.lux b/stdlib/source/library/lux/target/jvm/type/signature.lux index 4ebdb9248..23038130a 100644 --- a/stdlib/source/library/lux/target/jvm/type/signature.lux +++ b/stdlib/source/library/lux/target/jvm/type/signature.lux @@ -63,8 +63,8 @@ (def: .public var_name (-> (Signature Var) Text) (|>> :representation - (text.replace_all ..var_prefix "") - (text.replace_all //descriptor.class_suffix ""))) + (text.replaced ..var_prefix "") + (text.replaced //descriptor.class_suffix ""))) (def: .public lower_prefix "-") (def: .public upper_prefix "+") diff --git a/stdlib/source/library/lux/target/lua.lux b/stdlib/source/library/lux/target/lua.lux index a94c483f6..756efc949 100644 --- a/stdlib/source/library/lux/target/lua.lux +++ b/stdlib/source/library/lux/target/lua.lux @@ -31,7 +31,7 @@ (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (|>> (format text.new_line) - (text.replace_all text.new_line nested_new_line)))) + (text.replaced text.new_line nested_new_line)))) (def: input_separator ", ") @@ -94,8 +94,8 @@ (def: .public int (-> Int Literal) - ## Integers must be turned into hexadecimal to avoid quirks in how Lua parses integers. - ## In particular, the number -9223372036854775808 will be incorrectly parsed as a float by Lua. + ... Integers must be turned into hexadecimal to avoid quirks in how Lua parses integers. + ... In particular, the number -9223372036854775808 will be incorrectly parsed as a float by Lua. (.let [to_hex (\ n.hex encode)] (|>> .nat to_hex @@ -113,14 +113,14 @@ [(f.= f.not_a_number)] [(new> "(0.0/0.0)" [])] - ## else - [%.frac (text.replace_all "+" "")]) + ... else + [%.frac (text.replaced "+" "")]) :abstraction)) (def: safe (-> Text Text) (`` (|>> (~~ (template [<find> <replace>] - [(text.replace_all <find> <replace>)] + [(text.replaced <find> <replace>)] ["\" "\\"] [text.tab "\t"] @@ -379,7 +379,7 @@ (list\map (|>> %.nat code.local_identifier)))))) (syntax: (arity_types {arity <code>.nat}) - (in (list.repeat arity (` ..Expression)))) + (in (list.repeated arity (` ..Expression)))) (template [<arity> <function>+] [(with_expansions [<apply> (template.identifier ["apply/" <arity>]) diff --git a/stdlib/source/library/lux/target/php.lux b/stdlib/source/library/lux/target/php.lux index c1056e777..98ab82bca 100644 --- a/stdlib/source/library/lux/target/php.lux +++ b/stdlib/source/library/lux/target/php.lux @@ -33,7 +33,7 @@ (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (|>> (format text.new_line) - (text.replace_all text.new_line nested_new_line)))) + (text.replaced text.new_line nested_new_line)))) (def: block (-> Text Text) @@ -153,14 +153,14 @@ [(f.= f.not_a_number)] [(new> "NAN" [])] - ## else + ... else [%.frac]) :abstraction)) (def: safe (-> Text Text) (`` (|>> (~~ (template [<find> <replace>] - [(text.replace_all <find> <replace>)] + [(text.replaced <find> <replace>)] ["\" "\\"] [text.tab "\t"] @@ -190,7 +190,7 @@ (|> (format (:representation func) (..arguments args)) :abstraction)) - ## TODO: Remove when no longer using JPHP. + ... TODO: Remove when no longer using JPHP. (def: .public (apply/*' args func) (-> (List Expression) Expression Computation) (apply/* (list& func args) (..constant "call_user_func"))) @@ -235,7 +235,7 @@ (list\map (|>> %.nat code.local_identifier)))))) (syntax: (arity_types {arity <code>.nat}) - (in (list.repeat arity (` ..Expression)))) + (in (list.repeated arity (` ..Expression)))) (template [<arity> <function>+] [(with_expansions [<apply> (template.identifier ["apply/" <arity>]) diff --git a/stdlib/source/library/lux/target/python.lux b/stdlib/source/library/lux/target/python.lux index 55d0eecea..6b578ada2 100644 --- a/stdlib/source/library/lux/target/python.lux +++ b/stdlib/source/library/lux/target/python.lux @@ -45,7 +45,7 @@ (java/lang/String::replace (:as java/lang/CharSequence text.new_line) (:as java/lang/CharSequence nested_new_line)))} (|>> (format text.new_line) - (text.replace_all text.new_line nested_new_line))))) + (text.replaced text.new_line nested_new_line))))) (abstract: .public (Code brand) {} @@ -148,14 +148,14 @@ [f.not_a_number? "nan"] )) - ## else + ... else [%.frac]) :abstraction))) (def: safe (-> Text Text) (`` (|>> (~~ (template [<find> <replace>] - [(text.replace_all <find> <replace>)] + [(text.replaced <find> <replace>)] ["\" "\\"] [text.tab "\t"] @@ -188,7 +188,7 @@ (-> (List a) Literal))) (function (_ entries) (<| :abstraction - ## ..expression + ... ..expression (format left_delimiter (|> entries (list\map entry_serializer) @@ -207,13 +207,13 @@ (def: .public (slice from to list) (-> (Expression Any) (Expression Any) (Expression Any) Access) (<| :abstraction - ## ..expression + ... ..expression (format (:representation list) "[" (:representation from) ":" (:representation to) "]"))) (def: .public (slice_from from list) (-> (Expression Any) (Expression Any) Access) (<| :abstraction - ## ..expression + ... ..expression (format (:representation list) "[" (:representation from) ":]"))) (def: .public dict @@ -223,7 +223,7 @@ (def: .public (apply/* func args) (-> (Expression Any) (List (Expression Any)) (Computation Any)) (<| :abstraction - ## ..expression + ... ..expression (format (:representation func) "(" (text.join_with ", " (list\map ..code args)) ")"))) (template [<name> <brand> <prefix>] @@ -239,7 +239,7 @@ [(def: .public (<name> args extra func) (-> (List (Expression Any)) (Expression Any) (Expression Any) (Computation Any)) (<| :abstraction - ## ..expression + ... ..expression (format (:representation func) (format "(" (|> args (list\map (function (_ arg) (format (:representation arg) ", "))) @@ -312,7 +312,7 @@ [(def: .public (<name> subject) (-> (Expression Any) (Computation Any)) (<| :abstraction - ## ..expression + ... ..expression (format <unary> " " (:representation subject))))] [not "not"] @@ -465,7 +465,7 @@ (list\map (|>> %.nat code.local_identifier)))))) (syntax: (arity_types {arity <code>.nat}) - (in (list.repeat arity (` (Expression Any))))) + (in (list.repeated arity (` (Expression Any))))) (template [<arity> <function>+] [(with_expansions [<apply> (template.identifier ["apply/" <arity>]) diff --git a/stdlib/source/library/lux/target/r.lux b/stdlib/source/library/lux/target/r.lux index 3b6601179..e446c0cb1 100644 --- a/stdlib/source/library/lux/target/r.lux +++ b/stdlib/source/library/lux/target/r.lux @@ -77,7 +77,7 @@ (def: nested (-> Text Text) - (|>> (text.replace_all text.new_line ..nested_new_line) + (|>> (text.replaced text.new_line ..nested_new_line) (format ..nested_new_line))) (def: (_block expression) @@ -129,14 +129,14 @@ [(f.= f.not_a_number)] [(new> "0.0/0.0" [])] - ## else + ... else [%.frac]) ..self_contained)) (def: safe (-> Text Text) (`` (|>> (~~ (template [<find> <replace>] - [(text.replace_all <find> <replace>)] + [(text.replaced <find> <replace>)] ["\" "\\"] ["|" "\|"] @@ -168,7 +168,7 @@ (def: .public (apply args func) (-> (List Expression) Expression Expression) (let [func (:representation func) - spacing (|> " " (list.repeat (text.size func)) (text.join_with ""))] + spacing (|> " " (list.repeated (text.size func)) (text.join_with ""))] (:abstraction (format func "(" (|> args @@ -211,7 +211,7 @@ (list\map (|>> %.nat code.local_identifier)))))) (syntax: (arity_types {arity <code>.nat}) - (in (list.repeat arity (` ..Expression)))) + (in (list.repeated arity (` ..Expression)))) (template [<arity> <function>+] [(with_expansions [<apply> (template.identifier ["apply/" <arity>]) diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index fc08c16fa..d56ce5936 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -33,7 +33,7 @@ (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (|>> (format text.new_line) - (text.replace_all text.new_line nested_new_line)))) + (text.replaced text.new_line nested_new_line)))) (abstract: .public (Code brand) {} @@ -152,7 +152,7 @@ (def: safe (-> Text Text) (`` (|>> (~~ (template [<find> <replace>] - [(text.replace_all <find> <replace>)] + [(text.replaced <find> <replace>)] ["\" "\\"] [text.tab "\t"] @@ -187,7 +187,7 @@ [(f.= f.not_a_number)] [(new> "(+0.0/-0.0)" [])] - ## else + ... else [%.frac]) :abstraction)) @@ -441,7 +441,7 @@ (list\map (|>> %.nat code.local_identifier)))))) (syntax: (arity_types {arity <code>.nat}) - (in (list.repeat arity (` ..Expression)))) + (in (list.repeated arity (` ..Expression)))) (template [<arity> <function>+] [(with_expansions [<apply> (template.identifier ["apply/" <arity>]) diff --git a/stdlib/source/library/lux/target/scheme.lux b/stdlib/source/library/lux/target/scheme.lux index 011f681f9..6dcc744ca 100644 --- a/stdlib/source/library/lux/target/scheme.lux +++ b/stdlib/source/library/lux/target/scheme.lux @@ -24,7 +24,7 @@ (def: nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] - (text.replace_all text.new_line nested_new_line))) + (text.replaced text.new_line nested_new_line))) (abstract: .public (Code k) {} @@ -122,7 +122,7 @@ [f.not_a_number?] [(new> "+nan.0" [])] - ## else + ... else [%.frac]) :abstraction)) @@ -133,7 +133,7 @@ (def: safe (-> Text Text) (`` (|>> (~~ (template [<find> <replace>] - [(text.replace_all <find> <replace>)] + [(text.replaced <find> <replace>)] ["\" "\\"] ["|" "\|"] @@ -234,7 +234,7 @@ [[append/2 "append"] [cons/2 "cons"] [make_vector/2 "make-vector"] - ## [vector_ref/2 "vector-ref"] + ... [vector_ref/2 "vector-ref"] [list_tail/2 "list-tail"] [map/2 "map"] [string_ref/2 "string-ref"] @@ -250,19 +250,19 @@ [[vector_copy!/5 "vector-copy!"]]] ) - ## TODO: define "vector_ref/2" like a normal apply/2 function. - ## "vector_ref/2" as an 'invoke' is problematic, since it only works - ## in Kawa. - ## However, the way Kawa defines "vector-ref" causes trouble, - ## because it does a runtime type-check which throws an error when - ## it checks against custom values/objects/classes made for - ## JVM<->Scheme interop. - ## There are 2 ways to deal with this: - ## 0. To fork Kawa, and get rid of the type-check so the normal - ## "vector-ref" can be used instead. - ## 1. To carry on, and then, when it's time to compile the compiler - ## itself into Scheme, switch from 'invoke' to normal 'vector-ref'. - ## Either way, the 'invoke' needs to go away. + ... TODO: define "vector_ref/2" like a normal apply/2 function. + ... "vector_ref/2" as an 'invoke' is problematic, since it only works + ... in Kawa. + ... However, the way Kawa defines "vector-ref" causes trouble, + ... because it does a runtime type-check which throws an error when + ... it checks against custom values/objects/classes made for + ... JVM<->Scheme interop. + ... There are 2 ways to deal with this: + ... 0. To fork Kawa, and get rid of the type-check so the normal + ... "vector-ref" can be used instead. + ... 1. To carry on, and then, when it's time to compile the compiler + ... itself into Scheme, switch from 'invoke' to normal 'vector-ref'. + ... Either way, the 'invoke' needs to go away. (def: .public (vector_ref/2 vector index) (-> Expression Expression Computation) (..form (list (..var "invoke") vector (..symbol "getRaw") index))) diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index 304846eec..a2ff484ab 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -88,8 +88,8 @@ (async.Resolver [Tally Text])] (async.async [])) _ (|> left - (async.await (function (_ [l_tally l_documentation]) - (async.await (function (_ [r_tally r_documentation]) + (async.upon! (function (_ [l_tally l_documentation]) + (async.upon! (function (_ [r_tally r_documentation]) (write! [(..total l_tally r_tally) (format l_documentation ..separator r_documentation)])) right))) @@ -215,11 +215,11 @@ "100%" (let [raw (|> done_percent %.frac - (text.replace_once "+" ""))] + (text.replaced/1 "+" ""))] (|> raw (text.clip 0 (if (f.>= +10.0 done_percent) - 5 ## XX.XX - 4 ## X.XX + 5 ... XX.XX + 4 ... X.XX )) (maybe.else raw) (text.suffix "%"))))))] @@ -401,9 +401,9 @@ (async.async [])) _ (io.run (monad.map io.monad (function (_ [index test]) - (async.await (function (_ assertion) + (async.upon! (function (_ assertion) (do io.monad - [[_ results] (atom.update (dictionary.put index assertion) state)] + [[_ results] (atom.update! (dictionary.put index assertion) state)] (if (n.= expected_tests (dictionary.size results)) (let [assertions (|> results dictionary.entries diff --git a/stdlib/source/library/lux/time.lux b/stdlib/source/library/lux/time.lux index cb7fdd619..fe40eece2 100644 --- a/stdlib/source/library/lux/time.lux +++ b/stdlib/source/library/lux/time.lux @@ -26,7 +26,7 @@ (template [<name> <singular> <plural>] [(def: .public <name> Nat - (.nat (duration.query <singular> <plural>)))] + (.nat (duration.ticks <singular> <plural>)))] [milli_seconds duration.milli_second duration.second] [seconds duration.second duration.minute] @@ -165,7 +165,7 @@ (cond (n.= 0 millis) "" (n.< 10 millis) ($_ text\compose ".00" (n\encode millis)) (n.< 100 millis) ($_ text\compose ".0" (n\encode millis)) - ## (n.< 1,000 millis) + ... (n.< 1,000 millis) ($_ text\compose "." (n\encode millis)))) (type: .public Clock @@ -177,9 +177,9 @@ (def: .public (clock time) (-> Time Clock) (let [time (|> time ..millis .int duration.of_millis) - [hours time] [(duration.query duration.hour time) (duration.framed duration.hour time)] - [minutes time] [(duration.query duration.minute time) (duration.framed duration.minute time)] - [seconds millis] [(duration.query duration.second time) (duration.framed duration.second time)]] + [hours time] [(duration.ticks duration.hour time) (duration.framed duration.hour time)] + [minutes time] [(duration.ticks duration.minute time) (duration.framed duration.minute time)] + [seconds millis] [(duration.ticks duration.second time) (duration.framed duration.second time)]] {#hour (.nat hours) #minute (.nat minutes) #second (.nat seconds) diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux index 6fc97fb81..9318e7be0 100644 --- a/stdlib/source/library/lux/time/date.lux +++ b/stdlib/source/library/lux/time/date.lux @@ -224,17 +224,17 @@ days::70 (|> years::70 (n.* //year.days) (n.+ leaps::70)) - ## The epoch is being calculated from March 1st, instead of January 1st. + ... The epoch is being calculated from March 1st, instead of January 1st. january_&_february (n.+ (//month.days #//month.January) (//month.days #//month.February))] (|> 0 - ## 1600/01/01 + ... 1600/01/01 (n.+ (n.* 4 days_per_era)) - ## 1900/01/01 + ... 1900/01/01 (n.+ (n.* 3 days_per_century)) - ## 1970/01/01 + ... 1970/01/01 (n.+ days::70) - ## 1970/03/01 + ... 1970/03/01 (n.- january_&_february)))) (def: first_month_of_civil_year 3) @@ -278,13 +278,13 @@ (def: (civil_year utc_month utc_year) (-> Nat Year Int) - (let [## Coercing, because the year is already in external form. + (let [... Coercing, because the year is already in external form. utc_year (:as Int utc_year)] (if (n.< ..first_month_of_civil_year utc_month) (dec utc_year) utc_year))) -## http://howardhinnant.github.io/date_algorithms.html +... http://howardhinnant.github.io/date_algorithms.html (def: .public (days date) (-> Date Int) (let [utc_month (|> date ..month //month.number) @@ -308,7 +308,7 @@ (i.+ day_of_era) (i.- (.int ..days_since_epoch))))) -## http://howardhinnant.github.io/date_algorithms.html +... http://howardhinnant.github.io/date_algorithms.html (def: .public (of_days days) (-> Int Date) (let [days (i.+ (.int ..days_since_epoch) days) @@ -336,7 +336,7 @@ year (if (n.< ..first_month_of_civil_year month) (inc year) year)] - ## Coercing, because the year is already in internal form. + ... Coercing, because the year is already in internal form. (try.assumed (..date (:as Year year) (maybe.assume (dictionary.get month ..month_by_number)) diff --git a/stdlib/source/library/lux/time/duration.lux b/stdlib/source/library/lux/time/duration.lux index 07f104b97..6de3b80a7 100644 --- a/stdlib/source/library/lux/time/duration.lux +++ b/stdlib/source/library/lux/time/duration.lux @@ -58,7 +58,7 @@ (-> Duration Duration) (|>> :representation (i.* -1) :abstraction)) - (def: .public (query param subject) + (def: .public (ticks param subject) (-> Duration Duration Int) (i./ (:representation param) (:representation subject))) @@ -134,16 +134,16 @@ (nat\encode 0) ..milli_second_suffix) (let [signed? (negative? duration) - [days time_left] [(query day duration) (framed day duration)] + [days time_left] [(ticks day duration) (framed day duration)] days (if signed? (i.abs days) days) time_left (if signed? (..inverse time_left) time_left) - [hours time_left] [(query hour time_left) (framed hour time_left)] - [minutes time_left] [(query minute time_left) (framed minute time_left)] - [seconds time_left] [(query second time_left) (framed second time_left)] + [hours time_left] [(ticks hour time_left) (framed hour time_left)] + [minutes time_left] [(ticks minute time_left) (framed minute time_left)] + [seconds time_left] [(ticks second time_left) (framed second time_left)] millis (..millis time_left)] ($_ text\compose (if signed? ..negative_sign ..positive_sign) diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux index 858a29632..630388641 100644 --- a/stdlib/source/library/lux/time/instant.lux +++ b/stdlib/source/library/lux/time/instant.lux @@ -92,7 +92,7 @@ (..of_millis +0)) (def: millis_per_day - (duration.query duration.milli_second duration.day)) + (duration.ticks duration.milli_second duration.day)) (def: (date_time instant) (-> Instant [Date Duration]) @@ -210,17 +210,17 @@ (def: .public (day_of_week instant) (-> Instant Day) (let [offset (..relative instant) - days (duration.query duration.day offset) + days (duration.ticks duration.day offset) day_time (duration.framed duration.day offset) days (if (and (duration.negative? offset) (not (duration.neutral? day_time))) (dec days) days) - ## 1970/01/01 was a Thursday + ... 1970/01/01 was a Thursday y1970m0d0 +4] (case (|> y1970m0d0 (i.+ days) (i.% +7) - ## This is done to turn negative days into positive days. + ... This is done to turn negative days into positive days. (i.+ +7) (i.% +7)) +0 #day.Sunday +1 #day.Monday diff --git a/stdlib/source/library/lux/time/year.lux b/stdlib/source/library/lux/time/year.lux index d4331ba82..44534707c 100644 --- a/stdlib/source/library/lux/time/year.lux +++ b/stdlib/source/library/lux/time/year.lux @@ -10,7 +10,7 @@ ["." try (#+ Try)] ["." exception (#+ exception:)] ["<>" parser - ["<t>" text (#+ Parser)]]] + ["<.>" text (#+ Parser)]]] [data ["." text ("#\." monoid)]] [math @@ -34,12 +34,16 @@ (exception: .public there_is_no_year_0) +... https://en.wikipedia.org/wiki/Gregorian_calendar (abstract: .public Year - {} + {#.doc (doc "A year in the gregorian calendar." + "Both negative (< 0) and positive (> 0) values are valid, but not 0." + "This is because the first year of the gregorian calendar was year 1.")} Int (def: .public (year value) + {#.doc (doc "A valid year in the gregorian calendar, if possible.")} (-> Int (Try Year)) (case value +0 (exception.except ..there_is_no_year_0 []) @@ -55,9 +59,12 @@ ) (def: .public days + {#.doc (doc "The amount of days in a typical year.")} + Nat 365) (type: .public Period + {#.doc (doc "An amount of years.")} Nat) (template [<period> <name>] @@ -74,7 +81,7 @@ (-> Int Int Bit) (|> input (i.% factor) (i.= +0))) -## https://en.wikipedia.org/wiki/Leap_year#Algorithm +... https://en.wikipedia.org/wiki/Leap_year#Algorithm (def: .public (leap? year) (-> Year Bit) (let [year (|> year ..value ..internal)] @@ -89,6 +96,7 @@ days))) (def: .public (leaps year) + {#.doc (doc "The number of leap years in a period of years.")} (-> Year Int) (let [year (|> year ..value ..internal) limit (if (i.> +0 year) @@ -114,8 +122,8 @@ (def: .public parser (Parser Year) (do {! <>.monad} - [sign (<>.or (<t>.this "-") (in [])) - digits (<t>.many <t>.decimal) + [sign (<>.or (<text>.this "-") (in [])) + digits (<text>.many <text>.decimal) raw_year (<>.codec i.decimal (in (text\compose "+" digits)))] (<>.lift (..year (case sign (#.Left _) (i.* -1 raw_year) @@ -127,7 +135,7 @@ (Codec Text Year) (def: encode ..encode) - (def: decode (<t>.run ..parser))) + (def: decode (<text>.run ..parser))) (implementation: .public equivalence (Equivalence Year) diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux index e2fd13208..6127ea59a 100644 --- a/stdlib/source/library/lux/tool/compiler/default/init.lux +++ b/stdlib/source/library/lux/tool/compiler/default/init.lux @@ -154,7 +154,7 @@ (in [analysis_module [final_buffer final_registry]]))) -## TODO: Inline ASAP +... TODO: Inline ASAP (def: (get_current_payload _) (All [directive] (-> (Payload directive) @@ -168,7 +168,7 @@ ///generation.get_registry)] (in [buffer registry]))) -## TODO: Inline ASAP +... TODO: Inline ASAP (def: (process_directive archive expander pre_payoad code) (All [directive] (-> Archive Expander (Payload directive) Code diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index dac25756c..814e6dfd2 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -75,11 +75,11 @@ #phase_wrapper (-> Archive (<Operation> Phase_Wrapper)) #write (-> directive Binary)}) - ## TODO: Get rid of this + ... TODO: Get rid of this (type: (Action a) (Async (Try a))) - ## TODO: Get rid of this + ... TODO: Get rid of this (def: monad (:as (Monad Action) (try.with async.monad))) @@ -117,13 +117,13 @@ (ioW.cache system static module_id (_.run ..writer [descriptor document]))))) - ## TODO: Inline ASAP + ... TODO: Inline ASAP (def: initialize_buffer! (All [<type_vars>] (///generation.Operation <type_vars> Any)) (///generation.set_buffer ///generation.empty_buffer)) - ## TODO: Inline ASAP + ... TODO: Inline ASAP (def: (compile_runtime! platform) (All [<type_vars>] (-> <Platform> (///generation.Operation <type_vars> [Registry Output]))) @@ -380,7 +380,7 @@ (..circular_dependency? importer importee dependence) (exception.except ..cannot_import_circular_dependency [importer importee]) - ## else + ... else (#try.Success []))) (with_expansions [<Context> (as_is [Archive <State+>]) @@ -485,7 +485,7 @@ (in [])))] return))))) - ## TODO: Find a better way, as this only works for the Lux compiler. + ... TODO: Find a better way, as this only works for the Lux compiler. (def: (updated_state archive state) (All [<type_vars>] (-> Archive <State+> (Try <State+>))) @@ -558,9 +558,9 @@ (-> <Context> (///.Compilation <State+> .Module Any) (Set Module) (Action [Archive <State+>])) (:assume recur)) - ## TODO: Come up with a less hacky way to prevent duplicate imports. - ## This currently assumes that all imports will be specified once in a single .module: form. - ## This might not be the case in the future. + ... TODO: Come up with a less hacky way to prevent duplicate imports. + ... This currently assumes that all imports will be specified once in a single .module: form. + ... This might not be the case in the future. [all_dependencies duplicates _] (: [(Set Module) (Set Module) Bit] (list\fold (function (_ new [all duplicates seen_prelude?]) (if (set.member? all new) @@ -590,8 +590,8 @@ (..updated_state archive state))]))) (async\in (exception.except ..cannot_import_twice [module duplicates])))] (case ((get@ #///.process compilation) - ## TODO: The "///directive.set_current_module" below shouldn't be necessary. Remove it ASAP. - ## TODO: The context shouldn't need to be re-set either. + ... TODO: The "///directive.set_current_module" below shouldn't be necessary. Remove it ASAP. + ... TODO: The context shouldn't need to be re-set either. (|> (///directive.set_current_module module) (///phase.run' state) try.assumed diff --git a/stdlib/source/library/lux/tool/compiler/language/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux.lux index 34e1bbbb7..e86bd51aa 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux.lux @@ -18,8 +18,8 @@ ["." signature] ["." key (#+ Key)]]]]]) -## TODO: Remove #module_hash, #imports & #module_state ASAP. -## TODO: Not just from this parser, but from the lux.Module type. +... TODO: Remove #module_hash, #imports & #module_state ASAP. +... TODO: Not just from this parser, but from the lux.Module type. (def: .public writer (Writer .Module) (let [definition (: (Writer Definition) @@ -43,21 +43,21 @@ _.bit _.type))] ($_ _.and - ## #module_hash + ... #module_hash _.nat - ## #module_aliases + ... #module_aliases (_.list alias) - ## #definitions + ... #definitions (_.list (_.and _.text global)) - ## #imports + ... #imports (_.list _.text) - ## #tags + ... #tags (_.list (_.and _.text tag)) - ## #types + ... #types (_.list (_.and _.text type)) - ## #module_annotations + ... #module_annotations (_.maybe _.code) - ## #module_state + ... #module_state _.any))) (def: .public parser @@ -83,21 +83,21 @@ <b>.bit <b>.type))] ($_ <>.and - ## #module_hash + ... #module_hash <b>.nat - ## #module_aliases + ... #module_aliases (<b>.list alias) - ## #definitions + ... #definitions (<b>.list (<>.and <b>.text global)) - ## #imports + ... #imports (<b>.list <b>.text) - ## #tags + ... #tags (<b>.list (<>.and <b>.text tag)) - ## #types + ... #types (<b>.list (<>.and <b>.text type)) - ## #module_annotations + ... #module_annotations (<b>.maybe <b>.code) - ## #module_state + ... #module_state (\ <>.monad in #.Cached)))) (def: .public key diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux index b099446ea..74cadee55 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux @@ -31,7 +31,7 @@ (def: (context [module_id artifact_id]) (-> Context Context) - ## TODO: Find a better way that doesn't rely on clever tricks. + ... TODO: Find a better way that doesn't rely on clever tricks. [(n.- module_id 0) artifact_id]) (def: .public (evaluator expander synthesis_state generation_state generate) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux index f32b12865..315424e3c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux @@ -228,7 +228,7 @@ [?buffer (extension.read (get@ #buffer))] (case ?buffer (#.Some buffer) - ## TODO: Optimize by no longer checking for overwrites... + ... TODO: Optimize by no longer checking for overwrites... (if (row.any? (|>> product.left (n.= artifact_id)) buffer) (phase.except ..cannot_overwrite_output [artifact_id]) (extension.update (set@ #buffer (#.Some (row.add [artifact_id custom code] buffer))))) 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 d760db44f..b9b230b42 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 @@ -31,8 +31,8 @@ (exception: .public (unrecognized_syntax {code Code}) (exception.report ["Code" (%.code code)])) -## TODO: Had to split the 'compile' function due to compilation issues -## with old-luxc. Must re-combine all the code ASAP +... TODO: Had to split the 'compile' function due to compilation issues +... with old-luxc. Must re-combine all the code ASAP (type: (Fix a) (-> a a)) @@ -136,8 +136,8 @@ (-> Expander Phase) (function (compile archive code) (let [[location code'] code] - ## The location must be set in the state for the sake - ## of having useful error messages. + ... The location must be set in the state for the sake + ... of having useful error messages. (/.with_location location (compile|primitive (compile|structure archive compile (compile|others expander archive compile)) 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 0d106fe5a..11c4ba626 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 @@ -68,13 +68,13 @@ (#.Item head tail) (re_quantify tail (#.UnivQ head baseT)))) -## Type-checking on the input value is done during the analysis of a -## "case" expression, to ensure that the patterns being used make -## sense for the type of the input value. -## Sometimes, that input value is complex, by depending on -## type-variables or quantifications. -## This function makes it easier for "case" analysis to properly -## type-check the input with respect to the patterns. +... Type-checking on the input value is done during the analysis of a +... "case" expression, to ensure that the patterns being used make +... sense for the type of the input value. +... Sometimes, that input value is complex, by depending on +... type-variables or quantifications. +... This function makes it easier for "case" analysis to properly +... type-check the input with respect to the patterns. (def: (simplify_case caseT) (-> Type (Operation Type)) (loop [envs (: (List (List Type)) @@ -146,22 +146,22 @@ outputA next] (in [output outputA])))) -## This function handles several concerns at once, but it must be that -## way because those concerns are interleaved when doing -## pattern-matching and they cannot be separated. -## The pattern is analysed in order to get a general feel for what is -## expected of the input value. This, in turn, informs the -## type-checking of the input. -## A kind of "continuation" value is passed around which signifies -## what needs to be done _after_ analysing a pattern. -## In general, this is done to analyse the "body" expression -## associated to a particular pattern _in the context of_ said -## pattern. -## The reason why *context* is important is because patterns may bind -## values to local variables, which may in turn be referenced in the -## body expressions. -## That is why the body must be analysed in the context of the -## pattern, and not separately. +... This function handles several concerns at once, but it must be that +... way because those concerns are interleaved when doing +... pattern-matching and they cannot be separated. +... The pattern is analysed in order to get a general feel for what is +... expected of the input value. This, in turn, informs the +... type-checking of the input. +... A kind of "continuation" value is passed around which signifies +... what needs to be done _after_ analysing a pattern. +... In general, this is done to analyse the "body" expression +... associated to a particular pattern _in the context of_ said +... pattern. +... The reason why *context* is important is because patterns may bind +... values to local variables, which may in turn be referenced in the +... body expressions. +... That is why the body must be analysed in the context of the +... pattern, and not separately. (def: (analyse_pattern num_tags inputT pattern next) (All [a] (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a]))) (.case pattern @@ -205,7 +205,7 @@ (let [[prefix suffix] (list.split (dec num_subs) sub_patterns)] (list.zipped/2 subs (list\compose prefix (list (code.tuple suffix))))) - ## (n.= num_subs num_sub_patterns) + ... (n.= num_subs num_sub_patterns) (list.zipped/2 subs sub_patterns))] (do ! [[memberP+ thenA] (list\fold (: (All [a] 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 6b949ea29..7dd813c09 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 @@ -35,18 +35,18 @@ (-> Nat Bit) (n.> 0)) -## The coverage of a pattern-matching expression summarizes how well -## all the possible values of an input are being covered by the -## different patterns involved. -## Ideally, the pattern-matching has "exhaustive" coverage, which just -## means that every possible value can be matched by at least 1 -## pattern. -## Every other coverage is considered partial, and it would be valued -## as insuficient (since it could lead to runtime errors due to values -## not being handled by any pattern). -## The #Partial tag covers arbitrary partial coverages in a general -## way, while the other tags cover more specific cases for bits -## and variants. +... The coverage of a pattern-matching expression summarizes how well +... all the possible values of an input are being covered by the +... different patterns involved. +... Ideally, the pattern-matching has "exhaustive" coverage, which just +... means that every possible value can be matched by at least 1 +... pattern. +... Every other coverage is considered partial, and it would be valued +... as insuficient (since it could lead to runtime errors due to values +... not being handled by any pattern). +... The #Partial tag covers arbitrary partial coverages in a general +... way, while the other tags cover more specific cases for bits +... and variants. (type: .public #rec Coverage #Partial (#Bit Bit) @@ -101,8 +101,8 @@ (#/.Bind _)) (////\in #Exhaustive) - ## Primitive patterns always have partial coverage because there - ## are too many possibilities as far as values go. + ... Primitive patterns always have partial coverage because there + ... are too many possibilities as far as values go. (^template [<tag>] [(#/.Simple (<tag> _)) (////\in #Partial)]) @@ -112,14 +112,14 @@ [#/.Frac] [#/.Text]) - ## Bits are the exception, since there is only "#1" and - ## "#0", which means it is possible for bit - ## pattern-matching to become exhaustive if complementary parts meet. + ... Bits are the exception, since there is only "#1" and + ... "#0", which means it is possible for bit + ... pattern-matching to become exhaustive if complementary parts meet. (#/.Simple (#/.Bit value)) (////\in (#Bit value)) - ## Tuple patterns can be exhaustive if there is exhaustiveness for all of - ## their sub-patterns. + ... Tuple patterns can be exhaustive if there is exhaustiveness for all of + ... their sub-patterns. (#/.Complex (#/.Tuple membersP+)) (case (list.reversed membersP+) (^or #.End (#.Item _ #.End)) @@ -140,8 +140,8 @@ (in (#Seq leftC rightC))))) lastC prevsP+))) - ## Variant patterns can be shown to be exhaustive if all the possible - ## cases are handled exhaustively. + ... Variant patterns can be shown to be exhaustive if all the possible + ... cases are handled exhaustively. (#/.Complex (#/.Variant [lefts right? value])) (do ////.monad [value_coverage (determine value) @@ -159,12 +159,12 @@ (or (and left (not right)) (and (not left) right))) -## The coverage checker not only verifies that pattern-matching is -## exhaustive, but also that there are no redundant patterns. -## Redundant patterns will never be executed, since there will -## always be a pattern prior to them that would match the input. -## Because of that, the presence of redundant patterns is assumed to -## be a bug, likely due to programmer carelessness. +... The coverage checker not only verifies that pattern-matching is +... exhaustive, but also that there are no redundant patterns. +... Redundant patterns will never be executed, since there will +... always be a pattern prior to them that would match the input. +... Because of that, the presence of redundant patterns is assumed to +... be a bug, likely due to programmer carelessness. (exception: .public (redundant_pattern {so_far Coverage} {addition Coverage}) (exception.report ["Coverage so-far" (%coverage so_far)] @@ -215,17 +215,17 @@ ["So-far Cases" (%.nat so_far_cases)] ["Addition Cases" (%.nat addition_cases)])) -## After determining the coverage of each individual pattern, it is -## necessary to merge them all to figure out if the entire -## pattern-matching expression is exhaustive and whether it contains -## redundant patterns. +... After determining the coverage of each individual pattern, it is +... necessary to merge them all to figure out if the entire +... pattern-matching expression is exhaustive and whether it contains +... redundant patterns. (def: .public (merged addition so_far) (-> Coverage Coverage (Try Coverage)) (case [addition so_far] [#Partial #Partial] (try\in #Partial) - ## 2 bit coverages are exhaustive if they complement one another. + ... 2 bit coverages are exhaustive if they complement one another. (^multi [(#Bit sideA) (#Bit sideSF)] (xor sideA sideSF)) (try\in #Exhaustive) @@ -241,7 +241,7 @@ (\ (dictionary.equivalence ..equivalence) = casesSF casesA) (exception.except ..redundant_pattern [so_far addition]) - ## else + ... else (do {! try.monad} [casesM (monad.fold ! (function (_ [tagA coverageA] casesSF') @@ -270,58 +270,58 @@ [(#Seq leftA rightA) (#Seq leftSF rightSF)] (case [(coverage/= leftSF leftA) (coverage/= rightSF rightA)] - ## Same prefix + ... Same prefix [#1 #0] (do try.monad [rightM (merged rightA rightSF)] (if (exhaustive? rightM) - ## If all that follows is exhaustive, then it can be safely dropped - ## (since only the "left" part would influence whether the - ## merged coverage is exhaustive or not). + ... If all that follows is exhaustive, then it can be safely dropped + ... (since only the "left" part would influence whether the + ... merged coverage is exhaustive or not). (in leftSF) (in (#Seq leftSF rightM)))) - ## Same suffix + ... Same suffix [#0 #1] (do try.monad [leftM (merged leftA leftSF)] (in (#Seq leftM rightA))) - ## The 2 sequences cannot possibly be merged. + ... The 2 sequences cannot possibly be merged. [#0 #0] (try\in (#Alt so_far addition)) - ## There is nothing the addition adds to the coverage. + ... There is nothing the addition adds to the coverage. [#1 #1] (exception.except ..redundant_pattern [so_far addition])) - ## The addition cannot possibly improve the coverage. + ... The addition cannot possibly improve the coverage. [_ #Exhaustive] (exception.except ..redundant_pattern [so_far addition]) - ## The addition completes the coverage. + ... The addition completes the coverage. [#Exhaustive _] (try\in #Exhaustive) - ## The left part will always match, so the addition is redundant. + ... The left part will always match, so the addition is redundant. (^multi [(#Seq left right) single] (coverage/= left single)) (exception.except ..redundant_pattern [so_far addition]) - ## The right part is not necessary, since it can always match the left. + ... The right part is not necessary, since it can always match the left. (^multi [single (#Seq left right)] (coverage/= left single)) (try\in single) - ## When merging a new coverage against one based on Alt, it may be - ## that one of the many coverages in the Alt is complementary to - ## the new one, so effort must be made to fuse carefully, to match - ## the right coverages together. - ## If one of the Alt sub-coverages matches the new one, the cycle - ## must be repeated, in case the resulting coverage can now match - ## other ones in the original Alt. - ## This process must be repeated until no further productive - ## merges can be done. + ... When merging a new coverage against one based on Alt, it may be + ... that one of the many coverages in the Alt is complementary to + ... the new one, so effort must be made to fuse carefully, to match + ... the right coverages together. + ... If one of the Alt sub-coverages matches the new one, the cycle + ... must be repeated, in case the resulting coverage can now match + ... other ones in the original Alt. + ... This process must be repeated until no further productive + ... merges can be done. [_ (#Alt leftS rightS)] (do {! try.monad} [.let [fuse_once (: (-> Coverage (List Coverage) @@ -369,7 +369,7 @@ _ (if (coverage/= so_far addition) - ## The addition cannot possibly improve the coverage. + ... The addition cannot possibly improve the coverage. (exception.except ..redundant_pattern [so_far addition]) - ## There are now 2 alternative paths. + ... There are now 2 alternative paths. (try\in (#Alt so_far addition))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux index 3797288ae..265311550 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux @@ -76,7 +76,7 @@ (#.Some expectedT') (recur expectedT') - ## Inference + ... Inference _ (do ! [[input_id inputT] (//type.with_env check.var) @@ -94,8 +94,8 @@ (//scope.environment scope)) bodyA))) /.with_scope - ## Functions have access not only to their argument, but - ## also to themselves, through a local variable. + ... Functions have access not only to their argument, but + ... also to themselves, through a local variable. (//scope.with_local [function_name expectedT]) (//scope.with_local [arg_name inputT]) (//type.with_type outputT) 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 f7980c7ec..a07afe1fa 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 @@ -100,13 +100,13 @@ [ex_id _] (//type.with_env check.existential)] (in (named_type location ex_id)))) -## Type-inference works by applying some (potentially quantified) type -## to a sequence of values. -## Function types are used for this, although inference is not always -## done for function application (alternative uses may be records and -## tagged variants). -## But, so long as the type being used for the inference can be treated -## as a function type, this method of inference should work. +... Type-inference works by applying some (potentially quantified) type +... to a sequence of values. +... Function types are used for this, although inference is not always +... done for function application (alternative uses may be records and +... tagged variants). +... But, so long as the type being used for the inference can be treated +... as a function type, this method of inference should work. (def: .public (general archive analyse inferT args) (-> Archive Phase Type (List Code) (Operation [Type (List Analysis)])) (case args @@ -149,13 +149,13 @@ #.None (/.except ..invalid_type_application inferT)) - ## Arguments are inferred back-to-front because, by convention, - ## Lux functions take the most important arguments *last*, which - ## means that the most information for doing proper inference is - ## located in the last arguments to a function call. - ## By inferring back-to-front, a lot of type-annotations can be - ## avoided in Lux code, since the inference algorithm can piece - ## things together more easily. + ... Arguments are inferred back-to-front because, by convention, + ... Lux functions take the most important arguments *last*, which + ... means that the most information for doing proper inference is + ... located in the last arguments to a function call. + ... By inferring back-to-front, a lot of type-annotations can be + ... avoided in Lux code, since the inference algorithm can piece + ... things together more easily. (#.Function inputT outputT) (do ///.monad [[outputT' args'A] (general archive analyse outputT args') @@ -203,7 +203,7 @@ _ base))) -## Turns a record type into the kind of function type suitable for inference. +... Turns a record type into the kind of function type suitable for inference. (def: (record' target originalT inferT) (-> Nat Type Type (Operation Type)) (case inferT @@ -238,7 +238,7 @@ (-> Type (Operation Type)) (record' (n.- 2 0) inferT inferT)) -## Turns a variant type into the kind of function type suitable for inference. +... Turns a variant type into the kind of function type suitable for inference. (def: .public (variant tag expected_size inferT) (-> Nat Nat Type (Operation Type)) (loop [depth 0 @@ -286,7 +286,7 @@ (type.function (list (replace' caseT)) (replace' currentT)))))) - ## else + ... else (/.except ..variant_tag_out_of_bounds [expected_size tag inferT]))) (#.Apply inputT funcT) 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 2906b9fe8..097f47cce 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 @@ -1,6 +1,6 @@ (.module: [library - [lux #* + [lux (#- local) [abstract monad] [control @@ -174,8 +174,7 @@ output]) (#try.Failure error) - (#try.Failure error))) - )) + (#try.Failure error))))) (exception: .public cannot_get_next_reference_when_there_is_no_scope) 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 50afd0eed..6ff5f7ce4 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 @@ -125,9 +125,9 @@ (//type.with_type expectedT' (recur valueC)) - ## Cannot do inference when the tag is numeric. - ## This is because there is no way of knowing how many - ## cases the inferred sum type would have. + ... Cannot do inference when the tag is numeric. + ... This is because there is no way of knowing how many + ... cases the inferred sum type would have. _ (/.except ..cannot_infer_numeric_tag [expectedT tag valueC]))) @@ -215,7 +215,7 @@ (product archive analyse membersC)) _ - ## Must do inference... + ... Must do inference... (do ! [membersTA (monad.map ! (|>> (analyse archive) //type.with_inference) membersC) @@ -277,10 +277,10 @@ _ (..sum analyse lefts right? archive valueC)))) -## There cannot be any ambiguity or improper syntax when analysing -## records, so they must be normalized for further analysis. -## Normalization just means that all the tags get resolved to their -## canonical form (with their corresponding module identified). +... There cannot be any ambiguity or improper syntax when analysing +... records, so they must be normalized for further analysis. +... Normalization just means that all the tags get resolved to their +... canonical form (with their corresponding module identified). (def: .public (normal record) (-> (List [Code Code]) (Operation (List [Name Code]))) (monad.map ///.monad @@ -295,13 +295,13 @@ (/.except ..record_keys_must_be_tags [key record]))) record)) -## Lux already possesses the means to analyse tuples, so -## re-implementing the same functionality for records makes no sense. -## Records, thus, get transformed into tuples by ordering the elements. +... Lux already possesses the means to analyse tuples, so +... re-implementing the same functionality for records makes no sense. +... Records, thus, get transformed into tuples by ordering the elements. (def: .public (order record) (-> (List [Name Code]) (Operation [(List Code) Type])) (case record - ## empty_record = empty_tuple = unit = [] + ... empty_record = empty_tuple = unit = [] #.End (\ ///.monad in [(list) Any]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux index b085da3c0..16a8764d5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux @@ -196,7 +196,7 @@ [($_ <>.and <c>.nat <c>.any) (function (_ extension phase archive [arity abstractionC]) (do phase.monad - [.let [inputT (type.tuple (list.repeat arity Any))] + [.let [inputT (type.tuple (list.repeated arity Any))] abstractionA (analysis/type.with_type (-> inputT Any) (phase archive abstractionC)) _ (analysis/type.infer (for {@.js ffi.Function} 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 b98b2732a..d74b18019 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -161,12 +161,12 @@ (#.Primitive ..inheritance_relationship_type_name (list& class super_class super_interfaces))) -## TODO: Get rid of this template block and use the definition in -## lux/ffi.jvm.lux ASAP +... TODO: Get rid of this template block and use the definition in +... lux/ffi.jvm.lux ASAP (template [<name> <class>] [(def: .public <name> .Type (#.Primitive <class> #.End))] - ## Boxes + ... Boxes [Boolean box.boolean] [Byte box.byte] [Short box.short] @@ -177,7 +177,7 @@ [Character box.char] [String "java.lang.String"] - ## Primitives + ... Primitives [boolean (reflection.reflection reflection.boolean)] [byte (reflection.reflection reflection.byte)] [short (reflection.reflection reflection.short)] @@ -496,7 +496,7 @@ (text.starts_with? descriptor.array_prefix name)) (/////analysis.except ..non_parameter objectT) - ## else + ... else (phase\in (jvm.class name (list))))) (#.Named name anonymous) @@ -560,7 +560,7 @@ (\ phase.monad map jvm.array (check_jvm (#.Primitive unprefixed (list))))) - ## else + ... else (phase\in (jvm.class name (list))))) (^ (#.Primitive (static array.type_name) @@ -928,7 +928,7 @@ [reflection.double box.double] [reflection.char box.char])) - ## else + ... else (do ! [_ (phase.assertion ..primitives_are_not_objects [source_name] (not (dictionary.key? ..boxes source_name))) @@ -1633,7 +1633,7 @@ Strictness (List (Annotation a)) (List (Type Var)) - (List (Type Class)) ## Exceptions + (List (Type Class)) ... Exceptions Text (List Argument) (List (Typed a)) @@ -1715,7 +1715,7 @@ Text (List Argument) (Type Return) - (List (Type Class)) ## Exceptions + (List (Type Class)) ... Exceptions a]) (def: virtual_tag "virtual") @@ -1789,7 +1789,7 @@ Strictness (List (Annotation a)) (List (Type Var)) - (List (Type Class)) ## Exceptions + (List (Type Class)) ... Exceptions (List Argument) (Type Return) a]) @@ -2079,7 +2079,7 @@ (def: (anonymous_class_name module id) (-> Module Nat Text) - (let [global (text.replace_all .module_separator ..jvm_package_separator module) + (let [global (text.replaced .module_separator ..jvm_package_separator module) local (format "anonymous-class" (%.nat id))] (format global ..jvm_package_separator local))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux index 2fe863c2a..9428404aa 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux @@ -228,7 +228,7 @@ [($_ <>.and <code>.nat <code>.any) (function (_ extension phase archive [arity abstractionC]) (do phase.monad - [.let [inputT (type.tuple (list.repeat arity Any))] + [.let [inputT (type.tuple (list.repeated arity Any))] abstractionA (analysis/type.with_type (-> inputT Any) (phase archive abstractionC)) _ (analysis/type.infer ..Function)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux index b3f48d4ce..5a76b1804 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux @@ -79,7 +79,7 @@ (-> Type Type Type Type Handler) (simple (list subjectT param0T param1T) outputT)) -## TODO: Get rid of this ASAP +... TODO: Get rid of this ASAP (as_is (exception: .public (char_text_must_be_size_1 {text Text}) (exception.report @@ -121,7 +121,7 @@ (list& input else) (#////analysis.Extension extension_name)))))]))) -## "lux is" represents reference/pointer equality. +... "lux is" represents reference/pointer equality. (def: lux::is Handler (function (_ extension_name analyse archive args) @@ -130,8 +130,8 @@ ((binary varT varT Bit extension_name) analyse archive args)))) -## "lux try" provides a simple way to interact with the host platform's -## error_handling facilities. +... "lux try" provides a simple way to interact with the host platform's +... error_handling facilities. (def: lux::try Handler (function (_ extension_name analyse archive args) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux index 915933925..5fb859b4a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux @@ -196,7 +196,7 @@ [($_ <>.and <code>.nat <code>.any) (function (_ extension phase archive [arity abstractionC]) (do phase.monad - [.let [inputT (type.tuple (list.repeat arity Any))] + [.let [inputT (type.tuple (list.repeated arity Any))] abstractionA (analysis/type.with_type (-> inputT Any) (phase archive abstractionC)) _ (analysis/type.infer ..Function)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux index 00ed63ebf..505ae3bd3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux @@ -185,7 +185,7 @@ (def: (field_definition field) (-> Field (Resource field.Field)) (case field - ## TODO: Handle annotations. + ... TODO: Handle annotations. (#Constant [name annotations type value]) (case value (^template [<tag> <type> <constant>] @@ -205,11 +205,11 @@ [#.Text (type.class "java.lang.String" (list)) [pool.string]] ) - ## TODO: Tighten this pattern-matching so this catch-all clause isn't necessary. + ... TODO: Tighten this pattern-matching so this catch-all clause isn't necessary. _ (undefined)) - ## TODO: Handle annotations. + ... TODO: Handle annotations. (#Variable [name visibility state annotations type]) (field.field (modifier\compose visibility state) name type (row.row)))) @@ -255,7 +255,7 @@ super_class super_interfaces inheritance - ## TODO: Handle annotations. + ... TODO: Handle annotations. annotations fields methods]) @@ -284,16 +284,16 @@ generate (get@ [#directive.generation #directive.phase] state)] methods (monad.map ! (..method_definition [mapping selfT] [analyse synthesize generate]) methods) - ## _ (directive.lift_generation - ## (generation.save! true ["" name] - ## [name - ## (class.class version.v6_0 - ## (modifier\compose class.public inheritance) - ## (name.internal name) (list\map (|>> product.left parser.name ..constraint) parameters) - ## super_class super_interfaces - ## (list\map ..field_definition fields) - ## (list) ## TODO: Add methods - ## (row.row))])) + ... _ (directive.lift_generation + ... (generation.save! true ["" name] + ... [name + ... (class.class version.v6_0 + ... (modifier\compose class.public inheritance) + ... (name.internal name) (list\map (|>> product.left parser.name ..constraint) parameters) + ... super_class super_interfaces + ... (list\map ..field_definition fields) + ... (list) ... TODO: Add methods + ... (row.row))])) _ (directive.lift_generation (generation.log! (format "Class " name)))] (in directive.no_requirements)))])) @@ -302,6 +302,6 @@ (Bundle Anchor (Bytecode Any) Definition) (<| (bundle.prefix "jvm") (|> bundle.empty - ## TODO: Finish handling methods and un-comment. - ## (dictionary.put "class" jvm::class) + ... TODO: Finish handling methods and un-comment. + ... (dictionary.put "class" jvm::class) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux index 2861e1201..5c130e466 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux @@ -63,10 +63,10 @@ (def: (context [module_id artifact_id]) (-> Context Context) - ## TODO: Find a better way that doesn't rely on clever tricks. + ... TODO: Find a better way that doesn't rely on clever tricks. [module_id (n.- (inc artifact_id) 0)]) -## TODO: Inline "evaluate!'" into "evaluate!" ASAP +... TODO: Inline "evaluate!'" into "evaluate!" ASAP (def: (evaluate!' archive generate code//type codeS) (All [anchor expression directive] (-> Archive @@ -100,7 +100,7 @@ (synthesize archive codeA))] (evaluate!' archive generate type codeS))) -## TODO: Inline "definition'" into "definition" ASAP +... TODO: Inline "definition'" into "definition" ASAP (def: (definition' archive generate [module name] code//type codeS) (All [anchor expression directive] (-> Archive @@ -149,7 +149,7 @@ (definition' archive generate name code//type codeS))) (template [<full> <partial> <learn>] - [## TODO: Inline "<partial>" into "<full>" ASAP + [... TODO: Inline "<partial>" into "<full>" ASAP (def: (<partial> archive generate extension codeT codeS) (All [anchor expression directive] (-> Archive @@ -366,9 +366,9 @@ ..directive] ) -## TODO; Both "prepare-program" and "define-program" exist only -## because the old compiler couldn't handle a fully-inlined definition -## for "def::program". Inline them ASAP. +... TODO; Both "prepare-program" and "define-program" exist only +... because the old compiler couldn't handle a fully-inlined definition +... for "def::program". Inline them ASAP. (def: (prepare_program archive analyse synthesize programC) (All [anchor expression directive output] (-> Archive 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 13b4a40e4..bfe808472 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 @@ -54,44 +54,44 @@ (template: (!unary function) (|>> list _.apply/* (|> (_.constant function)))) -## ## TODO: Get rid of this ASAP -## (def: lux::syntax_char_case! -## (..custom [($_ <>.and -## <s>.any -## <s>.any -## (<>.some (<s>.tuple ($_ <>.and -## (<s>.tuple (<>.many <s>.i64)) -## <s>.any)))) -## (function (_ extension_name phase archive [input else conditionals]) -## (do {! /////.monad} -## [@input (\ ! map _.var (generation.gensym "input")) -## inputG (phase archive input) -## elseG (phase archive else) -## conditionalsG (: (Operation (List [Expression Expression])) -## (monad.map ! (function (_ [chars branch]) -## (do ! -## [branchG (phase archive branch)] -## (in [(|> chars (list\map (|>> .int _.int (_.=/2 @input))) _.or) -## branchG]))) -## conditionals))] -## (in (_.let (list [@input inputG]) -## (list (list\fold (function (_ [test then] else) -## (_.if test then else)) -## elseG -## conditionalsG))))))])) +... ... TODO: Get rid of this ASAP +... (def: lux::syntax_char_case! +... (..custom [($_ <>.and +... <s>.any +... <s>.any +... (<>.some (<s>.tuple ($_ <>.and +... (<s>.tuple (<>.many <s>.i64)) +... <s>.any)))) +... (function (_ extension_name phase archive [input else conditionals]) +... (do {! /////.monad} +... [@input (\ ! map _.var (generation.gensym "input")) +... inputG (phase archive input) +... elseG (phase archive else) +... conditionalsG (: (Operation (List [Expression Expression])) +... (monad.map ! (function (_ [chars branch]) +... (do ! +... [branchG (phase archive branch)] +... (in [(|> chars (list\map (|>> .int _.int (_.=/2 @input))) _.or) +... branchG]))) +... conditionals))] +... (in (_.let (list [@input inputG]) +... (list (list\fold (function (_ [test then] else) +... (_.if test then else)) +... elseG +... conditionalsG))))))])) (def: lux_procs Bundle (|> /.empty - ## (/.install "syntax char case!" lux::syntax_char_case!) + ... (/.install "syntax char case!" lux::syntax_char_case!) (/.install "is" (binary _.eq/2)) - ## (/.install "try" (unary //runtime.lux//try)) + ... (/.install "try" (unary //runtime.lux//try)) )) -## (def: (capped operation parameter subject) -## (-> (-> Expression Expression Expression) -## (-> Expression Expression Expression)) -## (//runtime.i64//64 (operation parameter subject))) +... (def: (capped operation parameter subject) +... (-> (-> Expression Expression Expression) +... (-> Expression Expression Expression)) +... (//runtime.i64//64 (operation parameter subject))) (def: i64_procs Bundle @@ -109,7 +109,7 @@ (/.install "*" (binary _.*/2)) (/.install "/" (binary _.floor/2)) (/.install "%" (binary _.rem/2)) - ## (/.install "f64" (unary (_.//2 (_.float +1.0)))) + ... (/.install "f64" (unary (_.//2 (_.float +1.0)))) (/.install "char" (unary (|>> _.code_char/1 _.string/1))) ))) @@ -117,16 +117,16 @@ Bundle (<| (/.prefix "f64") (|> /.empty - ## (/.install "=" (binary (product.uncurry _.=/2))) - ## (/.install "<" (binary (product.uncurry _.</2))) - ## (/.install "+" (binary (product.uncurry _.+/2))) - ## (/.install "-" (binary (product.uncurry _.-/2))) - ## (/.install "*" (binary (product.uncurry _.*/2))) - ## (/.install "/" (binary (product.uncurry _.//2))) - ## (/.install "%" (binary (product.uncurry _.rem/2))) - ## (/.install "i64" (unary _.truncate/1)) + ... (/.install "=" (binary (product.uncurry _.=/2))) + ... (/.install "<" (binary (product.uncurry _.</2))) + ... (/.install "+" (binary (product.uncurry _.+/2))) + ... (/.install "-" (binary (product.uncurry _.-/2))) + ... (/.install "*" (binary (product.uncurry _.*/2))) + ... (/.install "/" (binary (product.uncurry _.//2))) + ... (/.install "%" (binary (product.uncurry _.rem/2))) + ... (/.install "i64" (unary _.truncate/1)) (/.install "encode" (unary _.write_to_string/1)) - ## (/.install "decode" (unary //runtime.f64//decode)) + ... (/.install "decode" (unary //runtime.f64//decode)) ))) (def: (text//index [offset sub text]) @@ -146,7 +146,7 @@ (<| (/.prefix "text") (|> /.empty (/.install "=" (binary _.string=/2)) - ## (/.install "<" (binary (product.uncurry _.string<?/2))) + ... (/.install "<" (binary (product.uncurry _.string<?/2))) (/.install "concat" (binary (function (_ [left right]) (_.concatenate/3 [(_.symbol "string") left right])))) (/.install "index" (trinary ..text//index)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux index af7b75366..f17ea75a3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux @@ -45,8 +45,8 @@ (#try.Failure error) (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -## [Procedures] -## [[Bits]] +... [Procedures] +... [[Bits]] (template [<name> <op>] [(def: (<name> [paramG subjectG]) (Binary Expression) @@ -56,7 +56,7 @@ [i64//right_shifted //runtime.i64//right_shifted] ) -## [[Numbers]] +... [[Numbers]] (def: f64//decode (Unary Expression) (|>> list @@ -71,7 +71,7 @@ (list) (_.apply/* (_.var "String.fromCharCode")))) -## [[Text]] +... [[Text]] (def: (text//concat [leftG rightG]) (Binary Expression) (|> leftG (_.do "concat" (list rightG)))) @@ -84,14 +84,14 @@ (Trinary Expression) (//runtime.text//index startG partG subjectG)) -## [[IO]] +... [[IO]] (def: (io//log messageG) (Unary Expression) ($_ _., (//runtime.io//log messageG) //runtime.unit)) -## TODO: Get rid of this ASAP +... TODO: Get rid of this ASAP (def: lux::syntax_char_case! (..custom [($_ <>.and <s>.any @@ -117,7 +117,7 @@ (#.Some (_.return elseG)))) (list)))))])) -## [Bundles] +... [Bundles] (def: lux_procs Bundle (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux index 9daf4b072..b2c84251e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux @@ -136,7 +136,7 @@ (|>> generation.gensym (\ ! map _.var)))] g!inputs (monad.map ! (function (_ _) (variable "input")) - (list.repeat (.nat arity) [])) + (list.repeated (.nat arity) [])) g!abstraction (variable "abstraction")] (in (_.closure g!inputs ($_ _.then diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux index b21b16ad4..4bd10e9ec 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux @@ -96,7 +96,7 @@ (_.set_label @end) ))) -## TODO: Get rid of this ASAP +... TODO: Get rid of this ASAP (def: lux::syntax_char_case! (..custom [($_ <>.and <s>.any diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux index b3f22b503..953a4b88a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux @@ -608,7 +608,7 @@ [box.float type.float "floatValue"] [box.double type.double "doubleValue"] [box.char type.char "charValue"])) - ## else + ... else valueG)))))])) (def: bundle::object @@ -931,11 +931,12 @@ (#//////synthesis.Extension [name inputsS+]) (#//////synthesis.Extension [name (list\map recur inputsS+)])))) -(def: $Object (type.class "java.lang.Object" (list))) +(def: $Object + (type.class "java.lang.Object" (list))) (def: (anonymous_init_method env) (-> (Environment Synthesis) (Type category.Method)) - (type.method [(list.repeat (list.size env) ..$Object) + (type.method [(list.repeated (list.size env) ..$Object) type.void (list)])) @@ -995,7 +996,7 @@ (\ type.equivalence = type.float returnT) _.freturn - ## (\ type.equivalence = type.double returnT) + ... (\ type.equivalence = type.double returnT) _.dreturn)))) (def: class::anonymous @@ -1015,15 +1016,15 @@ anonymous_class_name (///runtime.class_name context) class (type.class anonymous_class_name (list)) total_environment (|> overriden_methods - ## Get all the environments. + ... Get all the environments. (list\map product.left) - ## Combine them. + ... Combine them. list\join - ## Remove duplicates. + ... Remove duplicates. (set.from_list //////synthesis.hash) set.list) global_mapping (|> total_environment - ## Give them names as "foreign" variables. + ... Give them names as "foreign" variables. list.enumeration (list\map (function (_ [id capture]) [capture (#//////variable.Foreign id)])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux index 656ccac5c..1ef715e28 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux @@ -51,7 +51,7 @@ (template: (!unary function) (|>> list _.apply/* (|> (_.var function)))) -## TODO: Get rid of this ASAP +... TODO: Get rid of this ASAP (def: lux::syntax_char_case! (..custom [($_ <>.and <s>.any @@ -151,9 +151,9 @@ (/.install "concat" (binary (product.uncurry (function.flip _.concat)))) (/.install "index" (trinary ..text//index)) (/.install "size" (unary //runtime.text//size)) - ## TODO: Use version below once the Lua compiler becomes self-hosted. - ## (/.install "size" (unary (for {@.lua (!unary "utf8.len")} - ## (!unary "string.len")))) + ... TODO: Use version below once the Lua compiler becomes self-hosted. + ... (/.install "size" (unary (for {@.lua (!unary "utf8.len")} + ... (!unary "string.len")))) (/.install "char" (binary ..text//char)) (/.install "clip" (trinary ..text//clip)) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux index 1a633675d..e3363fe01 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux @@ -175,7 +175,7 @@ (\ ! map _.var)))] g!inputs (monad.map ! (function (_ _) (variable "input")) - (list.repeat (.nat arity) []))] + (list.repeated (.nat arity) []))] (in (<| (_.closure g!inputs) _.statement (case (.nat arity) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux index 11be7a215..b061d4cc1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux @@ -54,7 +54,7 @@ (template: (!unary function) (|>> list _.apply/* (|> (_.constant function)))) -## TODO: Get rid of this ASAP +... TODO: Get rid of this ASAP (def: lux::syntax_char_case! (..custom [($_ <>.and <s>.any diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux index 4f6c64210..7d32ad88a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux @@ -48,7 +48,7 @@ (#try.Failure error) (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -## TODO: Get rid of this ASAP +... TODO: Get rid of this ASAP (def: lux::syntax_char_case! (..custom [($_ <>.and <s>.any diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux index 349186b55..81d1373d6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux @@ -134,7 +134,7 @@ (|>> generation.gensym (\ ! map _.var)))] g!inputs (monad.map ! (function (_ _) (variable "input")) - (list.repeat (.nat arity) []))] + (list.repeated (.nat arity) []))] (in (_.lambda g!inputs (case (.nat arity) 0 (_.apply/1 abstractionG //runtime.unit) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux index f547703e3..f14017891 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux @@ -51,129 +51,129 @@ (#try.Failure error) (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -## (template: (!unary function) -## (|>> list _.apply/* (|> (_.constant function)))) +... (template: (!unary function) +... (|>> list _.apply/* (|> (_.constant function)))) -## ## ## TODO: Get rid of this ASAP -## ## (def: lux::syntax_char_case! -## ## (..custom [($_ <>.and -## ## <s>.any -## ## <s>.any -## ## (<>.some (<s>.tuple ($_ <>.and -## ## (<s>.tuple (<>.many <s>.i64)) -## ## <s>.any)))) -## ## (function (_ extension_name phase archive [input else conditionals]) -## ## (do {! /////.monad} -## ## [@input (\ ! map _.var (generation.gensym "input")) -## ## inputG (phase archive input) -## ## elseG (phase archive else) -## ## conditionalsG (: (Operation (List [Expression Expression])) -## ## (monad.map ! (function (_ [chars branch]) -## ## (do ! -## ## [branchG (phase archive branch)] -## ## (in [(|> chars (list\map (|>> .int _.int (_.=/2 @input))) _.or) -## ## branchG]))) -## ## conditionals))] -## ## (in (_.let (list [@input inputG]) -## ## (list (list\fold (function (_ [test then] else) -## ## (_.if test then else)) -## ## elseG -## ## conditionalsG))))))])) +... ... ... TODO: Get rid of this ASAP +... ... (def: lux::syntax_char_case! +... ... (..custom [($_ <>.and +... ... <s>.any +... ... <s>.any +... ... (<>.some (<s>.tuple ($_ <>.and +... ... (<s>.tuple (<>.many <s>.i64)) +... ... <s>.any)))) +... ... (function (_ extension_name phase archive [input else conditionals]) +... ... (do {! /////.monad} +... ... [@input (\ ! map _.var (generation.gensym "input")) +... ... inputG (phase archive input) +... ... elseG (phase archive else) +... ... conditionalsG (: (Operation (List [Expression Expression])) +... ... (monad.map ! (function (_ [chars branch]) +... ... (do ! +... ... [branchG (phase archive branch)] +... ... (in [(|> chars (list\map (|>> .int _.int (_.=/2 @input))) _.or) +... ... branchG]))) +... ... conditionals))] +... ... (in (_.let (list [@input inputG]) +... ... (list (list\fold (function (_ [test then] else) +... ... (_.if test then else)) +... ... elseG +... ... conditionalsG))))))])) -## (def: lux_procs -## Bundle -## (|> /.empty -## ## (/.install "syntax char case!" lux::syntax_char_case!) -## (/.install "is" (binary _.eq/2)) -## ## (/.install "try" (unary //runtime.lux//try)) -## )) +... (def: lux_procs +... Bundle +... (|> /.empty +... ... (/.install "syntax char case!" lux::syntax_char_case!) +... (/.install "is" (binary _.eq/2)) +... ... (/.install "try" (unary //runtime.lux//try)) +... )) -## ## (def: (capped operation parameter subject) -## ## (-> (-> Expression Expression Expression) -## ## (-> Expression Expression Expression)) -## ## (//runtime.i64//64 (operation parameter subject))) +... ... (def: (capped operation parameter subject) +... ... (-> (-> Expression Expression Expression) +... ... (-> Expression Expression Expression)) +... ... (//runtime.i64//64 (operation parameter subject))) (def: i64_procs Bundle (<| (/.prefix "i64") (|> /.empty - ## (/.install "and" (binary _.logand/2)) - ## (/.install "or" (binary _.logior/2)) - ## (/.install "xor" (binary _.logxor/2)) - ## (/.install "left-shift" (binary _.ash/2)) - ## (/.install "right-shift" (binary (product.uncurry //runtime.i64//right_shift))) - ## (/.install "=" (binary _.=/2)) - ## (/.install "<" (binary _.</2)) - ## (/.install "+" (binary _.+/2)) - ## (/.install "-" (binary _.-/2)) - ## (/.install "*" (binary _.*/2)) - ## (/.install "/" (binary _.floor/2)) - ## (/.install "%" (binary _.rem/2)) - ## (/.install "f64" (unary (_.//2 (_.float +1.0)))) + ... (/.install "and" (binary _.logand/2)) + ... (/.install "or" (binary _.logior/2)) + ... (/.install "xor" (binary _.logxor/2)) + ... (/.install "left-shift" (binary _.ash/2)) + ... (/.install "right-shift" (binary (product.uncurry //runtime.i64//right_shift))) + ... (/.install "=" (binary _.=/2)) + ... (/.install "<" (binary _.</2)) + ... (/.install "+" (binary _.+/2)) + ... (/.install "-" (binary _.-/2)) + ... (/.install "*" (binary _.*/2)) + ... (/.install "/" (binary _.floor/2)) + ... (/.install "%" (binary _.rem/2)) + ... (/.install "f64" (unary (_.//2 (_.float +1.0)))) (/.install "char" (unary (|>> //runtime.i64_low _.intToUtf8/1))) ))) -## (def: f64_procs -## Bundle -## (<| (/.prefix "f64") -## (|> /.empty -## ## (/.install "=" (binary (product.uncurry _.=/2))) -## ## (/.install "<" (binary (product.uncurry _.</2))) -## ## (/.install "+" (binary (product.uncurry _.+/2))) -## ## (/.install "-" (binary (product.uncurry _.-/2))) -## ## (/.install "*" (binary (product.uncurry _.*/2))) -## ## (/.install "/" (binary (product.uncurry _.//2))) -## ## (/.install "%" (binary (product.uncurry _.rem/2))) -## ## (/.install "i64" (unary _.truncate/1)) -## (/.install "encode" (unary _.write_to_string/1)) -## ## (/.install "decode" (unary //runtime.f64//decode)) -## ))) +... (def: f64_procs +... Bundle +... (<| (/.prefix "f64") +... (|> /.empty +... ... (/.install "=" (binary (product.uncurry _.=/2))) +... ... (/.install "<" (binary (product.uncurry _.</2))) +... ... (/.install "+" (binary (product.uncurry _.+/2))) +... ... (/.install "-" (binary (product.uncurry _.-/2))) +... ... (/.install "*" (binary (product.uncurry _.*/2))) +... ... (/.install "/" (binary (product.uncurry _.//2))) +... ... (/.install "%" (binary (product.uncurry _.rem/2))) +... ... (/.install "i64" (unary _.truncate/1)) +... (/.install "encode" (unary _.write_to_string/1)) +... ... (/.install "decode" (unary //runtime.f64//decode)) +... ))) -## (def: (text//index [offset sub text]) -## (Trinary (Expression Any)) -## (//runtime.text//index offset sub text)) +... (def: (text//index [offset sub text]) +... (Trinary (Expression Any)) +... (//runtime.text//index offset sub text)) -## (def: (text//clip [offset length text]) -## (Trinary (Expression Any)) -## (//runtime.text//clip offset length text)) +... (def: (text//clip [offset length text]) +... (Trinary (Expression Any)) +... (//runtime.text//clip offset length text)) -## (def: (text//char [index text]) -## (Binary (Expression Any)) -## (_.char_code/1 (_.char/2 [text index]))) +... (def: (text//char [index text]) +... (Binary (Expression Any)) +... (_.char_code/1 (_.char/2 [text index]))) (def: text_procs Bundle (<| (/.prefix "text") (|> /.empty - ## (/.install "=" (binary _.string=/2)) - ## (/.install "<" (binary (product.uncurry _.string<?/2))) + ... (/.install "=" (binary _.string=/2)) + ... (/.install "<" (binary (product.uncurry _.string<?/2))) (/.install "concat" (binary _.paste/2)) - ## (/.install "index" (trinary ..text//index)) - ## (/.install "size" (unary _.length/1)) - ## (/.install "char" (binary ..text//char)) - ## (/.install "clip" (trinary ..text//clip)) + ... (/.install "index" (trinary ..text//index)) + ... (/.install "size" (unary _.length/1)) + ... (/.install "char" (binary ..text//char)) + ... (/.install "clip" (trinary ..text//clip)) ))) -## (def: (io//log! message) -## (Unary (Expression Any)) -## (_.progn (list (_.write_line/1 message) -## //runtime.unit))) +... (def: (io//log! message) +... (Unary (Expression Any)) +... (_.progn (list (_.write_line/1 message) +... //runtime.unit))) -## (def: io_procs -## Bundle -## (<| (/.prefix "io") -## (|> /.empty -## (/.install "log" (unary ..io//log!)) -## (/.install "error" (unary _.error/1)) -## ))) +... (def: io_procs +... Bundle +... (<| (/.prefix "io") +... (|> /.empty +... (/.install "log" (unary ..io//log!)) +... (/.install "error" (unary _.error/1)) +... ))) (def: .public bundle Bundle (<| (/.prefix "lux") (|> /.empty - ## (dictionary.merged lux_procs) + ... (dictionary.merged lux_procs) (dictionary.merged i64_procs) - ## (dictionary.merged f64_procs) + ... (dictionary.merged f64_procs) (dictionary.merged text_procs) - ## (dictionary.merged io_procs) + ... (dictionary.merged io_procs) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux index c1f9be2b9..cfe4e85e6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux @@ -48,7 +48,7 @@ (#try.Failure error) (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -## TODO: Get rid of this ASAP +... TODO: Get rid of this ASAP (def: lux::syntax_char_case! (..custom [($_ <>.and <s>.any 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 c04ee1e90..c90072ef1 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 @@ -54,7 +54,7 @@ (template: (!unary function) (|>> list _.apply/* (|> (_.constant function)))) -## TODO: Get rid of this ASAP +... TODO: Get rid of this ASAP (def: lux::syntax_char_case! (..custom [($_ <>.and <s>.any 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 2ca666bd4..9731cb94c 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 @@ -95,7 +95,7 @@ (_.apply/2 [(_.apply/2 [(_.function/1 @self) arity_inputs]) extra_inputs]))]) - ## (|> @num_args (_.< arityG)) + ... (|> @num_args (_.< arityG)) (_.lambda (_.args& (list) @missing) (_.apply/2 [(_.function/1 @self) (_.append/2 [@curried @missing])])))))]]) 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 b17b5fd09..7258dc416 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 @@ -35,11 +35,11 @@ (def: .public (scope expression archive [start initsS+ bodyS]) (Generator (Scope Synthesis)) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (expression archive bodyS) - ## true loop + ... true loop _ (do {! ///////phase.monad} [@scope (\ ! map (|>> %.nat (format "loop_scope") _.tag) /////generation.next) 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 0c557720d..32b090ae1 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 @@ -90,7 +90,7 @@ (syntax: .public (with_vars {vars (<code>.tuple (<>.some <code>.local_identifier))} body) (do {! meta.monad} - [ids (monad.seq ! (list.repeat (list.size vars) meta.seed))] + [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) @@ -144,7 +144,7 @@ (..left (_.format/3 [_.nil (_.string "~A") error]))]) (..right (_.funcall/+ [op (list ..unit)]))))) -## TODO: Use Common Lisp's swiss-army loop macro instead. +... TODO: Use Common Lisp's swiss-army loop macro instead. (runtime: (lux//program_args inputs) (with_vars [loop input tail] (_.labels (list [loop [(_.args (list input tail)) @@ -176,9 +176,9 @@ (with_vars [last_index_right] (_.let (list [last_index_right (..last_index tuple)]) (list (_.if (_.>/2 [lefts last_index_right]) - ## No need for recursion + ... No need for recursion (_.elt/2 [tuple lefts]) - ## Needs recursion + ... Needs recursion (!recur tuple//left)))))) (runtime: (tuple//right lefts tuple) @@ -188,18 +188,18 @@ (list (_.cond (list [(_.=/2 [last_index_right right_index]) (_.elt/2 [tuple right_index])] [(_.>/2 [last_index_right right_index]) - ## Needs recursion. + ... Needs recursion. (!recur tuple//right)]) (_.subseq/3 [tuple right_index (_.length/1 tuple)]))))))) -## TODO: Find a way to extract parts of the sum without "nth", which -## does a linear search, and is thus expensive. +... TODO: Find a way to extract parts of the sum without "nth", which +... does a linear search, and is thus expensive. (runtime: (sum//get sum wantsLast wantedTag) (with_vars [sum_tag sum_flag] (let [no_match! (_.return sum) sum_value (_.nth/2 [(_.int +2) sum]) test_recursion! (_.if sum_flag - ## Must iterate. + ... Must iterate. (_.progn (list (_.setq wantedTag (_.-/2 [sum_tag wantedTag])) (_.setq sum sum_value))) no_match!)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux index 95121edc4..5d8406d48 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux @@ -22,7 +22,7 @@ ["#" phase]]]]) (syntax: (Vector {size s.nat} elemT) - (in (list (` [(~+ (list.repeat size elemT))])))) + (in (list (` [(~+ (list.repeated size elemT))])))) (type: .public (Nullary of) (-> (Vector 0 of) of)) (type: .public (Unary of) (-> (Vector 1 of) of)) @@ -33,7 +33,7 @@ (syntax: (arity: {arity s.nat} {name s.local_identifier} type) (with_gensyms [g!_ g!extension g!name g!phase g!archive g!inputs g!of g!anchor g!expression g!directive] (do {! meta.monad} - [g!input+ (monad.seq ! (list.repeat arity (macro.gensym "input")))] + [g!input+ (monad.seq ! (list.repeated arity (macro.gensym "input")))] (in (list (` (def: .public ((~ (code.local_identifier name)) (~ g!extension)) (All [(~ g!anchor) (~ g!expression) (~ g!directive)] (-> ((~ type) (~ g!expression)) 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 51e58fb51..6671f1e3f 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 @@ -40,7 +40,7 @@ (do ///////phase.monad [valueO (expression archive valueS) bodyO (expression archive bodyS)] - ## TODO: Find some way to do 'let' without paying the price of the closure. + ... TODO: Find some way to do 'let' without paying the price of the closure. (in (_.apply/* (_.closure (list (..register register)) (_.return bodyO)) (list valueO))))) @@ -172,7 +172,7 @@ (^ (/////synthesis.member/left 0)) (///////phase\in (#.Some (push_cursor! (_.at (_.i32 +0) ..peek_cursor)))) - ## Extra optimization + ... Extra optimization (^ (/////synthesis.path/seq (/////synthesis.member/left 0) (/////synthesis.!bind_top register thenP))) @@ -182,7 +182,7 @@ (_.define (..register register) (_.at (_.i32 +0) ..peek_cursor)) then!)))) - ## Extra optimization + ... Extra optimization (^template [<pm> <getter>] [(^ (/////synthesis.path/seq (<pm> lefts) 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 00ac84cf8..75b54ebe7 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 @@ -107,7 +107,7 @@ (_.return (|> @self (apply_poly arity_inputs) (apply_poly extra_inputs))))]) - ## (|> @num_args (_.< arityO)) + ... (|> @num_args (_.< arityO)) (let [all_inputs (|> (_.array (list)) (_.the "slice") (_.do "call" (list @@arguments)))] 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 602ef1191..08a3a7c80 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 @@ -44,11 +44,11 @@ (def: .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (statement expression archive bodyS) - ## true loop + ... true loop _ (do {! ///////phase.monad} [@scope (\ ! map ..@scope /////generation.next) @@ -63,11 +63,11 @@ (def: .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (expression archive bodyS) - ## true loop + ... true loop _ (do {! ///////phase.monad} [loop! (scope! statement expression archive [start initsS+ bodyS])] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux index 5d09cbd16..815ee4a36 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux @@ -88,7 +88,7 @@ (syntax: .public (with_vars {vars (<code>.tuple (<>.some <code>.local_identifier))} body) (do {! meta.monad} - [ids (monad.seq ! (list.repeat (list.size vars) meta.seed))] + [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) @@ -153,9 +153,9 @@ ($_ _.then (_.define last_index_right (..last_index tuple)) (_.if (_.> lefts last_index_right) - ## No need for recursion + ... No need for recursion (_.return (_.at lefts tuple)) - ## Needs recursion + ... Needs recursion <recur>))))) (runtime: (tuple//right lefts tuple) @@ -167,7 +167,7 @@ (_.cond (list [(_.= last_index_right right_index) (_.return (_.at right_index tuple))] [(_.> last_index_right right_index) - ## Needs recursion. + ... Needs recursion. <recur>]) (_.return (_.do "slice" (list right_index) tuple))) ))))) @@ -198,7 +198,7 @@ is_last? (_.= ..unit sum_flag) extact_match! (_.return sum_value) test_recursion! (_.if is_last? - ## Must recurse. + ... Must recurse. ($_ _.then (_.set wanted_tag (_.- sum_tag wanted_tag)) (_.set sum sum_value)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux index 37f9134fb..d7a20b360 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux @@ -41,7 +41,7 @@ 0 (_\in []) 1 _.pop 2 _.pop2 - _ ## (n.> 2) + _ ... (n.> 2) ($_ _.compose _.pop2 (pop_alt (n.- 2 stack_depth))))) @@ -140,7 +140,7 @@ ([synthesis.member/left ..left_projection] [synthesis.member/right ..right_projection]) - ## Extra optimization + ... Extra optimization (^ (synthesis.path/seq (synthesis.member/left 0) (synthesis.!bind_top register thenP))) @@ -154,7 +154,7 @@ (_.astore register) thenG))) - ## Extra optimization + ... Extra optimization (^template [<pm> <projection>] [(^ (synthesis.path/seq (<pm> lefts) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux index 10dbc1bcc..1fb4d7d86 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux @@ -25,7 +25,7 @@ (def: .public (closure environment) (-> (Environment Synthesis) (List (Type Value))) - (list.repeat (list.size environment) //.type)) + (list.repeated (list.size environment) //.type)) (def: .public (get class register) (-> (Type Class) Register (Bytecode Any)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux index adc3da6c8..0b4208bec 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux @@ -34,7 +34,7 @@ (-> Nat (Bytecode Any)) ($_ _.compose (|> _.aconst_null - (list.repeat amount) + (list.repeated amount) (monad.seq _.monad)) (_\in []))) 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 9f4bc4e13..f90f1999b 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 @@ -95,7 +95,7 @@ [@default _.new_label @labelsH _.new_label @labelsT (|> _.new_label - (list.repeat (dec num_partials)) + (list.repeated (dec num_partials)) (monad.seq _.monad)) .let [cases (|> (list\compose (#.Item [@labelsH @labelsT]) (list @default)) @@ -132,12 +132,12 @@ (apply (n.+ ..this_offset arity_inputs) additional_inputs) _.areturn)) - ## (i.< over_extent (.int stage)) + ... (i.< over_extent (.int stage)) (let [current_environment (|> (list.indices (list.size environment)) (list\map (///foreign.get class)) (monad.seq _.monad)) missing_partials (|> _.aconst_null - (list.repeat (|> num_partials (n.- apply_arity) (n.- stage))) + (list.repeated (|> num_partials (n.- apply_arity) (n.- stage))) (monad.seq _.monad))] ($_ _.compose (_.new class) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux index 07473f901..a43a4c0bc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux @@ -22,7 +22,7 @@ (def: .public (type arity) (-> Arity (Type category.Method)) - (type.method [(list.repeat arity ////type.value) + (type.method [(list.repeated arity ////type.value) ////type.value (list)])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux index b99f5661a..ac11c1cf3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux @@ -45,7 +45,7 @@ (def: (partials arity) (-> Arity (List (Type Value))) - (list.repeat (dec arity) ////type.value)) + (list.repeated (dec arity) ////type.value)) (def: .public (type environment arity) (-> (Environment Synthesis) Arity (Type category.Method)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux index b58414fd9..c3d119ec4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux @@ -99,7 +99,7 @@ (def: (evaluate! library loader eval_class valueG) (-> Library java/lang/ClassLoader Text (Bytecode Any) (Try [Any Definition])) - (let [bytecode_name (text.replace_all class_path_separator .module_separator eval_class) + (let [bytecode_name (text.replaced class_path_separator .module_separator eval_class) bytecode (class.class version.v6_0 class.public (encoding/name.internal bytecode_name) @@ -125,7 +125,7 @@ (def: (execute! library loader temp_label [class_name class_bytecode]) (-> Library java/lang/ClassLoader Text Definition (Try Any)) (io.run (do (try.with io.monad) - [existing_class? (|> (atom.read library) + [existing_class? (|> (atom.read! library) (\ io.monad map (function (_ library) (dictionary.key? library class_name))) (try.lift io.monad) @@ -137,7 +137,7 @@ (def: (define! library loader [module name] valueG) (-> Library java/lang/ClassLoader Name (Bytecode Any) (Try [Text Any Definition])) - (let [class_name (format (text.replace_all .module_separator class_path_separator module) + (let [class_name (format (text.replaced .module_separator class_path_separator module) class_path_separator (name.normal name) "___" (%.nat (text\hash name)))] (do try.monad @@ -151,7 +151,7 @@ (: //runtime.Host (implementation (def: (evaluate! temp_label valueG) - (let [eval_class (|> temp_label name.normal (text.replace_all " " "$"))] + (let [eval_class (|> temp_label name.normal (text.replaced " " "$"))] (\ try.monad map product.left (..evaluate! library loader eval_class valueG)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux index 857066e4b..3e009b116 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux @@ -54,14 +54,14 @@ .let [storeG (_.astore register)]] (in [fetchG storeG]))))))] (in ($_ _.compose - ## It may look weird that first I fetch all the values separately, - ## and then I store them all. - ## It must be done that way in order to avoid a potential bug. - ## Let's say that you'll recur with 2 expressions: X and Y. - ## If Y depends on the value of X, and you don't perform fetches - ## and stores separately, then by the time Y is evaluated, it - ## will refer to the new value of X, instead of the old value, as - ## should be the case. + ... It may look weird that first I fetch all the values separately, + ... and then I store them all. + ... It must be done that way in order to avoid a potential bug. + ... Let's say that you'll recur with 2 expressions: X and Y. + ... If Y depends on the value of X, and you don't perform fetches + ... and stores separately, then by the time Y is evaluated, it + ... will refer to the new value of X, instead of the old value, as + ... should be the case. (|> updatesG (list\map product.left) (monad.seq _.monad)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux index 7c35b11de..7a5e65744 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux @@ -42,8 +42,8 @@ _ _.i2l] ..wrap_i64)]) ([-1 _.iconst_m1] - ## [+0 _.iconst_0] - ## [+1 _.iconst_1] + ... [+0 _.iconst_0] + ... [+1 _.iconst_1] [+2 _.iconst_2] [+3 _.iconst_3] [+4 _.iconst_4] @@ -101,8 +101,8 @@ _ _.i2d] ..wrap_f64)]) ([-1.0 _.iconst_m1] - ## [+0.0 _.iconst_0] - ## [+1.0 _.iconst_1] + ... [+0.0 _.iconst_0] + ... [+1.0 _.iconst_1] [+2.0 _.iconst_2] [+3.0 _.iconst_3] [+4.0 _.iconst_4] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux index 757716fe7..dff909982 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux @@ -120,11 +120,11 @@ (def: (set! index value) (-> (Bytecode Any) (Bytecode Any) (Bytecode Any)) ($_ _.compose - ## A - _.dup ## AA - index ## AAI - value ## AAIV - _.aastore ## A + ... A + _.dup ... AA + index ... AAI + value ... AAIV + _.aastore ... A )) (def: .public unit (_.string synthesis.unit)) @@ -150,10 +150,10 @@ ..variant::type (list) (#.Some ($_ _.compose - new_variant ## A[3] - (..set! ..variant_tag $tag) ## A[3] - (..set! ..variant_last? $last?) ## A[3] - (..set! ..variant_value $value) ## A[3] + new_variant ... A[3] + (..set! ..variant_tag $tag) ... A[3] + (..set! ..variant_last? $last?) ... A[3] + (..set! ..variant_value $value) ... A[3] _.areturn))))) (def: .public left_flag _.aconst_null) @@ -316,20 +316,20 @@ recur (: (-> Label (Bytecode Any)) (function (_ @loop_start) ($_ _.compose - ## tag, sumT - update_$variant ## tag, sumT - update_$tag ## sub_tag + ... tag, sumT + update_$variant ... tag, sumT + update_$tag ... sub_tag (_.goto @loop_start)))) super_nested_tag ($_ _.compose - ## tag, sumT - _.swap ## sumT, tag + ... tag, sumT + _.swap ... sumT, tag _.isub) super_nested ($_ _.compose - ## tag, sumT - super_nested_tag ## super_tag - $variant ::last? ## super_tag, super_last - $variant ::value ## super_tag, super_last, super_value + ... tag, sumT + super_nested_tag ... super_tag + $variant ::last? ... super_tag, super_last + $variant ::value ... super_tag, super_last, super_value ..variant)]] ($_ _.compose $tag @@ -337,23 +337,23 @@ $variant ::tag _.dup2 (_.if_icmpeq @tags_match!) _.dup2 (_.if_icmpgt @maybe_nested) - $last? (_.ifnull @mismatch!) ## tag, sumT - super_nested ## super_variant + $last? (_.ifnull @mismatch!) ... tag, sumT + super_nested ... super_variant _.areturn - (_.set_label @tags_match!) ## tag, sumT - $last? ## tag, sumT, wants_last? - $variant ::last? ## tag, sumT, wants_last?, is_last? - (_.if_acmpeq @perfect_match!) ## tag, sumT - (_.set_label @maybe_nested) ## tag, sumT - $variant ::last? ## tag, sumT, last? - (_.ifnull @mismatch!) ## tag, sumT + (_.set_label @tags_match!) ... tag, sumT + $last? ... tag, sumT, wants_last? + $variant ::last? ... tag, sumT, wants_last?, is_last? + (_.if_acmpeq @perfect_match!) ... tag, sumT + (_.set_label @maybe_nested) ... tag, sumT + $variant ::last? ... tag, sumT, last? + (_.ifnull @mismatch!) ... tag, sumT (recur @loop) - (_.set_label @perfect_match!) ## tag, sumT - ## _.pop2 + (_.set_label @perfect_match!) ... tag, sumT + ... _.pop2 $variant ::value _.areturn - (_.set_label @mismatch!) ## tag, sumT - ## _.pop2 + (_.set_label @mismatch!) ... tag, sumT + ... _.pop2 not_found _.areturn ))))) @@ -405,7 +405,7 @@ $tuple ::left _.areturn (_.set_label @recursive) - ## Recursive + ... Recursive (recur @loop))))) right_projection::method @@ -432,12 +432,12 @@ (_.set_label @loop) $last_right $right _.dup2 (_.if_icmpne @not_tail) - ## _.pop + ... _.pop $::nested _.areturn (_.set_label @not_tail) (_.if_icmpgt @slice) - ## Must recurse + ... Must recurse (recur @loop) (_.set_label @slice) super_nested @@ -449,7 +449,7 @@ (def: .public (apply::type arity) (-> Arity (Type category.Method)) - (type.method [(list) (list.repeat arity //type.value) //type.value (list)])) + (type.method [(list) (list.repeated arity //type.value) //type.value (list)])) (def: .public apply (_.invokevirtual //function.class ..apply::name (..apply::type 1))) @@ -479,25 +479,25 @@ ^PrintWriter (type.class "java.io.PrintWriter" (list)) print_writer ($_ _.compose - ## WTW - (_.new ^PrintWriter) ## WTWP - _.dup_x1 ## WTPWP - _.swap ## WTPPW - ..true ## WTPPWZ + ... WTW + (_.new ^PrintWriter) ... WTWP + _.dup_x1 ... WTPWP + _.swap ... WTPPW + ..true ... WTPPWZ (_.invokespecial ^PrintWriter "<init>" (type.method [(list) (list (type.class "java.io.Writer" (list)) type.boolean) type.void (list)])) - ## WTP + ... WTP )]] ($_ _.compose (_.try @try @handler @handler //type.error) (_.set_label @try) $unsafe unit ..apply ..right_injection _.areturn - (_.set_label @handler) ## T - string_writer ## TW - _.dup_x1 ## WTW - print_writer ## WTP - (_.invokevirtual //type.error "printStackTrace" (type.method [(list) (list ^PrintWriter) type.void (list)])) ## W - (_.invokevirtual ^StringWriter "toString" (type.method [(list) (list) //type.text (list)])) ## S + (_.set_label @handler) ... T + string_writer ... TW + _.dup_x1 ... WTW + print_writer ... WTP + (_.invokevirtual //type.error "printStackTrace" (type.method [(list) (list ^PrintWriter) type.void (list)])) ... W + (_.invokevirtual ^StringWriter "toString" (type.method [(list) (list) //type.text (list)])) ... S ..left_injection _.areturn ))))) @@ -605,7 +605,7 @@ (def: .public forge_label (Operation Label) (let [shift (n./ 4 i64.width)] - ## This shift is done to avoid the possibility of forged labels - ## to be in the range of the labels that are generated automatically - ## during the evaluation of Bytecode expressions. + ... This shift is done to avoid the possibility of forged labels + ... to be in the range of the labels that are generated automatically + ... during the evaluation of Bytecode expressions. (\ ////.monad map (i64.left_shifted shift) generation.next))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/value.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/value.lux index 138a9d2fb..fa7627b97 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/value.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/value.lux @@ -24,7 +24,7 @@ [type.float <float>] [type.double <double>] [type.char <char>])) - ## else + ... else (undefined))))] [primitive_wrapper 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 db4de757c..589d9191d 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 @@ -43,7 +43,7 @@ (do ///////phase.monad [valueO (expression archive valueS) bodyO (expression archive bodyS)] - ## TODO: Find some way to do 'let' without paying the price of the closure. + ... TODO: Find some way to do 'let' without paying the price of the closure. (in (|> bodyO _.return (_.closure (list (..register register))) 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 e26940c60..83db2505d 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 @@ -113,7 +113,7 @@ (_.return (|> @self (_.apply/* (list (unpack arity_inputs))) (_.apply/* (list (unpack extra_inputs))))))]) - ## (|> @num_args (_.< arityO)) + ... (|> @num_args (_.< arityO)) (_.return (_.closure (list @var_args) (let [@extra_args (_.var "extra_args")] ($_ _.then 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 d19421620..ddc716045 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 @@ -48,17 +48,17 @@ body)))) (def: .public (scope! statement expression archive as_expression? [start initsS+ bodyS]) - ## (Generator! (Scope Synthesis)) + ... (Generator! (Scope Synthesis)) (-> Phase! Phase Archive Bit (Scope Synthesis) (Operation [(List Expression) Statement])) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (|> bodyS (statement expression archive) (\ ///////phase.monad map (|>> [(list)]))) - ## true loop + ... true loop _ (do {! ///////phase.monad} [@scope (\ ! map ..@scope /////generation.next) @@ -74,11 +74,11 @@ (def: .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (expression archive bodyS) - ## true loop + ... true loop _ (do {! ///////phase.monad} [[[artifact_module artifact_id] [initsO+ scope!]] (/////generation.with_new_context archive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux index d77a51d8a..bfb1ab115 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux @@ -105,7 +105,7 @@ (syntax: .public (with_vars {vars (<code>.tuple (<>.some <code>.local_identifier))} body) (do {! meta.monad} - [ids (monad.seq ! (list.repeat (list.size vars) meta.seed))] + [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) @@ -174,9 +174,9 @@ ($_ _.then (_.local/1 last_index_right (..last_index tuple)) (_.if (_.> lefts last_index_right) - ## No need for recursion + ... No need for recursion (_.return (..item lefts tuple)) - ## Needs recursion + ... Needs recursion <recur>))))) (runtime: (tuple//right lefts tuple) @@ -188,7 +188,7 @@ (_.cond (list [(_.= last_index_right right_index) (_.return (..item right_index tuple))] [(_.> last_index_right right_index) - ## Needs recursion. + ... Needs recursion. <recur>]) (_.return (_.apply/* (list tuple (_.+ (_.int +1) right_index) @@ -206,7 +206,7 @@ is_last? (_.= ..unit sum_flag) extact_match! (_.return sum_value) test_recursion! (_.if is_last? - ## Must recurse. + ... Must recurse. ($_ _.then (_.set (list wanted_tag) (_.- sum_tag wanted_tag)) (_.set (list sum) sum_value)) @@ -319,7 +319,7 @@ (-> Expression Expression) (_.- (_.int +1))) -## TODO: Remove this once the Lua compiler becomes self-hosted. +... TODO: Remove this once the Lua compiler becomes self-hosted. (def: on_rembulan? (_.= (_.string "Lua 5.3") (_.var "_VERSION"))) @@ -353,7 +353,7 @@ text (..byte_index text offset) (|> (_.+ offset length) - ## (_.+ (_.int +1)) + ... (_.+ (_.int +1)) (..byte_index text) (_.- (_.int +1)))))] (for {@.lua <normal>} 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 2906c63ed..9b99a1ca6 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 @@ -231,13 +231,13 @@ (_.set! (..register register) ..peek_and_pop) then!))) - ## (^ (/////synthesis.!multi_pop nextP)) - ## (.let [[extra_pops nextP'] (////synthesis/case.count_pops nextP)] - ## (do ///////phase.monad - ## [next! (recur nextP')] - ## (///////phase\in ($_ _.then - ## (..multi_pop! (n.+ 2 extra_pops)) - ## next!)))) + ... (^ (/////synthesis.!multi_pop nextP)) + ... (.let [[extra_pops nextP'] (////synthesis/case.count_pops nextP)] + ... (do ///////phase.monad + ... [next! (recur nextP')] + ... (///////phase\in ($_ _.then + ... (..multi_pop! (n.+ 2 extra_pops)) + ... next!)))) (^template [<tag> <combinator>] [(^ (<tag> preP postP)) 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 f4df9c34b..f8746bdf2 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 @@ -104,7 +104,7 @@ extra_inputs (_.array_slice/2 [@curried arityG]) next (_.call_user_func_array/2 [@selfL arity_inputs])] (_.return (_.call_user_func_array/2 [next extra_inputs])))]) - ## (|> @num_args (_.< arityG)) + ... (|> @num_args (_.< arityG)) (let [@missing (_.var "missing")] (_.return (<| (_.closure (list (_.reference @selfL) (_.reference @curried)) (list)) ($_ _.then 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 32e6346cf..9f66b15b3 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 @@ -50,11 +50,11 @@ (def: .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (statement expression archive bodyS) - ## true loop + ... true loop _ (do {! ///////phase.monad} [@scope (\ ! map ..@scope /////generation.next) @@ -69,11 +69,11 @@ (def: .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (expression archive bodyS) - ## true loop + ... true loop _ (do {! ///////phase.monad} [[[loop_module loop_artifact] scope!] (/////generation.with_new_context archive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux index 4a5b7b5e0..f1c4c0eb6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux @@ -73,7 +73,7 @@ (syntax: .public (with_vars {vars (<code>.tuple (<>.some <code>.local_identifier))} body) (do {! meta.monad} - [ids (monad.seq ! (list.repeat (list.size vars) meta.seed))] + [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) @@ -155,7 +155,7 @@ (_.=== (_.string "5.6.99") (_.phpversion/0 []))) (runtime: (array//length array) - ## TODO: Get rid of this as soon as JPHP is no longer necessary. + ... TODO: Get rid of this as soon as JPHP is no longer necessary. (_.if ..jphp? (_.return (..tuple_size array)) (_.return (_.count/1 array)))) @@ -186,11 +186,11 @@ ($_ _.then (_.set! (..tuple_size values) size) (_.return values)) - ## https://www.php.net/manual/en/language.operators.assignment.php - ## https://www.php.net/manual/en/language.references.php - ## https://www.php.net/manual/en/functions.arguments.php - ## https://www.php.net/manual/en/language.oop5.references.php - ## https://www.php.net/manual/en/class.arrayobject.php + ... https://www.php.net/manual/en/language.operators.assignment.php + ... https://www.php.net/manual/en/language.references.php + ... https://www.php.net/manual/en/functions.arguments.php + ... https://www.php.net/manual/en/language.oop5.references.php + ... https://www.php.net/manual/en/class.arrayobject.php (_.return (_.new (_.constant "ArrayObject") (list values))))) (runtime: (tuple//left lefts tuple) @@ -201,12 +201,12 @@ (_.set! last_index_right (..jphp_last_index tuple)) (_.set! last_index_right (..normal_last_index tuple))) (_.if (_.> lefts last_index_right) - ## No need for recursion + ... No need for recursion (_.return (_.item lefts tuple)) - ## Needs recursion + ... Needs recursion <recur>))))) - ## TODO: Get rid of this as soon as JPHP is no longer necessary. + ... TODO: Get rid of this as soon as JPHP is no longer necessary. (runtime: (tuple//slice offset input) (with_vars [size index output] ($_ _.then @@ -232,7 +232,7 @@ (_.cond (list [(_.=== last_index_right right_index) (_.return (_.item right_index tuple))] [(_.> last_index_right right_index) - ## Needs recursion. + ... Needs recursion. <recur>]) (_.if ..jphp? (_.return (..tuple//make (_.- right_index (..tuple_size tuple)) @@ -275,14 +275,14 @@ (runtime: (sum//get sum wantsLast wantedTag) (let [no_match! (_.return _.null) sum_tag (_.item (_.string ..variant_tag_field) sum) - ## sum_tag (_.item (_.int +0) sum) + ... sum_tag (_.item (_.int +0) sum) sum_flag (_.item (_.string ..variant_flag_field) sum) - ## sum_flag (_.item (_.int +1) sum) + ... sum_flag (_.item (_.int +1) sum) sum_value (_.item (_.string ..variant_value_field) sum) - ## sum_value (_.item (_.int +2) sum) + ... sum_value (_.item (_.int +2) sum) is_last? (_.=== ..unit sum_flag) test_recursion! (_.if is_last? - ## Must recurse. + ... Must recurse. ($_ _.then (_.set! wantedTag (_.- sum_tag wantedTag)) (_.set! sum sum_value)) @@ -346,13 +346,13 @@ (|>> (i64.and mask)))) (runtime: (i64//right_shifted param subject) - (let [## The mask has to be calculated this way instead of in a more straightforward way - ## because in some languages, 1<<63 = max_negative_value - ## and max_negative_value-1 = max_positive_value. - ## And bitwise, max_positive_value works out to the mask that is desired when param = 0. - ## However, in PHP, max_negative_value-1 underflows and gets cast into a float. - ## And this messes up the computation. - ## This slightly more convoluted calculation avoids that problem. + (let [... The mask has to be calculated this way instead of in a more straightforward way + ... because in some languages, 1<<63 = max_negative_value + ... and max_negative_value-1 = max_positive_value. + ... And bitwise, max_positive_value works out to the mask that is desired when param = 0. + ... However, in PHP, max_negative_value-1 underflows and gets cast into a float. + ... And this messes up the computation. + ... This slightly more convoluted calculation avoids that problem. mask (|> (_.int +1) (_.bit_shl (_.- param (_.int +63))) (_.- (_.int +1)) 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 84bc0c2ca..137623c8a 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 @@ -52,7 +52,7 @@ (do ///////phase.monad [valueO (expression archive valueS) bodyO (expression archive bodyS)] - ## TODO: Find some way to do 'let' without paying the price of the closure. + ... TODO: Find some way to do 'let' without paying the price of the closure. (in (_.apply/* (_.lambda (list (..register register)) bodyO) (list valueO))))) 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 0b4ecc5e6..0304e7a58 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 @@ -100,7 +100,7 @@ (_.return (|> @self (apply_poly arity_inputs) (apply_poly extra_inputs))))]) - ## (|> @num_args (_.< arityO)) + ... (|> @num_args (_.< arityO)) (let [@next (_.var "next") @missing (_.var "missing")] ($_ _.then 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 b627e5c44..4332539e5 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 @@ -50,11 +50,11 @@ (def: .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (statement expression archive bodyS) - ## true loop + ... true loop _ (do {! ///////phase.monad} [initsO+ (monad.map ! (expression archive) initsS+) @@ -67,11 +67,11 @@ (def: .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (expression archive bodyS) - ## true loop + ... true loop _ (do {! ///////phase.monad} [initsO+ (monad.map ! (expression archive) initsS+) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux index 49507ed33..2cd100ce9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux @@ -112,7 +112,7 @@ (syntax: .public (with_vars {vars (<code>.tuple (<>.some <code>.local_identifier))} body) (do {! meta.monad} - [ids (monad.seq ! (list.repeat (list.size vars) meta.seed))] + [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) @@ -216,9 +216,9 @@ ($_ _.then (_.set (list last_index_right) (..last_index tuple)) (_.if (_.> lefts last_index_right) - ## No need for recursion + ... No need for recursion (_.return (_.item lefts tuple)) - ## Needs recursion + ... Needs recursion <recur>)) #.None))) @@ -231,7 +231,7 @@ (_.cond (list [(_.= last_index_right right_index) (_.return (_.item right_index tuple))] [(_.> last_index_right right_index) - ## Needs recursion. + ... Needs recursion. <recur>]) (_.return (_.slice_from right_index tuple)))) #.None)))) @@ -243,7 +243,7 @@ sum_value (_.item (_.int +2) sum) is_last? (_.= ..unit sum_flag) test_recursion! (_.if is_last? - ## Must recurse. + ... Must recurse. ($_ _.then (_.set (list wantedTag) (_.- sum_tag wantedTag)) (_.set (list sum) sum_value)) @@ -292,7 +292,7 @@ [(_.< ..i64::-limit) ..i64::-iteration ..i64::-cap ..i64::+limit] )) (_.return (for {@.python input} - ## This +- is only necessary to guarantee that values within the limits are always longs in Python 2 + ... This +- is only necessary to guarantee that values within the limits are always longs in Python 2 (|> input (_.+ ..i64::+limit) (_.- ..i64::+limit)))))))) (def: as_nat 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 bbfa2e83d..34334c668 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 @@ -106,7 +106,7 @@ (|> $self (apply_poly arity_args) (apply_poly output_func_args)))]) - ## (|> $num_args (_.< arityO)) + ... (|> $num_args (_.< arityO)) (let [$missing (_.var "missing")] (_.function (list _.var_args) ($_ _.then 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 32ec3b041..cdbaf6e1f 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 @@ -36,11 +36,11 @@ (def: .public (scope expression archive [offset initsS+ bodyS]) (Generator (Scope Synthesis)) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (expression archive bodyS) - ## true loop + ... true loop _ (do {! ///////phase.monad} [$scope (\ ! map _.var (/////generation.gensym "loop_scope")) 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 037259b8a..c257a2c0c 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 @@ -24,7 +24,7 @@ [".T" function] [".T" loop])) -## [Types] +... [Types] (type: .public Translator (-> ls.Synthesis (Meta Expression))) @@ -35,7 +35,7 @@ (Dict Text Proc)) (syntax: (Vector {size s.nat} elemT) - (in (list (` [(~+ (list.repeat size elemT))])))) + (in (list (` [(~+ (list.repeated size elemT))])))) (type: .public Nullary (-> (Vector +0 Expression) Expression)) (type: .public Unary (-> (Vector +1 Expression) Expression)) @@ -43,7 +43,7 @@ (type: .public Trinary (-> (Vector +3 Expression) Expression)) (type: .public Variadic (-> (List Expression) Expression)) -## [Utils] +... [Utils] (def: .public (install name unnamed) (-> Text (-> Text Proc) (-> Bundle Bundle)) @@ -65,7 +65,7 @@ (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")))] + [g!input+ (monad.seq @ (list.repeated arity (macro.gensym "input")))] (in (list (` (def: .public ((~ (code.local_identifier name)) (~ g!proc)) (-> (-> (..Vector (~ (code.nat arity)) Expression) Expression) (-> Text ..Proc)) @@ -96,8 +96,8 @@ [inputsI (monad.map @ translate inputsS)] (in (proc inputsI)))))) -## [Procedures] -## [[Lux]] +... [Procedures] +... [[Lux]] (def: (lux//is [leftO rightO]) Binary (r.apply (list leftO rightO) @@ -147,7 +147,7 @@ (install "recur" lux//recur) )) -## [[Bits]] +... [[Bits]] (template [<name> <op>] [(def: (<name> [subjectO paramO]) Binary @@ -180,7 +180,7 @@ (install "arithmetic-right-shift" (binary bit//arithmetic_right_shifted)) ))) -## [[Numbers]] +... [[Numbers]] (host.import: java/lang/Double (#static MIN_VALUE Double) (#static MAX_VALUE Double)) @@ -276,7 +276,7 @@ (install "encode" (unary frac//encode)) (install "decode" (unary runtimeT.frac//decode))))) -## [[Text]] +... [[Text]] (def: (text//concat [subjectO paramO]) Binary (r.apply (list subjectO paramO) (r.global "paste0"))) @@ -306,7 +306,7 @@ (install "clip" (trinary text//clip)) ))) -## [[IO]] +... [[IO]] (def: (io//exit input) Unary (r.apply_kw (list) @@ -327,7 +327,7 @@ (install "current-time" (nullary (function (_ _) (runtimeT.io//current_time! runtimeT.unit))))))) -## [Bundles] +... [Bundles] (def: .public procedures Bundle (<| (prefix "lux") 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 c99ceb072..db45a04fc 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 @@ -15,76 +15,76 @@ (/// [".T" runtime]) (// ["@" common])) -## (template [<name> <lua>] -## [(def: (<name> _) @.Nullary <lua>)] +... (template [<name> <lua>] +... [(def: (<name> _) @.Nullary <lua>)] -## [lua//nil "nil"] -## [lua//table "{}"] -## ) +... [lua//nil "nil"] +... [lua//table "{}"] +... ) -## (def: (lua//global proc translate inputs) -## (-> Text @.Proc) -## (case inputs -## (^ (list [_ (#.Text name)])) -## (do macro.Monad<Meta> -## [] -## (in name)) +... (def: (lua//global proc translate inputs) +... (-> Text @.Proc) +... (case inputs +... (^ (list [_ (#.Text name)])) +... (do macro.Monad<Meta> +... [] +... (in name)) -## _ -## (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) +... _ +... (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) -## (def: (lua//call proc translate inputs) -## (-> Text @.Proc) -## (case inputs -## (^ (list& functionS argsS+)) -## (do {@ macro.Monad<Meta>} -## [functionO (translate functionS) -## argsO+ (monad.map @ translate argsS+)] -## (in (lua.apply functionO argsO+))) +... (def: (lua//call proc translate inputs) +... (-> Text @.Proc) +... (case inputs +... (^ (list& functionS argsS+)) +... (do {@ macro.Monad<Meta>} +... [functionO (translate functionS) +... argsO+ (monad.map @ translate argsS+)] +... (in (lua.apply functionO argsO+))) -## _ -## (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) +... _ +... (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) -## (def: lua_procs -## @.Bundle -## (|> (dict.empty text.Hash<Text>) -## (@.install "nil" (@.nullary lua//nil)) -## (@.install "table" (@.nullary lua//table)) -## (@.install "global" lua//global) -## (@.install "call" lua//call))) +... (def: lua_procs +... @.Bundle +... (|> (dict.empty text.Hash<Text>) +... (@.install "nil" (@.nullary lua//nil)) +... (@.install "table" (@.nullary lua//table)) +... (@.install "global" lua//global) +... (@.install "call" lua//call))) -## (def: (table//call proc translate inputs) -## (-> Text @.Proc) -## (case inputs -## (^ (list& tableS [_ (#.Text field)] argsS+)) -## (do {@ macro.Monad<Meta>} -## [tableO (translate tableS) -## argsO+ (monad.map @ translate argsS+)] -## (in (lua.method field tableO argsO+))) +... (def: (table//call proc translate inputs) +... (-> Text @.Proc) +... (case inputs +... (^ (list& tableS [_ (#.Text field)] argsS+)) +... (do {@ macro.Monad<Meta>} +... [tableO (translate tableS) +... argsO+ (monad.map @ translate argsS+)] +... (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 -## (runtimeT.lua//get tableO fieldO)) +... (def: (table//get [fieldO tableO]) +... @.Binary +... (runtimeT.lua//get tableO fieldO)) -## (def: (table//set [fieldO valueO tableO]) -## @.Trinary -## (runtimeT.lua//set tableO fieldO valueO)) +... (def: (table//set [fieldO valueO tableO]) +... @.Trinary +... (runtimeT.lua//set tableO fieldO valueO)) -## (def: table_procs -## @.Bundle -## (<| (@.prefix "table") -## (|> (dict.empty text.Hash<Text>) -## (@.install "call" table//call) -## (@.install "get" (@.binary table//get)) -## (@.install "set" (@.trinary table//set))))) +... (def: table_procs +... @.Bundle +... (<| (@.prefix "table") +... (|> (dict.empty text.Hash<Text>) +... (@.install "call" table//call) +... (@.install "get" (@.binary table//get)) +... (@.install "set" (@.trinary table//set))))) (def: .public procedures @.Bundle (<| (@.prefix "lua") (dict.empty text.Hash<Text>) - ## (|> lua_procs - ## (dict.merged table_procs)) + ... (|> lua_procs + ... (dict.merged table_procs)) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux index 446f2ba72..b416fc128 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux @@ -73,13 +73,13 @@ (n.> half_32 input) (|> post_32 (n.- input) .int (i.* -1)) - ## else + ... else (.int input))) (syntax: .public (with_vars {vars (<code>.tuple (<>.some <code>.local_identifier))} body) (do {! meta.monad} - [ids (monad.seq ! (list.repeat (list.size vars) meta.seed))] + [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) @@ -580,9 +580,9 @@ ($_ _.then (_.set! $index_min_length (minimum_index_length index)) (_.if (|> (_.length product) (_.> $index_min_length)) - ## No need for recursion + ... No need for recursion (product_element product index) - ## Needs recursion + ... Needs recursion (tuple::left (updated_index $index_min_length product) (product_tail product)))))) @@ -590,14 +590,14 @@ (let [$index_min_length (_.var "index_min_length")] ($_ _.then (_.set! $index_min_length (minimum_index_length index)) - (_.cond (list [## Last element. + (_.cond (list [... Last element. (|> (_.length product) (_.= $index_min_length)) (product_element product index)] - [## Needs recursion + [... Needs recursion (|> (_.length product) (_.< $index_min_length)) (tuple::right (updated_index $index_min_length product) (product_tail product))]) - ## Must slice + ... Must slice (|> product (_.slice_from index)))))) (runtime: (sum::get sum wants_last? wanted_tag) @@ -607,7 +607,7 @@ sum_value (|> sum (_.item (_.string ..variant_value_field))) is_last? (|> sum_flag (_.= (_.string ""))) test_recursion (_.if is_last? - ## Must recurse. + ... Must recurse. (|> wanted_tag (_.- sum_tag) (sum::get sum_value wants_last?)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux index 7ae3e429a..608bffb04 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux @@ -15,16 +15,16 @@ [meta [archive (#+ Archive)]]]]) -## This universe constant is for languages where one can't just turn all compiled definitions -## into the local variables of some scoping function. +... This universe constant is for languages where one can't just turn all compiled definitions +... into the local variables of some scoping function. (def: .public universe - (for {## In the case of Lua, there is a limit of 200 locals in a function's scope. + (for {... In the case of Lua, there is a limit of 200 locals in a function's scope. @.lua (not ("lua script universe")) - ## Cannot make all definitions be local variables because of limitations with JRuby. + ... Cannot make all definitions be local variables because of limitations with JRuby. @.ruby (not ("ruby script universe")) - ## Cannot make all definitions be local variables because of limitations with PHP itself. + ... Cannot make all definitions be local variables because of limitations with PHP itself. @.php (not ("php script universe")) - ## Cannot make all definitions be local variables because of limitations with Kawa. + ... Cannot make all definitions be local variables because of limitations with Kawa. @.scheme (not ("scheme script universe"))} #0)) 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 0eca3ec0b..253bec114 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 @@ -53,7 +53,7 @@ (do ///////phase.monad [valueO (expression archive valueS) bodyO (expression archive bodyS)] - ## TODO: Find some way to do 'let' without paying the price of the closure. + ... TODO: Find some way to do 'let' without paying the price of the closure. (in (|> bodyO _.return (_.lambda #.None (list (..register register))) 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 11199e5b4..dc39ac6f7 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 @@ -99,7 +99,7 @@ (_.return (|> @self (_.apply_lambda/* (list arity_args)) (_.apply_lambda/* (list output_func_args)))))]) - ## (|> @num_args (_.< arityO)) + ... (|> @num_args (_.< arityO)) (let [@missing (_.local "missing")] (_.return (_.lambda #.None (list (_.variadic @missing)) (_.return (|> @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 89daa0b5f..9e2a43500 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 @@ -51,11 +51,11 @@ (def: .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (statement expression archive bodyS) - ## true loop + ... true loop _ (do {! ///////phase.monad} [initsO+ (monad.map ! (expression archive) initsS+) @@ -68,11 +68,11 @@ (def: .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (expression archive bodyS) - ## true loop + ... true loop _ (do {! ///////phase.monad} [body! (scope! statement expression archive [start initsS+ bodyS])] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux index ed17f4d1d..9de984f61 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux @@ -74,7 +74,7 @@ (syntax: .public (with_vars {vars (<code>.tuple (<>.some <code>.local_identifier))} body) (do {! meta.monad} - [ids (monad.seq ! (list.repeat (list.size vars) meta.seed))] + [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) @@ -139,9 +139,9 @@ ($_ _.then (_.set (list last_index_right) (..last_index tuple)) (_.if (_.> lefts last_index_right) - ## No need for recursion + ... No need for recursion (_.return (_.item lefts tuple)) - ## Needs recursion + ... Needs recursion <recur>))))) (runtime: (tuple//right lefts tuple) @@ -153,7 +153,7 @@ (_.cond (list [(_.= last_index_right right_index) (_.return (_.item right_index tuple))] [(_.> last_index_right right_index) - ## Needs recursion. + ... Needs recursion. <recur>]) (_.return (_.array_range right_index (..tuple_size tuple) tuple))) ))))) @@ -194,7 +194,7 @@ sum_value (_.item (_.string ..variant_value_field) sum) is_last? (_.= ..unit sum_flag) test_recursion! (_.if is_last? - ## Must recurse. + ... Must recurse. ($_ _.then (_.set (list wantedTag) (_.- sum_tag wantedTag)) (_.set (list sum) sum_value)) 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 89acab685..95e2f1edb 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 @@ -29,7 +29,7 @@ ["#." synthesis (#+ Synthesis)]]]]) (syntax: (Vector {size s.nat} elemT) - (in (list (` [(~+ (list.repeat size elemT))])))) + (in (list (` [(~+ (list.repeated size elemT))])))) (type: .public Nullary (-> (Vector 0 Expression) Computation)) (type: .public Unary (-> (Vector 1 Expression) Computation)) @@ -40,7 +40,7 @@ (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")))] + [g!input+ (monad.seq ! (list.repeated arity (macro.gensym "input")))] (in (list (` (def: .public ((~ (code.local_identifier name)) (~ g!extension)) (-> (-> (..Vector (~ (code.nat arity)) Expression) Computation) Handler) 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 9998edab9..d52f5d920 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 @@ -93,7 +93,7 @@ (_.begin (list (|> @self (apply_poly arity_args) (apply_poly output_func_args)))))) - ## (|> @num_args (_.</2 arityO)) + ... (|> @num_args (_.</2 arityO)) (_.lambda [(list) (#.Some @missing)] (|> @self (apply_poly (_.append/2 @curried @missing))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux index 32da9a0de..fb9add0aa 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 @@ -39,11 +39,11 @@ (def: .public (scope expression archive [start initsS+ bodyS]) (Generator (Scope Synthesis)) (case initsS+ - ## function/false/non-independent loop + ... function/false/non-independent loop #.End (expression archive bodyS) - ## true loop + ... true loop _ (do {! ///////phase.monad} [initsO+ (monad.map ! (expression archive) initsS+) 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 5e17c3324..e61519d16 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 @@ -61,7 +61,7 @@ (syntax: .public (with_vars {vars (<code>.tuple (<>.some <code>.local_identifier))} body) (do {! meta.monad} - [ids (monad.seq ! (list.repeat (list.size vars) meta.seed))] + [ids (monad.seq ! (list.repeated (list.size vars) meta.seed))] (in (list (` (let [(~+ (|> vars (list.zipped/2 ids) (list\map (function (_ [id var]) @@ -114,9 +114,9 @@ (_.begin (list (_.define_constant last_index_right (..last_index tuple)) (_.if (_.>/2 lefts last_index_right) - ## No need for recursion + ... No need for recursion (_.vector_ref/2 tuple lefts) - ## Needs recursion + ... Needs recursion (tuple//left (_.-/2 last_index_right lefts) (_.vector_ref/2 tuple last_index_right))))))) @@ -128,7 +128,7 @@ (<| (_.if (_.=/2 last_index_right right_index) (_.vector_ref/2 tuple right_index)) (_.if (_.>/2 last_index_right right_index) - ## Needs recursion. + ... Needs recursion. (tuple//right (_.-/2 last_index_right lefts) (_.vector_ref/2 tuple last_index_right))) (_.begin @@ -155,7 +155,7 @@ (with_vars [sum_tag sum_flag sum_value sum_temp sum_dump] (let [no_match _.nil test_recursion (_.if sum_flag - ## Must recurse. + ... Must recurse. (sum//get sum_value last? (|> wanted_tag (_.-/2 sum_tag))) @@ -233,22 +233,22 @@ @lux//program_args))) (def: i64//+limit (_.manual "+9223372036854775807" - ## "+0x7FFFFFFFFFFFFFFF" + ... "+0x7FFFFFFFFFFFFFFF" )) (def: i64//-limit (_.manual "-9223372036854775808" - ## "-0x8000000000000000" + ... "-0x8000000000000000" )) (def: i64//+iteration (_.manual "+18446744073709551616" - ## "+0x10000000000000000" + ... "+0x10000000000000000" )) (def: i64//-iteration (_.manual "-18446744073709551616" - ## "-0x10000000000000000" + ... "-0x10000000000000000" )) (def: i64//+cap (_.manual "+9223372036854775808" - ## "+0x8000000000000000" + ... "+0x8000000000000000" )) (def: i64//-cap (_.manual "-9223372036854775809" - ## "-0x8000000000000001" + ... "-0x8000000000000001" )) (runtime: (i64//64 input) 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 aa9c0a757..46189fb26 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 @@ -231,9 +231,9 @@ (in (/.branch/case [input (list\fold weave headSP tailSP+)])))) (template: (!masking <variable> <output>) - [[(#///analysis.Bind <variable>) - (#///analysis.Reference (///reference.local <output>))] - (list)]) + [[[(#///analysis.Bind <variable>) + (#///analysis.Reference (///reference.local <output>))] + (list)]]) (def: .public (synthesize_let synthesize archive input @variable body) (-> Phase Archive Synthesis Register Analysis (Operation Synthesis)) @@ -256,9 +256,9 @@ (in (/.branch/if [test then else])))) (template: (!get <patterns> <output>) - [[(///analysis.pattern/tuple <patterns>) - (#///analysis.Reference (///reference.local <output>))] - (.list)]) + [[[(///analysis.pattern/tuple <patterns>) + (#///analysis.Reference (///reference.local <output>))] + (.list)]]) (def: .public (synthesize_get synthesize archive input patterns @member) (-> Phase Archive Synthesis (///analysis.Tuple ///analysis.Pattern) Register (Operation Synthesis)) @@ -325,12 +325,12 @@ {#bindings (set.empty n.hash) #dependencies (set.empty ///reference/variable.hash)}) -## TODO: Use this to declare all local variables at the beginning of -## script functions. -## That way, it should be possible to do cheap "let" expressions, -## since the variable will exist beforehand, so no closure will need -## to be created for it. -## Apply this trick to JS, Python et al. +... TODO: Use this to declare all local variables at the beginning of +... script functions. +... That way, it should be possible to do cheap "let" expressions, +... since the variable will exist beforehand, so no closure will need +... to be created for it. +... Apply this trick to JS, Python et al. (def: .public (storage path) (-> Path Storage) (loop for_path diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 39d934d96..83822639e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -39,7 +39,7 @@ (list\map (|>> /.variable/local)))) (template: .public (self_reference) - (/.variable/local 0)) + [(/.variable/local 0)]) (def: (expanded_nested_self_reference arity) (-> Arity Synthesis) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux index 7f2f025f7..6ba15c700 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 @@ -51,8 +51,8 @@ (^or (#/.Seq (#/.Access (#/.Member member)) (#/.Seq (#/.Bind register) post)) - ## This alternative form should never occur in practice. - ## Yet, it is "technically" possible to construct it. + ... This alternative form should never occur in practice. + ... Yet, it is "technically" possible to construct it. (#/.Seq (#/.Seq (#/.Access (#/.Member member)) (#/.Bind register)) post)) 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 212181b2d..6615d49a9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -1,29 +1,29 @@ -## This is LuxC's parser. -## It takes the source code of a Lux file in raw text form and -## extracts the syntactic structure of the code from it. -## It only produces Lux Code nodes, and thus removes any white-space -## and comments while processing its inputs. - -## Another important aspect of the parser is that it keeps track of -## its position within the input data. -## That is, the parser takes into account the line and column -## information in the input text (it doesn't really touch the -## file-name aspect of the location, leaving it intact in whatever -## base-line location it is given). - -## This particular piece of functionality is not located in one -## function, but it is instead scattered throughout several parsers, -## since the logic for how to update the location varies, depending on -## what is being parsed, and the rules involved. - -## You will notice that several parsers have a "where" parameter, that -## tells them the location position prior to the parser being run. -## They are supposed to produce some parsed output, alongside an -## updated location pointing to the end position, after the parser was run. - -## Lux Code nodes/tokens are annotated with location meta-data -## [file-name, line, column] to keep track of their provenance and -## location, which is helpful for documentation and debugging. +... This is LuxC's parser. +... It takes the source code of a Lux file in raw text form and +... extracts the syntactic structure of the code from it. +... It only produces Lux Code nodes, and thus removes any white-space +... and comments while processing its inputs. + +... Another important aspect of the parser is that it keeps track of +... its position within the input data. +... That is, the parser takes into account the line and column +... information in the input text (it doesn't really touch the +... file-name aspect of the location, leaving it intact in whatever +... base-line location it is given). + +... This particular piece of functionality is not located in one +... function, but it is instead scattered throughout several parsers, +... since the logic for how to update the location varies, depending on +... what is being parsed, and the rules involved. + +... You will notice that several parsers have a "where" parameter, that +... tells them the location position prior to the parser being run. +... They are supposed to produce some parsed output, alongside an +... updated location pointing to the end position, after the parser was run. + +... Lux Code nodes/tokens are annotated with location meta-data +... [file-name, line, column] to keep track of their provenance and +... location, which is helpful for documentation and debugging. (.module: [library [lux #* @@ -54,18 +54,18 @@ [(for {@.python (def: <declaration> <type> <body>)} (template: <declaration> [<body>]))]) -## TODO: Implement "lux syntax char case!" as a custom extension. -## That way, it should be possible to obtain the char without wrapping -## it into a java.lang.Long, thereby improving performance. +... TODO: Implement "lux syntax char case!" as a custom extension. +... That way, it should be possible to obtain the char without wrapping +... it into a java.lang.Long, thereby improving performance. -## TODO: Make an extension to take advantage of java/lang/String::indexOf<int,int> -## to get better performance than the current "lux text index" extension. +... TODO: Make an extension to take advantage of java/lang/String::indexOf<int,int> +... to get better performance than the current "lux text index" extension. -## TODO: Instead of always keeping a "where" location variable, keep the -## individual components (i.e. file, line and column) separate, so -## that updated the "where" only involved updating the components, and -## producing the locations only involved building them, without any need -## for pattern-matching and de-structuring. +... TODO: Instead of always keeping a "where" location variable, keep the +... individual components (i.e. file, line and column) separate, so +... that updated the "where" only involved updating the components, and +... producing the locations only involved building them, without any need +... for pattern-matching and de-structuring. (type: Char Nat) @@ -113,15 +113,15 @@ (template [<char> <definition>] [(def: .public <definition> <char>)] - ## Form delimiters + ... Form delimiters ["(" open_form] [")" close_form] - ## Tuple delimiters + ... Tuple delimiters ["[" open_tuple] ["]" close_tuple] - ## Record delimiters + ... Record delimiters ["{" open_record] ["}" close_record] @@ -134,13 +134,13 @@ ["." frac_separator] - ## The parts of a name are separated by a single mark. - ## E.g. module.short. - ## Only one such mark may be used in an name, since there - ## can only be 2 parts to a name (the module [before the - ## mark], and the short [after the mark]). - ## There are also some extra rules regarding name syntax, - ## encoded in the parser. + ... The parts of a name are separated by a single mark. + ... E.g. module.short. + ... Only one such mark may be used in an name, since there + ... can only be 2 parts to a name (the module [before the + ... mark], and the short [after the mark]). + ... There are also some extra rules regarding name syntax, + ... encoded in the parser. ["." name_separator] ) @@ -193,7 +193,7 @@ (#.Right <binding>) <body> - ## (#.Left error) + ... (#.Left error) <<otherwise>> (:assume <<otherwise>>))]) @@ -233,9 +233,9 @@ [where (<tag> (list.reversed stack))]]) (#.Left [source' error])))))] - ## Form and tuple syntax is mostly the same, differing only in the - ## delimiters involved. - ## They may have an arbitrary number of arbitrary Code nodes as elements. + ... Form and tuple syntax is mostly the same, differing only in the + ... delimiters involved. + ... They may have an arbitrary number of arbitrary Code nodes as elements. [form_parser ..close_form #.Form] [tuple_parser ..close_tuple #.Tuple] ) @@ -299,7 +299,7 @@ [[<digits>] @then] - ## else + ... else @else)]) (template: (!if_digit?+ @char @then @else_options @else) @@ -309,7 +309,7 @@ (~~ (template.spliced @else_options))] - ## else + ... else @else))]) (`` (template: (!if_name_char?|tail @char @then @else) @@ -317,7 +317,7 @@ [[<non_name_chars>] @else] - ## else + ... else @then)])) (`` (template: (!if_name_char?|head @char @then @else) @@ -325,14 +325,14 @@ [[<non_name_chars> <digits>] @else] - ## else + ... else @then)])) ) (template: (!number_output <source_code> <start> <end> <codec> <tag>) [(case (|> <source_code> (!clip <start> <end>) - (text.replace_all ..digit_separator "") + (text.replaced ..digit_separator "") (\ <codec> decode)) (#.Right output) (#.Right [[(let [[where::file where::line where::column] where] @@ -377,7 +377,7 @@ (recur (!n/+ 3 end) char/0) [] <failure>))] - ## else + ... else <failure>))) <frac_output>)] @@ -477,10 +477,10 @@ [(!letE [source' full_name] (..full_name_parser @aliases @offset @source) (#.Right [source' [@where (@tag full_name)]]))]) -## TODO: Grammar macro for specifying syntax. -## (grammar: lux_grammar -## [expression ...] -## [form "(" [#* expression] ")"]) +... TODO: Grammar macro for specifying syntax. +... (grammar: lux_grammar +... [expression ...] +... [form "(" [#* expression] ")"]) (with_expansions [<consume_1> (as_is where (!inc offset/0) source_code) <move_1> (as_is [(!forward 1 where) (!inc offset/0) source_code]) @@ -499,8 +499,8 @@ (def: .public (parse current_module aliases source_code//size) (-> Text Aliases Nat (Parser Code)) - ## The "exec []" is only there to avoid function fusion. - ## This is to preserve the loop as much as possible and keep it tight. + ... The "exec []" is only there to avoid function fusion. + ... This is to preserve the loop as much as possible and keep it tight. (exec [] (function (recur [where offset/0 source_code]) @@ -522,17 +522,17 @@ (~~ (static text.carriage_return))] (recur (!horizontal where offset/0 source_code)) - ## New line + ... New line [(~~ (static text.new_line))] (recur (!vertical where offset/0 source_code)) <composites> - ## Text + ... Text [(~~ (static ..text_delimiter))] (text_parser where (!inc offset/0) source_code) - ## Special code + ... Special code [(~~ (static ..sigil))] (<| (let [offset/1 (!inc offset/0)]) (!with_char+ source_code//size source_code offset/1 char/1 @@ -541,15 +541,6 @@ [[(~~ (static ..name_separator))] (!short_name_parser source_code//size current_module <move_2> where #.Tag) - ## Single_line comment - [(~~ (static ..sigil))] - (case ("lux text index" (!inc offset/1) (static text.new_line) source_code) - (#.Some end) - (recur (!vertical where end source_code)) - - _ - (!end_of_file where offset/1 source_code current_module)) - (~~ (template [<char> <bit>] [[<char>] (..bit_syntax <bit> [where offset/0 source_code])] @@ -557,33 +548,57 @@ ["0" #0] ["1" #1]))] - ## else + ... else (!if_name_char?|head char/1 - ## Tag + ... Tag (!full_name_parser offset/1 <move_2> where aliases #.Tag) (!failure ..parse where offset/0 source_code)))) - ## Coincidentally (= ..name_separator ..frac_separator) + ... Coincidentally (= ..name_separator ..frac_separator) [(~~ (static ..name_separator)) - ## (~~ (static ..frac_separator)) + ... (~~ (static ..frac_separator)) ] - (<| (let [offset/1 (!inc offset/0)]) - (!with_char+ source_code//size source_code offset/1 char/1 - (!end_of_file where offset/1 source_code current_module)) - (!if_digit? char/1 - (rev_parser source_code//size offset/0 where (!inc offset/1) source_code) - (!short_name_parser source_code//size current_module [where offset/1 source_code] where #.Identifier))) + ... It's either a Rev, an identifier, or a comment. + (with_expansions [<rev_parser> (rev_parser source_code//size offset/0 where (!inc offset/1) source_code) + <short_name_parser> (!short_name_parser source_code//size current_module [where offset/1 source_code] where #.Identifier) + <comment_parser> (case ("lux text index" (!inc offset/1) (static text.new_line) source_code) + (#.Some end) + (recur (!vertical where end source_code)) + + _ + (!end_of_file where offset/1 source_code current_module))] + (<| (let [offset/1 (!inc offset/0)]) + (!with_char+ source_code//size source_code offset/1 char/1 + (!end_of_file where offset/1 source_code current_module)) + (!if_digit? char/1 + ... It's a Rev. + <rev_parser> + ... It's either an identifier, or a comment. + ("lux syntax char case!" char/1 + [[(~~ (static ..name_separator))] + ... It's either an identifier, or a comment. + (<| (let [offset/2 (!inc offset/1)]) + (!with_char+ source_code//size source_code offset/2 char/2 + (!end_of_file where offset/2 source_code current_module)) + ("lux syntax char case!" char/2 + [[(~~ (static ..name_separator))] + ... It's a comment. + <comment_parser>] + ... It's an identifier. + <short_name_parser>))] + ... It's an identifier. + <short_name_parser>)))) [(~~ (static ..positive_sign)) (~~ (static ..negative_sign))] (!signed_parser source_code//size offset/0 where source_code aliases (!end_of_file where offset/0 source_code current_module))] - ## else + ... else (!if_digit? char/0 - ## Natural number + ... Natural number (nat_parser source_code//size offset/0 where (!inc offset/0) source_code) - ## Identifier + ... Identifier (!full_name_parser offset/0 [<consume_1>] where aliases #.Identifier)) ))) ))) 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 3112e5b74..0f02d37be 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -39,7 +39,7 @@ (type: .public State {#locals Nat - ## https://en.wikipedia.org/wiki/Currying + ... https://en.wikipedia.org/wiki/Currying #currying? Bit}) (def: .public fresh_resolver @@ -790,13 +790,13 @@ #..Pop nextP)]) -## TODO: There are sister patterns to the simple side checks for tuples. -## These correspond to the situation where tuple members are accessed -## and bound to variables, but those variables are never used, so they -## become POPs. -## After re-implementing unused-variable-elimination, must add those -## pattern-optimizations again, since a lot of BINDs will become POPs -## and thus will result in useless code being generated. +... TODO: There are sister patterns to the simple side checks for tuples. +... These correspond to the situation where tuple members are accessed +... and bound to variables, but those variables are never used, so they +... become POPs. +... After re-implementing unused-variable-elimination, must add those +... pattern-optimizations again, since a lot of BINDs will become POPs +... and thus will result in useless code being generated. (template [<name> <side>] [(template: .public (<name> idx nextP) [($_ ..path/seq diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index 8efda7f03..e42b2d2c5 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -127,7 +127,7 @@ (#.Some [id (#.Some [existing_descriptor existing_document existing_output])]) (if (is? document existing_document) - ## TODO: Find out why this code allows for the same module to be added more than once. It looks fishy... + ... TODO: Find out why this code allows for the same module to be added more than once. It looks fishy... (#try.Success archive) (exception.except ..cannot_replace_document [module existing_document document])) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io.lux b/stdlib/source/library/lux/tool/compiler/meta/io.lux index 5aa0d7331..72f98b3d9 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io.lux @@ -14,7 +14,7 @@ (def: .public (safe system) (All [m] (-> (System m) Text Text)) - (text.replace_all "/" (\ system separator))) + (text.replaced "/" (\ system separator))) (def: .public lux_context "lux") 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 81ac25578..e65ede1eb 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux @@ -73,8 +73,8 @@ (def: (find_local_source_file fs importer import contexts partial_host_extension module) (-> (file.System Async) Module Import (List Context) Extension Module (Async (Try [file.Path Binary]))) - ## Preference is explicitly being given to Lux files that have a host extension. - ## Normal Lux files (i.e. without a host extension) are then picked as fallback files. + ... Preference is explicitly being given to Lux files that have a host extension. + ... Normal Lux files (i.e. without a host extension) are then picked as fallback files. (do {! async.monad} [outcome (..find_source_file fs importer contexts module (..full_host_extension partial_host_extension))] (case outcome @@ -109,8 +109,8 @@ (def: (find_any_source_file fs importer import contexts partial_host_extension module) (-> (file.System Async) Module Import (List Context) Extension Module (Async (Try [file.Path Binary]))) - ## Preference is explicitly being given to Lux files that have a host extension. - ## Normal Lux files (i.e. without a host extension) are then picked as fallback files. + ... Preference is explicitly being given to Lux files that have a host extension. + ... Normal Lux files (i.e. without a host extension) are then picked as fallback files. (do {! async.monad} [outcome (find_local_source_file fs importer import contexts partial_host_extension module)] (case outcome diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux index bf5ed12f9..a36b2fda0 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -118,11 +118,11 @@ (def: byte 1) -## https://en.wikipedia.org/wiki/Kibibyte +... https://en.wikipedia.org/wiki/Kibibyte (def: kibi_byte (n.* 1,024 byte)) -## https://en.wikipedia.org/wiki/Mebibyte +... https://en.wikipedia.org/wiki/Mebibyte (def: mebi_byte (n.* 1,024 kibi_byte)) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux index ee2dd3415..f3bfea5b0 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux @@ -44,7 +44,7 @@ ["$" lux [generation (#+ Context)]]]]]]) -## TODO: Delete ASAP +... TODO: Delete ASAP (type: (Action ! a) (! (Try a))) diff --git a/stdlib/source/library/lux/tool/interpreter.lux b/stdlib/source/library/lux/tool/interpreter.lux index a531ed396..4631daec4 100644 --- a/stdlib/source/library/lux/tool/interpreter.lux +++ b/stdlib/source/library/lux/tool/interpreter.lux @@ -173,14 +173,14 @@ (do try.monad [.let [[_where _offset _code] (get@ #source context)] [source' input] (syntax.parse ..module syntax.no_aliases (text.size _code) (get@ #source context)) - [state' representation] (let [## TODO: Simplify ASAP + [state' representation] (let [... TODO: Simplify ASAP state (:sharing [anchor expression directive] {<Context> context} {(State+ anchor expression directive) (get@ #state context)})] (<| (phase.run' state) - ## TODO: Simplify ASAP + ... TODO: Simplify ASAP (:sharing [anchor expression directive] {<Context> context} diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index ed5964589..ba0384442 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -135,7 +135,7 @@ ($_ text\compose module "." name) )) -## https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction +... https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction (def: (reduced env type) (-> (List Type) Type Type) (case type @@ -180,7 +180,7 @@ (Equivalence Type) (def: (= x y) - (or (for {@.php false} ## TODO: Remove this once JPHP is gone. + (or (for {@.php false} ... TODO: Remove this once JPHP is gone. (is? x y)) (case [x y] [(#.Primitive xname xparams) (#.Primitive yname yparams)] @@ -439,7 +439,7 @@ (Parser Typed) (<>.and <code>.any <code>.any)) -## TODO: Make sure the generated code always gets optimized away. +... TODO: Make sure the generated code always gets optimized away. (syntax: .public (:sharing {type_vars ..type_parameters} {exemplar ..typed} {computation ..typed}) diff --git a/stdlib/source/library/lux/type/abstract.lux b/stdlib/source/library/lux/type/abstract.lux index 2ea87233e..79c5ecb41 100644 --- a/stdlib/source/library/lux/type/abstract.lux +++ b/stdlib/source/library/lux/type/abstract.lux @@ -19,7 +19,8 @@ [syntax (#+ syntax:) ["|.|" annotations]]]]]) -(type: Stack List) +(type: Stack + List) (def: peek (All [a] (-> (Stack a) (Maybe a))) @@ -34,6 +35,7 @@ list.tail) (type: .public Frame + {#.doc (doc "Meta-data about an abstract/nominal type in a stack of them.")} {#name Text #type_vars (List Code) #abstraction Code @@ -91,10 +93,12 @@ (exception.except ..no_active_frames []))))) (def: .public current + {#.doc (doc "The currently-being-defined abstract/nominal type.")} (Meta Frame) (..peek! #.None)) (def: .public (specific name) + {#.doc (doc "A specific abstract/nominal type still being defined somewhere in the scope.")} (-> Text (Meta Frame)) (..peek! (#.Some name))) @@ -175,6 +179,10 @@ (template [<name> <from> <to>] [(syntax: .public (<name> {[frame value] ..cast}) + {#.doc (doc "Type-casting macro for abstract/nominal types." + (: <to> + (<name> (: <from> + value))))} (do meta.monad [[name type_vars abstraction representation] (peek! frame)] (in (list (` ((~! :cast) [(~+ type_vars)] (~ <from>) (~ <to>) @@ -216,11 +224,89 @@ (<>.and (<>\in (` .private)) private) ))) -## TODO: Make sure the generated code always gets optimized away. -## (This applies to uses of ":abstraction" and ":representation") +... TODO: Make sure the generated code always gets optimized away. +... (This applies to uses of ":abstraction" and ":representation") (syntax: .public (abstract: {[export_policy [name type_vars] annotations representation_type primitives] ..abstract}) + {#.doc (doc "Define abstract/nominal types which hide their representation details." + "You can convert between the abstraction and its representation selectively to access the value, while hiding it from others." + (abstract: String + {#.doc "An opaque text."} + + Text + + (def: (string value) + (-> Text String) + (:abstraction value)) + + (def: (text value) + (-> String Text) + (:representation value))) + + "Type-parameters are optional." + (abstract: (Duplicate a) + {} + + [a a] + + (def: (duplicate value) + (All [a] (-> a (Duplicate a))) + (:abstraction [value value]))) + + "Definitions can be nested." + (abstract: (Single a) + {} + + a + + (def: (single value) + (All [a] (-> a (Single a))) + (:abstraction value)) + + (abstract: (Double a) + {} + + [a a] + + (def: (double value) + (All [a] (-> a (Double a))) + (:abstraction [value value])) + + (def: (single' value) + (All [a] (-> a (Single a))) + (:abstraction Single [value value])) + + (let [value 0123] + (is? value + (|> value + single' + (:representation Single) + double + :representation))))) + + "Type-parameters do not necessarily have to be used in the representation type." + "If they are not used, they become phantom types and can be used to customize types without changing the representation." + (abstract: (JavaScript a) + {} + + Text + + (abstract: Expression {} Any) + (abstract: Statement {} Any) + + (def: (+ x y) + (-> (JavaScript Expression) (JavaScript Expression) (JavaScript Expression)) + (:abstraction + (format "(" (:representation x) "+" (:representation y) ")"))) + + (def: (while test body) + (-> (JavaScript Expression) (JavaScript Statement) (JavaScript Statement)) + (:abstraction + (format "while(" (:representation test) ") {" + (:representation body) + "}")))) + )} (do meta.monad [current_module meta.current_module_name .let [type_varsC (list\map code.local_identifier type_vars) @@ -251,18 +337,39 @@ parser)) (syntax: .public (:transmutation {selection (..selection <code>.any)}) + {#.doc (doc "Transmutes an abstract/nominal type's phantom types." + (abstract: (JavaScript a) + {} + + Text + + (abstract: Expression {} Any) + (abstract: Statement {} Any) + + (def: (statement expression) + (-> (JavaScript Expression) (JavaScript Statement)) + (:transmutation expression)) + + (def: (statement' expression) + (-> (JavaScript Expression) (JavaScript Statement)) + (:transmutation JavaScript expression))))} (case selection (#Specific specific value) - (in (list (` (..:abstraction (~ specific) - (..:representation (~ specific) - (~ value)))))) + (in (list (` (.|> (~ value) + (..:representation (~ specific)) + (..:abstraction (~ specific)))))) (#Current value) - (in (list (` (..:abstraction (..:representation (~ value)))))))) + (in (list (` (.|> (~ value) ..:representation ..:abstraction)))))) (syntax: .public (^:representation {selection (<code>.form (..selection <code>.local_identifier))} body {branches (<>.some <code>.any)}) + {#.doc (doc "Pattern-matching macro to easily extract a representation." + (def: (computation abstraction) + (All [a] (-> (Abstract a) ???)) + (let [(^:representation value) abstraction] + (foo (bar (baz value))))))} (case selection (#Specific specific name) (let [g!var (code.local_identifier name)] diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index 352c5f3df..1c04d9482 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -53,12 +53,14 @@ ["Actual" (//.format actual)])) (type: .public Var + {#.doc (doc "The ID for a type-variable in a type-checking context.")} Nat) (type: Assumption [Type Type]) (type: .public (Check a) + {#.doc (doc "A type-checking computation which may fail or yield a value.")} (-> Type_Context (Try [Type_Context a]))) (type: (Checker a) @@ -183,7 +185,7 @@ (..failure (exception.error exception message))) (def: .public existential - {#.doc "A producer of existential types."} + {#.doc "A brand-new existential type."} (Check [Nat Type]) (function (_ context) (let [id (get@ #.ex_counter context)] @@ -234,6 +236,8 @@ (exception.except ..unknown_type_var id)))) (def: .public (bind type id) + {#.doc (doc "Attemmpts to buy a type-variable." + "Fails if the variable has been bound already.")} (-> Type Var (Check Any)) (function (_ context) (case (|> context (get@ #.var_bindings) (var::get id)) @@ -259,6 +263,7 @@ (exception.except ..unknown_type_var id)))) (def: .public var + {#.doc (doc "A brand-new (unbound) type-variable.")} (Check [Var Type]) (function (_ context) (let [id (get@ #.var_counter context)] @@ -300,7 +305,7 @@ Ring (set.empty n.hash)) -## TODO: Optimize this by not using sets anymore. +... TODO: Optimize this by not using sets anymore. (def: (ring start) (-> Var (Check Ring)) (function (_ context) @@ -324,6 +329,7 @@ (exception.except ..unknown_type_var current))))) (def: .public fresh_context + {#.doc (doc "An empty/un-used type-checking context.")} Type_Context {#.var_counter 0 #.ex_counter 0 @@ -360,7 +366,7 @@ (-> Assumption (List Assumption) (List Assumption)) (#.Item assumption assumptions)) -## TODO: "if_bind" can be optimized... +... TODO: "if_bind" can be optimized... (def: (if_bind id type then else) (All [a] (-> Var Type (Check a) (-> Type (Check a)) @@ -378,21 +384,21 @@ [?bound (read id)] (else (maybe.else (#.Var id) ?bound))))) -## TODO: "link_2" can be optimized... +... TODO: "link_2" can be optimized... (def: (link_2 left right) (-> Var Var (Check Any)) (do ..monad [_ (..bind (#.Var right) left)] (..bind (#.Var left) right))) -## TODO: "link_3" can be optimized... +... TODO: "link_3" can be optimized... (def: (link_3 interpose to from) (-> Var Var Var (Check Any)) (do ..monad [_ (update (#.Var interpose) from)] (update (#.Var to) interpose))) -## TODO: "check_vars" can be optimized... +... TODO: "check_vars" can be optimized... (def: (check_vars check' assumptions idE idA) (-> (Checker Type) (Checker Var)) (if (!n\= idE idA) @@ -401,13 +407,13 @@ [ebound (attempt (peek idE)) abound (attempt (peek idA))] (case [ebound abound] - ## Link the 2 variables circularly + ... Link the 2 variables circularly [#.None #.None] (do ! [_ (link_2 idE idA)] (in assumptions)) - ## Interpose new variable between 2 existing links + ... Interpose new variable between 2 existing links [(#.Some etype) #.None] (case etype (#.Var targetE) @@ -418,7 +424,7 @@ _ (check' assumptions etype (#.Var idA))) - ## Interpose new variable between 2 existing links + ... Interpose new variable between 2 existing links [#.None (#.Some atype)] (case atype (#.Var targetA) @@ -437,7 +443,7 @@ ringA (..ring idA)] (if (\ set.equivalence = ringE ringA) (in assumptions) - ## Fuse 2 rings + ... Fuse 2 rings (do ! [_ (monad.fold ! (function (_ interpose to) (do ! @@ -463,7 +469,7 @@ (All [a] (Check a)) (..failure "")) -## TODO: "check_apply" can be optimized... +... TODO: "check_apply" can be optimized... (def: (check_apply check' assumptions expected actual) (-> (Checker Type) (Checker [Type Type])) (let [[expected_input expected_function] expected @@ -554,11 +560,11 @@ (All [e a] (-> (Exception e) e (Check a) (Check a))) (|>> check (exception.with exception parameter))) -## TODO: "check'" can be optimized... +... TODO: "check'" can be optimized... (def: (check' assumptions expected actual) {#.doc "Type-check to ensure that the 'expected' type subsumes the 'actual' type."} (Checker Type) - (if (for {@.php false} ## TODO: Remove this once JPHP is gone. + (if (for {@.php false} ... TODO: Remove this once JPHP is gone. (is? expected actual)) (check\in assumptions) (with ..type_check_failed [expected actual] @@ -599,7 +605,7 @@ [actual' (apply_type! F A)] (check' assumptions expected actual')) - ## TODO: Refactor-away as cold-code + ... TODO: Refactor-away as cold-code (^template [<tag> <instancer>] [[(<tag> _) _] (do ..monad @@ -609,7 +615,7 @@ ([#.UnivQ ..existential] [#.ExQ ..var]) - ## TODO: Refactor-away as cold-code + ... TODO: Refactor-away as cold-code (^template [<tag> <instancer>] [[_ (<tag> _)] (do ..monad @@ -680,11 +686,13 @@ true)) (def: .public context + {#.doc (doc "The current state of the type-checking context.")} (Check Type_Context) (function (_ context) (#try.Success [context context]))) (def: .public (clean inputT) + {#.doc (doc "Resolves every bound type-variable to yield a new type that is as resolved as possible.")} (-> Type (Check Type)) (case inputT (#.Primitive name paramsT+) diff --git a/stdlib/source/library/lux/type/dynamic.lux b/stdlib/source/library/lux/type/dynamic.lux index bfd73455c..8b4780d1f 100644 --- a/stdlib/source/library/lux/type/dynamic.lux +++ b/stdlib/source/library/lux/type/dynamic.lux @@ -33,9 +33,9 @@ (in (list (` (let [(~ g!value) (~ value)] ((~! ..abstraction) [(:of (~ g!value)) (~ g!value)]))))))) - (syntax: .public (:check type value) + (syntax: .public (:static type value) {#.doc (doc (: (try.Try Nat) - (:check Nat (:dynamic 123))))} + (:static Nat (:dynamic 123))))} (with_gensyms [g!type g!value] (in (list (` (let [[(~ g!type) (~ g!value)] ((~! ..representation) (~ value))] (: ((~! try.Try) (~ type)) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index b6b351262..74853320d 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -365,7 +365,7 @@ (#.Right [args _]) (do {! meta.monad} - [labels (|> (macro.gensym "") (list.repeat (list.size args)) (monad.seq !))] + [labels (|> (macro.gensym "") (list.repeated (list.size args)) (monad.seq !))] (in (list (` (let [(~+ (|> args (list.zipped/2 labels) (list\map ..pair_list) list\join))] (..\\ (~ (code.identifier member)) (~+ labels))))))) )) @@ -373,7 +373,7 @@ (def: (implicit_bindings amount) (-> Nat (Meta (List Code))) (|> (macro.gensym "g!implicit") - (list.repeat amount) + (list.repeated amount) (monad.seq meta.monad))) (def: implicits @@ -381,6 +381,10 @@ (<code>.tuple (<>.many <code>.any))) (syntax: .public (with {implementations ..implicits} body) + {#.doc (doc "Establish lexical bindings for implementations that will be prioritized over non-lexically-bound implementations." + (with [n.addition] + (n.= (\ n.addition compose left right) + (\\ compose left right))))} (do meta.monad [g!implicit+ (implicit_bindings (list.size implementations))] (in (list (` (let [(~+ (|> (list.zipped/2 g!implicit+ implementations) @@ -390,6 +394,11 @@ (~ body))))))) (syntax: .public (implicit: {implementations ..implicits}) + {#.doc (doc "Establish local definitions for implementations that will be prioritized over foreign definitions." + (implicit: [n.multiplication]) + + (n.= (\ n.multiplication compose left right) + (\\ compose left right)))} (do meta.monad [g!implicit+ (implicit_bindings (list.size implementations))] (in (|> (list.zipped/2 g!implicit+ implementations) diff --git a/stdlib/source/library/lux/type/quotient.lux b/stdlib/source/library/lux/type/quotient.lux index 5d2c29f2f..f68a1c099 100644 --- a/stdlib/source/library/lux/type/quotient.lux +++ b/stdlib/source/library/lux/type/quotient.lux @@ -9,7 +9,7 @@ abstract]]]) (abstract: .public (Class t c %) - {} + {#.doc (doc "The class knows how to classify/label values that are meant to be equivalent to one another.")} (-> t c) @@ -20,7 +20,9 @@ (|>> :abstraction)) (abstract: .public (Quotient t c %) - {} + {#.doc (doc "A quotient value has been labeled with a class." + "All equivalent values will belong to the same class." + "This means all equivalent values possess the same label.")} {#value t #label c} @@ -44,6 +46,16 @@ ) (syntax: .public (type class) + {#.doc (doc "The Quotient type associated with a Class type." + (def: even + (class even?)) + + (def: Even + Type + (type even)) + + (: Even + (quotient even 123)))} (with_gensyms [g!t g!c g!%] (in (list (` ((~! type.:by_example) [(~ g!t) (~ g!c) (~ g!%)] diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux index a34153800..0ea7bf75c 100644 --- a/stdlib/source/library/lux/type/refinement.lux +++ b/stdlib/source/library/lux/type/refinement.lux @@ -9,15 +9,16 @@ abstract]]]) (abstract: .public (Refined t %) - {#.doc "A refined type '%' of base type 't' using a predicate."} + {#.doc "A refined version of another type, using a predicate to select valid instances."} {#value t #predicate (Predicate t)} (type: .public (Refiner t %) + {#.doc (doc "A selection mechanism for refined instances of a type.")} (-> t (Maybe (Refined t %)))) - (def: .public (refinement predicate) + (def: .public (refiner predicate) (All [t] (Ex [%] (-> (Predicate t) (Refiner t %)))) @@ -37,6 +38,8 @@ ) (def: .public (lift transform) + {#.doc (doc "Yields a function that can work on refined values." + "Respects the constraints of the refinement.")} (All [t %] (-> (-> t t) (-> (Refined t %) (Maybe (Refined t %))))) @@ -50,7 +53,8 @@ ) (def: .public (only refiner values) - (All [t %] (-> (Refiner t %) (List t) (List (Refined t %)))) + (All [t %] + (-> (Refiner t %) (List t) (List (Refined t %)))) (case values #.End #.End @@ -64,7 +68,9 @@ (only refiner tail)))) (def: .public (partition refiner values) - (All [t %] (-> (Refiner t %) (List t) [(List (Refined t %)) (List t)])) + {#.doc (doc "Separates refined values from the un-refined ones.")} + (All [t %] + (-> (Refiner t %) (List t) [(List (Refined t %)) (List t)])) (case values #.End [#.End #.End] @@ -81,6 +87,16 @@ (#.Item head no)])))) (syntax: .public (type refiner) + {#.doc (doc "The Refined type associated with a Refiner type." + (def: even + (refiner even?)) + + (def: Even + Type + (type even)) + + (: (Maybe Even) + (even 123)))} (macro.with_gensyms [g!t g!%] (in (list (` ((~! type.:by_example) [(~ g!t) (~ g!%)] (..Refiner (~ g!t) (~ g!%)) diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux index 2a568e6fd..8d389b11e 100644 --- a/stdlib/source/library/lux/type/resource.lux +++ b/stdlib/source/library/lux/type/resource.lux @@ -26,17 +26,25 @@ abstract]]]) (type: .public (Procedure monad input output value) + {#.doc (doc "A computation that takes a sequence of resource access rights as inputs and yields a different sequence as outputs." + "A procedure yields a result value." + "A procedure can make use of monadic effects.")} (-> input (monad [output value]))) (type: .public (Linear monad value) + {#.doc (doc "A procedure that is constant with regards to resource access rights." + "This means no additional resources will be available after the computation is over." + "This also means no previously available resources will have been consumed.")} (All [keys] (Procedure monad keys keys value))) (type: .public (Affine monad permissions value) + {#.doc (doc "A procedure which expands the number of available resources.")} (All [keys] (Procedure monad keys [permissions keys] value))) (type: .public (Relevant monad permissions value) + {#.doc (doc "A procedure which reduces the number of available resources.")} (All [keys] (Procedure monad [permissions keys] keys value))) @@ -66,12 +74,17 @@ [output procedure] (in [keys output])))) -(abstract: .public Ordered {} Any) +(abstract: .public Ordered + {#.doc (doc "The mode of keys which CANNOT be swapped, and for whom order of release/consumption matters.")} + Any) -(abstract: .public Commutative {} Any) +(abstract: .public Commutative + {#.doc (doc "The mode of keys which CAN be swapped, and for whom order of release/consumption DOES NOT matters.")} + Any) (abstract: .public (Key mode key) - {} + {#.doc (doc "The access right for a resource." + "Without the key for a resource existing somewhere among the available ambient rights, one cannot use a resource.")} Any @@ -85,12 +98,14 @@ )) (abstract: .public (Res key value) - {#.doc "A value locked by a key."} + {#.doc (doc "A resource locked by a key." + "The 'key' represents the right to access/consume a resource.")} value (template [<name> <mode> <key>] [(def: .public (<name> monad value) + {#.doc (doc "Makes a value into a resource and adds the key/access-right to it to the ambient keyring for future use.")} (All [! v] (Ex [k] (-> (Monad !) v (Affine ! (Key <mode> k) (Res k v))))) (function (_ keys) (\ monad in [[(<key> []) keys] (:abstraction value)])))] @@ -100,6 +115,7 @@ ) (def: .public (read monad resource) + {#.doc (doc "Access the value of a resource, so long as its key is available.")} (All [! v k m] (-> (Monad !) (Res k v) (Relevant ! (Key m k) v))) (function (_ [key keys]) @@ -132,6 +148,16 @@ (\ monad in [context []]))) (syntax: .public (exchange {swaps ..indices}) + {#.doc (doc "A function that can exchange the keys for resource, so long as they are commutative." + "This keys will be placed at the front of the keyring in the order they are specified." + "The specific keys must be specified based of their index into the current keyring." + (do (..monad !) + [res|left (/.commutative ! pre) + res|right (/.commutative ! post) + _ ((/.exchange [1 0]) !) + left (/.read ! res|left) + right (/.read ! res|right)] + (in (format left right))))} (macro.with_gensyms [g!_ g!context g!!] (case swaps #.End @@ -140,7 +166,7 @@ (#.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")) + g!inputs (<| (monad.seq !) (list.repeated (inc max_idx)) (macro.gensym "input")) .let [g!outputs (|> (monad.fold maybe.monad (function (_ from to) (do maybe.monad @@ -171,10 +197,19 @@ (template [<name> <from> <to>] [(syntax: .public (<name> {amount ..amount}) + {#.doc (doc "Group/un-group keys in the keyring into/out-of tuples." + (do (..monad !) + [res|left (/.commutative ! pre) + res|right (/.commutative ! post) + _ ((/.group 2) !) + _ ((/.un_group 2) !) + right (/.read ! res|right) + left (/.read ! res|left)] + (in (format left right))))} (macro.with_gensyms [g!_ g!context g!!] (do {! meta.monad} [g!keys (|> (macro.gensym "keys") - (list.repeat amount) + (list.repeated amount) (monad.seq !))] (in (list (` (: (All [(~ g!!) (~+ g!keys) (~ g!context)] (-> ((~! monad.Monad) (~ g!!)) diff --git a/stdlib/source/library/lux/type/unit.lux b/stdlib/source/library/lux/type/unit.lux index 3348ded53..35d0c66c8 100644 --- a/stdlib/source/library/lux/type/unit.lux +++ b/stdlib/source/library/lux/type/unit.lux @@ -11,11 +11,13 @@ ["<>" parser ("#\." monad) ["<.>" code (#+ Parser)]]] [data - [text + ["." text ["%" format (#+ format)]]] [macro ["." code] + ["." template] [syntax (#+ syntax:) + ["|.|" export] ["|.|" annotations]]] [math [number @@ -26,7 +28,7 @@ abstract]]]) (abstract: .public (Qty unit) - {} + {#.doc (doc "A quantity with an associated unit of measurement.")} Int @@ -60,12 +62,14 @@ ) (interface: .public (Unit a) + {#.doc (doc "A unit of measurement, to qualify numbers with.")} (: (-> Int (Qty a)) in) (: (-> (Qty a) Int) out)) (interface: .public (Scale s) + {#.doc (doc "A scale of magnitude.")} (: (All [u] (-> (Qty u) (Qty (s u)))) scale) (: (All [u] (-> (Qty (s u)) (Qty u))) @@ -74,6 +78,7 @@ ratio)) (type: .public Pure + {#.doc (doc "A pure, unit-less quantity.")} (Qty Any)) (def: .public pure @@ -84,17 +89,16 @@ (-> Pure Int) ..out) -(def: unitP - (Parser [Code Text Text |annotations|.Annotations]) - (let [private ($_ <>.and - <code>.local_identifier - <code>.local_identifier - (<>.else |annotations|.empty |annotations|.parser))] - (<>.either (<>.and <code>.any private) - (<>.and (<>\in (` .private)) private)))) - -(syntax: .public (unit: - {[export_policy type_name unit_name annotations] ..unitP}) +(syntax: .public (unit: {[export_policy type_name unit_name annotations] + (|export|.parser + ($_ <>.and + <code>.local_identifier + <code>.local_identifier + (<>.else |annotations|.empty |annotations|.parser)))}) + {#.doc (doc "Define a unit of measurement." + "Both the name of the type, and the name of the Unit implementation must be specified." + (unit: .public Feet feet + {#.doc (doc "Optional annotations.")}))} (do meta.monad [@ meta.current_module_name .let [g!type (code.local_identifier type_name)]] @@ -120,18 +124,17 @@ (n.> 0 denominator))] (in [numerator denominator])))) -(def: scaleP - (Parser [Code Text Text Ratio |annotations|.Annotations]) - (let [private ($_ <>.and - <code>.local_identifier - <code>.local_identifier - ..scale - (<>.else |annotations|.empty |annotations|.parser))] - (<>.either (<>.and <code>.any private) - (<>.and (<>\in (` .private)) private)))) - -(syntax: .public (scale: - {[export_policy type_name scale_name ratio annotations] ..scaleP}) +(syntax: .public (scale: {[export_policy type_name scale_name ratio annotations] + (|export|.parser + ($_ <>.and + <code>.local_identifier + <code>.local_identifier + ..scale + (<>.else |annotations|.empty |annotations|.parser)))}) + {#.doc (doc "Define a scale of magnitude." + (scale: .public Bajillion bajillion + [1 1,234,567,890] + {#.doc (doc "Optional annotations.")}))} (do meta.monad [.let [(^slots [#ratio.numerator #ratio.denominator]) ratio] @ meta.current_module_name @@ -167,18 +170,34 @@ (i./ (.int denominator)) in))) -(scale: .public Kilo kilo [1 1,000]) -(scale: .public Mega mega [1 1,000,000]) -(scale: .public Giga giga [1 1,000,000,000]) +(syntax: (implementation_name {type_name <code>.local_identifier}) + (in (list (code.local_identifier (text.lower_cased type_name))))) -(scale: .public Milli milli [ 1,000 1]) -(scale: .public Micro micro [ 1,000,000 1]) -(scale: .public Nano nano [1,000,000,000 1]) +(template [<type> <from> <to>] + [(`` (scale: .public <type> + (~~ (implementation_name <type>)) + [<from> <to>] + {#.doc (doc (~~ (template.text ["'" <type> "' scale from " <from> " to " <to> "."])))}))] -(unit: .public Gram gram) -(unit: .public Meter meter) -(unit: .public Litre litre) -(unit: .public Second second) + [Kilo 1 1,000] + [Mega 1 1,000,000] + [Giga 1 1,000,000,000] + + [Milli 1,000 1] + [Micro 1,000,000 1] + [Nano 1,000,000,000 1] + ) + +(template [<type>] + [(`` (unit: .public <type> + (~~ (implementation_name <type>)) + {#.doc (doc (~~ (template.text ["'" <type> "' unit of meaurement."])))}))] + + [Gram] + [Meter] + [Litre] + [Second] + ) (implementation: .public equivalence (All [unit] (Equivalence (Qty unit))) diff --git a/stdlib/source/library/lux/type/variance.lux b/stdlib/source/library/lux/type/variance.lux index 2a7d65267..8755777b9 100644 --- a/stdlib/source/library/lux/type/variance.lux +++ b/stdlib/source/library/lux/type/variance.lux @@ -3,10 +3,13 @@ [lux #*]]) (type: .public (Co t) + {#.doc (doc "A constraint for covariant types.")} (-> Any t)) (type: .public (Contra t) + {#.doc (doc "A constraint for contravariant types.")} (-> t Any)) (type: .public (In t) + {#.doc (doc "A constraint for invariant types.")} (-> t t)) diff --git a/stdlib/source/library/lux/world/console.lux b/stdlib/source/library/lux/world/console.lux index fead037c2..83b83145d 100644 --- a/stdlib/source/library/lux/world/console.lux +++ b/stdlib/source/library/lux/world/console.lux @@ -78,8 +78,8 @@ (let [jvm_input (java/lang/System::in) jvm_output (java/lang/System::out)] (<| in - exception.return - (: (Console IO)) ## TODO: Remove ASAP + #try.Success + (: (Console IO)) ... TODO: Remove ASAP (implementation (def: (read _) (|> jvm_input @@ -119,11 +119,11 @@ (~~ (template [<method> <mock>] [(def: (<method> _) (do {! io.monad} - [|state| (atom.read state)] + [|state| (atom.read! state)] (case (\ mock <mock> |state|) (#try.Success [|state| output]) (do ! - [_ (atom.write |state| state)] + [_ (atom.write! |state| state)] (in (#try.Success output))) (#try.Failure error) @@ -135,11 +135,11 @@ (def: (write input) (do {! io.monad} - [|state| (atom.read state)] + [|state| (atom.read! state)] (case (\ mock on_write input |state|) (#try.Success |state|) (do ! - [_ (atom.write |state| state)] + [_ (atom.write! |state| state)] (in (#try.Success []))) (#try.Failure error) @@ -147,11 +147,11 @@ (def: (close _) (do {! io.monad} - [|state| (atom.read state)] + [|state| (atom.read! state)] (case (\ mock on_close |state|) (#try.Success |state|) (do ! - [_ (atom.write |state| state)] + [_ (atom.write! |state| state)] (in (#try.Success []))) (#try.Failure error) diff --git a/stdlib/source/library/lux/world/db/jdbc/output.lux b/stdlib/source/library/lux/world/db/jdbc/output.lux index 7fbcc2b3e..08c7354f5 100644 --- a/stdlib/source/library/lux/world/db/jdbc/output.lux +++ b/stdlib/source/library/lux/world/db/jdbc/output.lux @@ -165,7 +165,7 @@ [?tail (rows output results)] (case ?tail (#try.Success tail) - (in (ex.return (#.Item head tail))) + (in (#try.Success (#.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 e8d053c44..e7ebd8acf 100644 --- a/stdlib/source/library/lux/world/db/sql.lux +++ b/stdlib/source/library/lux/world/db/sql.lux @@ -17,7 +17,7 @@ (-> Text Text) (text.enclosed ["(" ")"])) -## Kind +... Kind (template [<declaration>] [(abstract: .public <declaration> Any)] @@ -62,7 +62,7 @@ (abstract: .public (SQL kind) Text - ## SQL + ... SQL (template [<declaration> <kind>] [(type: .public <declaration> (SQL <kind>))] @@ -111,7 +111,7 @@ (|>> (list\map (|>> :representation)) (text.join_with ", "))) - ## Value + ... Value (def: .public ? Placeholder (:abstraction "?")) (def: literal @@ -135,7 +135,7 @@ (:abstraction (format (:representation function) (..parenthesize (..listing parameters))))) - ## Condition + ... Condition (template [<name> <sql_op>] [(def: .public (<name> reference sample) (-> Value Value Condition) @@ -192,7 +192,7 @@ [exists Any_Query "EXISTS"] ) - ## Query + ... Query (template [<name> <type> <decoration>] [(def: .public <name> (-> <type> Source) @@ -315,7 +315,7 @@ " GROUP BY " (..listing pairs))))) - ## Command + ... Command (def: .public (insert table columns rows) (-> Table (List Column) (List (List Value)) (Command Without_Where Without_Having)) (:abstraction @@ -344,7 +344,7 @@ (-> Table (Command No_Where No_Having)) (|>> :representation (format "DELETE FROM ") :abstraction)) - ## Action + ... Action (def: .public (where condition prev) (All [kind having] (-> Condition (Action No_Where having kind) (Action With_Where having kind))) @@ -361,7 +361,7 @@ " HAVING " (:representation condition)))) - ## Schema + ... Schema (def: .public type (-> Text (Schema Value)) (|>> :abstraction)) diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 62c4404e8..8e2adf93b 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -802,185 +802,185 @@ (in []))) ))) - ## @.php - ## (as_is (ffi.import: (FILE_APPEND Int)) - ## ## https://www.php.net/manual/en/dir.constants.php - ## (ffi.import: (DIRECTORY_SEPARATOR ffi.String)) - ## ## https://www.php.net/manual/en/function.pack.php - ## ## https://www.php.net/manual/en/function.unpack.php - ## (ffi.import: (unpack [ffi.String ffi.String] Binary)) - ## ## https://www.php.net/manual/en/ref.filesystem.php - ## ## https://www.php.net/manual/en/function.file-get-contents.php - ## (ffi.import: (file_get_contents [Path] #io #try ffi.String)) - ## ## https://www.php.net/manual/en/function.file-put-contents.php - ## (ffi.import: (file_put_contents [Path ffi.String Int] #io #try ffi.Integer)) - ## (ffi.import: (filemtime [Path] #io #try ffi.Integer)) - ## (ffi.import: (filesize [Path] #io #try ffi.Integer)) - ## (ffi.import: (is_executable [Path] #io #try ffi.Boolean)) - ## (ffi.import: (touch [Path ffi.Integer] #io #try ffi.Boolean)) - ## (ffi.import: (rename [Path Path] #io #try ffi.Boolean)) - ## (ffi.import: (unlink [Path] #io #try ffi.Boolean)) - - ## ## https://www.php.net/manual/en/function.rmdir.php - ## (ffi.import: (rmdir [Path] #io #try ffi.Boolean)) - ## ## https://www.php.net/manual/en/function.scandir.php - ## (ffi.import: (scandir [Path] #io #try (Array Path))) - ## ## https://www.php.net/manual/en/function.is-file.php - ## (ffi.import: (is_file [Path] #io #try ffi.Boolean)) - ## ## https://www.php.net/manual/en/function.is-dir.php - ## (ffi.import: (is_dir [Path] #io #try ffi.Boolean)) - ## ## https://www.php.net/manual/en/function.mkdir.php - ## (ffi.import: (mkdir [Path] #io #try ffi.Boolean)) - - ## (def: byte_array_format "C*") - ## (def: default_separator (..DIRECTORY_SEPARATOR)) - - ## (template [<name>] - ## [(exception: .public (<name> {file Path}) - ## (exception.report - ## ["Path" file]))] - - ## [cannot_write_to_file] - ## ) - - ## (`` (implementation: (file path) - ## (-> Path (File IO)) - - ## (~~ (template [<name> <mode>] - ## [(def: (<name> data) - ## (do {! (try.with io.monad)} - ## [outcome (..file_put_contents [path ("php pack" ..byte_array_format data) <mode>])] - ## (if (bit\= false (:as Bit outcome)) - ## (\ io.monad in (exception.except ..cannot_write_to_file [path])) - ## (in []))))] + ... @.php + ... (as_is (ffi.import: (FILE_APPEND Int)) + ... ... https://www.php.net/manual/en/dir.constants.php + ... (ffi.import: (DIRECTORY_SEPARATOR ffi.String)) + ... ... https://www.php.net/manual/en/function.pack.php + ... ... https://www.php.net/manual/en/function.unpack.php + ... (ffi.import: (unpack [ffi.String ffi.String] Binary)) + ... ... https://www.php.net/manual/en/ref.filesystem.php + ... ... https://www.php.net/manual/en/function.file-get-contents.php + ... (ffi.import: (file_get_contents [Path] #io #try ffi.String)) + ... ... https://www.php.net/manual/en/function.file-put-contents.php + ... (ffi.import: (file_put_contents [Path ffi.String Int] #io #try ffi.Integer)) + ... (ffi.import: (filemtime [Path] #io #try ffi.Integer)) + ... (ffi.import: (filesize [Path] #io #try ffi.Integer)) + ... (ffi.import: (is_executable [Path] #io #try ffi.Boolean)) + ... (ffi.import: (touch [Path ffi.Integer] #io #try ffi.Boolean)) + ... (ffi.import: (rename [Path Path] #io #try ffi.Boolean)) + ... (ffi.import: (unlink [Path] #io #try ffi.Boolean)) + + ... ... https://www.php.net/manual/en/function.rmdir.php + ... (ffi.import: (rmdir [Path] #io #try ffi.Boolean)) + ... ... https://www.php.net/manual/en/function.scandir.php + ... (ffi.import: (scandir [Path] #io #try (Array Path))) + ... ... https://www.php.net/manual/en/function.is-file.php + ... (ffi.import: (is_file [Path] #io #try ffi.Boolean)) + ... ... https://www.php.net/manual/en/function.is-dir.php + ... (ffi.import: (is_dir [Path] #io #try ffi.Boolean)) + ... ... https://www.php.net/manual/en/function.mkdir.php + ... (ffi.import: (mkdir [Path] #io #try ffi.Boolean)) + + ... (def: byte_array_format "C*") + ... (def: default_separator (..DIRECTORY_SEPARATOR)) + + ... (template [<name>] + ... [(exception: .public (<name> {file Path}) + ... (exception.report + ... ["Path" file]))] + + ... [cannot_write_to_file] + ... ) + + ... (`` (implementation: (file path) + ... (-> Path (File IO)) + + ... (~~ (template [<name> <mode>] + ... [(def: (<name> data) + ... (do {! (try.with io.monad)} + ... [outcome (..file_put_contents [path ("php pack" ..byte_array_format data) <mode>])] + ... (if (bit\= false (:as Bit outcome)) + ... (\ io.monad in (exception.except ..cannot_write_to_file [path])) + ... (in []))))] - ## [over_write +0] - ## [append (..FILE_APPEND)] - ## )) - - ## (def: (content _) - ## (do {! (try.with io.monad)} - ## [data (..file_get_contents [path])] - ## (if (bit\= false (:as Bit data)) - ## (\ io.monad in (exception.except ..cannot_find_file [path])) - ## (in (..unpack [..byte_array_format data]))))) - - ## (def: path - ## path) - - ## (~~ (template [<name> <ffi> <pipeline>] - ## [(def: (<name> _) - ## (do {! (try.with io.monad)} - ## [value (<ffi> [path])] - ## (if (bit\= false (:as Bit value)) - ## (\ io.monad in (exception.except ..cannot_find_file [path])) - ## (in (`` (|> value (~~ (template.spliced <pipeline>))))))))] - - ## [size ..filesize [.nat]] - ## [last_modified ..filemtime [(i.* +1,000) duration.of_millis instant.absolute]] - ## )) - - ## (def: (can_execute? _) - ## (..is_executable [path])) - - ## (def: (modify moment) - ## (do {! (try.with io.monad)} - ## [verdict (..touch [path (|> moment instant.relative duration.millis (i./ +1,000))])] - ## (if (bit\= false (:as Bit verdict)) - ## (\ io.monad in (exception.except ..cannot_find_file [path])) - ## (in [])))) - - ## (def: (move destination) - ## (do {! (try.with io.monad)} - ## [verdict (..rename [path destination])] - ## (if (bit\= false (:as Bit verdict)) - ## (\ io.monad in (exception.except ..cannot_find_file [path])) - ## (in (file destination))))) - - ## (def: (delete _) - ## (do (try.with io.monad) - ## [verdict (..unlink [path])] - ## (if (bit\= false (:as Bit verdict)) - ## (\ io.monad in (exception.except ..cannot_find_file [path])) - ## (in [])))) - ## )) - - ## (`` (implementation: (directory path) - ## (-> Path (Directory IO)) - - ## (def: scope - ## path) - - ## (~~ (template [<name> <test> <constructor> <capability>] - ## [(def: (<name> _) - ## (do {! (try.with io.monad)} - ## [children (..scandir [path])] - ## (loop [input (|> children - ## array.list - ## (list.only (function (_ child) - ## (not (or (text\= "." child) - ## (text\= ".." child)))))) - ## output (: (List (<capability> IO)) - ## (list))] - ## (case input - ## #.End - ## (in output) - - ## (#.Item head tail) - ## (do ! - ## [verdict (<test> head)] - ## (if verdict - ## (recur tail (#.Item (<constructor> head) output)) - ## (recur tail output)))))))] - - ## [files ..is_file ..file File] - ## [directories ..is_dir directory Directory] - ## )) - - ## (def: (discard _) - ## (do (try.with io.monad) - ## [verdict (..rmdir [path])] - ## (if (bit\= false (:as Bit verdict)) - ## (\ io.monad in (exception.except ..cannot_find_directory [path])) - ## (in [])))) - ## )) - - ## (`` (implementation: .public default - ## (System IO) - - ## (~~ (template [<name> <test> <constructor> <exception>] - ## [(def: (<name> path) - ## (do {! (try.with io.monad)} - ## [verdict (<test> path)] - ## (\ io.monad in - ## (if verdict - ## (#try.Success (<constructor> path)) - ## (exception.except <exception> [path])))))] - - ## [file ..is_file ..file ..cannot_find_file] - ## [directory ..is_dir ..directory ..cannot_find_directory] - ## )) - - ## (def: (make_file path) - ## (do {! (try.with io.monad)} - ## [verdict (..touch [path (|> instant.now io.run instant.relative duration.millis (i./ +1,000))])] - ## (\ io.monad in - ## (if verdict - ## (#try.Success (..file path)) - ## (exception.except ..cannot_make_file [path]))))) + ... [over_write +0] + ... [append (..FILE_APPEND)] + ... )) + + ... (def: (content _) + ... (do {! (try.with io.monad)} + ... [data (..file_get_contents [path])] + ... (if (bit\= false (:as Bit data)) + ... (\ io.monad in (exception.except ..cannot_find_file [path])) + ... (in (..unpack [..byte_array_format data]))))) + + ... (def: path + ... path) + + ... (~~ (template [<name> <ffi> <pipeline>] + ... [(def: (<name> _) + ... (do {! (try.with io.monad)} + ... [value (<ffi> [path])] + ... (if (bit\= false (:as Bit value)) + ... (\ io.monad in (exception.except ..cannot_find_file [path])) + ... (in (`` (|> value (~~ (template.spliced <pipeline>))))))))] + + ... [size ..filesize [.nat]] + ... [last_modified ..filemtime [(i.* +1,000) duration.of_millis instant.absolute]] + ... )) + + ... (def: (can_execute? _) + ... (..is_executable [path])) + + ... (def: (modify moment) + ... (do {! (try.with io.monad)} + ... [verdict (..touch [path (|> moment instant.relative duration.millis (i./ +1,000))])] + ... (if (bit\= false (:as Bit verdict)) + ... (\ io.monad in (exception.except ..cannot_find_file [path])) + ... (in [])))) + + ... (def: (move destination) + ... (do {! (try.with io.monad)} + ... [verdict (..rename [path destination])] + ... (if (bit\= false (:as Bit verdict)) + ... (\ io.monad in (exception.except ..cannot_find_file [path])) + ... (in (file destination))))) + + ... (def: (delete _) + ... (do (try.with io.monad) + ... [verdict (..unlink [path])] + ... (if (bit\= false (:as Bit verdict)) + ... (\ io.monad in (exception.except ..cannot_find_file [path])) + ... (in [])))) + ... )) + + ... (`` (implementation: (directory path) + ... (-> Path (Directory IO)) + + ... (def: scope + ... path) + + ... (~~ (template [<name> <test> <constructor> <capability>] + ... [(def: (<name> _) + ... (do {! (try.with io.monad)} + ... [children (..scandir [path])] + ... (loop [input (|> children + ... array.list + ... (list.only (function (_ child) + ... (not (or (text\= "." child) + ... (text\= ".." child)))))) + ... output (: (List (<capability> IO)) + ... (list))] + ... (case input + ... #.End + ... (in output) + + ... (#.Item head tail) + ... (do ! + ... [verdict (<test> head)] + ... (if verdict + ... (recur tail (#.Item (<constructor> head) output)) + ... (recur tail output)))))))] + + ... [files ..is_file ..file File] + ... [directories ..is_dir directory Directory] + ... )) + + ... (def: (discard _) + ... (do (try.with io.monad) + ... [verdict (..rmdir [path])] + ... (if (bit\= false (:as Bit verdict)) + ... (\ io.monad in (exception.except ..cannot_find_directory [path])) + ... (in [])))) + ... )) + + ... (`` (implementation: .public default + ... (System IO) + + ... (~~ (template [<name> <test> <constructor> <exception>] + ... [(def: (<name> path) + ... (do {! (try.with io.monad)} + ... [verdict (<test> path)] + ... (\ io.monad in + ... (if verdict + ... (#try.Success (<constructor> path)) + ... (exception.except <exception> [path])))))] + + ... [file ..is_file ..file ..cannot_find_file] + ... [directory ..is_dir ..directory ..cannot_find_directory] + ... )) + + ... (def: (make_file path) + ... (do {! (try.with io.monad)} + ... [verdict (..touch [path (|> instant.now io.run instant.relative duration.millis (i./ +1,000))])] + ... (\ io.monad in + ... (if verdict + ... (#try.Success (..file path)) + ... (exception.except ..cannot_make_file [path]))))) - ## (def: (make_directory path) - ## (do {! (try.with io.monad)} - ## [verdict (..mkdir path)] - ## (\ io.monad in - ## (if verdict - ## (#try.Success (..directory path)) - ## (exception.except ..cannot_make_directory [path]))))) - - ## (def: separator - ## ..default_separator) - ## )) - ## ) + ... (def: (make_directory path) + ... (do {! (try.with io.monad)} + ... [verdict (..mkdir path)] + ... (\ io.monad in + ... (if verdict + ... (#try.Success (..directory path)) + ... (exception.except ..cannot_make_directory [path]))))) + + ... (def: separator + ... ..default_separator) + ... )) + ... ) } (as_is))) diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index 1958e1403..f9229b17c 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -318,7 +318,7 @@ kind) ..deletion - ## else + ... else ..none ))) diff --git a/stdlib/source/library/lux/world/net/http/cookie.lux b/stdlib/source/library/lux/world/net/http/cookie.lux index 1e4623761..07437df10 100644 --- a/stdlib/source/library/lux/world/net/http/cookie.lux +++ b/stdlib/source/library/lux/world/net/http/cookie.lux @@ -34,7 +34,7 @@ (def: .public (max_age duration) (-> Duration Directive) - (let [seconds (duration.query duration.second duration)] + (let [seconds (duration.ticks duration.second duration)] (..directive (format "Max-Age=" (if (i.< +0 seconds) (%.int seconds) (%.nat (.nat seconds))))))) diff --git a/stdlib/source/library/lux/world/net/http/mime.lux b/stdlib/source/library/lux/world/net/http/mime.lux index 1592b3d25..f52b63136 100644 --- a/stdlib/source/library/lux/world/net/http/mime.lux +++ b/stdlib/source/library/lux/world/net/http/mime.lux @@ -22,7 +22,7 @@ (|>> :representation)) ) -## https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types +... https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types (template [<name> <type>] [(def: .public <name> MIME (..mime <type>))] diff --git a/stdlib/source/library/lux/world/net/http/query.lux b/stdlib/source/library/lux/world/net/http/query.lux index d0be7dfc3..1beb1a06f 100644 --- a/stdlib/source/library/lux/world/net/http/query.lux +++ b/stdlib/source/library/lux/world/net/http/query.lux @@ -57,7 +57,7 @@ (l.one_of "&;") l.end)] (form (dictionary.put key "" context))))) - ## if invalid form data, just stop parsing... + ... if invalid form data, just stop parsing... (\ p.monad in context))) (def: .public (parameters raw) diff --git a/stdlib/source/library/lux/world/net/http/status.lux b/stdlib/source/library/lux/world/net/http/status.lux index 0d7d45fd5..e7810c7fa 100644 --- a/stdlib/source/library/lux/world/net/http/status.lux +++ b/stdlib/source/library/lux/world/net/http/status.lux @@ -3,19 +3,19 @@ [lux #*]] [// (#+ Status)]) -## https://en.wikipedia.org/wiki/List_of_HTTP_status_codes +... https://en.wikipedia.org/wiki/List_of_HTTP_status_codes (template [<status> <name>] [(def: .public <name> Status <status>)] - ## 1xx Informational response + ... 1xx Informational response [100 continue] [101 switching_protocols] [102 processing] [103 early_hints] - ## 2xx Success + ... 2xx Success [200 ok] [201 created] [202 accepted] @@ -27,7 +27,7 @@ [208 already_reported] [226 im_used] - ## 3xx Redirection + ... 3xx Redirection [300 multiple_choices] [301 moved_permanently] [302 found] @@ -38,7 +38,7 @@ [307 temporary_redirect] [308 permanent_redirect] - ## 4xx Client errors + ... 4xx Client errors [400 bad_request] [401 unauthorized] [402 payment_required] @@ -68,7 +68,7 @@ [431 request_header_fields_too_large] [451 unavailable_for_legal_reasons] - ## 5xx Server errors + ... 5xx Server errors [500 internal_server_error] [501 not_implemented] [502 bad_gateway] diff --git a/stdlib/source/library/lux/world/output/video/resolution.lux b/stdlib/source/library/lux/world/output/video/resolution.lux index b48cc44bb..4ad3813d3 100644 --- a/stdlib/source/library/lux/world/output/video/resolution.lux +++ b/stdlib/source/library/lux/world/output/video/resolution.lux @@ -22,7 +22,7 @@ (Equivalence Resolution) (\ ..hash &equivalence)) -## https://en.wikipedia.org/wiki/Display_resolution#Common_display_resolutions +... https://en.wikipedia.org/wiki/Display_resolution#Common_display_resolutions (template [<name> <width> <height>] [(def: .public <name> Resolution diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index c846f1b7d..3216c6b93 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -108,8 +108,8 @@ (def: (exit code) (io.io (error! (%.int code))))))) -## Do not trust the values of environment variables -## https://wiki.sei.cmu.edu/confluence/display/java/ENV02-J.+Do+not+trust+the+values+of+environment+variables +... Do not trust the values of environment variables +... https://wiki.sei.cmu.edu/confluence/display/java/ENV02-J.+Do+not+trust+the+values+of+environment+variables (with_expansions [<jvm> (as_is (import: java/lang/String) @@ -276,28 +276,28 @@ ["#::." (#static exit [Int] #io Nothing)])) - ## @.php - ## (as_is (ffi.import: (exit [Int] #io Nothing)) - ## ## https://www.php.net/manual/en/function.exit.php - ## (ffi.import: (getcwd [] #io ffi.String)) - ## ## https://www.php.net/manual/en/function.getcwd.php - ## (ffi.import: (getenv #as getenv/1 [ffi.String] #io ffi.String)) - ## (ffi.import: (getenv #as getenv/0 [] #io (Array ffi.String))) - ## ## https://www.php.net/manual/en/function.getenv.php - ## ## https://www.php.net/manual/en/function.array-keys.php - ## (ffi.import: (array_keys [(Array ffi.String)] (Array ffi.String))) - ## ) - - ## @.scheme - ## (as_is (ffi.import: (exit [Int] #io Nothing)) - ## ## https://srfi.schemers.org/srfi-98/srfi-98.html - ## (abstract: Pair Any) - ## (abstract: PList Any) - ## (ffi.import: (get-environment-variables [] #io PList)) - ## (ffi.import: (car [Pair] Text)) - ## (ffi.import: (cdr [Pair] Text)) - ## (ffi.import: (car #as head [PList] Pair)) - ## (ffi.import: (cdr #as tail [PList] PList))) + ... @.php + ... (as_is (ffi.import: (exit [Int] #io Nothing)) + ... ... https://www.php.net/manual/en/function.exit.php + ... (ffi.import: (getcwd [] #io ffi.String)) + ... ... https://www.php.net/manual/en/function.getcwd.php + ... (ffi.import: (getenv #as getenv/1 [ffi.String] #io ffi.String)) + ... (ffi.import: (getenv #as getenv/0 [] #io (Array ffi.String))) + ... ... https://www.php.net/manual/en/function.getenv.php + ... ... https://www.php.net/manual/en/function.array-keys.php + ... (ffi.import: (array_keys [(Array ffi.String)] (Array ffi.String))) + ... ) + + ... @.scheme + ... (as_is (ffi.import: (exit [Int] #io Nothing)) + ... ... https://srfi.schemers.org/srfi-98/srfi-98.html + ... (abstract: Pair Any) + ... (abstract: PList Any) + ... (ffi.import: (get-environment-variables [] #io PList)) + ... (ffi.import: (car [Pair] Text)) + ... (ffi.import: (cdr [Pair] Text)) + ... (ffi.import: (car #as head [PList] Pair)) + ... (ffi.import: (cdr #as tail [PList] PList))) } (as_is))) @@ -322,28 +322,28 @@ (list)) (list))) @.python (\ io.monad map array.list (os/environ::keys [])) - ## Lua offers no way to get all the environment variables available. + ... Lua offers no way to get all the environment variables available. @.lua (io.io (list)) @.ruby (|> (RubyEnv::keys []) array.list io.io) - ## @.php (do io.monad - ## [environment (..getenv/0 [])] - ## (in (|> environment - ## ..array_keys - ## array.list - ## (list\map (function (_ variable) - ## [variable ("php array read" (:as Nat variable) environment)])) - ## (dictionary.of_list text.hash)))) - ## @.scheme (do io.monad - ## [input (..get-environment-variables [])] - ## (loop [input input - ## output environment.empty] - ## (if ("scheme object nil?" input) - ## (in output) - ## (let [entry (..head input)] - ## (recur (..tail input) - ## (dictionary.put (..car entry) (..cdr entry) output)))))) + ... @.php (do io.monad + ... [environment (..getenv/0 [])] + ... (in (|> environment + ... ..array_keys + ... array.list + ... (list\map (function (_ variable) + ... [variable ("php array read" (:as Nat variable) environment)])) + ... (dictionary.of_list text.hash)))) + ... @.scheme (do io.monad + ... [input (..get-environment-variables [])] + ... (loop [input input + ... output environment.empty] + ... (if ("scheme object nil?" input) + ... (in output) + ... (let [entry (..head input)] + ... (recur (..tail input) + ... (dictionary.put (..car entry) (..cdr entry) output)))))) }))) (def: (variable name) @@ -389,13 +389,13 @@ @.python (os/path::expanduser ["~"]) @.lua (..run_command "~" "echo ~") @.ruby (io.io (RubyDir::home)) - ## @.php (do io.monad - ## [output (..getenv/1 ["HOME"])] - ## (in (if (bit\= false (:as Bit output)) - ## "~" - ## output))) + ... @.php (do io.monad + ... [output (..getenv/1 ["HOME"])] + ... (in (if (bit\= false (:as Bit output)) + ... "~" + ... output))) } - ## TODO: Replace dummy implementation. + ... TODO: Replace dummy implementation. <default>)))) (def: directory @@ -420,13 +420,13 @@ (..run_command default "pwd") (in on_windows))) @.ruby (io.io (RubyFileUtils::pwd)) - ## @.php (do io.monad - ## [output (..getcwd [])] - ## (in (if (bit\= false (:as Bit output)) - ## "." - ## output))) + ... @.php (do io.monad + ... [output (..getcwd [])] + ... (in (if (bit\= false (:as Bit output)) + ... "." + ... output))) } - ## TODO: Replace dummy implementation. + ... TODO: Replace dummy implementation. (io.io <default>))))) (def: (exit code) @@ -441,11 +441,11 @@ ffi.on_browser? (..exit_browser! code) - ## else + ... else (..default_exit! code)) @.python (os::_exit [code]) @.lua (os/exit [code]) @.ruby (RubyKernel::exit [code]) - ## @.php (..exit [code]) - ## @.scheme (..exit [code]) + ... @.php (..exit [code]) + ... @.scheme (..exit [code]) })))) diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index b8fae1871..a09be98bb 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -91,7 +91,7 @@ [process (\ shell execute input)] (in (..async_process process))))))) -## https://en.wikipedia.org/wiki/Code_injection#Shell_injection +... https://en.wikipedia.org/wiki/Code_injection#Shell_injection (interface: (Policy ?) (: (-> Command (Safe Command ?)) command) @@ -106,32 +106,32 @@ (type: Replacer (-> Text Text)) -(def: (replace bad replacer) +(def: (replaced bad replacer) (-> Text Replacer (-> Text Text)) - (text.replace_all bad (replacer bad))) + (text.replaced bad (replacer bad))) (def: safe_common_command (-> Replacer (Sanitizer Command)) (let [x0A (text.of_char (hex "0A")) xFF (text.of_char (hex "FF"))] (function (_ replacer) - (|>> (..replace x0A replacer) - (..replace xFF replacer) - (..replace "\" replacer) - (..replace "&" replacer) - (..replace "#" replacer) - (..replace ";" replacer) - (..replace "`" replacer) - (..replace "|" replacer) - (..replace "*" replacer) - (..replace "?" replacer) - (..replace "~" replacer) - (..replace "^" replacer) - (..replace "$" replacer) - (..replace "<" replacer) (..replace ">" replacer) - (..replace "(" replacer) (..replace ")" replacer) - (..replace "[" replacer) (..replace "]" replacer) - (..replace "{" replacer) (..replace "}" replacer))))) + (|>> (..replaced x0A replacer) + (..replaced xFF replacer) + (..replaced "\" replacer) + (..replaced "&" replacer) + (..replaced "#" replacer) + (..replaced ";" replacer) + (..replaced "`" replacer) + (..replaced "|" replacer) + (..replaced "*" replacer) + (..replaced "?" replacer) + (..replaced "~" replacer) + (..replaced "^" replacer) + (..replaced "$" replacer) + (..replaced "<" replacer) (..replaced ">" replacer) + (..replaced "(" replacer) (..replaced ")" replacer) + (..replaced "[" replacer) (..replaced "]" replacer) + (..replaced "{" replacer) (..replaced "}" replacer))))) (def: (policy safe_command safe_argument) (Ex [?] (-> (Sanitizer Command) (Sanitizer Argument) (Policy ?))) @@ -149,7 +149,7 @@ safe_command (: (Sanitizer Command) (..safe_common_command replacer)) safe_argument (: (Sanitizer Argument) - (|>> (..replace "'" replacer) + (|>> (..replaced "'" replacer) (text.enclosed' "'")))] (..policy safe_command safe_argument))) @@ -158,12 +158,12 @@ (function.constant " ")) safe_command (: (Sanitizer Command) (|>> (..safe_common_command replacer) - (..replace "%" replacer) - (..replace "!" replacer))) + (..replaced "%" replacer) + (..replaced "!" replacer))) safe_argument (: (Sanitizer Argument) - (|>> (..replace "%" replacer) - (..replace "!" replacer) - (..replace text.double_quote replacer) + (|>> (..replaced "%" replacer) + (..replaced "!" replacer) + (..replaced text.double_quote replacer) (text.enclosed' text.double_quote)))] (..policy safe_command safe_argument))) @@ -279,7 +279,7 @@ ["#::." (#static getProperty [java/lang/String] #io #try java/lang/String)]) - ## https://en.wikipedia.org/wiki/Code_injection#Shell_injection + ... https://en.wikipedia.org/wiki/Code_injection#Shell_injection (def: windows? (IO (Try Bit)) (\ (try.with io.monad) map @@ -324,11 +324,11 @@ (~~ (template [<name> <mock>] [(def: (<name> _) (do {! io.monad} - [|state| (atom.read state)] + [|state| (atom.read! state)] (case (\ mock <mock> |state|) (#try.Success [|state| output]) (do ! - [_ (atom.write |state| state)] + [_ (atom.write! |state| state)] (in (#try.Success output))) (#try.Failure error) @@ -340,22 +340,22 @@ )) (def: (write message) (do {! io.monad} - [|state| (atom.read state)] + [|state| (atom.read! state)] (case (\ mock on_write message |state|) (#try.Success |state|) (do ! - [_ (atom.write |state| state)] + [_ (atom.write! |state| state)] (in (#try.Success []))) (#try.Failure error) (in (#try.Failure error))))) (def: (destroy _) (do {! io.monad} - [|state| (atom.read state)] + [|state| (atom.read! state)] (case (\ mock on_destroy |state|) (#try.Success |state|) (do ! - [_ (atom.write |state| state)] + [_ (atom.write! |state| state)] (in (#try.Success []))) (#try.Failure error) diff --git a/stdlib/source/poly/lux/abstract/equivalence.lux b/stdlib/source/poly/lux/abstract/equivalence.lux index 4c33de0f3..797caaf12 100644 --- a/stdlib/source/poly/lux/abstract/equivalence.lux +++ b/stdlib/source/poly/lux/abstract/equivalence.lux @@ -50,7 +50,7 @@ (function (_ type) (` ((~! /.Equivalence) (~ (poly.code *env* type))))))]] ($_ <>.either - ## Basic types + ... Basic types (~~ (template [<matcher> <eq>] [(do ! [_ <matcher>] @@ -64,7 +64,7 @@ [(<type>.sub Rev) (~! rev.equivalence)] [(<type>.sub Frac) (~! frac.equivalence)] [(<type>.sub Text) (~! text.equivalence)])) - ## Composite types + ... Composite types (~~ (template [<name> <eq>] [(do ! [[_ argC] (<type>.applied (<>.and (<type>.exactly <name>) @@ -87,7 +87,7 @@ equivalence))] (in (` (: (~ (@Equivalence inputT)) ((~! dictionary.equivalence) (~ valC)))))) - ## Models + ... Models (~~ (template [<type> <eq>] [(do ! [_ (<type>.exactly <type>)] @@ -105,7 +105,7 @@ <type>.any))] (in (` (: (~ (@Equivalence inputT)) unit.equivalence)))) - ## Variants + ... Variants (do ! [members (<type>.variant (<>.many equivalence)) .let [last (dec (list.size members)) @@ -126,7 +126,7 @@ (list.enumeration members)))) (~ g!_) #0)))))) - ## Tuples + ... Tuples (do ! [g!eqs (<type>.tuple (<>.many equivalence)) .let [g!_ (code.local_identifier "_____________") @@ -138,7 +138,7 @@ (and (~+ (|> (list.zipped/3 g!eqs g!lefts g!rights) (list\map (function (_ [g!eq g!left g!right]) (` ((~ g!eq) (~ g!left) (~ g!right))))))))))))) - ## Type recursion + ... Type recursion (do ! [[g!self bodyC] (<type>.recursive equivalence) .let [g!_ (code.local_identifier "_____________")]] @@ -146,13 +146,13 @@ ((~! /.rec) (.function ((~ g!_) (~ g!self)) (~ bodyC))))))) <type>.recursive_self - ## Type applications + ... Type applications (do ! [[funcC argsC] (<type>.applied (<>.and equivalence (<>.many equivalence)))] (in (` ((~ funcC) (~+ argsC))))) - ## Parameters + ... Parameters <type>.parameter - ## Polymorphism + ... Polymorphism (do ! [[funcC varsC bodyC] (<type>.polymorphic equivalence)] (in (` (: (All [(~+ varsC)] @@ -161,7 +161,7 @@ (function ((~ funcC) (~+ varsC)) (~ bodyC)))))) <type>.recursive_call - ## If all else fails... + ... If all else fails... (|> <type>.any (\ ! map (|>> %.type (format "Cannot create Equivalence for: ") <>.failure)) (\ ! join)) diff --git a/stdlib/source/poly/lux/abstract/functor.lux b/stdlib/source/poly/lux/abstract/functor.lux index bb9ef4a88..842c4b66c 100644 --- a/stdlib/source/poly/lux/abstract/functor.lux +++ b/stdlib/source/poly/lux/abstract/functor.lux @@ -44,12 +44,12 @@ Arg<?> (: (-> Code (<type>.Parser Code)) (function (Arg<?> valueC) ($_ p.either - ## Type-var + ... Type-var (do p.monad [.let [varI (|> num_vars (n.* 2) dec)] _ (<type>.parameter! varI)] (in (` ((~ funcC) (~ valueC))))) - ## Variants + ... Variants (do ! [_ (in []) membersC (<type>.variant (p.many (Arg<?> valueC))) @@ -62,7 +62,7 @@ (list (` ((~ (code.nat tag)) #0 (~ valueC))) (` ((~ (code.nat tag)) #0 (~ memberC)))))) (list.enumeration membersC)))))))) - ## Tuples + ... Tuples (do p.monad [pairsCC (: (<type>.Parser (List [Code Code])) (<type>.tuple (loop [idx 0 @@ -78,7 +78,7 @@ (in (` (case (~ valueC) [(~+ (list\map product.left pairsCC))] [(~+ (list\map product.right pairsCC))])))) - ## Functions + ... Functions (do ! [_ (in []) .let [g! (code.local_identifier "____________") @@ -91,11 +91,11 @@ (in (` (function ((~ g!) (~+ inC+)) (let [(~ outL) ((~ valueC) (~+ inC+))] (~ outC)))))) - ## Recursion + ... Recursion (do p.monad [_ <type>.recursive_call] (in (` ((~' map) (~ funcC) (~ valueC))))) - ## Parameters + ... Parameters (do p.monad [_ <type>.any] (in valueC)) diff --git a/stdlib/source/poly/lux/data/format/json.lux b/stdlib/source/poly/lux/data/format/json.lux index 847e3a160..5ee07e1d1 100644 --- a/stdlib/source/poly/lux/data/format/json.lux +++ b/stdlib/source/poly/lux/data/format/json.lux @@ -29,8 +29,8 @@ ["." int] ["." frac]]] [time - ## ["." instant] - ## ["." duration] + ... ["." instant] + ... ["." duration] ["." date] ["." day] ["." month]] @@ -116,8 +116,8 @@ (in (` (: (~ (@JSON\encode inputT)) (|>> (\ (~! <codec>) (~' encode)) #/.String)))))] - ## [duration.Duration duration.codec] - ## [instant.Instant instant.codec] + ... [duration.Duration duration.codec] + ... [instant.Instant instant.codec] [date.Date date.codec] [day.Day day.codec] [month.Month month.codec])] @@ -191,7 +191,7 @@ ((~! /.json) [(~+ (list\map (function (_ [g!member g!encode]) (` ((~ g!encode) (~ g!member)))) (list.zipped/2 g!members g!encoders)))])))))) - ## Type recursion + ... Type recursion (do ! [[selfC non_recC] (<type>.recursive encode) .let [g! (code.local_identifier "____________")]] @@ -199,11 +199,11 @@ ((~! ..rec_encode) (.function ((~ g!) (~ selfC)) (~ non_recC))))))) <type>.recursive_self - ## Type applications + ... Type applications (do ! [partsC (<type>.applied (<>.many encode))] (in (` ((~+ partsC))))) - ## Polymorphism + ... Polymorphism (do ! [[funcC varsC bodyC] (<type>.polymorphic encode)] (in (` (: (All [(~+ varsC)] @@ -215,7 +215,7 @@ (~ bodyC)))))) <type>.parameter <type>.recursive_call - ## If all else fails... + ... If all else fails... (<>.failure (format "Cannot create JSON encoder for: " (type.format inputT))) )))) @@ -239,8 +239,8 @@ (in (` (: (~ (@JSON\decode inputT)) ((~! <>.codec) (~! <codec>) (~! </>.string))))))] - ## [duration.Duration duration.codec] - ## [instant.Instant instant.codec] + ... [duration.Duration duration.codec] + ... [instant.Instant instant.codec] [date.Date date.codec] [day.Day day.codec] [month.Month month.codec])] @@ -295,7 +295,7 @@ [g!decoders (<type>.tuple (<>.many decode))] (in (` (: (~ (@JSON\decode inputT)) ((~! </>.array) ($_ ((~! <>.and)) (~+ g!decoders))))))) - ## Type recursion + ... Type recursion (do ! [[selfC bodyC] (<type>.recursive decode) .let [g! (code.local_identifier "____________")]] @@ -303,11 +303,11 @@ ((~! <>.rec) (.function ((~ g!) (~ selfC)) (~ bodyC))))))) <type>.recursive_self - ## Type applications + ... Type applications (do ! [[funcC argsC] (<type>.applied (<>.and decode (<>.many decode)))] (in (` ((~ funcC) (~+ argsC))))) - ## Polymorphism + ... Polymorphism (do ! [[funcC varsC bodyC] (<type>.polymorphic decode)] (in (` (: (All [(~+ varsC)] @@ -317,7 +317,7 @@ (~ bodyC)))))) <type>.parameter <type>.recursive_call - ## If all else fails... + ... If all else fails... (<>.failure (format "Cannot create JSON decoder for: " (type.format inputT))) )))) diff --git a/stdlib/source/program/aedifex/artifact.lux b/stdlib/source/program/aedifex/artifact.lux index ec955d4dd..a6980813e 100644 --- a/stdlib/source/program/aedifex/artifact.lux +++ b/stdlib/source/program/aedifex/artifact.lux @@ -95,7 +95,7 @@ (let [/ uri.separator group (..directory / (get@ #group artifact)) name (get@ #name artifact) - ## version (get@ #version artifact) + ... version (get@ #version artifact) identity (..identity artifact)] (%.format group / name / version / identity))) diff --git a/stdlib/source/program/aedifex/artifact/extension.lux b/stdlib/source/program/aedifex/artifact/extension.lux index 11a94bb7e..130dda74e 100644 --- a/stdlib/source/program/aedifex/artifact/extension.lux +++ b/stdlib/source/program/aedifex/artifact/extension.lux @@ -21,7 +21,7 @@ (def: .public type (-> Extension //.Type) - (text.replace_all ..separator "")) + (text.replaced ..separator "")) (template [<name>] [(def: .public <name> diff --git a/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux b/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux index 55ece62c7..63681a3fe 100644 --- a/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux +++ b/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux @@ -36,8 +36,8 @@ (#///.Remote stamp) (let [(^slots [#///stamp.time #///stamp.build]) stamp] - (%.format (text.replace_all ..snapshot - (///time.format time) - version) + (%.format (text.replaced ..snapshot + (///time.format time) + version) ..separator (%.nat build))))) diff --git a/stdlib/source/program/aedifex/artifact/type.lux b/stdlib/source/program/aedifex/artifact/type.lux index dde76fc0c..ae6f9b79b 100644 --- a/stdlib/source/program/aedifex/artifact/type.lux +++ b/stdlib/source/program/aedifex/artifact/type.lux @@ -2,7 +2,7 @@ [library [lux (#- Type)]]) -## https://maven.apache.org/ref/3.6.3/maven-core/artifact-handlers.html +... https://maven.apache.org/ref/3.6.3/maven-core/artifact-handlers.html (type: .public Type Text) diff --git a/stdlib/source/program/aedifex/cli.lux b/stdlib/source/program/aedifex/cli.lux index 8e97e02d3..7f9fe61ff 100644 --- a/stdlib/source/program/aedifex/cli.lux +++ b/stdlib/source/program/aedifex/cli.lux @@ -48,24 +48,24 @@ (def: .public equivalence (Equivalence Command) ($_ sum.equivalence - ## #Version + ... #Version ..any_equivalence - ## #Clean + ... #Clean ..any_equivalence - ## #POM + ... #POM ..any_equivalence - ## #Dependencies + ... #Dependencies ..any_equivalence - ## #Install + ... #Install ..any_equivalence - ## #Deploy + ... #Deploy ($_ product.equivalence text.equivalence text.equivalence text.equivalence) - ## #Compilation + ... #Compilation ..compilation_equivalence - ## #Auto + ... #Auto ..compilation_equivalence)) (def: command' diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux index 2c4c8ac19..579f68462 100644 --- a/stdlib/source/program/aedifex/command/auto.lux +++ b/stdlib/source/program/aedifex/command/auto.lux @@ -41,7 +41,7 @@ (def: (pause delay) (-> Nat (Async (Try Any))) - (async.delay delay (#try.Success []))) + (async.delayed delay (#try.Success []))) (def: .public (do! delay watcher command) (All [a] diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index ff7825678..00380e59b 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -115,7 +115,7 @@ artifact (get@ #///dependency.artifact dependency)] (|> artifact (///local.uri (get@ #///artifact.version artifact)) - (text.replace_all uri.separator /) + (text.replaced uri.separator /) (format home /) (text.suffix (format "." (get@ #///dependency.type dependency)))))) @@ -193,29 +193,29 @@ (template [<name> <capability>] [(def: .public (<name> console process) (-> (Console Async) (Process Async) (Async (Try Any))) - ## This is a very odd way of implementing this function. - ## But it's written this way because the more straightforward way (i.e. by using (try.with async.monad)) - ## eventually led to the function hanging/freezing. - ## I'm not sure why it happened, but I got this weirder implementation to work. + ... This is a very odd way of implementing this function. + ... But it's written this way because the more straightforward way (i.e. by using (try.with async.monad)) + ... eventually led to the function hanging/freezing. + ... I'm not sure why it happened, but I got this weirder implementation to work. (let [[read! write!] (: [(Async (Try Any)) (async.Resolver (Try Any))] (async.async [])) _ (|> (\ process <capability> []) - (async.await (function (recur ?line) + (async.upon! (function (recur ?line) (case ?line (#try.Failure error) (if (exception.match? shell.no_more_output error) (write! (#try.Success [])) - (async.await write! (console.write_line error console))) + (async.upon! write! (console.write_line error console))) (#try.Success line) - (async.await (function (_ outcome) + (async.upon! (function (_ outcome) (case outcome (#try.Failure error) (write! (#try.Failure error)) (#try.Success _) - (async.await recur + (async.upon! recur (\ process <capability> [])))) (console.write_line line console))))) io.run)] diff --git a/stdlib/source/program/aedifex/dependency/deployment.lux b/stdlib/source/program/aedifex/dependency/deployment.lux index 6ff052a5a..d23e4a805 100644 --- a/stdlib/source/program/aedifex/dependency/deployment.lux +++ b/stdlib/source/program/aedifex/dependency/deployment.lux @@ -110,9 +110,9 @@ {#///artifact/snapshot/version/value.version version_template #///artifact/snapshot/version/value.snapshot versioning_snapshot}) #///artifact/snapshot/version.updated now})) - ## (set@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] - ## (list\compose (..artifacts type (product.right (get@ #///package.library package))) - ## (..artifacts ///artifact/type.pom (product.right (get@ #///package.pom package))))) + ... (set@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] + ... (list\compose (..artifacts type (product.right (get@ #///package.library package))) + ... (..artifacts ///artifact/type.pom (product.right (get@ #///package.pom package))))) )))) (def: .public (one repository [artifact type] package) diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux index c34d88494..ed4303ac5 100644 --- a/stdlib/source/program/aedifex/dependency/resolution.lux +++ b/stdlib/source/program/aedifex/dependency/resolution.lux @@ -214,7 +214,7 @@ (#.Item head tail) (case (get@ [#//.artifact #///artifact.version] head) - ## Skip if there is no version + ... Skip if there is no version "" (recur repositories successes failures @@ -234,13 +234,13 @@ ///package.dependencies (try\map set.list) (try.else (list))) - ## For security reasons, it's not a good idea to allow dependencies to introduce repositories. - ## package_repositories (|> package - ## ///package.repositories - ## (try\map set.list) - ## (try.else (list)) - ## (list\map new_repository)) - ## sub_repositories (list\compose repositories package_repositories) + ... For security reasons, it's not a good idea to allow dependencies to introduce repositories. + ... package_repositories (|> package + ... ///package.repositories + ... (try\map set.list) + ... (try.else (list)) + ... (list\map new_repository)) + ... sub_repositories (list\compose repositories package_repositories) sub_repositories repositories] [successes failures resolution] (recur sub_repositories (#.Item head successes) diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index 95247c471..2e46286ea 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -21,9 +21,9 @@ [type abstract]]]) -## TODO: Replace with pure-Lux implementations of these algorithms -## https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode -## https://en.wikipedia.org/wiki/MD5#Algorithm +... TODO: Replace with pure-Lux implementations of these algorithms +... https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode +... https://en.wikipedia.org/wiki/MD5#Algorithm (import: java/lang/String) (import: java/security/MessageDigest @@ -127,7 +127,7 @@ (#.Some [head tail]) (do try.monad [head (\ n.hex decode head) - output (binary.write/64 index head output)] + output (binary.write/64! index head output)] (recur tail (inc chunk) output)) #.None @@ -139,9 +139,9 @@ [head (\ n.hex decode input) output (<write> index head output)] (constructor output))]) - ([1 binary.write/8] - [2 binary.write/16] - [4 binary.write/32]) + ([1 binary.write/8!] + [2 binary.write/16!] + [4 binary.write/32!]) _ (exception.except ..not_a_hash [(..encoding_size size) encoded]))))) (exception.except ..not_a_hash [(..encoding_size size) encoded])))) diff --git a/stdlib/source/program/aedifex/metadata.lux b/stdlib/source/program/aedifex/metadata.lux index 7b883e4f8..5badc4783 100644 --- a/stdlib/source/program/aedifex/metadata.lux +++ b/stdlib/source/program/aedifex/metadata.lux @@ -36,8 +36,8 @@ (def: .public (local_uri remote_uri) (-> URI URI) - (text.replace_once ..remote_file ..local_file remote_uri)) + (text.replaced/1 ..remote_file ..local_file remote_uri)) (def: .public (remote_uri local_uri) (-> URI URI) - (text.replace_once ..local_file ..remote_file local_uri)) + (text.replaced/1 ..local_file ..remote_file local_uri)) diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux index 13900d276..e2ad11079 100644 --- a/stdlib/source/program/aedifex/pom.lux +++ b/stdlib/source/program/aedifex/pom.lux @@ -29,7 +29,7 @@ ["#." artifact (#+ Artifact) ["#/." type]]]) -## https://maven.apache.org/pom.html +... https://maven.apache.org/pom.html (def: project_tag "project") (def: dependency_tag "dependency") @@ -178,8 +178,8 @@ #//artifact.version (|> properties (dictionary.get ["" ..version_tag]) (maybe.else "") - (text.replace_all "${project.version}" own_version) - (text.replace_all "${project.parent.version}" parent_version))} + (text.replaced "${project.version}" own_version) + (text.replaced "${project.parent.version}" parent_version))} #//dependency.type (|> properties (dictionary.get ["" "type"]) (maybe.else //artifact/type.jvm_library))}))))) diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux index 93eeec473..ffd549c06 100644 --- a/stdlib/source/program/aedifex/profile.lux +++ b/stdlib/source/program/aedifex/profile.lux @@ -174,37 +174,37 @@ (def: .public equivalence (Equivalence Profile) ($_ product.equivalence - ## #parents + ... #parents (list.equivalence text.equivalence) - ## #identity + ... #identity (maybe.equivalence artifact.equivalence) - ## #info + ... #info (maybe.equivalence ..info_equivalence) - ## #repositories + ... #repositories set.equivalence - ## #dependencies + ... #dependencies set.equivalence - ## #compiler + ... #compiler dependency.equivalence - ## #sources + ... #sources set.equivalence - ## #target + ... #target text.equivalence - ## #program + ... #program (maybe.equivalence text.equivalence) - ## #test + ... #test (maybe.equivalence text.equivalence) - ## #deploy_repositories + ... #deploy_repositories (dictionary.equivalence text.equivalence) - ## #java + ... #java runtime.equivalence - ## #js + ... #js runtime.equivalence - ## #python + ... #python runtime.equivalence - ## #lua + ... #lua runtime.equivalence - ## #ruby + ... #ruby runtime.equivalence)) (implementation: .public monoid diff --git a/stdlib/source/program/aedifex/repository/local.lux b/stdlib/source/program/aedifex/repository/local.lux index f59a04b85..907610233 100644 --- a/stdlib/source/program/aedifex/repository/local.lux +++ b/stdlib/source/program/aedifex/repository/local.lux @@ -23,12 +23,12 @@ (def: (root program /) (-> (Program Async) Text file.Path) (|> ///local.repository - (text.replace_all uri.separator /) + (text.replaced uri.separator /) (format (\ program home) /))) (def: (path /) (-> Text (-> URI file.Path)) - (text.replace_all uri.separator /)) + (text.replaced uri.separator /)) (def: (absolute_path program /) (-> (Program Async) Text (-> URI file.Path)) diff --git a/stdlib/source/program/aedifex/runtime.lux b/stdlib/source/program/aedifex/runtime.lux index 842708e44..b239d03ea 100644 --- a/stdlib/source/program/aedifex/runtime.lux +++ b/stdlib/source/program/aedifex/runtime.lux @@ -34,7 +34,7 @@ [default_js "node" ["--stack_size=8192"]] [default_python "python3" []] [default_lua "lua" []] - ## [default_ruby "RUBY_THREAD_VM_STACK_SIZE=15700000 ruby" []] + ... [default_ruby "RUBY_THREAD_VM_STACK_SIZE=15700000 ruby" []] [default_ruby "ruby" []] ) diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index 88ceec96c..f19575859 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -24,7 +24,7 @@ ["." world #_ ["." file] ["#/." program] - ## ["." console] + ... ["." console] ] [tool [compiler @@ -49,7 +49,7 @@ ["." dependency]] [io ["ioW" archive]]]] - ## ["." interpreter] + ... ["." interpreter] ]]] ["." / #_ ["#." cli (#+ Service)] @@ -172,12 +172,12 @@ (in (debug.log! "Export complete!")))) (#/cli.Interpretation interpretation) - ## TODO: Fix the interpreter... + ... TODO: Fix the interpreter... (undefined) - ## (<| (or_crash! "Interpretation failed:") - ## (do {! async.monad} - ## [console (|> console.default - ## async.future - ## (\ ! map (|>> try.assumed console.async)))] - ## (interpreter.run (try.with async.monad) console platform interpretation generation_bundle))) + ... (<| (or_crash! "Interpretation failed:") + ... (do {! async.monad} + ... [console (|> console.default + ... async.future + ... (\ ! map (|>> try.assumed console.async)))] + ... (interpreter.run (try.with async.monad) console platform interpretation generation_bundle))) )))) diff --git a/stdlib/source/program/compositor/export.lux b/stdlib/source/program/compositor/export.lux index ade242f57..b229b36ba 100644 --- a/stdlib/source/program/compositor/export.lux +++ b/stdlib/source/program/compositor/export.lux @@ -48,7 +48,7 @@ (function (_ [path source_code]) (do try.monad [path (|> path - (text.replace_all (\ fs separator) .module_separator) + (text.replaced (\ fs separator) .module_separator) tar.path) source_code (tar.content source_code)] (in (#tar.Normal [path diff --git a/stdlib/source/program/scriptum.lux b/stdlib/source/program/scriptum.lux index c9b27a305..b18ce7bff 100644 --- a/stdlib/source/program/scriptum.lux +++ b/stdlib/source/program/scriptum.lux @@ -32,8 +32,8 @@ ["." annotation]] [world ["." file]]]] - ## This was added to make sure that all tested modules are picked up - ## and their documentation is generated. + ... This was added to make sure that all tested modules are picked up + ... and their documentation is generated. [test/lux (#+)]) (def: name_options "abcdefghijklmnopqrstuvwxyz") @@ -300,7 +300,7 @@ (|>> (#.Item [name def_annotations def_type]))) organization) - ## else + ... else (update@ #values (: (Mutation (List Value)) (|>> (#.Item [name def_annotations def_type]))) @@ -491,7 +491,7 @@ (def: (save_documentation! [module_name documentation]) (-> [Text (Markdown Block)] (IO Any)) - (let [path (format (text.replace_all "/" "_" module_name) ".md")] + (let [path (format (text.replaced "/" "_" module_name) ".md")] (do io.monad [outcome (\ file.default write (\ utf8.codec encode (md.markdown documentation)) path)] (in (case outcome diff --git a/stdlib/source/specification/compositor/generation/case.lux b/stdlib/source/specification/compositor/generation/case.lux index c3dbd1835..81042846f 100644 --- a/stdlib/source/specification/compositor/generation/case.lux +++ b/stdlib/source/specification/compositor/generation/case.lux @@ -70,9 +70,9 @@ [subS subP] case .let [unitS (synthesis.text synthesis.unit) caseS (synthesis.tuple - (list.concat (list (list.repeat idx unitS) + (list.concat (list (list.repeated idx unitS) (list subS) - (list.repeat (|> size dec (n.- idx)) unitS)))) + (list.repeated (|> size dec (n.- idx)) unitS)))) caseP ($_ synthesis.path/seq (if (tail? size idx) (synthesis.member/right idx) @@ -204,27 +204,27 @@ _tail_ _item_ _head_ (synthesis.path/bind 5) synthesis.path/pop _tail_ _end_ - ## THEN + ... THEN (synthesis.path/then (synthesis.bit #1))) ($_ synthesis.path/seq (synthesis.path/bind 2) - ## THEN + ... THEN (synthesis.path/then (synthesis.bit #0)))))) (def: special_pattern analysis.Pattern - (let [## [_ (#Tuple (#Item arg args'))] + (let [... [_ (#Tuple (#Item arg args'))] head (<| analysis.pattern/tuple (list (analysis.pattern/bind 2)) analysis.pattern/variant [9 #0] analysis.pattern/variant [0 #1] analysis.pattern/tuple (list (analysis.pattern/bind 3) (analysis.pattern/bind 4))) - ## (#Item body #End) + ... (#Item body #End) tail (<| analysis.pattern/variant [0 #1] analysis.pattern/tuple (list (analysis.pattern/bind 5)) analysis.pattern/variant [0 #0] (analysis.pattern/unit))] - ## (#Item <head> <tail>) + ... (#Item <head> <tail>) (<| analysis.pattern/variant [0 #1] (analysis.pattern/tuple (list head tail))))) @@ -239,10 +239,10 @@ (analysis.bit #1)) ($_ synthesis.path/seq (synthesis.path/bind 2) - ## THEN + ... THEN (synthesis.path/then (synthesis.bit #0))))) -## TODO: Get rid of this ASAP +... TODO: Get rid of this ASAP (def: (special_spec run) (-> Runner Test) ($_ _.and diff --git a/stdlib/source/specification/compositor/generation/common.lux b/stdlib/source/specification/compositor/generation/common.lux index 1e3d6bb9e..93dd3bba5 100644 --- a/stdlib/source/specification/compositor/generation/common.lux +++ b/stdlib/source/specification/compositor/generation/common.lux @@ -30,7 +30,7 @@ (def: safe (-> Text Text) - (text.replace_all " " "_")) + (text.replaced " " "_")) (def: (bit run) (-> Runner Test) @@ -187,8 +187,8 @@ concatenatedS (#synthesis.Extension "lux text concat" (list sample_lowerS sample_upperS)) pre_rep_once (format sample_lower sample_upper) post_rep_once (format sample_lower sample_alpha) - pre_rep_all (|> (list.repeat sample_size sample_lower) (text.join_with sample_upper)) - post_rep_all (|> (list.repeat sample_size sample_lower) (text.join_with sample_alpha))]] + pre_rep_all (|> sample_lower (list.repeated sample_size) (text.join_with sample_upper)) + post_rep_all (|> sample_lower (list.repeated sample_size) (text.join_with sample_alpha))]] ($_ _.and (_.test "Can compare texts for equality." (and (|> (#synthesis.Extension "lux text =" (list sample_lowerS sample_lowerS)) diff --git a/stdlib/source/specification/lux/abstract/order.lux b/stdlib/source/specification/lux/abstract/order.lux index e8a022686..94bf6712a 100644 --- a/stdlib/source/specification/lux/abstract/order.lux +++ b/stdlib/source/specification/lux/abstract/order.lux @@ -24,7 +24,7 @@ (@//< subject parameter) (not (@//= parameter subject)) - ## else + ... else (@//= parameter subject)))) (do random.monad [parameter generator @@ -45,7 +45,7 @@ (or greater? lesser? in_between?)) - ## (@//< subject parameter) + ... (@//< subject parameter) (let [greater? (and (@//< extra subject) (@//< extra parameter)) lesser? (and (@//< parameter extra) diff --git a/stdlib/source/test/aedifex/cli.lux b/stdlib/source/test/aedifex/cli.lux index f59cf6619..4b5e79ac5 100644 --- a/stdlib/source/test/aedifex/cli.lux +++ b/stdlib/source/test/aedifex/cli.lux @@ -28,24 +28,24 @@ (def: command (Random /.Command) ($_ random.or - ## #Version + ... #Version (random\in []) - ## #Clean + ... #Clean (random\in []) - ## #POM + ... #POM (random\in []) - ## #Dependencies + ... #Dependencies (random\in []) - ## #Install + ... #Install (random\in []) - ## #Deploy + ... #Deploy ($_ random.and (random.ascii/alpha 1) (random.ascii/alpha 1) (random.ascii/alpha 1)) - ## #Compilation + ... #Compilation ..compilation - ## #Auto + ... #Auto ..compilation)) (def: (compilation_format value) diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index 6a7ef98ab..074eeab5e 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -53,7 +53,7 @@ [@runs (function (_ console program fs shell resolution profile) (do {! async.monad} - [[_ actual_runs] (async.future (atom.update inc @runs))] + [[_ actual_runs] (async.future (atom.update! inc @runs))] (if (n.= expected_runs actual_runs) (in (#try.Failure end_signal)) (do (try.with !) @@ -116,7 +116,7 @@ (#try.Success _) false)))) correct_number_of_runs! (|> @runs - atom.read + atom.read! async.future (\ ! map (n.= expected_runs)))] (in (#try.Success (and correct_number_of_runs! diff --git a/stdlib/source/test/aedifex/command/install.lux b/stdlib/source/test/aedifex/command/install.lux index 0ca484196..a3cd99edd 100644 --- a/stdlib/source/test/aedifex/command/install.lux +++ b/stdlib/source/test/aedifex/command/install.lux @@ -84,11 +84,11 @@ library_exists! (|> library_path (format home /) (\ fs file?) - (\ async.monad map exception.return)) + (\ async.monad map (|>> #try.Success))) pom_exists! (|> pom_path (format home /) (\ fs file?) - (\ async.monad map exception.return))] + (\ async.monad map (|>> #try.Success)))] (in (and succeeded! library_exists! pom_exists!)))] diff --git a/stdlib/source/test/aedifex/dependency/deployment.lux b/stdlib/source/test/aedifex/dependency/deployment.lux index ec2ecad3d..0add3a487 100644 --- a/stdlib/source/test/aedifex/dependency/deployment.lux +++ b/stdlib/source/test/aedifex/dependency/deployment.lux @@ -69,7 +69,7 @@ [_ (: (IO Any) (case [method input] [#@http.Put (#.Some input)] - (atom.update (dictionary.put url input) cache) + (atom.update! (dictionary.put url input) cache) _ (in [])))] @@ -158,7 +158,7 @@ repository (repository.async (remote.repository http #.None address))]] (in (do async.monad [?outcome (/.one repository dependency package) - cache (async.future (atom.read cache))] + cache (async.future (atom.read! cache))] (_.cover' [/.one] (|> ?outcome (try\map (verify_one 1 address package cache expected_artifact)) @@ -181,7 +181,7 @@ repository (repository.async (remote.repository http #.None address))]] (in (do async.monad [?outcome (/.all repository resolution) - cache (async.future (atom.read cache))] + cache (async.future (atom.read! cache))] (_.cover' [/.all] (|> ?outcome (try\map (function (_ actual_artifacts) diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index 01b57eb62..4bef34eff 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -132,7 +132,7 @@ (text.ends_with? ..pom_md5 uri) (#try.Success [state (..md5 pom)]) - ## else + ... else (#try.Failure "NOPE"))) (#try.Failure "NOPE"))) (def: (on_upload uri binary state) @@ -185,7 +185,7 @@ (\ utf8.codec encode) ..md5)]) - ## else + ... else (#try.Failure "NOPE")) (#try.Failure "NOPE"))) (def: (on_upload uri binary state) @@ -238,7 +238,7 @@ (\ utf8.codec encode) ..md5)]) - ## else + ... else (#try.Failure "NOPE")) (#try.Failure "NOPE"))) (def: (on_upload uri binary state) diff --git a/stdlib/source/test/aedifex/repository.lux b/stdlib/source/test/aedifex/repository.lux index eead05e89..478f02d7e 100644 --- a/stdlib/source/test/aedifex/repository.lux +++ b/stdlib/source/test/aedifex/repository.lux @@ -75,14 +75,14 @@ (#.Some content) (case (binary.size content) 0 (exception.except ..not_found [uri]) - _ (exception.return [state content])) + _ (#try.Success [state content])) #.None (exception.except ..not_found [uri]))) (def: (on_upload uri content state) (if (dictionary.key? state uri) (exception.except ..cannot_upload [uri]) - (exception.return (dictionary.put uri content state))))) + (#try.Success (dictionary.put uri content state))))) (def: .public test Test diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 925894d7b..a659b6523 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -8,7 +8,6 @@ [program (#+ program:)] ["_" test (#+ Test)] ["@" target] - ["." meta] [abstract [monad (#+ do)]] [control @@ -34,22 +33,25 @@ ["i" int] ["r" rev] ["f" frac] - ["." i64]]]]] - ## TODO: Must have 100% coverage on tests. + ["." i64]]] + ["." meta + ["." location ("#\." equivalence)]]]] + ... TODO: Must have 100% coverage on tests. ["." / #_ ["#." abstract] ["#." control] ["#." data] ["#." debug] ["#." locale] - ["#." macro] + ["#." macro + ["#/." code]] ["#." math] ["#." meta] ["#." program] ["#." target] ["#." test] ["#." time] - ## ["#." tool] ## TODO: Update & expand tests for this + ... ["#." tool] ... TODO: Update & expand tests for this ["#." type] ["#." world] ["#." ffi] @@ -57,7 +59,7 @@ ["#." target #_ <target>]])) -## TODO: Get rid of this ASAP +... TODO: Get rid of this ASAP (template: (!bundle body) [(: Test (do random.monad @@ -66,7 +68,7 @@ (def: sub_tests Test - (with_expansions [## TODO: Update & expand tests for this + (with_expansions [... TODO: Update & expand tests for this <target> (for {@.jvm (~~ (as_is /target/jvm.test)) @.old (~~ (as_is /target/jvm.test))} (~~ (as_is))) @@ -86,7 +88,7 @@ /test.test /time.test - ## /tool.test + ... /tool.test /type.test /world.test /ffi.test @@ -129,13 +131,13 @@ (/.cond /.true expected - ## else + ... else dummy)) (n.= expected (/.cond /.false dummy - ## else + ... else expected)) (n.= expected (/.cond /.true @@ -144,7 +146,7 @@ /.false dummy - ## else + ... else dummy)) (n.= expected (/.cond /.false @@ -153,7 +155,7 @@ /.true expected - ## else + ... else dummy)))) )))) @@ -399,13 +401,20 @@ (def: for_code Test (do random.monad - [example_nat random.nat] - (_.for [/.Code /.Code'] - ($_ _.and - ..for_code/' - ..for_code/` - ..for_code/`' - )))) + [example_nat random.nat + example /macro/code.random] + ($_ _.and + (_.for [/.Code /.Code'] + ($_ _.and + ..for_code/' + ..for_code/` + ..for_code/`' + )) + (_.cover [/.Ann] + (|> example + (get@ #/.meta) + (location\= location.dummy))) + ))) (/.macro: (identity_macro tokens) (\ meta.monad in tokens)) @@ -998,10 +1007,10 @@ post (random.only (|>> (n.= pre) not) random.nat) .let [box (atom.atom pre)]] (_.cover [/.exec] - (and (is? pre (io.run (atom.read box))) + (and (is? pre (io.run (atom.read! box))) (/.exec - (io.run (atom.write post box)) - (is? post (io.run (atom.read box))))))) + (io.run (atom.write! post box)) + (is? post (io.run (atom.read! box))))))) )) (def: identity/constant diff --git a/stdlib/source/test/lux/abstract/comonad/cofree.lux b/stdlib/source/test/lux/abstract/comonad/cofree.lux index 531510a04..541977fc5 100644 --- a/stdlib/source/test/lux/abstract/comonad/cofree.lux +++ b/stdlib/source/test/lux/abstract/comonad/cofree.lux @@ -21,7 +21,7 @@ (def: (injection value) (Injection (/.CoFree Sequence)) - [value (sequence\map injection (sequence.repeat value))]) + [value (sequence\map injection (sequence.repeated value))]) (def: (interpret [head tail]) (All [a] (-> (/.CoFree Sequence a) (Sequence a))) diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux index 618271a6e..b97f6498f 100644 --- a/stdlib/source/test/lux/control/concurrency/actor.lux +++ b/stdlib/source/test/lux/control/concurrency/actor.lux @@ -103,7 +103,7 @@ (in outcome))))}) [])] (/.poison! actor))) - _ (async.wait 100) + _ (async.delay 100) result (async.future (async.poll read))] (_.cover' [/.poisoned] (case result @@ -143,9 +143,9 @@ [actor (/.spawn! /.default initial_state) sent? (/.mail! die! actor) alive? (/.alive? actor) - obituary (/.obituary actor)] + obituary (/.obituary' actor)] (in (#try.Success [actor sent? alive? obituary]))))] - (_.cover' [/.Obituary /.obituary] + (_.cover' [/.Obituary /.obituary'] (case result (^ (#try.Success [actor sent? alive? (#.Some [error state (list single_pending_message)])])) (and (..mailed? sent?) @@ -184,7 +184,7 @@ sent/inc? (/.mail! inc! anonymous) sent/dec? (/.mail! dec! anonymous) poisoned? (/.poison! anonymous) - obituary (/.obituary anonymous)] + obituary (/.obituary' anonymous)] (in (and (..mailed? sent/inc?) (..mailed? sent/dec?) (..mailed? poisoned?) @@ -210,21 +210,21 @@ [agent (async.future (do {! io.monad} [agent (/.actor {Nat 0}) - _ (/.observe (function (_ event stop) - (function (_ events_seen self) - (async.future - (if (n.< num_observations events_seen) - (do ! - [_ (atom.update (row.add event) sink)] - (in (#try.Success (inc events_seen)))) - (do ! - [_ stop] - (in (#try.Failure "YOLO"))))))) - (frp.sequential 0 events) - agent)] + _ (/.observe! (function (_ event stop) + (function (_ events_seen self) + (async.future + (if (n.< num_observations events_seen) + (do ! + [_ (atom.update! (row.add event) sink)] + (in (#try.Success (inc events_seen)))) + (do ! + [_ stop] + (in (#try.Failure "YOLO"))))))) + (frp.sequential 0 events) + agent)] (in agent))) - _ (/.await agent) - actual (async.future (atom.read sink))] - (_.cover' [/.Stop /.observe /.await] + _ (/.obituary agent) + actual (async.future (atom.read! sink))] + (_.cover' [/.Stop /.observe! /.obituary] (\ (list.equivalence n.equivalence) = expected (row.list actual)))))) )))) diff --git a/stdlib/source/test/lux/control/concurrency/async.lux b/stdlib/source/test/lux/control/concurrency/async.lux index b16aa0bf2..f4353bc4f 100644 --- a/stdlib/source/test/lux/control/concurrency/async.lux +++ b/stdlib/source/test/lux/control/concurrency/async.lux @@ -86,17 +86,17 @@ (n.= expected actual)))) (in (do /.monad [pre (/.future instant.now) - actual (/.schedule waiting_time (io.io expected)) + actual (/.schedule! waiting_time (io.io expected)) post (/.future instant.now)] - (_.cover' [/.schedule] + (_.cover' [/.schedule!] (and (n.= expected actual) (i.>= (.int waiting_time) (duration.millis (instant.span pre post))))))) (in (do /.monad [pre (/.future instant.now) - _ (/.wait waiting_time) + _ (/.delay waiting_time) post (/.future instant.now)] - (_.cover' [/.wait] + (_.cover' [/.delay] (i.>= (.int waiting_time) (duration.millis (instant.span pre post)))))) (in (do /.monad @@ -107,16 +107,16 @@ (n.+ leftA rightA))))) (in (do /.monad [pre (/.future instant.now) - actual (/.delay waiting_time expected) + actual (/.delayed waiting_time expected) post (/.future instant.now)] - (_.cover' [/.delay] + (_.cover' [/.delayed] (and (n.= expected actual) (i.>= (.int waiting_time) (duration.millis (instant.span pre post))))))) (in (do /.monad [?left (/.or (in leftE) - (/.delay waiting_time dummy)) - ?right (/.or (/.delay waiting_time dummy) + (/.delayed waiting_time dummy)) + ?right (/.or (/.delayed waiting_time dummy) (in rightE))] (_.cover' [/.or] (case [?left ?right] @@ -128,8 +128,8 @@ false)))) (in (do /.monad [leftA (/.either (in leftE) - (/.delay waiting_time dummy)) - rightA (/.either (/.delay waiting_time dummy) + (/.delayed waiting_time dummy)) + rightA (/.either (/.delayed waiting_time dummy) (in rightE))] (_.cover' [/.either] (n.= (n.+ leftE rightE) @@ -155,7 +155,7 @@ (and yep (not nope))))) (in (do /.monad - [?none (/.time_out 0 (/.delay waiting_time dummy)) + [?none (/.time_out 0 (/.delayed waiting_time dummy)) ?actual (/.time_out waiting_time (in expected))] (_.cover' [/.time_out] (case [?none ?actual] @@ -167,10 +167,10 @@ (in (do /.monad [.let [box (: (Atom Nat) (atom.atom dummy))] - _ (/.future (/.await (function (_ value) - (atom.write value box)) + _ (/.future (/.upon! (function (_ value) + (atom.write! value box)) (/.resolved expected))) - actual (/.future (atom.read box))] - (_.cover' [/.await] + actual (/.future (atom.read! box))] + (_.cover' [/.upon!] (n.= expected actual)))) )))) diff --git a/stdlib/source/test/lux/control/concurrency/atom.lux b/stdlib/source/test/lux/control/concurrency/atom.lux index aec2d56d9..e3c5a9b89 100644 --- a/stdlib/source/test/lux/control/concurrency/atom.lux +++ b/stdlib/source/test/lux/control/concurrency/atom.lux @@ -20,22 +20,22 @@ (do random.monad [expected random.nat .let [box (/.atom expected)]] - (_.cover [/.Atom /.atom /.read] + (_.cover [/.Atom /.atom /.read!] (io.run (do io.monad - [actual (/.read box)] + [actual (/.read! box)] (in (is? expected actual)))))) (do random.monad [target random.nat unknown (random.only (|>> (is? target) not) random.nat) expected random.nat .let [box (/.atom target)]] - (_.cover [/.compare_and_swap] + (_.cover [/.compare_and_swap!] (io.run (do io.monad - [swapped_unknown? (/.compare_and_swap unknown expected box) - swapped_target? (/.compare_and_swap target expected box) - actual (/.read box)] + [swapped_unknown? (/.compare_and_swap! unknown expected box) + swapped_target? (/.compare_and_swap! target expected box) + actual (/.read! box)] (in (and (not swapped_unknown?) swapped_target? (is? expected actual))))))) @@ -43,10 +43,10 @@ [init random.nat shift random.nat .let [box (/.atom init)]] - (_.cover [/.update] + (_.cover [/.update!] (io.run (do io.monad - [[pre post] (/.update (n.+ shift) box)] + [[pre post] (/.update! (n.+ shift) box)] (in (and (is? init pre) (n.= (n.+ shift init) post))))))) @@ -54,11 +54,11 @@ [pre random.nat post random.nat .let [box (/.atom pre)]] - (_.cover [/.write] + (_.cover [/.write!] (io.run (do io.monad - [old (/.write post box) - new (/.read box)] + [old (/.write! post box) + new (/.read! box)] (in (and (is? pre old) (is? post new))))))) ))) diff --git a/stdlib/source/test/lux/control/concurrency/frp.lux b/stdlib/source/test/lux/control/concurrency/frp.lux index ecb6d7c93..675eabfa3 100644 --- a/stdlib/source/test/lux/control/concurrency/frp.lux +++ b/stdlib/source/test/lux/control/concurrency/frp.lux @@ -144,8 +144,8 @@ (atom.atom row.empty))] _ (async.future (/.subscribe (function (_ value) (do {! io.monad} - [current (atom.read sink) - _ (atom.update (row.add value) sink)] + [current (atom.read! sink) + _ (atom.update! (row.add value) sink)] (if (n.< (list.size inputs) (inc (row.size current))) (in (#.Some [])) @@ -155,7 +155,7 @@ (/.sequential 0 (list\compose inputs inputs)))) _ ?signal listened (|> sink - atom.read + atom.read! async.future (\ ! map row.list))] (_.cover' [/.Subscriber /.subscribe] @@ -218,6 +218,6 @@ /.consume)] (_.cover' [/.iterations] (and (n.= max_iterations (list.size actual)) - (list\= (list.folds n.+ sample (list.repeat (dec max_iterations) shift)) + (list\= (list.folds n.+ sample (list.repeated (dec max_iterations) shift)) actual))))) ))))) diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index 33c5e1da1..58492c733 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -54,7 +54,7 @@ [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) .let [semaphore (/.semaphore initial_open_positions)]] (in (do {! async.monad} - [_ (monad.map ! /.wait (list.repeat initial_open_positions semaphore)) + [_ (monad.map ! /.wait (list.repeated initial_open_positions semaphore)) result (async.time_out ..delay (/.wait semaphore))] (_.cover' [/.wait] (case result @@ -67,7 +67,7 @@ [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) .let [semaphore (/.semaphore initial_open_positions)]] (in (do {! async.monad} - [_ (monad.map ! /.wait (list.repeat initial_open_positions semaphore)) + [_ (monad.map ! /.wait (list.repeated initial_open_positions semaphore)) .let [block (/.wait semaphore)] result/0 (async.time_out ..delay block) open_positions (/.signal semaphore) @@ -100,29 +100,29 @@ (do {! random.monad} [repetitions (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10)))) .let [resource (atom.atom "") - expected_As (text.join_with "" (list.repeat repetitions "A")) - expected_Bs (text.join_with "" (list.repeat repetitions "B")) + expected_As (text.join_with "" (list.repeated repetitions "A")) + expected_Bs (text.join_with "" (list.repeated repetitions "B")) mutex (/.mutex []) processA (<| (/.synchronize mutex) io.io async.future (do {! io.monad} [_ (<| (monad.seq !) - (list.repeat repetitions) - (atom.update (|>> (format "A")) resource))] + (list.repeated repetitions) + (atom.update! (|>> (format "A")) resource))] (in []))) processB (<| (/.synchronize mutex) io.io async.future (do {! io.monad} [_ (<| (monad.seq !) - (list.repeat repetitions) - (atom.update (|>> (format "B")) resource))] + (list.repeated repetitions) + (atom.update! (|>> (format "B")) resource))] (in [])))]] (in (do async.monad [_ processA _ processB - .let [outcome (io.run (atom.read resource))]] + .let [outcome (io.run (atom.read! resource))]] (_.cover' [/.mutex /.synchronize] (or (text\= (format expected_As expected_Bs) outcome) @@ -134,7 +134,7 @@ (-> (Atom Text) /.Barrier Nat (Async Any)) (do async.monad [_ (/.block barrier) - _ (async.future (atom.update (|>> (format (%.nat id))) resource))] + _ (async.future (atom.update! (|>> (format (%.nat id))) resource))] (in []))) (def: barrier @@ -161,15 +161,15 @@ (in (do {! async.monad} [.let [suffix "_" expected_ending (|> suffix - (list.repeat limit) + (list.repeated limit) (text.join_with "")) expected_ids (enum.range n.enum 0 (dec limit))] _ (|> expected_ids (list\map (function (_ id) - (exec (io.run (atom.update (|>> (format suffix)) resource)) + (exec (io.run (atom.update! (|>> (format suffix)) resource)) (waiter resource barrier id)))) (monad.seq !)) - .let [outcome (io.run (atom.read resource))]] + .let [outcome (io.run (atom.read! resource))]] (_.cover' [/.barrier /.block] (and (text.ends_with? expected_ending outcome) (list.every? (function (_ id) diff --git a/stdlib/source/test/lux/control/concurrency/stm.lux b/stdlib/source/test/lux/control/concurrency/stm.lux index 79880064e..7c9b3137d 100644 --- a/stdlib/source/test/lux/control/concurrency/stm.lux +++ b/stdlib/source/test/lux/control/concurrency/stm.lux @@ -93,7 +93,7 @@ changes)))) (in (let [var (/.var 0)] (do {! async.monad} - [_ (|> (list.repeat iterations_per_process []) + [_ (|> (list.repeated iterations_per_process []) (list\map (function (_ _) (/.commit (/.update inc var)))) (monad.seq !)) cummulative (/.commit (/.read var))] diff --git a/stdlib/source/test/lux/control/concurrency/thread.lux b/stdlib/source/test/lux/control/concurrency/thread.lux index 182a05908..bee49206d 100644 --- a/stdlib/source/test/lux/control/concurrency/thread.lux +++ b/stdlib/source/test/lux/control/concurrency/thread.lux @@ -35,12 +35,12 @@ [reference_time (async.future instant.now) .let [box (atom.atom [reference_time dummy])] _ (async.future - (/.schedule delay (do io.monad - [execution_time instant.now] - (atom.write [execution_time expected] box)))) - _ (async.wait (n.* 2 delay)) - [execution_time actual] (async.future (atom.read box))] - (_.cover' [/.schedule] + (/.schedule! delay (do io.monad + [execution_time instant.now] + (atom.write! [execution_time expected] box)))) + _ (async.delay (n.* 2 delay)) + [execution_time actual] (async.future (atom.read! box))] + (_.cover' [/.schedule!] (let [expected_delay! (i.>= (.int delay) (duration.millis (instant.span reference_time execution_time))) diff --git a/stdlib/source/test/lux/control/continuation.lux b/stdlib/source/test/lux/control/continuation.lux index 6635d84b6..a0dcec237 100644 --- a/stdlib/source/test/lux/control/continuation.lux +++ b/stdlib/source/test/lux/control/continuation.lux @@ -53,9 +53,9 @@ (function (_ k) (do ! [temp (k sample)] - ## If this code where to run, - ## the output would be - ## (n.* 4 sample) + ... If this code where to run, + ... the output would be + ... (n.* 4 sample) (k temp))))] (in (n.* 2 value)))))) (_.cover [/.portal] diff --git a/stdlib/source/test/lux/control/exception.lux b/stdlib/source/test/lux/control/exception.lux index 13bde092b..74e73f45b 100644 --- a/stdlib/source/test/lux/control/exception.lux +++ b/stdlib/source/test/lux/control/exception.lux @@ -37,10 +37,6 @@ (<| (_.covering /._) (_.for [/.Exception]) ($_ _.and - (_.cover [/.return] - (case (/.return expected) - (#try.Success actual) (n.= expected actual) - (#try.Failure _) false)) (_.cover [/.except] (case (/.except ..an_exception []) (#try.Success _) false @@ -63,20 +59,20 @@ (#try.Failure message) (and (not assertion_succeeded?) (text\= message (/.error ..an_exception []))))) - (_.cover [/.catch] + (_.cover [/.when] (and (n.= expected (|> (/.except ..an_exception []) - (/.catch ..an_exception (function (_ ex) expected)) + (/.when ..an_exception (function (_ ex) expected)) (/.otherwise (function (_ ex) wrong)))) (n.= expected (|> (/.except ..another_exception []) - (/.catch ..an_exception (function (_ ex) wrong)) - (/.catch ..another_exception (function (_ ex) expected)) + (/.when ..an_exception (function (_ ex) wrong)) + (/.when ..another_exception (function (_ ex) expected)) (/.otherwise (function (_ ex) wrong)))))) (_.cover [/.otherwise] (n.= expected (|> (/.except ..another_exception []) - (/.catch ..an_exception (function (_ ex) wrong)) + (/.when ..an_exception (function (_ ex) wrong)) (/.otherwise (function (_ ex) expected))))) (_.cover [/.report] (let [report (/.report [field0 value0] diff --git a/stdlib/source/test/lux/control/function/memo.lux b/stdlib/source/test/lux/control/function/memo.lux index 11e1b876c..b5bea4224 100644 --- a/stdlib/source/test/lux/control/function/memo.lux +++ b/stdlib/source/test/lux/control/function/memo.lux @@ -46,10 +46,10 @@ (def: milli_seconds (-> Duration Nat) - (|>> (duration.query duration.milli_second) .nat)) + (|>> (duration.ticks duration.milli_second) .nat)) -## the wiggle room is there to account for GC pauses -## and other issues that might mess with duration +... the wiggle room is there to account for GC pauses +... and other issues that might mess with duration (def: wiggle_room Nat (i64.left_shifted 4 1)) diff --git a/stdlib/source/test/lux/control/parser/binary.lux b/stdlib/source/test/lux/control/parser/binary.lux index bbba888a7..e86718715 100644 --- a/stdlib/source/test/lux/control/parser/binary.lux +++ b/stdlib/source/test/lux/control/parser/binary.lux @@ -270,7 +270,7 @@ [/.set (/.set n.hash /.nat) format.set (format.set format.nat) (random.set n.hash ..segment_size random.nat) set.equivalence] [/.name /.name format.name format.name ..random_name name.equivalence])) (do {! random.monad} - [expected (\ ! map (list.repeat ..segment_size) random.nat)] + [expected (\ ! map (list.repeated ..segment_size) random.nat)] (_.cover [/.set_elements_are_not_unique] (|> expected (format.run (format.list format.nat)) diff --git a/stdlib/source/test/lux/control/parser/xml.lux b/stdlib/source/test/lux/control/parser/xml.lux index 6269cafd5..81c4da80d 100644 --- a/stdlib/source/test/lux/control/parser/xml.lux +++ b/stdlib/source/test/lux/control/parser/xml.lux @@ -163,14 +163,14 @@ (_.cover [/.somewhere] (|> (/.run parser (list (node parent - (list.concat (list (list.repeat repetitions (node wrong (list))) + (list.concat (list (list.repeated repetitions (node wrong (list))) (list (node right (list))) - (list.repeat repetitions (node wrong (list)))))))) + (list.repeated repetitions (node wrong (list)))))))) (!expect (#try.Success [])))) (_.cover [/.nowhere] (|> (/.run parser (list (node parent - (list.repeat repetitions (node wrong (list)))))) + (list.repeated repetitions (node wrong (list)))))) (!expect (^multi (#try.Failure error) (exception.match? /.nowhere error))))) )) diff --git a/stdlib/source/test/lux/data.lux b/stdlib/source/test/lux/data.lux index d350cabf9..beb1ee201 100644 --- a/stdlib/source/test/lux/data.lux +++ b/stdlib/source/test/lux/data.lux @@ -25,7 +25,7 @@ ["#/." xml]] ["#." collection]]) -## TODO: Get rid of this ASAP +... TODO: Get rid of this ASAP (template: (!bundle body) [(: Test (do random.monad @@ -66,7 +66,7 @@ (def: .public test Test - ## TODO: Inline ASAP + ... TODO: Inline ASAP ($_ _.and (!bundle test/0) (!bundle test/1) diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index 3326d0055..b7ae6bba4 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -38,7 +38,7 @@ (if (n.< size idx) (do random.monad [byte random.nat] - (exec (try.assumed (/.write/8 idx byte output)) + (exec (try.assumed (/.write/8! idx byte output)) (recur (inc idx)))) (\ random.monad in output))))) @@ -104,14 +104,14 @@ (|> (/.create size) /.size (n.= size))) (_.for [/.index_out_of_bounds] ($_ _.and - (_.cover [/.read/8 /.write/8] - (..binary_io 0 /.read/8 /.write/8 value)) - (_.cover [/.read/16 /.write/16] - (..binary_io 1 /.read/16 /.write/16 value)) - (_.cover [/.read/32 /.write/32] - (..binary_io 2 /.read/32 /.write/32 value)) - (_.cover [/.read/64 /.write/64] - (..binary_io 3 /.read/64 /.write/64 value)))) + (_.cover [/.read/8! /.write/8!] + (..binary_io 0 /.read/8! /.write/8! value)) + (_.cover [/.read/16! /.write/16!] + (..binary_io 1 /.read/16! /.write/16! value)) + (_.cover [/.read/32! /.write/32!] + (..binary_io 2 /.read/32! /.write/32! value)) + (_.cover [/.read/64! /.write/64!] + (..binary_io 3 /.read/64! /.write/64! value)))) (_.cover [/.slice] (let [random_slice (try.assumed (/.slice offset length sample)) idxs (: (List Nat) @@ -119,7 +119,7 @@ 0 (list) _ (enum.range n.enum 0 (dec length)))) reader (function (_ binary idx) - (/.read/8 idx binary))] + (/.read/8! idx binary))] (and (n.= length (/.size random_slice)) (case [(monad.map try.monad (|>> (n.+ offset) (reader sample)) idxs) (monad.map try.monad (reader random_slice) idxs)] @@ -154,10 +154,10 @@ false) (succeed (do try.monad - [sample/0 (/.read/8 0 sample) + [sample/0 (/.read/8! 0 sample) copy (/.copy 1 0 sample 0 (/.create 2)) - copy/0 (/.read/8 0 copy) - copy/1 (/.read/8 1 copy)] + copy/0 (/.read/8! 0 copy) + copy/1 (/.read/8! 1 copy)] (in (and (n.= sample/0 copy/0) (n.= 0 copy/1))))))) ))))) diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index ee6b9e7cb..abf61aef3 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -96,8 +96,8 @@ (\ bit.equivalence = (/.empty? sample) (n.= 0 (/.size sample)))) - (_.cover [/.repeat] - (n.= size (/.size (/.repeat size [])))) + (_.cover [/.repeated] + (n.= size (/.size (/.repeated size [])))) (_.cover [/.reversed] (or (n.< 2 (/.size sample)) (let [not_same! diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/sequence.lux index c94b19ac6..7485d857c 100644 --- a/stdlib/source/test/lux/data/collection/sequence.lux +++ b/stdlib/source/test/lux/data/collection/sequence.lux @@ -43,16 +43,16 @@ cycle_next (random.list size random.nat)] ($_ _.and (_.for [/.functor] - ($functor.spec /.repeat ..equivalence /.functor)) + ($functor.spec /.repeated ..equivalence /.functor)) (_.for [/.comonad] - ($comonad.spec /.repeat ..equivalence /.comonad)) + ($comonad.spec /.repeated ..equivalence /.comonad)) (_.cover [/.iterations /.item] (n.= (n.+ offset index) (/.item index (/.iterations inc offset)))) - (_.cover [/.repeat] + (_.cover [/.repeated] (n.= repeated - (/.item index (/.repeat repeated)))) + (/.item index (/.repeated repeated)))) (_.cover [/.take] (list\= (enum.range n.enum offset (dec (n.+ size offset))) (/.take size (/.iterations inc offset)))) @@ -103,7 +103,7 @@ offset))))) (_.cover [/.cycle] (let [cycle (list& cycle_start cycle_next)] - (list\= (list.concat (list.repeat size cycle)) + (list\= (list.concat (list.repeated size cycle)) (/.take (n.* size (list.size cycle)) (/.cycle [cycle_start cycle_next]))))) (_.cover [/.^sequence&] diff --git a/stdlib/source/test/lux/data/color/named.lux b/stdlib/source/test/lux/data/color/named.lux index 7f8c959b9..6d0130db6 100644 --- a/stdlib/source/test/lux/data/color/named.lux +++ b/stdlib/source/test/lux/data/color/named.lux @@ -21,7 +21,7 @@ (with_expansions [<colors> (as_is [letter/a [/.alice_blue /.antique_white - ## /.aqua + ... /.aqua /.aquamarine /.azure]] @@ -72,7 +72,7 @@ [/.fire_brick /.floral_white /.forest_green - ## /.fuchsia + ... /.fuchsia ]] [letter/g diff --git a/stdlib/source/test/lux/data/format/tar.lux b/stdlib/source/test/lux/data/format/tar.lux index 4ccec923b..c951382ba 100644 --- a/stdlib/source/test/lux/data/format/tar.lux +++ b/stdlib/source/test/lux/data/format/tar.lux @@ -163,7 +163,7 @@ chunk (random.ascii/lower chunk_size) chunks (\ ! map (n.% 100) random.nat) .let [content (|> chunk - (list.repeat chunks) + (list.repeated chunks) (text.join_with "") (\ utf8.codec encode))]] (`` ($_ _.and @@ -206,7 +206,7 @@ (in (case (row.list tar) (^ (list (<tag> [actual_path actual_moment actual_mode actual_ownership actual_content]))) (let [seconds (: (-> Instant Int) - (|>> instant.relative (duration.query duration.second)))] + (|>> instant.relative (duration.ticks duration.second)))] (and (text\= (/.from_path expected_path) (/.from_path actual_path)) (i.= (seconds expected_moment) diff --git a/stdlib/source/test/lux/data/name.lux b/stdlib/source/test/lux/data/name.lux index 01d5131c8..2cde215a0 100644 --- a/stdlib/source/test/lux/data/name.lux +++ b/stdlib/source/test/lux/data/name.lux @@ -29,11 +29,11 @@ Test (<| (_.covering /._) (do {! random.monad} - [## First Name + [... First Name sizeM1 (|> random.nat (\ ! map (n.% 100))) sizeS1 (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1)))) (^@ name1 [module1 short1]) (..random sizeM1 sizeS1) - ## Second Name + ... Second Name sizeM2 (|> random.nat (\ ! map (n.% 100))) sizeS2 (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1)))) (^@ name2 [module2 short2]) (..random sizeM2 sizeS2)] diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index ca7f2f69f..4ff904116 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -204,10 +204,10 @@ (\ /.equivalence = (/.concat (set.list characters)) (/.join_with "" (set.list characters))))) - (_.cover [/.replace_once] + (_.cover [/.replaced/1] (\ /.equivalence = (\ /.monoid compose post static) - (/.replace_once pre post (\ /.monoid compose pre static)))) + (/.replaced/1 pre post (\ /.monoid compose pre static)))) (_.cover [/.split_with] (case (/.split_with static ($_ (\ /.monoid compose) pre static post)) (#.Some [left right]) @@ -314,9 +314,9 @@ (do {! random.monad} [sizeP bounded_size sizeL bounded_size - .let [## The wider unicode charset includes control characters that - ## can make text replacement work improperly. - ## Because of that, I restrict the charset. + .let [... The wider unicode charset includes control characters that + ... can make text replacement work improperly. + ... Because of that, I restrict the charset. normal_char_gen (|> random.nat (\ ! map (|>> (n.% 128) (n.max 1))))] sep1 (random.text normal_char_gen 1) sep2 (random.text normal_char_gen 1) @@ -326,9 +326,9 @@ .let [sample1 (/.concat (list.interpose sep1 parts)) sample2 (/.concat (list.interpose sep2 parts)) (^open "/\.") /.equivalence]] - (_.cover [/.replace_all] + (_.cover [/.replaced] (/\= sample2 - (/.replace_all sep1 sep2 sample1)))) + (/.replaced sep1 sep2 sample1)))) /buffer.test /encoding.test diff --git a/stdlib/source/test/lux/data/text/escape.lux b/stdlib/source/test/lux/data/text/escape.lux index 3b320fd90..35dfaf1cf 100644 --- a/stdlib/source/test/lux/data/text/escape.lux +++ b/stdlib/source/test/lux/data/text/escape.lux @@ -76,8 +76,8 @@ (random.ascii 10))]] (in (list (code.text expected))))) -(syntax: (static_escape {un_escaped <code>.text}) - (in (list (code.text (/.escape un_escaped))))) +(syntax: (static_escaped {un_escaped <code>.text}) + (in (list (code.text (/.escaped un_escaped))))) (def: .public test Test @@ -99,24 +99,24 @@ (do random.monad [left (random.char unicode.character) right (random.char unicode.character)] - (_.cover [/.escape /.un_escape] + (_.cover [/.escaped /.un_escaped] (let [expected (format (text.of_char left) (text.of_char right))] (if (or (/.escapable? left) (/.escapable? right)) - (let [escaped (/.escape expected)] - (case (/.un_escape escaped) + (let [escaped (/.escaped expected)] + (case (/.un_escaped escaped) (#try.Success un_escaped) (and (not (text\= escaped expected)) (text\= un_escaped expected)) (#try.Failure error) false)) - (text\= expected (/.escape expected)))))) + (text\= expected (/.escaped expected)))))) (do {! random.monad} [dummy (|> (random.char unicode.character) (\ ! map text.of_char))] (_.cover [/.dangling_escape] - (case (/.un_escape (format (/.escape dummy) "\")) + (case (/.un_escaped (format (/.escaped dummy) "\")) (#try.Success _) false @@ -127,7 +127,7 @@ (random.only (|>> (set.member? ..valid_sigils) not)) (\ ! map text.of_char))] (_.cover [/.invalid_escape] - (case (/.un_escape (format "\" dummy)) + (case (/.un_escaped (format "\" dummy)) (#try.Success _) false @@ -143,7 +143,7 @@ (#try.Success _) false))))] (_.cover [/.invalid_unicode_escape] (template.let [(!invalid <code>) - [(case (/.un_escape (format "\u" <code>)) + [(case (/.un_escaped (format "\u" <code>)) (#try.Success _) false @@ -151,7 +151,7 @@ (exception.match? /.invalid_unicode_escape error))]] (and (!invalid (\ n.hex encode too_short)) (!invalid code))))) - (_.cover [/.escaped] + (_.cover [/.literal] (with_expansions [<example> (..static_sample)] - (text\= <example> (`` (/.escaped (~~ (..static_escape <example>))))))) + (text\= <example> (`` (/.literal (~~ (..static_escaped <example>))))))) ))) diff --git a/stdlib/source/test/lux/data/text/unicode/block.lux b/stdlib/source/test/lux/data/text/unicode/block.lux index 4f92f8db9..6cdc5f091 100644 --- a/stdlib/source/test/lux/data/text/unicode/block.lux +++ b/stdlib/source/test/lux/data/text/unicode/block.lux @@ -141,7 +141,7 @@ /.halfwidth_and_fullwidth_forms /.specials - ## Specialized blocks + ... Specialized blocks /.basic_latin/decimal /.basic_latin/upper /.basic_latin/lower]] diff --git a/stdlib/source/test/lux/debug.lux b/stdlib/source/test/lux/debug.lux index 8d9a9ef4c..7d7f7cf64 100644 --- a/stdlib/source/test/lux/debug.lux +++ b/stdlib/source/test/lux/debug.lux @@ -85,20 +85,20 @@ (#try.Failure error) false) - ## TODO: Uncomment after switching from the old (tag+last?) to the new (lefts+right?) representation for variants - ## (~~ (template [<lefts> <right?> <value> <format>] - ## [(|> (/.representation (type (Or Bit Int Frac)) - ## (: (Or Bit Int Frac) - ## (<lefts> <right?> <value>))) - ## (try\map (text\= (format "(" (%.nat <lefts>) - ## " " (%.bit <right?>) - ## " " (<format> <value>) ")"))) - ## (try.else false))] + ... TODO: Uncomment after switching from the old (tag+last?) to the new (lefts+right?) representation for variants + ... (~~ (template [<lefts> <right?> <value> <format>] + ... [(|> (/.representation (type (Or Bit Int Frac)) + ... (: (Or Bit Int Frac) + ... (<lefts> <right?> <value>))) + ... (try\map (text\= (format "(" (%.nat <lefts>) + ... " " (%.bit <right?>) + ... " " (<format> <value>) ")"))) + ... (try.else false))] - ## [0 #0 sample_bit %.bit] - ## [1 #0 sample_int %.int] - ## [1 #1 sample_frac %.frac] - ## )) + ... [0 #0 sample_bit %.bit] + ... [1 #0 sample_int %.int] + ... [1 #1 sample_frac %.frac] + ... )) ))))) (def: can_represent_complex_types diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux index 117fd784a..e28e013cc 100644 --- a/stdlib/source/test/lux/extension.lux +++ b/stdlib/source/test/lux/extension.lux @@ -50,16 +50,16 @@ (def: dummy_generation "dummy generation") (def: my_directive "my directive") -## Generation +... Generation (for {@.old (as_is)} (as_is - ## Analysis + ... Analysis (analysis: (..my_analysis self phase archive {pass_through <code>.any}) (phase archive pass_through)) - ## Synthesis + ... Synthesis (analysis: (..my_synthesis self phase archive {parameters (<>.some <code>.any)}) (let [! phase.monad] (|> parameters @@ -69,7 +69,7 @@ (synthesis: (..my_synthesis self phase archive {pass_through <analysis>.any}) (phase archive pass_through)) - ## Generation + ... Generation (analysis: (..my_generation self phase archive {parameters (<>.some <code>.any)}) (let [! phase.monad] (|> parameters @@ -106,7 +106,7 @@ @.php (php.string self) @.scheme (scheme.string self)}))) - ## Directive + ... Directive (directive: (..my_directive self phase archive {parameters (<>.some <code>.any)}) (do phase.monad [.let [_ (debug.log! (format "Successfully installed directive " (%.text self) "!"))]] diff --git a/stdlib/source/test/lux/ffi.js.lux b/stdlib/source/test/lux/ffi.js.lux index 2ba2c8f7a..994430c85 100644 --- a/stdlib/source/test/lux/ffi.js.lux +++ b/stdlib/source/test/lux/ffi.js.lux @@ -19,19 +19,19 @@ (/.import: Uint8Array) -## On Nashorn +... On Nashorn (/.import: java/lang/String ["#::." (new [Uint8Array /.String]) (getBytes [/.String] Uint8Array)]) -## On Node +... On Node (/.import: Buffer ["#::." (#static from [/.String /.String] Buffer) (toString [/.String] /.String)]) -## On the browser +... On the browser (/.import: TextEncoder ["#::." (new [/.String]) @@ -52,7 +52,7 @@ (: (-> Nat Nat) (nat.+ shift))) random.nat) - ## I64s get compiled as JavaScript objects with a specific structure. + ... I64s get compiled as JavaScript objects with a specific structure. object random.nat] (<| (_.covering /._) (`` ($_ _.and @@ -132,7 +132,7 @@ (|> (Buffer::from [string encoding]) (Buffer::toString [encoding])) - ## On the browser + ... On the browser (let [binary (|> (TextEncoder::new [encoding]) (TextEncoder::encode [string]))] (|> (TextDecoder::new [encoding]) diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index b393d363b..6b03ebc15 100644 --- a/stdlib/source/test/lux/ffi.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -339,12 +339,12 @@ example/4!)))) (/.class: #final test/TestClass0 [test/TestInterface0] - ## Fields + ... Fields (#private value java/lang/Long) - ## Constructors + ... Constructors (#public [] (new self {value java/lang/Long}) [] (:= ::value value)) - ## Methods + ... Methods (test/TestInterface0 [] (actual0 self) java/lang/Long ::value)) @@ -353,12 +353,12 @@ (new [java/lang/Long])]) (/.class: #final test/TestClass1 [test/TestInterface1] - ## Fields + ... Fields (#private value java/lang/Long) - ## Constructors + ... Constructors (#public [] (new self {value java/lang/Long}) [] (:= ::value value)) - ## Methods + ... Methods (test/TestInterface1 [] (actual1 self {throw? java/lang/Boolean}) java/lang/Long #throws [java/lang/Throwable] (if (:as Bit throw?) (error! "YOLO") @@ -369,10 +369,10 @@ (new [java/lang/Long])]) (/.class: #final test/TestClass2 [test/TestInterface2] - ## Constructors + ... Constructors (#public [] (new self) [] []) - ## Methods + ... Methods (test/TestInterface2 [a] (actual2 self {input a}) a @@ -383,12 +383,12 @@ (new [])]) (/.class: #final (test/TestClass3 a) [(test/TestInterface3 a)] - ## Fields + ... Fields (#private value a) - ## Constructors + ... Constructors (#public [] (new self {value a}) [] (:= ::value value)) - ## Methods + ... Methods ((test/TestInterface3 a) [] (actual3 self) a @@ -399,10 +399,10 @@ (new [a])]) (/.class: #final test/TestClass4 [] - ## Constructors + ... Constructors (#public [] (new self) [] []) - ## Methods + ... Methods (#public (actual4 self {value java/lang/Long}) java/lang/Long value)) @@ -412,10 +412,10 @@ (actual4 [java/lang/Long] java/lang/Long)]) (/.class: #final test/TestClass5 [] - ## Constructors + ... Constructors (#public [] (new self) [] []) - ## Methods + ... Methods (#public #static (actual5 {value java/lang/Long}) java/lang/Long value)) @@ -425,10 +425,10 @@ (#static actual5 [java/lang/Long] java/lang/Long)]) (/.class: #abstract test/TestClass6 [] - ## Constructors + ... Constructors (#public [] (new self) [] []) - ## Methods + ... Methods (#public #abstract (actual6 {value java/lang/Long}) java/lang/Long)) @@ -437,10 +437,10 @@ (actual6 [java/lang/Long] java/lang/Long)]) (/.class: #final test/TestClass7 test/TestClass6 [] - ## Constructors + ... Constructors (#public [] (new self) [] []) - ## Methods + ... Methods (test/TestClass6 [] (actual6 self {input java/lang/Long}) java/lang/Long @@ -451,10 +451,10 @@ (new [])]) (/.class: #final test/TestClass8 [test/TestInterface4] - ## Constructors + ... Constructors (#public [] (new self) [] []) - ## Methods + ... Methods (test/TestInterface4 [] (actual4 self {actual_left long} {actual_right long} {_ long}) long @@ -467,12 +467,12 @@ (new [])]) (/.class: #final (test/TestClass9 a) [] - ## Fields + ... Fields (#private value9 a) - ## Constructors + ... Constructors (#public [] (new self {value a}) [] (:= ::value9 value)) - ## Methods + ... Methods (#public (set_actual9 self {value a}) void (:= ::value9 value)) (#public (get_actual9 self) a diff --git a/stdlib/source/test/lux/ffi.old.lux b/stdlib/source/test/lux/ffi.old.lux index 7e9301b30..9ca7d80b3 100644 --- a/stdlib/source/test/lux/ffi.old.lux +++ b/stdlib/source/test/lux/ffi.old.lux @@ -34,10 +34,10 @@ (getName [] java/lang/String)]) (/.class: #final (TestClass A) [] - ## Fields + ... Fields (#private increase java/lang/Long) (#private counter java/lang/Long) - ## Methods + ... Methods (#public [] (new {increase java/lang/Long} {counter java/lang/Long}) [] (exec (:= ::increase increase) diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux index 09f2bfc52..d40c628c7 100644 --- a/stdlib/source/test/lux/locale/language.lux +++ b/stdlib/source/test/lux/locale/language.lux @@ -219,22 +219,22 @@ (def: aliases_test/0 Test ($_ _.and - ## A + ... A (!aliases /.official_aramaic [/.imperial_aramaic]) (!aliases /.asturian [/.bable /.leonese /.asturleonese]) - ## B + ... B (!aliases /.bini [/.edo]) (!aliases /.blin [/.bilin]) - ## C + ... C (!aliases /.catalan [/.valencian]) (!aliases /.church_slavic [/.old_slavonic /.church_slavonic /.old_bulgarian /.old_church_slavonic]) - ## D + ... D (!aliases /.dhivehi [/.maldivian]) - ## G + ... G (!aliases /.swiss_german [/.alemannic /.alsatian]) - ## I + ... I (!aliases /.sichuan_yi [/.nuosu]) - ## K + ... K (!aliases /.kachin [/.jingpho]) (!aliases /.kalaallisut [/.greenlandic]) (!aliases /.khotanese [/.sakan]) @@ -243,27 +243,27 @@ (def: aliases_test/1 Test ($_ _.and - ## M + ... M (!aliases /.mi'kmaq [/.micmac]) - ## N + ... N (!aliases /.newari [/.nepal_bhasa]) (!aliases /.dutch [/.flemish]) (!aliases /.northern_sotho [/.pedi /.sepedi]) (!aliases /.old_newari [/.classical_newari /.classical_nepal_bhasa]) (!aliases /.nyanja [/.chichewa /.chewa]) - ## O + ... O (!aliases /.occitan [/.provencal]) - ## P + ... P (!aliases /.pampanga [/.kapampangan]) - ## R + ... R (!aliases /.rarotongan [/.cook_islands_maori]) (!aliases /.romanian [/.moldavian /.moldovan]) (!aliases /.aromanian [/.arumanian /.macedo_romanian]) - ## S + ... S (!aliases /.spanish [/.castilian]) - ## X + ... X (!aliases /.kalmyk [/.oirat]) - ## Z + ... Z (!aliases /.zaza [/.dimili /.dimli /.kirdki /.kirmanjki /.zazaki]) )) diff --git a/stdlib/source/test/lux/locale/territory.lux b/stdlib/source/test/lux/locale/territory.lux index 8f323004c..a5b5c4f61 100644 --- a/stdlib/source/test/lux/locale/territory.lux +++ b/stdlib/source/test/lux/locale/territory.lux @@ -176,14 +176,14 @@ (def: aliases_test Test ($_ _.and - ## A + ... A (!aliases /.antigua [/.barbuda]) - ## B + ... B (!aliases /.bonaire [/.sint_eustatius /.saba]) (!aliases /.bosnia [/.herzegovina]) - ## H + ... H (!aliases /.heard_island [/.mcdonald_islands]) - ## S + ... S (!aliases /.saint_helena [/.ascension /.tristan_da_cunha]) (!aliases /.saint_kitts [/.nevis]) (!aliases /.saint_pierre [/.miquelon]) @@ -191,12 +191,12 @@ (!aliases /.sao_tome [/.principe]) (!aliases /.south_georgia [/.south_sandwich_islands]) (!aliases /.svalbard [/.jan_mayen]) - ## T + ... T (!aliases /.trinidad [/.tobago]) (!aliases /.turks [/.caicos_islands]) - ## U + ... U (!aliases /.united_kingdom [/.northern_ireland]) - ## W + ... W (!aliases /.wallis [/.futuna]) )) diff --git a/stdlib/source/test/lux/macro.lux b/stdlib/source/test/lux/macro.lux index bbc60bf4a..7ff37ea43 100644 --- a/stdlib/source/test/lux/macro.lux +++ b/stdlib/source/test/lux/macro.lux @@ -48,8 +48,8 @@ (syntax: (pow/4 number) (in (list (` (..pow/2 (..pow/2 (~ number))))))) -(syntax: (repeat {times <code>.nat} token) - (in (list.repeat times token))) +(syntax: (repeated {times <code>.nat} token) + (in (list.repeated times token))) (syntax: (fresh_identifier) (do meta.monad @@ -89,7 +89,7 @@ #.definitions (: (List [Text .Global]) (list (!global ..pow/2) (!global ..pow/4) - (!global ..repeat))) + (!global ..repeated))) #.imports (list) #.tags (list) #.types (list) @@ -143,7 +143,7 @@ )) (_.cover [/.one_expansion] (bit\= (not (nat.= 1 repetitions)) - (|> (/.one_expansion (` (..repeat (~ (code.nat repetitions)) (~ pow/1)))) + (|> (/.one_expansion (` (..repeated (~ (code.nat repetitions)) (~ pow/1)))) (meta.run lux) (!expect (#try.Failure _))))) )))) diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux index a5bb3a9e9..d0bd1343a 100644 --- a/stdlib/source/test/lux/macro/code.lux +++ b/stdlib/source/test/lux/macro/code.lux @@ -79,14 +79,14 @@ (#.Right [end lux_code]) (#try.Success lux_code)))) -(def: (replace_simulation [original substitute]) +(def: (replacement_simulation [original substitute]) (-> [Code Code] (Random [Code Code])) (random.rec - (function (_ replace_simulation) + (function (_ replacement_simulation) (let [for_sequence (: (-> (-> (List Code) Code) (Random [Code Code])) (function (_ to_code) (do {! random.monad} - [parts (..random_sequence replace_simulation)] + [parts (..random_sequence replacement_simulation)] (in [(to_code (list\map product.left parts)) (to_code (list\map product.right parts))]))))] ($_ random.either @@ -106,7 +106,7 @@ (for_sequence /.form) (for_sequence /.tuple) (do {! random.monad} - [parts (..random_sequence replace_simulation)] + [parts (..random_sequence replacement_simulation)] (in [(/.record (let [parts' (list\map product.left parts)] (list.zipped/2 parts' parts'))) (/.record (let [parts' (list\map product.right parts)] @@ -180,9 +180,9 @@ (random.and ..random ..random)) [sample expected] (random.only (function (_ [sample expected]) (not (\ /.equivalence = sample expected))) - (..replace_simulation [original substitute]))] - (_.cover [/.replace] + (..replacement_simulation [original substitute]))] + (_.cover [/.replaced] (\ /.equivalence = expected - (/.replace original substitute sample)))) + (/.replaced original substitute sample)))) ))) diff --git a/stdlib/source/test/lux/macro/poly/json.lux b/stdlib/source/test/lux/macro/poly/json.lux index fa8e6facb..b1b9883cb 100644 --- a/stdlib/source/test/lux/macro/poly/json.lux +++ b/stdlib/source/test/lux/macro/poly/json.lux @@ -15,7 +15,7 @@ pipe ["." try] ["p" parser - ## TODO: Get rid of this import ASAP + ... TODO: Get rid of this import ASAP [json (#+)]]] [data ["." bit] @@ -42,13 +42,13 @@ [time ["ti" instant] ["tda" date] - ## ["tdu" duration] + ... ["tdu" duration] ]]] [test [lux [time ["_." instant] - ## ["_." duration] + ... ["_." duration] ]]]) (type: Variant @@ -70,8 +70,8 @@ #variant Variant #tuple [Bit Text Frac] #recursive Recursive - ## #instant ti.Instant - ## #duration tdu.Duration + ... #instant ti.Instant + ... #duration tdu.Duration #date tda.Date #grams (unit.Qty unit.Gram)}) @@ -101,8 +101,8 @@ ($_ random.or random.bit (random.unicode size) random.safe_frac) ($_ random.and random.bit (random.unicode size) random.safe_frac) ..gen_recursive - ## _instant.instant - ## _duration.duration + ... _instant.instant + ... _duration.duration random.date ..qty ))) diff --git a/stdlib/source/test/lux/macro/syntax/export.lux b/stdlib/source/test/lux/macro/syntax/export.lux index adb95407f..58d8b50a5 100644 --- a/stdlib/source/test/lux/macro/syntax/export.lux +++ b/stdlib/source/test/lux/macro/syntax/export.lux @@ -5,26 +5,44 @@ [abstract [monad (#+ do)]] [control - ["." try] + ["." try ("#\." functor)] [parser ["<.>" code]]] [data - ["." bit ("#\." equivalence)]] + ["." maybe]] + [macro + ["." code ("#\." equivalence)]] [math - ["." random]]]] + ["." random (#+ Random)] + [number + ["n" nat]]]]] [\\library ["." /]]) +(def: export + (Random [(Maybe Code) Nat]) + ($_ random.and + (|> random.bit + (\ random.monad map code.bit) + random.maybe) + random.nat)) + (def: .public test Test (<| (_.covering /._) (do random.monad - [expected random.bit] - (_.cover [/.format /.parser] - (case (<code>.run /.parser - (/.format expected)) - (#try.Failure _) - false - - (#try.Success actual) - (bit\= expected actual)))))) + [[expected_export_policy expected_un_exported] ..export] + (_.cover [/.parser /.default_policy] + (|> (case expected_export_policy + (#.Some expected_export_policy) + (list expected_export_policy (code.nat expected_un_exported)) + + #.None + (list (code.nat expected_un_exported))) + (<code>.run (/.parser <code>.nat)) + (try\map (function (_ [actual_export_policy actual_un_exported]) + (|> expected_export_policy + (maybe.else /.default_policy) + (code\= actual_export_policy) + (and (n.= expected_un_exported actual_un_exported))))) + (try.else false)))))) diff --git a/stdlib/source/test/lux/math/number.lux b/stdlib/source/test/lux/math/number.lux index d97c73f45..8a298338f 100644 --- a/stdlib/source/test/lux/math/number.lux +++ b/stdlib/source/test/lux/math/number.lux @@ -26,7 +26,7 @@ (def: clean_commas (-> Text Text) - (text.replace_all "," "")) + (text.replaced "," "")) (def: .public test Test diff --git a/stdlib/source/test/lux/math/number/complex.lux b/stdlib/source/test/lux/math/number/complex.lux index 25bdc1216..77cafc155 100644 --- a/stdlib/source/test/lux/math/number/complex.lux +++ b/stdlib/source/test/lux/math/number/complex.lux @@ -21,7 +21,7 @@ ["f" frac] ["." int]]]]) -## This margin of error is necessary because floating-point arithmetic is not exact. +... This margin of error is necessary because floating-point arithmetic is not exact. (def: margin_of_error +0.000000001) @@ -115,7 +115,7 @@ (and normal! not_a_number! infinity!))) - ## https://en.wikipedia.org/wiki/Argument_(complex_analysis)#Identities + ... https://en.wikipedia.org/wiki/Argument_(complex_analysis)#Identities (_.cover [/.argument] (let [sample (/.complex real imaginary)] (or (/.= /.zero sample) @@ -188,7 +188,7 @@ (and reciprocal! own_inverse!))) (_.cover [/.signum] - ## Absolute value of signum is always root/2(2), 1 or 0. + ... Absolute value of signum is always root/2(2), 1 or 0. (let [signum_abs (|> x /.signum /.abs)] (or (f.= +0.0 signum_abs) (f.= +1.0 signum_abs) diff --git a/stdlib/source/test/lux/math/number/i64.lux b/stdlib/source/test/lux/math/number/i64.lux index 3504af6f7..9e9228ab6 100644 --- a/stdlib/source/test/lux/math/number/i64.lux +++ b/stdlib/source/test/lux/math/number/i64.lux @@ -105,15 +105,15 @@ (case size 0 (\= /.false (/.region offset size)) _ (\= (|> pattern - ## NNNNYYYYNNNN + ... NNNNYYYYNNNN (/.right_shifted offset) - ## ____NNNNYYYY + ... ____NNNNYYYY (/.left_shifted spare) - ## YYYY________ + ... YYYY________ (/.right_shifted spare) - ## ________YYYY + ... ________YYYY (/.left_shifted offset) - ## ____YYYY____ + ... ____YYYY____ ) (/.and (/.region offset size) pattern))))) )))) diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index e6cfcf082..dfe6180ab 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -504,7 +504,7 @@ (i.> (:as Int reference) (:as Int subject)) (:as java/lang/Long +1) - ## (i.< (:as Int reference) (:as Int subject)) + ... (i.< (:as Int reference) (:as Int subject)) (:as java/lang/Long -1))]] (<| (..bytecode (for {@.old (|>> (:as Int) (i.= expected)) @@ -704,7 +704,7 @@ _ instruction _ /.i2l] ..$Long::wrap))))) - ## https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.dcmp_op + ... https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.dcmp_op comparison_standard (: (-> java/lang/Double java/lang/Double Bit) (function (_ reference subject) (for {@.old @@ -1485,7 +1485,7 @@ @wrong /.new_label @return /.new_label _ (/.bipush (|> minimum /signed.value .int /signed.s1 try.assumed)) - _ (/.tableswitch minimum @wrong [@right (list.repeat afterwards @wrong)]) + _ (/.tableswitch minimum @wrong [@right (list.repeated afterwards @wrong)]) _ (/.set_label @wrong) _ (..$Long::literal dummy) _ (/.goto @return) diff --git a/stdlib/source/test/lux/test.lux b/stdlib/source/test/lux/test.lux index 574feb176..0df2e43d3 100644 --- a/stdlib/source/test/lux/test.lux +++ b/stdlib/source/test/lux/test.lux @@ -105,11 +105,11 @@ times_assertion (<| (/.times expected) (do ! [_ (in []) - .let [_ (io.run (atom.update inc counter))]] + .let [_ (io.run (atom.update! inc counter))]] (/.test "" true)))] (in (do async.monad [[tally error] times_assertion - actual (async.future (atom.read counter))] + actual (async.future (atom.read! counter))] (/.cover' [/.times] (and (n.= expected actual) (n.= 1 (get@ #/.successes tally)) @@ -124,15 +124,15 @@ .let [counter (: (Atom Nat) (atom.atom 0))] assertion (<| /.in_parallel - (list.repeat expected) + (list.repeated expected) (: /.Test) (do ! [_ (in []) - .let [_ (io.run (atom.update inc counter))]] + .let [_ (io.run (atom.update! inc counter))]] (/.test "" true)))] (in (do async.monad [[tally error] assertion - actual (async.future (atom.read counter))] + actual (async.future (atom.read! counter))] (/.cover' [/.in_parallel] (and (n.= expected actual) (n.= expected (get@ #/.successes tally)) @@ -142,16 +142,16 @@ .let [counter (: (Atom Nat) (atom.atom 0))] assertion (<| /.in_parallel - (list.repeat expected) + (list.repeated expected) (: /.Test) (do ! [_ (in []) .let [_ (undefined) - _ (io.run (atom.update inc counter))]] + _ (io.run (atom.update! inc counter))]] (/.test "" true)))] (in (do async.monad [[tally error] assertion - actual (async.future (atom.read counter))] + actual (async.future (atom.read! counter))] (/.cover' [/.error_during_execution] (let [correct_error! (text.contains? (get@ #exception.label /.error_during_execution) error) no_complete_run! (n.= 0 actual) diff --git a/stdlib/source/test/lux/time/duration.lux b/stdlib/source/test/lux/time/duration.lux index b43ef18bd..f522dc613 100644 --- a/stdlib/source/test/lux/time/duration.lux +++ b/stdlib/source/test/lux/time/duration.lux @@ -79,13 +79,13 @@ (and (\< frame sample') (bit\= (\< frame sample) (\= sample sample'))))) - (_.cover [/.query] - (i.= +1 (/.query sample sample))) + (_.cover [/.ticks] + (i.= +1 (/.ticks sample sample))) (_.cover [/.milli_second] (\= /.empty (\ /.enum pred /.milli_second))) (~~ (template [<factor> <big> <small>] [(_.cover [<big>] - (|> <big> (/.query <small>) (i.= <factor>)))] + (|> <big> (/.ticks <small>) (i.= <factor>)))] [+1,000 /.second /.milli_second] [+60 /.minute /.second] diff --git a/stdlib/source/test/lux/time/instant.lux b/stdlib/source/test/lux/time/instant.lux index c48ae6955..6e7c90821 100644 --- a/stdlib/source/test/lux/time/instant.lux +++ b/stdlib/source/test/lux/time/instant.lux @@ -73,7 +73,7 @@ (function (_ polarity move steps) (let [day_shift (list\fold (function.constant move) d0 - (list.repeat steps [])) + (list.repeated steps [])) instant_shift (|> instant (/.after (polarity (duration.up steps duration.day))) /.day_of_week)] diff --git a/stdlib/source/test/lux/time/month.lux b/stdlib/source/test/lux/time/month.lux index 03c50086f..18d56c088 100644 --- a/stdlib/source/test/lux/time/month.lux +++ b/stdlib/source/test/lux/time/month.lux @@ -77,13 +77,13 @@ (n.= all uniques)))) (_.cover [/.days] - (let [expected (.nat (duration.query duration.day duration.normal_year))] + (let [expected (.nat (duration.ticks duration.day duration.normal_year))] (|> /.year (list\map /.days) (list\fold n.+ 0) (n.= expected)))) (_.cover [/.leap_year_days] - (let [expected (.nat (duration.query duration.day duration.leap_year))] + (let [expected (.nat (duration.ticks duration.day duration.leap_year))] (|> /.year (list\map /.leap_year_days) (list\fold n.+ 0) diff --git a/stdlib/source/test/lux/time/year.lux b/stdlib/source/test/lux/time/year.lux index 366cc8bc2..82cdbf713 100644 --- a/stdlib/source/test/lux/time/year.lux +++ b/stdlib/source/test/lux/time/year.lux @@ -70,7 +70,7 @@ (#try.Failure error) (exception.match? /.there_is_no_year_0 error))) (_.cover [/.days] - (n.= (.nat (//duration.query //duration.day //duration.normal_year)) + (n.= (.nat (//duration.ticks //duration.day //duration.normal_year)) /.days)) (_.cover [/.epoch] (\ /.equivalence = diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux index 7a5b44f51..6d83f1fa7 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -131,12 +131,12 @@ (case member (#.Left lefts) (analysis.pattern/tuple - (list\compose (list.repeat lefts (analysis.pattern/unit)) + (list\compose (list.repeated lefts (analysis.pattern/unit)) (list inner (analysis.pattern/unit)))) (#.Right lefts) (analysis.pattern/tuple - (list\compose (list.repeat (inc lefts) (analysis.pattern/unit)) + (list\compose (list.repeated (inc lefts) (analysis.pattern/unit)) (list inner))))) (#analysis.Bind @member) (list.reversed path)) @@ -290,10 +290,10 @@ branch (: (-> Nat Bit Text Frac Branch) (function (_ lefts right? value body) {#analysis.when (if right? - (analysis.pattern/tuple (list\compose (list.repeat (inc lefts) (analysis.pattern/unit)) + (analysis.pattern/tuple (list\compose (list.repeated (inc lefts) (analysis.pattern/unit)) (list (analysis.pattern/text value)))) (analysis.pattern/tuple ($_ list\compose - (list.repeat lefts (analysis.pattern/unit)) + (list.repeated lefts (analysis.pattern/unit)) (list (analysis.pattern/text value) (analysis.pattern/unit))))) #analysis.then (analysis.frac body)}))]] diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 188c50a86..31e5e3422 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -230,7 +230,7 @@ #analysis.value (#analysis.Bind 2)}) #analysis.then actual_output} {#analysis.when (analysis.pattern/tuple - (list\compose (list.repeat lefts (analysis.pattern/unit)) + (list\compose (list.repeated lefts (analysis.pattern/unit)) (if right? (list (analysis.pattern/unit) (#analysis.Bind 2)) (list (#analysis.Bind 2) (analysis.pattern/unit))))) @@ -289,7 +289,7 @@ expected_record]) (#analysis.Case actual_record [{#analysis.when (analysis.pattern/tuple - (list\compose (list.repeat lefts (analysis.pattern/unit)) + (list\compose (list.repeated lefts (analysis.pattern/unit)) (if right? (list (analysis.pattern/unit) (#analysis.Bind 2)) (list (#analysis.Bind 2) (analysis.pattern/unit))))) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux index e5a1e45d3..947170187 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux @@ -117,7 +117,7 @@ (Random Text) (do r.monad [comment comment_text^] - (in (format "## " comment text.new_line)))) + (in (format "... " comment text.new_line)))) (def: comments Test diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux index 171f34873..5b2327dc4 100644 --- a/stdlib/source/test/lux/type.lux +++ b/stdlib/source/test/lux/type.lux @@ -10,10 +10,13 @@ [pipe (#+ case>)]] [data ["." maybe] + ["." bit ("#\." equivalence)] ["." text ("#\." equivalence)] [collection ["." list] ["." array]]] + [macro + ["." code ("#\." equivalence)]] [math ["." random (#+ Random) ("#\." monad)] [number @@ -92,7 +95,7 @@ _ #1))) - (list.repeat size) + (list.repeated size) (monad.seq !)) .let [(^open "/\.") /.equivalence (^open "list\.") (list.equivalence /.equivalence)]] @@ -118,7 +121,7 @@ (case> #.None #1 _ #0)))) (do {! random.monad} [size (|> random.nat (\ ! map (n.% 3))) - members (monad.seq ! (list.repeat size ..random)) + members (monad.seq ! (list.repeated size ..random)) extra (|> ..random (random.only (function (_ type) (case type @@ -218,6 +221,18 @@ (I64 a) (.i64 expected))))) + (do random.monad + [.let [(^open "/\.") /.equivalence] + left ..random + right ..random] + ($_ _.and + (_.cover [/.code] + (bit\= (/\= left right) + (code\= (/.code left) (/.code right)))) + (_.cover [/.format] + (bit\= (/\= left right) + (text\= (/.format left) (/.format right)))) + )) /abstract.test /check.test diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux index eaa8cbb86..57df78e84 100644 --- a/stdlib/source/test/lux/type/check.lux +++ b/stdlib/source/test/lux/type/check.lux @@ -30,7 +30,7 @@ [\\library ["." /]]) -## TODO: Remove the following 3 definitions ASAP. //.type already exists... +... TODO: Remove the following 3 definitions ASAP. //.type already exists... (def: short (Random Text) (random.unicode 10)) @@ -421,7 +421,7 @@ (do ! [[id/T var/tail] /.var] (in var/tail))) - (list.repeat tail_size /.var)) + (list.repeated tail_size /.var)) var/last (monad.fold ! (function (_ var/next var/prev) (do ! [_ (/.check var/prev var/next)] @@ -582,7 +582,7 @@ (..succeeds? (/.check Any (#.Named right_name nominal))) (..succeeds? (/.check (#.Named left_name Any) (#.Named right_name nominal))))) -## TODO: Test all the crazy corner cases from /.check_apply +... TODO: Test all the crazy corner cases from /.check_apply (def: (handles_application! nominal/0 nominal/1) (-> Type Type Bit) (let [types_flow_through! diff --git a/stdlib/source/test/lux/type/dynamic.lux b/stdlib/source/test/lux/type/dynamic.lux index 04c25fb70..5a3e9e89d 100644 --- a/stdlib/source/test/lux/type/dynamic.lux +++ b/stdlib/source/test/lux/type/dynamic.lux @@ -24,15 +24,15 @@ (do random.monad [expected random.nat] ($_ _.and - (_.cover [/.:dynamic /.:check] - (case (/.:check Nat (/.:dynamic expected)) + (_.cover [/.:dynamic /.:static] + (case (/.:static Nat (/.:dynamic expected)) (#try.Success actual) (n.= expected actual) (#try.Failure _) false)) (_.cover [/.wrong_type] - (case (/.:check Text (/.:dynamic expected)) + (case (/.:static Text (/.:dynamic expected)) (#try.Success actual) false diff --git a/stdlib/source/test/lux/type/refinement.lux b/stdlib/source/test/lux/type/refinement.lux index da5826098..2c99f3163 100644 --- a/stdlib/source/test/lux/type/refinement.lux +++ b/stdlib/source/test/lux/type/refinement.lux @@ -17,7 +17,7 @@ ["." /]]) (def: _refiner - (/.refinement (n.> 123))) + (/.refiner (n.> 123))) (def: _type (/.type _refiner)) @@ -36,29 +36,29 @@ ($_ _.and (_.for [/.Refiner] ($_ _.and - (_.cover [/.refinement] - (case (/.refinement predicate raw) + (_.cover [/.refiner] + (case (/.refiner predicate raw) (#.Some refined) (predicate raw) #.None (not (predicate raw)))) (_.cover [/.predicate] - (|> (/.refinement predicate modulus) + (|> (/.refiner predicate modulus) (maybe\map (|>> /.predicate (is? predicate))) (maybe.else false))) )) (_.cover [/.value] - (|> (/.refinement predicate modulus) + (|> (/.refiner predicate modulus) (maybe\map (|>> /.value (n.= modulus))) (maybe.else false))) (_.cover [/.lift] - (and (|> (/.refinement predicate modulus) + (and (|> (/.refiner predicate modulus) (maybe\map (/.lift (n.+ modulus))) maybe\join (maybe\map (|>> /.value (n.= (n.+ modulus modulus)))) (maybe.else false)) - (|> (/.refinement predicate modulus) + (|> (/.refiner predicate modulus) (maybe\map (/.lift (n.+ (inc modulus)))) maybe\join (maybe\map (|>> /.value (n.= (n.+ modulus (inc modulus))))) @@ -66,7 +66,7 @@ not))) (_.cover [/.only] (let [expected (list.only predicate raws) - actual (/.only (/.refinement predicate) raws)] + actual (/.only (/.refiner predicate) raws)] (and (n.= (list.size expected) (list.size actual)) (\ (list.equivalence n.equivalence) = @@ -74,7 +74,7 @@ (list\map /.value actual))))) (_.cover [/.partition] (let [expected (list.only predicate raws) - [actual alternative] (/.partition (/.refinement predicate) raws)] + [actual alternative] (/.partition (/.refiner predicate) raws)] (and (n.= (list.size expected) (list.size actual)) (n.= (n.- (list.size expected) total_raws) diff --git a/stdlib/source/test/lux/world/file/watch.lux b/stdlib/source/test/lux/world/file/watch.lux index 6f70358e5..f3e0d7968 100644 --- a/stdlib/source/test/lux/world/file/watch.lux +++ b/stdlib/source/test/lux/world/file/watch.lux @@ -118,7 +118,7 @@ (def: (after_modification! fs watcher data expected_path) (-> (//.System Async) (/.Watcher Async) Binary //.Path (Async (Try Bit))) (do (try.with async.monad) - [_ (async.delay 1 (#try.Success "Delay to make sure the over_write time-stamp always changes.")) + [_ (async.delayed 1 (#try.Success "Delay to make sure the over_write time-stamp always changes.")) _ (\ fs write data expected_path) poll/2 (\ watcher poll []) poll/2' (\ watcher poll [])] diff --git a/stdlib/source/test/lux/world/shell.lux b/stdlib/source/test/lux/world/shell.lux index 3db61b469..4451f1f6f 100644 --- a/stdlib/source/test/lux/world/shell.lux +++ b/stdlib/source/test/lux/world/shell.lux @@ -44,7 +44,7 @@ (def: (on_error dead?) (if dead? (exception.except ..dead []) - (exception.return [dead? ""]))) + (#try.Success [dead? ""]))) (def: (on_write message dead?) (if dead? |