[Haskell-cafe] Monad transformers (was: Is my code too complicated?)

Roman Cheplyaka roma at ro-che.info
Sat Jul 3 09:35:08 EDT 2010


* Andrew Coppin <andrewcoppin at btinternet.com> [2010-07-03 14:20:14+0100]
> In my experience, using more than one monad transformer at once makes
> code utterly incomprehensible.

See X monad (xmonad) for an counterexample.

-- | The X monad, 'ReaderT' and 'StateT' transformers over 'IO'
-- encapsulating the window manager configuration and state,
-- respectively.
--
-- Dynamic components may be retrieved with 'get', static components
-- with 'ask'. With newtype deriving we get readers and state monads
-- instantiated on 'XConf' and 'XState' automatically.
--
newtype X a = X (ReaderT XConf (StateT XState IO) a)

-- 
Roman I. Cheplyaka :: http://ro-che.info/
"Don't let school get in the way of your education." - Mark Twain


More information about the Haskell-Cafe mailing list