type peano = Zero | Succ of peano

let rec to_int p = match p with
  | Zero -> 0
  | Succ p' -> 1 + to_int p'

let rec from_int n =
  if n = 0 then Zero
  else Succ (from_int (n - 1))

let rec plus a b = match a with
  | Zero -> b
  | Succ a' -> Succ (plus a' b)

let rec mul a b = match a with
  | Zero -> Zero
  | Succ a' -> plus b (mul a' b)

;;

to_int (mul (from_int 5) (from_int 6))
