Created
March 25, 2015 17:31
-
-
Save rampion/38d871a8f71eb7167282 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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