| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Transformation.AG.Monomorphic
Description
A special case of an attribute grammar where every node has only a single inherited and a single synthesized
attribute of the same monoidal type. The synthesized attributes of child nodes are all mconcatted together.
Synopsis
- newtype Auto t = Auto t
- newtype Keep t = Keep t
- type Atts a = Atts a a
- pattern Atts :: a -> a -> Atts a
- inh :: Atts a -> a
- syn :: Atts a -> a
- type Semantics a = Const (a -> a) :: Type -> Type
- type Rule a = Atts a -> Atts a
- class AttributeTransformation t => Attribution t (g :: (Type -> Type) -> (Type -> Type) -> Type) where
- attribution :: t -> Domain t (g (Codomain t) (Codomain t)) -> Rule (Attributes t)
- knit :: (Foldable (g sem), sem ~ Semantics a b, Monoid a, Monoid b) => Rule a b -> g sem sem -> sem (g sem sem)
- applyDefault :: forall a t q x (g :: (Type -> Type) -> (Type -> Type) -> Type). (a ~ Attributes t, q ~ Codomain t, q ~ Semantics a, x ~ g q q, Foldable (g q), Attribution t g, Monoid a) => (forall y. Domain t y -> y) -> t -> Domain t x -> q x
- fullMapDefault :: (p ~ Domain t, q ~ Semantics a, a ~ Attributes t, q ~ Codomain t, x ~ g q q, Foldable (g q), Functor p, Functor t g, Attribution t g, Monoid a) => (forall y. p y -> y) -> t -> p (g p p) -> q (g q q)
Documentation
Transformation wrapper that allows automatic inference of attribute rules.
Constructors
| Auto t |
Instances
| (Transformation (Auto t), Domain (Auto t) ~ f, Functor f, Codomain (Auto t) ~ Semantics a, Functor (g f), Functor (Auto t) g, At (Auto t) (g (Semantics a) (Semantics a))) => Functor (Auto t) g Source # | |
Defined in Transformation.AG.Monomorphic Methods (<$>) :: Auto t -> Domain (Auto t) (g (Domain (Auto t)) (Domain (Auto t))) -> Codomain (Auto t) (g (Codomain (Auto t)) (Codomain (Auto t))) Source # coerce :: (Auto t ~ Coercion p q, forall (h :: (Type -> Type) -> (Type -> Type) -> Type). Coercible (p (h p p)) (q (h q q))) => p (g p p) -> q (g q q) Source # | |
| (Transformation (Auto t), p ~ Domain (Auto t), q ~ Codomain (Auto t), q ~ Semantics a, a ~ Attributes (Auto t), Foldable (g q), Monoid a, Foldable p, Attribution (Auto t) g) => At (Auto t) (g (Semantics a) (Semantics a)) Source # | |
Transformation wrapper that allows automatic inference of attribute rules and preservation of the attribute with the original nodes.
Constructors
| Keep t |
type Semantics a = Const (a -> a) :: Type -> Type Source #
A node's Semantics maps its inherited attribute to its synthesized attribute.
type Rule a = Atts a -> Atts a Source #
An attribution rule maps a node's inherited attribute and its child nodes' synthesized attribute to the node's synthesized attribute and the children nodes' inherited attributes.
class AttributeTransformation t => Attribution t (g :: (Type -> Type) -> (Type -> Type) -> Type) where Source #
The core type class for defining the attribute grammar. The instances of this class typically have a form like
instance Attribution MyAttGrammar MyMonoid MyNode (Semantics MyAttGrammar) Identity where
attribution MyAttGrammar{} (Identity MyNode{})
Atts{inh= fromParent,
syn= fromChildren}
= Atts{syn= toParent,
inh= toChildren}Methods
attribution :: t -> Domain t (g (Codomain t) (Codomain t)) -> Rule (Attributes t) Source #
The attribution rule for a given transformation and node.
Instances
| AttributeTransformation t => Attribution t g Source # | |
Defined in Transformation.AG.Monomorphic | |
knit :: (Foldable (g sem), sem ~ Semantics a b, Monoid a, Monoid b) => Rule a b -> g sem sem -> sem (g sem sem) Source #