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
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 =
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