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
- Adds stateful scripting to existing monadic computations without manually passing state through each operation.
- How deep it goes
- Explains state access, lifting, nested stacks, runners, tests, and a type-synonym workaround; defers broader transformer discussion to appendixes.
- Examples
- Uses Minesweeper board and score scripts, board-state tests, and a stateful spaceship rotation script.
- What you can do after
- Apply it via Control.Monad.State to build and run stateful monadic scripts, including nested state layers.
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.
What to know first
- stateState is information describing the condition or configuration of a system or computation at a particular time that may influence its behavior or subsequent transitions.
- IOAn IO abstraction is a programming construct that represents input/output operations or computations that interact with the external world.
- monadA monad is a programming abstraction that provides operations for sequencing computations while encapsulating and preserving their computational context.
Related concepts
- monad transformerkind of · A monad transformer is a type-level construction that combines a monad with an underlying monad to compose computations involving both effects.
- liftingused by · Lifting is the transformation of 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 a monadic interface.
Questions about StateT
What is StateT?
StateT is a Haskell monad transformer that threads and updates state through computations in an underlying monad.
Which Manning books explain StateT?
Functional Design and Architecture: Examples in Haskell and Learn Haskell by Example.
What should I know before learning StateT?
Manning books that teach StateT usually introduce state, IO and monad first.
What is the difference between StateT and ReaderT monad?
StateT is a Haskell monad transformer that threads and updates state through computations in an underlying monad. ReaderT is a monad transformer that adds access to a read-only environment to an underlying monad.
What is StateT a kind of?
StateT is a kind of monad transformer. A monad transformer is a type-level construction that combines a monad with an underlying monad to compose computations involving both effects.
What is StateT part of?
StateT 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.

