Safe Haskell  None 

Language  Haskell2010 
An attribute grammar is a particular kind of Transformation
that assigns attributes to nodes in a
tree. Different node types may have different types of attributes, so the transformation is not natural. All
attributes are divided into Inherited
and Synthesized
attributes.
Synopsis
 type family Atts (f :: * > *) a
 newtype Inherited t a = Inherited {}
 newtype Synthesized t a = Synthesized {
 syn :: Atts (Synthesized t) a
 type Semantics t = Inherited t ~> Synthesized t
 type Rule t g = forall sem. sem ~ Semantics t => (Inherited t (g sem sem), g sem (Synthesized t)) > (Synthesized t (g sem sem), g sem (Inherited t))
 knit :: (Apply (g sem), sem ~ Semantics t) => Rule t g > g sem sem > sem (g sem sem)
 class Attribution t g deep shallow where
 attribution :: t > shallow (g deep deep) > Rule t g
 applyDefault :: (q ~ Semantics t, x ~ g q q, Apply (g q), Attribution t g q p) => (forall a. p a > a) > t > p x > q x
 fullMapDefault :: (p ~ Domain t, q ~ Semantics t, q ~ Codomain t, x ~ g q q, Apply (g q), Functor t g, Attribution t g p p) => (forall a. p a > a) > t > p (g p p) > q (g q q)
Documentation
type family Atts (f :: * > *) a Source #
Type family that maps a node type to the type of its attributes, indexed per type constructor.
newtype Inherited t a Source #
Type constructor wrapping the inherited attributes for the given transformation.
newtype Synthesized t a Source #
Type constructor wrapping the synthesized attributes for the given transformation.
Synthesized  

Instances
(sem ~ Semantics t, Domain t ~ shallow, Revelation t shallow, Functor (PassDown t sem (Atts (Inherited t) (g sem sem))) (g sem)) => Bequether t g (Semantics t) shallow Source #  
Show (Atts (Synthesized t) a) => Show (Synthesized t a) Source #  
Defined in Transformation.AG showsPrec :: Int > Synthesized t a > ShowS # show :: Synthesized t a > String # showList :: [Synthesized t a] > ShowS # 
type Semantics t = Inherited t ~> Synthesized t Source #
A node's Semantics
is a natural tranformation from the node's inherited attributes to its synthesized
attributes.
type Rule t g = forall sem. sem ~ Semantics t => (Inherited t (g sem sem), g sem (Synthesized t)) > (Synthesized t (g sem sem), g sem (Inherited t)) Source #
An attribution rule maps a node's inherited attributes and its child nodes' synthesized attributes to the node's synthesized attributes and the children nodes' inherited attributes.
class Attribution t g deep shallow where Source #
The core type class for defining the attribute grammar. The instances of this class typically have a form like
instance Attribution MyAttGrammar MyNode (Semantics MyAttGrammar) Identity where attribution MyAttGrammar{} (Identity MyNode{}) (Inherited fromParent, Synthesized MyNode{firstChild= fromFirstChild, ...}) = (Synthesized _forMyself, Inherited MyNode{firstChild= _forFirstChild, ...})
If you prefer to separate the calculation of different attributes, you can split the above instance into two
instances of the Bequether
and Synthesizer
classes
instead. If you derive Generic
instances for your attributes, you can even define each synthesized
attribute individually with a SynthesizedField
instance.
attribution :: t > shallow (g deep deep) > Rule t g Source #
The attribution rule for a given transformation and node.
Instances
(Bequether (Auto t) g d s, Synthesizer (Auto t) g d s) => Attribution (Auto t) g d s Source #  
Defined in Transformation.AG.Generics 
applyDefault :: (q ~ Semantics t, x ~ g q q, Apply (g q), Attribution t g q p) => (forall a. p a > a) > t > p x > q x Source #
Dropin implementation of $
fullMapDefault :: (p ~ Domain t, q ~ Semantics t, q ~ Codomain t, x ~ g q q, Apply (g q), Functor t g, Attribution t g p p) => (forall a. p a > a) > t > p (g p p) > q (g q q) Source #
Dropin implementation of <$>