[Haskell-cafe] combining monads with IO
Richard Silverman
res at qoxp.net
Thu Jun 25 08:16:10 EDT 2009
Hi all,
I'm puzzled by something. Suppose I have some code that does lots of
IO, and also occasionally refers to some global state. No problem, use
ReaderT for the state, combining with the IO monad. Except... since IO
is on the bottom, simple uses of do-notation such as "foo <- ask" work
in the Reader monad, and to access the IO monad, I need to lift, e.g.
(bar <- liftIO getLine). If my code does lots of IO, this is *very*
ugly -- the code is littered with lift functions! Is there no cleaner
way to do this?
Thanks,
- Richard
More information about the Haskell-Cafe
mailing list