From 454a5266124416aa0a91881612b9513666c18b2f Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 9 Jan 2025 23:42:47 +0000 Subject: monads: Add mbegin. * ravanan/work/monads.scm (mbegin): New macro. --- ravanan/work/monads.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 value valid?) maybe? -- cgit v1.2.3