For example, after defining the identity monad:
(define-monad
<id>
(lambda (a) a)
(lambda (a f) (f a)))
We can bind a chain of methods upon an initial value using it:
(doto-using <id> (+ 0 1)
(lambda (x) (+ x 1))
(lambda (y) (+ y 2)))
Or, alternatively, we can be explicit:
(using <id>
(>>= (>>= (return (+ 0 1))
(lambda (x) (+ x 1)))
(lambda (y) (+ y 2))))
A short demo showing the behaviour:
###Hi!
#<id> 2
##<id> 2
##Hi!
#<id> 2
#Hi!
#<id> 2
And the repository is on GitHub:
Please have a look at the wiki for a more thorough introduction and comments.
Thanks for Chicken!
-Dan