aboutsummaryrefslogtreecommitdiff
path: root/source/lux
diff options
context:
space:
mode:
Diffstat (limited to 'source/lux')
-rw-r--r--source/lux/control/comonad.lux8
-rw-r--r--source/lux/data/maybe.lux21
2 files changed, 10 insertions, 19 deletions
diff --git a/source/lux/control/comonad.lux b/source/lux/control/comonad.lux
index 052b8768d..8e12c24c0 100644
--- a/source/lux/control/comonad.lux
+++ b/source/lux/control/comonad.lux
@@ -29,7 +29,7 @@
## [Syntax]
(defmacro #export (be tokens state)
(case tokens
- (\ (list monad [_ (#;TupleS bindings)] body))
+ (\ (@list comonad [_ (#;TupleS bindings)] body))
(let [body' (foldL (: (-> AST (, AST AST) AST)
(lambda [body' binding]
(let [[var value] binding]
@@ -42,9 +42,9 @@
(~ value)))))))
body
(reverse (as-pairs bindings)))]
- (#;Right [state (list (` (;case (~ monad)
- {#;return ;return #;bind ;bind}
- (~ body'))))]))
+ (#;Right [state (@list (` (;case (~ comonad)
+ {#;return ;return #;bind ;bind}
+ (~ body'))))]))
_
(#;Left "Wrong syntax for be")))
diff --git a/source/lux/data/maybe.lux b/source/lux/data/maybe.lux
index 77dbec5b1..7c0affd68 100644
--- a/source/lux/data/maybe.lux
+++ b/source/lux/data/maybe.lux
@@ -41,18 +41,9 @@
#;None #;None
(#;Some xs) xs)))
-## [Syntax]
-(defmacro #export (? tokens state)
- (case tokens
- (\ (list maybe else))
- (let [g!value (symbol$ ["" "_"])
- g!_ (symbol$ ["" "12_34"])]
- (#;Right state (list (` (case (~ maybe)
- (#;Some (~ g!value))
- (~ g!value)
-
- (~ g!_)
- (~ else))))))
-
- _
- (#;Left "Wrong syntax for ?")))
+## [Functions]
+(def #export (? else maybe)
+ (All [a] (-> a (Maybe a) a))
+ (case maybe
+ (#;Some x) x
+ _ else))