[Haskell-cafe] Monad, more than one of them ?

gary ng garyng2000 at yahoo.com
Sun Sep 11 00:22:50 EDT 2005

I am reading "Monads for functional programming" from
which is IMO the best explanation of monad I have seen
so far.

What I would like to know is, what if I need more than
one of them at the same time. Using the example given
in the paper, it is quite comment that one would need
exception handling, state management and output all at
the same time. 

In an imperative language, one can do all three at the
same time in the normal flow like wrapping a try/catch
block, make some state changes to a global variable
and make some io calls.

How would one do it in a monadic way ? As my
understanding of Monad is that it is something like a
"wrapper/container" where the side-effect is kept. One
way of doing it is of course expand it to include all
three side effects. But this is unmanageable and it is
no different than the non-monadic version mentioned in
the paper. Another way I can see is to "wrap" one
monad with another and so on. But this can also get
complicated as what if I have 10 type of monads that
can be permutated in various way.

Click here to donate to the Hurricane Katrina relief effort.

More information about the Haskell-Cafe mailing list