Source

lambda-translator / term.ml

Full commit
type var = string

type term =
  | Var of var
  | Abs of var * term
  | App of term * term

let rec sterm = function
  | Var v -> v
  | Abs (x, t) -> "^" ^ x ^ ". " ^ sterm t
  | App ((Abs _ as t1), (Abs _ as t2)) -> "(" ^ sterm t1 ^ ") (" ^ sterm t2 ^ ")"
  | App ((Abs _ as t1), t2) -> "(" ^ sterm t1 ^ ") " ^ sterm t2
  | App (t1, (Abs _ as t2)) -> sterm t1 ^ " (" ^ sterm t2 ^ ")"
  | App (t1, t2) -> sterm t1 ^ " " ^ sterm t2