aboutsummaryrefslogtreecommitdiff
path: root/examples.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2018-11-10 23:57:53 +0100
committerHugo Hörnquist <hugo@hornquist.se>2018-11-10 23:57:53 +0100
commitd86d88b96cd7aba976ab58b909fd4eae48323bb0 (patch)
tree0c7f93144cbe8c93a5a7c838165bd0e8a0cf24b0 /examples.scm
parentAdd README. (diff)
downloadscheme-monad-d86d88b96cd7aba976ab58b909fd4eae48323bb0.tar.gz
scheme-monad-d86d88b96cd7aba976ab58b909fd4eae48323bb0.tar.xz
Add >>, fix do to use it.
Diffstat (limited to 'examples.scm')
-rw-r--r--examples.scm8
1 files changed, 8 insertions, 0 deletions
diff --git a/examples.scm b/examples.scm
index 1fd453c..7eed583 100644
--- a/examples.scm
+++ b/examples.scm
@@ -21,6 +21,10 @@
y <- (just 20)
(+ x y)) ; => 30
+(do (just 10)
+ (nothing)
+ (just 20)) ; => [Nothing]
+
;;; Writer Monad, and do notation
;; Int -> Writer Int String
@@ -31,3 +35,7 @@
b <- (log-number 5)
(writer (* a b) ""))
;; => [Writer 15, "Got nuber: 3, Got nuber: 5, "]
+
+(do (log-number 3)
+ (log-number 5))
+;; => [Writer 5, "Got nuber: 3Got nuber: 5"]