Solution

ID: past-exam-of-the-computer-science-course-of-the-university-of-oxford/2015/principles-of-programming-languages/1/b/solution

Use the three monad laws of the base computational monad. For left identity, at an arbitrary program state ,
The last step is the base left identity law. For right identity,
The penultimate equality identifies the pair-destructuring function with ; the last uses the base right identity law.
For associativity, expand the two successive uses of sequencing and apply base associativity:
No program state is duplicated or reset during these rearrangements: both sides pass to , its output to , and the output of to . By function extensionality,

New to topics? Read the docs here!