News for hackers. Stuff that matters.
Re:"Welcome to the Machine": State monads in Clojure by brehaut on Tuesday February 09, 2010 @10:38PM (#1114144)
Clojure (being a lisp) uses macros and some dynamic variables to manage this sort of polymorphism. The clojure library provides a defmonad macro to let you define the functions required (m-bind and m-result are a must, and m-plus and m-zero are optional).

Unlike haskell which can choose an implementation based on the return type of return and bind, you do have to spell it out. The macro with-monad will wrap a set of expressions up in the correct monad, and the domonad monad comprehension form is also able to accept an optional monad name (useful if you aren't inside a with-monad form, or if you need a different monad)

There are no comments on this comment yet.