aboutsummaryrefslogtreecommitdiff
path: root/source/lux/data/maybe.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/lux/data/maybe.lux20
1 files changed, 17 insertions, 3 deletions
diff --git a/source/lux/data/maybe.lux b/source/lux/data/maybe.lux
index faec53c2e..396ec470a 100644
--- a/source/lux/data/maybe.lux
+++ b/source/lux/data/maybe.lux
@@ -7,9 +7,12 @@
## You must not remove this notice, or any other, from this software.
(;import lux
- (lux/control (monoid #as m #refer #all)
- (functor #as F #refer #all)
- (monad #as M #refer #all)))
+ (.. list)
+ (lux (control (monoid #as m #refer #all)
+ (functor #as F #refer #all)
+ (monad #as M #refer #all))
+ (meta lux
+ syntax)))
## [Types]
## (deftype (Maybe a)
@@ -40,3 +43,14 @@
(case mma
#;None #;None
(#;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)))))))