A monad transformer is a type constructor that extends an underlying monad with additional computational effects while preserving monadic composition. It helps structure effectful applications without relying on IO alone. section 15.0 section 15.4
A transformer stack separates common application concerns: ReaderT provides read-only configuration, StateT provides mutable state, and WriterT accumulates output. RWST combines all three capabilities. section 15.1 section 15.4
ReaderT shows how a transformer adds an environment to another monad:
- ReaderT r m a stores an environment of type r, uses m as its underlying monad, and produces a result of type a. section 15.1.1
- ReaderT Config IO a combines configuration access with IO; ask reads the environment without passing it through every action. section 15.1.1
Configuration-aware file synchronization
Define type App a = ReaderT Config IO a. An App action can read source and destination paths with ask, then print them using liftIO. Running runReaderT example cfg produces the configured path mapping, such as “src -> dst”.

