[Haskell-cafe] tips on using monads
claus.reinke at talk21.com
Mon May 18 12:58:50 EDT 2009
>>> I've got one of those algorithms which "threatens to march off the right edge" (in the words of
>>> Goerzen et al). I need something like a State or Maybe monad, but this is inside the IO monad.
>>> So I presume I need StateT or MaybeT. However, I'm still (sdlowly) learning about monads from
>>> first principles. I thought I might present my code and get some pointers... maybe someone could
>>> actually show me how to rewrite it, which would be a neat way to see MaybeT and StateT in
>>> action. I'm hoping to get anything from a one-line response to a rewrite of my code. Anything
>>> will help.
>> Perhaps this is useful:
> I can't quite tell--is that example in the IO monad? Part of my difficulty is that I'm inside IO.
> I know how to do this with Maybe, except that I have to combine Maybe and IO (use MaybeT?)
It was in the GHC.Conc.STM monad, so yes, it used a MaybeT
and Control.Monad.Trans.MonadTrans's lift (btw, the MonadTrans
docs only point to , but  might also be of interest, if rather
More information about the Haskell-Cafe