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

Symantic.Parser.Grammar.Optimize

Synopsis

Type Comb

data Comb (repr :: Type -> Type) a where Source #

Pattern-matchable Combinators of the grammar. (repr) is not strictly necessary since it's only a phantom type (no constructor use it as a value), but having it:

  1. emphasizes that those Combinators will be transformed again (eg. in DumpComb or Instructions).
  2. Avoid overlapping instances between (Trans (Comb repr) repr) and (Trans (Comb repr) (OptimizeComb letName repr))

Constructors

Pure :: Haskell a -> Comb repr a 
Satisfy :: Satisfiable repr tok => [ErrorItem tok] -> Haskell (tok -> Bool) -> Comb repr tok 
Item :: Satisfiable repr tok => Comb repr tok 
Try :: Comb repr a -> Comb repr a 
Look :: Comb repr a -> Comb repr a 
NegLook :: Comb repr a -> Comb repr () 
Eof :: Comb repr () 
(:<*>) :: Comb repr (a -> b) -> Comb repr a -> Comb repr b infixl 4 
(:<|>) :: Comb repr a -> Comb repr a -> Comb repr a infixl 3 
Empty :: Comb repr a 
Branch :: Comb repr (Either a b) -> Comb repr (a -> c) -> Comb repr (b -> c) -> Comb repr c 
Match :: Eq a => [Haskell (a -> Bool)] -> [Comb repr b] -> Comb repr a -> Comb repr b -> Comb repr b 
ChainPre :: Comb repr (a -> a) -> Comb repr a -> Comb repr a 
ChainPost :: Comb repr a -> Comb repr (a -> a) -> Comb repr a 
Def :: Name -> Comb repr a -> Comb repr a 
Ref :: Bool -> Name -> Comb repr a 

Instances

Instances details
Letable Name (Comb repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

def :: Name -> Comb repr a -> Comb repr a Source #

ref :: Bool -> Name -> Comb repr a Source #

Lookable (Comb repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

look :: Comb repr a -> Comb repr a Source #

negLook :: Comb repr a -> Comb repr () Source #

eof :: Comb repr () Source #

Foldable (Comb repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

chainPre :: Comb repr (a -> a) -> Comb repr a -> Comb repr a Source #

chainPost :: Comb repr a -> Comb repr (a -> a) -> Comb repr a Source #

Matchable (Comb repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

conditional :: Eq a => [Haskell (a -> Bool)] -> [Comb repr b] -> Comb repr a -> Comb repr b -> Comb repr b Source #

match :: Eq a => [Haskell a] -> Comb repr a -> (Haskell a -> Comb repr b) -> Comb repr b -> Comb repr b Source #

Selectable (Comb repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

branch :: Comb repr (Either a b) -> Comb repr (a -> c) -> Comb repr (b -> c) -> Comb repr c Source #

Alternable (Comb repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

(<|>) :: Comb repr a -> Comb repr a -> Comb repr a Source #

empty :: Comb repr a Source #

try :: Comb repr a -> Comb repr a Source #

(<+>) :: (Applicable (Comb repr), Alternable (Comb repr)) => Comb repr a -> Comb repr b -> Comb repr (Either a b) Source #

Applicable (Comb repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

(<$>) :: Haskell (a -> b) -> Comb repr a -> Comb repr b Source #

(<&>) :: Comb repr a -> Haskell (a -> b) -> Comb repr b Source #

(<$) :: Haskell a -> Comb repr b -> Comb repr a Source #

($>) :: Comb repr a -> Haskell b -> Comb repr b Source #

pure :: Haskell a -> Comb repr a Source #

(<*>) :: Comb repr (a -> b) -> Comb repr a -> Comb repr b Source #

liftA2 :: Haskell (a -> b -> c) -> Comb repr a -> Comb repr b -> Comb repr c Source #

(<*) :: Comb repr a -> Comb repr b -> Comb repr a Source #

(*>) :: Comb repr a -> Comb repr b -> Comb repr b Source #

(<**>) :: Comb repr a -> Comb repr (a -> b) -> Comb repr b Source #

(Applicable repr, Alternable repr, Selectable repr, Foldable repr, Lookable repr, Matchable repr, Letable Name repr) => Trans (Comb repr) repr Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

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

Satisfiable repr tok => Satisfiable (Comb repr) tok Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

satisfy :: [ErrorItem tok] -> Haskell (tok -> Bool) -> Comb repr tok Source #

Trans3 (Comb repr) (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

trans3 :: (Comb repr a -> Comb repr b -> Comb repr c -> Comb repr d) -> OptimizeComb letName repr a -> OptimizeComb letName repr b -> OptimizeComb letName repr c -> OptimizeComb letName repr d Source #

Trans2 (Comb repr) (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

trans2 :: (Comb repr a -> Comb repr b -> Comb repr c) -> OptimizeComb letName repr a -> OptimizeComb letName repr b -> OptimizeComb letName repr c Source #

Trans1 (Comb repr) (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

trans1 :: (Comb repr a -> Comb repr b) -> OptimizeComb letName repr a -> OptimizeComb letName repr b Source #

Trans (Comb repr) (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

trans :: Comb repr a -> OptimizeComb letName repr a Source #

Trans (OptimizeComb letName repr) (Comb repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

trans :: OptimizeComb letName repr a -> Comb repr a Source #

type Output (Comb repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

type Output (Comb repr) = repr

pattern (:<$>) :: Haskell (a -> b) -> Comb repr a -> Comb repr b infixl 4 Source #

pattern (:$>) :: Comb repr a -> Haskell b -> Comb repr b infixl 4 Source #

pattern (:<$) :: Haskell a -> Comb repr b -> Comb repr a infixl 4 Source #

pattern (:*>) :: Comb repr a -> Comb repr b -> Comb repr b infixl 4 Source #

pattern (:<*) :: Comb repr a -> Comb repr b -> Comb repr a infixl 4 Source #

Type OptimizeComb

newtype OptimizeComb letName repr a Source #

Constructors

OptimizeComb 

Fields

Instances

Instances details
Letable letName (Comb repr) => Letable letName (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

def :: letName -> OptimizeComb letName repr a -> OptimizeComb letName repr a Source #

ref :: Bool -> letName -> OptimizeComb letName repr a Source #

Trans3 (Comb repr) (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

trans3 :: (Comb repr a -> Comb repr b -> Comb repr c -> Comb repr d) -> OptimizeComb letName repr a -> OptimizeComb letName repr b -> OptimizeComb letName repr c -> OptimizeComb letName repr d Source #

Trans2 (Comb repr) (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

trans2 :: (Comb repr a -> Comb repr b -> Comb repr c) -> OptimizeComb letName repr a -> OptimizeComb letName repr b -> OptimizeComb letName repr c Source #

Trans1 (Comb repr) (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

trans1 :: (Comb repr a -> Comb repr b) -> OptimizeComb letName repr a -> OptimizeComb letName repr b Source #

Trans (Comb repr) (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

trans :: Comb repr a -> OptimizeComb letName repr a Source #

Lookable (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

look :: OptimizeComb letName repr a -> OptimizeComb letName repr a Source #

negLook :: OptimizeComb letName repr a -> OptimizeComb letName repr () Source #

eof :: OptimizeComb letName repr () Source #

Foldable (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

chainPre :: OptimizeComb letName repr (a -> a) -> OptimizeComb letName repr a -> OptimizeComb letName repr a Source #

chainPost :: OptimizeComb letName repr a -> OptimizeComb letName repr (a -> a) -> OptimizeComb letName repr a Source #

Matchable (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

conditional :: Eq a => [Haskell (a -> Bool)] -> [OptimizeComb letName repr b] -> OptimizeComb letName repr a -> OptimizeComb letName repr b -> OptimizeComb letName repr b Source #

match :: Eq a => [Haskell a] -> OptimizeComb letName repr a -> (Haskell a -> OptimizeComb letName repr b) -> OptimizeComb letName repr b -> OptimizeComb letName repr b Source #

Selectable (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

branch :: OptimizeComb letName repr (Either a b) -> OptimizeComb letName repr (a -> c) -> OptimizeComb letName repr (b -> c) -> OptimizeComb letName repr c Source #

Alternable (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

(<|>) :: OptimizeComb letName repr a -> OptimizeComb letName repr a -> OptimizeComb letName repr a Source #

empty :: OptimizeComb letName repr a Source #

try :: OptimizeComb letName repr a -> OptimizeComb letName repr a Source #

(<+>) :: (Applicable (OptimizeComb letName repr), Alternable (OptimizeComb letName repr)) => OptimizeComb letName repr a -> OptimizeComb letName repr b -> OptimizeComb letName repr (Either a b) Source #

Applicable (OptimizeComb letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

(<$>) :: Haskell (a -> b) -> OptimizeComb letName repr a -> OptimizeComb letName repr b Source #

(<&>) :: OptimizeComb letName repr a -> Haskell (a -> b) -> OptimizeComb letName repr b Source #

(<$) :: Haskell a -> OptimizeComb letName repr b -> OptimizeComb letName repr a Source #

($>) :: OptimizeComb letName repr a -> Haskell b -> OptimizeComb letName repr b Source #

pure :: Haskell a -> OptimizeComb letName repr a Source #

(<*>) :: OptimizeComb letName repr (a -> b) -> OptimizeComb letName repr a -> OptimizeComb letName repr b Source #

liftA2 :: Haskell (a -> b -> c) -> OptimizeComb letName repr a -> OptimizeComb letName repr b -> OptimizeComb letName repr c Source #

(<*) :: OptimizeComb letName repr a -> OptimizeComb letName repr b -> OptimizeComb letName repr a Source #

(*>) :: OptimizeComb letName repr a -> OptimizeComb letName repr b -> OptimizeComb letName repr b Source #

(<**>) :: OptimizeComb letName repr a -> OptimizeComb letName repr (a -> b) -> OptimizeComb letName repr b Source #

Trans (Comb repr) repr => Trans (OptimizeComb letName repr) repr Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

trans :: OptimizeComb letName repr a -> repr a Source #

Satisfiable repr tok => Satisfiable (OptimizeComb letName repr) tok Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

satisfy :: [ErrorItem tok] -> Haskell (tok -> Bool) -> OptimizeComb letName repr tok Source #

Trans (OptimizeComb letName repr) (Comb repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

Methods

trans :: OptimizeComb letName repr a -> Comb repr a Source #

type Output (OptimizeComb _letName repr) Source # 
Instance details

Defined in Symantic.Parser.Grammar.Optimize

type Output (OptimizeComb _letName repr) = Comb repr

optimizeComb :: Trans (OptimizeComb Name repr) repr => OptimizeComb Name repr a -> repr a Source #

optimizeCombNode :: Comb repr a -> Comb repr a Source #

Orphan instances

MakeLetName Name Source # 
Instance details