diff options
author | Arun Isaac | 2025-01-09 23:42:47 +0000 |
---|---|---|
committer | Arun Isaac | 2025-01-19 16:44:26 +0000 |
commit | 454a5266124416aa0a91881612b9513666c18b2f (patch) | |
tree | c471bbf00263f0f732dbd5aa975ac154f2999fec | |
parent | f0ab91f0898dd39c0fe43d25c2fffbb6ff6dae69 (diff) | |
download | ravanan-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.scm | 10 |
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? |