liveBook · Manning

Monad transformer

A monad transformer is a type-level construction that combines a monad with an underlying monad to compose computations involving both effects.

How 2 Manning books explain it

Functional Design and Architecture: Examples in Haskell

A monad transformer is a type-level abstraction that adds one monad's effects to another monad.

How it is used
Combines effects in monadic computations, including pure state alongside IO or embedded application logic.
How deep it goes
Works through nested StateT stacks, lifting, runners, and tests, while directing readers elsewhere for further transformer explanation.
Examples
Uses a Minesweeper board and score stack, plus a stateful spaceship rotation script.
What you can do after
Apply StateT to combine state with another monad, lift underlying actions, and run or test the resulting stack.

Read how Functional Design and Architecture: Examples in Haskell explains monad transformer →

Learn Haskell by Example

A monad transformer is a type constructor that augments an underlying monad with additional computational effects while preserving monadic composition.

How it is used
Structures a directory-synchronization application around configuration access, state, accumulated output, and IO.
How deep it goes
Explains transformer roles, ReaderT types, environment access, and lifting, while stopping short of detailed transformer stacking mechanics.
Examples
Uses a file-synchronization Config, a ReaderT Config IO application, ask, liftIO, and runReaderT.
What you can do after
Build effectful application actions that read configuration and perform IO without manually threading environment values.

Read how Learn Haskell by Example explains monad transformer →

Also covered in

What to know first

Related concepts

Questions about monad transformer

What is monad transformer?

A monad transformer is a type-level construction that combines a monad with an underlying monad to compose computations involving both effects.

Which Manning books explain monad transformer?

Functional Design and Architecture: Examples in Haskell and Learn Haskell by Example.

What should I know before learning monad transformer?

Manning books that teach monad transformer usually introduce monad, state and IO first.

What kinds of monad transformer are there?

Kinds of monad transformer include ReaderT monad, StateT, ExceptT, RWST and WriterT.

What is monad transformer part of?

Monad transformer is part of monad stack. A monad stack is a nested composition of monads or monad transformers that combines multiple computational effects behind a monadic interface.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.