Re: [Haskell-cafe] simple state monad exercises? (besides labeling trees)

2009-07-07 Thread John Meacham
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 exists

[Haskell-cafe] simple state monad exercises? (besides labeling trees)

2009-07-06 Thread Thomas Hartman
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

Re: [Haskell-cafe] simple state monad exercises? (besides labeling trees)

2009-07-06 Thread Thomas ten Cate
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]

Re: [Haskell-cafe] simple state monad exercises? (besides labeling trees)

2009-07-06 Thread Matthias Görgens
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.

Re: [Haskell-cafe] simple state monad exercises? (besides labeling trees)

2009-07-06 Thread Lanny Ripple
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,