pinchot-0.18.2.0: Write grammars, not parsers

Safe HaskellNone
LanguageHaskell2010

Pinchot.SyntaxTree.Instancer

Synopsis

Documentation

bifunctorInstances :: Seq (Rule t) -> DecsQ Source #

Creates an instance of Bifunctor for every Rule in the Seq as well as their ancestors.

This function must be spliced in the same module as the module in which the syntax tree types are created. This avoids problems with orphan instances. Since ancestors are included, you can get the entire tree of instances that you need by applying this function to a single start symbol.

Example: Pinchot.Examples.SyntaxTrees.

semigroupInstances :: Seq (Rule t) -> DecsQ Source #

Where possible, creates an instance of Semigroup for every Rule in the Seq as well as their ancestors. Only star and plus rules, as well as rules that through one or more layers of wrap ultimately wrap a star or plus rule, get a Semigroup instance.

This function must be spliced in the same module as the module in which the syntax tree types are created. This avoids problems with orphan instances. Since ancestors are included, you can get the entire tree of instances that you need by applying this function to a single start symbol.

Example: Pinchot.Examples.SyntaxTrees.

monoidInstances :: Seq (Rule t) -> DecsQ Source #

Where possible, creates an instance of Monoid for every Rule in the Seq as well as their ancestors. Only star rules, as well as rules that through one or more layers of wrap ultimately wrap a star rule, get a Monoid instance.

This function must be spliced in the same module as the module in which the syntax tree types are created. This avoids problems with orphan instances. Since ancestors are included, you can get the entire tree of instances that you need by applying this function to a single start symbol.

Example: Pinchot.Examples.SyntaxTrees.

bimapLetBinds Source #

Arguments

:: Qualifier 
-> Name
(a -> b)
-> Name
(c -> d)
-> Map RuleName Name

Looks up names for other let binds

-> Rule t 
-> Q [DecQ] 

bimapLetBind Source #

Arguments

:: Qualifier 
-> Name
(a -> b)
-> Name
(c -> d)
-> Map RuleName Name 
-> Rule t 
-> Q DecQ 

optBimapLetBind Source #

Arguments

:: Qualifier 
-> Map RuleName Name 
-> RuleName

Name of this rule

-> RuleName

Name of inner rule

-> Q DecQ 

starBimapLetBind Source #

Arguments

:: Qualifier 
-> Map RuleName Name 
-> RuleName

Name of this rule

-> RuleName

Name of inner rule

-> Q DecQ 

plusBimapLetBind Source #

Arguments

:: Qualifier 
-> Map RuleName Name 
-> RuleName

Name of this rule

-> RuleName

Name of inner rule

-> Q DecQ 

errLookup :: (Ord a, Show a) => a -> Map a b -> b Source #

nameMap :: Rule t -> Q (Map RuleName Name) Source #

Creates a map of all ancestor rule names and a corresponding TH name.

memptyExpression :: Qualifier -> Rule t -> Maybe ExpQ Source #

If possible, creates an expression of type

RuleData

which is a Monoid mempty.

mappendExpression :: Qualifier -> Rule t -> Maybe ExpQ Source #

If possible, creates an expression of type

RuleData -> RuleData -> RuleData

which is a Monoid mappend.

semigroupExpression :: Qualifier -> Rule t -> Maybe ExpQ Source #

If possible, creates an expression of type

RuleData -> RuleData -> RuleData

which is a Semigroup <>.

wrappedSemigroupExpression Source #

Arguments

:: Name

mappend operator

-> Qualifier 
-> Seq RuleName

Rule names, with the outermost name on the left side of the Seq.

-> ExpQ

An expression of type

RuleData -> RuleData -> RuleData

It unwraps the two argument types, uses the Semigroup <> operator to combine them, and rewraps the result.