Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Term repr a where
- Term :: {..} -> Term repr a
- (:@) :: Term repr (a -> b) -> Term repr a -> Term repr b
- Lam :: (Term repr a -> Term repr b) -> Term repr (a -> b)
- Lam1 :: (Term repr a -> Term repr b) -> Term repr (a -> b)
- Var :: String -> Term repr a
- Char :: (Lift tok, Show tok) => tok -> Term repr tok
- Cons :: Term repr (a -> [a] -> [a])
- Eq :: Eq a => Term repr (a -> a -> Bool)
- optimizeTerm :: Term repr a -> Term repr a
Type Term
data Term repr a where Source #
Initial encoding of some Termable
symantics,
useful for some optimizations in optimizeTerm
.
Term | Black-box for all terms neither interpreted nor pattern-matched. |
(:@) :: Term repr (a -> b) -> Term repr a -> Term repr b infixl 9 | |
Lam :: (Term repr a -> Term repr b) -> Term repr (a -> b) | |
Lam1 :: (Term repr a -> Term repr b) -> Term repr (a -> b) | |
Var :: String -> Term repr a | |
Char :: (Lift tok, Show tok) => tok -> Term repr tok | |
Cons :: Term repr (a -> [a] -> [a]) | |
Eq :: Eq a => Term repr (a -> a -> Bool) |
Instances
optimizeTerm :: Term repr a -> Term repr a Source #
Beta-reduce the left-most outer-most lambda abstraction (aka. normal-order reduction), but to avoid duplication of work, only those manually marked as using their variable at most once. This is mainly to get prettier splices.
DOC: Demonstrating Lambda Calculus Reduction, Peter Sestoft, 2001, https://www.itu.dk/people/sestoft/papers/sestoft-lamreduce.pdf