
24 May
2011
24 May
'11
9 a.m.
On 24 May 2011 09:41, Sean Perry
when invoked as
print $ evalState foo 0
I get "blah" as expected. When I switch to execState I get the value 1. This is what confuses me. Where is the State coming from if it is not passed into foo? What are get and put operating on?
If you write it like this print $ (execState foo) 0 and note that execState foo :: Int -> Int it's easier to see that evalState foo returns a *function* that takes an initial state and then operates on this. Hope this makes it a bit clearer. :-) -- Erlend Hamberg ehamberg@gmail.com