type expr = | Const of int | Add of expr * expr | Mul of expr * expr let rec eval : expr -> int = fun (e : expr) => match e with | Const(i) => i | Add(u,v) => plus (eval u) (eval v) | Mul(u,v) => times (eval u) (eval v) end type binop = Add' | Mul' type expr' = | Const' of int | BinOp' of binop * expr' * expr' let rec convert : expr' -> expr = fun (e : expr') => match e with | Const'(i) => Const(i) | BinOp'(op,u,v) => match op with | Add' => Add(convert u, convert v) | Mul' => Mul(convert u, convert v) end end let ornament convert : expr' -> expr let ornament eval' from eval with {convert} -> [int]