aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/data
diff options
context:
space:
mode:
authorEduardo Julian2022-08-11 04:15:07 -0400
committerEduardo Julian2022-08-11 04:15:07 -0400
commit065e8a4d8122d4616b570496915d2c0e2c78cd6b (patch)
treef2bbdc3e40b796b34026ab04c9a478d8a3f082d5 /stdlib/source/library/lux/data
parent68d78235694c633c956bb9e8a007cad7d65370bc (diff)
Re-named the "case" macro to "when".
Diffstat (limited to 'stdlib/source/library/lux/data')
-rw-r--r--stdlib/source/library/lux/data/bit.lux4
-rw-r--r--stdlib/source/library/lux/data/collection/bits.lux10
-rw-r--r--stdlib/source/library/lux/data/collection/dictionary.lux46
-rw-r--r--stdlib/source/library/lux/data/collection/dictionary/ordered.lux66
-rw-r--r--stdlib/source/library/lux/data/collection/list.lux96
-rw-r--r--stdlib/source/library/lux/data/collection/list/property.lux10
-rw-r--r--stdlib/source/library/lux/data/collection/queue.lux4
-rw-r--r--stdlib/source/library/lux/data/collection/queue/priority.lux16
-rw-r--r--stdlib/source/library/lux/data/collection/sequence.lux26
-rw-r--r--stdlib/source/library/lux/data/collection/set/multi.lux6
-rw-r--r--stdlib/source/library/lux/data/collection/stack.lux4
-rw-r--r--stdlib/source/library/lux/data/collection/stream.lux4
-rw-r--r--stdlib/source/library/lux/data/collection/tree/finger.lux10
-rw-r--r--stdlib/source/library/lux/data/collection/tree/zipper.lux34
-rw-r--r--stdlib/source/library/lux/data/color.lux6
-rw-r--r--stdlib/source/library/lux/data/format/css.lux4
-rw-r--r--stdlib/source/library/lux/data/format/css/value.lux6
-rw-r--r--stdlib/source/library/lux/data/format/html.lux20
-rw-r--r--stdlib/source/library/lux/data/format/json.lux26
-rw-r--r--stdlib/source/library/lux/data/format/markdown.lux4
-rw-r--r--stdlib/source/library/lux/data/format/tar.lux12
-rw-r--r--stdlib/source/library/lux/data/format/xml.lux10
-rw-r--r--stdlib/source/library/lux/data/sum.lux14
-rw-r--r--stdlib/source/library/lux/data/text.lux26
-rw-r--r--stdlib/source/library/lux/data/text/escape.lux16
-rw-r--r--stdlib/source/library/lux/data/text/regex.lux18
-rw-r--r--stdlib/source/library/lux/data/text/unicode/set.lux2
27 files changed, 250 insertions, 250 deletions
diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux
index dcb0ad6bb..18b53bb1c 100644
--- a/stdlib/source/library/lux/data/bit.lux
+++ b/stdlib/source/library/lux/data/bit.lux
@@ -31,7 +31,7 @@
(def equivalence ..equivalence)
(def (hash value)
- (case value
+ (when value
#0 2
#1 3))))
@@ -55,7 +55,7 @@
"#0"))
(def (decoded input)
- (case input
+ (when input
"#1" {.#Right #1}
"#0" {.#Right #0}
_ {.#Left "Wrong syntax for Bit."}))))
diff --git a/stdlib/source/library/lux/data/collection/bits.lux b/stdlib/source/library/lux/data/collection/bits.lux
index b036bb9dc..1e84ee9c4 100644
--- a/stdlib/source/library/lux/data/collection/bits.lux
+++ b/stdlib/source/library/lux/data/collection/bits.lux
@@ -69,7 +69,7 @@
output ..empty])
(let [idx|output (-- size|output)]
(if (n.> 0 size|output)
- (case (|> (..chunk idx|output input)
+ (when (|> (..chunk idx|output input)
(pipe.cond [(pipe.new (n.= chunk_index idx|output) [])]
[(<op> bit_index)]
@@ -109,7 +109,7 @@
(def .public (not input)
(-> Bits Bits)
- (case (array.size input)
+ (when (array.size input)
0
..empty
@@ -117,7 +117,7 @@
(loop (again [size|output size|output
output ..empty])
(let [idx (-- size|output)]
- (case (|> input (..chunk idx) i64.not .nat)
+ (when (|> input (..chunk idx) i64.not .nat)
0
(again (-- size|output) output)
@@ -133,7 +133,7 @@
(with_template [<name> <op>]
[(def .public (<name> param subject)
(-> Bits Bits Bits)
- (case (n.max (array.size param)
+ (when (n.max (array.size param)
(array.size subject))
0
..empty
@@ -143,7 +143,7 @@
output ..empty])
(let [idx (-- size|output)]
(if (n.> 0 size|output)
- (case (|> (..chunk idx subject)
+ (when (|> (..chunk idx subject)
(<op> (..chunk idx param))
.nat)
0
diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux
index 99badd2bc..a2e1282d5 100644
--- a/stdlib/source/library/lux/data/collection/dictionary.lux
+++ b/stdlib/source/library/lux/data/collection/dictionary.lux
@@ -271,7 +271,7 @@
(if (with_bit_position? (to_bit_position hierarchy_idx)
bitmap)
[(++ base_idx)
- (case (array.item base_idx base)
+ (when (array.item base_idx base)
{.#Left sub_node}
(array.has! hierarchy_idx sub_node h_array)
@@ -289,7 +289,7 @@
... So, this test is introduced to detect them.
(def (node#empty? node)
(All (_ k v) (-> (Node k v) Bit))
- (case node
+ (when node
{#Base ..clean_bitmap _}
true
@@ -298,7 +298,7 @@
(def (node#has level hash key val key_hash node)
(All (_ k v) (-> Level Hash_Code k v (Hash k) (Node k v) (Node k v)))
- (case node
+ (when node
... For #Hierarchy nodes, check whether one can add the element to
... a sub-node. If impossible, introduce a new singleton sub-node.
{#Hierarchy _size hierarchy}
@@ -317,7 +317,7 @@
(if (with_bit_position? bit bitmap)
... If so...
(let [idx (base_index bit bitmap)]
- {#Base bitmap (case (array.item idx base)
+ {#Base bitmap (when (array.item idx base)
... If it's being used by a node, add the KV to it.
{.#Left sub_node}
(let [sub_node' (node#has (level_up level) hash key val key_hash sub_node)]
@@ -371,7 +371,7 @@
(if (n.= hash _hash)
... If they're equal, that means the new KV contributes to the
... collisions.
- (case (collision_index key_hash key _colls)
+ (when (collision_index key_hash key _colls)
... If the key was already present in the collisions-list, its
... value gets updated.
{.#Some coll_idx}
@@ -390,7 +390,7 @@
(def (node#lacks level hash key key_hash node)
(All (_ k v) (-> Level Hash_Code k (Hash k) (Node k v) (Node k v)))
- (case node
+ (when node
... For #Hierarchy nodes, find out if there's a valid sub-node for
... the Hash-Code.
{#Hierarchy h_size h_array}
@@ -422,7 +422,7 @@
(let [bit (level_bit_position level hash)]
(if (with_bit_position? bit bitmap)
(let [idx (base_index bit bitmap)]
- (case (array.item idx base)
+ (when (array.item idx base)
... If set, check if it's a sub_node, and remove the KV
... from it.
{.#Left sub_node}
@@ -460,7 +460,7 @@
... For #Collisions nodes, It need to find out if the key already existst.
{#Collisions _hash _colls}
- (case (collision_index key_hash key _colls)
+ (when (collision_index key_hash key _colls)
... If not, then there's nothing to remove.
{.#None}
node
@@ -477,7 +477,7 @@
(def (node#value level hash key key_hash node)
(All (_ k v) (-> Level Hash_Code k (Hash k) (Node k v) (Maybe v)))
- (case node
+ (when node
... For #Hierarchy nodes, just look-up the key on its children.
{#Hierarchy _size hierarchy}
(let [index (level_index level hash)]
@@ -489,7 +489,7 @@
{#Base bitmap base}
(let [bit (level_bit_position level hash)]
(if (with_bit_position? bit bitmap)
- (case (array.item (base_index bit bitmap) base)
+ (when (array.item (base_index bit bitmap) base)
{.#Left sub_node}
(node#value (level_up level) hash key key_hash sub_node)
@@ -508,7 +508,7 @@
(def (node#size node)
(All (_ k v) (-> (Node k v) Nat))
- (case node
+ (when node
{#Hierarchy _size hierarchy}
(array.mix (function (_ _ item total)
(n.+ item total))
@@ -520,7 +520,7 @@
(n.+ item total))
0
(array.each (function (_ sub_node')
- (case sub_node'
+ (when sub_node'
{.#Left sub_node} (node#size sub_node)
{.#Right _} 1))
base))
@@ -531,7 +531,7 @@
(def (node#mix f init node)
(All (_ k v a) (-> (-> [k v] a a) a (Node k v) a))
- (case node
+ (when node
{#Hierarchy _size hierarchy}
(array.mix (function (_ _ sub_node current)
(node#mix f current sub_node))
@@ -540,7 +540,7 @@
{#Base bitmap base}
(array.mix (function (_ _ branch current)
- (case branch
+ (when branch
{.#Left sub_node}
(node#mix f current sub_node)
@@ -592,7 +592,7 @@
(def .public (key? dict key)
(All (_ k v) (-> (Dictionary k v) k Bit))
- (case (value key dict)
+ (when (value key dict)
{.#None}
false
@@ -603,13 +603,13 @@
(def .public (has' key val dict)
(All (_ k v) (-> k v (Dictionary k v) (Try (Dictionary k v))))
- (case (value key dict)
+ (when (value key dict)
{.#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)
+ (when (value key dict)
{.#None}
dict
@@ -664,7 +664,7 @@
(def .public (composite_with f dict2 dict1)
(All (_ k v) (-> (-> v v v) (Dictionary k v) (Dictionary k v) (Dictionary k v)))
(node#mix (function (_ [key val2] dict)
- (case (value key dict)
+ (when (value key dict)
{.#None}
(has key val2 dict)
@@ -675,7 +675,7 @@
(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)
+ (when (value from_key dict)
{.#None}
dict
@@ -688,7 +688,7 @@
(All (_ k v) (-> (List k) (Dictionary k v) (Dictionary k v)))
(let [[key_hash _] dict]
(list#mix (function (_ key new_dict)
- (case (value key dict)
+ (when (value key dict)
{.#None} new_dict
{.#Some val} (has key val new_dict)))
(empty key_hash)
@@ -701,7 +701,7 @@
(and (n.= (..size reference)
(..size subject))
(list.every? (function (_ [k rv])
- (case (..value k subject)
+ (when (..value k subject)
{.#Some sv}
(,#= rv sv)
@@ -713,13 +713,13 @@
(All (_ k) (Functor (Node k)))
(implementation
(def (each f fa)
- (case fa
+ (when fa
{#Hierarchy size hierarchy}
{#Hierarchy size (array.each (each f) hierarchy)}
{#Base bitmap base}
{#Base bitmap (array.each (function (_ either)
- (case either
+ (when either
{.#Left fa'}
{.#Left (each f fa')}
diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux
index 44848eae6..3541cef42 100644
--- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux
+++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux
@@ -64,7 +64,7 @@
(let [... (open "_#[0]") (the #order dict)
]
(loop (again [node (the #root dict)])
- (case node
+ (when node
{.#None}
{.#None}
@@ -89,7 +89,7 @@
(let [... (open "_#[0]") (the #order dict)
]
(loop (again [node (the #root dict)])
- (case node
+ (when node
{.#None}
false
@@ -105,13 +105,13 @@
(with_template [<name> <side>]
[(def .public (<name> dict)
(All (_ k v) (-> (Dictionary k v) (Maybe v)))
- (case (the #root dict)
+ (when (the #root dict)
{.#None}
{.#None}
{.#Some node}
(loop (again [node node])
- (case (the <side> node)
+ (when (the <side> node)
{.#None}
{.#Some (the #value node)}
@@ -125,7 +125,7 @@
(def .public (size dict)
(All (_ k v) (-> (Dictionary k v) Nat))
(loop (again [node (the #root dict)])
- (case node
+ (when node
{.#None}
0
@@ -140,7 +140,7 @@
(with_template [<name> <other_color> <self_color> <no_change>]
[(def (<name> self)
(All (_ k v) (-> (Node k v) (Node k v)))
- (case (the #color self)
+ (when (the #color self)
{<other_color>}
(.has #color {<self_color>} self)
@@ -154,7 +154,7 @@
(def (with_left addition center)
(All (_ k v) (-> (Node k v) (Node k v) (Node k v)))
- (case (the #color center)
+ (when (the #color center)
{#Red}
(red (the #key center)
(the #value center)
@@ -167,9 +167,9 @@
(the #value center)
{.#Some addition}
(the #right center)))]
- (case (the #color addition)
+ (when (the #color addition)
{#Red}
- (case (the #left addition)
+ (when (the #left addition)
(^.multi {.#Some left}
[(the #color left) {#Red}])
(red (the #key addition)
@@ -181,7 +181,7 @@
(the #right center))})
_
- (case (the #right addition)
+ (when (the #right addition)
(^.multi {.#Some right}
[(the #color right) {#Red}])
(red (the #key right)
@@ -203,7 +203,7 @@
(def (with_right addition center)
(All (_ k v) (-> (Node k v) (Node k v) (Node k v)))
- (case (the #color center)
+ (when (the #color center)
{#Red}
(red (the #key center)
(the #value center)
@@ -216,9 +216,9 @@
(the #value center)
(the #left center)
{.#Some addition}))]
- (case (the #color addition)
+ (when (the #color addition)
{#Red}
- (case (the #right addition)
+ (when (the #right addition)
(^.multi {.#Some right}
[(the #color right) {#Red}])
(red (the #key addition)
@@ -230,7 +230,7 @@
{.#Some (blackened right)})
_
- (case (the #left addition)
+ (when (the #left addition)
(^.multi {.#Some left}
[(the #color left) {#Red}])
(red (the #key left)
@@ -254,7 +254,7 @@
(All (_ k v) (-> k v (Dictionary k v) (Dictionary k v)))
(let [(open "_#[0]") (the #order dict)
root' (loop (again [?root (the #root dict)])
- (case ?root
+ (when ?root
{.#None}
{.#Some (red key value {.#None} {.#None})}
@@ -281,7 +281,7 @@
(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
+ (when ?left
(^.multi {.#Some left}
[(the #color left) {#Red}]
[(the #left left) {.#Some left>>left}]
@@ -310,7 +310,7 @@
(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
+ (when ?right
(^.multi {.#Some right}
[(the #color right) {#Red}]
[(the #right right) {.#Some right>>right}]
@@ -337,13 +337,13 @@
(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
+ (when ?left
(^.multi {.#Some left}
[(the #color left) {#Red}])
(red key value {.#Some (blackened left)} ?right)
_
- (case ?right
+ (when ?right
(^.multi {.#Some right}
[(the #color right) {#Black}])
(right_balanced key value ?left {.#Some (reddened right)})
@@ -366,13 +366,13 @@
(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
+ (when ?right
(^.multi {.#Some right}
[(the #color right) {#Red}])
(red key value ?left {.#Some (blackened right)})
_
- (case ?left
+ (when ?left
(^.multi {.#Some left}
[(the #color left) {#Black}])
(left_balanced key value {.#Some (reddened left)} ?right)
@@ -395,7 +395,7 @@
(def (prepended ?left ?right)
(All (_ k v) (-> (Maybe (Node k v)) (Maybe (Node k v)) (Maybe (Node k v))))
- (case [?left ?right]
+ (when [?left ?right]
[{.#None} _]
?right
@@ -403,11 +403,11 @@
?left
[{.#Some left} {.#Some right}]
- (case [(the #color left) (the #color right)]
+ (when [(the #color left) (the #color right)]
[{#Red} {#Red}]
(do maybe.monad
[fused (prepended (the #right left) (the #right right))]
- (case (the #color fused)
+ (when (the #color fused)
{#Red}
(in (red (the #key fused)
(the #value fused)
@@ -446,7 +446,7 @@
[{#Black} {#Black}]
(do maybe.monad
[fused (prepended (the #right left) (the #left right))]
- (case (the #color fused)
+ (when (the #color fused)
{#Red}
(in (red (the #key fused)
(the #value fused)
@@ -477,7 +477,7 @@
(All (_ k v) (-> k (Dictionary k v) (Dictionary k v)))
(let [(open "_#[0]") (the #order dict)
[?root found?] (loop (again [?root (the #root dict)])
- (case ?root
+ (when ?root
{.#Some root}
(let [root_key (the #key root)
root_val (the #value root)]
@@ -486,7 +486,7 @@
(the #right root))
true]
(let [go_left? (_#< root_key key)]
- (case (again (if go_left?
+ (when (again (if go_left?
(the #left root)
(the #right root)))
[{.#None} .false]
@@ -494,7 +494,7 @@
[side_outcome _]
(if go_left?
- (case (the #left root)
+ (when (the #left root)
(^.multi {.#Some left}
[(the #color left) {#Black}])
[{.#Some (without_left root_key root_val side_outcome (the #right root))}
@@ -503,7 +503,7 @@
_
[{.#Some (red root_key root_val side_outcome (the #right root))}
false])
- (case (the #right root)
+ (when (the #right root)
(^.multi {.#Some right}
[(the #color right) {#Black}])
[{.#Some (without_right root_key root_val (the #left root) side_outcome)}
@@ -518,7 +518,7 @@
{.#None}
[{.#None} false]
))]
- (case ?root
+ (when ?root
{.#None}
(if found?
(.has #root ?root dict)
@@ -530,7 +530,7 @@
(def .public (revised key transform dict)
(All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v)))
- (case (..value key dict)
+ (when (..value key dict)
{.#Some old}
(..has key (transform old) dict)
@@ -548,7 +548,7 @@
[(def .public (<name> dict)
(All (_ k v) (-> (Dictionary k v) (List <type>)))
(loop (again [node (the #root dict)])
- (case node
+ (when node
{.#None}
(list)
@@ -570,7 +570,7 @@
(let [(open "/#[0]") (the #order reference)]
(loop (again [entriesR (entries reference)
entriesS (entries sample)])
- (case [entriesR entriesS]
+ (when [entriesR entriesS]
[{.#End} {.#End}]
true
diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux
index 4114acd8e..c2dff94fc 100644
--- a/stdlib/source/library/lux/data/collection/list.lux
+++ b/stdlib/source/library/lux/data/collection/list.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except revised all only with)
+ [lux (.except revised all only with when)
[abstract
[monoid (.only Monoid)]
[apply (.only Apply)]
@@ -30,7 +30,7 @@
(Mix List)
(implementation
(def (mix f init xs)
- (case xs
+ (.when xs
{.#End}
init
@@ -39,7 +39,7 @@
(def .public (mixes f init inputs)
(All (_ a b) (-> (-> a b b) b (List a) (List b)))
- (case inputs
+ (.when inputs
{.#End}
(list init)
@@ -57,7 +57,7 @@
(def .public (only keep? xs)
(All (_ a)
(-> (Predicate a) (List a) (List a)))
- (case xs
+ (.when xs
{.#End}
{.#End}
@@ -68,7 +68,7 @@
(def .public (partition satisfies? list)
(All (_ a) (-> (Predicate a) (List a) [(List a) (List a)]))
- (case list
+ (.when list
{.#End}
[{.#End} {.#End}]
@@ -85,7 +85,7 @@
(def .public partial
(macro (_ tokens state)
- (case (reversed tokens)
+ (.when (reversed tokens)
{.#Item tail heads}
{.#Right [state (list (..mix (function (_ head tail)
(` {.#Item (, head) (, tail)}))
@@ -97,9 +97,9 @@
(def .public (pairs xs)
(All (_ a) (-> (List a) (Maybe (List [a a]))))
- (case xs
+ (.when xs
(partial x1 x2 xs')
- (case (pairs xs')
+ (.when (pairs xs')
{.#Some tail}
{.#Some (partial [x1 x2] tail)}
@@ -117,7 +117,7 @@
(All (_ a)
(-> Nat (List a) (List a)))
(if (n.> 0 n)
- (case xs
+ (.when xs
{.#End}
{.#End}
@@ -133,7 +133,7 @@
[(def .public (<name> predicate xs)
(All (_ a)
(-> (Predicate a) (List a) (List a)))
- (case xs
+ (.when xs
{.#End}
{.#End}
@@ -149,9 +149,9 @@
(def .public (split_at n xs)
(All (_ a)
(-> Nat (List a) [(List a) (List a)]))
- (case n
+ (.when n
0 [{.#End} xs]
- _ (case xs
+ _ (.when xs
{.#End}
[{.#End} {.#End}]
@@ -162,7 +162,7 @@
(def (split_when' predicate ys xs)
(All (_ a)
(-> (Predicate a) (List a) (List a) [(List a) (List a)]))
- (case xs
+ (.when xs
{.#End}
[ys xs]
@@ -179,7 +179,7 @@
(def .public (sub size list)
(All (_ a) (-> Nat (List a) (List (List a))))
- (case list
+ (.when list
{.#End}
{.#End}
@@ -190,14 +190,14 @@
(def .public (repeated n x)
(All (_ a)
(-> Nat a (List a)))
- (case n
+ (.when n
0 {.#End}
_ {.#Item x (repeated (-- n) x)}))
(def (iterations' f x)
(All (_ a)
(-> (-> a (Maybe a)) a (List a)))
- (case (f x)
+ (.when (f x)
{.#Some x'}
{.#Item x (iterations' f x')}
@@ -207,7 +207,7 @@
(def .public (iterations f x)
(All (_ a)
(-> (-> a (Maybe a)) a (List a)))
- (case (f x)
+ (.when (f x)
{.#Some x'}
{.#Item x (iterations' f x')}
@@ -217,12 +217,12 @@
(def .public (one check xs)
(All (_ a b)
(-> (-> a (Maybe b)) (List a) (Maybe b)))
- (case xs
+ (.when xs
{.#End}
{.#None}
{.#Item x xs'}
- (case (check x)
+ (.when (check x)
{.#Some output}
{.#Some output}
@@ -235,7 +235,7 @@
(for @.js
... TODO: Stop relying on this ASAP.
(mix (function (_ head tail)
- (case (check head)
+ (.when (check head)
{.#Some head}
{.#Item head tail}
@@ -243,12 +243,12 @@
tail))
{.#End}
(reversed xs))
- (case xs
+ (.when xs
{.#End}
{.#End}
{.#Item x xs'}
- (case (check x)
+ (.when (check x)
{.#Some output}
{.#Item output (all check xs')}
@@ -267,7 +267,7 @@
(def .public (interposed sep xs)
(All (_ a)
(-> a (List a) (List a)))
- (case xs
+ (.when xs
{.#End}
xs
@@ -285,7 +285,7 @@
[(def .public (<name> predicate items)
(All (_ a)
(-> (Predicate a) (List a) Bit))
- (case items
+ (.when items
{.#End}
<init>
@@ -300,12 +300,12 @@
(def .public (item i xs)
(All (_ a)
(-> Nat (List a) (Maybe a)))
- (case xs
+ (.when xs
{.#End}
{.#None}
{.#Item x xs'}
- (case i
+ (.when i
0 {.#Some x}
_ (item (-- i) xs'))))
@@ -313,7 +313,7 @@
(All (_ a) (-> (Equivalence a) (Equivalence (List a))))
(implementation
(def (= xs ys)
- (case [xs ys]
+ (.when [xs ys]
[{.#End} {.#End}]
true
@@ -342,7 +342,7 @@
(def identity
{.#End})
(def (composite xs ys)
- (case xs
+ (.when xs
{.#End}
ys
@@ -355,7 +355,7 @@
(Functor List)
(implementation
(def (each f ma)
- (case ma
+ (.when ma
{.#End}
{.#End}
@@ -370,7 +370,7 @@
(def functor ..functor)
(def (on fa ff)
- (case ff
+ (.when ff
{.#End}
{.#End}
@@ -392,7 +392,7 @@
(def .public (sorted < xs)
(All (_ a) (-> (-> a a Bit) (List a) (List a)))
- (case xs
+ (.when xs
{.#End}
(list)
@@ -410,7 +410,7 @@
(def .public (empty? xs)
(All (_ a) (Predicate (List a)))
- (case xs
+ (.when xs
{.#End}
true
@@ -419,7 +419,7 @@
(def .public (member? eq xs x)
(All (_ a) (-> (Equivalence a) (List a) a Bit))
- (case xs
+ (.when xs
{.#End}
false
@@ -430,7 +430,7 @@
(with_template [<name> <output> <side>]
[(def .public (<name> xs)
(All (_ a) (-> (List a) (Maybe <output>)))
- (case xs
+ (.when xs
{.#End}
{.#None}
@@ -443,7 +443,7 @@
(def .public (indices size)
(All (_ a) (-> Nat (List Nat)))
- (case size
+ (.when size
0 (list)
_ (|> size -- (enum.range n.enum 0))))
@@ -455,7 +455,7 @@
(-> Nat Text)
(loop (again [input value
output ""])
- (let [digit (case (n.% 10 input)
+ (let [digit (.when (n.% 10 input)
0 "0"
1 "1"
2 "2"
@@ -469,13 +469,13 @@
_ (undefined))
output' ("lux text concat" digit output)
input' (n./ 10 input)]
- (case input'
+ (.when input'
0 output'
_ (again input' output')))))
(def .public zipped
(macro (_ tokens state)
- (case tokens
+ (.when tokens
(list [_ {.#Nat num_lists}])
(if (n.> 0 num_lists)
(let [(open "[0]") ..functor
@@ -498,7 +498,7 @@
list_vars (each product.right vars+lists)
code (` (is (, zipped_type)
(function ((, g!step) (,* list_vars))
- (case [(,* list_vars)]
+ (.when [(,* list_vars)]
(, pattern)
{.#Item [(,* (each product.left vars+lists))]
((, g!step) (,* list_vars))}
@@ -516,7 +516,7 @@
(def .public zipped_with
(macro (_ tokens state)
- (case tokens
+ (.when tokens
(list [_ {.#Nat num_lists}])
(if (n.> 0 num_lists)
(let [(open "[0]") ..functor
@@ -542,7 +542,7 @@
list_vars (each product.right vars+lists)
code (` (is (, zipped_type)
(function ((, g!step) (, g!func) (,* list_vars))
- (case [(,* list_vars)]
+ (.when [(,* list_vars)]
(, pattern)
{.#Item ((, g!func) (,* (each product.left vars+lists)))
((, g!step) (, g!func) (,* list_vars))}
@@ -560,7 +560,7 @@
(def .public (last xs)
(All (_ a) (-> (List a) (Maybe a)))
- (case xs
+ (.when xs
{.#End}
{.#None}
@@ -572,7 +572,7 @@
(def .public (inits xs)
(All (_ a) (-> (List a) (Maybe (List a))))
- (case xs
+ (.when xs
{.#End}
{.#None}
@@ -580,7 +580,7 @@
{.#Some {.#End}}
{.#Item x xs'}
- (case (inits xs')
+ (.when (inits xs')
{.#None}
(undefined)
@@ -620,7 +620,7 @@
(All (_ a) (-> (List a) (List [Nat a])))
(loop (again [idx 0
xs xs])
- (case xs
+ (.when xs
{.#End}
{.#End}
@@ -629,7 +629,7 @@
(def .public when
(macro (_ tokens state)
- (case tokens
+ (.when tokens
(list test then)
{.#Right [state (.list (` (.if (, test)
(, then)
@@ -640,11 +640,11 @@
(def .public (revised item revision it)
(All (_ a) (-> Nat (-> a a) (List a) (List a)))
- (case it
+ (.when it
{.#End}
{.#End}
{.#Item head tail}
- (case item
+ (.when item
0 {.#Item (revision head) tail}
_ (revised (-- item) revision it))))
diff --git a/stdlib/source/library/lux/data/collection/list/property.lux b/stdlib/source/library/lux/data/collection/list/property.lux
index a4480dabb..d249a3a4f 100644
--- a/stdlib/source/library/lux/data/collection/list/property.lux
+++ b/stdlib/source/library/lux/data/collection/list/property.lux
@@ -33,7 +33,7 @@
(def .public (value key properties)
(All (_ a) (-> Text (List a) (Maybe a)))
- (case properties
+ (when properties
{.#End}
{.#None}
@@ -53,7 +53,7 @@
(def .public (contains? key properties)
(All (_ a) (-> Text (List a) Bit))
- (case (..value key properties)
+ (when (..value key properties)
{.#Some _}
true
@@ -62,7 +62,7 @@
(def .public (has key val properties)
(All (_ a) (-> Text a (List a) (List a)))
- (case properties
+ (when properties
{.#End}
(list [key val])
@@ -75,7 +75,7 @@
(def .public (revised key f properties)
(All (_ a) (-> Text (-> a a) (List a) (List a)))
- (case properties
+ (when properties
{.#End}
{.#End}
@@ -86,7 +86,7 @@
(def .public (lacks key properties)
(All (_ a) (-> Text (List a) (List a)))
- (case properties
+ (when properties
{.#End}
properties
diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux
index 0420c1954..05a5107c3 100644
--- a/stdlib/source/library/lux/data/collection/queue.lux
+++ b/stdlib/source/library/lux/data/collection/queue.lux
@@ -53,7 +53,7 @@
(def .public (next queue)
(All (_ a) (-> (Queue a) (Queue a)))
- (case (the #front queue)
+ (when (the #front queue)
... Empty...
(.list)
queue
@@ -71,7 +71,7 @@
(def .public (end val queue)
(All (_ a) (-> a (Queue a) (Queue a)))
- (case (the #front queue)
+ (when (the #front queue)
{.#End}
(has #front (.list val) queue)
diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux
index 0d02d0a09..bbd66f362 100644
--- a/stdlib/source/library/lux/data/collection/queue/priority.lux
+++ b/stdlib/source/library/lux/data/collection/queue/priority.lux
@@ -53,13 +53,13 @@
(def .public (size queue)
(All (_ a) (-> (Queue a) Nat))
- (case (representation queue)
+ (when (representation queue)
{.#None}
0
{.#Some tree}
(loop (again [node tree])
- (case (tree.root node)
+ (when (tree.root node)
{0 #0 _}
1
@@ -68,13 +68,13 @@
(def .public (member? equivalence queue member)
(All (_ a) (-> (Equivalence a) (Queue a) a Bit))
- (case (representation queue)
+ (when (representation queue)
{.#None}
false
{.#Some tree}
(loop (again [node tree])
- (case (tree.root node)
+ (when (tree.root node)
{0 #0 reference}
(at equivalence = reference member)
@@ -89,7 +89,7 @@
[tree (representation queue)
.let [highest_priority (tree.tag tree)]]
(loop (again [node tree])
- (case (tree.root node)
+ (when (tree.root node)
{0 #0 reference}
(if (n.= highest_priority (tree.tag node))
{.#None}
@@ -97,13 +97,13 @@
{0 #1 left right}
(if (n.= highest_priority (tree.tag left))
- (case (again left)
+ (when (again left)
{.#None}
{.#Some right}
{.#Some =left}
{.#Some (at ..builder branch =left right)})
- (case (again right)
+ (when (again right)
{.#None}
{.#Some left}
@@ -114,7 +114,7 @@
(All (_ a) (-> Priority a (Queue a) (Queue a)))
(let [addition (at ..builder leaf priority value)]
(abstraction
- (case (representation queue)
+ (when (representation queue)
{.#None}
{.#Some addition}
diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux
index 060c5a255..55c782acf 100644
--- a/stdlib/source/library/lux/data/collection/sequence.lux
+++ b/stdlib/source/library/lux/data/collection/sequence.lux
@@ -118,7 +118,7 @@
(if (array.lacks? sub_idx parent)
... If so, set the path to the tail
(..path (level_down level) tail)
- (case (array.item sub_idx parent)
+ (when (array.item sub_idx parent)
... If not, push the tail onto the sub_node.
{#Hierarchy sub_node}
{#Hierarchy (with_tail size (level_down level) tail sub_node)}
@@ -138,7 +138,7 @@
(def (hierarchy#has level idx val hierarchy)
(All (_ a) (-> Level Index a (Hierarchy a) (Hierarchy a)))
(let [sub_idx (branch_idx (i64.right_shifted level idx))]
- (case (array.item sub_idx hierarchy)
+ (when (array.item sub_idx hierarchy)
{#Hierarchy sub_node}
(|> (array.clone hierarchy)
(array.has! sub_idx {#Hierarchy (hierarchy#has (level_down level) idx val sub_node)}))
@@ -165,7 +165,7 @@
(maybe#each (function (_ sub)
(|> (array.clone hierarchy)
(array.has! sub_idx {#Hierarchy sub})))
- (case (array.item sub_idx hierarchy)
+ (when (array.item sub_idx hierarchy)
{#Hierarchy sub}
(without_tail size (level_down level) sub)
@@ -180,7 +180,7 @@
(def (node#list node)
(All (_ a) (-> (Node a) (List a)))
- (case node
+ (when node
{#Base base}
(array.list {.#None} base)
@@ -264,7 +264,7 @@
(let [index (branch_idx (i64.right_shifted level idx))]
(if (array.lacks? index hierarchy)
(exception.except ..base_was_not_found [])
- (case [(n.> branching_exponent level)
+ (when [(n.> branching_exponent level)
(array.item index hierarchy)]
[.true {#Hierarchy sub}]
(again (level_down level) sub)
@@ -307,7 +307,7 @@
(def .public (prefix sequence)
(All (_ a) (-> (Sequence a) (Sequence a)))
- (case (the #size sequence)
+ (when (the #size sequence)
0
empty
@@ -332,7 +332,7 @@
(with_expansions [<else> [level root]]
(if (n.> branching_exponent level)
(if (array.lacks? 1 root)
- (case (array.item 0 root)
+ (when (array.item 0 root)
{#Hierarchy sub_node}
(again (level_down level) sub_node)
@@ -375,7 +375,7 @@
(All (_ a) (-> (Equivalence a) (Equivalence (Node a))))
(implementation
(def (= v1 v2)
- (case [v1 v2]
+ (when [v1 v2]
[{#Base b1} {#Base b2}]
(array.= //#= b1 b2)
@@ -400,7 +400,7 @@
(Mix Node)
(implementation
(def (mix $ init xs)
- (case xs
+ (when xs
{#Base base}
(array.mix (function (_ _ item output) ($ item output))
init
@@ -434,7 +434,7 @@
(Functor Node)
(implementation
(def (each $ xs)
- (case xs
+ (when xs
{#Base base}
{#Base (array.each $ base)}
@@ -491,7 +491,7 @@
(let [help (is (All (_ a)
(-> (Predicate a) (Node a) Bit))
(function (help predicate node)
- (case node
+ (when node
{#Base base}
(<array> predicate base)
@@ -518,7 +518,7 @@
(def (one|node check items)
(All (_ a b)
(-> (-> a (Maybe b)) (Node a) (Maybe b)))
- (case items
+ (when items
{#Base items}
(array.one check items)
@@ -528,7 +528,7 @@
(def .public (one check items)
(All (_ a b)
(-> (-> a (Maybe b)) (Sequence a) (Maybe b)))
- (case (let [... TODO: This binding was established to get around a compilation error. Fix and inline!
+ (when (let [... TODO: This binding was established to get around a compilation error. Fix and inline!
check (..one|node check)]
(|> items
(the #root)
diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux
index 3b3e2039d..e08756a80 100644
--- a/stdlib/source/library/lux/data/collection/set/multi.lux
+++ b/stdlib/source/library/lux/data/collection/set/multi.lux
@@ -34,7 +34,7 @@
(def .public (has multiplicity elem set)
(All (_ a) (-> Nat a (Set a) (Set a)))
- (case multiplicity
+ (when multiplicity
0 set
_ (|> set
representation
@@ -43,9 +43,9 @@
(def .public (lacks multiplicity elem set)
(All (_ a) (-> Nat a (Set a) (Set a)))
- (case multiplicity
+ (when multiplicity
0 set
- _ (case (dictionary.value elem (representation set))
+ _ (when (dictionary.value elem (representation set))
{.#Some current}
(abstraction
(if (n.> multiplicity current)
diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux
index c53ba235a..c037e1a56 100644
--- a/stdlib/source/library/lux/data/collection/stack.lux
+++ b/stdlib/source/library/lux/data/collection/stack.lux
@@ -28,7 +28,7 @@
(def .public (value stack)
(All (_ a) (-> (Stack a) (Maybe a)))
- (case (representation stack)
+ (when (representation stack)
{.#End}
{.#None}
@@ -37,7 +37,7 @@
(def .public (next stack)
(All (_ a) (-> (Stack a) (Maybe [a (Stack a)])))
- (case (representation stack)
+ (when (representation stack)
{.#End}
{.#None}
diff --git a/stdlib/source/library/lux/data/collection/stream.lux b/stdlib/source/library/lux/data/collection/stream.lux
index 3c3a2cb29..bf39422ee 100644
--- a/stdlib/source/library/lux/data/collection/stream.lux
+++ b/stdlib/source/library/lux/data/collection/stream.lux
@@ -39,7 +39,7 @@
(-> [a (List a)] (Stream a)))
(loop (again [head start
tail next])
- (//.pending [head (case tail
+ (//.pending [head (when tail
{.#End}
(again start next)
@@ -59,7 +59,7 @@
(def .public (item idx stream)
(All (_ a) (-> Nat (Stream a) a))
(let [[head tail] (//.result stream)]
- (case idx
+ (when idx
0 head
_ (item (-- idx) tail))))
diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux
index b8a654516..68d7e7157 100644
--- a/stdlib/source/library/lux/data/collection/tree/finger.lux
+++ b/stdlib/source/library/lux/data/collection/tree/finger.lux
@@ -58,7 +58,7 @@
(def .public (value tree)
(All (_ @ t v) (-> (Tree @ t v) v))
- (case (the #root (representation tree))
+ (when (the #root (representation tree))
{0 #0 value}
value
@@ -67,7 +67,7 @@
(def .public (tags tree)
(All (_ @ t v) (-> (Tree @ t v) (List t)))
- (case (the #root (representation tree))
+ (when (the #root (representation tree))
{0 #0 value}
(list (the #tag (representation tree)))
@@ -77,7 +77,7 @@
(def .public (values tree)
(All (_ @ t v) (-> (Tree @ t v) (List v)))
- (case (the #root (representation tree))
+ (when (the #root (representation tree))
{0 #0 value}
(list value)
@@ -92,7 +92,7 @@
(let [(open "tag//[0]") monoid]
(loop (again [_tag tag//identity
_node root])
- (case _node
+ (when _node
{0 #0 value}
{.#Some value}
@@ -106,7 +106,7 @@
(def .public (exists? predicate tree)
(All (_ @ t v) (-> (Predicate t) (Tree @ t v) Bit))
- (case (..one predicate tree)
+ (when (..one predicate tree)
{.#Some _}
true
diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux
index 1e403280e..b06a5c591 100644
--- a/stdlib/source/library/lux/data/collection/tree/zipper.lux
+++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux
@@ -80,7 +80,7 @@
(def .public (start? zipper)
(All (_ a) (-> (Zipper a) Bit))
- (case (the #family zipper)
+ (when (the #family zipper)
{.#None}
true
@@ -89,7 +89,7 @@
(def .public (down zipper)
(All (_ a) (-> (Zipper a) (Maybe (Zipper a))))
- (case (..children zipper)
+ (when (..children zipper)
{.#End}
{.#None}
@@ -120,9 +120,9 @@
(with_template [<one> <all> <side> <op_side>]
[(def .public (<one> zipper)
(All (_ a) (-> (Zipper a) (Maybe (Zipper a))))
- (case (the #family zipper)
+ (when (the #family zipper)
{.#Some family}
- (case (the <side> family)
+ (when (the <side> family)
{.#Item next side'}
{.#Some (for @.old
[#family {.#Some (|> family
@@ -144,12 +144,12 @@
(def .public (<all> zipper)
(All (_ a) (-> (Zipper a) (Maybe (Zipper a))))
- (case (the #family zipper)
+ (when (the #family zipper)
{.#None}
{.#None}
{.#Some family}
- (case (list.reversed (the <side> family))
+ (when (list.reversed (the <side> family))
{.#End}
{.#None}
@@ -173,13 +173,13 @@
(def .public (next zipper)
(All (_ a) (-> (Zipper a) (Maybe (Zipper a))))
- (case (..down zipper)
+ (when (..down zipper)
{.#Some forward}
{.#Some forward}
{.#None}
(loop (again [@ zipper])
- (case (..right @)
+ (when (..right @)
{.#Some forward}
{.#Some forward}
@@ -190,12 +190,12 @@
(def (bottom zipper)
(All (_ a) (-> (Zipper a) (Zipper a)))
- (case (..right zipper)
+ (when (..right zipper)
{.#Some forward}
(bottom forward)
{.#None}
- (case (..down zipper)
+ (when (..down zipper)
{.#Some forward}
(bottom forward)
@@ -204,12 +204,12 @@
(def .public (previous zipper)
(All (_ a) (-> (Zipper a) (Maybe (Zipper a))))
- (case (..left zipper)
+ (when (..left zipper)
{.#None}
(..up zipper)
{.#Some backward}
- {.#Some (case (..down backward)
+ {.#Some (when (..down backward)
{.#Some then}
(..bottom then)
@@ -219,13 +219,13 @@
(with_template [<name> <move>]
[(def .public (<name> zipper)
(All (_ a) (-> (Zipper a) (Maybe (Zipper a))))
- (case (<move> zipper)
+ (when (<move> zipper)
{.#None}
{.#None}
{.#Some @}
(loop (again [@ @])
- (case (<move> @)
+ (when (<move> @)
{.#None}
{.#Some @}
@@ -238,7 +238,7 @@
(def .public (end? zipper)
(All (_ a) (-> (Zipper a) Bit))
- (case (..end zipper)
+ (when (..end zipper)
{.#None}
true
@@ -261,7 +261,7 @@
(All (_ a) (-> (Zipper a) (Maybe (Zipper a))))
(do maybe.monad
[family (the #family zipper)]
- (case (the #lefts family)
+ (when (the #lefts family)
{.#End}
(in (has [#node //.#children]
(the #rights family)
@@ -277,7 +277,7 @@
(with_template [<name> <side>]
[(def .public (<name> value zipper)
(All (_ a) (-> a (Zipper a) (Maybe (Zipper a))))
- (case (the #family zipper)
+ (when (the #family zipper)
{.#None}
{.#None}
diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux
index bbccf6b7b..61e3d5593 100644
--- a/stdlib/source/library/lux/data/color.lux
+++ b/stdlib/source/library/lux/data/color.lux
@@ -249,9 +249,9 @@
t (|> +1.0 (f.- (|> +1.0 (f.- f) (f.* saturation))) (f.* brightness))
v brightness
mod (|> i (f.% +6.0) f.int .nat)
- red (case mod 0 v 1 q 2 p 3 p 4 t 5 v _ (undefined))
- green (case mod 0 t 1 v 2 v 3 q 4 p 5 p _ (undefined))
- blue (case mod 0 p 1 p 2 t 3 v 4 v 5 q _ (undefined))]
+ red (when mod 0 v 1 q 2 p 3 p 4 t 5 v _ (undefined))
+ green (when mod 0 t 1 v 2 v 3 q 4 p 5 p _ (undefined))
+ blue (when mod 0 p 1 p 2 t 3 v 4 v 5 q _ (undefined))]
(of_rgb [#red (..up red)
#green (..up green)
#blue (..up blue)])))
diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux
index 80b0623cd..600068d16 100644
--- a/stdlib/source/library/lux/data/format/css.lux
+++ b/stdlib/source/library/lux/data/format/css.lux
@@ -55,7 +55,7 @@
(def .public (font font)
(-> Font (CSS Special))
- (let [with_unicode (case (the /font.#unicode_range font)
+ (let [with_unicode (when (the /font.#unicode_range font)
{.#Some unicode_range}
(let [unicode_range' (format "U+" (at nat.hex encoded (the /font.#start unicode_range))
"-" (at nat.hex encoded (the /font.#end unicode_range)))]
@@ -79,7 +79,7 @@
(def .public (import url query)
(-> URL (Maybe Query) (CSS Special))
(abstraction (format (format "@import url(" (%.text url) ")")
- (case query
+ (when query
{.#Some query}
(format " " (/query.query query))
diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux
index 3845d2cb6..4675c0385 100644
--- a/stdlib/source/library/lux/data/format/css/value.lux
+++ b/stdlib/source/library/lux/data/format/css/value.lux
@@ -918,7 +918,7 @@
(def (with_hint [hint stop])
(-> [(Maybe Hint) Stop] Text)
- (case hint
+ (when hint
{.#None}
(representation Stop stop)
@@ -1073,7 +1073,7 @@
Stop (List/1 [(Maybe Hint) Stop])
(Value Image))
(let [after_extent (format "at " (representation location))
- with_extent (case extent
+ with_extent (when extent
{.#Some extent}
(format (..extent extent) " " after_extent)
@@ -1155,7 +1155,7 @@
(def .public (font_family options)
(-> (List Font) (Value Font))
- (case options
+ (when options
{.#Item _}
(|> options
(list#each ..font_name)
diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux
index 15d20bb2d..d01f92b22 100644
--- a/stdlib/source/library/lux/data/format/html.lux
+++ b/stdlib/source/library/lux/data/format/html.lux
@@ -46,7 +46,7 @@
(def (target value)
(-> Target Text)
- (case value
+ (when value
{#Blank} "_blank"
{#Parent} "_parent"
{#Self} "_self"
@@ -176,7 +176,7 @@
(def .public (base href target)
(-> URL (Maybe Target) Meta)
(let [partial (list ["href" href])
- full (case target
+ full (when target
{.#Some target}
(list.partial ["target" (..target target)] partial)
@@ -286,7 +286,7 @@
(def (area attributes shape)
(-> Attributes Shape (HTML Any))
- (case shape
+ (when shape
{#Rectangle rectangle}
(..rectangle attributes rectangle)
@@ -300,7 +300,7 @@
(-> Attributes (List [Attributes Shape]) Image Image)
(all ..and
for
- (case (list#each (product.uncurried ..area) areas)
+ (when (list#each (product.uncurried ..area) areas)
{.#End}
(..empty "map" attributes)
@@ -348,7 +348,7 @@
[(def .public (<name> description attributes content)
(-> (Maybe Content) Attributes <type> <type>)
(..tag <container_tag> attributes
- (case description
+ (when description
{.#Some description}
(all ..and
(..tag <description_tag> (list) description)
@@ -462,7 +462,7 @@
(def .public (description_list attributes descriptions)
(-> Attributes (List [Content Element]) Element)
- (case (list#each (function (_ [term description])
+ (when (list#each (function (_ [term description])
(all ..and
(..term term)
(..description description)))
@@ -524,7 +524,7 @@
(def .public (table attributes caption columns headers rows footer)
(-> 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)
+ content (when (list#each table_row rows)
{.#End}
head
@@ -532,21 +532,21 @@
(..and head
(..table_body
(list#mix (function.flipped ..and) first rest))))
- content (case footer
+ content (when footer
{.#None}
content
{.#Some footer}
(..and content
(..table_foot (..table_row footer))))
- content (case columns
+ content (when columns
{.#None}
content
{.#Some columns}
(..and (..columns_group columns)
content))
- content (case caption
+ content (when caption
{.#None}
content
diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux
index 3dd15f400..a5b036478 100644
--- a/stdlib/source/library/lux/data/format/json.lux
+++ b/stdlib/source/library/lux/data/format/json.lux
@@ -62,7 +62,7 @@
(def .public null?
(Predicate JSON)
- (|>> (pipe.case {#Null} true
+ (|>> (pipe.when {#Null} true
_ false)))
(def .public object
@@ -98,7 +98,7 @@
(def (jsonF token)
(-> JSON' Code)
- (case token
+ (when token
{#Null' _}
(` {..#Null})
@@ -128,7 +128,7 @@
(def .public (fields json)
(-> JSON (Try (List String)))
- (case json
+ (when json
{#Object obj}
{try.#Success (dictionary.keys obj)}
@@ -137,9 +137,9 @@
(def .public (field key json)
(-> String JSON (Try JSON))
- (case json
+ (when json
{#Object obj}
- (case (dictionary.value key obj)
+ (when (dictionary.value key obj)
{.#Some value}
{try.#Success value}
@@ -151,7 +151,7 @@
(def .public (has key value json)
(-> String JSON JSON (Try JSON))
- (case json
+ (when json
{#Object obj}
{try.#Success {#Object (dictionary.has key value obj)}}
@@ -161,7 +161,7 @@
(with_template [<name> <tag> <type>]
[(def .public (<name> key json)
(-> Text JSON (Try <type>))
- (case (field key json)
+ (when (field key json)
{try.#Success {<tag> value}}
{try.#Success value}
@@ -182,7 +182,7 @@
(Equivalence JSON)
(implementation
(def (= x y)
- (case [x y]
+ (when [x y]
[{#Null} {#Null}]
true
@@ -209,7 +209,7 @@
(and (n.= (dictionary.size xs) (dictionary.size ys))
(list#mix (function (_ [xk xv] prev)
(and prev
- (case (dictionary.value xk ys)
+ (when (dictionary.value xk ys)
{.#None} false
{.#Some yv} (= xv yv))))
true
@@ -228,7 +228,7 @@
(def boolean_format
(-> Boolean Text)
- (|>> (pipe.case
+ (|>> (pipe.when
.false
"false"
@@ -237,7 +237,7 @@
(def number_format
(-> Number Text)
- (|>> (pipe.case
+ (|>> (pipe.when
+0.0 ... OR -0.0
"0.0"
@@ -294,7 +294,7 @@
(def .public (format json)
(-> JSON Text)
- (case json
+ (when json
(^.with_template [<tag> <format>]
[{<tag> value}
(<format> value)])
@@ -359,7 +359,7 @@
signed?' (<>.parses? (<text>.this "-"))
offset (<text>.many <text>.decimal)]
(in (all text#composite mark (if signed?' "-" "") offset))))]
- (case (f#decoded (all text#composite (if signed? "-" "") digits "." decimals exp))
+ (when (f#decoded (all text#composite (if signed? "-" "") digits "." decimals exp))
{try.#Failure message}
(<>.failure message)
diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux
index 4b8e1a4a2..f6faa4820 100644
--- a/stdlib/source/library/lux/data/format/markdown.lux
+++ b/stdlib/source/library/lux/data/format/markdown.lux
@@ -110,7 +110,7 @@
(|>> list.enumeration
(list#each (function (_ [idx [summary detail]])
(format "1. " (representation summary)
- (case detail
+ (when detail
{.#Some detail}
(|> detail
representation
@@ -128,7 +128,7 @@
(Markdown Block))
(|>> (list#each (function (_ [summary detail])
(format "* " (representation summary)
- (case detail
+ (when detail
{.#Some detail}
(|> detail
representation
diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux
index aad8579af..360ceeb11 100644
--- a/stdlib/source/library/lux/data/format/tar.lux
+++ b/stdlib/source/library/lux/data/format/tar.lux
@@ -236,16 +236,16 @@
(def (un_padded string)
(-> Binary Binary)
- (case (binary!.size string)
+ (when (binary!.size string)
0
string
size
(loop (again [end (-- size)])
- (case end
+ (when end
0 (at utf8.codec encoded "")
_ (let [last_char (binary!.bits_8 end string)]
- (`` (case (.nat last_char)
+ (`` (when (.nat last_char)
(char (,, (static ..null)))
(again (-- end))
@@ -434,7 +434,7 @@
(Parser Link_Flag)
(do <>.monad
[it <binary>.bits_8]
- (case (.nat it)
+ (when (.nat it)
(^.with_template [<value> <link_flag>]
[<value>
(in <link_flag>)])
@@ -597,7 +597,7 @@
(-> Big Nat)
(n.+ (n./ ..block_size
(..from_big size))
- (case (n.% ..block_size (..from_big size))
+ (when (n.% ..block_size (..from_big size))
0 0
_ 1)))
@@ -729,7 +729,7 @@
(def entry_format
(Format Entry)
- (|>> (pipe.case
+ (|>> (pipe.when
{#Normal value} (..normal_file_format value)
{#Symbolic_Link value} (..symbolic_link_format value)
{#Directory value} (..directory_format value)
diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux
index 3635c56f3..0978967f1 100644
--- a/stdlib/source/library/lux/data/format/xml.lux
+++ b/stdlib/source/library/lux/data/format/xml.lux
@@ -62,7 +62,7 @@
(<>.codec int.decimal)
<text>.slice
<text>.many!
- (case hex?
+ (when hex?
{.#None}
<text>.decimal!
@@ -95,7 +95,7 @@
(do <>.monad
[first_part xml_identifier
?second_part (<| <>.maybe (<>.after (<text>.this ..namespace_separator)) xml_identifier)]
- (case ?second_part
+ (when ?second_part
{.#None}
(in ["" first_part])
@@ -213,7 +213,7 @@
(def .public (tag [namespace name])
(-> Tag Text)
- (case namespace
+ (when namespace
"" name
_ (all text#composite namespace ..namespace_separator name)))
@@ -248,7 +248,7 @@
..xml_header text.new_line
(loop (again [prefix ""
input input])
- (case input
+ (when input
{#Text value}
(sanitize_value value)
@@ -282,7 +282,7 @@
(Equivalence XML)
(implementation
(def (= reference sample)
- (case [reference sample]
+ (when [reference sample]
[{#Text reference/value} {#Text sample/value}]
(text#= reference/value sample/value)
diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux
index 03e26b25d..0ed2931d1 100644
--- a/stdlib/source/library/lux/data/sum.lux
+++ b/stdlib/source/library/lux/data/sum.lux
@@ -19,7 +19,7 @@
(-> (-> a c) (-> b c)
(-> (Or a b) c)))
(function (_ input)
- (case input
+ (when input
{0 #0 l} (on_left l)
{0 #1 r} (on_right r))))
@@ -28,14 +28,14 @@
(-> (-> l l') (-> r r')
(-> (Or l r) (Or l' r'))))
(function (_ input)
- (case input
+ (when input
{0 #0 l} {0 #0 (on_left l)}
{0 #1 r} {0 #1 (on_right r)})))
(with_template [<name> <side> <right?>]
[(def .public (<name> items)
(All (_ a b) (-> (List (Or a b)) (List <side>)))
- (case items
+ (when items
{.#End}
{.#End}
@@ -51,13 +51,13 @@
(def .public (partition xs)
(All (_ a b) (-> (List (Or a b)) [(List a) (List b)]))
- (case xs
+ (when xs
{.#End}
[{.#End} {.#End}]
{.#Item x xs'}
(let [[lefts rights] (partition xs')]
- (case x
+ (when x
{0 #0 x'} [{.#Item x' lefts} rights]
{0 #1 x'} [lefts {.#Item x' rights}]))))
@@ -65,7 +65,7 @@
(All (_ l r) (-> (Equivalence l) (Equivalence r) (Equivalence (Or l r))))
(implementation
(def (= reference sample)
- (case [reference sample]
+ (when [reference sample]
[{.#Left reference} {.#Left sample}]
(at left = reference sample)
@@ -82,7 +82,7 @@
(..equivalence (at left equivalence)
(at right equivalence)))
(def (hash value)
- (.nat (case value
+ (.nat (when value
{.#Left value}
("lux i64 *" +2 (.int (at left hash value)))
diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux
index e9fa52957..8502d1d76 100644
--- a/stdlib/source/library/lux/data/text.lux
+++ b/stdlib/source/library/lux/data/text.lux
@@ -71,7 +71,7 @@
output (is (Maybe Nat)
{.#None})])
(let [output' ("lux text index" offset part text)]
- (case output'
+ (when output'
{.#None}
output
@@ -80,7 +80,7 @@
(def .public (starts_with? prefix x)
(-> Text Text Bit)
- (case (index prefix x)
+ (when (index prefix x)
{.#Some 0}
true
@@ -89,7 +89,7 @@
(def .public (ends_with? postfix x)
(-> Text Text Bit)
- (case (last_index postfix x)
+ (when (last_index postfix x)
{.#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)
+ (when ("lux text index" 0 sub text)
{.#Some _}
true
@@ -146,7 +146,7 @@
(def .public (split_at at x)
(-> Nat Text (Maybe [Text Text]))
- (case [(..clip 0 at x) (..clip_since at x)]
+ (when [(..clip 0 at x) (..clip_since at x)]
[{.#Some pre} {.#Some post}]
{.#Some [pre post]}
@@ -165,7 +165,7 @@
(-> Text Text (List Text))
(loop (again [input sample
output (is (List Text) (list))])
- (case (..split_by token input)
+ (when (..split_by token input)
{.#Some [pre post]}
(|> output
{.#Item pre}
@@ -185,9 +185,9 @@
(for @.js (these (def defined?
(macro (_ tokens lux)
- (case tokens
+ (when tokens
(list it)
- {.#Right [lux (list (` (.case ("js type-of" ("js constant" (, it)))
+ {.#Right [lux (list (` (.when ("js type-of" ("js constant" (, it)))
"undefined"
.false
@@ -198,7 +198,7 @@
{.#Left ""})))
(def if_nashorn
(macro (_ tokens lux)
- (case tokens
+ (when tokens
(list then else)
{.#Right [lux (list (if (and (..defined? "java")
(..defined? "java.lang")
@@ -215,7 +215,7 @@
(with_expansions [... Inefficient default
<default> (loop (again [left ""
right template])
- (case (..split_by pattern right)
+ (when (..split_by pattern right)
{.#Some [pre post]}
(again (all "lux text concat" left pre replacement) post)
@@ -320,13 +320,13 @@
(def .public (interposed separator texts)
(-> Text (List Text) Text)
- (case separator
+ (when separator
"" (..together texts)
_ (|> texts (list.interposed separator) ..together)))
(def .public (empty? text)
(-> Text Bit)
- (case text
+ (when text
"" true
_ false))
@@ -347,7 +347,7 @@
[..carriage_return]
[..form_feed]
)]
- (`` (case char
+ (`` (when char
<options>
_
diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux
index 85f038d05..2ce6021a6 100644
--- a/stdlib/source/library/lux/data/text/escape.lux
+++ b/stdlib/source/library/lux/data/text/escape.lux
@@ -72,7 +72,7 @@
(-> Char Bit)
(or (n.< ..ascii_bottom char)
(n.> ..ascii_top char)
- (case char
+ (when char
(^.with_template [<char>]
[<char>
true])
@@ -97,7 +97,7 @@
(-> Char Nat Nat Text Text [Text Text Nat])
(let [code (at n.hex encoded char)
replacement (format ..sigil "u"
- (case ("lux text size" code)
+ (when ("lux text size" code)
1 (format "000" code)
2 (format "00" code)
3 (format "0" code)
@@ -117,7 +117,7 @@
current text
limit ("lux text size" text)])
(if (n.< limit offset)
- (case ("lux text char" offset current)
+ (when ("lux text char" offset current)
(^.with_template [<char> <replacement>]
[<char>
(let [[previous' current' limit'] (ascii_escaped <replacement> offset limit previous current)]
@@ -180,7 +180,7 @@
(def (unicode_un_escaped offset previous current limit)
(-> Nat Text Text Nat (Try [Text Text Nat]))
- (case (|> current
+ (when (|> current
("lux text clip" (n.+ ..ascii_escape_offset offset) ..code_size)
(at n.hex decoded))
{try.#Success char}
@@ -201,11 +201,11 @@
current text
limit ("lux text size" text)])
(if (n.< limit offset)
- (case ("lux text char" offset current)
+ (when ("lux text char" offset current)
..sigil_char
(let [@sigil (++ offset)]
(if (n.< limit @sigil)
- (case ("lux text char" @sigil current)
+ (when ("lux text char" @sigil current)
(^.with_template [<sigil> <un_escaped>]
[<sigil>
(let [[previous' current' limit'] (..ascii_un_escaped <un_escaped> offset previous current limit)]
@@ -235,13 +235,13 @@
_
(again (++ offset) previous current limit))
- {try.#Success (case previous
+ {try.#Success (when previous
"" current
_ (format previous current))})))
(def .public literal
(syntax (_ [literal <code>.text])
- (case (..un_escaped literal)
+ (when (..un_escaped literal)
{try.#Success un_escaped}
(in (list (code.text un_escaped)))
diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux
index d8d094f6e..09dba9073 100644
--- a/stdlib/source/library/lux/data/text/regex.lux
+++ b/stdlib/source/library/lux/data/text/regex.lux
@@ -111,7 +111,7 @@
parts (<>.many (all <>.either
re_range^
re_options^))]
- (in (case negate?
+ (in (when negate?
{.#Some _} (` (<text>.not (all <>.either (,* parts))))
{.#None} (` (all <>.either (,* parts)))))))
@@ -219,7 +219,7 @@
(do <>.monad
[base (re_simple^ current_module)
quantifier (<text>.one_of "?*+")]
- (case quantifier
+ (when quantifier
"?"
(in (` (<>.else "" (, base))))
@@ -290,7 +290,7 @@
[Nat (List Code) (List (List Code))]
[Nat (List Code) (List (List Code))])
(function (_ part [idx names steps])
- (case part
+ (when part
(^.or {.#Left complex}
{.#Right [{#Non_Capturing} complex]})
[idx
@@ -300,7 +300,7 @@
steps)]
{.#Right [{#Capturing [?name num_captures]} scoped]}
- (let [[idx! name!] (case ?name
+ (let [[idx! name!] (when ?name
{.#Some _name}
[idx (code.symbol ["" _name])]
@@ -335,12 +335,12 @@
(def .public (or left right)
(All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser [Text (Or l r)])))
(function (_ input)
- (case (left input)
+ (when (left input)
{try.#Success [input' [lt lv]]}
{try.#Success [input' [lt {0 #0 lv}]]}
{try.#Failure _}
- (case (right input)
+ (when (right input)
{try.#Success [input' [rt rv]]}
{try.#Success [input' [rt {0 #1 rv}]]}
@@ -350,12 +350,12 @@
(def .public (either left right)
(All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser Text)))
(function (_ input)
- (case (left input)
+ (when (left input)
{try.#Success [input' [lt lv]]}
{try.#Success [input' lt]}
{try.#Failure _}
- (case (right input)
+ (when (right input)
{try.#Success [input' [rt rv]]}
{try.#Success [input' rt]}
@@ -418,7 +418,7 @@
(syntax (_ [pattern <code>.text])
(do meta.monad
[current_module meta.current_module_name]
- (case (<text>.result (regex^ current_module)
+ (when (<text>.result (regex^ current_module)
pattern)
{try.#Failure error}
(meta.failure (format "Error while parsing regular-expression:" //.new_line
diff --git a/stdlib/source/library/lux/data/text/unicode/set.lux b/stdlib/source/library/lux/data/text/unicode/set.lux
index 13c5d4f47..771fb287f 100644
--- a/stdlib/source/library/lux/data/text/unicode/set.lux
+++ b/stdlib/source/library/lux/data/text/unicode/set.lux
@@ -217,7 +217,7 @@
(-> Set Char Bit)
(loop (again [tree (representation set)])
(if (//block.within? (tree.tag tree) character)
- (case (tree.root tree)
+ (when (tree.root tree)
{0 #0 _}
true