import Html exposing (text) import Text type Term = Con Int | Div Term Term type M a = Raise Exception | Return a type alias Exception = String eval : Term -> M Int eval term = case term of Con a -> Return a Div t u -> case eval t of Raise e -> Raise e Return a -> case eval u of Raise e -> Raise e Return b -> if b==0 then Raise "divide by zero" else Return (a // b) main = text (toString (eval (Div(Div(Con 1972)(Con 2))(Con 0))))