aboutsummaryrefslogtreecommitdiff
path: root/source/lux/data/maybe.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/lux/data/maybe.lux31
1 files changed, 17 insertions, 14 deletions
diff --git a/source/lux/data/maybe.lux b/source/lux/data/maybe.lux
index 396ec470a..a6019e256 100644
--- a/source/lux/data/maybe.lux
+++ b/source/lux/data/maybe.lux
@@ -7,12 +7,11 @@
## You must not remove this notice, or any other, from this software.
(;import lux
- (.. list)
- (lux (control (monoid #as m #refer #all)
+ (lux (meta macro)
+ (control (monoid #as m #refer #all)
(functor #as F #refer #all)
- (monad #as M #refer #all))
- (meta lux
- syntax)))
+ (monad #as M #refer #all)))
+ (.. list))
## [Types]
## (deftype (Maybe a)
@@ -45,12 +44,16 @@
(#;Some xs) xs)))
## [Syntax]
-(defsyntax #export (? maybe else)
- (do Lux/Monad
- [g!value (gensym "")]
- (M;wrap (list (` (case (~ maybe)
- (#;Some (~ g!value))
- (~ g!value)
-
- _
- (~ else)))))))
+(defmacro #export (? tokens state)
+ (case tokens
+ (\ (list maybe else))
+ (let [g!value (symbol$ ["" "_"])]
+ (#;Right state (list (` (case (~ maybe)
+ (#;Some (~ g!value))
+ (~ g!value)
+
+ _
+ (~ else))))))
+
+ _
+ (#;Left "Wrong syntax for ?")))