diff options
author | Eduardo Julian | 2022-08-11 04:15:07 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-08-11 04:15:07 -0400 |
commit | 065e8a4d8122d4616b570496915d2c0e2c78cd6b (patch) | |
tree | f2bbdc3e40b796b34026ab04c9a478d8a3f082d5 /stdlib/source/library/lux/meta/macro/pattern.lux | |
parent | 68d78235694c633c956bb9e8a007cad7d65370bc (diff) |
Re-named the "case" macro to "when".
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/meta/macro/pattern.lux | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/stdlib/source/library/lux/meta/macro/pattern.lux b/stdlib/source/library/lux/meta/macro/pattern.lux index b639259ba..f4f352efc 100644 --- a/stdlib/source/library/lux/meta/macro/pattern.lux +++ b/stdlib/source/library/lux/meta/macro/pattern.lux @@ -19,7 +19,7 @@ (def locally (macro (_ tokens lux) (.let [[prelude _] (symbol ._)] - (case tokens + (when tokens (list [@ {.#Symbol ["" name]}]) {.#Right [lux (list (.` ("lux in-module" (., [@ {.#Text prelude}]) (., [@ {.#Symbol [prelude name]}]))))]} @@ -68,9 +68,9 @@ (def .public or (pattern (macro (_ tokens) - (case tokens + (when tokens (list.partial [_ {.#Form patterns}] body branches) - (case patterns + (when patterns {.#End} (///.failure (..wrong_syntax_error (symbol ..or))) @@ -85,12 +85,12 @@ (def .public with_template (pattern (macro (_ tokens) - (case tokens + (when tokens (list.partial [_ {.#Form (list [_ {.#Tuple bindings}] [_ {.#Tuple templates}])}] [_ {.#Form data}] branches) - (case (is (Maybe (List Code)) + (when (is (Maybe (List Code)) (do maybe.monad [bindings' (monad.each maybe.monad symbol_short bindings) data' (monad.each maybe.monad tuple_list data)] @@ -118,7 +118,7 @@ (def (level it) (-> Code (Meta Level)) - (///#in (case it + (///#in (when it [_ {.#Tuple (list expr binding)}] [expr binding] @@ -130,7 +130,7 @@ (def (multiP levels) (-> (List Code) (Meta Multi)) - (case levels + (when levels {.#End} (///.failure "Multi-level patterns cannot be empty.") @@ -142,13 +142,13 @@ (def (multiG g!_ [[init_pattern levels] body]) (-> Code [Multi Code] (List Code)) (.let [inner_pattern_body (list#mix (function (_ [calculation pattern] success) - (.let [bind? (case pattern + (.let [bind? (when pattern [_ {.#Symbol _}] true _ false)] - (.` (case (., calculation) + (.` (when (., calculation) (., pattern) (., success) @@ -162,12 +162,12 @@ (def .public multi (pattern (macro (_ tokens) - (case tokens + (when tokens (list.partial [_meta {.#Form levels}] body next_branches) (with_symbols [g!temp] (do ///.monad [mlc (multiP levels) - .let [initial_bind? (case mlc + .let [initial_bind? (when mlc [[_ {.#Symbol _}] _] true @@ -179,10 +179,10 @@ (., g!temp) {.#None} - (.case (., g!temp) + (.when (., g!temp) (.,* next_branches))} ("lux type check" {.#Apply (., (type_code expected)) Maybe} - (.case (., g!temp) + (.when (., g!temp) (.,* (multiG g!temp [mlc body])) (.,* (if initial_bind? @@ -195,11 +195,11 @@ (def .public let (pattern (macro (_ tokens) - (case tokens + (when tokens (list.partial [_meta {.#Form (list [_ {.#Symbol ["" name]}] pattern)}] body branches) (.let [g!whole (local$ name)] (///#in (list.partial g!whole - (.` (case (., g!whole) (., pattern) (., body))) + (.` (when (., g!whole) (., pattern) (., body))) branches))) _ @@ -208,7 +208,7 @@ (def .public |> (pattern (macro (_ tokens) - (case tokens + (when tokens (list.partial [_meta {.#Form (list [_ {.#Symbol ["" name]}] [_ {.#Tuple steps}])}] body branches) (.let [g!name (local$ name)] (///#in (list.partial g!name @@ -225,7 +225,7 @@ (def (untemplated_partial_list last inits) (-> Code (List Code) Code) - (case inits + (when inits {.#End} last @@ -244,12 +244,12 @@ (with_expansions [<default> (do ///.monad [=elems (monad.each ///.monad untemplated_pattern elems)] (in (.` [(., g!meta) {(., <tag>) (., (untemplated_list =elems))}])))] - (case (list.reversed elems) + (when (list.reversed elems) {.#Item [_ {.#Form {.#Item [_ {.#Symbol global}] parameters}}] inits} (do ///.monad [micro (///.try (..named_spliced_unquote global))] - (case micro + (when micro {try.#Success micro} (do ///.monad [output (..one_expansion ((//.function micro) parameters)) @@ -281,7 +281,7 @@ (def (untemplated_pattern pattern) (-> Code (Meta Code)) (with_symbols [g!meta] - (case pattern + (when pattern (..with_template [<tag> <gen>] [[_ {<tag> value}] (///#in (.` [(., g!meta) {<tag> (., (<gen> value))}]))]) @@ -296,7 +296,7 @@ [@composite {.#Form {.#Item [@global {.#Symbol global}] parameters}}] (do [! ///.monad] [micro (///.try (..named_unquote global))] - (case micro + (when micro {try.#Success micro} (do ! [[_ output] (..one_expansion ((//.function micro) parameters))] @@ -316,7 +316,7 @@ (def .public ` (pattern (macro (_ tokens) - (case tokens + (when tokens (list.partial [_meta {.#Form (list template)}] body branches) (do ///.monad [pattern (untemplated_pattern template)] |