Example Usage of Monad Transformer
The best tutorial of Monad Transformer is "Monad Transformers Step by Step" by Martin Grabmulle. The tutorial is available online. Code is available [here] (https://github.com/seckcoder/Haskell-Demo/blob/master/src/Eval.hs)
Construct your own Monad Transformer
To better understand Monad Transformer, you can implement your own Monad Transformers. For example:
Problems of Monad Transformers:
One Monad Transformer shows up multiple times in the monad stack
-- Multiple Environments
type Eval a = ReaderT Env (ReaderT Env Identity) a
eval (Val n) = do env1 <- ask
env2 <- lift ask -- To get the inner environment, you need to lift the computation here
-- ...
Alternative to Monad Transformers