git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Add test that should pass, but doesn't
commitd2ba55c3d265a4455b561b762e46fb18c469ff1d authorGary Burgess <gary.burgess@gmail.com> dateSat 26 Jul 2014, 12:58 (12 years ago) parentda699d0
1 file changed+27
examples/shouldpass/NewtypeTCO.purs+27
examples/shouldpass/NewtypeTCO.pursnew file+27
@@ -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"