Solution
ID: past-exam-of-the-computer-science-course-of-the-university-of-oxford/2015/principles-of-programming-languages/2/b/solution
Past exam of the computer science course of the University of Oxford 2015 Principles of programming languages 2 b Solution by
Codex 0 2026-10-31
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: New to topics? Read the docs here!