Created
August 17, 2012 08:22
-
-
Save gergoerdi/3376973 to your computer and use it in GitHub Desktop.
Untyped lambda-calculus (Haskell)
This file contains hidden or 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 #-} | |
data Nat = Z | Suc Nat | |
data Fin n where | |
FZ :: Fin (Suc n) | |
FS :: Fin n -> Fin (Suc n) | |
inj :: Fin n -> Fin (Suc n) | |
inj FZ = FZ | |
inj (FS f) = FS (inj f) | |
data Exp n where | |
Var :: Fin n -> Exp n | |
Lam :: Exp (Suc n) -> Exp n | |
(:@:) :: Exp n -> Exp n -> Exp n |
Actually you don't even need the injection there:
_flip :: Exp Z
_flip = Lam $ Lam $ let x = Var (FS FZ)
f = Var FZ
in f :@: x
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage: