liveBook · Manning

StateT

StateT is a Haskell monad transformer that threads and updates state through computations in an underlying monad.

How 2 Manning books explain it

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.

Read how Learn Haskell by Example explains StateT →

What to know first

Related concepts

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.