On Mon, Jul 06, 2009 at 12:54:54PM -0400, Thomas Hartman wrote:
> Can someone give some simple common scenarios where the state monad is
> useful, besides labeling trees?
Implementing the Union-Find data structure[1] for unification based type
inference. As far as I know, no good alternative exist
Off the top of my head state is important when getting from A to B
depends on the path you took. As such a common scenario I find
myself in all the time is not having a good CLI craps game. (And
which I resolve by rewriting in every language I learn.) Stake,
current bet, bets outstanding, point.
> Can someone give some simple common scenarios where the state monad is
> useful, besides labeling trees?
Emulating the VM given in this years ICFP programming contest was also
a good application of the state monad. Of course you interprate much
simpler language imperative languages, too. (Howe
I used the State monad to implement a Brainfuck [1] interpreter a few
months ago. It stored the program counter, pointer and the memory of
the machine.
There might have been a different (better?) way, but as I was trying
to learn more about monads, it was an obvious choice.
Thomas
[1] http://www
Can someone give some simple common scenarios where the state monad is
useful, besides labeling trees?
References to puzzles like those in project Euler or similar would be nice.
Thanks!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.