pinchot-0.24.0.0: Write grammars, not parsers

Safe HaskellNone
LanguageHaskell2010

Pinchot.SyntaxTree.Instancer

Synopsis

Documentation

bifunctorInstances :: [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 :: [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 :: [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 
-> [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.

prettyExpression :: Qualifier -> Rule t -> ExpQ Source #

Creates an expression of type

RuleData -> Value

prettyInstance :: Rule t -> DecQ Source #

Creates a PrettyVal instance. This must be spliced into the same module in which the corresponding data type is spliced.

prettyInstanceFamily :: Rule t -> DecsQ Source #

Creates a PrettyVal instance for a rule and all its ancestors.

prettyInstances :: [Rule t] -> DecsQ Source #

Creates a PrettyVal instance for each Rule in the Seq, as well as for all the ancestors of each Rule in the Seq.

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.

prettyExpressionInEnv Source #

Arguments

:: Qualifier 
-> Map RuleName Name

All expressions

-> Rule t 
-> ExpQ 

Creates an expression of type

RuleData -> Value

deconstruct Source #

Arguments

:: Name

Name of the constructor

-> Int

Create this many fields

-> ([ExpQ] -> ExpQ)

Each expression that results from each field is passed to this function.

-> Q (PatQ, ExpQ) 

Creates a MatchQ when given a value constructor name and functions that work on the field values.

prettyConstructor Source #

Arguments

:: Qualifier 
-> Map RuleName Name 
-> String

Name of branch, or name of data constructor

-> [Rule t] 
-> Q (PatQ, ExpQ)