Solution

ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2015/functional-programming-design-and-analysis-of-algorithms/2/a/solution

Use a sum type whose two constructors distinguish a number from an operator:
data Elem = Number Int | Operator Op
Then the supplied Polish and RPolish aliases can both be lists of Elem. Constructor tags distinguish tokens without attempting to encode operators as special numeric values. The numeric type Int agrees with the supplied abstract syntax tree.

New to topics? Read the docs here!