[<<][compsci][>>][..]

Sat May 8 17:47:57 EDT 2010

## State monad with unit output

What's the purpose of a State monad that doesn't produce output, like
(s -> ((),s)) ?
The way I use it is to use fmap to map (In -> State s) over [In] to
get [State s] which can then be sequenced to State s and started with
runState. The only thing I'm interested in is the end state.
But without output, this is really just a left fold (accumulator) ::
In -> s -> s. What's the benefit of wrapping a fold up into a state
monad? Monad transformers?
It pops up in the Flatten.hs code for graph -> SSA conversion.
Maybe this is related: merging monads and folds[1]. It talks about
the two schools: fold vs. monads.
[1] http://www.springerlink.com/index/768043006044675P.pdf

[Reply][About]

[<<][compsci][>>][..]