fun x -> x x;; (*does not type*)
let rec church n = if n = 0 then fun f x -> x else fun f x -> f (church (n-1) f x);;
church 0;;
church 1;;
church 2;;
church 10 ((^) "|") "";;
type nat = Zero | Succ of nat;;
let rec add m n = match m with
| Zero -> n
| Succ m -> Succ (add m n);;
let add = fun m n f x -> m f (n f x);;
let mul = fun m n f -> m (n f);;
let n3 = church 3;;
(add n3 n3);;
(add n3 n3) ((^) "|") "";;
(mul n3 n3) ((^) "|") "";;
(* WHNF *)
let g = (fun x -> print_int 3; (fun y -> print_int 5));;
g ();;
g () ();;