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 2 succ 0;; church 10 succ 0;; church 10 (fun x -> "|"::x) [];; church 2 (fun x -> "|"::x) [];; type nat = Zero | Succ nat;; type nat = Zero | Succ of nat;; let rec add m n = match m with | Zero -> n | Succ m -> Succ (add m n);; let rec church n = if n = 0 then fun f x -> x else fun f x -> f (church (n-1) f x);; let add = fun m n f x -> m f (n f x);; let n2 = church 2;; let n4 = add n2 n2;; n4 succ 0;; n4;; n2;; n4 ((^) "|") "";; let n2 = church 2;; let n4 = add n2 n2;; n4 ((^) "|") "";; n4;; let rec church n = if n = 0 then fun f x -> x else fun f x -> f (church (n-1) f x);; let n4 = add n2 n2;; let add = fun m n f x -> m f (n f x);; let f x = print_int 3;; f ();; fun x -> print_int 3;; (fun x -> print_int 3; (fun y -> print_int 5));; let g = (fun x -> print_int 3; (fun y -> print_int 5));; g ();; g () ();;