git.iko.soy/rowtype-yoga/purescript-native
on 24fdff2 help sign in
29 lines 566 B history raw
1module Main where
3import Prelude hiding (add)
5data Id = Id forall a. a -> a
7runId = \id a -> case id of
8 Id f -> f a
10data Nat = Nat forall r. r -> (r -> r) -> r
12runNat = \nat -> case nat of
13 Nat f -> f 0.0 (\n -> n + 1.0)
15zero' = Nat (\zero' _ -> zero')
17succ = \n -> case n of
18 Nat f -> Nat (\zero' succ -> succ (f zero' succ))
20add = \n m -> case n of
21 Nat f -> case m of
22 Nat g -> Nat (\zero' succ -> g (f zero' succ) succ)
24one' = succ zero'
25two = succ zero'
26four = add two two
27fourNumber = runNat four
29main = Control.Monad.Eff.Console.log "Done'"