@@ -0,0 +1,27 @@
1+module Main where
2+
3+newtype Id = Id forall a. a -> a
4+
5+runId = \id a -> case id of
6+ Id f -> f a
7+
8+newtype Nat = Nat forall r. r -> (r -> r) -> r
9+
10+runNat = \nat -> case nat of
11+ Nat f -> f 0 (\n -> n + 1)
12+
13+zero = Nat (\zero _ -> zero)
14+
15+succ = \n -> case n of
16+ Nat f -> Nat (\zero succ -> succ (f zero succ))
17+
18+add = \n m -> case n of
19+ Nat f -> case m of
20+ Nat g -> Nat (\zero succ -> g (f zero succ) succ)
21+
22+one = succ zero
23+two = succ zero
24+four = add two two
25+fourNumber = runNat four
26+
27+main = Debug.Trace.trace "Done"