Re: [Haskell-cafe] Composing monads (sort of)

2006-12-16 Thread Chris Eidhof
Hey Mark, How can I concisely compose these functions without having to write a cascade of case statements such as: case f1 rec1 of Nothing - return Nothing Just id1 - do rec2 - f2 id2 return $ case rec2 of

Re: [Haskell-cafe] Composing monads (sort of)

2006-12-16 Thread Pepe Iborra
Wait, there are two monads in scene here, IO and Maybe. The right solution is to compose them indeed. One could use the MaybeT monad transformer defined in the 'All about monads' tutorial [1], or we could just define the IOmaybe monad: import Data.Traversable (mapM) newtype IOMaybe a =

Re: Re: [Haskell-cafe] Composing monads (sort of)

2006-12-16 Thread Nicolas Frisby
Once I start needing to combine Maybe with other monads, I usually take a moment to generalize the appropriate Maybe parts to MonadError e m = m. Then we can just use the (ErrorT e IO) monad. Nick On 12/16/06, Pepe Iborra [EMAIL PROTECTED] wrote: Wait, there are two monads in scene here, IO