[Haskell] ST vs State
Joel Koerwer
joelkoerwer at gmail.com
Wed May 30 07:18:53 EDT 2007
Hi Frederico,
I had the exact same problem when I first started with Haskell.
Quite simply, State uses get/put to handle passing state, whereas ST
uses STRefs and STArrays.
In State s a, the s has meaning, for example it could be a random
number generator or key-value mapping you want to pass around. However
in ST s a, the s only exists in the type. The actual state is stored
in references and arrays.
Perhaps someone more knowledgeable should add something to the Haddock
comments; I think this confuses a lot of people at first.
Joel
More information about the Haskell
mailing list