aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/optional.scm9
1 files changed, 7 insertions, 2 deletions
diff --git a/data/optional.scm b/data/optional.scm
index b008471..c90fec5 100644
--- a/data/optional.scm
+++ b/data/optional.scm
@@ -2,11 +2,11 @@
#:use-module (oop goops)
#:use-module (ice-9 match)
#:use-module (control monad)
+ #:use-module (data functor)
#:export (nothing just
nothing? just?
return-optional)
- ;; TODO is this reexport needed?
- #:re-export (>>=))
+ #:re-export (>>= >> fmap))
(define-class <optional> ()
(slot #:init-value #f
@@ -47,3 +47,8 @@
(nothing? b))
(nothing)
b))
+
+(define-method (fmap (f <procedure>)
+ (m <optional>))
+ (do x <- m
+ (return-optional (f x))))