[Haskell-beginners] Getting into nested monad transformers

Brent Yorgey byorgey at seas.upenn.edu
Mon Feb 23 06:06:43 EST 2009


On Thu, Feb 19, 2009 at 09:51:06PM -0800, Arthur Chan wrote:
> Hey all,
> 
> I've been trying to access the inner state "s" for this type:
> 
> newtype TestThingey s a = TestThingey {
>       runTrans :: ReaderT Int (StateT String (StateT s IO)) a
> } deriving (Monad, MonadIO, MonadState String, MonadReader Int)

In this situation I would combine the String and s into one state:

  ReaderT Int (StateT (String,s) IO) a

Otherwise, yes, you'll just have to use the appropriate number of
lifts.

-Brent


More information about the Beginners mailing list