diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2018-11-10 23:57:53 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@hornquist.se> | 2018-11-10 23:57:53 +0100 |
commit | d86d88b96cd7aba976ab58b909fd4eae48323bb0 (patch) | |
tree | 0c7f93144cbe8c93a5a7c838165bd0e8a0cf24b0 /data | |
parent | Add README. (diff) | |
download | scheme-monad-d86d88b96cd7aba976ab58b909fd4eae48323bb0.tar.gz scheme-monad-d86d88b96cd7aba976ab58b909fd4eae48323bb0.tar.xz |
Add >>, fix do to use it.
Diffstat (limited to 'data')
-rw-r--r-- | data/optional.scm | 7 | ||||
-rw-r--r-- | data/writer.scm | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/data/optional.scm b/data/optional.scm index e71c10d..b008471 100644 --- a/data/optional.scm +++ b/data/optional.scm @@ -40,3 +40,10 @@ ((just? this) (match this (($ <optional> slot) (proc slot)))))) + +(define-method (>> (a <optional>) + (b <optional>)) + (if (or (nothing? a) + (nothing? b)) + (nothing) + b)) diff --git a/data/writer.scm b/data/writer.scm index 462d391..93f3798 100644 --- a/data/writer.scm +++ b/data/writer.scm @@ -21,7 +21,14 @@ (match this (($ <writer> value monoid) (match (proc value) (($ <writer> nval ncontext) - (writer nval { monoid <> ", " <> ncontext })))))) + (writer nval { monoid <> ncontext })))))) + +(define-method (>> (a <writer>) + (b <writer>)) + (match a (($ <writer> _ monoid-a) + (match b (($ <writer> val monoid-b) + (writer val (<> monoid-a monoid-b)) + ))))) (define (return-writer val) (writer val "")) |