diff options
Diffstat (limited to 'monads.lisp')
-rw-r--r-- | monads.lisp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/monads.lisp b/monads.lisp index 8586f5b..0bda2ac 100644 --- a/monads.lisp +++ b/monads.lisp @@ -234,6 +234,19 @@ ;;; State transformer monad, with operations expressed using comprehensions ;;; over the identity monad, featuring multiple-value binding. ;;; +;;; Example: +;;; +;;; (let ((transformer (state-xform-comp (list x y z) +;;; (x (lambda (state) +;;; (values `(:stage x ,state) (1+ state)))) +;;; (y (lambda (state) +;;; (values `(:stage y ,state) (+ 10 state)))) +;;; (z (lambda (state) +;;; (values `(:stage z ,state) nil)))))) +;;; (funcall transformer 42)) +;;; +;;; -> ((:STAGE X 42) (:STAGE Y 43) (:STAGE Z 53)) +;;; (define-monad state-xform-monad :comprehension state-xform-comp :map ((f) |