Apply the memory interface before invoking the supplied continuation:
get :: Location -> M Value
get a k s = k (contents s a) s

put :: Location -> Value -> M ()
put a v k s = k () (update s a v)

new :: M Location
new k s = let (a,s') = fresh s in k a s'
A read preserves computer memory; a write changes it but returns the unit type value; an allocation uses the updated computer memory returned by fresh. The continuation always receives the latest computer memory:

Articles by others on the same topic (0)

There are currently no matching articles.