diff options
-rw-r--r-- | ravanan/work/monads.scm | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ravanan/work/monads.scm b/ravanan/work/monads.scm index 830e7ce..a5aea5f 100644 --- a/ravanan/work/monads.scm +++ b/ravanan/work/monads.scm @@ -40,6 +40,7 @@ state-let* state-begin state-sequence + state-mmap current-state set-current-state run-with-state)) @@ -85,6 +86,11 @@ of values." mvalues))) (return (reverse reverse-list))))) +(define (mmap monad-type mproc . lists) + "Map monadic funcion @var{mproc} in @var{monad-type} over @var{lists} and return +a monadic list." + (sequence monad-type (apply map mproc lists))) + (define-immutable-record-type <maybe> (maybe value valid?) maybe? @@ -243,6 +249,9 @@ maybe-monadic." (define state-sequence (cut sequence %state-monad <>)) +(define state-map + (cut mmap %state-monad <> <...>)) + (define (current-state) "Return the current state as a state-monadic value." (lambda (state) |