If you are reading this post you are probably a programmer. You might be a beginner or a professional programmer but most likely you are an imperative programmer. In this post, I will try to motivate you why lambda calculus is interesting and how it is important.
type 'a boolean = 'a -> 'a -> 'a
let true' : 'a boolean = fun t _ -> t
let false' : 'a boolean = fun _ f -> f
let ( && ) (x : 'a boolean) (y : 'a boolean) : 'a boolean =
fun t f -> x (y t f) f
let ( || ) (x : 'a boolean) (y : 'a boolean) : 'a boolean =
fun t f -> x t (y t f)
let ( ! ) (x : 'a boolean) : 'a boolean = fun t f -> x f t
export type Bool<T> = (x: T, y: T) => T;
export const _true = <T>(t: T, _f: T) => t;
export const _false = <T>(_t: T, f: T) => f;
export const and =
<T>(x: Bool<T>, y: Bool<T>) =>
(t: T, f: T) =>
x(y(t, f), f);
export const or =
<T>(x: Bool<T>, y: Bool<T>) =>
(t: T, f: T) =>
x(t, y(t, f));
export const not =
<T>(x: Bool<T>) =>
(t: T, f: T) =>
x(f, t);