diff options
Diffstat (limited to 'stdlib/source/library/lux/data')
35 files changed, 791 insertions, 788 deletions
diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index e4a07b788..312f74be1 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -198,13 +198,13 @@ (def: .public (read/8! index binary) (-> Nat Binary (Try I64)) (if (n.< (..!size binary) index) - {#try.Success (!read index binary)} + {try.#Success (!read index binary)} (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (read/16! index binary) (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 1 index)) - {#try.Success ($_ i64.or + {try.#Success ($_ i64.or (i64.left_shifted 8 (!read index binary)) (!read (n.+ 1 index) binary))} (exception.except ..index_out_of_bounds [(..!size binary) index]))) @@ -212,7 +212,7 @@ (def: .public (read/32! index binary) (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 3 index)) - {#try.Success ($_ i64.or + {try.#Success ($_ i64.or (i64.left_shifted 24 (!read index binary)) (i64.left_shifted 16 (!read (n.+ 1 index) binary)) (i64.left_shifted 8 (!read (n.+ 2 index) binary)) @@ -222,7 +222,7 @@ (def: .public (read/64! index binary) (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 7 index)) - {#try.Success ($_ i64.or + {try.#Success ($_ i64.or (i64.left_shifted 56 (!read index binary)) (i64.left_shifted 48 (!read (n.+ 1 index) binary)) (i64.left_shifted 40 (!read (n.+ 2 index) binary)) @@ -236,14 +236,14 @@ (def: .public (write/8! index value binary) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) index) - {#try.Success (|> binary + {try.#Success (|> binary (!write index value))} (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (write/16! index value binary) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 1 index)) - {#try.Success (|> binary + {try.#Success (|> binary (!write index (i64.right_shifted 8 value)) (!write (n.+ 1 index) value))} (exception.except ..index_out_of_bounds [(..!size binary) index]))) @@ -251,7 +251,7 @@ (def: .public (write/32! index value binary) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 3 index)) - {#try.Success (|> binary + {try.#Success (|> binary (!write index (i64.right_shifted 24 value)) (!write (n.+ 1 index) (i64.right_shifted 16 value)) (!write (n.+ 2 index) (i64.right_shifted 8 value)) @@ -269,8 +269,8 @@ (!write (n.+ 5 index) (i64.right_shifted 16 value)) (!write (n.+ 6 index) (i64.right_shifted 8 value)) (!write (n.+ 7 index) value))] - (|> binary write_high write_low #try.Success))] - {#try.Success (|> binary + (|> binary write_high write_low {try.#Success}))] + {try.#Success (|> binary (!write index (i64.right_shifted 56 value)) (!write (n.+ 1 index) (i64.right_shifted 48 value)) (!write (n.+ 2 index) (i64.right_shifted 40 value)) @@ -329,7 +329,7 @@ (!read (n.+ source_offset index) source) target) (recur (++ index))) - {#try.Success target}))))))) + {try.#Success target}))))))) (def: .public (slice offset length binary) (-> Nat Nat Binary (Try Binary)) @@ -337,7 +337,7 @@ limit (n.+ length offset)] (if (n.> size limit) (exception.except ..slice_out_of_bounds [size offset length]) - (with_expansions [<jvm> (as_is {#try.Success (java/util/Arrays::copyOfRange binary (.int offset) (.int limit))})] + (with_expansions [<jvm> (as_is {try.#Success (java/util/Arrays::copyOfRange binary (.int offset) (.int limit))})] (for [@.old <jvm> @.jvm <jvm>] @@ -350,10 +350,10 @@ 0 binary _ (let [distance (n.- bytes (..!size binary))] (case (..slice bytes distance binary) - {#try.Success slice} + {try.#Success slice} slice - {#try.Failure _} + {try.#Failure _} (..empty 0))))) (implementation: .public monoid diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux index d78777213..831497deb 100644 --- a/stdlib/source/library/lux/data/bit.lux +++ b/stdlib/source/library/lux/data/bit.lux @@ -56,9 +56,9 @@ (def: (decoded input) (case input - "#1" {#.Right #1} - "#0" {#.Right #0} - _ {#.Left "Wrong syntax for Bit."}))) + "#1" {.#Right #1} + "#0" {.#Right #0} + _ {.#Left "Wrong syntax for Bit."}))) (def: .public complement (All (_ a) (-> (-> a Bit) (-> a Bit))) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 73cc3e9d0..08cfac991 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -22,7 +22,7 @@ "#Array") (type: .public (Array a) - {#.Primitive ..type_name {#.Item a #.End}}) + {.#Primitive ..type_name {.#Item a {.#End}}}) (with_expansions [<index_type> (primitive "java.lang.Long") <elem_type> (primitive "java.lang.Object") @@ -78,8 +78,8 @@ (template: (!read! <read!> <null?>) [(let [output (<read!> index array)] (if (<null?> output) - #.None - {#.Some output}))]) + {.#None} + {.#Some output}))]) (def: .public (read! index array) (All (_ a) @@ -88,16 +88,16 @@ (for [@.old (let [value ("jvm aaload" array index)] (if ("jvm object null?" value) - #.None - {#.Some value})) + {.#None} + {.#Some value})) @.jvm (let [value (|> array (:as <array_type>) ("jvm array read object" (!int index)))] (if ("jvm object null?" value) - #.None - {#.Some (:expected value)})) + {.#None} + {.#Some (:expected value)})) @.js (!read! "js array read" "js object undefined?") @.python (!read! "python array read" "python object none?") @@ -105,7 +105,7 @@ @.ruby (!read! "ruby array read" "ruby object nil?") @.php (!read! "php array read" "php object null?") @.scheme (!read! "scheme array read" "scheme object nil?")]) - #.None)) + {.#None})) (def: .public (write! index value array) (All (_ a) @@ -149,7 +149,7 @@ (All (_ a) (-> Nat (Array a) Bit)) (case (..read! index array) - {#.Some _} + {.#Some _} true _ @@ -159,10 +159,10 @@ (All (_ a) (-> Nat (-> a a) (Array a) (Array a))) (case (read! index array) - #.None + {.#None} array - {#.Some value} + {.#Some value} (write! index (transform value) array))) (def: .public (upsert! index default transform array) @@ -180,10 +180,10 @@ dest_array (list\mix (function (_ offset target) (case (read! (n.+ offset src_start) src_array) - #.None + {.#None} target - {#.Some value} + {.#Some value} (write! (n.+ offset dest_start) value target))) dest_array (list.indices length)))) @@ -192,10 +192,10 @@ (All (_ a) (-> (Array a) Nat)) (list\mix (function (_ idx count) (case (read! idx array) - #.None + {.#None} count - {#.Some _} + {.#Some _} (++ count))) 0 (list.indices (size array)))) @@ -209,10 +209,10 @@ (-> (Predicate a) (Array a) (Array a))) (list\mix (function (_ idx xs') (case (read! idx xs) - #.None + {.#None} xs' - {#.Some x} + {.#Some x} (if (p x) xs' (delete! idx xs')))) @@ -226,14 +226,14 @@ (loop [idx 0] (if (n.< arr_size idx) (case (read! idx xs) - #.None + {.#None} (recur (++ idx)) - {#.Some x} + {.#Some x} (if (p x) - {#.Some x} + {.#Some x} (recur (++ idx)))) - #.None)))) + {.#None})))) (def: .public (example+ p xs) (All (_ a) @@ -242,24 +242,24 @@ (loop [idx 0] (if (n.< arr_size idx) (case (read! idx xs) - #.None + {.#None} (recur (++ idx)) - {#.Some x} + {.#Some x} (if (p idx x) - {#.Some [idx x]} + {.#Some [idx x]} (recur (++ idx)))) - #.None)))) + {.#None})))) (def: .public (clone xs) (All (_ a) (-> (Array a) (Array a))) (let [arr_size (size xs)] (list\mix (function (_ idx ys) (case (read! idx xs) - #.None + {.#None} ys - {#.Some x} + {.#Some x} (write! idx x ys))) (empty arr_size) (list.indices arr_size)))) @@ -278,7 +278,7 @@ (def: (list|-default array) (All (_ a) (-> (Array a) (List a))) (loop [idx (-- (size array)) - output #.End] + output {.#End}] (case idx (^ (static ..underflow)) output @@ -286,32 +286,32 @@ _ (recur (-- idx) (case (read! idx array) - {#.Some head} - {#.Item head output} + {.#Some head} + {.#Item head output} - #.None + {.#None} output))))) (def: (list|+default default array) (All (_ a) (-> a (Array a) (List a))) (loop [idx (-- (size array)) - output #.End] + output {.#End}] (case idx (^ (static ..underflow)) output _ (recur (-- idx) - {#.Item (maybe.else default (read! idx array)) + {.#Item (maybe.else default (read! idx array)) output})))) (def: .public (list default array) (All (_ a) (-> (Maybe a) (Array a) (List a))) (case default - {#.Some default} + {.#Some default} (list|+default default array) - #.None + {.#None} (list|-default array))) (implementation: .public (equivalence (^open ",\[0]")) @@ -324,10 +324,10 @@ (list\mix (function (_ idx prev) (and prev (case [(read! idx xs) (read! idx ys)] - [#.None #.None] + [{.#None} {.#None}] true - [{#.Some x} {#.Some y}] + [{.#Some x} {.#Some y}] (,\= x y) _ @@ -356,10 +356,10 @@ (empty arr_size) (list\mix (function (_ idx mb) (case (read! idx ma) - #.None + {.#None} mb - {#.Some x} + {.#Some x} (write! idx (f x) mb))) (empty arr_size) (list.indices arr_size)) @@ -374,10 +374,10 @@ idx 0] (if (n.< arr_size idx) (case (read! idx xs) - #.None + {.#None} (recur so_far (++ idx)) - {#.Some value} + {.#Some value} (recur (f value so_far) (++ idx))) so_far))))) @@ -390,11 +390,11 @@ (loop [idx 0] (if (n.< size idx) (case (..read! idx array) - {#.Some value} + {.#Some value} (<op> (predicate value) (recur (++ idx))) - #.None + {.#None} (recur (++ idx))) <init>)))))] diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index 0b9690eb3..bdfc2638a 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -240,12 +240,12 @@ (product.right (list\mix (function (_ idx [insertion_idx node]) (let [[bitmap base] node] (case (array.read! idx h_array) - #.None [insertion_idx node] - {#.Some sub_node} (if (n.= except_idx idx) + {.#None} [insertion_idx node] + {.#Some sub_node} (if (n.= except_idx idx) [insertion_idx node] [(++ insertion_idx) [(with_bit_position (to_bit_position idx) bitmap) - (array.write! insertion_idx {#.Left sub_node} base)]]) + (array.write! insertion_idx {.#Left sub_node} base)]]) ))) [0 [clean_bitmap (array.empty (-- h_size))]] @@ -268,15 +268,15 @@ bitmap) [(++ base_idx) (case (array.read! base_idx base) - {#.Some {#.Left sub_node}} + {.#Some {.#Left sub_node}} (array.write! hierarchy_idx sub_node h_array) - {#.Some {#.Right [key' val']}} + {.#Some {.#Right [key' val']}} (array.write! hierarchy_idx (node\has (level_up level) (\ key_hash hash key') key' val' key_hash empty_node) h_array) - #.None + {.#None} (undefined))] default)) [0 @@ -303,7 +303,7 @@ {#Hierarchy _size hierarchy} (let [idx (level_index level hash) [_size' sub_node] (case (array.read! idx hierarchy) - {#.Some sub_node} + {.#Some sub_node} [_size sub_node] _ @@ -321,18 +321,18 @@ (let [idx (base_index bit bitmap)] (case (array.read! idx base) ... If it's being used by a node, add the KV to it. - {#.Some {#.Left sub_node}} + {.#Some {.#Left sub_node}} (let [sub_node' (node\has (level_up level) hash key val key_hash sub_node)] - {#Base bitmap (array\revised idx {#.Left sub_node'} base)}) + {#Base bitmap (array\revised idx {.#Left sub_node'} base)}) ... Otherwise, if it's being used by a KV, compare the keys. - {#.Some {#.Right key' val'}} + {.#Some {.#Right key' val'}} (if (\ key_hash = key key') ... If the same key is found, replace the value. - {#Base bitmap (array\revised idx {#.Right key val} base)} + {#Base bitmap (array\revised idx {.#Right key val} base)} ... Otherwise, compare the hashes of the keys. {#Base bitmap (array\revised idx - {#.Left (let [hash' (\ key_hash hash key')] + {.#Left (let [hash' (\ key_hash hash key')] (if (n.= hash hash') ... If the hashes are ... the same, a new @@ -352,7 +352,7 @@ (node\has next_level hash key val key_hash)))))} base)}) - #.None + {.#None} (undefined))) ... However, if the Bit_Position has not been used yet, check ... whether this #Base node is ready for a promotion. @@ -361,7 +361,7 @@ ... If so, resize the #Base node to accommodate the ... new KV-pair. {#Base (with_bit_position bit bitmap) - (array\has (base_index bit bitmap) {#.Right [key val]} base)} + (array\has (base_index bit bitmap) {.#Right [key val]} base)} ... Otherwise, promote it to a #Hierarchy node, and add the new ... KV-pair as a singleton node to it. {#Hierarchy (++ base_count) @@ -378,17 +378,17 @@ (case (collision_index key_hash key _colls) ... If the key was already present in the collisions-list, its ... value gets updated. - {#.Some coll_idx} + {.#Some coll_idx} {#Collisions _hash (array\revised coll_idx [key val] _colls)} ... Otherwise, the KV-pair is added to the collisions-list. - #.None + {.#None} {#Collisions _hash (array\has (array.size _colls) [key val] _colls)}) ... If the hashes are not equal, create a new #Base node that ... contains the old #Collisions node, plus the new KV-pair. (|> {#Base (level_bit_position level _hash) (|> (array.empty 1) - (array.write! 0 {#.Left node}))} + (array.write! 0 {.#Left node}))} (node\has level hash key val key_hash))) )) @@ -401,11 +401,11 @@ (let [idx (level_index level hash)] (case (array.read! idx h_array) ... If not, there's nothing to remove. - #.None + {.#None} node ... But if there is, try to remove the key from the sub-node. - {#.Some sub_node} + {.#Some sub_node} (let [sub_node' (node\lacks (level_up level) hash key key_hash sub_node)] ... Then check if a removal was actually done. (if (same? sub_node sub_node') @@ -431,7 +431,7 @@ (case (array.read! idx base) ... If set, check if it's a sub_node, and remove the KV ... from it. - {#.Some {#.Left sub_node}} + {.#Some {.#Left sub_node}} (let [sub_node' (node\lacks (level_up level) hash key key_hash sub_node)] ... Verify that it was removed. (if (same? sub_node sub_node') @@ -450,10 +450,10 @@ ... But, if it did not come out empty, then the ... position is kept, and the node gets updated. {#Base bitmap - (array\revised idx {#.Left sub_node'} base)}))) + (array\revised idx {.#Left sub_node'} base)}))) ... If, however, there was a KV-pair instead of a sub-node. - {#.Some {#.Right [key' val']}} + {.#Some {.#Right [key' val']}} ... Check if the keys match. (if (\ key_hash = key key') ... If so, remove the KV-pair and unset the Bit_Position. @@ -462,7 +462,7 @@ ... Otherwise, there's nothing to remove. node) - #.None + {.#None} (undefined))) ... If the Bit_Position is not set, there's nothing to remove. node)) @@ -471,11 +471,11 @@ {#Collisions _hash _colls} (case (collision_index key_hash key _colls) ... If not, then there's nothing to remove. - #.None + {.#None} node ... But if so, then check the size of the collisions list. - {#.Some idx} + {.#Some idx} (if (n.= 1 (array.size _colls)) ... If there's only one left, then removing it leaves us with ... an empty node. @@ -490,25 +490,25 @@ ... 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} (node\value (level_up level) hash key key_hash sub_node)) + {.#None} {.#None} + {.#Some sub_node} (node\value (level_up level) hash key key_hash sub_node)) ... For #Base nodes, check the leaves, and recursively check the branches. {#Base bitmap base} (let [bit (level_bit_position level hash)] (if (with_bit_position? bit bitmap) (case (array.read! (base_index bit bitmap) base) - {#.Some {#.Left sub_node}} + {.#Some {.#Left sub_node}} (node\value (level_up level) hash key key_hash sub_node) - {#.Some {#.Right [key' val']}} + {.#Some {.#Right [key' val']}} (if (\ key_hash = key key') - {#.Some val'} - #.None) + {.#Some val'} + {.#None}) - #.None + {.#None} (undefined)) - #.None)) + {.#None})) ... For #Collisions nodes, do a linear scan of all the known KV-pairs. {#Collisions _hash _colls} @@ -526,8 +526,8 @@ {#Base _ base} (array\mix n.+ 0 (array\each (function (_ sub_node') (case sub_node' - {#.Left sub_node} (node\size sub_node) - {#.Right _} 1)) + {.#Left sub_node} (node\size sub_node) + {.#Right _} 1)) base)) {#Collisions hash colls} @@ -539,23 +539,23 @@ (case node {#Hierarchy _size hierarchy} (array\mix (function (_ sub_node tail) (list\composite (node\entries sub_node) tail)) - #.End + {.#End} hierarchy) {#Base bitmap base} (array\mix (function (_ branch tail) (case branch - {#.Left sub_node} + {.#Left sub_node} (list\composite (node\entries sub_node) tail) - {#.Right [key' val']} - {#.Item [key' val'] tail})) - #.End + {.#Right [key' val']} + {.#Item [key' val'] tail})) + {.#End} base) {#Collisions hash colls} - (array\mix (function (_ [key' val'] tail) {#.Item [key' val'] tail}) - #.End + (array\mix (function (_ [key' val'] tail) {.#Item [key' val'] tail}) + {.#End} colls))) (type: .public (Dictionary k v) @@ -565,7 +565,7 @@ (def: .public key_hash (All (_ k v) (-> (Dictionary k v) (Hash k))) - (value@ #..hash)) + (value@ ..#hash)) (def: .public (empty key_hash) (All (_ k v) (-> (Hash k) (Dictionary k v))) @@ -590,24 +590,24 @@ (def: .public (key? dict key) (All (_ k v) (-> (Dictionary k v) k Bit)) (case (value key dict) - #.None #0 - {#.Some _} #1)) + {.#None} #0 + {.#Some _} #1)) (exception: .public key_already_exists) (def: .public (has' key val dict) (All (_ k v) (-> k v (Dictionary k v) (Try (Dictionary k v)))) (case (value key dict) - #.None {#try.Success (has key val dict)} - {#.Some _} (exception.except ..key_already_exists []))) + {.#None} {try.#Success (has key val dict)} + {.#Some _} (exception.except ..key_already_exists []))) (def: .public (revised key f dict) (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (value key dict) - #.None + {.#None} dict - {#.Some val} + {.#Some val} (has key (f val) dict))) (def: .public (revised' key default f dict) @@ -641,8 +641,8 @@ (All (_ k v) (-> (Dictionary k v) (List <side>))) (|>> ..entries (list\mix (function (_ [k v] bundle) - {#.Item <side> bundle}) - #.End)))] + {.#Item <side> bundle}) + {.#End})))] [k keys] [v values] @@ -658,10 +658,10 @@ (All (_ k v) (-> (-> v v v) (Dictionary k v) (Dictionary k v) (Dictionary k v))) (list\mix (function (_ [key val2] dict) (case (value key dict) - #.None + {.#None} (has key val2 dict) - {#.Some val1} + {.#Some val1} (has key (f val2 val1) dict))) dict1 (entries dict2))) @@ -669,10 +669,10 @@ (def: .public (re_bound from_key to_key dict) (All (_ k v) (-> k k (Dictionary k v) (Dictionary k v))) (case (value from_key dict) - #.None + {.#None} dict - {#.Some val} + {.#Some val} (|> dict (lacks from_key) (has to_key val)))) @@ -682,8 +682,8 @@ (let [[key_hash _] dict] (list\mix (function (_ key new_dict) (case (value key dict) - #.None new_dict - {#.Some val} (has key val new_dict))) + {.#None} new_dict + {.#Some val} (has key val new_dict))) (empty key_hash) keys))) @@ -695,7 +695,7 @@ (..size subject)) (list.every? (function (_ [k rv]) (case (..value k subject) - {#.Some sv} + {.#Some sv} (,\= rv sv) _ @@ -713,11 +713,11 @@ {#Base bitmap base} {#Base bitmap (array\each (function (_ either) (case either - {#.Left fa'} - {#.Left (each f fa')} + {.#Left fa'} + {.#Left (each f fa')} - {#.Right [k v]} - {#.Right [k (f v)]})) + {.#Right [k v]} + {.#Right [k (f v)]})) base)} {#Collisions hash collisions} diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index d6376e88b..1fc2e3ea5 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -20,8 +20,8 @@ (type: Color (Variant - #Red - #Black)) + {#Red} + {#Black})) (type: (Node k v) (Record @@ -34,7 +34,7 @@ (template [<create> <color>] [(def: (<create> key value left right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) - [#color <color> + [#color {<color>} #key key #value value #left left @@ -52,7 +52,7 @@ (def: .public (empty order) (All (_ k v) (-> (Order k) (Dictionary k v))) [#&order order - #root #.None]) + #root {.#None}]) ... TODO: Doing inneficient access of Order functions due to compiler bug. ... TODO: Must improve it as soon as bug is fixed. @@ -62,14 +62,14 @@ ] (loop [node (value@ #root dict)] (case node - #.None - #.None + {.#None} + {.#None} - {#.Some node} + {.#Some node} (let [node_key (value@ #key node)] (cond (\ dict = node_key key) ... (_\= node_key key) - {#.Some (value@ #value node)} + {.#Some (value@ #value node)} (\ dict < node_key key) ... (_\< node_key key) @@ -87,10 +87,10 @@ ] (loop [node (value@ #root dict)] (case node - #.None + {.#None} #0 - {#.Some node} + {.#Some node} (let [node_key (value@ #key node)] (or (\ dict = node_key key) ... (_\= node_key key) @@ -103,16 +103,16 @@ [(def: .public (<name> dict) (All (_ k v) (-> (Dictionary k v) (Maybe v))) (case (value@ #root dict) - #.None - #.None + {.#None} + {.#None} - {#.Some node} + {.#Some node} (loop [node node] (case (value@ <side> node) - #.None - {#.Some (value@ #value node)} + {.#None} + {.#Some (value@ #value node)} - {#.Some side} + {.#Some side} (recur side)))))] [min #left] @@ -123,10 +123,10 @@ (All (_ k v) (-> (Dictionary k v) Nat)) (loop [node (value@ #root dict)] (case node - #.None + {.#None} 0 - {#.Some node} + {.#Some node} (++ (n.+ (recur (value@ #left node)) (recur (value@ #right node))))))) @@ -138,10 +138,10 @@ [(def: (<name> self) (All (_ k v) (-> (Node k v) (Node k v))) (case (value@ #color self) - <other_color> - (with@ #color <self_color> self) + {<other_color>} + (with@ #color {<self_color>} self) - <self_color> + {<self_color>} <no_change> ))] @@ -152,42 +152,42 @@ (def: (with_left addition center) (All (_ k v) (-> (Node k v) (Node k v) (Node k v))) (case (value@ #color center) - #Red + {#Red} (red (value@ #key center) (value@ #value center) - {#.Some addition} + {.#Some addition} (value@ #right center)) - #Black + {#Black} (with_expansions [<default_behavior> (as_is (black (value@ #key center) (value@ #value center) - {#.Some addition} + {.#Some addition} (value@ #right center)))] (case (value@ #color addition) - #Red + {#Red} (case (value@ #left addition) - (^multi {#.Some left} - [(value@ #color left) #Red]) + (^multi {.#Some left} + [(value@ #color left) {#Red}]) (red (value@ #key addition) (value@ #value addition) - {#.Some (blackened left)} - {#.Some (black (value@ #key center) + {.#Some (blackened left)} + {.#Some (black (value@ #key center) (value@ #value center) (value@ #right addition) (value@ #right center))}) _ (case (value@ #right addition) - (^multi {#.Some right} - [(value@ #color right) #Red]) + (^multi {.#Some right} + [(value@ #color right) {#Red}]) (red (value@ #key right) (value@ #value right) - {#.Some (black (value@ #key addition) + {.#Some (black (value@ #key addition) (value@ #value addition) (value@ #left addition) (value@ #left right))} - {#.Some (black (value@ #key center) + {.#Some (black (value@ #key center) (value@ #value center) (value@ #right right) (value@ #right center))}) @@ -195,48 +195,48 @@ _ <default_behavior>)) - #Black + {#Black} <default_behavior>)))) (def: (with_right addition center) (All (_ k v) (-> (Node k v) (Node k v) (Node k v))) (case (value@ #color center) - #Red + {#Red} (red (value@ #key center) (value@ #value center) (value@ #left center) - {#.Some addition}) + {.#Some addition}) - #Black + {#Black} (with_expansions [<default_behavior> (as_is (black (value@ #key center) (value@ #value center) (value@ #left center) - {#.Some addition}))] + {.#Some addition}))] (case (value@ #color addition) - #Red + {#Red} (case (value@ #right addition) - (^multi {#.Some right} - [(value@ #color right) #Red]) + (^multi {.#Some right} + [(value@ #color right) {#Red}]) (red (value@ #key addition) (value@ #value addition) - {#.Some (black (value@ #key center) + {.#Some (black (value@ #key center) (value@ #value center) (value@ #left center) (value@ #left addition))} - {#.Some (blackened right)}) + {.#Some (blackened right)}) _ (case (value@ #left addition) - (^multi {#.Some left} - [(value@ #color left) #Red]) + (^multi {.#Some left} + [(value@ #color left) {#Red}]) (red (value@ #key left) (value@ #value left) - {#.Some (black (value@ #key center) + {.#Some (black (value@ #key center) (value@ #value center) (value@ #left center) (value@ #left left))} - {#.Some (black (value@ #key addition) + {.#Some (black (value@ #key addition) (value@ #value addition) (value@ #right left) (value@ #right addition))}) @@ -244,7 +244,7 @@ _ <default_behavior>)) - #Black + {#Black} <default_behavior>)))) (def: .public (has key value dict) @@ -252,10 +252,10 @@ (let [(^open "_\[0]") (value@ #&order dict) root' (loop [?root (value@ #root dict)] (case ?root - #.None - {#.Some (red key value #.None #.None)} + {.#None} + {.#Some (red key value {.#None} {.#None})} - {#.Some root} + {.#Some root} (let [reference (value@ #key root)] (`` (cond (~~ (template [<comp> <tag> <add>] [(<comp> reference key) @@ -263,15 +263,15 @@ outcome (recur side_root)] (if (same? side_root outcome) ?root - {#.Some (<add> (maybe.trusted outcome) + {.#Some (<add> (maybe.trusted outcome) root)}))] - [_\< #left ..with_left] + [_\< #left ..with_left] [(order.> (value@ #&order dict)) #right ..with_right] )) ... (_\= reference key) - {#.Some (with@ #value value root)} + {.#Some (with@ #value value root)} ))) ))] (with@ #root root' dict))) @@ -279,26 +279,26 @@ (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} - [(value@ #color left) #Red] - [(value@ #left left) {#.Some left>>left}] - [(value@ #color left>>left) #Red]) + (^multi {.#Some left} + [(value@ #color left) {#Red}] + [(value@ #left left) {.#Some left>>left}] + [(value@ #color left>>left) {#Red}]) (red (value@ #key left) (value@ #value left) - {#.Some (blackened left>>left)} - {#.Some (black key value (value@ #right left) ?right)}) + {.#Some (blackened left>>left)} + {.#Some (black key value (value@ #right left) ?right)}) - (^multi {#.Some left} - [(value@ #color left) #Red] - [(value@ #right left) {#.Some left>>right}] - [(value@ #color left>>right) #Red]) + (^multi {.#Some left} + [(value@ #color left) {#Red}] + [(value@ #right left) {.#Some left>>right}] + [(value@ #color left>>right) {#Red}]) (red (value@ #key left>>right) (value@ #value left>>right) - {#.Some (black (value@ #key left) + {.#Some (black (value@ #key left) (value@ #value left) (value@ #left left) (value@ #left left>>right))} - {#.Some (black key value + {.#Some (black key value (value@ #right left>>right) ?right)}) @@ -308,23 +308,23 @@ (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} - [(value@ #color right) #Red] - [(value@ #right right) {#.Some right>>right}] - [(value@ #color right>>right) #Red]) + (^multi {.#Some right} + [(value@ #color right) {#Red}] + [(value@ #right right) {.#Some right>>right}] + [(value@ #color right>>right) {#Red}]) (red (value@ #key right) (value@ #value right) - {#.Some (black key value ?left (value@ #left right))} - {#.Some (blackened right>>right)}) + {.#Some (black key value ?left (value@ #left right))} + {.#Some (blackened right>>right)}) - (^multi {#.Some right} - [(value@ #color right) #Red] - [(value@ #left right) {#.Some right>>left}] - [(value@ #color right>>left) #Red]) + (^multi {.#Some right} + [(value@ #color right) {#Red}] + [(value@ #left right) {.#Some right>>left}] + [(value@ #color right>>left) {#Red}]) (red (value@ #key right>>left) (value@ #value right>>left) - {#.Some (black key value ?left (value@ #left right>>left))} - {#.Some (black (value@ #key right) + {.#Some (black key value ?left (value@ #left right>>left))} + {.#Some (black (value@ #key right) (value@ #value right) (value@ #right right>>left) (value@ #right right))}) @@ -335,24 +335,24 @@ (def: (without_left key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left - (^multi {#.Some left} - [(value@ #color left) #Red]) - (red key value {#.Some (blackened left)} ?right) + (^multi {.#Some left} + [(value@ #color left) {#Red}]) + (red key value {.#Some (blackened left)} ?right) _ (case ?right - (^multi {#.Some right} - [(value@ #color right) #Black]) - (right_balanced key value ?left {#.Some (reddened right)}) - - (^multi {#.Some right} - [(value@ #color right) #Red] - [(value@ #left right) {#.Some right>>left}] - [(value@ #color right>>left) #Black]) + (^multi {.#Some right} + [(value@ #color right) {#Black}]) + (right_balanced key value ?left {.#Some (reddened right)}) + + (^multi {.#Some right} + [(value@ #color right) {#Red}] + [(value@ #left right) {.#Some right>>left}] + [(value@ #color right>>left) {#Black}]) (red (value@ #key right>>left) (value@ #value right>>left) - {#.Some (black key value ?left (value@ #left right>>left))} - {#.Some (right_balanced (value@ #key right) + {.#Some (black key value ?left (value@ #left right>>left))} + {.#Some (right_balanced (value@ #key right) (value@ #value right) (value@ #right right>>left) (\ maybe.functor each reddened (value@ #right right)))}) @@ -364,27 +364,27 @@ (def: (without_right key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right - (^multi {#.Some right} - [(value@ #color right) #Red]) - (red key value ?left {#.Some (blackened right)}) + (^multi {.#Some right} + [(value@ #color right) {#Red}]) + (red key value ?left {.#Some (blackened right)}) _ (case ?left - (^multi {#.Some left} - [(value@ #color left) #Black]) - (left_balanced key value {#.Some (reddened left)} ?right) - - (^multi {#.Some left} - [(value@ #color left) #Red] - [(value@ #right left) {#.Some left>>right}] - [(value@ #color left>>right) #Black]) + (^multi {.#Some left} + [(value@ #color left) {#Black}]) + (left_balanced key value {.#Some (reddened left)} ?right) + + (^multi {.#Some left} + [(value@ #color left) {#Red}] + [(value@ #right left) {.#Some left>>right}] + [(value@ #color left>>right) {#Black}]) (red (value@ #key left>>right) (value@ #value left>>right) - {#.Some (left_balanced (value@ #key left) + {.#Some (left_balanced (value@ #key left) (value@ #value left) (\ maybe.functor each reddened (value@ #left left)) (value@ #left left>>right))} - {#.Some (black key value (value@ #right left>>right) ?right)}) + {.#Some (black key value (value@ #right left>>right) ?right)}) _ (panic! error_message) @@ -393,76 +393,76 @@ (def: (prepended ?left ?right) (All (_ k v) (-> (Maybe (Node k v)) (Maybe (Node k v)) (Maybe (Node k v)))) (case [?left ?right] - [#.None _] + [{.#None} _] ?right - [_ #.None] + [_ {.#None}] ?left - [{#.Some left} {#.Some right}] + [{.#Some left} {.#Some right}] (case [(value@ #color left) (value@ #color right)] - [#Red #Red] + [{#Red} {#Red}] (do maybe.monad [fused (prepended (value@ #right left) (value@ #right right))] (case (value@ #color fused) - #Red + {#Red} (in (red (value@ #key fused) (value@ #value fused) - {#.Some (red (value@ #key left) + {.#Some (red (value@ #key left) (value@ #value left) (value@ #left left) (value@ #left fused))} - {#.Some (red (value@ #key right) + {.#Some (red (value@ #key right) (value@ #value right) (value@ #right fused) (value@ #right right))})) - #Black + {#Black} (in (red (value@ #key left) (value@ #value left) (value@ #left left) - {#.Some (red (value@ #key right) + {.#Some (red (value@ #key right) (value@ #value right) - {#.Some fused} + {.#Some fused} (value@ #right right))})))) - [#Red #Black] - {#.Some (red (value@ #key left) + [{#Red} {#Black}] + {.#Some (red (value@ #key left) (value@ #value left) (value@ #left left) (prepended (value@ #right left) ?right))} - [#Black #Red] - {#.Some (red (value@ #key right) + [{#Black} {#Red}] + {.#Some (red (value@ #key right) (value@ #value right) (prepended ?left (value@ #left right)) (value@ #right right))} - [#Black #Black] + [{#Black} {#Black}] (do maybe.monad [fused (prepended (value@ #right left) (value@ #left right))] (case (value@ #color fused) - #Red + {#Red} (in (red (value@ #key fused) (value@ #value fused) - {#.Some (black (value@ #key left) + {.#Some (black (value@ #key left) (value@ #value left) (value@ #left left) (value@ #left fused))} - {#.Some (black (value@ #key right) + {.#Some (black (value@ #key right) (value@ #value right) (value@ #right fused) (value@ #right right))})) - #Black + {#Black} (in (without_left (value@ #key left) (value@ #value left) (value@ #left left) - {#.Some (black (value@ #key right) + {.#Some (black (value@ #key right) (value@ #value right) - {#.Some fused} + {.#Some fused} (value@ #right right))})) )) ) @@ -475,10 +475,10 @@ (let [(^open "_\[0]") (value@ #&order dict) [?root found?] (loop [?root (value@ #root dict)] (case ?root - #.None - [#.None #0] + {.#None} + [{.#None} #0] - {#.Some root} + {.#Some root} (let [root_key (value@ #key root) root_val (value@ #value root)] (if (_\= root_key key) @@ -489,49 +489,49 @@ (case (recur (if go_left? (value@ #left root) (value@ #right root))) - [#.None #0] - [#.None #0] + [{.#None} #0] + [{.#None} #0] [side_outcome _] (if go_left? (case (value@ #left root) - (^multi {#.Some left} - [(value@ #color left) #Black]) - [{#.Some (without_left root_key root_val side_outcome (value@ #right root))} + (^multi {.#Some left} + [(value@ #color left) {#Black}]) + [{.#Some (without_left root_key root_val side_outcome (value@ #right root))} #0] _ - [{#.Some (red root_key root_val side_outcome (value@ #right root))} + [{.#Some (red root_key root_val side_outcome (value@ #right root))} #0]) (case (value@ #right root) - (^multi {#.Some right} - [(value@ #color right) #Black]) - [{#.Some (without_right root_key root_val (value@ #left root) side_outcome)} + (^multi {.#Some right} + [(value@ #color right) {#Black}]) + [{.#Some (without_right root_key root_val (value@ #left root) side_outcome)} #0] _ - [{#.Some (red root_key root_val (value@ #left root) side_outcome)} + [{.#Some (red root_key root_val (value@ #left root) side_outcome)} #0]) ))) )) ))] (case ?root - #.None + {.#None} (if found? (with@ #root ?root dict) dict) - {#.Some root} - (with@ #root {#.Some (blackened root)} dict) + {.#Some root} + (with@ #root {.#Some (blackened root)} dict) ))) (def: .public (revised key transform dict) (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (..value key dict) - {#.Some old} + {.#Some old} (..has key (transform old) dict) - #.None + {.#None} dict)) (def: .public (of_list order list) @@ -546,10 +546,10 @@ (All (_ k v) (-> (Dictionary k v) (List <type>))) (loop [node (value@ #root dict)] (case node - #.None + {.#None} (list) - {#.Some node'} + {.#Some node'} ($_ list\composite (recur (value@ #left node')) (list <output>) @@ -568,10 +568,10 @@ (loop [entriesR (entries reference) entriesS (entries sample)] (case [entriesR entriesS] - [#.End #.End] + [{.#End} {.#End}] #1 - [{#.Item [keyR valueR] entriesR'} {#.Item [keyS valueS] entriesS'}] + [{.#Item [keyR valueR] entriesR'} {.#Item [keyS valueS] entriesS'}] (and (/\= keyR keyS) (,\= valueR valueS) (recur entriesR' entriesS')) diff --git a/stdlib/source/library/lux/data/collection/dictionary/plist.lux b/stdlib/source/library/lux/data/collection/dictionary/plist.lux index bb7f63265..8ffa6682a 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux @@ -18,7 +18,7 @@ (def: .public empty PList - #.End) + {.#End}) (def: .public size (All (_ a) (-> (PList a) Nat)) @@ -31,12 +31,12 @@ (def: .public (value key properties) (All (_ a) (-> Text (PList a) (Maybe a))) (case properties - #.End - #.None + {.#End} + {.#None} - {#.Item [k' v'] properties'} + {.#Item [k' v'] properties'} (if (text\= key k') - {#.Some v'} + {.#Some v'} (value key properties')))) (template [<name> <type> <access>] @@ -51,46 +51,46 @@ (def: .public (contains? key properties) (All (_ a) (-> Text (PList a) Bit)) (case (..value key properties) - {#.Some _} + {.#Some _} true - #.None + {.#None} false)) (def: .public (has key val properties) (All (_ a) (-> Text a (PList a) (PList a))) (case properties - #.End + {.#End} (list [key val]) - {#.Item [k' v'] properties'} + {.#Item [k' v'] properties'} (if (text\= key k') - {#.Item [key val] + {.#Item [key val] properties'} - {#.Item [k' v'] + {.#Item [k' v'] (has key val properties')}))) (def: .public (revised key f properties) (All (_ a) (-> Text (-> a a) (PList a) (PList a))) (case properties - #.End - #.End + {.#End} + {.#End} - {#.Item [k' v'] properties'} + {.#Item [k' v'] properties'} (if (text\= key k') - {#.Item [k' (f v')] properties'} - {#.Item [k' v'] (revised key f properties')}))) + {.#Item [k' (f v')] properties'} + {.#Item [k' v'] (revised key f properties')}))) (def: .public (lacks key properties) (All (_ a) (-> Text (PList a) (PList a))) (case properties - #.End + {.#End} properties - {#.Item [k' v'] properties'} + {.#Item [k' v'] properties'} (if (text\= key k') properties' - {#.Item [k' v'] + {.#Item [k' v'] (lacks key properties')}))) (def: .public equivalence diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index e2cb06a42..4232af895 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -28,60 +28,61 @@ (def: (mix f init xs) (case xs - #.End + {.#End} init - {#.Item x xs'} + {.#Item x xs'} (mix f (f x init) xs')))) (def: .public (mixes f init inputs) (All (_ a b) (-> (-> a b b) b (List a) (List b))) (case inputs - #.End + {.#End} (list init) - {#.Item [head tail]} - {#.Item [init (mixes f (f head init) tail)]})) + {.#Item [head tail]} + {.#Item [init (mixes f (f head init) tail)]})) (def: .public (reversed xs) (All (_ a) (-> (List a) (List a))) - (mix (function (_ head tail) {#.Item head tail}) - #.End + (mix (function (_ head tail) + {.#Item head tail}) + {.#End} xs)) (def: .public (only keep? xs) (All (_ a) (-> (Predicate a) (List a) (List a))) (case xs - #.End - #.End + {.#End} + {.#End} - {#.Item x xs'} + {.#Item x xs'} (if (keep? x) - {#.Item x (only keep? xs')} + {.#Item x (only keep? xs')} (only keep? xs')))) (def: .public (partition satisfies? list) (All (_ a) (-> (Predicate a) (List a) [(List a) (List a)])) (case list - #.End - [#.End #.End] + {.#End} + [{.#End} {.#End}] - {#.Item head tail} + {.#Item head tail} (let [[in out] (partition satisfies? tail)] (if (satisfies? head) - [{#.Item head in} out] - [in {#.Item head out}])))) + [{.#Item head in} out] + [in {.#Item head out}])))) (def: .public (pairs xs) (All (_ a) (-> (List a) (List [a a]))) (case xs (^ (list& x1 x2 xs')) - {#.Item [x1 x2] (pairs xs')} + {.#Item [x1 x2] (pairs xs')} _ - #.End)) + {.#End})) (template [<name> <then> <else>] [(def: .public (<name> n xs) @@ -89,14 +90,14 @@ (-> Nat (List a) (List a))) (if (n.> 0 n) (case xs - #.End - #.End + {.#End} + {.#End} - {#.Item x xs'} + {.#Item x xs'} <then>) <else>))] - [first {#.Item x (first (-- n) xs')} #.End] + [first {.#Item x (first (-- n) xs')} {.#End}] [after (after (-- n) xs') xs] ) @@ -105,15 +106,15 @@ (All (_ a) (-> (Predicate a) (List a) (List a))) (case xs - #.End - #.End + {.#End} + {.#End} - {#.Item x xs'} + {.#Item x xs'} (if (predicate x) <then> <else>)))] - [while {#.Item x (while predicate xs')} #.End] + [while {.#Item x (while predicate xs')} {.#End}] [until (until predicate xs') xs] ) @@ -122,82 +123,82 @@ (-> Nat (List a) [(List a) (List a)])) (if (n.> 0 n) (case xs - #.End - [#.End #.End] + {.#End} + [{.#End} {.#End}] - {#.Item x xs'} + {.#Item x xs'} (let [[tail rest] (split_at (-- n) xs')] - [{#.Item x tail} rest])) - [#.End xs])) + [{.#Item x tail} rest])) + [{.#End} xs])) (def: (split_when' predicate ys xs) (All (_ a) (-> (Predicate a) (List a) (List a) [(List a) (List a)])) (case xs - #.End + {.#End} [ys xs] - {#.Item x xs'} + {.#Item x xs'} (if (predicate x) [ys xs] - (split_when' predicate {#.Item x ys} xs')))) + (split_when' predicate {.#Item x ys} xs')))) (def: .public (split_when predicate xs) (All (_ a) (-> (Predicate a) (List a) [(List a) (List a)])) - (let [[ys' xs'] (split_when' predicate #.End xs)] + (let [[ys' xs'] (split_when' predicate {.#End} xs)] [(reversed ys') xs'])) (def: .public (sub size list) (All (_ a) (-> Nat (List a) (List (List a)))) (case list - #.End - #.End + {.#End} + {.#End} _ (let [[pre post] (split_at size list)] - {#.Item pre (sub size post)}))) + {.#Item pre (sub size post)}))) (def: .public (repeated n x) (All (_ a) (-> Nat a (List a))) (case n - 0 #.End - _ {#.Item x (repeated (-- n) x)})) + 0 {.#End} + _ {.#Item x (repeated (-- n) x)})) (def: (iterations' f x) (All (_ a) (-> (-> a (Maybe a)) a (List a))) (case (f x) - {#.Some x'} - {#.Item x (iterations' f x')} + {.#Some x'} + {.#Item x (iterations' f x')} - #.None + {.#None} (list))) (def: .public (iterations f x) (All (_ a) (-> (-> a (Maybe a)) a (List a))) (case (f x) - {#.Some x'} - {#.Item x (iterations' f x')} + {.#Some x'} + {.#Item x (iterations' f x')} - #.None + {.#None} (list x))) (def: .public (one check xs) (All (_ a b) (-> (-> a (Maybe b)) (List a) (Maybe b))) (case xs - #.End - #.None + {.#End} + {.#None} - {#.Item x xs'} + {.#Item x xs'} (case (check x) - {#.Some output} - {#.Some output} + {.#Some output} + {.#Some output} - #.None + {.#None} (one check xs')))) (def: .public (all check xs) @@ -207,23 +208,23 @@ @.js (mix (function (_ head tail) (case (check head) - {#.Some head} - {#.Item head tail} + {.#Some head} + {.#Item head tail} - #.None + {.#None} tail)) - #.End + {.#End} (reversed xs))] (case xs - #.End - #.End + {.#End} + {.#End} - {#.Item x xs'} + {.#Item x xs'} (case (check x) - {#.Some output} - {#.Item output (all check xs')} + {.#Some output} + {.#Item output (all check xs')} - #.None + {.#None} (all check xs'))))) (def: .public (example predicate xs) @@ -231,21 +232,21 @@ (-> (Predicate a) (List a) (Maybe a))) (..one (function (_ value) (if (predicate value) - {#.Some value} - #.None)) + {.#Some value} + {.#None})) xs)) (def: .public (interposed sep xs) (All (_ a) (-> a (List a) (List a))) (case xs - #.End + {.#End} xs - {#.Item x #.End} + {.#Item x {.#End}} xs - {#.Item x xs'} + {.#Item x xs'} (list& x sep (interposed sep xs')))) (def: .public (size list) @@ -257,10 +258,10 @@ (All (_ a) (-> (Predicate a) (List a) Bit)) (case items - #.End + {.#End} <init> - {#.Item head tail} + {.#Item head tail} (<op> (predicate head) (<name> predicate tail))))] @@ -272,12 +273,12 @@ (All (_ a) (-> Nat (List a) (Maybe a))) (case xs - #.End - #.None + {.#End} + {.#None} - {#.Item x xs'} + {.#Item x xs'} (case i - 0 {#.Some x} + 0 {.#Some x} _ (item (-- i) xs')))) (implementation: .public (equivalence Equivalence<a>) @@ -285,10 +286,10 @@ (def: (= xs ys) (case [xs ys] - [#.End #.End] + [{.#End} {.#End}] #1 - [{#.Item x xs'} {#.Item y ys'}] + [{.#Item x xs'} {.#Item y ys'}] (and (\ Equivalence<a> = x y) (= xs' ys')) @@ -311,14 +312,15 @@ (implementation: .public monoid (All (_ a) (Monoid (List a))) - (def: identity #.End) + (def: identity + {.#End}) (def: (composite xs ys) (case xs - #.End + {.#End} ys - {#.Item x xs'} - {#.Item x (composite xs' ys)}))) + {.#Item x xs'} + {.#Item x (composite xs' ys)}))) (open: "[0]" ..monoid) @@ -327,11 +329,11 @@ (def: (each f ma) (case ma - #.End - #.End + {.#End} + {.#End} - {#.Item a ma'} - {#.Item (f a) (each f ma')}))) + {.#Item a ma'} + {.#Item (f a) (each f ma')}))) (open: "[0]" ..functor) @@ -342,10 +344,10 @@ (def: (on fa ff) (case ff - #.End - #.End + {.#End} + {.#End} - {#.Item f ff'} + {.#Item f ff'} (|> ff' (on fa) (composite (each f fa)))))) @@ -356,7 +358,7 @@ (def: &functor ..functor) (def: (in a) - {#.Item a #.End}) + {.#Item a {.#End}}) (def: conjoint (|>> reversed (mix composite identity)))) @@ -364,14 +366,14 @@ (def: .public (sorted < xs) (All (_ a) (-> (-> a a Bit) (List a) (List a))) (case xs - #.End + {.#End} (list) - {#.Item x xs'} + {.#Item x xs'} (let [[pre post] (mix (function (_ x' [pre post]) (if (< x x') - [{#.Item x' pre} post] - [pre {#.Item x' post}])) + [{.#Item x' pre} post] + [pre {.#Item x' post}])) [(list) (list)] xs')] ($_ composite (sorted < pre) (list x) (sorted < post))))) @@ -379,7 +381,7 @@ (def: .public (empty? xs) (All (_ a) (Predicate (List a))) (case xs - #.End + {.#End} true _ @@ -388,10 +390,10 @@ (def: .public (member? eq xs x) (All (_ a) (-> (Equivalence a) (List a) a Bit)) (case xs - #.End + {.#End} #0 - {#.Item x' xs'} + {.#Item x' xs'} (or (\ eq = x x') (member? eq xs' x)))) @@ -399,11 +401,11 @@ [(def: .public (<name> xs) (All (_ a) (-> (List a) (Maybe <output>))) (case xs - #.End - #.None + {.#End} + {.#None} - {#.Item x xs'} - {#.Some <side>}))] + {.#Item x xs'} + {.#Some <side>}))] [head a x] [tail (List a) xs'] @@ -417,7 +419,7 @@ (def: (identifier$ name) (-> Text Code) - [["" 0 0] {#.Identifier "" name}]) + [["" 0 0] {.#Identifier "" name}]) (def: (nat\encoded value) (-> Nat Text) @@ -443,7 +445,7 @@ (macro: .public (zipped tokens state) (case tokens - (^ (list [_ {#.Nat num_lists}])) + (^ (list [_ {.#Nat num_lists}])) (if (n.> 0 num_lists) (let [(^open "[0]") ..functor indices (..indices num_lists) @@ -458,7 +460,7 @@ (let [base (nat\encoded idx)] [(identifier$ base) (identifier$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (each (function (_ [v vs]) (` {#.Item (~ v) (~ vs)})) + pattern (` [(~+ (each (function (_ [v vs]) (` {.#Item (~ v) (~ vs)})) vars+lists))]) g!step (identifier$ "0step0") g!blank (identifier$ "0,0") @@ -467,23 +469,23 @@ (function ((~ g!step) (~+ list_vars)) (case [(~+ list_vars)] (~ pattern) - {#.Item [(~+ (each product.left vars+lists))] + {.#Item [(~+ (each product.left vars+lists))] ((~ g!step) (~+ list_vars))} (~ g!blank) - #.End))))] - {#.Right [state (list code)]}) - {#.Left "Cannot zipped 0 lists."}) + {.#End}))))] + {.#Right [state (list code)]}) + {.#Left "Cannot zipped 0 lists."}) _ - {#.Left "Wrong syntax for zipped"})) + {.#Left "Wrong syntax for zipped"})) (def: .public zipped/2 (zipped 2)) (def: .public zipped/3 (zipped 3)) (macro: .public (zipped_with tokens state) (case tokens - (^ (list [_ {#.Nat num_lists}])) + (^ (list [_ {.#Nat num_lists}])) (if (n.> 0 num_lists) (let [(^open "[0]") ..functor indices (..indices num_lists) @@ -501,7 +503,7 @@ (let [base (nat\encoded idx)] [(identifier$ base) (identifier$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (each (function (_ [v vs]) (` {#.Item (~ v) (~ vs)})) + pattern (` [(~+ (each (function (_ [v vs]) (` {.#Item (~ v) (~ vs)})) vars+lists))]) g!step (identifier$ "0step0") g!blank (identifier$ "0,0") @@ -510,16 +512,16 @@ (function ((~ g!step) (~ g!func) (~+ list_vars)) (case [(~+ list_vars)] (~ pattern) - {#.Item ((~ g!func) (~+ (each product.left vars+lists))) + {.#Item ((~ g!func) (~+ (each product.left vars+lists))) ((~ g!step) (~ g!func) (~+ list_vars))} (~ g!blank) - #.End))))] - {#.Right [state (list code)]}) - {#.Left "Cannot zipped_with 0 lists."}) + {.#End}))))] + {.#Right [state (list code)]}) + {.#Left "Cannot zipped_with 0 lists."}) _ - {#.Left "Wrong syntax for zipped_with"})) + {.#Left "Wrong syntax for zipped_with"})) (def: .public zipped_with/2 (zipped_with 2)) (def: .public zipped_with/3 (zipped_with 3)) @@ -527,31 +529,31 @@ (def: .public (last xs) (All (_ a) (-> (List a) (Maybe a))) (case xs - #.End - #.None + {.#End} + {.#None} - {#.Item x #.End} - {#.Some x} + {.#Item x {.#End}} + {.#Some x} - {#.Item x xs'} + {.#Item x xs'} (last xs'))) (def: .public (inits xs) (All (_ a) (-> (List a) (Maybe (List a)))) (case xs - #.End - #.None + {.#End} + {.#None} - {#.Item x #.End} - {#.Some #.End} + {.#Item x {.#End}} + {.#Some {.#End}} - {#.Item x xs'} + {.#Item x xs'} (case (inits xs') - #.None + {.#None} (undefined) - {#.Some tail} - {#.Some {#.Item x tail}}) + {.#Some tail} + {.#Some {.#Item x tail}}) )) (def: .public together @@ -562,7 +564,7 @@ (All (_ M) (-> (Monad M) (Monad (All (_ a) (M (List a)))))) (def: &functor - (functor.composite (value@ #monad.&functor monad) + (functor.composite (value@ monad.&functor monad) ..functor)) (def: in @@ -573,9 +575,8 @@ [lMla MlMla ... TODO: Remove this version ASAP and use one below. lla (for [@.old - (: {#.Apply - (type (List (List (:parameter 1)))) - (:parameter 0)} + (: {.#Apply (type (List (List (:parameter 1)))) + (:parameter 0)} (monad.all ! lMla))] (monad.all ! lMla))] (in (..together lla))))) @@ -589,18 +590,18 @@ (loop [idx 0 xs xs] (case xs - #.End - #.End + {.#End} + {.#End} - {#.Item x xs'} - {#.Item [idx x] (recur (++ idx) xs')}))) + {.#Item x xs'} + {.#Item [idx x] (recur (++ idx) xs')}))) (macro: .public (when tokens state) (case tokens (^ (.list test then)) - {#.Right [state (.list (` (.if (~ test) + {.#Right [state (.list (` (.if (~ test) (~ then) (.list))))]} _ - {#.Left "Wrong syntax for when"})) + {.#Left "Wrong syntax for when"})) diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index 7a52a1e9f..4fc1e31a1 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -29,7 +29,7 @@ (def: .public (list queue) (All (_ a) (-> (Queue a) (List a))) (let [(^slots [#front #rear]) queue] - (list\composite front (list.reversed rear)))) + (list\composite #front (list.reversed #rear)))) (def: .public front (All (_ a) (-> (Queue a) (Maybe a))) @@ -38,8 +38,8 @@ (def: .public (size queue) (All (_ a) (-> (Queue a) Nat)) (let [(^slots [#front #rear]) queue] - (n.+ (list.size front) - (list.size rear)))) + (n.+ (list.size #front) + (list.size #rear)))) (def: .public empty? (All (_ a) (-> (Queue a) Bit)) @@ -48,8 +48,8 @@ (def: .public (member? equivalence queue member) (All (_ a) (-> (Equivalence a) (Queue a) a Bit)) (let [(^slots [#front #rear]) queue] - (or (list.member? equivalence front member) - (list.member? equivalence rear member)))) + (or (list.member? equivalence #front member) + (list.member? equivalence #rear member)))) (def: .public (next queue) (All (_ a) (-> (Queue a) (Queue a))) @@ -72,11 +72,11 @@ (def: .public (end val queue) (All (_ a) (-> a (Queue a) (Queue a))) (case (value@ #front queue) - #.End + {.#End} (with@ #front (.list val) queue) _ - (revised@ #rear (|>> {#.Item val}) queue))) + (revised@ #rear (|>> {.#Item val}) queue))) (implementation: .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Queue a)))) diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux index d277ec515..e9069fa5e 100644 --- a/stdlib/source/library/lux/data/collection/queue/priority.lux +++ b/stdlib/source/library/lux/data/collection/queue/priority.lux @@ -42,7 +42,7 @@ (def: .public empty Queue - (:abstraction #.None)) + (:abstraction {.#None})) (def: .public (front queue) (All (_ a) (-> (Queue a) (Maybe a))) @@ -54,10 +54,10 @@ (def: .public (size queue) (All (_ a) (-> (Queue a) Nat)) (case (:representation queue) - #.None + {.#None} 0 - {#.Some tree} + {.#Some tree} (loop [node tree] (case (tree.root node) {0 #0 _} @@ -69,10 +69,10 @@ (def: .public (member? equivalence queue member) (All (_ a) (-> (Equivalence a) (Queue a) a Bit)) (case (:representation queue) - #.None + {.#None} false - {#.Some tree} + {.#Some tree} (loop [node tree] (case (tree.root node) {0 #0 reference} @@ -92,34 +92,34 @@ (case (tree.root node) {0 #0 reference} (if (n.= highest_priority (tree.tag node)) - #.None - {#.Some node}) + {.#None} + {.#Some node}) {0 #1 left right} (if (n.= highest_priority (tree.tag left)) (case (recur left) - #.None - {#.Some right} + {.#None} + {.#Some right} - {#.Some =left} - {#.Some (\ ..builder branch =left right)}) + {.#Some =left} + {.#Some (\ ..builder branch =left right)}) (case (recur right) - #.None - {#.Some left} + {.#None} + {.#Some left} - {#.Some =right} - {#.Some (\ ..builder branch left =right)}))))))) + {.#Some =right} + {.#Some (\ ..builder branch left =right)}))))))) (def: .public (end priority value queue) (All (_ a) (-> Priority a (Queue a) (Queue a))) (let [addition (\ ..builder leaf priority value)] (:abstraction (case (:representation queue) - #.None - {#.Some addition} + {.#None} + {.#Some addition} - {#.Some tree} - {#.Some (\ ..builder branch tree addition)})))) + {.#Some tree} + {.#Some (\ ..builder branch tree addition)})))) ) (def: .public empty? diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index aa8c6d0f7..a39ea8af3 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -96,7 +96,7 @@ {#Base tail} (|> (empty_hierarchy []) (array.write! 0 (path (level_down level) tail)) - #Hierarchy))) + {#Hierarchy}))) (def: (tail singleton) (All (_ a) (-> a (Base a))) @@ -113,10 +113,10 @@ ... Otherwise, check whether there's a vacant spot (case (array.read! sub_idx parent) ... If so, set the path to the tail - #.None + {.#None} (..path (level_down level) tail) ... If not, push the tail onto the sub_node. - {#.Some {#Hierarchy sub_node}} + {.#Some {#Hierarchy sub_node}} {#Hierarchy (with_tail size (level_down level) tail sub_node)} _ @@ -136,16 +136,16 @@ (All (_ a) (-> Level Index a (Hierarchy a) (Hierarchy a))) (let [sub_idx (branch_idx (i64.right_shifted level idx))] (case (array.read! sub_idx hierarchy) - {#.Some {#Hierarchy sub_node}} + {.#Some {#Hierarchy sub_node}} (|> (array.clone hierarchy) (array.write! sub_idx {#Hierarchy (hierarchy\has (level_down level) idx val sub_node)})) - (^multi {#.Some {#Base base}} + (^multi {.#Some {#Base base}} (n.= 0 (level_down level))) (|> (array.clone hierarchy) (array.write! sub_idx (|> (array.clone base) (array.write! (branch_idx idx) val) - #Base))) + {#Base}))) _ (undefined)))) @@ -154,7 +154,7 @@ (All (_ a) (-> Nat Level (Hierarchy a) (Maybe (Hierarchy a)))) (let [sub_idx (branch_idx (i64.right_shifted level (n.- 2 size)))] (cond (n.= 0 sub_idx) - #.None + {.#None} (n.> branching_exponent level) (do maybe.monad @@ -167,27 +167,27 @@ (undefined))] (|> (array.clone hierarchy) (array.write! sub_idx {#Hierarchy sub}) - #.Some)) + {.#Some})) ... Else... (|> (array.clone hierarchy) (array.delete! sub_idx) - #.Some) + {.#Some}) ))) (def: (node\list node) (All (_ a) (-> (Node a) (List a))) (case node {#Base base} - (array.list #.None base) + (array.list {.#None} base) {#Hierarchy hierarchy} (|> hierarchy - (array.list #.None) + (array.list {.#None}) list.reversed (list\mix (function (_ sub acc) (list\composite (node\list sub) acc)) - #.End)))) + {.#End})))) (type: .public (Row a) (Record @@ -261,18 +261,18 @@ hierarchy (value@ #root row)] (case [(n.> branching_exponent level) (array.read! (branch_idx (i64.right_shifted level idx)) hierarchy)] - [#1 {#.Some {#Hierarchy sub}}] + [#1 {.#Some {#Hierarchy sub}}] (recur (level_down level) sub) - [#0 {#.Some {#Base base}}] - {#try.Success base} + [#0 {.#Some {#Base base}}] + {try.#Success base} - [_ #.None] + [_ {.#None}] (exception.except ..base_was_not_found []) _ (exception.except ..incorrect_row_structure []))) - {#try.Success (value@ #tail row)}) + {try.#Success (value@ #tail row)}) (exception.except ..index_out_of_bounds [row idx]))) (def: .public (item idx row) @@ -280,17 +280,17 @@ (do try.monad [base (base_for idx row)] (case (array.read! (branch_idx idx) base) - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None + {.#None} (exception.except ..incorrect_row_structure [])))) (def: .public (has idx val row) (All (_ a) (-> Nat a (Row a) (Try (Row a)))) (let [row_size (value@ #size row)] (if (within_bounds? row idx) - {#try.Success (if (n.< (tail_off row_size) idx) + {try.#Success (if (n.< (tail_off row_size) idx) (revised@ #root (hierarchy\has (value@ #level row) idx val) row) (revised@ #tail (for [@.old @@ -332,10 +332,10 @@ (without_tail row_size init_level (value@ #root row)))] (if (n.> branching_exponent level) (case [(array.read! 1 root) (array.read! 0 root)] - [#.None {#.Some {#Hierarchy sub_node}}] + [{.#None} {.#Some {#Hierarchy sub_node}}] (recur (level_down level) sub_node) - ... [#.None {#.Some {#Base _}}] + ... [{.#None} {.#Some {#Base _}}] ... (undefined) _ @@ -492,8 +492,8 @@ (<array> (help predicate) hierarchy))))] (function (<name> predicate row) (let [(^slots [#root #tail]) row] - (<op> (help predicate {#Hierarchy root}) - (help predicate {#Base tail}))))))] + (<op> (help predicate {#Hierarchy #root}) + (help predicate {#Base #tail}))))))] [every? array.every? #1 and] [any? array.any? #0 or] diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index 6e4e0b801..fccc576df 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -39,10 +39,10 @@ (loop [head start tail next] (//.pending [head (case tail - #.End + {.#End} (recur start next) - {#.Item head' tail'} + {.#Item head' tail'} (recur head' tail'))]))) (template [<name> <return>] @@ -91,7 +91,7 @@ (if <pred_test> [(list) xs] (let [[tail next] (<splitter> <pred_step> xs')] - [{#.Item [x tail]} next]))))] + [{.#Item [x tail]} next]))))] [split_when (-> a Bit) (pred x) pred] [split_at Nat (n.= 0 pred) (-- pred)] diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index 2d4c3975b..b325c793a 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -43,13 +43,13 @@ (case multiplicity 0 set _ (case (dictionary.value elem (:representation set)) - {#.Some current} + {.#Some current} (:abstraction (if (n.> multiplicity current) (dictionary.revised elem (n.- multiplicity) (:representation set)) (dictionary.lacks elem (:representation set)))) - #.None + {.#None} set))) (def: .public (multiplicity set elem) @@ -62,7 +62,7 @@ dictionary.entries (list\mix (function (_ [elem multiplicity] output) (list\composite (list.repeated multiplicity elem) output)) - #.End))) + {.#End}))) (template [<name> <composite>] [(def: .public (<name> parameter subject) diff --git a/stdlib/source/library/lux/data/collection/set/ordered.lux b/stdlib/source/library/lux/data/collection/set/ordered.lux index 72344d090..2fea2876a 100644 --- a/stdlib/source/library/lux/data/collection/set/ordered.lux +++ b/stdlib/source/library/lux/data/collection/set/ordered.lux @@ -58,13 +58,13 @@ (All (_ a) (-> (Set a) (Set a) (Set a))) (|> (..list right) (list.only (..member? left)) - (..of_list (value@ #/.&order (:representation right))))) + (..of_list (value@ /.#&order (:representation right))))) (def: .public (difference param subject) (All (_ a) (-> (Set a) (Set a) (Set a))) (|> (..list subject) (list.only (|>> (..member? param) not)) - (..of_list (value@ #/.&order (:representation subject))))) + (..of_list (value@ /.#&order (:representation subject))))) (implementation: .public equivalence (All (_ a) (Equivalence (Set a))) diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux index e90d53f84..8c55178f9 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -28,24 +28,24 @@ (def: .public (value stack) (All (_ a) (-> (Stack a) (Maybe a))) (case (:representation stack) - #.End - #.None + {.#End} + {.#None} - {#.Item value _} - {#.Some value})) + {.#Item value _} + {.#Some value})) (def: .public (next stack) (All (_ a) (-> (Stack a) (Maybe [a (Stack a)]))) (case (:representation stack) - #.End - #.None + {.#End} + {.#None} - {#.Item top stack'} - {#.Some [top (:abstraction stack')]})) + {.#Item top stack'} + {.#Some [top (:abstraction stack')]})) (def: .public (top value stack) (All (_ a) (-> a (Stack a) (Stack a))) - (:abstraction {#.Item value (:representation stack)})) + (:abstraction {.#Item value (:representation stack)})) (implementation: .public (equivalence super) (All (_ a) diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux index 281e9f2ed..4beb81cf3 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -27,7 +27,7 @@ (value@ #children) (list\each flat) list\conjoint - {#.Item (value@ #value tree)})) + {.#Item (value@ #value tree)})) (def: .public (leaf value) (All (_ a) (-> a (Tree a))) diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index 5cef4d130..01e125e9d 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -91,21 +91,21 @@ _node root] (case _node {0 #0 value} - {#.Some value} + {.#Some value} {0 #1 [left right]} (let [shifted_tag (tag//composite _tag (..tag left))] (if (predicate shifted_tag) (recur _tag (value@ #root (:representation left))) (recur shifted_tag (value@ #root (:representation right)))))))) - #.None))) + {.#None}))) ) (def: .public (exists? predicate tree) (All (_ @ t v) (-> (Predicate t) (Tree @ t v) Bit)) (case (..one predicate tree) - {#.Some _} + {.#Some _} true - #.None + {.#None} false)) diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index 60c11d032..767365e6f 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -46,7 +46,7 @@ (def: .public (zipper tree) (All (_ a) (-> (Tree a) (Zipper a))) - [#family #.None + [#family {.#None} #node tree]) (def: .public tree @@ -55,19 +55,19 @@ (def: .public value (All (_ a) (-> (Zipper a) a)) - (value@ [#node #//.value])) + (value@ [#node //.#value])) (def: .public (set value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) - (with@ [#node #//.value] value zipper)) + (with@ [#node //.#value] value zipper)) (def: .public (update transform zipper) (All (_ a) (-> (-> a a) (Zipper a) (Zipper a))) - (revised@ [#node #//.value] transform zipper)) + (revised@ [#node //.#value] transform zipper)) (def: children (All (_ a) (-> (Zipper a) (List (Tree a)))) - (value@ [#node #//.children])) + (value@ [#node //.#children])) (def: .public leaf? (All (_ a) (-> (Zipper a) Bit)) @@ -80,7 +80,7 @@ (def: .public (start? zipper) (All (_ a) (-> (Zipper a) Bit)) (case (value@ #family zipper) - #.None + {.#None} true _ @@ -89,12 +89,12 @@ (def: .public (down zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..children zipper) - #.End - #.None + {.#End} + {.#None} - {#.Item head tail} - {#.Some [#family {#.Some [#parent (with@ [#node #//.children] (list) zipper) - #lefts #.End + {.#Item head tail} + {.#Some [#family {.#Some [#parent (with@ [#node //.#children] (list) zipper) + #lefts {.#End} #rights tail]} #node head]})) @@ -106,64 +106,64 @@ (for [@.old (revised@ #node (: (-> (Tree (:parameter 0)) (Tree (:parameter 0))) - (with@ #//.children (list\composite (list.reversed lefts) - {#.Item (value@ #node zipper) - rights}))) - parent)] - (with@ [#node #//.children] - (list\composite (list.reversed lefts) - {#.Item (value@ #node zipper) - rights}) - parent)))))) + (with@ //.#children (list\composite (list.reversed #lefts) + {.#Item (value@ #node zipper) + #rights}))) + #parent)] + (with@ [#node //.#children] + (list\composite (list.reversed #lefts) + {.#Item (value@ #node zipper) + #rights}) + #parent)))))) (template [<one> <all> <side> <op_side>] [(def: .public (<one> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (value@ #family zipper) - {#.Some family} + {.#Some family} (case (value@ <side> family) - {#.Item next side'} - {#.Some (for [@.old - [#family {#.Some (|> family + {.#Item next side'} + {.#Some (for [@.old + [#family {.#Some (|> family (with@ <side> side') - (revised@ <op_side> (|>> {#.Item (value@ #node zipper)})))} + (revised@ <op_side> (|>> {.#Item (value@ #node zipper)})))} #node next]] (let [move (: (All (_ a) (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ side' zipper) (|>> (with@ <side> side') - (revised@ <op_side> (|>> {#.Item (value@ #node zipper)})))))] - [#family {#.Some (move side' zipper family)} + (revised@ <op_side> (|>> {.#Item (value@ #node zipper)})))))] + [#family {.#Some (move side' zipper family)} #node next]))} - #.End - #.None) + {.#End} + {.#None}) - #.None - #.None)) + {.#None} + {.#None})) (def: .public (<all> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (value@ #family zipper) - #.None - #.None + {.#None} + {.#None} - {#.Some family} + {.#Some family} (case (list.reversed (value@ <side> family)) - #.End - #.None + {.#End} + {.#None} - {#.Item last prevs} - {#.Some (for [@.old [#family {#.Some (|> family - (with@ <side> #.End) - (revised@ <op_side> (|>> {#.Item (value@ #node zipper)} + {.#Item last prevs} + {.#Some (for [@.old [#family {.#Some (|> family + (with@ <side> {.#End}) + (revised@ <op_side> (|>> {.#Item (value@ #node zipper)} (list\composite prevs))))} #node last]] (let [move (: (All (_ a) (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ prevs zipper) - (|>> (with@ <side> #.End) - (revised@ <op_side> (|>> {#.Item (value@ #node zipper)} + (|>> (with@ <side> {.#End}) + (revised@ <op_side> (|>> {.#Item (value@ #node zipper)} (list\composite prevs))))))] - [#family {#.Some (move prevs zipper family)} + [#family {.#Some (move prevs zipper family)} #node last]))})))] [right rightmost #rights #lefts] @@ -173,16 +173,16 @@ (def: .public (next zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..down zipper) - {#.Some forward} - {#.Some forward} + {.#Some forward} + {.#Some forward} - #.None + {.#None} (loop [@ zipper] (case (..right @) - {#.Some forward} - {#.Some forward} + {.#Some forward} + {.#Some forward} - #.None + {.#None} (do maybe.monad [@ (..up @)] (recur @)))))) @@ -190,45 +190,45 @@ (def: (bottom zipper) (All (_ a) (-> (Zipper a) (Zipper a))) (case (..right zipper) - {#.Some forward} + {.#Some forward} (bottom forward) - #.None + {.#None} (case (..down zipper) - {#.Some forward} + {.#Some forward} (bottom forward) - #.None + {.#None} zipper))) (def: .public (previous zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..left zipper) - #.None + {.#None} (..up zipper) - {#.Some backward} - {#.Some (case (..down backward) - {#.Some then} + {.#Some backward} + {.#Some (case (..down backward) + {.#Some then} (..bottom then) - #.None + {.#None} backward)})) (template [<name> <move>] [(def: .public (<name> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (<move> zipper) - #.None - #.None + {.#None} + {.#None} - {#.Some @} + {.#Some @} (loop [@ @] (case (<move> @) - #.None - {#.Some @} + {.#None} + {.#Some @} - {#.Some @} + {.#Some @} (recur @)))))] [end ..next] @@ -238,22 +238,22 @@ (def: .public (end? zipper) (All (_ a) (-> (Zipper a) Bit)) (case (..end zipper) - #.None + {.#None} true - {#.Some _} + {.#Some _} false)) (def: .public (interpose value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) - (revised@ [#node #//.children] + (revised@ [#node //.#children] (|>> (//.branch value) list) zipper)) (def: .public (adopt value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) - (revised@ [#node #//.children] - (|>> {#.Item (//.leaf value)}) + (revised@ [#node //.#children] + (|>> {.#Item (//.leaf value)}) zipper)) (def: .public (remove zipper) @@ -261,28 +261,28 @@ (do maybe.monad [family (value@ #family zipper)] (case (value@ #lefts family) - #.End - (in (with@ [#node #//.children] + {.#End} + (in (with@ [#node //.#children] (value@ #rights family) (value@ #parent family))) - {#.Item next side} + {.#Item next side} (in (|> zipper (with@ #family (|> family (with@ #lefts side) - #.Some)) + {.#Some})) (with@ #node next)))))) (template [<name> <side>] [(def: .public (<name> value zipper) (All (_ a) (-> a (Zipper a) (Maybe (Zipper a)))) (case (value@ #family zipper) - #.None - #.None + {.#None} + {.#None} - {#.Some family} - {#.Some (with@ #family - {#.Some (revised@ <side> (|>> {#.Item (//.leaf value)}) family)} + {.#Some family} + {.#Some (with@ #family + {.#Some (revised@ <side> (|>> {.#Item (//.leaf value)}) family)} zipper)}))] [insert_left #lefts] @@ -294,29 +294,31 @@ (def: (each f (^slots [#family #node])) [#family (maybe\each (function (_ (^slots [#parent #lefts #rights])) - [#parent (each f parent) - #lefts (list\each (//\each f) lefts) - #rights (list\each (//\each f) rights)]) - family) - #node (//\each f node)])) + [#parent (each f #parent) + #lefts (list\each (//\each f) #lefts) + #rights (list\each (//\each f) #rights)]) + #family) + #node (//\each f #node)])) (implementation: .public comonad (CoMonad Zipper) - (def: &functor ..functor) + (def: &functor + ..functor) - (def: out (value@ [#node #//.value])) + (def: out + (value@ [#node //.#value])) (def: (disjoint (^slots [#family #node])) (let [tree_splitter (: (All (_ a) (-> (Tree a) (Tree (Zipper a)))) (function (tree_splitter tree) - [#//.value (..zipper tree) - #//.children (|> tree - (value@ #//.children) + [//.#value (..zipper tree) + //.#children (|> tree + (value@ //.#children) (list\each tree_splitter))]))] [#family (maybe\each (function (_ (^slots [#parent #lefts #rights])) - [#parent (disjoint parent) - #lefts (list\each tree_splitter lefts) - #rights (list\each tree_splitter rights)]) - family) - #node (tree_splitter node)]))) + [..#parent (disjoint #parent) + ..#lefts (list\each tree_splitter #lefts) + ..#rights (list\each tree_splitter #rights)]) + #family) + #node (tree_splitter #node)]))) diff --git a/stdlib/source/library/lux/data/color/named.lux b/stdlib/source/library/lux/data/color/named.lux index 822708ccc..26deaeaa6 100644 --- a/stdlib/source/library/lux/data/color/named.lux +++ b/stdlib/source/library/lux/data/color/named.lux @@ -8,9 +8,9 @@ (template [<red> <green> <blue> <name>] [(`` (def: .public <name> Color - (//.of_rgb [#//.red (hex <red>) - #//.green (hex <green>) - #//.blue (hex <blue>)])))] + (//.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 0fcc94723..8905c32bf 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -94,8 +94,8 @@ try.trusted [(.++ offset)] caseT))])]) - ([0 #.Left left] - [1 #.Right right]) + ([0 .#Left left] + [1 .#Right right]) ))) (def: .public (and pre post) @@ -242,17 +242,17 @@ try.trusted [(.++ offset)] caseT))])]) - ([0 #.Primitive (..and ..text (..list recur))] - [1 #.Sum pair] - [2 #.Product pair] - [3 #.Function pair] - [4 #.Parameter indexed] - [5 #.Var indexed] - [6 #.Ex indexed] - [7 #.UnivQ quantified] - [8 #.ExQ quantified] - [9 #.Apply pair] - [10 #.Named (..and ..name recur)]) + ([0 .#Primitive (..and ..text (..list recur))] + [1 .#Sum pair] + [2 .#Product pair] + [3 .#Function pair] + [4 .#Parameter indexed] + [5 .#Var indexed] + [6 .#Ex indexed] + [7 .#UnivQ quantified] + [8 .#ExQ quantified] + [9 .#Apply pair] + [10 .#Named (..and ..name recur)]) )))))) (def: .public location @@ -277,15 +277,14 @@ try.trusted [(.++ offset)] caseT))])]) - ([00 #.Bit ..bit] - [01 #.Nat ..nat] - [02 #.Int ..int] - [03 #.Rev ..rev] - [04 #.Frac ..frac] - [05 #.Text ..text] - [06 #.Identifier ..name] - [07 #.Tag ..name] - [08 #.Form sequence] - [09 #.Variant sequence] - [10 #.Tuple sequence]) + ([0 .#Bit ..bit] + [1 .#Nat ..nat] + [2 .#Int ..int] + [3 .#Rev ..rev] + [4 .#Frac ..frac] + [5 .#Text ..text] + [6 .#Identifier ..name] + [7 .#Form sequence] + [8 .#Variant sequence] + [9 .#Tuple sequence]) ))))))) diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux index 488ccba64..90cb8ad54 100644 --- a/stdlib/source/library/lux/data/format/css.lux +++ b/stdlib/source/library/lux/data/format/css.lux @@ -49,19 +49,19 @@ (def: .public (font font) (-> Font (CSS Special)) - (let [with_unicode (case (value@ #/font.unicode_range font) - {#.Some unicode_range} - (let [unicode_range' (format "U+" (\ nat.hex encoded (value@ #/font.start unicode_range)) - "-" (\ nat.hex encoded (value@ #/font.end unicode_range)))] + (let [with_unicode (case (value@ /font.#unicode_range font) + {.#Some unicode_range} + (let [unicode_range' (format "U+" (\ nat.hex encoded (value@ /font.#start unicode_range)) + "-" (\ nat.hex encoded (value@ /font.#end unicode_range)))] (list ["unicode-range" unicode_range'])) - #.None + {.#None} (list))] - (|> (list& ["font-family" (value@ #/font.family font)] - ["src" (format "url(" (value@ #/font.source font) ")")] - ["font-stretch" (|> font (value@ #/font.stretch) (maybe.else /value.normal_stretch) /value.value)] - ["font-style" (|> font (value@ #/font.style) (maybe.else /value.normal_style) /value.value)] - ["font-weight" (|> font (value@ #/font.weight) (maybe.else /value.normal_weight) /value.value)] + (|> (list& ["font-family" (value@ /font.#family font)] + ["src" (format "url(" (value@ /font.#source font) ")")] + ["font-stretch" (|> font (value@ /font.#stretch) (maybe.else /value.normal_stretch) /value.value)] + ["font-style" (|> font (value@ /font.#style) (maybe.else /value.normal_style) /value.value)] + ["font-weight" (|> font (value@ /font.#weight) (maybe.else /value.normal_weight) /value.value)] with_unicode) (list\each (function (_ [property value]) (format property ": " value ";"))) @@ -74,10 +74,10 @@ (-> URL (Maybe Query) (CSS Special)) (:abstraction (format (format "@import url(" (%.text url) ")") (case query - {#.Some query} + {.#Some query} (format " " (/query.query query)) - #.None + {.#None} "") ";"))) diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index 25b09fb71..ba082cb05 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -827,7 +827,7 @@ (def: .public (rgba pigment) (-> color.Pigment (Value Color)) - (let [(^slots [#color.color #color.alpha]) pigment + (let [(^slots [color.#color color.#alpha]) pigment [red green blue] (color.rgb color)] (..apply "rgba" (list (%.nat red) (%.nat green) @@ -919,10 +919,10 @@ (def: (with_hint [hint stop]) (-> [(Maybe Hint) Stop] Text) (case hint - #.None + {.#None} (:representation Stop stop) - {#.Some hint} + {.#Some hint} (format (:representation Hint hint) ..value_separator (:representation Stop stop)))))) (type: .public (List/1 a) @@ -1078,10 +1078,10 @@ (Value Image)) (let [after_extent (format "at " (:representation location)) with_extent (case extent - {#.Some extent} + {.#Some extent} (format (..extent extent) " " after_extent) - #.None + {.#None} after_extent) where (format (..shape shape) " " with_extent) [now after] next] @@ -1158,13 +1158,13 @@ (def: .public (font_family options) (-> (List Font) (Value Font)) (case options - {#.Item _} + {.#Item _} (|> options (list\each ..font_name) (text.interposed ",") (:abstraction Value)) - #.End + {.#End} ..initial))]) (def: .public font_size diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index 72ec3e7a1..60c405963 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -176,10 +176,10 @@ (-> URL (Maybe Target) Meta) (let [partial (list ["href" href]) full (case target - {#.Some target} + {.#Some target} (list& ["target" (..target target)] partial) - #.None + {.#None} partial)] (..simple "base" full))) @@ -213,7 +213,7 @@ (def: .public (image source attributes) (-> URL Attributes Image) (|> attributes - {#.Item ["src" source]} + {.#Item ["src" source]} (..simple "img"))) (def: .public (svg attributes content) @@ -300,10 +300,10 @@ ($_ ..and for (case (list\each (product.uncurried ..area) areas) - #.End + {.#End} (..empty "map" attributes) - {#.Item head tail} + {.#Item head tail} (..tag "map" attributes (list\mix (function.flipped ..and) head tail))))) @@ -348,12 +348,12 @@ (-> (Maybe Content) Attributes <type> <type>) (..tag <container_tag> attributes (case description - {#.Some description} + {.#Some description} ($_ ..and (..tag <description_tag> (list) description) content) - #.None + {.#None} content)))] [details "details" "summary" Element] @@ -466,10 +466,10 @@ (..term term) (..description description))) descriptions) - #.End + {.#End} (..empty "dl" attributes) - {#.Item head tail} + {.#Item head tail} (..tag "dl" attributes (list\mix (function.flipped ..and) head tail)))) @@ -524,32 +524,32 @@ (-> Attributes (Maybe Content) (Maybe Column) Header (List Cell) (Maybe Cell) Element) (let [head (..table_head (..table_row headers)) content (case (list\each table_row rows) - #.End + {.#End} head - {#.Item first rest} + {.#Item first rest} (..and head (..table_body (list\mix (function.flipped ..and) first rest)))) content (case footer - #.None + {.#None} content - {#.Some footer} + {.#Some footer} (..and content (..table_foot (..table_row footer)))) content (case columns - #.None + {.#None} content - {#.Some columns} + {.#Some columns} (..and (..columns_group columns) content)) content (case caption - #.None + {.#None} content - {#.Some caption} + {.#Some caption} (..and (:as HTML caption) content))] (..tag "table" attributes diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index f29042a83..734a38177 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -60,12 +60,12 @@ (def: .public null? (Predicate JSON) - (|>> (case> #Null true + (|>> (case> {#Null} true _ false))) (def: .public object (-> (List [String JSON]) JSON) - (|>> (dictionary.of_list text.hash) #..Object)) + (|>> (dictionary.of_list text.hash) {..#Object})) (type: JSON' (Rec JSON' @@ -83,7 +83,7 @@ (<>.rec (function (_ jsonP) ($_ <>.or - (<code>.local_tag! "null") + (<code>.form (<>\in [])) <code>.bit <code>.frac <code>.text @@ -98,20 +98,20 @@ (-> JSON' Code) (case token {#Null' _} - (` #..Null) + (` {..#Null}) (^template [<ctor> <input_tag> <output_tag>] [{<input_tag> value} (` {<output_tag> (~ (<ctor> value))})]) - ([code.bit #..Boolean' #..Boolean] - [code.frac #..Number' #..Number] - [code.text #..String' #..String]) + ([code.bit ..#Boolean' ..#Boolean] + [code.frac ..#Number' ..#Number] + [code.text ..#String' ..#String]) {#Array' members} - (` {#..Array ((~! row.row) (~+ (row.list (row\each jsonF members))))}) + (` {..#Array ((~! row.row) (~+ (row.list (row\each jsonF members))))}) {#Object' pairs} - (` {#..Object ((~! dictionary.of_list) + (` {..#Object ((~! dictionary.of_list) (~! text.hash) (list (~+ (|> pairs dictionary.entries @@ -128,46 +128,46 @@ (-> JSON (Try (List String))) (case json {#Object obj} - {#try.Success (dictionary.keys obj)} + {try.#Success (dictionary.keys obj)} _ - {#try.Failure ($_ text\composite "Cannot get the fields of a non-object.")})) + {try.#Failure ($_ text\composite "Cannot get the fields of a non-object.")})) (def: .public (field key json) (-> String JSON (Try JSON)) (case json {#Object obj} (case (dictionary.value key obj) - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None - {#try.Failure ($_ text\composite "Missing field '" key "' on object.")}) + {.#None} + {try.#Failure ($_ text\composite "Missing field '" key "' on object.")}) _ - {#try.Failure ($_ text\composite "Cannot get field '" key "' on a non-object.")})) + {try.#Failure ($_ text\composite "Cannot get field '" key "' on a non-object.")})) (def: .public (has key value json) (-> String JSON JSON (Try JSON)) (case json {#Object obj} - {#try.Success {#Object (dictionary.has key value obj)}} + {try.#Success {#Object (dictionary.has key value obj)}} _ - {#try.Failure ($_ text\composite "Cannot set field '" key "' on a non-object.")})) + {try.#Failure ($_ text\composite "Cannot set field '" key "' on a non-object.")})) (template [<name> <tag> <type>] [(def: .public (<name> key json) (-> Text JSON (Try <type>)) (case (field key json) - {#try.Success {<tag> value}} - {#try.Success value} + {try.#Success {<tag> value}} + {try.#Success value} - {#try.Success _} - {#try.Failure ($_ text\composite "Wrong value type at key: " key)} + {try.#Success _} + {try.#Failure ($_ text\composite "Wrong value type at key: " key)} - {#try.Failure error} - {#try.Failure error}))] + {try.#Failure error} + {try.#Failure error}))] [boolean_field #Boolean Boolean] [number_field #Number Number] @@ -181,7 +181,7 @@ (def: (= x y) (case [x y] - [#Null #Null] + [{#Null} {#Null}] #1 (^template [<tag> <struct>] @@ -208,8 +208,8 @@ (list\mix (function (_ [xk xv] prev) (and prev (case (dictionary.value xk ys) - #.None #0 - {#.Some yv} (= xv yv)))) + {.#None} #0 + {.#Some yv} (= xv yv)))) #1 (dictionary.entries xs))) @@ -352,10 +352,10 @@ offset (<text>.many <text>.decimal)] (in ($_ text\composite mark (if signed?' "-" "") offset))))] (case (f\decoded ($_ text\composite (if signed? "-" "") digits "." decimals exp)) - {#try.Failure message} + {try.#Failure message} (<>.failure message) - {#try.Success value} + {try.#Success value} (in value)))) (def: escaped_parser diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux index 8f64a70f0..0e45ec331 100644 --- a/stdlib/source/library/lux/data/format/markdown.lux +++ b/stdlib/source/library/lux/data/format/markdown.lux @@ -110,14 +110,14 @@ (list\each (function (_ [idx [summary detail]]) (format "1. " (:representation summary) (case detail - {#.Some detail} + {.#Some detail} (|> detail :representation ..indent (text.enclosed [text.new_line text.new_line]) (format text.new_line)) - #.None + {.#None} "")))) (text.interposed text.new_line) ..block)) @@ -128,14 +128,14 @@ (|>> (list\each (function (_ [summary detail]) (format "* " (:representation summary) (case detail - {#.Some detail} + {.#Some detail} (|> detail :representation ..indent (text.enclosed [text.new_line text.new_line]) (format text.new_line)) - #.None + {.#None} "")))) (text.interposed text.new_line) ..block)) diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index c33250527..bfc337c87 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -76,7 +76,7 @@ (def: .public (<in> value) (-> Nat (Try <type>)) (if (n.< <limit> value) - {#try.Success (:abstraction value)} + {try.#Success (:abstraction value)} (exception.except <exception> [value]))) (def: .public <out> @@ -230,10 +230,10 @@ (def: (un_padded string) (-> Binary (Try Binary)) (case (binary.size string) - 0 {#try.Success string} + 0 {try.#Success string} size (loop [end (-- size)] (case end - 0 {#try.Success (\ utf8.codec encoded "")} + 0 {try.#Success (\ utf8.codec encoded "")} _ (do try.monad [last_char (binary.read/8! end string)] (`` (case (.nat last_char) @@ -261,7 +261,7 @@ binary.size (n.> <size>)) (exception.except <exception> [value]) - {#try.Success (:abstraction value)}) + {try.#Success (:abstraction value)}) (exception.except ..not_ascii [value]))) (def: .public <out> @@ -848,14 +848,14 @@ (def: entry_parser (Parser Entry) ($_ <>.either - (\ <>.monad each (|>> #..Normal) + (\ <>.monad each (|>> {..#Normal}) (<>.either (..file_parser ..normal) (..file_parser ..old_normal))) - (\ <>.monad each (|>> #..Symbolic_Link) + (\ <>.monad each (|>> {..#Symbolic_Link}) (..file_name_parser ..symbolic_link (value@ #link_name))) - (\ <>.monad each (|>> #..Directory) + (\ <>.monad each (|>> {..#Directory}) (..file_name_parser ..directory (value@ #path))) - (\ <>.monad each (|>> #..Contiguous) + (\ <>.monad each (|>> {..#Contiguous}) (..file_parser ..contiguous)))) ... It's safe to implement the parser this way because the range of values for Nat is 2^64 diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index 90aaa1b1e..f2064c166 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -58,10 +58,10 @@ (|> (do <>.monad [hex? (<>.maybe (<text>.this "x")) code (case hex? - #.None + {.#None} (<>.codec int.decimal (<text>.many <text>.decimal)) - {#.Some _} + {.#Some _} (<>.codec int.decimal (<text>.many <text>.hexadecimal)))] (in (|> code .nat text.of_char))) (<>.before (<text>.this ";")) @@ -92,10 +92,10 @@ [first_part xml_identifier ?second_part (<| <>.maybe (<>.after (<text>.this ..namespace_separator)) xml_identifier)] (case ?second_part - #.None + {.#None} (in ["" first_part]) - {#.Some second_part} + {.#Some second_part} (in [first_part second_part])))) (def: tag^ namespaced_symbol^) @@ -159,7 +159,7 @@ (Parser XML) (|> (..spaced^ (<text>.many xml_char^)) (<>.either cdata^) - (<>\each (|>> #Text)))) + (<>\each (|>> {#Text})))) (def: null^ (Parser Any) diff --git a/stdlib/source/library/lux/data/name.lux b/stdlib/source/library/lux/data/name.lux index 79d1feef3..86f813cf7 100644 --- a/stdlib/source/library/lux/data/name.lux +++ b/stdlib/source/library/lux/data/name.lux @@ -53,10 +53,10 @@ (def: (decoded input) (case (text.all_split_by ..separator input) (^ (list short)) - {#.Right ["" short]} + {.#Right ["" short]} (^ (list module short)) - {#.Right [module short]} + {.#Right [module short]} _ - {#.Left (text\composite "Invalid format for Name: " input)}))) + {.#Left (text\composite "Invalid format for Name: " input)}))) diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux index 174a2936f..cd66c8aa4 100644 --- a/stdlib/source/library/lux/data/sum.lux +++ b/stdlib/source/library/lux/data/sum.lux @@ -36,13 +36,13 @@ [(def: .public (<name> items) (All (_ a b) (-> (List (Or a b)) (List <side>))) (case items - #.End - #.End + {.#End} + {.#End} - {#.Item {0 <right?> x} items'} - {#.Item [x (<name> items')]} + {.#Item {0 <right?> x} items'} + {.#Item [x (<name> items')]} - {#.Item _ items'} + {.#Item _ items'} (<name> items')))] [lefts a #0] @@ -52,24 +52,24 @@ (def: .public (partition xs) (All (_ a b) (-> (List (Or a b)) [(List a) (List b)])) (case xs - #.End - [#.End #.End] + {.#End} + [{.#End} {.#End}] - {#.Item x xs'} + {.#Item x xs'} (let [[lefts rights] (partition xs')] (case x - {0 #0 x'} [{#.Item x' lefts} rights] - {0 #1 x'} [lefts {#.Item x' rights}])))) + {0 #0 x'} [{.#Item x' lefts} rights] + {0 #1 x'} [lefts {.#Item x' rights}])))) (def: .public (equivalence left right) (All (_ l r) (-> (Equivalence l) (Equivalence r) (Equivalence (Or l r)))) (implementation (def: (= reference sample) (case [reference sample] - [{#.Left reference} {#.Left sample}] + [{.#Left reference} {.#Left sample}] (\ left = reference sample) - [{#.Right reference} {#.Right sample}] + [{.#Right reference} {.#Right sample}] (\ right = reference sample) _ @@ -83,8 +83,8 @@ (\ right &equivalence))) (def: (hash value) (case value - {#.Left value} + {.#Left value} (\ left hash value) - {#.Right value} + {.#Right value} (\ right hash value))))) diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index 7823bd333..a95490493 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -53,8 +53,8 @@ (def: .public (char index input) (-> Nat Text (Maybe Char)) (if (n.< ("lux text size" input) index) - {#.Some ("lux text char" index input)} - #.None)) + {.#Some ("lux text char" index input)} + {.#None})) (def: .public (index_since offset pattern input) (-> Nat Text Text (Maybe Nat)) @@ -68,19 +68,19 @@ (-> Text Text (Maybe Nat)) (loop [offset 0 output (: (Maybe Nat) - #.None)] + {.#None})] (let [output' ("lux text index" offset part text)] (case output' - #.None + {.#None} output - {#.Some offset'} + {.#Some offset'} (recur (++ offset') output'))))) (def: .public (starts_with? prefix x) (-> Text Text Bit) (case (index prefix x) - {#.Some 0} + {.#Some 0} true _ @@ -89,7 +89,7 @@ (def: .public (ends_with? postfix x) (-> Text Text Bit) (case (last_index postfix x) - {#.Some n} + {.#Some n} (n.= (size x) (n.+ (size postfix) n)) @@ -104,7 +104,7 @@ (def: .public (contains? sub text) (-> Text Text Bit) (case ("lux text index" 0 sub text) - {#.Some _} + {.#Some _} true _ @@ -133,24 +133,24 @@ (def: .public (clip offset size input) (-> Nat Nat Text (Maybe Text)) (if (|> size (n.+ offset) (n.> ("lux text size" input))) - #.None - {#.Some ("lux text clip" offset size input)})) + {.#None} + {.#Some ("lux text clip" offset size input)})) (def: .public (clip_since offset input) (-> Nat Text (Maybe Text)) (let [size ("lux text size" input)] (if (n.> size offset) - #.None - {#.Some ("lux text clip" offset (n.- offset size) input)}))) + {.#None} + {.#Some ("lux text clip" offset (n.- offset size) input)}))) (def: .public (split_at at x) (-> Nat Text (Maybe [Text Text])) (case [(..clip 0 at x) (..clip_since at x)] - [{#.Some pre} {#.Some post}] - {#.Some [pre post]} + [{.#Some pre} {.#Some post}] + {.#Some [pre post]} _ - #.None)) + {.#None})) (def: .public (split_by token sample) (-> Text Text (Maybe [Text Text])) @@ -165,14 +165,14 @@ (loop [input sample output (: (List Text) (list))] (case (..split_by token input) - {#.Some [pre post]} + {.#Some [pre post]} (|> output - {#.Item pre} + {.#Item pre} (recur post)) - #.None + {.#None} (|> output - {#.Item input} + {.#Item input} list.reversed)))) (def: .public (replaced/1 pattern replacement template) @@ -219,10 +219,10 @@ (loop [left "" right template] (case (..split_by pattern right) - {#.Some [pre post]} + {.#Some [pre post]} (recur ($_ "lux text concat" left pre replacement) post) - #.None + {.#None} ("lux text concat" left right))))) (implementation: .public equivalence diff --git a/stdlib/source/library/lux/data/text/encoding/utf8.lux b/stdlib/source/library/lux/data/text/encoding/utf8.lux index fc063228e..40b58a7dc 100644 --- a/stdlib/source/library/lux/data/text/encoding/utf8.lux +++ b/stdlib/source/library/lux/data/text/encoding/utf8.lux @@ -113,7 +113,7 @@ (def: (decoded value) (-> Binary (Try Text)) - (with_expansions [<jvm> {#try.Success (java/lang/String::new value (//.name //.utf_8))}] + (with_expansions [<jvm> {try.#Success (java/lang/String::new value (//.name //.utf_8))}] (for [@.old <jvm> @.jvm <jvm> @@ -121,23 +121,23 @@ (cond ffi.on_nashorn? (|> ("js object new" ("js constant" "java.lang.String") [value "utf8"]) (:as Text) - #try.Success) + {try.#Success}) ffi.on_node_js? (|> (Buffer::from|decoded [value]) (Buffer::toString ["utf8"]) - #try.Success) + {try.#Success}) ... On the browser (|> (TextDecoder::new [(//.name //.utf_8)]) (TextDecoder::decode [value]) - #try.Success)) + {try.#Success})) @.python (try (:as Text ("python object do" "decode" (:expected value) "utf-8"))) @.lua - {#try.Success ("lua utf8 decode" value)} + {try.#Success ("lua utf8 decode" value)} @.ruby (|> value @@ -145,17 +145,17 @@ (RubyArray::pack ["C*"]) (:as RubyString) (RubyString::force_encoding ["UTF-8"]) - #try.Success) + {try.#Success}) @.php (|> value ("php pack" ..php_byte_array_format) - #try.Success) + {try.#Success}) @.scheme (|> value ..utf8->string - #try.Success)]))) + {try.#Success})]))) (implementation: .public codec (Codec Binary Text) diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux index 422239a27..67e31e72c 100644 --- a/stdlib/source/library/lux/data/text/escape.lux +++ b/stdlib/source/library/lux/data/text/escape.lux @@ -182,15 +182,15 @@ (case (|> current ("lux text clip" (n.+ ..ascii_escape_offset offset) ..code_size) (\ n.hex decoded)) - {#try.Success char} + {try.#Success char} (let [limit' (|> limit (n.- offset) (n.- ..unicode_escape_offset))] - {#try.Success [(format previous + {try.#Success [(format previous ("lux text clip" 0 offset current) (//.of_char char)) ("lux text clip" (n.+ ..unicode_escape_offset offset) limit' current) limit']}) - {#try.Failure error} + {try.#Failure error} (exception.except ..invalid_unicode_escape [current offset]))) (def: .public (un_escaped text) @@ -234,14 +234,14 @@ _ (recur (++ offset) previous current limit)) - {#try.Success (case previous + {try.#Success (case previous "" current _ (format previous current))}))) (syntax: .public (literal [literal <code>.text]) (case (..un_escaped literal) - {#try.Success un_escaped} + {try.#Success un_escaped} (in (list (code.text un_escaped))) - {#try.Failure error} + {try.#Failure error} (meta.failure error))) diff --git a/stdlib/source/library/lux/data/text/format.lux b/stdlib/source/library/lux/data/text/format.lux index b22f3ce00..03de3ed04 100644 --- a/stdlib/source/library/lux/data/text/format.lux +++ b/stdlib/source/library/lux/data/text/format.lux @@ -125,8 +125,8 @@ (All (_ a) (-> (Format a) (Format (Maybe a)))) (function (_ value) (case value - #.None - "#.None" + {.#None} + "{.#None}" - {#.Some value} - (..format "{#.Some " (format value) "}")))) + {.#Some value} + (..format "{.#Some " (format value) "}")))) diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index 63b112bb4..189665302 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -110,8 +110,8 @@ re_range^ re_options^))] (in (case negate? - {#.Some _} (` ((~! <text>.not) ($_ ((~! <>.either)) (~+ parts)))) - #.None (` ($_ ((~! <>.either)) (~+ parts))))))) + {.#Some _} (` ((~! <text>.not) ($_ ((~! <>.either)) (~+ parts)))) + {.#None} (` ($_ ((~! <>.either)) (~+ parts))))))) (def: re_user_class^ (Parser Code) @@ -272,7 +272,7 @@ (type: Re_Group (Variant - #Non_Capturing + {#Non_Capturing} {#Capturing [(Maybe Text) Nat]})) (def: (re_sequential^ capturing? re_scoped^ current_module) @@ -290,19 +290,20 @@ [Nat (List Code) (List (List Code))]) (function (_ part [idx names steps]) (case part - (^or {#.Left complex} {#.Right [#Non_Capturing complex]}) + (^or {.#Left complex} + {.#Right [{#Non_Capturing} complex]}) [idx names (list& (list g!temp complex (` .let) (` [(~ g!total) (\ (~! //.monoid) (~' composite) (~ g!total) (~ g!temp))])) steps)] - {#.Right [{#Capturing [?name num_captures]} scoped]} + {.#Right [{#Capturing [?name num_captures]} scoped]} (let [[idx! name!] (case ?name - {#.Some _name} + {.#Some _name} [idx (code.identifier ["" _name])] - #.None + {.#None} [(++ idx) (code.identifier ["" (n\encoded idx)])]) access (if (n.> 0 num_captures) (` ((~! product.left) (~ name!))) @@ -334,31 +335,31 @@ (All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser [Text (Or l r)]))) (function (_ input) (case (left input) - {#try.Success [input' [lt lv]]} - {#try.Success [input' [lt {0 #0 lv}]]} + {try.#Success [input' [lt lv]]} + {try.#Success [input' [lt {0 #0 lv}]]} - {#try.Failure _} + {try.#Failure _} (case (right input) - {#try.Success [input' [rt rv]]} - {#try.Success [input' [rt {0 #1 rv}]]} + {try.#Success [input' [rt rv]]} + {try.#Success [input' [rt {0 #1 rv}]]} - {#try.Failure error} - {#try.Failure error})))) + {try.#Failure error} + {try.#Failure error})))) (def: (|||_^ left right) (All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser Text))) (function (_ input) (case (left input) - {#try.Success [input' [lt lv]]} - {#try.Success [input' lt]} + {try.#Success [input' [lt lv]]} + {try.#Success [input' lt]} - {#try.Failure _} + {try.#Failure _} (case (right input) - {#try.Success [input' [rt rv]]} - {#try.Success [input' rt]} + {try.#Success [input' [rt rv]]} + {try.#Success [input' rt]} - {#try.Failure error} - {#try.Failure error})))) + {try.#Failure error} + {try.#Failure error})))) (def: (prep_alternative [num_captures alt]) (-> [Nat Code] Code) @@ -391,22 +392,22 @@ [_ (<text>.this "(?:") [_ scoped] (re_alternative^ #0 re_scoped^ current_module) _ (<text>.this ")")] - (in [#Non_Capturing scoped])) + (in [{#Non_Capturing} scoped])) (do <>.monad [complex (re_complex^ current_module)] - (in [#Non_Capturing complex])) + (in [{#Non_Capturing} complex])) (do <>.monad [_ (<text>.this "(?<") captured_name name_part^ _ (<text>.this ">") [num_captures pattern] (re_alternative^ #1 re_scoped^ current_module) _ (<text>.this ")")] - (in [{#Capturing [{#.Some captured_name} num_captures]} pattern])) + (in [{#Capturing [{.#Some captured_name} num_captures]} pattern])) (do <>.monad [_ (<text>.this "(") [num_captures pattern] (re_alternative^ #1 re_scoped^ current_module) _ (<text>.this ")")] - (in [{#Capturing [#.None num_captures]} pattern])))) + (in [{#Capturing [{.#None} num_captures]} pattern])))) (def: (regex^ current_module) (-> Text (Parser Code)) @@ -417,11 +418,11 @@ [current_module meta.current_module_name] (case (<text>.result (regex^ current_module) pattern) - {#try.Failure error} + {try.#Failure error} (meta.failure (format "Error while parsing regular-expression:" //.new_line error)) - {#try.Success regex} + {try.#Success regex} (in (list regex))))) (syntax: .public (^regex [[pattern bindings] (<code>.form (<>.and <code>.text (<>.maybe <code>.any))) @@ -430,6 +431,6 @@ (with_identifiers [g!temp] (in (list& (` (^multi (~ g!temp) [((~! <text>.result) (..regex (~ (code.text pattern))) (~ g!temp)) - {#try.Success (~ (maybe.else g!temp bindings))}])) + {try.#Success (~ (maybe.else g!temp bindings))}])) body branches)))) diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux index 5abc56ffc..770ae8554 100644 --- a/stdlib/source/library/lux/data/text/unicode/block.lux +++ b/stdlib/source/library/lux/data/text/unicode/block.lux @@ -43,14 +43,14 @@ (-> Block Char) (|>> :representation (value@ <slot>)))] - [start #interval.bottom] - [end #interval.top] + [start interval.bottom] + [end interval.top] ) (def: .public (size block) (-> Block Nat) - (let [start (value@ #interval.bottom (:representation block)) - end (value@ #interval.top (:representation block))] + (let [start (value@ interval.bottom (:representation block)) + end (value@ interval.top (:representation block))] (|> end (n.- start) ++))) (def: .public (within? block char) diff --git a/stdlib/source/library/lux/data/trace.lux b/stdlib/source/library/lux/data/trace.lux index 156497e43..5fdf1b1c4 100644 --- a/stdlib/source/library/lux/data/trace.lux +++ b/stdlib/source/library/lux/data/trace.lux @@ -25,7 +25,7 @@ (def: (out wa) ((value@ #trace wa) - (value@ [#monoid #monoid.identity] wa))) + (value@ [#monoid monoid.#identity] wa))) (def: (disjoint wa) (let [monoid (value@ #monoid wa)] |