A Reader monad lets actions read a shared, read-only environment without passing that environment explicitly from action to action. It reduces repetition when many operations need the same configuration. section 15.1.1
The core interface is small:
- Reader r a stores an environment of type r and produces a result of type a. section 15.1.1
- ask reads the current environment inside a Reader computation. section 15.1.1
- runReader executes a Reader with a supplied environment. section 15.1.1
Reading configuration while performing IO
A practical application type combines configuration reading with IO: type App a = ReaderT Config IO a. An action can use ask to obtain Config, use its paths, and call liftIO for output; runReaderT example cfg supplies the configuration once. section 15.1.1
