git.iko.soy/rowtype-yoga/purescript-native
on cd4c708 help sign in
30 lines 608 B history raw
1module Main where
3import Prelude hiding (add)
4import Control.Monad.Eff.Console (log)
6data Id = Id forall a. a -> a
8runId = \id a -> case id of
9 Id f -> f a
11data Nat = Nat forall r. r -> (r -> r) -> r
13runNat = \nat -> case nat of
14 Nat f -> f 0.0 (\n -> n + 1.0)
16zero' = Nat (\zero' _ -> zero')
18succ = \n -> case n of
19 Nat f -> Nat (\zero' succ -> succ (f zero' succ))
21add = \n m -> case n of
22 Nat f -> case m of
23 Nat g -> Nat (\zero' succ -> g (f zero' succ) succ)
25one' = succ zero'
26two = succ zero'
27four = add two two
28fourNumber = runNat four
30main = log "Done"