Skip to content

Instantly share code, notes, and snippets.

@rampion
Created March 25, 2015 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rampion/38d871a8f71eb7167282 to your computer and use it in GitHub Desktop.
Save rampion/38d871a8f71eb7167282 to your computer and use it in GitHub Desktop.
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE RankNTypes #-}
module Temp where
type Point f = forall a. a -> f a
data Nat = Z | S Nat
type family Apply n f x where
Apply Z f x = x
Apply (S n) f x = f (Apply n f x)
data Church (n :: Nat) where
Church :: (forall f x. Point f -> x -> Apply n f x) -> Church n
zero :: Church Z
zero = Church $ \f x -> x
one :: Church (S Z)
one = Church $ \f x -> f x
two :: Church (S (S Z))
two = Church $ \f x -> f (f x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment