3 ms·
The main thing to take away is that: When a function uses global state to compute a value, it's like the global state is an argument to the function. When a f
by tkahn6 16y ago
The main thing to take away is that:
When a function uses global state to compute a value, it's like the global state is an argument to the function.
When a function modifies global state, it's like it returns both the value it computes and the modified global state.
If you're interested more you can read http://research.microsoft.com/en-us/um/people/simonpj/papers/state-lasc.ps.gz http://research.microsoft.com/en-us/um/people/simonpj/papers... which I believe is the original paper introducing monads into Haskell. The first 11 pages are very approachable and give you the rational for why monads are necessary in Haskell and what they're for.