Skip to content

Instantly share code, notes, and snippets.

@Peaker
Last active August 29, 2015 14:05
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 Peaker/a93a6c5ccb1906e4b8f7 to your computer and use it in GitHub Desktop.
Save Peaker/a93a6c5ccb1906e4b8f7 to your computer and use it in GitHub Desktop.
-- 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