[Haskell-cafe] Newbie: State monad example questions
jules at jellybean.co.uk
Wed May 21 11:31:04 EDT 2008
Dmitri O.Kondratiev wrote:
> Stupid question, please bear with me:
> x :: Int -- x declared, but not constructed
> x = 1 -- x constructed
> s1 :: State StdGen a -- s1 declared, yes, but why s1 is *also already
> constructed* ?
it's constructed when you do
s1 = return 1
... or ...
s1 = get >>= put
.. or some other more complex interaction, perhaps using do notation.
It's the >>= or the return that construct the State, just as the '1' is
enough to construct the Int.
More information about the Haskell-Cafe