In the previous recipe, we implemented our own State Monad transformer. In this recipe, we will revisit the mtl library and use the Reader monad transformer. The Reader monad transformer is a restricted version of the State Monad transformer in which we are allowed only to get the state (but not modify it).
Working with the Reader monad transformer
How to do it...
- Create a new project read-trans using the simple Stack template.
- Open read-trans.cabal and add the following dependencies in the build-depends subsection of the executable section:
executable read-trans
hs-source-dirs: src
main-is: Main.hs
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
...