diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2018-11-16 00:05:56 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2018-11-16 00:05:56 +0100 |
commit | 34569bd7811b553c93c4351dbd117b1548f17ca7 (patch) | |
tree | 4d8ca40ae1d973da728aefebcc81da629e89daf7 | |
parent | Add curried map (cmap) to (data functor). (diff) | |
download | scheme-monad-34569bd7811b553c93c4351dbd117b1548f17ca7.tar.gz scheme-monad-34569bd7811b553c93c4351dbd117b1548f17ca7.tar.xz |
Made do notation support pattern matching.
-rw-r--r-- | control/monad.scm | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/control/monad.scm b/control/monad.scm index f51289d..2ef230c 100644 --- a/control/monad.scm +++ b/control/monad.scm @@ -1,14 +1,16 @@ (define-module (control monad) #:use-module (control monad procedures) + #:use-module (ice-9 match) #:export (do) #:re-export (>> >>=)) (define-syntax do (syntax-rules (<- let =) - ((_ let var = val rest ...) - (let ((var val)) (do rest ...))) - ((_ var <- val rest ...) - (>>= val (lambda (var) (do rest ...)))) + ((_ let ptrn = val rest ...) + (match val + (ptrn (do rest ...)))) + ((_ ptrn <- val rest ...) + (>>= val (match-lambda (ptrn (do rest ...))))) ((_ a) a) ((_ token rest ...) (>> token (do rest ...))))) |