symantic-parser-0.1.0.20210201: Parser combinators statically optimized and staged via typed meta-programming
Safe HaskellNone
LanguageHaskell2010

Symantic.Parser.Haskell.Optimize

Contents

Synopsis

Type Term

data Term repr a where Source #

Initial encoding of some Termable symantics, useful for some optimizations in optimizeTerm.

Constructors

Term

Black-box for all terms neither interpreted nor pattern-matched.

Fields

(:@) :: 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

Instances details
Trans repr (Term repr) Source # 
Instance details

Defined in Symantic.Parser.Haskell.Optimize

Methods

trans :: repr a -> Term repr a Source #

Termable repr => Termable (Term repr) Source # 
Instance details

Defined in Symantic.Parser.Haskell.Optimize

Methods

(.@) :: Term repr (a -> b) -> Term repr a -> Term repr b Source #

lam :: (Term repr a -> Term repr b) -> Term repr (a -> b) Source #

lam1 :: (Term repr a -> Term repr b) -> Term repr (a -> b) Source #

bool :: Bool -> Term repr Bool Source #

char :: (Lift tok, Show tok) => tok -> Term repr tok Source #

cons :: Term repr (a -> [a] -> [a]) Source #

nil :: Term repr [a] Source #

eq :: Eq a => Term repr (a -> a -> Bool) Source #

unit :: Term repr () Source #

left :: Term repr (l -> Either l r) Source #

right :: Term repr (r -> Either l r) Source #

nothing :: Term repr (Maybe a) Source #

just :: Term repr (a -> Maybe a) Source #

const :: Term repr (a -> b -> a) Source #

flip :: Term repr ((a -> b -> c) -> b -> a -> c) Source #

id :: Term repr (a -> a) Source #

(.) :: Term repr ((b -> c) -> (a -> b) -> a -> c) Source #

($) :: Term repr ((a -> b) -> a -> b) Source #

Trans (Term Identity) Identity Source # 
Instance details

Defined in Symantic.Parser.Haskell.Optimize

Methods

trans :: Term Identity a -> Identity a Source #

Trans (Term ValueCode) ValueCode Source # 
Instance details

Defined in Symantic.Parser.Haskell.Optimize

Trans (Term (CodeQ :: Type -> Type)) (CodeQ :: Type -> Type) Source # 
Instance details

Defined in Symantic.Parser.Haskell.Optimize

Methods

trans :: Term CodeQ a -> CodeQ a Source #

Trans (Term (CodeQ :: Type -> Type)) (Term ValueCode) Source # 
Instance details

Defined in Symantic.Parser.Haskell.Optimize

Methods

trans :: Term CodeQ a -> Term ValueCode a Source #

Trans (Term ValueCode) (Term (CodeQ :: Type -> Type)) Source # 
Instance details

Defined in Symantic.Parser.Haskell.Optimize

Methods

trans :: Term ValueCode a -> Term CodeQ a Source #

Show (Term repr a) Source # 
Instance details

Defined in Symantic.Parser.Haskell.View

Methods

showsPrec :: Int -> Term repr a -> ShowS #

show :: Term repr a -> String #

showList :: [Term repr a] -> ShowS #

type Output (Term repr) Source # 
Instance details

Defined in Symantic.Parser.Haskell.Optimize

type Output (Term repr) = repr

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