aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/meta.lux')
-rw-r--r--stdlib/source/library/lux/meta.lux74
1 files changed, 37 insertions, 37 deletions
diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux
index c2123fa99..5cb1d3894 100644
--- a/stdlib/source/library/lux/meta.lux
+++ b/stdlib/source/library/lux/meta.lux
@@ -31,7 +31,7 @@
(implementation
(def (each f fa)
(function (_ lux)
- (case (fa lux)
+ (when (fa lux)
{try.#Success [lux' a]}
{try.#Success [lux' (f a)]}
@@ -45,9 +45,9 @@
(def (on fa ff)
(function (_ lux)
- (case (ff lux)
+ (when (ff lux)
{try.#Success [lux' f]}
- (case (fa lux')
+ (when (fa lux')
{try.#Success [lux'' a]}
{try.#Success [lux'' (f a)]}
@@ -68,7 +68,7 @@
(def (conjoint mma)
(function (_ lux)
- (case (mma lux)
+ (when (mma lux)
{try.#Success [lux' ma]}
(ma lux')
@@ -81,7 +81,7 @@
(def .public (result lux action)
(All (_ a) (-> Lux (Meta a) (Try a)))
- (case (action lux)
+ (when (action lux)
{try.#Success [_ output]}
{try.#Success output}
@@ -91,7 +91,7 @@
(def .public (either left right)
(All (_ a) (-> (Meta a) (Meta a) (Meta a)))
(function (_ lux)
- (case (left lux)
+ (when (left lux)
{try.#Success [lux' output]}
{try.#Success [lux' output]}
@@ -114,7 +114,7 @@
(def .public (module name)
(-> Text (Meta Module))
(function (_ lux)
- (case (property.value name (the .#modules lux))
+ (when (property.value name (the .#modules lux))
{.#Some module}
{try.#Success [lux module]}
@@ -124,7 +124,7 @@
(def .public current_module_name
(Meta Text)
(function (_ lux)
- (case (the .#current_module lux)
+ (when (the .#current_module lux)
{.#Some current_module}
{try.#Success [lux current_module]}
@@ -140,7 +140,7 @@
(def (macro_type? type)
(-> Type Bit)
- (case type
+ (when type
{.#Named [.prelude "Macro"]
{.#Primitive "#Macro" {.#End}}}
true
@@ -150,7 +150,7 @@
(def .public (normal name)
(-> Symbol (Meta Symbol))
- (case name
+ (when name
["" name]
(do ..monad
[module_name ..current_module_name]
@@ -166,7 +166,7 @@
(is (Meta (Maybe Macro))
(function (_ lux)
{try.#Success [lux
- (case (..current_module_name lux)
+ (when (..current_module_name lux)
{try.#Success [_ this_module]}
(let [modules (the .#modules lux)]
(loop (again [module module
@@ -178,7 +178,7 @@
(is Module)
(the .#definitions)
(property.value name)))]
- (case definition
+ (when definition
{.#Alias [r_module r_name]}
(again r_module r_name)
@@ -208,7 +208,7 @@
(def .public (module_exists? module)
(-> Text (Meta Bit))
(function (_ lux)
- {try.#Success [lux (case (property.value module (the .#modules lux))
+ {try.#Success [lux (when (property.value module (the .#modules lux))
{.#Some _}
true
@@ -218,13 +218,13 @@
(def (on_either f x1 x2)
(All (_ a b)
(-> (-> a (Maybe b)) a a (Maybe b)))
- (case (f x1)
+ (when (f x1)
{.#None} (f x2)
{.#Some y} {.#Some y}))
(def (type_variable idx bindings)
(-> Nat (List [Nat (Maybe Type)]) (Maybe Type))
- (case bindings
+ (when bindings
{.#End}
{.#None}
@@ -235,10 +235,10 @@
(`` (def (clean_type type)
(-> Type (Meta Type))
- (case type
+ (when type
{.#Var var}
(function (_ lux)
- (case (|> lux
+ (when (|> lux
(the [.#type_context .#var_bindings])
(type_variable var))
(,, (with_template [<pattern>]
@@ -260,7 +260,7 @@
(function (_ lux)
(let [test (is (-> [Text [Type Any]] Bit)
(|>> product.left (text#= name)))]
- (case (do maybe.monad
+ (when (do maybe.monad
[scope (list.example (function (_ env)
(or (list.any? test (is (List [Text [Type Any]])
(the [.#locals .#mappings] env)))
@@ -301,7 +301,7 @@
[name (..normal name)
.let [[normal_module normal_short] name]]
(function (_ lux)
- (case (is (Maybe Global)
+ (when (is (Maybe Global)
(do maybe.monad
[(open "[0]") (|> lux
(the .#modules)
@@ -319,7 +319,7 @@
{try.#Failure (all text#composite
"Unknown definition: " (symbol#encoded name) text.new_line
" Current module: " current_module text.new_line
- (case (property.value current_module (the .#modules lux))
+ (when (property.value current_module (the .#modules lux))
{.#Some this_module}
(let [candidates (|> lux
(the .#modules)
@@ -327,7 +327,7 @@
(|> module
(the .#definitions)
(list.all (function (_ [def_name global])
- (`` (case global
+ (`` (when global
(,, (with_template [<pattern>]
[<pattern>
(if (and exported?
@@ -370,7 +370,7 @@
(-> Symbol (Meta Definition))
(do ..monad
[definition (..definition name)]
- (case definition
+ (when definition
{.#Definition definition}
(let [[exported? def_type def_value] definition]
(if exported?
@@ -401,7 +401,7 @@
(-> Symbol (Meta Type))
(do ..monad
[definition (definition name)]
- (case definition
+ (when definition
{.#Alias de_aliased}
(definition_type de_aliased)
@@ -423,7 +423,7 @@
(def .public (type name)
(-> Symbol (Meta Type))
- (case name
+ (when name
["" _name]
(either (var_type _name)
(definition_type name))
@@ -435,7 +435,7 @@
(-> Symbol (Meta Type))
(do ..monad
[definition (definition name)]
- (case definition
+ (when definition
{.#Alias de_aliased}
(type_definition de_aliased)
@@ -460,7 +460,7 @@
(def .public (globals module)
(-> Text (Meta (List [Text Global])))
(function (_ lux)
- (case (property.value module (the .#modules lux))
+ (when (property.value module (the .#modules lux))
{.#Some module}
{try.#Success [lux (the .#definitions module)]}
@@ -471,7 +471,7 @@
(-> Text (Meta (List [Text Definition])))
(at ..monad each
(list.all (function (_ [name global])
- (case global
+ (when global
{.#Alias de_aliased}
{.#None}
@@ -511,9 +511,9 @@
(do ..monad
[.let [[module_name name] type_name]
module (..module module_name)]
- (case (property.value name (the .#definitions module))
+ (when (property.value name (the .#definitions module))
{.#Some {.#Type [exported? type labels]}}
- (case labels
+ (when labels
(,, (with_template [<pattern>]
[<pattern>
(in {.#Some (list#each (|>> [module_name])
@@ -533,7 +533,7 @@
(def .public expected_type
(Meta Type)
(function (_ lux)
- (case (the .#expected lux)
+ (when (the .#expected lux)
{.#Some type}
{try.#Success [lux type]}
@@ -565,7 +565,7 @@
[.let [[module name] label_name]
=module (..module module)
this_module_name ..current_module_name]
- (case (property.value name (the .#definitions =module))
+ (when (property.value name (the .#definitions =module))
{.#Some {<tag> [exported? type group idx]}}
(if (or (text#= this_module_name module)
exported?)
@@ -586,12 +586,12 @@
[=module (..module module)
this_module_name ..current_module_name]
(in (list.all (function (_ [short global])
- (case global
+ (when global
{.#Type [exported? type labels]}
(if (or exported?
(text#= this_module_name module))
{.#Some [(list#each (|>> [module])
- (case labels
+ (when labels
{.#Left tags}
{.#Item tags}
@@ -607,7 +607,7 @@
(def .public locals
(Meta (List (List [Text Type])))
(function (_ lux)
- (case (list.inits (the .#scopes lux))
+ (when (list.inits (the .#scopes lux))
{.#Some scopes}
{try.#Success [lux
(list#each (|>> (the [.#locals .#mappings])
@@ -622,7 +622,7 @@
(-> Symbol (Meta Symbol))
(do ..monad
[constant (..definition def_name)]
- (in (case constant
+ (in (when constant
{.#Alias real_def_name}
real_def_name
@@ -650,7 +650,7 @@
(def .public (lifted result)
(All (_ a) (-> (Try a) (Meta a)))
- (case result
+ (when result
{try.#Success output}
(at ..monad in output)
@@ -667,7 +667,7 @@
(def .public (try computation)
(All (_ it) (-> (Meta it) (Meta (Try it))))
(function (_ lux)
- (case (computation lux)
+ (when (computation lux)
{try.#Success [lux' output]}
{try.#Success [lux' {try.#Success output}]}