diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-18 18:44:04 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-18 18:44:04 +0100 |
commit | f91c0bf56ba1ed979266d4e32937dcab48d7030e (patch) | |
tree | dbd16aa51e107c02d5efa741a415382ff66d1e91 | |
parent | Compleately redid file structure. (diff) | |
download | scheme-monad-f91c0bf56ba1ed979266d4e32937dcab48d7030e.tar.gz scheme-monad-f91c0bf56ba1ed979266d4e32937dcab48d7030e.tar.xz |
Add equal? instance to <optional>.
-rw-r--r-- | monad/optional.scm | 7 |
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)))))) |