4 ms·
The State Monad isn't really mutating state though, it's really a monad for composition of incremental operations upon immutable data structures. The ST monad
by runT1ME 14y ago
The State Monad isn't really mutating state though, it's really a monad for composition of incremental operations upon immutable data structures. The ST monad is for 'hiding' mutable variables and ensuring their state doesn't violate referential transparency.
- tel 14y agoFrom inside the State monad though, it "looks just like" (has semantics of) mutability. It's simply interpreted in an immutable lambda calculus. The ST monad has the same game but a different interpreter.