Last active
August 29, 2015 14:05
-
-
Save Peaker/a93a6c5ccb1906e4b8f7 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
-- Simple Lambda Calculus | |
data Body a = Var String | Lam String (Expr a) | Apply (Expr a) (Expr a) | |
deriving (Functor, Foldable, Traversable) | |
data Expr a = Expr (Body a) a | |
deriving (Functor, Foldable, Traversable) | |
Now each sub-expression in (Expr a) has associated data of type "a" which is really useful! | |
NEXT: | |
data Body expr = Var String | Lam String expr | Apply Expr expr | |
deriving (Functor, Foldable, Traversable) | |
data Expr a = Expr (Body (Expr a)) a | |
deriving (Functor, Foldable, Traversable) | |
This is also useful, because it lets you easily recurse to all subexpressions, if you use |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment