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

Cale Gibbard cgibbard at gmail.com
Sun Sep 11 06:10:30 EDT 2005


Aside from using a monad which has all the effects you need directly,
or working in the IO monad, you can compose a monad with the necessary
properties using monad transformers (which you tend to then at least
give a type alias to, if not a newtype declaration). Part III of
http://www.nomaware.com/monads/html/ deals with monad transformers,
and shows how various effects can be combined to get just what is
desired.

 - Cale

On 11/09/05, gary ng <garyng2000 at yahoo.com> wrote:
> I am reading "Monads for functional programming" from
> http://homepages.inf.ed.ac.uk/wadler/topics/monads.html,
> 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.
> http://store.yahoo.com/redcross-donate3/
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list