aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2025-01-09 23:42:47 +0000
committerArun Isaac2025-01-19 16:44:26 +0000
commit454a5266124416aa0a91881612b9513666c18b2f (patch)
treec471bbf00263f0f732dbd5aa975ac154f2999fec
parentf0ab91f0898dd39c0fe43d25c2fffbb6ff6dae69 (diff)
downloadravanan-454a5266124416aa0a91881612b9513666c18b2f.tar.gz
ravanan-454a5266124416aa0a91881612b9513666c18b2f.tar.lz
ravanan-454a5266124416aa0a91881612b9513666c18b2f.zip
monads: Add mbegin.
* ravanan/work/monads.scm (mbegin): New macro.
-rw-r--r--ravanan/work/monads.scm10
1 files changed, 10 insertions, 0 deletions
diff --git a/ravanan/work/monads.scm b/ravanan/work/monads.scm
index fa08bd2..6d55449 100644
--- a/ravanan/work/monads.scm
+++ b/ravanan/work/monads.scm
@@ -53,6 +53,16 @@
(mlet* monad-type (bindings ...)
body ...))))))
+(define-syntax mbegin
+ (syntax-rules ()
+ ((_ monad-type expression)
+ expression)
+ ((_ monad-type first-expression body ...)
+ ((monad-bind monad-type)
+ first-expression
+ (lambda _
+ body ...)))))
+
(define-immutable-record-type <maybe>
(maybe value valid?)
maybe?