aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-03-18 18:44:04 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-03-18 18:44:04 +0100
commitf91c0bf56ba1ed979266d4e32937dcab48d7030e (patch)
treedbd16aa51e107c02d5efa741a415382ff66d1e91
parentCompleately redid file structure. (diff)
downloadscheme-monad-f91c0bf56ba1ed979266d4e32937dcab48d7030e.tar.gz
scheme-monad-f91c0bf56ba1ed979266d4e32937dcab48d7030e.tar.xz
Add equal? instance to <optional>.
-rw-r--r--monad/optional.scm7
1 files changed, 7 insertions, 0 deletions
diff --git a/monad/optional.scm b/monad/optional.scm
index 1aa1e92..015fc90 100644
--- a/monad/optional.scm
+++ b/monad/optional.scm
@@ -51,3 +51,10 @@ the value embedded in maybe-val"
(($ <optional> slot) (proc slot))))))
(define-method (return (a <optional>)) just)
+
+(define-method (equal? (a <optional>)
+ (b <optional>))
+ (or (and (nothing? a) (nothing? b))
+ (from-just #f (do aa <- a
+ bb <- b
+ (just (equal? aa bb))))))