[Haskell-cafe] A monad using IO, Reader, Writer, State and Error

Martin Huschenbett huschi at gmx.org
Fri Apr 13 05:12:36 EDT 2007

Hi all,

for my current project I need a monad that is an instance of MonadIO, 
MonadReader, MonadWriter, MonadState, and MonadError. I see two ways for 
defining such a monad using the mtl.

1) type MyMonad = ErrorT E (RWST R W S IO)


2) type MyMonad = RWST R W S (ErrorT E IO)

I can't figure out what is the difference between these two definitions 
and therefore which one is more suitable for my problem. Or are the 
equivalent and it is unimportant which one I use?

Or is it even better define a new type like

newtype MyMonad a = MyMonad { runMyMonad :: R -> S -> IO (Either E a,S,W) }

and declare instances for all 5 type classes?

Thanks for your help in advance,


More information about the Haskell-Cafe mailing list