-- ==================================================
-- Lecture 6: Introduction to the Lambda Calculus
-- ==================================================
-- Lambda expressions in Haskell

f1 x y = x + y

f2 = \x -> \y -> x + y

i = \x -> x

-- i 5
-- i i 5

-- ==================================================
-- Representing Booleans

t = \x -> \y -> x
f = \x -> \y -> y

isTrue b = b "yes" "no"
isFalse b = b "no" "yes"

-- isTrue t
-- isFalse f

neg = \b -> b f t
-- not = \b -> b f t

-- ==================================================
-- Representing Tuples

pair = \x -> \y -> \z -> z x y
first = \p -> p t
second = \p -> p f

-- first (pair 1 2)
-- first (second (pair 1 (pair 2 3)))

-- ==================================================
-- Representing Numbers

zero = i
succ' = \n -> pair f n
isZero = first
pred' = second

one = succ' zero
two = succ' one

-- isTrue (isZero (pred' (pred' two)))

-- ==================================================
-- omega:
-- \x -> x x

-- ==================================================
