diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-18 18:45:56 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-18 18:45:56 +0100 |
commit | bd03b21c4823a17fe031b4e61aea7a123ca91d75 (patch) | |
tree | bab1449fa05c0bc67dc28599e36d6da7323be5cd /examples/do.scm | |
parent | Remove state-minimal. (diff) | |
download | scheme-monad-bd03b21c4823a17fe031b4e61aea7a123ca91d75.tar.gz scheme-monad-bd03b21c4823a17fe031b4e61aea7a123ca91d75.tar.xz |
Remove entire examples directory.
Diffstat (limited to '')
-rw-r--r-- | examples/do.scm | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/examples/do.scm b/examples/do.scm deleted file mode 100644 index d758177..0000000 --- a/examples/do.scm +++ /dev/null @@ -1,41 +0,0 @@ -(add-to-load-path (dirname (current-filename))) - -(use-modules (control monad) - (data monoid) - (data optional) - (data writer)) - -;;; Optional Monad, and do notation - -(do x <- (just 10) - x) ; => 10 - -(do let y = (just 10) - x <- y - (+ x 5)) ; => 15 - -(do x <- (nothing) - (+ x 5)) ; => [Nothing] - -(do x <- (just 10) - y <- (just 20) - (+ x y)) ; => 30 - -(do (just 10) - (nothing) - (just 20)) ; => [Nothing] - -;;; Writer Monad, and do notation - -;; Int -> Writer Int String -(define (log-number n) - (writer n (format #f "Got nuber: ~a" n))) - -(do a <- (log-number 3) - b <- (log-number 5) - (writer (* a b) "")) -;; => [Writer 15, "Got nuber: 3Got nuber: 5"] - -(do (log-number 3) - (log-number 5)) -;; => [Writer 5, "Got nuber: 3Got nuber: 5"] |