-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrim.txt
More file actions
34 lines (26 loc) · 870 Bytes
/
Copy pathPrim.txt
File metadata and controls
34 lines (26 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{-
Define some basic types and operations
You can load this file before a repl session by doing
./Main Prim.txt -
-}
-- SKI combinators
I, id = Λα. λx:α. x
K, const = Λα. λx:α. Λb. λy:b. x
S, ap = Λα. λx:α -> α -> α. λy:α -> α. λz:α. x z (y z)
-- Church booleans
B, bool = [∀α. α → α → α]
T, true = Λα. λx:α. λy:α. x
F, false = Λα. λx:α. λy:α. y
and = λx:bool. λy:bool. x [bool] y false
or = λx:bool. λy:bool. x [bool] true y
not = λx:bool. x [bool] false true
if = Λα. λx:bool. λy:α. λz:α. x [α] y z
-- Church numerals
N, nat = [∀α. α -> (α -> α) -> α]
0, zero = Λα. λx:α. λf:α -> α. x
S, succ = λn:nat. Λα. λx:α. λf:α -> α. f (n [α] x f)
-- TODO: iszero
-- Church pairs
-- TODO: pair, fst, snd
-- Church lists
-- TODO: list, nil, cons, isnil