diff options
Diffstat (limited to 'stdlib/source/library')
101 files changed, 737 insertions, 692 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 9bf50bba5..84d33d03b 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -63,7 +63,7 @@ (2 #0 (4 #0 1) (9 #0 (4 #0 1) (4 #0 0)))))) [dummy_location - (9 #1 (0 #1 [[dummy_location (7 #0 ["library/lux" "type-args"])] + (9 #1 (0 #1 [[dummy_location (7 #0 ["library/lux" "type_args"])] [dummy_location (9 #0 (0 #1 [dummy_location (5 #0 "a")] (0 #0)))]] (0 #1 [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "A potentially empty list of values.")]] @@ -167,7 +167,7 @@ ## "lux.Some" (4 #0 1)))) [dummy_location - (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type-args"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type_args"])] [dummy_location (9 #0 (#Item [dummy_location (5 #0 "a")] #End))]] (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "A potentially missing value.")]] @@ -223,7 +223,7 @@ [dummy_location (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "This type represents the data-structures that are used to specify types themselves.")]] - (#Item [[dummy_location (7 #0 ["library/lux" "type-rec?"])] + (#Item [[dummy_location (7 #0 ["library/lux" "type_rec?"])] [dummy_location (0 #0 #1)]] #End)))] ["Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"] @@ -255,7 +255,7 @@ [dummy_location (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "doc"])] [dummy_location (5 #0 "The type of things that can be annotated with meta-data of arbitrary types.")]] - (#Item [[dummy_location (7 #0 ["library/lux" "type-args"])] + (#Item [[dummy_location (7 #0 ["library/lux" "type_args"])] [dummy_location (9 #0 (#Item [dummy_location (5 #0 "m")] (#Item [dummy_location (5 #0 "v")] #End)))]] #End)))] ["meta" "datum"] @@ -307,7 +307,7 @@ (#Parameter 0)) (#Parameter 1))))) [dummy_location - (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type-args"])] + (9 #1 (#Item [[dummy_location (7 #0 ["library/lux" "type_args"])] [dummy_location (9 #0 (#Item [dummy_location (5 #0 "w")] #End))]] #End))] ["Bit" "Nat" "Int" "Rev" "Frac" "Text" "Identifier" "Tag" "Form" "Tuple" "Record"] @@ -460,7 +460,7 @@ (#Apply (#Product (#Parameter 3) (#Parameter 1)) List))))) - (record$ (#Item [(tag$ ["library/lux" "type-args"]) + (record$ (#Item [(tag$ ["library/lux" "type_args"]) (tuple$ (#Item (text$ "k") (#Item (text$ "v") #End)))] #End)) ["counter" "mappings"] @@ -515,7 +515,7 @@ (#Parameter 3) ## "lux.Right" (#Parameter 1))))) - (record$ (#Item [(tag$ ["library/lux" "type-args"]) + (record$ (#Item [(tag$ ["library/lux" "type_args"]) (tuple$ (#Item (text$ "l") (#Item (text$ "r") #End)))] (#Item [(tag$ ["library/lux" "doc"]) (text$ "A choice between two values of different types.")] @@ -709,7 +709,7 @@ (text$ ("lux text concat" ("lux text concat" "Computations that can have access to the state of the compiler." __paragraph) "These computations may fail, or modify the state of the compiler."))] - (#Item [(tag$ ["library/lux" "type-args"]) + (#Item [(tag$ ["library/lux" "type_args"]) (tuple$ (#Item (text$ "a") #End))] #End))) #1) @@ -2985,7 +2985,7 @@ meta _ - (` (#.Item [[(~ location_code) (#.Tag ["library/lux" "func-args"])] + (` (#.Item [[(~ location_code) (#.Tag ["library/lux" "func_args"])] [(~ location_code) (#.Tuple (.list (~+ (list\map (function (_ arg) (` [(~ location_code) (#.Text (~ (text$ (code\encode arg))))])) args))))]] @@ -2993,7 +2993,7 @@ (def:' (with_type_args args) (-> (List Code) Code) - (` {#.type-args [(~+ (list\map (function (_ arg) (text$ (code\encode arg))) + (` {#.type_args [(~+ (list\map (function (_ arg) (text$ (code\encode arg))) args))]})) (def:' (export^ tokens) @@ -3590,7 +3590,9 @@ #None (failure "Wrong syntax for implementation:")))) -(def: (function\identity x) (All [a] (-> a a)) x) +(def: (function\identity value) + (All [a] (-> a a)) + value) (macro: #export (type: tokens) {#.doc (text$ ($_ "lux text concat" @@ -3649,7 +3651,7 @@ (#Some (` (.All (~ type_name) [(~+ args)] (~ type))))))) total_meta (let [meta (process_def_meta meta) meta (if rec? - (` (#.Item (~ (flag_meta "type-rec?")) (~ meta))) + (` (#.Item (~ (flag_meta "type_rec?")) (~ meta))) meta)] (` [(~ location_code) (#.Record (~ meta))]))] @@ -4045,7 +4047,7 @@ cases)] output)) -(def: (try_both f x1 x2) +(def: (on_either f x1 x2) (All [a b] (-> (-> a (Maybe b)) a a (Maybe b))) (case (f x1) @@ -4066,13 +4068,13 @@ #inner _ #locals {#counter _ #mappings locals} #captured {#counter _ #mappings closure}} - (try_both (find (: (-> [Text [Type Any]] (Maybe Type)) - (function (_ [bname [type _]]) - (if (text\= name bname) - (#Some type) - #None)))) - (: (List [Text [Type Any]]) locals) - (: (List [Text [Type Any]]) closure))))) + (on_either (find (: (-> [Text [Type Any]] (Maybe Type)) + (function (_ [bname [type _]]) + (if (text\= name bname) + (#Some type) + #None)))) + (: (List [Text [Type Any]]) locals) + (: (List [Text [Type Any]]) closure))))) scopes))) (def: (definition_type name state) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index 9e3bfea18..2a9e61ac7 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -37,7 +37,7 @@ (|> (<>.and <c>.local_identifier <c>.any) <>.some <c>.record - (<>.default (list)))) + (<>.else (list)))) (def: bottom^ (Parser Nat) @@ -98,8 +98,8 @@ [?bottomI ?bottomO] (with_gensyms [g!stack] (monad.do meta.monad - [inputC (singleton (macro.full_expansion (stack_fold (get@ #top inputs) (maybe.default g!stack ?bottomI)))) - outputC (singleton (macro.full_expansion (stack_fold (get@ #top outputs) (maybe.default g!stack ?bottomO))))] + [inputC (singleton (macro.full_expansion (stack_fold (get@ #top inputs) (maybe.else g!stack ?bottomI)))) + outputC (singleton (macro.full_expansion (stack_fold (get@ #top outputs) (maybe.else g!stack ?bottomO))))] (in (list (` (All [(~ g!stack)] (-> (~ (de_alias inputC)) (~ (de_alias outputC)))))))))))) @@ -124,7 +124,7 @@ (syntax: #export (word: {export |export|.parser} {name <c>.local_identifier} - {annotations (<>.default |annotations|.empty |annotations|.parser)} + {annotations (<>.else |annotations|.empty |annotations|.parser)} type {commands (<>.some <c>.any)}) {#.doc (doc "A named concatenative function." diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index 72d28a0b7..067cf0178 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -287,7 +287,7 @@ (syntax: #export (actor: {export |export|.parser} {[name vars] actor_decl^} - {annotations (<>.default |annotations|.empty |annotations|.parser)} + {annotations (<>.else |annotations|.empty |annotations|.parser)} state_type {[?on_mail messages] behavior^}) {#.doc (doc "Defines a named actor, with its behavior and internal state." @@ -335,7 +335,7 @@ (def: signature^ (Parser Signature) (<code>.form ($_ <>.and - (<>.default (list) (<code>.tuple (<>.some <code>.local_identifier))) + (<>.else (list) (<code>.tuple (<>.some <code>.local_identifier))) <code>.local_identifier (<>.some |input|.parser) <code>.local_identifier @@ -349,7 +349,7 @@ (syntax: #export (message: {export |export|.parser} {signature signature^} - {annotations (<>.default |annotations|.empty |annotations|.parser)} + {annotations (<>.else |annotations|.empty |annotations|.parser)} output_type body) {#.doc (doc "A message can access the actor's state through the state parameter." diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index c57c9877b..e7cdd6d3e 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -90,7 +90,7 @@ (..except exception message))) (syntax: #export (exception: {export |export|.parser} - {t_vars (p.default (list) (s.tuple (p.some |type_variable|.parser)))} + {t_vars (p.else (list) (s.tuple (p.some |type_variable|.parser)))} {[name inputs] (p.either (p.and s.local_identifier (in (list))) (s.form (p.and s.local_identifier (p.some |input|.parser))))} {body (p.maybe s.any)}) @@ -116,7 +116,7 @@ {#..label (~ g!descriptor) #..constructor (function ((~ g!self) [(~+ (list\map (get@ #|input|.binding) inputs))]) ((~! text\compose) (~ g!descriptor) - (~ (maybe.default (' "") body))))}))))) + (~ (maybe.else (' "") body))))}))))) ))) (def: (report' entries) diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index 696ec7525..e8ba63499 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -241,7 +241,7 @@ (#try.Failure error) (#try.Failure error)))) -(def: #export (default value parser) +(def: #export (else value parser) {#.doc "If the given parser fails, returns the default value."} (All [s a] (-> a (Parser s a) (Parser s a))) (function (_ input) diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index 8d9d3116a..ec576f9cd 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -117,18 +117,18 @@ [state a] (sFa state)] (in [state (f a)]))))) -(type: #export (State' M s a) +(type: #export (+State M s a) {#.doc "Stateful computations decorated by a monad."} (-> s (M [s a]))) (def: #export (run' state action) {#.doc "Execute a stateful computation decorated by a monad."} - (All [M s a] (-> s (State' M s a) (M [s a]))) + (All [M s a] (-> s (+State M s a) (M [s a]))) (action state)) (implementation: #export (with monad) {#.doc "A monad transformer to create composite stateful computations."} - (All [M s] (-> (Monad M) (Monad (State' M s)))) + (All [M s] (-> (Monad M) (Monad (+State M s)))) (def: &functor (with//functor (\ monad &functor))) @@ -143,8 +143,8 @@ (sMa state'))))) (def: #export (lift monad ma) - {#.doc "Lift monadic values to the State' wrapper."} - (All [M s a] (-> (Monad M) (M a) (State' M s a))) + {#.doc "Lift monadic values to the +State wrapper."} + (All [M s a] (-> (Monad M) (M a) (+State M s a))) (function (_ state) (do monad [a ma] diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 4a6a35678..c1a991628 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -131,14 +131,14 @@ (#Failure (`` (("lux in-module" (~~ (static .prelude_module)) .name\encode) (name_of ..of_maybe)))))) -(macro: #export (default tokens compiler) +(macro: #export (else tokens compiler) {#.doc (doc "Allows you to provide a default value that will be used" "if a (Try x) value turns out to be #Failure." "Note: the expression for the default value will not be computed if the base computation succeeds." (= "bar" - (default "foo" (#..Success "bar"))) + (else "foo" (#..Success "bar"))) (= "foo" - (default "foo" (#..Failure "KABOOM!"))))} + (else "foo" (#..Failure "KABOOM!"))))} (case tokens (^ (list else try)) (#Success [compiler (list (` (case (~ try) @@ -149,4 +149,4 @@ (~ else))))]) _ - (#Failure "Wrong syntax for default"))) + (#Failure "Wrong syntax for else"))) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index 185a142bf..6cd8c722b 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -137,7 +137,7 @@ ## Default (|> binary (array.read idx) - (maybe.default (: (I64 Any) 0)) + (maybe.else (: (I64 Any) 0)) (:as I64)))) (template: (!!write <byte_type> <post> <write> idx value binary) @@ -200,7 +200,7 @@ (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 1 idx)) (#try.Success ($_ i64.or - (i64.left_shift 8 (!read idx binary)) + (i64.left_shifted 8 (!read idx binary)) (!read (n.+ 1 idx) binary))) (exception.except ..index_out_of_bounds [(..!size binary) idx]))) @@ -208,9 +208,9 @@ (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 3 idx)) (#try.Success ($_ i64.or - (i64.left_shift 24 (!read idx binary)) - (i64.left_shift 16 (!read (n.+ 1 idx) binary)) - (i64.left_shift 8 (!read (n.+ 2 idx) binary)) + (i64.left_shifted 24 (!read idx binary)) + (i64.left_shifted 16 (!read (n.+ 1 idx) binary)) + (i64.left_shifted 8 (!read (n.+ 2 idx) binary)) (!read (n.+ 3 idx) binary))) (exception.except ..index_out_of_bounds [(..!size binary) idx]))) @@ -218,13 +218,13 @@ (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 7 idx)) (#try.Success ($_ i64.or - (i64.left_shift 56 (!read idx binary)) - (i64.left_shift 48 (!read (n.+ 1 idx) binary)) - (i64.left_shift 40 (!read (n.+ 2 idx) binary)) - (i64.left_shift 32 (!read (n.+ 3 idx) binary)) - (i64.left_shift 24 (!read (n.+ 4 idx) binary)) - (i64.left_shift 16 (!read (n.+ 5 idx) binary)) - (i64.left_shift 8 (!read (n.+ 6 idx) binary)) + (i64.left_shifted 56 (!read idx binary)) + (i64.left_shifted 48 (!read (n.+ 1 idx) binary)) + (i64.left_shifted 40 (!read (n.+ 2 idx) binary)) + (i64.left_shifted 32 (!read (n.+ 3 idx) binary)) + (i64.left_shifted 24 (!read (n.+ 4 idx) binary)) + (i64.left_shifted 16 (!read (n.+ 5 idx) binary)) + (i64.left_shifted 8 (!read (n.+ 6 idx) binary)) (!read (n.+ 7 idx) binary))) (exception.except ..index_out_of_bounds [(..!size binary) idx]))) @@ -239,7 +239,7 @@ (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 1 idx)) (#try.Success (|> binary - (!write idx (i64.right_shift 8 value)) + (!write idx (i64.right_shifted 8 value)) (!write (n.+ 1 idx) value))) (exception.except ..index_out_of_bounds [(..!size binary) idx]))) @@ -247,32 +247,32 @@ (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 3 idx)) (#try.Success (|> binary - (!write idx (i64.right_shift 24 value)) - (!write (n.+ 1 idx) (i64.right_shift 16 value)) - (!write (n.+ 2 idx) (i64.right_shift 8 value)) + (!write idx (i64.right_shifted 24 value)) + (!write (n.+ 1 idx) (i64.right_shifted 16 value)) + (!write (n.+ 2 idx) (i64.right_shifted 8 value)) (!write (n.+ 3 idx) value))) (exception.except ..index_out_of_bounds [(..!size binary) idx]))) (def: #export (write/64 idx value binary) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 7 idx)) - (for {@.scheme (let [write_high (|>> (!write idx (i64.right_shift 56 value)) - (!write (n.+ 1 idx) (i64.right_shift 48 value)) - (!write (n.+ 2 idx) (i64.right_shift 40 value)) - (!write (n.+ 3 idx) (i64.right_shift 32 value))) - write_low (|>> (!write (n.+ 4 idx) (i64.right_shift 24 value)) - (!write (n.+ 5 idx) (i64.right_shift 16 value)) - (!write (n.+ 6 idx) (i64.right_shift 8 value)) + (for {@.scheme (let [write_high (|>> (!write idx (i64.right_shifted 56 value)) + (!write (n.+ 1 idx) (i64.right_shifted 48 value)) + (!write (n.+ 2 idx) (i64.right_shifted 40 value)) + (!write (n.+ 3 idx) (i64.right_shifted 32 value))) + write_low (|>> (!write (n.+ 4 idx) (i64.right_shifted 24 value)) + (!write (n.+ 5 idx) (i64.right_shifted 16 value)) + (!write (n.+ 6 idx) (i64.right_shifted 8 value)) (!write (n.+ 7 idx) value))] (|> binary write_high write_low #try.Success))} (#try.Success (|> binary - (!write idx (i64.right_shift 56 value)) - (!write (n.+ 1 idx) (i64.right_shift 48 value)) - (!write (n.+ 2 idx) (i64.right_shift 40 value)) - (!write (n.+ 3 idx) (i64.right_shift 32 value)) - (!write (n.+ 4 idx) (i64.right_shift 24 value)) - (!write (n.+ 5 idx) (i64.right_shift 16 value)) - (!write (n.+ 6 idx) (i64.right_shift 8 value)) + (!write idx (i64.right_shifted 56 value)) + (!write (n.+ 1 idx) (i64.right_shifted 48 value)) + (!write (n.+ 2 idx) (i64.right_shifted 40 value)) + (!write (n.+ 3 idx) (i64.right_shifted 32 value)) + (!write (n.+ 4 idx) (i64.right_shifted 24 value)) + (!write (n.+ 5 idx) (i64.right_shifted 16 value)) + (!write (n.+ 6 idx) (i64.right_shifted 8 value)) (!write (n.+ 7 idx) value)))) (exception.except ..index_out_of_bounds [(..!size binary) idx]))) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 96b082211..330ea38eb 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -175,7 +175,7 @@ (All [a] (-> Nat a (-> a a) (Array a) (Array a))) (write! index - (|> array (read index) (maybe.default default) transform) + (|> array (read index) (maybe.else default) transform) array)) (def: #export (copy! length src_start src_array dest_start dest_array) @@ -311,7 +311,7 @@ (if (n.= ..underflow idx) output (recur (dec idx) - (#.Item (maybe.default default (read idx array)) + (#.Item (maybe.else default (read idx array)) output))))) (implementation: #export (equivalence (^open ",\.")) diff --git a/stdlib/source/library/lux/data/collection/bits.lux b/stdlib/source/library/lux/data/collection/bits.lux index 6066bd0c2..f45916a00 100644 --- a/stdlib/source/library/lux/data/collection/bits.lux +++ b/stdlib/source/library/lux/data/collection/bits.lux @@ -53,13 +53,13 @@ (let [[chunk_index bit_index] (n./% chunk_size index)] (.and (n.< (array.size bits) chunk_index) (|> (array.read chunk_index bits) - (maybe.default empty_chunk) + (maybe.else empty_chunk) (i64.set? bit_index))))) (def: (chunk idx bits) (-> Nat Bits Chunk) (if (n.< (array.size bits) idx) - (|> bits (array.read idx) (maybe.default empty_chunk)) + (|> bits (array.read idx) (maybe.else empty_chunk)) empty_chunk)) (template [<name> <op>] diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index 81ad72fbd..42e421952 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -26,14 +26,14 @@ ## 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: BitMap +(type: Bit_Map Nat) -## Represents the position of a node in a BitMap. +## 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 BitMap. -(type: BitPosition +## position exists within a #Base, as reflected in its Bit_Map. +(type: Bit_Position Nat) ## An index into an array. @@ -58,7 +58,7 @@ ## Dictionaries. (type: (Node k v) (#Hierarchy Nat (Array (Node k v))) - (#Base BitMap + (#Base Bit_Map (Array (Either (Node k v) [k v]))) (#Collisions Hash_Code (Array [k v]))) @@ -84,7 +84,7 @@ ## Or 0x00000000. ## Which is 32 zeroes, since the branching factor is 32. (def: clean_bitmap - BitMap + Bit_Map 0) ## Bitmap position (while looking inside #Base nodes) is determined by @@ -110,18 +110,18 @@ ## which is 1/4 of the branching factor (or a left-shift 2). (def: demotion_threshold Nat - (i64.left_shift (n.- 2 branching_exponent) 1)) + (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). (def: promotion_threshold Nat - (i64.left_shift (n.- 1 branching_exponent) 1)) + (i64.left_shifted (n.- 1 branching_exponent) 1)) ## The size of hierarchy-nodes, which is 2^(branching-exponent). (def: hierarchy_nodes_size Nat - (i64.left_shift branching_exponent 1)) + (i64.left_shifted branching_exponent 1)) ## The cannonical empty node, which is just an empty #Base node. (def: empty @@ -163,7 +163,7 @@ (n.+ branching_exponent)) (def: hierarchy_mask - BitMap + Bit_Map (dec hierarchy_nodes_size)) ## Gets the branching-factor sized section of the hash corresponding @@ -171,20 +171,20 @@ (def: (level_index level hash) (-> Level Hash_Code Index) (i64.and ..hierarchy_mask - (i64.right_shift level hash))) + (i64.right_shifted level hash))) ## A mechanism to go from indices to bit-positions. (def: (to_bit_position index) - (-> Index BitPosition) - (i64.left_shift index 1)) + (-> Index Bit_Position) + (i64.left_shifted index 1)) ## The bit-position within a base that a given hash-code would have. (def: (bit_position level hash) - (-> Level Hash_Code BitPosition) + (-> Level Hash_Code Bit_Position) (to_bit_position (level_index level hash))) (def: (bit_position_is_set? bit bitmap) - (-> BitPosition BitMap Bit) + (-> Bit_Position Bit_Map Bit) (|> bitmap (i64.and bit) (n.= clean_bitmap) @@ -192,48 +192,48 @@ ## Figures out whether a bitmap only contains a single bit-position. (def: only_bit_position? - (-> BitPosition BitMap Bit) + (-> Bit_Position Bit_Map Bit) n.=) (def: (set_bit_position bit bitmap) - (-> BitPosition BitMap BitMap) + (-> Bit_Position Bit_Map Bit_Map) (i64.or bit bitmap)) (def: unset_bit_position - (-> BitPosition BitMap BitMap) + (-> 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. (def: bitmap_size - (-> BitMap Nat) + (-> 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. (def: bit_position_mask - (-> BitPosition BitMap) + (-> Bit_Position Bit_Map) dec) ## The index on the base array, based on its bit-position. (def: (base_index bit_position bitmap) - (-> BitPosition BitMap Index) + (-> 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. -(def: (collision_index Hash<k> key colls) +(def: (collision_index key_hash key colls) (All [k v] (-> (Hash k) k (Collisions k v) (Maybe Index))) (\ maybe.monad map product.left (array.find+ (function (_ idx [key' val']) - (\ Hash<k> = key key')) + (\ key_hash = key key')) colls))) ## When #Hierarchy nodes grow too small, they're demoted to #Base ## nodes to save space. (def: (demote_hierarchy except_idx [h_size h_array]) - (All [k v] (-> Index (Hierarchy k v) [BitMap (Base k v)])) + (All [k v] (-> Index (Hierarchy k v) [Bit_Map (Base k v)])) (product.right (list\fold (function (_ idx [insertion_idx node]) (let [[bitmap base] node] (case (array.read idx h_array) @@ -252,11 +252,11 @@ ## add some depth to the tree and help keep its balance. (def: hierarchy_indices (List Index) (list.indices hierarchy_nodes_size)) -(def: (promote_base put' Hash<k> level bitmap base) +(def: (promote_base put' key_hash level bitmap base) (All [k v] (-> (-> Level Hash_Code k v (Hash k) (Node k v) (Node k v)) (Hash k) Level - BitMap (Base k v) + Bit_Map (Base k v) (Array (Node k v)))) (product.right (list\fold (function (_ hierarchy_idx (^@ default [base_idx h_array])) (if (bit_position_is_set? (to_bit_position hierarchy_idx) @@ -268,7 +268,7 @@ (#.Some (#.Right [key' val'])) (array.write! hierarchy_idx - (put' (level_up level) (\ Hash<k> hash key') key' val' Hash<k> empty) + (put' (level_up level) (\ key_hash hash key') key' val' key_hash empty) h_array) #.None @@ -290,7 +290,7 @@ _ #0))) -(def: (put' level hash key val Hash<k> node) +(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 @@ -304,10 +304,10 @@ _ [(inc _size) empty])] (#Hierarchy _size' - (update! idx (put' (level_up level) hash key val Hash<k> sub_node) + (update! idx (put' (level_up level) hash key val key_hash sub_node) hierarchy))) - ## For #Base nodes, check if the corresponding BitPosition has + ## For #Base nodes, check if the corresponding Bit_Position has ## already been used. (#Base bitmap base) (let [bit (bit_position level hash)] @@ -317,17 +317,17 @@ (case (array.read idx base) ## 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 Hash<k> 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. (#.Some (#.Right key' val')) - (if (\ Hash<k> = key key') + (if (\ key_hash = key key') ## If the same key is found, replace the value. (#Base bitmap (update! idx (#.Right key val) base)) ## Otherwise, compare the hashes of the keys. (#Base bitmap (update! idx - (#.Left (let [hash' (\ Hash<k> hash key')] + (#.Left (let [hash' (\ key_hash hash key')] (if (n.= hash hash') ## If the hashes are ## the same, a new @@ -343,22 +343,22 @@ ## to the empty one. (let [next_level (level_up level)] (|> empty - (put' next_level hash' key' val' Hash<k>) - (put' next_level hash key val Hash<k>)))))) + (put' next_level hash' key' val' key_hash) + (put' next_level hash key val key_hash)))))) base))) #.None (undefined))) - ## However, if the BitPosition has not been used yet, check + ## 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. (#Hierarchy (inc base_count) - (|> (promote_base put' Hash<k> level bitmap base) + (|> (promote_base put' key_hash level bitmap base) (array.write! (level_index level hash) - (put' (level_up level) hash key val Hash<k> empty)))) + (put' (level_up level) hash key val key_hash empty)))) ## Otherwise, just resize the #Base node to accommodate the ## new KV-pair. (#Base (set_bit_position bit bitmap) @@ -369,7 +369,7 @@ (if (n.= hash _hash) ## If they're equal, that means the new KV contributes to the ## collisions. - (case (collision_index Hash<k> key _colls) + (case (collision_index key_hash key _colls) ## If the key was already present in the collisions-list, its ## value gets updated. (#.Some coll_idx) @@ -383,10 +383,10 @@ (|> (#Base (bit_position level _hash) (|> (array.new 1) (array.write! 0 (#.Left node)))) - (put' level hash key val Hash<k>))) + (put' level hash key val key_hash))) )) -(def: (remove' level hash key Hash<k> node) +(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 @@ -400,7 +400,7 @@ ## 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 Hash<k> sub_node)] + (let [sub_node' (remove' (level_up level) hash key key_hash sub_node)] ## Then check if a removal was actually done. (if (is? sub_node sub_node') ## If not, then there's nothing to change here either. @@ -417,7 +417,7 @@ ## just update the hiearchy branch. (#Hierarchy h_size (update! idx sub_node' h_array))))))) - ## For #Base nodes, check whether the BitPosition is set. + ## For #Base nodes, check whether the Bit_Position is set. (#Base bitmap base) (let [bit (bit_position level hash)] (if (bit_position_is_set? bit bitmap) @@ -426,7 +426,7 @@ ## 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 Hash<k> sub_node)] + (let [sub_node' (remove' (level_up level) hash key key_hash sub_node)] ## Verify that it was removed. (if (is? sub_node sub_node') ## If not, there's also nothing to change here. @@ -449,8 +449,8 @@ ## If, however, there was a KV-pair instead of a sub-node. (#.Some (#.Right [key' val'])) ## Check if the keys match. - (if (\ Hash<k> = key key') - ## If so, remove the KV-pair and unset the BitPosition. + (if (\ key_hash = key key') + ## If so, remove the KV-pair and unset the Bit_Position. (#Base (unset_bit_position bit bitmap) (remove! idx base)) ## Otherwise, there's nothing to remove. @@ -458,12 +458,12 @@ #.None (undefined))) - ## If the BitPosition 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. (#Collisions _hash _colls) - (case (collision_index Hash<k> key _colls) + (case (collision_index key_hash key _colls) ## If not, then there's nothing to remove. #.None node @@ -478,14 +478,14 @@ (#Collisions _hash (remove! idx _colls)))) )) -(def: (get' level hash key Hash<k> node) +(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. (#Hierarchy _size hierarchy) (case (array.read (level_index level hash) hierarchy) #.None #.None - (#.Some sub_node) (get' (level_up level) hash key Hash<k> sub_node)) + (#.Some sub_node) (get' (level_up level) hash key key_hash sub_node)) ## For #Base nodes, check the leaves, and recursively check the branches. (#Base bitmap base) @@ -493,10 +493,10 @@ (if (bit_position_is_set? bit bitmap) (case (array.read (base_index bit bitmap) base) (#.Some (#.Left sub_node)) - (get' (level_up level) hash key Hash<k> sub_node) + (get' (level_up level) hash key key_hash sub_node) (#.Some (#.Right [key' val'])) - (if (\ Hash<k> = key key') + (if (\ key_hash = key key') (#.Some val') #.None) @@ -507,7 +507,7 @@ ## 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 (\ Hash<k> = key)) + (array.find (|>> product.left (\ key_hash = key)) _colls)) )) @@ -561,25 +561,26 @@ (All [k v] (-> (Dictionary k v) (Hash k))) (get@ #..hash)) -(def: #export (new Hash<k>) +(def: #export (new key_hash) + {#.doc (doc "An empty dictionary.")} (All [k v] (-> (Hash k) (Dictionary k v))) - {#hash Hash<k> + {#hash key_hash #root empty}) (def: #export (put key val dict) (All [k v] (-> k v (Dictionary k v) (Dictionary k v))) - (let [[Hash<k> node] dict] - [Hash<k> (put' root_level (\ Hash<k> hash key) key val Hash<k> node)])) + (let [[key_hash node] dict] + [key_hash (put' root_level (\ key_hash hash key) key val key_hash node)])) (def: #export (remove key dict) (All [k v] (-> k (Dictionary k v) (Dictionary k v))) - (let [[Hash<k> node] dict] - [Hash<k> (remove' root_level (\ Hash<k> hash key) key Hash<k> node)])) + (let [[key_hash node] dict] + [key_hash (remove' root_level (\ key_hash hash key) key key_hash node)])) (def: #export (get key dict) (All [k v] (-> k (Dictionary k v) (Maybe v))) - (let [[Hash<k> node] dict] - (get' root_level (\ Hash<k> hash key) key Hash<k> node))) + (let [[key_hash node] dict] + (get' root_level (\ key_hash hash key) key key_hash node))) (def: #export (key? dict key) (All [k v] (-> (Dictionary k v) k Bit)) @@ -611,8 +612,8 @@ "Otherwise, puts a value by applying the function to a default.")} (All [k v] (-> k v (-> v v) (Dictionary k v) (Dictionary k v))) (..put key - (f (maybe.default default - (..get key dict))) + (f (maybe.else default + (..get key dict))) dict)) (def: #export size @@ -627,14 +628,14 @@ (All [k v] (-> (Dictionary k v) (List [k v]))) (|>> product.right ..entries')) -(def: #export (of_list Hash<k> kvs) +(def: #export (of_list key_hash kvs) (All [k v] (-> (Hash k) (List [k v]) (Dictionary k v))) (list\fold (function (_ [k v] dict) (..put k v dict)) - (new Hash<k>) + (new key_hash) kvs)) -(template [<name> <side>] +(template [<side> <name>] [(def: #export <name> (All [k v] (-> (Dictionary k v) (List <side>))) (|>> ..entries @@ -642,8 +643,8 @@ (#.Item <side> bundle)) #.End)))] - [keys k] - [values v] + [k keys] + [v values] ) (def: #export (merge dict2 dict1) @@ -669,6 +670,7 @@ (entries dict2))) (def: #export (re_bind from_key to_key dict) + {#.doc (doc "If there is a value under 'from_key', remove 'from_key' and store the value under 'to_key'.")} (All [k v] (-> k k (Dictionary k v) (Dictionary k v))) (case (get from_key dict) #.None @@ -680,14 +682,14 @@ (put to_key val)))) (def: #export (select keys dict) - {#.doc "Creates a sub-set of the given dict, with only the specified keys."} + {#.doc "A sub-dictionary, with only the specified keys."} (All [k v] (-> (List k) (Dictionary k v) (Dictionary k v))) - (let [[Hash<k> _] dict] + (let [[key_hash _] dict] (list\fold (function (_ key new_dict) (case (get key dict) #.None new_dict (#.Some val) (put key val new_dict))) - (new Hash<k>) + (new key_hash) keys))) (implementation: #export (equivalence (^open ",\.")) diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index 0b8976411..8008cb8b0 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -147,113 +147,107 @@ <no_change> ))] - [blacken #Red #Black self] - [redden #Black #Red (error! error_message)] + [blackened #Red #Black self] + [reddened #Black #Red (error! error_message)] ) -(def: (balance_left_add parent self) - (All [k v] (-> (Node k v) (Node k v) (Node k v))) - (with_expansions - [<default_behavior> (as_is (black (get@ #key parent) - (get@ #value parent) - (#.Some self) - (get@ #right parent)))] - (case (get@ #color self) - #Red - (case (get@ #left self) - (^multi (#.Some left) - {(get@ #color left) #Red}) - (red (get@ #key self) - (get@ #value self) - (#.Some (blacken left)) - (#.Some (black (get@ #key parent) - (get@ #value parent) - (get@ #right self) - (get@ #right parent)))) - - _ - (case (get@ #right self) - (^multi (#.Some right) - {(get@ #color right) #Red}) - (red (get@ #key right) - (get@ #value right) - (#.Some (black (get@ #key self) - (get@ #value self) - (get@ #left self) - (get@ #left right))) - (#.Some (black (get@ #key parent) - (get@ #value parent) - (get@ #right right) - (get@ #right parent)))) - - _ - <default_behavior>)) - - #Black - <default_behavior> - ))) - -(def: (balance_right_add parent self) - (All [k v] (-> (Node k v) (Node k v) (Node k v))) - (with_expansions - [<default_behavior> (as_is (black (get@ #key parent) - (get@ #value parent) - (get@ #left parent) - (#.Some self)))] - (case (get@ #color self) - #Red - (case (get@ #right self) - (^multi (#.Some right) - {(get@ #color right) #Red}) - (red (get@ #key self) - (get@ #value self) - (#.Some (black (get@ #key parent) - (get@ #value parent) - (get@ #left parent) - (get@ #left self))) - (#.Some (blacken right))) - - _ - (case (get@ #left self) - (^multi (#.Some left) - {(get@ #color left) #Red}) - (red (get@ #key left) - (get@ #value left) - (#.Some (black (get@ #key parent) - (get@ #value parent) - (get@ #left parent) - (get@ #left left))) - (#.Some (black (get@ #key self) - (get@ #value self) - (get@ #right left) - (get@ #right self)))) - - _ - <default_behavior>)) - - #Black - <default_behavior> - ))) - (def: (add_left addition center) (All [k v] (-> (Node k v) (Node k v) (Node k v))) (case (get@ #color center) #Red - (red (get@ #key center) (get@ #value center) (#.Some addition) (get@ #right center)) + (red (get@ #key center) + (get@ #value center) + (#.Some addition) + (get@ #right center)) #Black - (balance_left_add center addition) - )) + (with_expansions + [<default_behavior> (as_is (black (get@ #key center) + (get@ #value center) + (#.Some addition) + (get@ #right center)))] + (case (get@ #color addition) + #Red + (case (get@ #left addition) + (^multi (#.Some left) + {(get@ #color left) #Red}) + (red (get@ #key addition) + (get@ #value addition) + (#.Some (blackened left)) + (#.Some (black (get@ #key center) + (get@ #value center) + (get@ #right addition) + (get@ #right center)))) + + _ + (case (get@ #right addition) + (^multi (#.Some right) + {(get@ #color right) #Red}) + (red (get@ #key right) + (get@ #value right) + (#.Some (black (get@ #key addition) + (get@ #value addition) + (get@ #left addition) + (get@ #left right))) + (#.Some (black (get@ #key center) + (get@ #value center) + (get@ #right right) + (get@ #right center)))) + + _ + <default_behavior>)) + + #Black + <default_behavior>)))) (def: (add_right addition center) (All [k v] (-> (Node k v) (Node k v) (Node k v))) (case (get@ #color center) #Red - (red (get@ #key center) (get@ #value center) (get@ #left center) (#.Some addition)) + (red (get@ #key center) + (get@ #value center) + (get@ #left center) + (#.Some addition)) #Black - (balance_right_add center addition) - )) + (with_expansions + [<default_behavior> (as_is (black (get@ #key center) + (get@ #value center) + (get@ #left center) + (#.Some addition)))] + (case (get@ #color addition) + #Red + (case (get@ #right addition) + (^multi (#.Some right) + {(get@ #color right) #Red}) + (red (get@ #key addition) + (get@ #value addition) + (#.Some (black (get@ #key center) + (get@ #value center) + (get@ #left center) + (get@ #left addition))) + (#.Some (blackened right))) + + _ + (case (get@ #left addition) + (^multi (#.Some left) + {(get@ #color left) #Red}) + (red (get@ #key left) + (get@ #value left) + (#.Some (black (get@ #key center) + (get@ #value center) + (get@ #left center) + (get@ #left left))) + (#.Some (black (get@ #key addition) + (get@ #value addition) + (get@ #right left) + (get@ #right addition)))) + + _ + <default_behavior>)) + + #Black + <default_behavior>)))) (def: #export (put key value dict) (All [k v] (-> k v (Dictionary k v) (Dictionary k v))) @@ -284,7 +278,7 @@ ))] (set@ #root root' dict))) -(def: (left_balance key value ?left ?right) +(def: (left_balanced key value ?left ?right) (All [k v] (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left (^multi (#.Some left) @@ -293,7 +287,7 @@ {(get@ #color left>>left) #Red}) (red (get@ #key left) (get@ #value left) - (#.Some (blacken left>>left)) + (#.Some (blackened left>>left)) (#.Some (black key value (get@ #right left) ?right))) (^multi (#.Some left) @@ -313,7 +307,7 @@ _ (black key value ?left ?right))) -(def: (right_balance key value ?left ?right) +(def: (right_balanced key value ?left ?right) (All [k v] (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right (^multi (#.Some right) @@ -323,7 +317,7 @@ (red (get@ #key right) (get@ #value right) (#.Some (black key value ?left (get@ #left right))) - (#.Some (blacken right>>right))) + (#.Some (blackened right>>right))) (^multi (#.Some right) {(get@ #color right) #Red} @@ -345,13 +339,13 @@ (case ?left (^multi (#.Some left) {(get@ #color left) #Red}) - (red key value (#.Some (blacken left)) ?right) + (red key value (#.Some (blackened left)) ?right) _ (case ?right (^multi (#.Some right) {(get@ #color right) #Black}) - (right_balance key value ?left (#.Some (redden right))) + (right_balanced key value ?left (#.Some (reddened right))) (^multi (#.Some right) {(get@ #color right) #Red} @@ -360,10 +354,10 @@ (red (get@ #key right>>left) (get@ #value right>>left) (#.Some (black key value ?left (get@ #left right>>left))) - (#.Some (right_balance (get@ #key right) - (get@ #value right) - (get@ #right right>>left) - (\ maybe.functor map redden (get@ #right right))))) + (#.Some (right_balanced (get@ #key right) + (get@ #value right) + (get@ #right right>>left) + (\ maybe.functor map reddened (get@ #right right))))) _ (error! error_message)) @@ -374,13 +368,13 @@ (case ?right (^multi (#.Some right) {(get@ #color right) #Red}) - (red key value ?left (#.Some (blacken right))) + (red key value ?left (#.Some (blackened right))) _ (case ?left (^multi (#.Some left) {(get@ #color left) #Black}) - (left_balance key value (#.Some (redden left)) ?right) + (left_balanced key value (#.Some (reddened left)) ?right) (^multi (#.Some left) {(get@ #color left) #Red} @@ -388,17 +382,17 @@ {(get@ #color left>>right) #Black}) (red (get@ #key left>>right) (get@ #value left>>right) - (#.Some (left_balance (get@ #key left) - (get@ #value left) - (\ maybe.functor map redden (get@ #left left)) - (get@ #left left>>right))) + (#.Some (left_balanced (get@ #key left) + (get@ #value left) + (\ maybe.functor map reddened (get@ #left left)) + (get@ #left left>>right))) (#.Some (black key value (get@ #right left>>right) ?right))) _ (error! error_message) ))) -(def: (prepend ?left ?right) +(def: (prepended ?left ?right) (All [k v] (-> (Maybe (Node k v)) (Maybe (Node k v)) (Maybe (Node k v)))) (case [?left ?right] [#.None _] @@ -411,7 +405,7 @@ (case [(get@ #color left) (get@ #color right)] [#Red #Red] (do maybe.monad - [fused (prepend (get@ #right left) (get@ #right right))] + [fused (prepended (get@ #right left) (get@ #right right))] (case (get@ #color fused) #Red (in (red (get@ #key fused) @@ -438,19 +432,19 @@ (#.Some (red (get@ #key left) (get@ #value left) (get@ #left left) - (prepend (get@ #right left) - ?right))) + (prepended (get@ #right left) + ?right))) [#Black #Red] (#.Some (red (get@ #key right) (get@ #value right) - (prepend ?left - (get@ #left right)) + (prepended ?left + (get@ #left right)) (get@ #right right))) [#Black #Black] (do maybe.monad - [fused (prepend (get@ #right left) (get@ #left right))] + [fused (prepended (get@ #right left) (get@ #left right))] (case (get@ #color fused) #Red (in (red (get@ #key fused) @@ -490,8 +484,8 @@ (let [root_key (get@ #key root) root_val (get@ #value root)] (if (_\= root_key key) - [(prepend (get@ #left root) - (get@ #right root)) + [(prepended (get@ #left root) + (get@ #right root)) #1] (let [go_left? (_\< root_key key)] (case (recur (if go_left? @@ -530,7 +524,7 @@ dict) (#.Some root) - (set@ #root (#.Some (blacken root)) dict) + (set@ #root (#.Some (blackened root)) dict) ))) (def: #export (update key transform dict) diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index ee500594b..a584f9363 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -51,6 +51,7 @@ xs)) (def: #export (only keep? xs) + {#.doc (doc "A list with only values that satisfy the predicate.")} (All [a] (-> (Predicate a) (List a) (List a))) (case xs @@ -152,16 +153,16 @@ (let [[ys' xs'] (split_with' predicate #.End xs)] [(reverse ys') xs'])) -(def: #export (chunk n xs) - {#.doc "Segment the list in chunks of size N."} +(def: #export (chunk size list) + {#.doc "Segment the list in chunks of the given size."} (All [a] (-> Nat (List a) (List (List a)))) - (case xs + (case list + #.End #.End - (list) _ - (let [[pre post] (split n xs)] - (#.Item pre (chunk n post))))) + (let [[pre post] (split size list)] + (#.Item pre (chunk size post))))) (def: #export (repeat n x) {#.doc "A list of the value x, repeated n times."} @@ -234,7 +235,7 @@ (all check xs'))))) (def: #export (find predicate xs) - {#.doc "Returns the first value in the list for which the predicate is #1."} + {#.doc "Yields the first value in the list that satisfies the predicate."} (All [a] (-> (Predicate a) (List a) (Maybe a))) (..one (function (_ value) @@ -374,6 +375,7 @@ (def: join (|>> reverse (fold compose identity)))) (def: #export (sort < xs) + {#.doc (doc "A list ordered by a comparison function.")} (All [a] (-> (-> a a Bit) (List a) (List a))) (case xs #.End @@ -418,8 +420,8 @@ (#.Item x xs') (#.Some <side>)))] - [head a x "Returns the first element of a list."] - [tail (List a) xs' "For a list of size N, returns the N-1 elements after the first one."] + [head a x "Yields the first element of a list."] + [tail (List a) xs' "For a list of size N, yields the N-1 elements after the first one."] ) (def: #export (indices size) @@ -433,7 +435,7 @@ (-> Text Code) [["" 0 0] (#.Identifier "" name)]) -(def: (nat@encode value) +(def: (nat\encode value) (-> Nat Text) (loop [input value output ""] @@ -459,13 +461,14 @@ {#.doc (doc "Create list zippers with the specified number of input lists." (def: #export zipped/2 (zipped 2)) (def: #export zipped/3 (zipped 3)) + (zipped/3 xs ys zs) ((zipped 3) xs ys zs))} (case tokens (^ (list [_ (#.Nat num_lists)])) (if (n.> 0 num_lists) (let [(^open ".") ..functor indices (..indices num_lists) - type_vars (: (List Code) (map (|>> nat@encode identifier$) indices)) + type_vars (: (List Code) (map (|>> nat\encode identifier$) indices)) zipped_type (` (All [(~+ type_vars)] (-> (~+ (map (: (-> Code Code) (function (_ var) (` (List (~ var))))) type_vars)) @@ -473,7 +476,7 @@ vars+lists (|> indices (map inc) (map (function (_ idx) - (let [base (nat@encode idx)] + (let [base (nat\encode idx)] [(identifier$ base) (identifier$ ("lux text concat" base "'"))])))) pattern (` [(~+ (map (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) @@ -503,6 +506,7 @@ {#.doc (doc "Create list zippers with the specified number of input lists." (def: #export zipped_with/2 (zipped_with 2)) (def: #export zipped_with/3 (zipped_with 3)) + (zipped_with/2 + xs ys) ((zipped_with 2) + xs ys))} (case tokens (^ (list [_ (#.Nat num_lists)])) @@ -511,7 +515,7 @@ indices (..indices num_lists) g!return_type (identifier$ "0return_type0") g!func (identifier$ "0func0") - type_vars (: (List Code) (map (|>> nat@encode identifier$) indices)) + type_vars (: (List Code) (map (|>> nat\encode identifier$) indices)) zipped_type (` (All [(~+ type_vars) (~ g!return_type)] (-> (-> (~+ type_vars) (~ g!return_type)) (~+ (map (: (-> Code Code) (function (_ var) (` (List (~ var))))) @@ -520,7 +524,7 @@ vars+lists (|> indices (map inc) (map (function (_ idx) - (let [base (nat@encode idx)] + (let [base (nat\encode idx)] [(identifier$ base) (identifier$ ("lux text concat" base "'"))])))) pattern (` [(~+ (map (function (_ [v vs]) (` (#.Item (~ v) (~ vs)))) @@ -559,8 +563,8 @@ (last xs'))) (def: #export (inits xs) - {#.doc (doc "For a list of size N, returns the first N-1 elements." - "Empty lists will result in a #.None value being returned instead.")} + {#.doc (doc "For a list of size N, yields the first N-1 elements." + "Will yield a #.None for empty lists.")} (All [a] (-> (List a) (Maybe (List a)))) (case xs #.End @@ -578,11 +582,13 @@ (#.Some (#.Item x tail))) )) -(def: #export (concat xss) +(def: #export concat + {#.doc (doc "The sequential combination of all the lists.")} (All [a] (-> (List (List a)) (List a))) - (\ ..monad join xss)) + (\ ..monad join)) (implementation: #export (with monad) + {#.doc (doc "Enhances a monad with List functionality.")} (All [M] (-> (Monad M) (Monad (All [a] (M (List a)))))) (def: &functor (functor.compose (get@ #monad.&functor monad) ..functor)) @@ -600,6 +606,7 @@ (in (concat lla))))) (def: #export (lift monad) + {#.doc (doc "Wraps a monadic value with List machinery.")} (All [M a] (-> (Monad M) (-> (M a) (M (List a))))) (\ monad map (\ ..monad in))) diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index 5fc4b333d..8a0b6d08b 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -12,6 +12,7 @@ ["n" nat]]]]]) (type: #export (Queue a) + {#.doc (doc "A first-in, first-out sequential data-structure.")} {#front (List a) #rear (List a)}) @@ -31,6 +32,7 @@ (list\compose front (list.reverse rear)))) (def: #export peek + {#.doc (doc "Yields the first value in the queue, if any.")} (All [a] (-> (Queue a) (Maybe a))) (|>> (get@ #front) list.head)) diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index a53c7fb0e..b5bbcbe30 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -62,7 +62,7 @@ (def: full_node_size Nat - (i64.left_shift branching_exponent 1)) + (i64.left_shifted branching_exponent 1)) (def: branch_idx_mask Nat @@ -81,8 +81,8 @@ (if (n.< full_node_size row_size) 0 (|> (dec row_size) - (i64.right_shift branching_exponent) - (i64.left_shift branching_exponent)))) + (i64.right_shifted branching_exponent) + (i64.left_shifted branching_exponent)))) (def: (new_path level tail) (All [a] (-> Level (Base a) (Node a))) @@ -99,7 +99,7 @@ (def: (push_tail size level tail parent) (All [a] (-> Nat Level (Base a) (Hierarchy a) (Hierarchy a))) - (let [sub_idx (branch_idx (i64.right_shift level (dec size))) + (let [sub_idx (branch_idx (i64.right_shifted level (dec size))) ## If we're currently on a bottom node sub_node (if (n.= branching_exponent level) ## Just add the tail to it @@ -128,7 +128,7 @@ (def: (put' level idx val hierarchy) (All [a] (-> Level Index a (Hierarchy a) (Hierarchy a))) - (let [sub_idx (branch_idx (i64.right_shift level idx))] + (let [sub_idx (branch_idx (i64.right_shifted level idx))] (case (array.read sub_idx hierarchy) (#.Some (#Hierarchy sub_node)) (|> (array.clone hierarchy) @@ -146,7 +146,7 @@ (def: (pop_tail size level hierarchy) (All [a] (-> Nat Level (Hierarchy a) (Maybe (Hierarchy a)))) - (let [sub_idx (branch_idx (i64.right_shift level (n.- 2 size)))] + (let [sub_idx (branch_idx (i64.right_shifted level (n.- 2 size)))] (cond (n.= 0 sub_idx) #.None @@ -183,6 +183,7 @@ #.End)))) (type: #export (Row a) + {#.doc (doc "A sequential data-structure with fast random access.")} {#level Level #size Nat #root (Hierarchy a) @@ -211,8 +212,8 @@ ## Otherwise, push tail into the tree ## -------------------------------------------------------- ## Will the root experience an overflow with this addition? - (|> (if (n.> (i64.left_shift (get@ #level row) 1) - (i64.right_shift branching_exponent row_size)) + (|> (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. (|> row @@ -241,6 +242,7 @@ (exception: base_was_not_found) (def: #export (within_bounds? row idx) + {#.doc (doc "Determines whether the index is within the bounds of the row.")} (All [a] (-> (Row a) Nat Bit)) (n.< (get@ #size row) idx)) @@ -252,7 +254,7 @@ (loop [level (get@ #level row) hierarchy (get@ #root row)] (case [(n.> branching_exponent level) - (array.read (branch_idx (i64.right_shift level idx)) hierarchy)] + (array.read (branch_idx (i64.right_shifted level idx)) hierarchy)] [#1 (#.Some (#Hierarchy sub))] (recur (level_down level) sub) @@ -319,8 +321,8 @@ [new_tail (base_for (n.- 2 row_size) row) #let [[level' root'] (let [init_level (get@ #level row)] (loop [level init_level - root (maybe.default (new_hierarchy []) - (pop_tail row_size init_level (get@ #root row)))] + root (maybe.else (new_hierarchy []) + (pop_tail row_size init_level (get@ #root row)))] (if (n.> branching_exponent level) (case [(array.read 1 root) (array.read 0 root)] [#.None (#.Some (#Hierarchy sub_node))] @@ -358,7 +360,7 @@ (syntax: #export (row {elems (p.some s.any)}) {#.doc (doc "Row literals." - (row +10 +20 +30 +40))} + (row 12 34 56 78 90))} (in (list (` (..of_list (list (~+ elems))))))) (implementation: (node_equivalence Equivalence<a>) diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index d36ca16c4..4105e22e5 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -104,6 +104,7 @@ (//.pending [x (unfold step next)]))) (def: #export (only predicate sequence) + {#.doc (doc "A new sequence only with items that satisfy the predicate.")} (All [a] (-> (-> a Bit) (Sequence a) (Sequence a))) (let [[head tail] (//.run sequence)] (if (predicate head) diff --git a/stdlib/source/library/lux/data/collection/set.lux b/stdlib/source/library/lux/data/collection/set.lux index 27049802d..6c0c58a65 100644 --- a/stdlib/source/library/lux/data/collection/set.lux +++ b/stdlib/source/library/lux/data/collection/set.lux @@ -16,6 +16,8 @@ ["#" dictionary (#+ Dictionary)]]) (type: #export (Set a) + {#.doc (doc "An un-ordered data-structure with unique items." + "This means there is no repetition/duplication among the items.")} (Dictionary a Any)) (def: #export member_hash diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index 155217b81..fdbbe7b1b 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -57,7 +57,7 @@ (def: #export (multiplicity set elem) (All [a] (-> (Set a) a Nat)) - (|> set :representation (dictionary.get elem) (maybe.default 0))) + (|> set :representation (dictionary.get elem) (maybe.else 0))) (def: #export to_list (All [a] (-> (Set a) (List a))) diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux index 53b608c2c..3f720d9ac 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -13,6 +13,8 @@ (abstract: #export (Stack a) (List a) + {#.doc (doc "A first-in, last-out sequential data-structure.")} + (def: #export empty Stack (:abstraction (list))) @@ -26,6 +28,7 @@ (|>> :representation //.empty?)) (def: #export (peek stack) + {#.doc (doc "Yields the top value in the stack, if any.")} (All [a] (-> (Stack a) (Maybe a))) (case (:representation stack) #.End diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux index 7a14946c5..23a957fb7 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -17,14 +17,16 @@ ["." code]]]]) (type: #export (Tree a) + {#.doc (doc "A generic tree data-structure.")} {#value a #children (List (Tree a))}) -(def: #export (flatten tree) +(def: #export (flat tree) + {#.doc (doc "All the leaf values of the tree, in order.")} (All [a] (-> (Tree a) (List a))) (|> tree (get@ #children) - (list\map flatten) + (list\map flat) list\join (#.Item (get@ #value tree)))) @@ -49,16 +51,16 @@ <>.rec <>.some <code>.record - (<>.default (list)) + (<>.else (list)) (<>.and <code>.any))) (syntax: #export (tree {root tree^}) {#.doc (doc "Tree literals." (: (Tree Nat) - (tree 10 - {20 {} - 30 {} - 40 {}})))} + (tree 12 + {34 {} + 56 {} + 78 {90 {}}})))} (in (list (` (~ (loop [[value children] root] (` {#value (~ value) #children (list (~+ (list\map recur children)))}))))))) diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux index 68cf97171..325d94db0 100644 --- a/stdlib/source/library/lux/data/color.lux +++ b/stdlib/source/library/lux/data/color.lux @@ -79,8 +79,8 @@ (def: (hash value) (let [[r g b] (:representation value)] ($_ i64.or - (i64.left_shift 16 r) - (i64.left_shift 8 g) + (i64.left_shifted 16 r) + (i64.left_shifted 8 g) b)))) (def: #export black diff --git a/stdlib/source/library/lux/data/color/named.lux b/stdlib/source/library/lux/data/color/named.lux index 8eb01d331..459ab6db8 100644 --- a/stdlib/source/library/lux/data/color/named.lux +++ b/stdlib/source/library/lux/data/color/named.lux @@ -1,16 +1,37 @@ (.module: [library [lux #* + [control + ["<>" parser + ["<.>" code]]] + [data + ["." text + ["%" format (#+ format)]]] + [macro + ["." syntax (#+ syntax:)] + ["." code]] [math [number (#+ hex)]]]] ["." // (#+ Color)]) +(syntax: (documentation {<red> <code>.text} + {<green> <code>.text} + {<blue> <code>.text} + {<name> <code>.local_identifier}) + (|> <name> + (text.replace_all "_" " ") + (format <red> <green> <blue> " | ") + code.text + list + in)) + (template [<red> <green> <blue> <name>] - [(def: #export <name> - Color - (//.of_rgb {#//.red (hex <red>) - #//.green (hex <green>) - #//.blue (hex <blue>)}))] + [(`` (def: #export <name> + {#.doc (doc (~~ (..documentation <red> <green> <blue> <name>)))} + Color + (//.of_rgb {#//.red (hex <red>) + #//.green (hex <green>) + #//.blue (hex <blue>)})))] ["F0" "F8" "FF" alice_blue] ["FA" "EB" "D7" antique_white] diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux index b12e9f2e1..b2464a488 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -33,16 +33,20 @@ (|>> (n.* i64.bits_per_byte) i64.mask)) (type: #export Mutation + {#.doc (doc "A mutation of binary data, tracking where in the data to transform.")} (-> [Offset Binary] [Offset Binary])) (type: #export Specification + {#.doc (doc "A description of how to transform binary data.")} [Size Mutation]) (def: #export no_op + {#.doc (doc "A specification for empty binary data.")} Specification [0 function.identity]) (def: #export (instance [size mutation]) + {#.doc (doc "Given a specification of how to construct binary data, yields a binary blob that matches it.")} (-> Specification Binary) (|> size binary.create [0] mutation product.right)) @@ -57,9 +61,11 @@ (|>> mutL mutR)])) (type: #export (Writer a) + {#.doc (doc "An operation that knows how to write information into a binary blob.")} (-> a Specification)) (def: #export (run writer value) + {#.doc (doc "Yields a binary blob with all the information written to it.")} (All [a] (-> (Writer a) a Binary)) (..instance (writer value))) @@ -104,6 +110,7 @@ (\ ..monoid compose (pre preV) (post postV)))) (def: #export (rec body) + {#.doc (doc "A combinator for recursive writers.")} (All [a] (-> (-> (Writer a) (Writer a)) (Writer a))) (function (recur value) (body recur value))) @@ -129,6 +136,7 @@ (|>> frac.to_bits ..bits/64)) (def: #export (segment size) + {#.doc (doc "Writes at most 'size' bytes of an input binary blob.")} (-> Nat (Writer Binary)) (function (_ value) [size diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux index f2f991da2..a3ff932e7 100644 --- a/stdlib/source/library/lux/data/format/css.lux +++ b/stdlib/source/library/lux/data/format/css.lux @@ -58,9 +58,9 @@ (list))] (|> (list& ["font-family" (get@ #/font.family font)] ["src" (format "url(" (get@ #/font.source font) ")")] - ["font-stretch" (|> font (get@ #/font.stretch) (maybe.default /value.normal_stretch) /value.value)] - ["font-style" (|> font (get@ #/font.style) (maybe.default /value.normal_style) /value.value)] - ["font-weight" (|> font (get@ #/font.weight) (maybe.default /value.normal_weight) /value.value)] + ["font-stretch" (|> font (get@ #/font.stretch) (maybe.else /value.normal_stretch) /value.value)] + ["font-style" (|> font (get@ #/font.style) (maybe.else /value.normal_style) /value.value)] + ["font-weight" (|> font (get@ #/font.weight) (maybe.else /value.normal_weight) /value.value)] with_unicode) (list\map (function (_ [property value]) (format property ": " value ";"))) diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index e49c06687..cff3affb0 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -1025,8 +1025,8 @@ (Value Filter)) (|> (list (:representation horizontal) (:representation vertical) - (|> blur (maybe.default ..default_shadow_length) :representation) - (|> spread (maybe.default ..default_shadow_length) :representation) + (|> blur (maybe.else ..default_shadow_length) :representation) + (|> spread (maybe.else ..default_shadow_length) :representation) (:representation color)) (text.join_with " ") (list) @@ -1101,8 +1101,8 @@ (list))] (|> (list& (:representation horizontal) (:representation vertical) - (|> blur (maybe.default ..default_shadow_length) :representation) - (|> spread (maybe.default ..default_shadow_length) :representation) + (|> blur (maybe.else ..default_shadow_length) :representation) + (|> spread (maybe.else ..default_shadow_length) :representation) (:representation color) with_inset) (text.join_with " ") @@ -1196,7 +1196,7 @@ (-> (List (List (Maybe (Value Grid)))) (Value Grid_Template)) (let [empty (: (Value Grid) (:abstraction "."))] - (|>> (list\map (|>> (list\map (|>> (maybe.default empty) + (|>> (list\map (|>> (list\map (|>> (maybe.else empty) :representation)) (text.join_with ..grid_column_separator) (text.enclosed ["'" "'"]))) diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index 419096680..6bbef9f5b 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -188,7 +188,7 @@ (-> Attributes (Maybe Script) Meta) (|> inline (maybe\map js.code) - (maybe.default "") + (maybe.else "") (..raw "script" attributes))) (def: #export text @@ -316,7 +316,7 @@ (-> Attributes Media (Maybe Content) Element) (..tag <tag> attributes (|> on_unsupported - (maybe.default (..text "")) + (maybe.else (..text "")) (..and media))))] [audio "audio"] @@ -357,7 +357,7 @@ [(def: #export (<name> attributes content) (-> Attributes (Maybe Content) <type>) (|> content - (maybe.default (..text "")) + (maybe.else (..text "")) (..tag <tag> attributes)))] [text_area "textarea" Input] diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index 8f3293e56..daac4e81d 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -184,11 +184,11 @@ (and (n.= (row.size xs) (row.size ys)) (list\fold (function (_ idx prev) (and prev - (maybe.default #0 - (do maybe.monad - [x' (row.nth idx xs) - y' (row.nth idx ys)] - (in (= x' y')))))) + (maybe.else #0 + (do maybe.monad + [x' (row.nth idx xs) + y' (row.nth idx ys)] + (in (= x' y')))))) #1 (list.indices (row.size xs)))) @@ -241,22 +241,22 @@ Text <token>)] - ["," separator] + ["," value_separator] [":" entry_separator] - ["[" open_array] - ["]" close_array] + ["[" array_start] + ["]" array_end] - ["{" open_object] - ["}" close_object] + ["{" object_start] + ["}" object_end] ) (def: (array_format format) (-> (-> JSON Text) (-> Array Text)) (|>> (row\map format) row.to_list - (text.join_with ..separator) - (text.enclosed [..open_array ..close_array]))) + (text.join_with ..value_separator) + (text.enclosed [..array_start ..array_end]))) (def: (kv_format format [key value]) (-> (-> JSON Text) (-> [String JSON] Text)) @@ -270,8 +270,8 @@ (-> (-> JSON Text) (-> Object Text)) (|>> dictionary.entries (list\map (..kv_format format)) - (text.join_with ..separator) - (text.enclosed [..open_object ..close_object]))) + (text.join_with ..value_separator) + (text.enclosed [..object_start ..object_end]))) (def: #export (format json) (-> JSON Text) @@ -295,11 +295,11 @@ (Parser Text) (<text>.some <text>.space)) -(def: separator_parser +(def: value_separator_parser (Parser [Text Any Text]) ($_ <>.and ..space_parser - (<text>.this ..separator) + (<text>.this ..value_separator) ..space_parser)) (def: null_parser @@ -330,16 +330,16 @@ (do {! <>.monad} [signed? (<>.parses? (<text>.this "-")) digits (<text>.many <text>.decimal) - decimals (<>.default "0" - (do ! - [_ (<text>.this ".")] - (<text>.many <text>.decimal))) - exp (<>.default "" - (do ! - [mark (<text>.one_of "eE") - signed?' (<>.parses? (<text>.this "-")) - offset (<text>.many <text>.decimal)] - (in ($_ text\compose mark (if signed?' "-" "") offset))))] + decimals (<>.else "0" + (do ! + [_ (<text>.this ".")] + (<text>.many <text>.decimal))) + exp (<>.else "" + (do ! + [mark (<text>.one_of "eE") + signed?' (<>.parses? (<text>.this "-")) + offset (<text>.many <text>.decimal)] + (in ($_ text\compose mark (if signed?' "-" "") offset))))] (case (f\decode ($_ text\compose (if signed? "-" "") digits "." decimals exp)) (#try.Failure message) (<>.failure message) @@ -395,13 +395,13 @@ (do <>.monad [_ (<text>.this <open>) _ space_parser - elems (<>.separated_by ..separator_parser <elem_parser>) + elems (<>.separated_by ..value_separator_parser <elem_parser>) _ space_parser _ (<text>.this <close>)] (in (<prep> elems))))] - [array_parser Array ..open_array ..close_array json_parser row.of_list] - [object_parser Object ..open_object ..close_object (kv_parser json_parser) (dictionary.of_list text.hash)] + [array_parser Array ..array_start ..array_end json_parser row.of_list] + [object_parser Object ..object_start ..object_end (kv_parser json_parser) (dictionary.of_list text.hash)] ) (def: json_parser diff --git a/stdlib/source/library/lux/data/lazy.lux b/stdlib/source/library/lux/data/lazy.lux index 016a5a18a..d3283cfc8 100644 --- a/stdlib/source/library/lux/data/lazy.lux +++ b/stdlib/source/library/lux/data/lazy.lux @@ -20,7 +20,7 @@ (abstract: #export (Lazy a) (-> [] a) - (def: (freeze' generator) + (def: (lazy' generator) (All [a] (-> (-> [] a) (Lazy a))) (let [cache (atom.atom #.None)] (:abstraction (function (_ _) @@ -33,36 +33,37 @@ (exec (io.run (atom.compare_and_swap _ (#.Some value) cache)) value))))))) - (def: #export (thaw l_value) + (def: #export (value l_value) (All [a] (-> (Lazy a) a)) ((:representation l_value) []))) -(syntax: #export (freeze expr) +(syntax: #export (lazy expr) (with_gensyms [g!_] - (in (list (` ((~! freeze') (function ((~ g!_) (~ g!_)) (~ expr)))))))) + (in (list (` ((~! lazy') (function ((~ g!_) (~ g!_)) (~ expr)))))))) (implementation: #export (equivalence (^open "_\.")) (All [a] (-> (Equivalence a) (Equivalence (Lazy a)))) (def: (= left right) - (_\= (..thaw left) (..thaw right)))) + (_\= (..value left) + (..value right)))) (implementation: #export functor (Functor Lazy) (def: (map f fa) - (freeze (f (thaw fa))))) + (lazy (f (value fa))))) (implementation: #export apply (Apply Lazy) (def: &functor ..functor) (def: (apply ff fa) - (freeze ((thaw ff) (thaw fa))))) + (lazy ((value ff) (value fa))))) (implementation: #export monad (Monad Lazy) (def: &functor ..functor) - (def: in (|>> freeze)) - (def: join thaw)) + (def: in (|>> lazy)) + (def: join value)) diff --git a/stdlib/source/library/lux/data/maybe.lux b/stdlib/source/library/lux/data/maybe.lux index 155254f2e..b0cf1960e 100644 --- a/stdlib/source/library/lux/data/maybe.lux +++ b/stdlib/source/library/lux/data/maybe.lux @@ -114,14 +114,14 @@ (All [M a] (-> (Monad M) (-> (M a) (M (Maybe a))))) (\ monad map (\ ..monad in))) -(macro: #export (default tokens state) +(macro: #export (else tokens state) {#.doc (doc "Allows you to provide a default value that will be used" "if a (Maybe x) value turns out to be #.None." "Note: the expression for the default value will not be computed if the base computation succeeds." - (default +20 (#.Some +10)) + (else +20 (#.Some +10)) "=>" +10 - (default +20 #.None) + (else +20 #.None) "=>" +20)} (case tokens @@ -135,11 +135,11 @@ (~ else))))])) _ - (#.Left "Wrong syntax for default"))) + (#.Left "Wrong syntax for else"))) (def: #export assume (All [a] (-> (Maybe a) a)) - (|>> (..default (undefined)))) + (|>> (..else (undefined)))) (def: #export (to_list value) (All [a] (-> (Maybe a) (List a))) diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index d9abb0f48..b60a1f797 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -191,7 +191,7 @@ (def: #export (replace_once pattern replacement template) (-> Text Text Text Text) - (<| (maybe.default template) + (<| (maybe.else template) (do maybe.monad [[pre post] (..split_with pattern template)] (in ($_ "lux text concat" pre replacement post))))) @@ -289,7 +289,7 @@ (if (n.< length idx) (recur (inc idx) (|> hash - (i64.left_shift 5) + (i64.left_shifted 5) (n.- hash) (n.+ ("lux text char" idx input)))) hash)))))) @@ -333,7 +333,7 @@ _ false)))) -(def: #export (lower_case value) +(def: #export (lower_cased value) (-> Text Text) (for {@.old (:as Text @@ -356,7 +356,7 @@ (:as Text ("ruby object do" "downcase" value))})) -(def: #export (upper_case value) +(def: #export (upper_cased value) (-> Text Text) (for {@.old (:as Text diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index 691fccad7..ccbb1417a 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -220,7 +220,7 @@ quantifier (<text>.one_of "?*+")] (case quantifier "?" - (in (` (<>.default "" (~ base)))) + (in (` (<>.else "" (~ base)))) "*" (in (` ((~! join_text^) (<>.some (~ base))))) @@ -498,6 +498,6 @@ (with_gensyms [g!temp] (in (list& (` (^multi (~ g!temp) {((~! <text>.run) (..regex (~ (code.text pattern))) (~ g!temp)) - (#try.Success (~ (maybe.default g!temp bindings)))})) + (#try.Success (~ (maybe.else g!temp bindings)))})) body branches)))) diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux index 24ddb34e2..e67eb3ae3 100644 --- a/stdlib/source/library/lux/data/text/unicode/block.lux +++ b/stdlib/source/library/lux/data/text/unicode/block.lux @@ -68,7 +68,7 @@ (def: &equivalence ..equivalence) (def: (hash value) - (i64.or (i64.left_shift 32 (..start value)) + (i64.or (i64.left_shifted 32 (..start value)) (..end value)))) (template [<name> <start> <end>] diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 2e6b46b4f..669bcbad3 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -559,7 +559,7 @@ (syntax: #export (here {targets (: (<code>.Parser (List Target)) (|> ..target <>.some - (<>.default (list))))}) + (<>.else (list))))}) (do {! meta.monad} [location meta.location locals meta.locals diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux index 81ecf4d82..0b641a3a6 100644 --- a/stdlib/source/library/lux/ffi.js.lux +++ b/stdlib/source/library/lux/ffi.js.lux @@ -186,9 +186,9 @@ (def: import (Parser Import) (<>.or (<>.and ..class_declaration - (<>.default ["" (list)] - (<code>.tuple (<>.and <code>.text - (<>.some member))))) + (<>.else ["" (list)] + (<code>.tuple (<>.and <code>.text + (<>.some member))))) (<code>.form ..common_method))) (def: (with_io with? without) @@ -280,7 +280,7 @@ (#Method method) (case method (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.default method alias)) + (..make_function (qualify (maybe.else method alias)) g!temp (%.format real_class "." method) inputsT @@ -290,7 +290,7 @@ (#Virtual [method alias inputsT io? try? outputT]) (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.default method alias))) + (` (def: ((~ (qualify (maybe.else method alias))) [(~+ (list\map product.right g!inputs))] (~ g!object)) (All [(~+ class_parameters)] @@ -310,7 +310,7 @@ members))))) (#Function [name alias inputsT io? try? outputT]) - (in (list (..make_function (code.local_identifier (maybe.default name alias)) + (in (list (..make_function (code.local_identifier (maybe.else name alias)) g!temp name inputsT diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index ba8499262..c5080d912 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -713,11 +713,11 @@ (Parser (List Annotation)) (do <>.monad [anns?? (<>.maybe ..annotations^')] - (in (maybe.default (list) anns??)))) + (in (maybe.else (list) anns??)))) (def: (throws_decl^ type_vars) (-> (List (Type Var)) (Parser (List (Type Class)))) - (<| (<>.default (list)) + (<| (<>.else (list)) (do <>.monad [_ (<code>.this! (' #throws))] (<code>.tuple (<>.some (..class^ type_vars)))))) @@ -725,7 +725,7 @@ (def: (method_decl^ type_vars) (-> (List (Type Var)) (Parser [Member_Declaration MethodDecl])) (<code>.form (do <>.monad - [tvars (<>.default (list) ..vars^) + [tvars (<>.else (list) ..vars^) #let [total_vars (list\compose tvars type_vars)] name <code>.local_identifier anns ..annotations^ @@ -783,7 +783,7 @@ (<code>.form (do <>.monad [pm privacy_modifier^ strict_fp? (<>.parses? (<code>.this! (' #strict))) - method_vars (<>.default (list) ..vars^) + method_vars (<>.else (list) ..vars^) #let [total_vars (list\compose class_vars method_vars)] [_ self_name arguments] (<code>.form ($_ <>.and (<code>.this! (' new)) @@ -804,7 +804,7 @@ [pm privacy_modifier^ strict_fp? (<>.parses? (<code>.this! (' #strict))) final? (<>.parses? (<code>.this! (' #final))) - method_vars (<>.default (list) ..vars^) + method_vars (<>.else (list) ..vars^) #let [total_vars (list\compose class_vars method_vars)] [name self_name arguments] (<code>.form ($_ <>.and <code>.local_identifier @@ -824,7 +824,7 @@ (<code>.form (do <>.monad [strict_fp? (<>.parses? (<code>.this! (' #strict))) owner_class ..declaration^ - method_vars (<>.default (list) ..vars^) + method_vars (<>.else (list) ..vars^) #let [total_vars (list\compose (product.right (parser.declaration owner_class)) method_vars)] [name self_name arguments] (<code>.form ($_ <>.and @@ -846,7 +846,7 @@ [pm privacy_modifier^ strict_fp? (<>.parses? (<code>.this! (' #strict))) _ (<code>.this! (' #static)) - method_vars (<>.default (list) ..vars^) + method_vars (<>.else (list) ..vars^) #let [total_vars method_vars] [name arguments] (<code>.form (<>.and <code>.local_identifier (..arguments^ total_vars))) @@ -864,7 +864,7 @@ (<code>.form (do <>.monad [pm privacy_modifier^ _ (<code>.this! (' #abstract)) - method_vars (<>.default (list) ..vars^) + method_vars (<>.else (list) ..vars^) #let [total_vars method_vars] [name arguments] (<code>.form (<>.and <code>.local_identifier (..arguments^ total_vars))) @@ -881,7 +881,7 @@ (<code>.form (do <>.monad [pm privacy_modifier^ _ (<code>.this! (' #native)) - method_vars (<>.default (list) ..vars^) + method_vars (<>.else (list) ..vars^) #let [total_vars method_vars] [name arguments] (<code>.form (<>.and <code>.local_identifier (..arguments^ total_vars))) @@ -948,15 +948,15 @@ enum_members (<>.some <code>.local_identifier)] (in (#EnumDecl enum_members)))) (<code>.form (do <>.monad - [tvars (<>.default (list) ..vars^) + [tvars (<>.else (list) ..vars^) _ (<code>.identifier! ["" "new"]) ?alias import_member_alias^ #let [total_vars (list\compose owner_vars tvars)] ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^] - (in (#ConstructorDecl [{#import_member_mode (maybe.default #AutoPrM ?prim_mode) - #import_member_alias (maybe.default "new" ?alias) + (in (#ConstructorDecl [{#import_member_mode (maybe.else #AutoPrM ?prim_mode) + #import_member_alias (maybe.else "new" ?alias) #import_member_kind #VirtualIMK #import_member_tvars tvars #import_member_args args @@ -969,7 +969,7 @@ [kind (: (Parser ImportMethodKind) (<>.or (<code>.tag! ["" "static"]) (in []))) - tvars (<>.default (list) ..vars^) + tvars (<>.else (list) ..vars^) name <code>.local_identifier ?alias import_member_alias^ #let [total_vars (list\compose owner_vars tvars)] @@ -977,8 +977,8 @@ args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^ return (..return^ total_vars)] - (in (#MethodDecl [{#import_member_mode (maybe.default #AutoPrM ?prim_mode) - #import_member_alias (maybe.default name ?alias) + (in (#MethodDecl [{#import_member_mode (maybe.else #AutoPrM ?prim_mode) + #import_member_alias (maybe.else name ?alias) #import_member_kind kind #import_member_tvars tvars #import_member_args args @@ -994,7 +994,7 @@ gtype (..type^ owner_vars) maybe? (<>.parses? (<code>.this! (' #?))) setter? (<>.parses? (<code>.this! (' #!)))] - (in (#FieldAccessDecl {#import_field_mode (maybe.default #AutoPrM ?prim_mode) + (in (#FieldAccessDecl {#import_field_mode (maybe.else #AutoPrM ?prim_mode) #import_field_name name #import_field_static? static? #import_field_maybe? maybe? @@ -1204,10 +1204,10 @@ {#let [! <>.monad]} {im inheritance_modifier^} {[full_class_name class_vars] (\ ! map parser.declaration ..declaration^)} - {super (<>.default $Object - (class^ class_vars))} - {interfaces (<>.default (list) - (<code>.tuple (<>.some (class^ class_vars))))} + {super (<>.else $Object + (class^ class_vars))} + {interfaces (<>.else (list) + (<code>.tuple (<>.some (class^ class_vars))))} {annotations ..annotations^} {fields (<>.some (..field_decl^ class_vars))} {methods (<>.some (..method_def^ class_vars))}) @@ -1260,8 +1260,8 @@ (syntax: #export (interface: {#let [! <>.monad]} {[full_class_name class_vars] (\ ! map parser.declaration ..declaration^)} - {supers (<>.default (list) - (<code>.tuple (<>.some (class^ class_vars))))} + {supers (<>.else (list) + (<code>.tuple (<>.some (class^ class_vars))))} {annotations ..annotations^} {members (<>.some (..method_decl^ class_vars))}) {#.doc (doc "Allows defining JVM interfaces." @@ -1275,10 +1275,10 @@ (syntax: #export (object {class_vars ..vars^} - {super (<>.default $Object - (class^ class_vars))} - {interfaces (<>.default (list) - (<code>.tuple (<>.some (class^ class_vars))))} + {super (<>.else $Object + (class^ class_vars))} + {interfaces (<>.else (list) + (<code>.tuple (<>.some (class^ class_vars))))} {constructor_args (..constructor_args^ class_vars)} {methods (<>.some ..overriden_method_def^)}) {#.doc (doc "Allows defining anonymous classes." diff --git a/stdlib/source/library/lux/ffi.lua.lux b/stdlib/source/library/lux/ffi.lua.lux index 7a4825ea7..c004b3145 100644 --- a/stdlib/source/library/lux/ffi.lua.lux +++ b/stdlib/source/library/lux/ffi.lua.lux @@ -1,8 +1,8 @@ (.module: [library [lux #* - ["." meta] ["@" target] + ["." meta] [abstract [monad (#+ do)]] [control @@ -164,9 +164,9 @@ (def: import ($_ <>.or (<>.and <code>.local_identifier - (<>.default ["" (list)] - (<code>.tuple (<>.and <code>.text - (<>.some member))))) + (<>.else ["" (list)] + (<code>.tuple (<>.and <code>.text + (<>.some member))))) (<code>.form ..common_method) ..constant )) @@ -257,7 +257,7 @@ (#Method method) (case method (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.default method alias)) + (..make_function (qualify (maybe.else method alias)) g!temp (` ("lua object get" (~ (code.text method)) (:as (..Object .Any) (~ imported)))) @@ -268,7 +268,7 @@ (#Virtual [method alias inputsT io? try? outputT]) (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.default method alias))) + (` (def: ((~ (qualify (maybe.else method alias))) [(~+ (list\map product.right g!inputs))] (~ g!object)) (-> [(~+ (list\map nilable_type inputsT))] @@ -287,7 +287,7 @@ members))))) (#Function [name alias inputsT io? try? outputT]) - (in (list (..make_function (code.local_identifier (maybe.default name alias)) + (in (list (..make_function (code.local_identifier (maybe.else name alias)) g!temp (` ("lua constant" (~ (code.text (text.replace_all "/" "." name))))) inputsT diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index 16ff216e4..119c1d091 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -589,7 +589,7 @@ (|> ..type_param^ <>.some <code>.tuple - (<>.default (list)))) + (<>.else (list)))) (def: class_decl^ (Parser Class_Declaration) @@ -638,7 +638,7 @@ (Parser (List Annotation)) (do <>.monad [anns?? (<>.maybe ..annotations^')] - (in (maybe.default (list) anns??)))) + (in (maybe.else (list) anns??)))) (def: (throws_decl'^ type_vars) (-> (List Type_Parameter) (Parser (List GenericType))) @@ -650,7 +650,7 @@ (-> (List Type_Parameter) (Parser (List GenericType))) (do <>.monad [exs? (<>.maybe (throws_decl'^ type_vars))] - (in (maybe.default (list) exs?)))) + (in (maybe.else (list) exs?)))) (def: (method_decl^ type_vars) (-> (List Type_Parameter) (Parser [Member_Declaration MethodDecl])) @@ -883,8 +883,8 @@ ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^] - (in (#ConstructorDecl [{#import_member_mode (maybe.default #AutoPrM ?prim_mode) - #import_member_alias (maybe.default "new" ?alias) + (in (#ConstructorDecl [{#import_member_mode (maybe.else #AutoPrM ?prim_mode) + #import_member_alias (maybe.else "new" ?alias) #import_member_kind #VirtualIMK #import_member_tvars tvars #import_member_args args @@ -905,8 +905,8 @@ args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^ return (..generic_type^ total_vars)] - (in (#MethodDecl [{#import_member_mode (maybe.default #AutoPrM ?prim_mode) - #import_member_alias (maybe.default name ?alias) + (in (#MethodDecl [{#import_member_mode (maybe.else #AutoPrM ?prim_mode) + #import_member_alias (maybe.else name ?alias) #import_member_kind kind #import_member_tvars tvars #import_member_args args @@ -923,7 +923,7 @@ gtype (..generic_type^ owner_vars) maybe? (<>.parses? (<code>.this! (' #?))) setter? (<>.parses? (<code>.this! (' #!)))] - (in (#FieldAccessDecl {#import_field_mode (maybe.default #AutoPrM ?prim_mode) + (in (#FieldAccessDecl {#import_field_mode (maybe.else #AutoPrM ?prim_mode) #import_field_name name #import_field_static? static? #import_field_maybe? maybe? @@ -1170,10 +1170,10 @@ {class_decl ..class_decl^} {#let [full_class_name (product.left class_decl)]} {#let [class_vars (product.right class_decl)]} - {super (<>.default object_super_class - (..super_class_decl^ class_vars))} - {interfaces (<>.default (list) - (<code>.tuple (<>.some (..super_class_decl^ class_vars))))} + {super (<>.else object_super_class + (..super_class_decl^ class_vars))} + {interfaces (<>.else (list) + (<code>.tuple (<>.some (..super_class_decl^ class_vars))))} {annotations ..annotations^} {fields (<>.some (..field_decl^ class_vars))} {methods (<>.some (..method_def^ class_vars))}) @@ -1228,8 +1228,8 @@ (syntax: #export (interface: {class_decl ..class_decl^} {#let [class_vars (product.right class_decl)]} - {supers (<>.default (list) - (<code>.tuple (<>.some (..super_class_decl^ class_vars))))} + {supers (<>.else (list) + (<code>.tuple (<>.some (..super_class_decl^ class_vars))))} {annotations ..annotations^} {members (<>.some (..method_decl^ class_vars))}) {#.doc (doc "Allows defining JVM interfaces." @@ -1245,10 +1245,10 @@ (syntax: #export (object {class_vars (<code>.tuple (<>.some ..type_param^))} - {super (<>.default object_super_class - (..super_class_decl^ class_vars))} - {interfaces (<>.default (list) - (<code>.tuple (<>.some (..super_class_decl^ class_vars))))} + {super (<>.else object_super_class + (..super_class_decl^ class_vars))} + {interfaces (<>.else (list) + (<code>.tuple (<>.some (..super_class_decl^ class_vars))))} {constructor_args (..constructor_args^ class_vars)} {methods (<>.some ..overriden_method_def^)}) {#.doc (doc "Allows defining anonymous classes." diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux index c9a0a584c..a8f0a7f06 100644 --- a/stdlib/source/library/lux/ffi.php.lux +++ b/stdlib/source/library/lux/ffi.php.lux @@ -175,9 +175,9 @@ ($_ <>.and <code>.local_identifier (<>.maybe ..alias) - (<>.default ["" (list)] - (<code>.tuple (<>.and <code>.text - (<>.some member))))) + (<>.else ["" (list)] + (<code>.tuple (<>.and <code>.text + (<>.some member))))) (<code>.form ..common_method) ..constant )) @@ -240,10 +240,10 @@ (let [qualify (: (-> Text Code) (function (_ member_name) (|> format - (text.replace_all "#" (maybe.default class alias)) + (text.replace_all "#" (maybe.else class alias)) (text.replace_all "." member_name) code.local_identifier))) - g!type (code.local_identifier (maybe.default class alias)) + g!type (code.local_identifier (maybe.else class alias)) class_import (` ("php constant" (~ (code.text class))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text class)))))) @@ -251,7 +251,7 @@ (case member (#Field [static? field alias fieldT]) (if static? - (` ((~! syntax:) ((~ (qualify (maybe.default field alias)))) + (` ((~! syntax:) ((~ (qualify (maybe.else field alias)))) (\ (~! meta.monad) (~' in) (list (` (.:as (~ (nullable_type fieldT)) ("php constant" (~ (code.text (%.format class "::" field)))))))))) @@ -266,7 +266,7 @@ (#Method method) (case method (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.default method alias)) + (..make_function (qualify (maybe.else method alias)) g!temp (` ("php object get" (~ (code.text method)) (:as (..Object .Any) @@ -278,7 +278,7 @@ (#Virtual [method alias inputsT io? try? outputT]) (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.default method alias))) + (` (def: ((~ (qualify (maybe.else method alias))) [(~+ (list\map product.right g!inputs))] (~ g!object)) (-> [(~+ (list\map nullable_type inputsT))] @@ -298,7 +298,7 @@ (#Function [name alias inputsT io? try? outputT]) (let [imported (` ("php constant" (~ (code.text name))))] - (in (list (..make_function (code.local_identifier (maybe.default name alias)) + (in (list (..make_function (code.local_identifier (maybe.else name alias)) g!temp imported inputsT @@ -308,7 +308,7 @@ (#Constant [_ name alias fieldT]) (let [imported (` ("php constant" (~ (code.text name))))] - (in (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.default name alias)))) + (in (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.else name alias)))) (\ (~! meta.monad) (~' in) (list (` (.:as (~ (nullable_type fieldT)) (~ imported)))))))))) ))) diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux index 436f1c729..5c05710a7 100644 --- a/stdlib/source/library/lux/ffi.py.lux +++ b/stdlib/source/library/lux/ffi.py.lux @@ -166,9 +166,9 @@ (def: import (Parser Import) (<>.or (<>.and <code>.local_identifier - (<>.default ["" (list)] - (<code>.tuple (<>.and <code>.text - (<>.some member))))) + (<>.else ["" (list)] + (<code>.tuple (<>.and <code>.text + (<>.some member))))) (<code>.form ..common_method))) (def: (with_io with? without) @@ -268,7 +268,7 @@ (#Method method) (case method (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.default method alias)) + (..make_function (qualify (maybe.else method alias)) g!temp (` ("python object get" (~ (code.text method)) (:as (..Object .Any) (~ imported)))) @@ -279,7 +279,7 @@ (#Virtual [method alias inputsT io? try? outputT]) (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.default method alias))) + (` (def: ((~ (qualify (maybe.else method alias))) [(~+ (list\map product.right g!inputs))] (~ g!object)) (-> [(~+ (list\map noneable_type inputsT))] @@ -298,7 +298,7 @@ members))))) (#Function [name alias inputsT io? try? outputT]) - (in (list (..make_function (code.local_identifier (maybe.default name alias)) + (in (list (..make_function (code.local_identifier (maybe.else name alias)) g!temp (` ("python constant" (~ (code.text name)))) inputsT diff --git a/stdlib/source/library/lux/ffi.rb.lux b/stdlib/source/library/lux/ffi.rb.lux index d22138957..70c2f21be 100644 --- a/stdlib/source/library/lux/ffi.rb.lux +++ b/stdlib/source/library/lux/ffi.rb.lux @@ -177,9 +177,9 @@ ($_ <>.and <code>.local_identifier (<>.maybe ..alias) - (<>.default ["" (list)] - (<code>.tuple (<>.and <code>.text - (<>.some member))))) + (<>.else ["" (list)] + (<code>.tuple (<>.and <code>.text + (<>.some member))))) (<code>.form ..common_method) ..constant ))) @@ -233,10 +233,10 @@ (let [qualify (: (-> Text Code) (function (_ member_name) (|> format - (text.replace_all "#" (maybe.default class alias)) + (text.replace_all "#" (maybe.else class alias)) (text.replace_all "." member_name) code.local_identifier))) - g!type (code.local_identifier (maybe.default class alias)) + g!type (code.local_identifier (maybe.else class alias)) module_import (: (List Code) (case ?module (#.Some module) @@ -251,7 +251,7 @@ (case member (#Field [static? field alias fieldT]) (if static? - (` ((~! syntax:) ((~ (qualify (maybe.default field alias)))) + (` ((~! syntax:) ((~ (qualify (maybe.else field alias)))) (\ (~! meta.monad) (~' in) (list (` (.:as (~ (nilable_type fieldT)) (.exec @@ -268,7 +268,7 @@ (#Method method) (case method (#Static [method alias inputsT io? try? outputT]) - (..make_function (qualify (maybe.default method alias)) + (..make_function (qualify (maybe.else method alias)) g!temp (` ("ruby object get" (~ (code.text method)) (:as (..Object .Any) @@ -282,7 +282,7 @@ (#Virtual [method alias inputsT io? try? outputT]) (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.default method alias))) + (` (def: ((~ (qualify (maybe.else method alias))) [(~+ (list\map product.right g!inputs))] (~ g!object)) (-> [(~+ (list\map nilable_type inputsT))] @@ -309,7 +309,7 @@ #.None (list))) ("ruby constant" (~ (code.text name)))))] - (in (list (..make_function (code.local_identifier (maybe.default name alias)) + (in (list (..make_function (code.local_identifier (maybe.else name alias)) g!temp imported inputsT @@ -326,7 +326,7 @@ #.None (list))) ("ruby constant" (~ (code.text name)))))] - (in (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.default name alias)))) + (in (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.else name alias)))) (\ (~! meta.monad) (~' in) (list (` (.:as (~ (nilable_type fieldT)) (~ imported)))))))))) ))) diff --git a/stdlib/source/library/lux/ffi.scm.lux b/stdlib/source/library/lux/ffi.scm.lux index dddce2ebc..886f045d1 100644 --- a/stdlib/source/library/lux/ffi.scm.lux +++ b/stdlib/source/library/lux/ffi.scm.lux @@ -204,7 +204,7 @@ (case import (#Function [name alias inputsT io? try? outputT]) (let [imported (` ("scheme constant" (~ (code.text name))))] - (in (list (..make_function (code.local_identifier (maybe.default name alias)) + (in (list (..make_function (code.local_identifier (maybe.else name alias)) g!temp imported inputsT @@ -214,7 +214,7 @@ (#Constant [_ name alias fieldT]) (let [imported (` ("scheme constant" (~ (code.text name))))] - (in (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.default name alias)))) + (in (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.else name alias)))) (\ (~! meta.monad) (~' in) (list (` (.:as (~ (nilable_type fieldT)) (~ imported)))))))))) ))) diff --git a/stdlib/source/library/lux/locale.lux b/stdlib/source/library/lux/locale.lux index 381938c74..e77e88c89 100644 --- a/stdlib/source/library/lux/locale.lux +++ b/stdlib/source/library/lux/locale.lux @@ -26,10 +26,10 @@ (:abstraction (format (language.code language) (|> territory (maybe\map (|>> territory.long_code (format ..territory_separator))) - (maybe.default "")) + (maybe.else "")) (|> encoding (maybe\map (|>> encoding.name (format ..encoding_separator))) - (maybe.default ""))))) + (maybe.else ""))))) (def: #export code (-> Locale Text) diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index 4108f7ced..35744c33f 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -53,7 +53,7 @@ {constructor_args (constructor_args^ imports class_vars)} {methods (some (overriden_method_def^ imports))}) (let [def_code ($_ text\compose "anon-class:" - (spaced (list (super_class_decl$ (maybe.default object_super_class super)) + (spaced (list (super_class_decl$ (maybe.else object_super_class super)) (with_brackets (spaced (list\map super_class_decl$ interfaces))) (with_brackets (spaced (list\map constructor_arg$ constructor_args))) (with_brackets (spaced (list\map (method_def$ id) methods))))))] diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux index c374519b9..1a34bfbf5 100644 --- a/stdlib/source/library/lux/math/number/complex.lux +++ b/stdlib/source/library/lux/math/number/complex.lux @@ -33,8 +33,7 @@ "The imaginary part can be omitted if it's 0." (complex real))} (in (list (` {#..real (~ real) - #..imaginary (~ (maybe.default (' +0.0) - ?imaginary))})))) + #..imaginary (~ (maybe.else (' +0.0) ?imaginary))})))) (def: #export i (..complex +0.0 +1.0)) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index 7b6f4df5d..5576109a7 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -294,16 +294,16 @@ (//i64.and ..exponent_mask)) mantissa_bits (..int mantissa)] ($_ //i64.or - (//i64.left_shift ..sign_offset sign_bit) - (//i64.left_shift ..exponent_offset exponent_bits) + (//i64.left_shifted ..sign_offset sign_bit) + (//i64.left_shifted ..exponent_offset exponent_bits) (//i64.clear ..mantissa_size mantissa_bits))) ))) (template [<getter> <size> <offset>] [(def: <getter> (-> (I64 Any) I64) - (let [mask (|> 1 (//i64.left_shift <size>) dec (//i64.left_shift <offset>))] - (|>> (//i64.and mask) (//i64.right_shift <offset>) .i64)))] + (let [mask (|> 1 (//i64.left_shifted <size>) dec (//i64.left_shifted <offset>))] + (|>> (//i64.and mask) (//i64.right_shifted <offset>) .i64)))] [mantissa ..mantissa_size 0] [exponent ..exponent_size ..mantissa_size] @@ -417,8 +417,8 @@ #let [sign (if negative? 1 0)]] (in (..of_bits ($_ //i64.or - (//i64.left_shift ..sign_offset (.i64 sign)) - (//i64.left_shift ..mantissa_size (.i64 (//int.+ (.int ..double_bias) exponent))) + (//i64.left_shifted ..sign_offset (.i64 sign)) + (//i64.left_shifted ..mantissa_size (.i64 (//int.+ (.int ..double_bias) exponent))) (//i64.clear ..mantissa_size (.i64 mantissa)))))) (#try.Failure ("lux text concat" <error> representation))))))] diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index f11eee2f4..6ddd718ec 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -31,8 +31,8 @@ [(I64 Any) xor "lux i64 xor" "Bitwise xor."] [(I64 Any) and "lux i64 and" "Bitwise and."] - [Nat left_shift "lux i64 left-shift" "Bitwise left-shift."] - [Nat right_shift "lux i64 right-shift" "Unsigned/logic bitwise right-shift."] + [Nat left_shifted "lux i64 left-shift" "Bitwise left-shift."] + [Nat right_shifted "lux i64 right-shift" "Unsigned/logic bitwise right-shift."] ) (type: #export Mask @@ -40,7 +40,7 @@ (def: #export (bit position) (-> Nat Mask) - (|> 1 .i64 (..left_shift (n.% ..width position)))) + (|> 1 .i64 (..left_shifted (n.% ..width position)))) (def: #export sign Mask @@ -65,19 +65,19 @@ 0 ..false bits (case (n.% ..width bits) 0 ..true - bits (|> 1 .i64 (..left_shift (n.% ..width bits)) .dec)))) + bits (|> 1 .i64 (..left_shifted (n.% ..width bits)) .dec)))) (def: (add_shift shift value) (-> Nat Nat Nat) - (|> value (right_shift shift) (n.+ value))) + (|> value (right_shifted shift) (n.+ value))) (def: #export (count subject) {#.doc "Count the number of 1s in a bit-map."} (-> (I64 Any) Nat) - (let [count' (n.- (|> subject (right_shift 1) (..and 6148914691236517205) i64) + (let [count' (n.- (|> subject (right_shifted 1) (..and 6148914691236517205) i64) (i64 subject))] (|> count' - (right_shift 2) (..and 3689348814741910323) (n.+ (..and 3689348814741910323 count')) + (right_shifted 2) (..and 3689348814741910323) (n.+ (..and 3689348814741910323 count')) (add_shift 4) (..and 1085102592571150095) (add_shift 8) (add_shift 16) @@ -113,13 +113,13 @@ (..or (<forward> distance input) (<backward> (n.- (n.% ..width distance) ..width) input)))] - [rotate_left ..left_shift ..right_shift] - [rotate_right ..right_shift ..left_shift] + [left_rotated ..left_shifted ..right_shifted] + [right_rotated ..right_shifted ..left_shifted] ) (def: #export (region size offset) (-> Nat Nat Mask) - (..left_shift offset (..mask size))) + (..left_shifted offset (..mask size))) (implementation: #export equivalence (All [a] (Equivalence (I64 a))) @@ -149,7 +149,7 @@ (All [a] (-> (I64 a) (I64 a))) (let [swapper (: (-> Nat (All [a] (-> (I64 a) (I64 a)))) (function (_ power) - (let [size (..left_shift power 1) + (let [size (..left_shifted power 1) repetitions (: (-> Nat Text Text) (function (_ times char) (loop [iterations 1 @@ -164,10 +164,10 @@ (repetitions size "0"))) high (try.assumed (\ n.binary decode pattern)) - low (..rotate_right size high)] + low (..right_rotated size high)] (function (_ value) - (..or (..right_shift size (..and high value)) - (..left_shift size (..and low value))))))) + (..or (..right_shifted size (..and high value)) + (..left_shifted size (..and low value))))))) swap/01 (swapper 0) swap/02 (swapper 1) @@ -205,7 +205,7 @@ (def: &equivalence ..equivalence) (def: width width) (def: (narrow value) - (..or (|> value (..and ..sign) (..right_shift sign_shift)) + (..or (|> value (..and ..sign) (..right_shifted sign_shift)) (|> value (..and mantissa)))) (def: (widen value) (.i64 (case (.nat (..and sign value)) diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index b5806e0db..9724bc766 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -189,12 +189,12 @@ (def: &enum ..enum) (def: top ## +9,223,372,036,854,775,807 - (let [half (//i64.left_shift 62 +1)] + (let [half (//i64.left_shifted 62 +1)] (+ half (dec half)))) (def: bottom ## -9,223,372,036,854,775,808 - (//i64.left_shift 63 +1))) + (//i64.left_shifted 63 +1))) (template [<name> <compose> <identity>] [(implementation: #export <name> @@ -253,8 +253,8 @@ (def: &equivalence ..equivalence) (def: hash .nat)) -(def: #export (right_shift parameter subject) +(def: #export (right_shifted parameter subject) {#.doc "Signed/arithmetic bitwise right-shift."} (-> Nat Int Int) (//i64.or (//i64.and //i64.sign subject) - (//i64.right_shift parameter subject))) + (//i64.right_shifted parameter subject))) diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux index 3ad54b2bd..c97849629 100644 --- a/stdlib/source/library/lux/math/number/ratio.lux +++ b/stdlib/source/library/lux/math/number/ratio.lux @@ -45,8 +45,7 @@ "The denominator can be omitted if it is 1." (ratio numerator))} (in (list (` ((~! ..normal) {#..numerator (~ numerator) - #..denominator (~ (maybe.default (' 1) - ?denominator))}))))) + #..denominator (~ (maybe.else (' 1) ?denominator))}))))) (def: #export (= parameter subject) (-> Ratio Ratio Bit) diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index 431f44ed1..72073f421 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -23,7 +23,7 @@ (template [<power> <name>] [(def: #export <name> Rev - (.rev (//i64.left_shift (//nat.- <power> //i64.width) 1)))] + (.rev (//i64.left_shifted (//nat.- <power> //i64.width) 1)))] [01 /2] [02 /4] @@ -118,12 +118,12 @@ ..high ("lux i64 +" top)))) -(def: even_one (//i64.rotate_right 1 1)) +(def: even_one (//i64.right_rotated 1 1)) (def: odd_one (dec 0)) (def: (even_reciprocal numerator) (-> Nat Nat) - (//nat./ (//i64.right_shift 1 numerator) + (//nat./ (//i64.right_shifted 1 numerator) ..even_one)) (def: (odd_reciprocal numerator) @@ -293,7 +293,7 @@ (def: (digits::get idx digits) (-> Nat Digits Nat) - (|> digits (array.read idx) (maybe.default 0))) + (|> digits (array.read idx) (maybe.else 0))) (def: digits::put (-> Nat Nat Digits Digits) diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index f0a912431..c4f307a7b 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -124,7 +124,7 @@ (let [[prng left] (prng []) [prng right] (prng [])] [prng (|> left - (i64.left_shift 32) + (i64.left_shifted 32) ("lux i64 +" right))]))) (template [<name> <type> <cast>] @@ -143,7 +143,7 @@ (def: #export safe_frac (Random Frac) - (let [mantissa_range (.int (i64.left_shift 53 1)) + (let [mantissa_range (.int (i64.left_shifted 53 1)) mantissa_max (i.frac (dec mantissa_range))] (\ ..monad map (|>> (i.% mantissa_range) @@ -359,12 +359,12 @@ (let [magic 6364136223846793005] (function (_ _) [(|> seed .nat (n.* magic) ("lux i64 +" increase) [increase] pcg32) - (let [rot (|> seed .i64 (i64.right_shift 59))] + (let [rot (|> seed .i64 (i64.right_shifted 59))] (|> seed - (i64.right_shift 18) + (i64.right_shifted 18) (i64.xor seed) - (i64.right_shift 27) - (i64.rotate_right rot) + (i64.right_shifted 27) + (i64.right_rotated rot) .i64))]))) (def: #export (xoroshiro_128+ [s0 s1]) @@ -374,10 +374,10 @@ (function (_ _) [(let [s01 (i64.xor s0 s1)] (xoroshiro_128+ [(|> s0 - (i64.rotate_left 55) + (i64.left_rotated 55) (i64.xor s01) - (i64.xor (i64.left_shift 14 s01))) - (i64.rotate_left 36 s01)])) + (i64.xor (i64.left_shifted 14 s01))) + (i64.left_rotated 36 s01)])) ("lux i64 +" s0 s1)])) ## https://en.wikipedia.org/wiki/Xorshift#Initialization @@ -387,7 +387,7 @@ (-> Nat PRNG) (let [twist (: (-> Nat Nat Nat) (function (_ shift value) - (i64.xor (i64.right_shift shift value) + (i64.xor (i64.right_shifted shift value) value))) mix n.*] (..prng (n.+ (hex "9E,37,79,B9,7F,4A,7C,15")) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index 728e969b8..5c7d102fe 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -214,7 +214,7 @@ #.None #0)]))) -(def: (try_both f x1 x2) +(def: (on_either f x1 x2) (All [a b] (-> (-> a (Maybe b)) a a (Maybe b))) (case (f x1) @@ -262,11 +262,11 @@ (list.any? test (: (List [Text [Type Any]]) (get@ [#.captured #.mappings] env))))) (get@ #.scopes compiler)) - [_ [type _]] (try_both (list.find test) - (: (List [Text [Type Any]]) - (get@ [#.locals #.mappings] scope)) - (: (List [Text [Type Any]]) - (get@ [#.captured #.mappings] scope)))] + [_ [type _]] (on_either (list.find test) + (: (List [Text [Type Any]]) + (get@ [#.locals #.mappings] scope)) + (: (List [Text [Type Any]]) + (get@ [#.captured #.mappings] scope)))] (in type)) (#.Some var_type) ((clean_type var_type) compiler) @@ -291,7 +291,7 @@ (#try.Success [compiler definition]) _ - (let [current_module (|> compiler (get@ #.current_module) (maybe.default "???")) + (let [current_module (|> compiler (get@ #.current_module) (maybe.else "???")) separator ($_ text\compose text.new_line " ")] (#try.Failure ($_ text\compose "Unknown definition: " (name\encode name) text.new_line diff --git a/stdlib/source/library/lux/meta/annotation.lux b/stdlib/source/library/lux/meta/annotation.lux index 27512d5f6..a9892473f 100644 --- a/stdlib/source/library/lux/meta/annotation.lux +++ b/stdlib/source/library/lux/meta/annotation.lux @@ -61,7 +61,7 @@ (def: #export (flagged? flag) (-> Name Annotation Bit) - (|>> (..bit flag) (maybe.default false))) + (|>> (..bit flag) (maybe.else false))) (template [<name> <tag>] [(def: #export <name> @@ -69,7 +69,7 @@ (..flagged? (name_of <tag>)))] [implementation? #.implementation?] - [recursive_type? #.type-rec?] + [recursive_type? #.type_rec?] [signature? #.sig?] ) @@ -85,11 +85,11 @@ (template [<name> <tag>] [(def: #export (<name> ann) (-> Annotation (List Text)) - (maybe.default (list) - (do {! maybe.monad} - [args (..tuple (name_of <tag>) ann)] - (monad.map ! ..text_parser args))))] + (<| (maybe.else (list)) + (do {! maybe.monad} + [args (..tuple (name_of <tag>) ann)] + (monad.map ! ..text_parser args))))] - [function_arguments #.func-args] - [type_arguments #.type-args] + [function_arguments #.func_args] + [type_arguments #.type_args] ) diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 8571aeece..8ca668f99 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -7,7 +7,7 @@ ["." monad (#+ Monad do)]] [control ["." writer (#+ Writer)] - ["." state (#+ State')] + ["." state (#+ +State)] ["." function] ["." try (#+ Try)] ["." exception (#+ exception:)]] @@ -98,7 +98,7 @@ (_\compose left_instruction right_instruction)])))))) (type: #export (Bytecode a) - (State' Try [Pool Environment Tracker] (Writer Relative a))) + (+State Try [Pool Environment Tracker] (Writer Relative a))) (def: #export new_label (Bytecode Label) @@ -149,7 +149,7 @@ (do try.monad [[actual environment] (/environment.continue (|> environment (get@ #/environment.stack) - (maybe.default /stack.empty)) + (maybe.else /stack.empty)) environment)] <success>)))))) @@ -157,7 +157,7 @@ (Monad Bytecode) (<| (:as (Monad Bytecode)) (writer.with ..relative_monoid) - (: (Monad (State' Try [Pool Environment Tracker]))) + (: (Monad (+State Try [Pool Environment Tracker]))) state.with (: (Monad Try)) try.monad)) diff --git a/stdlib/source/library/lux/target/jvm/constant/pool.lux b/stdlib/source/library/lux/target/jvm/constant/pool.lux index 18b6a9c61..e2c12039e 100644 --- a/stdlib/source/library/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/library/lux/target/jvm/constant/pool.lux @@ -6,7 +6,7 @@ [equivalence (#+ Equivalence)] [monad (#+ Monad do)]] [control - ["." state (#+ State')] + ["." state (#+ +State)] ["." try (#+ Try)]] [data ["." product] @@ -44,7 +44,7 @@ //.equivalence)))) (type: #export (Resource a) - (State' Try Pool a)) + (+State Try Pool a)) (def: #export monad (Monad Resource) diff --git a/stdlib/source/library/lux/target/jvm/encoding/signed.lux b/stdlib/source/library/lux/target/jvm/encoding/signed.lux index 1958ea63c..dfdcedbb6 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/signed.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/signed.lux @@ -61,7 +61,7 @@ (def: #export <constructor> (-> Int (Try <name>)) (let [positive (|> <bytes> (n.* i64.bits_per_byte) i64.mask) - negative (|> positive .int (i.right_shift 1) i64.not)] + negative (|> positive .int (i.right_shifted 1) i64.not)] (function (_ value) (if (i.= (if (i.< +0 value) (i64.or negative value) diff --git a/stdlib/source/library/lux/target/jvm/type/alias.lux b/stdlib/source/library/lux/target/jvm/type/alias.lux index e7cc570c1..365460dc6 100644 --- a/stdlib/source/library/lux/target/jvm/type/alias.lux +++ b/stdlib/source/library/lux/target/jvm/type/alias.lux @@ -37,7 +37,7 @@ [var //parser.var'] (in (|> aliasing (dictionary.get var) - (maybe.default var) + (maybe.else var) //.var)))) (def: (class parameter) @@ -47,7 +47,7 @@ parameters (|> (<>.some parameter) (<>.after (<text>.this //signature.parameters_start)) (<>.before (<text>.this //signature.parameters_end)) - (<>.default (list)))] + (<>.else (list)))] (in (//.class name parameters))) (<>.after (<text>.this //descriptor.class_prefix)) (<>.before (<text>.this //descriptor.class_suffix)))) @@ -123,7 +123,7 @@ [type_variables (|> (<>.some (..bound_type_var aliasing)) (<>.after (<text>.this //signature.parameters_start)) (<>.before (<text>.this //signature.parameters_end)) - (<>.default (list))) + (<>.else (list))) inputs (..inputs aliasing) return (..return aliasing) exceptions (<>.some (..exception aliasing))] diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index 6b6fc2b5f..79104adaa 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -133,7 +133,7 @@ parameters (|> (<>.some parameter) (<>.after (<text>.this //signature.parameters_start)) (<>.before (<text>.this //signature.parameters_end)) - (<>.default (list)))] + (<>.else (list)))] (in (do {! check.monad} [parameters (monad.seq ! parameters)] (in (#.Primitive name parameters))))) diff --git a/stdlib/source/library/lux/target/jvm/type/parser.lux b/stdlib/source/library/lux/target/jvm/type/parser.lux index b955ce0f7..5dbada115 100644 --- a/stdlib/source/library/lux/target/jvm/type/parser.lux +++ b/stdlib/source/library/lux/target/jvm/type/parser.lux @@ -117,7 +117,7 @@ parameters (|> (<>.some parameter) (<>.after (<text>.this //signature.parameters_start)) (<>.before (<text>.this //signature.parameters_end)) - (<>.default (list)))] + (<>.else (list)))] (in [name parameters])) (<>.after (<text>.this //descriptor.class_prefix)) (<>.before (<text>.this //descriptor.class_suffix)))) @@ -217,7 +217,7 @@ (|> (<>.some ..var) (<>.after (<text>.this //signature.parameters_start)) (<>.before (<text>.this //signature.parameters_end)) - (<>.default (list))) + (<>.else (list))) ..inputs ..return (<>.some ..exception)))] @@ -253,7 +253,7 @@ (|> (<>.some ..var) (<>.after (<text>.this //signature.parameters_start)) (<>.before (<text>.this //signature.parameters_end)) - (<>.default (list)))) + (<>.else (list)))) (<>.after (<text>.this //descriptor.class_prefix)) (<>.before (<text>.this //descriptor.class_suffix)))) diff --git a/stdlib/source/library/lux/target/r.lux b/stdlib/source/library/lux/target/r.lux index 11d080762..01deac3a2 100644 --- a/stdlib/source/library/lux/target/r.lux +++ b/stdlib/source/library/lux/target/r.lux @@ -337,7 +337,7 @@ (.function (_ parameter value preparation) (|> value (maybe\map (|>> :representation preparation (format ", " parameter " = "))) - (maybe.default ""))))] + (maybe.else ""))))] (..self_contained (format "tryCatch(" (.._block (:representation body)) diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index 8af624e4c..ee3604c0a 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -221,7 +221,7 @@ 5 ## XX.XX 4 ## X.XX )) - (maybe.default raw) + (maybe.else raw) (text.suffix "%"))))))] (exception.report ["Duration" (%.duration duration)] diff --git a/stdlib/source/library/lux/time/duration.lux b/stdlib/source/library/lux/time/duration.lux index 5e0907481..72ee9debc 100644 --- a/stdlib/source/library/lux/time/duration.lux +++ b/stdlib/source/library/lux/time/duration.lux @@ -164,7 +164,7 @@ "" (<t>.this suffix) _ (<>.after (<>.not (<t>.this false_suffix)) (<t>.this suffix)))) - (<>.default 0))))] + (<>.else 0))))] (do <>.monad [sign (<>.or (<t>.this ..negative_sign) (<t>.this ..positive_sign)) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index cde736979..c5f2cfb8e 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -319,7 +319,7 @@ (|> dependence lens (dictionary.get module) - (maybe.default ..empty)))) + (maybe.else ..empty)))) transitive_depends_on (transitive_dependency (get@ #depends_on) import) transitive_depended_by (transitive_dependency (get@ #depended_by) module) update_dependence (: (-> [Module (Set Module)] [Module (Set Module)] @@ -351,7 +351,7 @@ (let [targets (|> dependence relationship (dictionary.get from) - (maybe.default ..empty))] + (maybe.else ..empty))] (set.member? targets to))))] (or (dependence? import (get@ #depends_on) module) (dependence? module (get@ #depended_by) import)))) 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 e48d2b1f8..291cf89c2 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 @@ -194,8 +194,8 @@ (.case inputT' (#.Product _) (let [subs (type.flat_tuple inputT') - num_subs (maybe.default (list.size subs) - num_tags) + num_subs (maybe.else (list.size subs) + num_tags) num_sub_patterns (list.size sub_patterns) matches (cond (n.< num_subs num_sub_patterns) (let [[prefix suffix] (list.split (dec num_sub_patterns) subs)] @@ -253,7 +253,7 @@ (#.Sum _) (let [flat_sum (type.flat_variant inputT') size_sum (list.size flat_sum) - num_cases (maybe.default size_sum num_tags) + num_cases (maybe.else size_sum num_tags) idx (/.tag lefts right?)] (.case (list.nth idx flat_sum) (^multi (#.Some caseT) 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 99e1730f1..3760c86cc 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 @@ -29,7 +29,7 @@ (def: cases (-> (Maybe Nat) Nat) - (|>> (maybe.default 0))) + (|>> (maybe.else 0))) (def: known_cases? (-> Nat Bit) 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 863975408..31ce0998c 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 @@ -85,8 +85,8 @@ (#.Right [state #.None]) (#.Item top_outer _) - (let [[ref_type init_ref] (maybe.default (undefined) - (..reference name top_outer)) + (let [[ref_type init_ref] (maybe.else (undefined) + (..reference name top_outer)) [ref inner'] (list\fold (: (-> Scope [Variable (List Scope)] [Variable (List Scope)]) (function (_ scope ref+inner) [(#variable.Foreign (get@ [#.captured #.counter] scope)) @@ -169,7 +169,7 @@ state)]) (#try.Success [[bundle' state'] output]) (#try.Success [[bundle' (update@ #.scopes - (|>> list.tail (maybe.default (list))) + (|>> list.tail (maybe.else (list))) state')] output]) 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 b34743db7..3804bcec2 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 @@ -1117,7 +1117,7 @@ (#.Some name) (|> aliasing (dictionary.get name) - (maybe.default name) + (maybe.else name) jvm.var) #.None @@ -1147,7 +1147,7 @@ (#.Some name) (|> aliasing (dictionary.get name) - (maybe.default name) + (maybe.else name) jvm.var) #.None 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 4fd8d5842..602c40504 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 @@ -101,7 +101,7 @@ (/.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 "right-shift" (binary (product.uncurry //runtime.i64//right_shifted))) (/.install "=" (binary _.=/2)) (/.install "<" (binary _.</2)) (/.install "+" (binary _.+/2)) 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 e84d5cdf7..da9bbc7f8 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 @@ -52,8 +52,8 @@ (Binary Expression) (<op> subjectG (//runtime.i64//to_number paramG)))] - [i64//left_shift //runtime.i64//left_shift] - [i64//right_shift //runtime.i64//right_shift] + [i64//left_shifted //runtime.i64//left_shifted] + [i64//right_shifted //runtime.i64//right_shifted] ) ## [[Numbers]] @@ -132,8 +132,8 @@ (/.install "and" (binary (product.uncurry //runtime.i64//and))) (/.install "or" (binary (product.uncurry //runtime.i64//or))) (/.install "xor" (binary (product.uncurry //runtime.i64//xor))) - (/.install "left-shift" (binary i64//left_shift)) - (/.install "right-shift" (binary i64//right_shift)) + (/.install "left-shift" (binary i64//left_shifted)) + (/.install "right-shift" (binary i64//right_shifted)) (/.install "=" (binary (product.uncurry //runtime.i64//=))) (/.install "<" (binary (product.uncurry //runtime.i64//<))) (/.install "+" (binary (product.uncurry //runtime.i64//+))) 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 eed3eb6ce..354537c19 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 @@ -182,8 +182,8 @@ shiftG ..jvm_int <op> (///value.wrap type.long)))] - [i64::left_shift _.lshl] - [i64::right_shift _.lushr] + [i64::left_shifted _.lshl] + [i64::right_shifted _.lushr] ) (template [<name> <type> <op>] @@ -272,8 +272,8 @@ (/////bundle.install "and" (binary ..i64::and)) (/////bundle.install "or" (binary ..i64::or)) (/////bundle.install "xor" (binary ..i64::xor)) - (/////bundle.install "left-shift" (binary ..i64::left_shift)) - (/////bundle.install "right-shift" (binary ..i64::right_shift)) + (/////bundle.install "left-shift" (binary ..i64::left_shifted)) + (/////bundle.install "right-shift" (binary ..i64::right_shifted)) (/////bundle.install "=" (binary ..i64::=)) (/////bundle.install "<" (binary ..i64::<)) (/////bundle.install "+" (binary ..i64::+)) 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 9827c2480..58ac1efc1 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 @@ -889,7 +889,7 @@ (^ (//////synthesis.variable var)) (|> mapping (dictionary.get var) - (maybe.default var) + (maybe.else var) //////synthesis.variable) (^ (//////synthesis.branch/case [inputS pathS])) @@ -916,7 +916,7 @@ (^ (//////synthesis.variable local)) (|> mapping (dictionary.get local) - (maybe.default local) + (maybe.else local) //////synthesis.variable) _ 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 519ed6563..3925bec4b 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 @@ -105,7 +105,7 @@ (/.install "try" (unary //runtime.lux//try)) )) -(def: (left_shift [parameter subject]) +(def: (left_shifted [parameter subject]) (Binary Expression) (_.bit_shl (_.% (_.int +64) parameter) subject)) @@ -116,8 +116,8 @@ (/.install "and" (binary (product.uncurry _.bit_and))) (/.install "or" (binary (product.uncurry _.bit_or))) (/.install "xor" (binary (product.uncurry _.bit_xor))) - (/.install "left-shift" (binary ..left_shift)) - (/.install "right-shift" (binary (product.uncurry //runtime.i64//right_shift))) + (/.install "left-shift" (binary ..left_shifted)) + (/.install "right-shift" (binary (product.uncurry //runtime.i64//right_shifted))) (/.install "=" (binary (product.uncurry _.==))) (/.install "<" (binary (product.uncurry _.<))) (/.install "+" (binary (product.uncurry //runtime.i64//+))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux index 1853971a6..ee472fe92 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux @@ -29,18 +29,18 @@ (bundle.install "is" (binary (product.uncurry _.eq))) (bundle.install "try" (unary ///runtime.lux//try)))) -(def: (i64//left_shift [paramG subjectG]) +(def: (i64//left_shifted [paramG subjectG]) (Binary (Expression Any)) (_.ash (_.rem (_.int +64) paramG) subjectG)) -(def: (i64//arithmetic_right_shift [paramG subjectG]) +(def: (i64//arithmetic_right_shifted [paramG subjectG]) (Binary (Expression Any)) (_.ash (|> paramG (_.rem (_.int +64)) (_.* (_.int -1))) subjectG)) -(def: (i64//logic_right_shift [paramG subjectG]) +(def: (i64//logic_right_shifted [paramG subjectG]) (Binary (Expression Any)) - (///runtime.i64//logic_right_shift (_.rem (_.int +64) paramG) subjectG)) + (///runtime.i64//logic_right_shifted (_.rem (_.int +64) paramG) subjectG)) (def: i64_procs Bundle @@ -49,9 +49,9 @@ (bundle.install "and" (binary (product.uncurry _.logand))) (bundle.install "or" (binary (product.uncurry _.logior))) (bundle.install "xor" (binary (product.uncurry _.logxor))) - (bundle.install "left-shift" (binary i64//left_shift)) - (bundle.install "logical-right-shift" (binary i64//logic_right_shift)) - (bundle.install "arithmetic-right-shift" (binary i64//arithmetic_right_shift)) + (bundle.install "left-shift" (binary i64//left_shifted)) + (bundle.install "logical-right-shift" (binary i64//logic_right_shifted)) + (bundle.install "arithmetic-right-shift" (binary i64//arithmetic_right_shifted)) (bundle.install "=" (binary (product.uncurry _.=))) (bundle.install "<" (binary (product.uncurry _.<))) (bundle.install "+" (binary (product.uncurry _.+))) 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 fd0e7a780..6b390352b 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 @@ -226,7 +226,7 @@ @tuple//right @sum//get)) -(runtime: (i64//right_shift shift input) +(runtime: (i64//right_shifted shift input) (_.if (_.=/2 [(_.int +0) shift]) input (let [anti_shift (_.-/2 [shift (_.int +64)]) @@ -239,7 +239,7 @@ (def: runtime//i64 (List (Expression Any)) - (list @i64//right_shift)) + (list @i64//right_shifted)) (runtime: (text//clip offset length text) (_.subseq/3 [text offset (_.+/2 [offset length])])) 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 506a957c7..94fe61c3e 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 @@ -64,11 +64,11 @@ (def: #export high (-> (I64 Any) (I64 Any)) - (i64.right_shift 32)) + (i64.right_shifted 32)) (def: #export low (-> (I64 Any) (I64 Any)) - (let [mask (dec (i64.left_shift 32 1))] + (let [mask (dec (i64.left_shifted 32 1))] (|>> (i64.and mask)))) (def: #export unit @@ -416,7 +416,7 @@ (-> Var Expression) (|>> (_.< (_.i32 +32)))) -(runtime: (i64//left_shift input shift) +(runtime: (i64//left_shifted input shift) ($_ _.then (..cap_shift! shift) (_.return (<| (..no_shift! shift input) @@ -429,7 +429,7 @@ (..i64 high (_.i32 +0))))) )) -(runtime: (i64//arithmetic_right_shift input shift) +(runtime: (i64//arithmetic_right_shifted input shift) ($_ _.then (..cap_shift! shift) (_.return (<| (..no_shift! shift input) @@ -444,7 +444,7 @@ low (|> input (_.the ..i64_high_field) (_.arithmetic_right_shift (_.- (_.i32 +32) shift)))] (..i64 high low)))))) -(runtime: (i64//right_shift input shift) +(runtime: (i64//right_shifted input shift) ($_ _.then (..cap_shift! shift) (_.return (<| (..no_shift! shift input) @@ -465,9 +465,9 @@ @i64//or @i64//xor @i64//not - @i64//left_shift - @i64//arithmetic_right_shift - @i64//right_shift + @i64//left_shifted + @i64//arithmetic_right_shifted + @i64//right_shifted )) (runtime: (i64//- parameter subject) @@ -557,11 +557,11 @@ [(i64//= i64//min parameter) (_.return i64//one)]) (with_vars [approximation] - (let [subject/2 (..i64//arithmetic_right_shift subject (_.i32 +1))] + (let [subject/2 (..i64//arithmetic_right_shifted subject (_.i32 +1))] ($_ _.then - (_.define approximation (i64//left_shift (i64/// parameter - subject/2) - (_.i32 +1))) + (_.define approximation (i64//left_shifted (i64/// parameter + subject/2) + (_.i32 +1))) (_.if (i64//= i64//zero approximation) (_.return (_.? (negative? parameter) i64//one 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 86a980c95..80315db66 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 @@ -608,4 +608,4 @@ ## 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_shift shift) generation.next))) + (\ ////.monad map (i64.left_shifted shift) generation.next))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux index 3c9054abf..b51cd2930 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux @@ -65,7 +65,7 @@ (//////phase\map _.return (/function.function statement expression archive abstraction)) )) -(exception: #export cannot-recur-as-an-expression) +(exception: #export cannot_recur_as_an_expression) (def: (expression archive synthesis) Phase @@ -103,7 +103,7 @@ (/loop.scope ..statement expression archive scope) (^ (synthesis.loop/recur updates)) - (//////phase.except ..cannot-recur-as-an-expression []) + (//////phase.except ..cannot_recur_as_an_expression []) (^ (synthesis.function/abstraction abstraction)) (/function.function ..statement expression archive abstraction) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux index 1565f7c0e..7d92f48d3 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 @@ -260,10 +260,10 @@ (def: cap_shift (_.% (_.int +64))) -(runtime: (i64//left_shift param subject) +(runtime: (i64//left_shifted param subject) (_.return (_.bit_shl (..cap_shift param) subject))) -(runtime: (i64//right_shift param subject) +(runtime: (i64//right_shifted param subject) (let [mask (|> (_.int +1) (_.bit_shl (_.- param (_.int +64))) (_.- (_.int +1)))] @@ -294,8 +294,8 @@ (def: runtime//i64 Statement ($_ _.then - @i64//left_shift - @i64//right_shift + @i64//left_shifted + @i64//right_shifted @i64//division @i64//remainder )) 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 9729815b6..6c08b4ed0 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 @@ -338,14 +338,14 @@ (def: #export high (-> (I64 Any) (I64 Any)) - (i64.right_shift 32)) + (i64.right_shifted 32)) (def: #export low (-> (I64 Any) (I64 Any)) - (let [mask (dec (i64.left_shift 32 1))] + (let [mask (dec (i64.left_shifted 32 1))] (|>> (i64.and mask)))) -(runtime: (i64//right_shift param subject) +(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. @@ -376,13 +376,13 @@ _.iconv/3)))) (runtime: (i64//+ parameter subject) - (let [high_16 (..i64//right_shift (_.int +16)) + (let [high_16 (..i64//right_shifted (_.int +16)) low_16 (_.bit_and (_.int (.int (hex "FFFF")))) cap_16 low_16 - hh (..i64//right_shift (_.int +48)) - hl (|>> (..i64//right_shift (_.int +32)) cap_16) - lh (|>> (..i64//right_shift (_.int +16)) cap_16) + hh (..i64//right_shifted (_.int +48)) + hl (|>> (..i64//right_shifted (_.int +32)) cap_16) + lh (|>> (..i64//right_shifted (_.int +16)) cap_16) ll cap_16 up_16 (_.bit_shl (_.int +16))] @@ -435,13 +435,13 @@ (_.return (..i64//+ (..i64//negate parameter) subject))) (runtime: (i64//* parameter subject) - (let [high_16 (..i64//right_shift (_.int +16)) + (let [high_16 (..i64//right_shifted (_.int +16)) low_16 (_.bit_and (_.int (.int (hex "FFFF")))) cap_16 low_16 - hh (..i64//right_shift (_.int +48)) - hl (|>> (..i64//right_shift (_.int +32)) cap_16) - lh (|>> (..i64//right_shift (_.int +16)) cap_16) + hh (..i64//right_shifted (_.int +48)) + hl (|>> (..i64//right_shifted (_.int +32)) cap_16) + lh (|>> (..i64//right_shifted (_.int +16)) cap_16) ll cap_16 up_16 (_.bit_shl (_.int +16))] @@ -492,7 +492,7 @@ (def: runtime//i64 Statement ($_ _.then - @i64//right_shift + @i64//right_shifted @i64//char @i64//+ @i64//negate 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 440f208ba..44ea19376 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 @@ -298,12 +298,12 @@ (def: as_nat (_.% ..i64::+iteration)) -(runtime: (i64::left_shift param subject) +(runtime: (i64::left_shifted param subject) (_.return (|> subject (_.bit_shl (_.% (_.int +64) param)) ..i64::64))) -(runtime: (i64::right_shift param subject) +(runtime: (i64::right_shifted param subject) ($_ _.then (_.set (list param) (_.% (_.int +64) param)) (_.return (_.? (_.= (_.int +0) param) @@ -354,8 +354,8 @@ (Statement Any) ($_ _.then @i64::64 - @i64::left_shift - @i64::right_shift + @i64::left_shifted + @i64::right_shifted @i64::division @i64::remainder @i64::and 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 225d32a81..b650c7e8d 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 @@ -163,9 +163,9 @@ Binary (<op> (runtimeT.int64_low paramO) subjectO))] - [bit//left_shift runtimeT.bit//left_shift] - [bit//arithmetic_right_shift runtimeT.bit//arithmetic_right_shift] - [bit//logical_right_shift runtimeT.bit//logical_right_shift] + [bit//left_shifted runtimeT.bit//left_shifted] + [bit//arithmetic_right_shifted runtimeT.bit//arithmetic_right_shifted] + [bit//logical_right_shifted runtimeT.bit//logical_right_shifted] ) (def: bit_procs @@ -175,9 +175,9 @@ (install "and" (binary bit//and)) (install "or" (binary bit//or)) (install "xor" (binary bit//xor)) - (install "left-shift" (binary bit//left_shift)) - (install "logical-right-shift" (binary bit//logical_right_shift)) - (install "arithmetic-right-shift" (binary bit//arithmetic_right_shift)) + (install "left-shift" (binary bit//left_shifted)) + (install "logical-right-shift" (binary bit//logical_right_shifted)) + (install "arithmetic-right-shift" (binary bit//arithmetic_right_shifted)) ))) ## [[Numbers]] 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 06ae68255..dba43659e 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 @@ -199,7 +199,7 @@ (def: high_32 (-> Nat Nat) - (i64.right_shift 32)) + (i64.right_shifted 32)) (def: low_32 (-> Nat Nat) @@ -214,7 +214,7 @@ (def: #export (lux_i64 high low) (-> Int Int Int) (|> high - (i64.left_shift 32) + (i64.left_shifted 32) (i64.or low))) (template [<name> <value>] @@ -387,7 +387,7 @@ [(|> shift (_.= (_.int +0))) input]) -(runtime: (i64::left_shift shift input) +(runtime: (i64::left_shifted shift input) ($_ _.then (limit_shift! shift) (_.cond (list (no_shift_clause shift input) @@ -403,26 +403,26 @@ (_.bit_shl (|> shift (_.- (_.int +32)))))] (i64::new high (_.int +0)))))) -(runtime: (i64::arithmetic_right_shift_32 shift input) +(runtime: (i64::arithmetic_right_shifted_32 shift input) (let [top_bit (|> input (_.bit_and (_.as::integer (_.int (hex "+80000000")))))] (|> input (_.bit_ushr shift) (_.bit_or top_bit)))) -(runtime: (i64::arithmetic_right_shift shift input) +(runtime: (i64::arithmetic_right_shifted shift input) ($_ _.then (limit_shift! shift) (_.cond (list (no_shift_clause shift input) [(|> shift (_.< (_.int +32))) (let [mid (|> (i64_high input) (_.bit_shl (|> (_.int +32) (_.- shift)))) high (|> (i64_high input) - (i64::arithmetic_right_shift_32 shift)) + (i64::arithmetic_right_shifted_32 shift)) low (|> (i64_low input) (_.bit_ushr shift) (_.bit_or mid))] (i64::new high low))]) (let [low (|> (i64_high input) - (i64::arithmetic_right_shift_32 (|> shift (_.- (_.int +32))))) + (i64::arithmetic_right_shifted_32 (|> shift (_.- (_.int +32))))) high (_.if (|> (i64_high input) (_.>= (_.int +0))) (_.int +0) (_.int -1))] @@ -447,9 +447,9 @@ ($_ _.then (_.set! approximation (|> subject - (i64::arithmetic_right_shift (_.int +1)) + (i64::arithmetic_right_shifted (_.int +1)) (i64::/ param) - (i64::left_shift (_.int +1)))) + (i64::left_shifted (_.int +1)))) (_.if (|> approximation (i64::= i64::zero)) (_.if (negative? param) i64::one @@ -647,7 +647,7 @@ [i64::xor _.bit_xor] ) -(runtime: (i64::right_shift shift input) +(runtime: (i64::right_shifted shift input) ($_ _.then (limit_shift! shift) (_.cond (list (no_shift_clause shift input) @@ -682,10 +682,10 @@ @i64::or @i64::xor @i64::not - @i64::left_shift - @i64::arithmetic_right_shift_32 - @i64::arithmetic_right_shift - @i64::right_shift + @i64::left_shifted + @i64::arithmetic_right_shifted_32 + @i64::arithmetic_right_shifted + @i64::right_shifted @i64::zero @i64::one 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 1a19be4a3..1ab1ab616 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 @@ -275,12 +275,12 @@ (def: as_nat (_.% (_.manual "0x10000000000000000"))) -(runtime: (i64//left_shift param subject) +(runtime: (i64//left_shifted param subject) (_.return (|> subject (_.bit_shl (_.% (_.int +64) param)) ..i64//64))) -(runtime: (i64//right_shift param subject) +(runtime: (i64//right_shifted param subject) ($_ _.then (_.set (list param) (_.% (_.int +64) param)) (_.return (_.? (_.= (_.int +0) param) @@ -309,8 +309,8 @@ ($_ _.then @i64//64 @i64//nat_top - @i64//left_shift - @i64//right_shift + @i64//left_shifted + @i64//right_shifted @i64//and @i64//or @i64//xor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux index 9d9c62b18..79d8950ce 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux @@ -183,7 +183,7 @@ [/////synthesis.side/right true inc]) (^ (/////synthesis.member/left 0)) - (///////phase\in (..push_cursor! (_.vector-ref/2 ..peek (_.int +0)))) + (///////phase\in (..push_cursor! (_.vector_ref/2 ..peek (_.int +0)))) (^template [<pm> <getter>] [(^ (<pm> lefts)) 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 6b976b9b6..a3a598808 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 @@ -39,23 +39,23 @@ (syntax: (arity: {name s.local_identifier} {arity s.nat}) (with_gensyms [g!_ g!extension g!name g!phase g!inputs] - (do {! macro.monad} - [g!input+ (monad.seq ! (list.repeat arity (macro.gensym "input")))] - (in (list (` (def: #export ((~ (code.local_identifier name)) (~ g!extension)) - (-> (-> (..Vector (~ (code.nat arity)) Expression) Computation) - Handler) - (function ((~ g!_) (~ g!name) (~ g!phase) (~ g!inputs)) - (case (~ g!inputs) - (^ (list (~+ g!input+))) - (do /////.monad - [(~+ (|> g!input+ - (list\map (function (_ g!input) - (list g!input (` ((~ g!phase) (~ g!input)))))) - list.concat))] - ((~' in) ((~ g!extension) [(~+ g!input+)]))) - - (~' _) - (/////.except /////extension.incorrect_arity [(~ g!name) 1 (list.size (~ g!inputs))])))))))))) + (do {! macro.monad} + [g!input+ (monad.seq ! (list.repeat arity (macro.gensym "input")))] + (in (list (` (def: #export ((~ (code.local_identifier name)) (~ g!extension)) + (-> (-> (..Vector (~ (code.nat arity)) Expression) Computation) + Handler) + (function ((~ g!_) (~ g!name) (~ g!phase) (~ g!inputs)) + (case (~ g!inputs) + (^ (list (~+ g!input+))) + (do /////.monad + [(~+ (|> g!input+ + (list\map (function (_ g!input) + (list g!input (` ((~ g!phase) (~ g!input)))))) + list.concat))] + ((~' in) ((~ g!extension) [(~+ g!input+)]))) + + (~' _) + (/////.except /////extension.incorrect_arity [(~ g!name) 1 (list.size (~ g!inputs))])))))))))) (arity: nullary 0) (arity: unary 1) @@ -86,19 +86,19 @@ [i64::xor _.bit_xor/2] ) -(def: (i64::left_shift [subjectO paramO]) +(def: (i64::left_shifted [subjectO paramO]) Binary (_.arithmetic_shift/2 (_.remainder/2 (_.int +64) paramO) subjectO)) -(def: (i64::arithmetic_right_shift [subjectO paramO]) +(def: (i64::arithmetic_right_shifted [subjectO paramO]) Binary (_.arithmetic_shift/2 (|> paramO (_.remainder/2 (_.int +64)) (_.*/2 (_.int -1))) subjectO)) -(def: (i64::logical_right_shift [subjectO paramO]) +(def: (i64::logical_right_shifted [subjectO paramO]) Binary - (///runtime.i64//logical_right_shift (_.remainder/2 (_.int +64) paramO) subjectO)) + (///runtime.i64//logical_right_shifted (_.remainder/2 (_.int +64) paramO) subjectO)) (template [<name> <op>] [(def: (<name> [subjectO paramO]) @@ -147,9 +147,9 @@ (bundle.install "and" (binary i64::and)) (bundle.install "or" (binary i64::or)) (bundle.install "xor" (binary i64::xor)) - (bundle.install "left-shift" (binary i64::left_shift)) - (bundle.install "logical-right-shift" (binary i64::logical_right_shift)) - (bundle.install "arithmetic-right-shift" (binary i64::arithmetic_right_shift)) + (bundle.install "left-shift" (binary i64::left_shifted)) + (bundle.install "logical-right-shift" (binary i64::logical_right_shifted)) + (bundle.install "arithmetic-right-shift" (binary i64::arithmetic_right_shifted)) (bundle.install "+" (binary i64::+)) (bundle.install "-" (binary i64::-)) (bundle.install "*" (binary i64::*)) 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 140b72106..2e5c8d495 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 @@ -265,7 +265,7 @@ )) input)))) -(runtime: (i64//left_shift param subject) +(runtime: (i64//left_shifted param subject) (|> subject (_.arithmetic_shift/2 (_.remainder/2 (_.int +64) param)) ..i64//64)) @@ -273,7 +273,7 @@ (def: as_nat (_.remainder/2 ..i64//+iteration)) -(runtime: (i64//right_shift shift subject) +(runtime: (i64//right_shifted shift subject) (_.let (list [shift (_.remainder/2 (_.int +64) shift)]) (_.if (_.=/2 (_.int +0) shift) subject @@ -296,8 +296,8 @@ (def: runtime//i64 Computation (_.begin (list @i64//64 - @i64//left_shift - @i64//right_shift + @i64//left_shifted + @i64//right_shifted @i64//or @i64//xor @i64//and 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 10a5c6eec..4dc984bae 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 @@ -72,7 +72,7 @@ _ (/.loop/scope [start inits iteration]))))) - (maybe.default <apply>)))) + (maybe.else <apply>)))) (in <apply>)) (^ (/.function/apply [funcS' argsS'])) 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 956c59cd6..80d3eb556 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 @@ -369,7 +369,7 @@ [redundancy output] (optimization' [redundancy output]) #let [redundant? (|> redundancy (dictionary.get register) - (maybe.default ..necessary!))]] + (maybe.else ..necessary!))]] (in [(dictionary.remove register redundancy) (#/.Control (if redundant? (#/.Branch (#/.Case input 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 e304e237c..a54350ccf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -469,7 +469,7 @@ (!failure ..full_name_parser where offset source_code)) (#.Right [source'' [(|> aliases (dictionary.get simple) - (maybe.default simple)) + (maybe.else simple)) complex]]))) <simple>))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux index 37e5f7cfa..c51151b68 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux @@ -76,7 +76,7 @@ (-> Graph Module Module Bit) (let [target_ancestry (|> ancestry (dictionary.get target) - (maybe.default ..fresh))] + (maybe.else ..fresh))] (set.member? target_ancestry source))) (type: #export Order 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 6a25f1094..b1735f389 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -142,7 +142,7 @@ (Try java/util/jar/JarOutputStream)) (let [class_path (|> custom (maybe\map (|>> name.internal name.read)) - (maybe.default (runtime.class_name [module artifact])) + (maybe.else (runtime.class_name [module artifact])) (text.suffix (get@ #static.artifact_extension static)))] (do try.monad [_ (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path) sink)] diff --git a/stdlib/source/library/lux/tool/compiler/phase.lux b/stdlib/source/library/lux/tool/compiler/phase.lux index 845ba3dba..0554592a0 100644 --- a/stdlib/source/library/lux/tool/compiler/phase.lux +++ b/stdlib/source/library/lux/tool/compiler/phase.lux @@ -25,7 +25,7 @@ [archive (#+ Archive)]]]) (type: #export (Operation s o) - (state.State' Try s o)) + (state.+State Try s o)) (def: #export monad (All [s] (Monad (Operation s))) diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index f3f79adc2..ce3b32921 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -90,10 +90,10 @@ (list\fold (function.flip text\compose) "")) ")") - (^template [<tag> <open> <close> <flatten>] + (^template [<tag> <open> <close> <flat>] [(<tag> _) ($_ text\compose <open> - (|> (<flatten> type) + (|> (<flat> type) (list\map format) list.reverse (list.interpose " ") @@ -160,17 +160,17 @@ [#.ExQ]) (#.Parameter idx) - (maybe.default (error! ($_ text\compose - "Unknown type parameter" text.new_line - " Index: " (n\encode idx) text.new_line - "Environment: " (|> env - list.enumeration - (list\map (.function (_ [index type]) - ($_ text\compose - (n\encode index) - " " (..format type)))) - (text.join_with (text\compose text.new_line " "))))) - (list.nth idx env)) + (maybe.else (error! ($_ text\compose + "Unknown type parameter" text.new_line + " Index: " (n\encode idx) text.new_line + "Environment: " (|> env + list.enumeration + (list\map (.function (_ [index type]) + ($_ text\compose + (n\encode index) + " " (..format type)))) + (text.join_with (text\compose text.new_line " "))))) + (list.nth idx env)) _ type @@ -346,7 +346,7 @@ (#.Apply A F) (|> (..applied (list A) F) (\ maybe.monad map quantified?) - (maybe.default #0)) + (maybe.else #0)) (^or (#.UnivQ _) (#.ExQ _)) #1 diff --git a/stdlib/source/library/lux/type/abstract.lux b/stdlib/source/library/lux/type/abstract.lux index f6b6b35ac..66560bc4f 100644 --- a/stdlib/source/library/lux/type/abstract.lux +++ b/stdlib/source/library/lux/type/abstract.lux @@ -209,7 +209,7 @@ {export |export|.parser} {[name type_vars] declaration} representation_type - {annotations (<>.default |annotations|.empty |annotations|.parser)} + {annotations (<>.else |annotations|.empty |annotations|.parser)} {primitives (<>.some <code>.any)}) (do meta.monad [current_module meta.current_module_name diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index 4e6bcdc3d..03dd7b89e 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -376,7 +376,7 @@ then) (do ..monad [?bound (read id)] - (else (maybe.default (#.Var id) ?bound))))) + (else (maybe.else (#.Var id) ?bound))))) ## TODO: "link_2" can be optimized... (def: (link_2 left right) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index f44509aaa..2063b9de1 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -133,7 +133,7 @@ (do meta.monad [local_batches meta.locals #let [total_locals (list\fold (function (_ [name type] table) - (try.default table (dictionary.try_put name type table))) + (try.else table (dictionary.try_put name type table))) (: (Dictionary Text Type) (dictionary.new text.hash)) (list\join local_batches))]] diff --git a/stdlib/source/library/lux/type/unit.lux b/stdlib/source/library/lux/type/unit.lux index 790aa77ad..9d2bbd9bf 100644 --- a/stdlib/source/library/lux/type/unit.lux +++ b/stdlib/source/library/lux/type/unit.lux @@ -87,7 +87,7 @@ {export |export|.parser} {type_name <code>.local_identifier} {unit_name <code>.local_identifier} - {annotations (<>.default |annotations|.empty |annotations|.parser)}) + {annotations (<>.else |annotations|.empty |annotations|.parser)}) (do meta.monad [@ meta.current_module_name #let [g!type (code.local_identifier type_name)]] @@ -118,7 +118,7 @@ {type_name <code>.local_identifier} {scale_name <code>.local_identifier} {(^slots [#ratio.numerator #ratio.denominator]) ..scale} - {annotations (<>.default |annotations|.empty |annotations|.parser)}) + {annotations (<>.else |annotations|.empty |annotations|.parser)}) (do meta.monad [@ meta.current_module_name #let [g!scale (code.local_identifier type_name)]] diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 962636aa9..db20b54a4 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -98,7 +98,7 @@ (All [!] (-> (System !) Path Text)) (|> (..un_nest fs path) (maybe\map product.right) - (maybe.default path))) + (maybe.else path))) (def: #export (async fs) (-> (System IO) (System Async)) @@ -210,7 +210,7 @@ [(def: <name> (|>> java/io/File::new <method> - (io\map (|>> (try.default false)))))] + (io\map (|>> (try.else false)))))] [file? java/io/File::isFile] [directory? java/io/File::isDirectory] @@ -580,7 +580,7 @@ (~~ (template [<name> <method>] [(def: <name> (|>> <method> - (io\map (|>> (try.default false)))))] + (io\map (|>> (try.else false)))))] [file? os/path::isfile] [directory? os/path::isdir] @@ -706,7 +706,7 @@ (~~ (template [<name> <test>] [(def: <name> (|>> <test> - (io\map (|>> (try.default false)))))] + (io\map (|>> (try.else false)))))] [file? RubyFile::file?] [directory? RubyFile::directory?] @@ -1181,7 +1181,7 @@ (\ stm.monad map (|>> (<retrieve> separator path) (try\map (function.constant true)) - (try.default false))) + (try.else false))) stm.commit))] [file? ..retrieve_mock_file!] diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index eea669a47..e1e572023 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -433,7 +433,7 @@ (do async.monad [?concern (stop path)] (do (try.with async.monad) - [key (..default_start (..watch_events (..also (try.default ..none ?concern) + [key (..default_start (..watch_events (..also (try.else ..none ?concern) concern)) watcher path)] diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux index 02cc6ed91..0861d7d96 100644 --- a/stdlib/source/library/lux/world/net/http/client.lux +++ b/stdlib/source/library/lux/world/net/http/client.lux @@ -110,7 +110,7 @@ (def: (default_body input) (-> java/io/BufferedInputStream (//.Body IO)) (|>> (maybe\map (|>> [true])) - (maybe.default [false ..default_buffer_size]) + (maybe.else [false ..default_buffer_size]) (case> [_ 0] (do (try.with io.monad) [_ (java/lang/AutoCloseable::close input)] @@ -165,7 +165,7 @@ (do ! [?value (java/net/URLConnection::getHeaderField index connection)] (recur (inc index) - (dictionary.put name (maybe.default "" ?value) headers))) + (dictionary.put name (maybe.else "" ?value) headers))) #.None (in headers))))) diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index a65f5b2c0..7ef59466b 100644 --- a/stdlib/source/library/lux/world/net/http/request.lux +++ b/stdlib/source/library/lux/world/net/http/request.lux @@ -85,7 +85,7 @@ (let [full (get@ #//.uri resource) [uri query] (|> full (text.split_with "?") - (maybe.default [full ""]))] + (maybe.else [full ""]))] (case (do try.monad [query (//query.parameters query) input (context.run query property)] @@ -118,7 +118,7 @@ (case (do try.monad [cookies (|> (get@ #//.headers message) (dictionary.get "Cookie") - (maybe.default "") + (maybe.else "") //cookie.get)] (context.run cookies property)) (#try.Success input) diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index 730a2001a..f73621cae 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -252,7 +252,7 @@ (do ! [?output (LuaFile::read ["*l"] file) _ (LuaFile::close [] file)] - (in (maybe.default default ?output))) + (in (maybe.else default ?output))) #.None (in default)) @@ -378,7 +378,7 @@ (def: home (io.run (with_expansions [<default> (io.io "~") - <jvm> (io.io (maybe.default "" (java/lang/System::getProperty "user.home")))] + <jvm> (io.io (maybe.else "" (java/lang/System::getProperty "user.home")))] (for {@.old <jvm> @.jvm <jvm> @.js (if ffi.on_node_js? @@ -401,7 +401,7 @@ (def: directory (io.run (with_expansions [<default> "." - <jvm> (io.io (maybe.default "" (java/lang/System::getProperty "user.dir")))] + <jvm> (io.io (maybe.else "" (java/lang/System::getProperty "user.dir")))] (for {@.old <jvm> @.jvm <jvm> @.js (if ffi.on_node_js? |