Solution

ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2017/imperative-programming-resit/7/c/solution

Use tagged disjoint unions for results that can contain either a value or an error message. This avoids ambiguity even if the item set itself contains the string Empty queue. The operation signatures are
Here is a singleton, expressing that create takes no meaningful argument. Write successful results as and , and errors as and for . Returning an error is not returning a queue, so its result must not be silently passed to another queue operation.

New to topics? Read the docs here!