KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Just learning about State monad from this excellent tutorial . However, when I tried to explain it to a non-programmer they had a question that stumped me. If the purpose of the State is to simulate mutable memory, why is the function that state monad stores is of the type: s -> (a, s) and not simply: s -> s In other words, what is the need for the "intermediate" value? For example, couldn't we, in the cases where we need it, simulate it by simply defining a state as a tuple of (state, value) ? I'm sure I confused something, any help is appreciated.
Tags (comma-separated)
Save Edits
Cancel