StateT
StateT is a Haskell monad transformer that threads and updates state through computations in an underlying monad.
Functional Design and Architecture: Examples in Haskell
StateT is a Haskell monad transformer that adds a mutable-state abstraction to an underlying monadic computation.
- How it is used
- Structures stateful game and ship-control scripts while retaining IO or domain-specific monadic actions.
- How deep it goes
- Explains types, get, put, lift, nested stacks, runners, and tests; defers transformer foundations to appendixes.
- Examples
- Uses aging scripts, a Minesweeper board reveal, layered score-and-board state, tests, and spaceship rotation control.
- What you can do after
- Build stateful scripts over IO or a custom monad, lift inner actions, run stack layers, and test final state.
Read how Functional Design and Architecture: Examples in Haskell explains StateT →
Learn Haskell by Example
StateT is a Haskell monad transformer that threads and updates state through computations in an underlying monad.
- How it is used
- Threads mutable application data through computations that also perform effects such as filesystem IO.
- How deep it goes
- Defines the type parameters and three essential operations, then demonstrates recursive state updates while deferring less-used functions.
- Examples
- Uses recursive directory traversal, counters, a Stats record, modify helpers, execStateT, and GHCi execution.
- What you can do after
- Apply it via Control.Monad.Trans.State.Strict to build effectful computations that read, replace, and update threaded state.
Related concepts
- monad transformerkind of · A monad transformer is a parameterized construction that adds one monad’s computational effects to another while preserving monadic composition.
- liftingused by · Lifting transforms a value, function, or operation so it can participate in computations within a computational context.
- ReaderT monadalternative to · ReaderT is a monad transformer that adds access to a read-only environment to an underlying monad.
- monad stackpart of · A monad stack is a nested composition of monads or monad transformers that combines multiple computational effects behind one 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.

