pinchot-0.24.0.0: Write grammars, not parsers

Safe HaskellNone
LanguageHaskell2010

Pinchot.SyntaxTree.Optics

Synopsis

Documentation

rulesToOptics Source #

Arguments

:: (Lift t, Data t) 
=> Qualifier

Qualifier for module containing the data types that will get optics

-> Name

Type name for the terminal

-> [Rule t] 
-> Q [Dec] 

Creates optics declarations for a Rule, if optics can be made for the Rule:

Each rule in the sequence of Rule, as well as all ancestors of those Rules, will be handled.

Example: Pinchot.Examples.RulesToOptics.

ruleToOptics Source #

Arguments

:: (Lift t, Data t) 
=> Qualifier

Qualifier for module containing the data type that will get optics

-> Name

Type name for the terminal

-> Rule t 
-> Q [Dec] 

Creates optics declarations for a single Rule, if optics can be made for the Rule:

terminalToOptics Source #

Arguments

:: Lift t 
=> Qualifier

Qualifier for module containing the data type that will get optics

-> Name

Terminal type name

-> String

Rule name

-> Predicate t 
-> Q [Dec] 

Creates a prism for a terminal type. Although a newtype wraps each terminal, do not make a Wrapped or an Iso, because the relationship between the outer type and the type that it wraps typically is not isometric. Thus, use a Prism instead, which captures this relationship properly.

seriesToOptics Source #

Arguments

:: (Data t, Lift t) 
=> Qualifier

Qualifier for module containing the data type that will get optics

-> Name

Terminal type name

-> String

Rule name

-> NonEmpty t 
-> Q [Dec] 

prismSignature Source #

Arguments

:: Qualifier 
-> String

Rule name

-> Branch t 
-> DecQ 

setterPatAndExpn Source #

Arguments

:: Qualifier 
-> BranchName 
-> [a]

List of rules

-> Q (PatQ, ExpQ) 

rightPatternAndExpression Source #

Arguments

:: Qualifier 
-> BranchName 
-> Int

Number of fields

-> Q (PatQ, ExpQ) 

Returns a pattern and expression to match a particular branch; if there is a match, the expression will return each field, in a tuple in a Right.

leftPatternAndExpression Source #

Arguments

:: [a]

List of all other branches

-> Maybe (Q (PatQ, ExpQ)) 

Returns a pattern and expression for branches that did not match. Does not return anything if there are no other branches.

prismGetter Source #

Arguments

:: Qualifier 
-> Branch t

Make prism for this branch

-> [Branch t]

List of all branches

-> ExpQ 

nonTerminalToOptics Source #

Arguments

:: Qualifier

Qualifier for module containing the data type that will get optics

-> String

Rule name

-> NonEmpty (Branch t) 
-> [Q Dec] 

Creates prisms for each Branch.

recordLensSignature Source #

Arguments

:: Qualifier 
-> RuleName

Name of the main rule

-> RuleName

Name of the rule for this lens

-> Int

Index for this lens

-> DecQ 

recordLensGetter Source #

Arguments

:: Qualifier 
-> String

Record field name

-> ExpQ 

recordLensSetter Source #

Arguments

:: Qualifier 
-> String

Record field name

-> ExpQ 

recordLensFunction Source #

Arguments

:: Qualifier 
-> RuleName

Name of the main rule

-> RuleName

Name of the rule for this lens

-> Int

Index for this lens

-> DecQ 

recordsToOptics Source #

Arguments

:: Qualifier

Qualifier for module containing the data type that will get optics

-> String

Rule name

-> [Rule t] 
-> [Q Dec]