[Haskell-cafe] Fighting the monad stack, MonadIO

Tillmann Rendel rendel at daimi.au.dk
Thu Apr 10 15:49:00 EDT 2008

Adam Smyczek wrote:
> For a small webapi binding I try to implement a session like monad
> by building a stack including BrowserAction from Network.Browser
> module as following:
> newtype RBAction a = RBAction
>     { exec :: ErrorT String (StateT RBState BrowserAction) a }
>     deriving (Functor, Monad, MonadState RBState)
> I would like the RBAction to implement MonadIO as well,
> but fight with the liftIO function for hours now, without success.
> Any idea how the implementation of liftIO could look like?

I would add

   instance MonadIO BrowserAction where
     liftIO = ioAction

to hook Network.Browser into the monad transformer framework. I don't 
know why this instance is missing from Network.Browser. Maybe to avoid a 
dependency on the mtl?  Anyway, with this instance, MonadIO can simply 
be derived for RBAction:

   newtype RBAction a = ... deriving (MonadIO, ...)


More information about the Haskell-Cafe mailing list