| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Transformation.AG.Dimorphic
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 T t = T t
- newtype Auto t = Auto t
- data Atts a b = Atts {}
- type Semantics a b = Const (a -> b) :: Type -> Type
- type Rule a b = Atts a b -> Atts a b
- class Attribution t where
- class Attribution t => At t (g :: (Type -> Type) -> (Type -> Type) -> Type) where
- attribution :: forall (f :: Type -> Type). Functor (g f) => t -> Origin t (g f f) -> Rule (Inherited t) (Synthesized t)
- knit :: (Foldable (g sem), sem ~ Semantics a b, Monoid a, Monoid b) => Rule a b -> g sem sem -> sem (g sem sem)
Documentation
Wrapper that provides a Transformation instance for any Attribution
Constructors
| T t |
Instances
| Attribution t => Transformation (T t) Source # | |||||||||
Defined in Transformation.AG.Dimorphic Associated Types
| |||||||||
| (Attribution t, At t g, p ~ Origin t, a ~ Inherited t, b ~ Synthesized t, q ~ Semantics a b, Monoid a, Monoid b, Foldable p, Functor p, Foldable (g q), Functor (g p), Functor (g q), Functor (T t) g) => Functor (T t) g Source # | |||||||||
Defined in Transformation.AG.Dimorphic Methods (<$>) :: T t -> Domain (T t) (g (Domain (T t)) (Domain (T t))) -> Codomain (T t) (g (Codomain (T t)) (Codomain (T t))) Source # coerce :: (T t ~ Coercion p0 q0, forall (h :: (Type -> Type) -> (Type -> Type) -> Type). Coercible (p0 (h p0 p0)) (q0 (h q0 q0))) => p0 (g p0 p0) -> q0 (g q0 q0) Source # | |||||||||
| (Attribution t, p ~ Origin t, a ~ Inherited t, b ~ Synthesized t, q ~ Semantics a b, Foldable (g q), Functor (g q), Monoid a, Monoid b, Foldable p, At t g) => At (T t) (g (Semantics a b) (Semantics a b)) Source # | |||||||||
| type Codomain (T t) Source # | |||||||||
Defined in Transformation.AG.Dimorphic | |||||||||
| type Domain (T t) Source # | |||||||||
Defined in Transformation.AG.Dimorphic | |||||||||
Wrapper that provides a default Attribution and (via AG.Knit) Transformation instance for any Attribution
Constructors
| Auto t |
Instances
| (Attribution t, Foldable (Origin t)) => Attribution (Auto t) Source # | |
| (Attribution t, f ~ Origin t, Foldable f, At t g, Foldable (g (Semantics (Auto t))), Functor (g (Semantics (Auto t))), Monoid (Synthesized t)) => At (Auto t) g Source # | |
Defined in Transformation.AG.Dimorphic | |
| type Origin (Auto t) Source # | |
Defined in Transformation.AG.Dimorphic | |
| type Atts (Inherited (Auto t)) g Source # | |
Defined in Transformation.AG.Dimorphic | |
| type Atts (Synthesized (Auto t)) g Source # | |
Defined in Transformation.AG.Dimorphic | |
Node attributes
Instances
| (Data a, Data b) => Data (Atts a b) Source # | |
Defined in Transformation.AG.Dimorphic Methods gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Atts a b -> c (Atts a b) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Atts a b) # toConstr :: Atts a b -> Constr # dataTypeOf :: Atts a b -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Atts a b)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Atts a b)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Atts a b -> Atts a b # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Atts a b -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Atts a b -> r # gmapQ :: (forall d. Data d => d -> u) -> Atts a b -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Atts a b -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Atts a b -> m (Atts a b) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Atts a b -> m (Atts a b) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Atts a b -> m (Atts a b) # | |
| (Monoid a, Monoid b) => Monoid (Atts a b) Source # | |
| (Semigroup a, Semigroup b) => Semigroup (Atts a b) Source # | |
| (Show a, Show b) => Show (Atts a b) Source # | |
type Semantics a b = Const (a -> b) :: Type -> Type Source #
A node's Semantics maps its inherited attribute to its synthesized attribute.
type Rule a b = Atts a b -> Atts a b Source #
An attribution rule maps a node's inherited attribute and its child nodes' synthesized attributes to the node's synthesized attribute and the children nodes' inherited attributes.
class Attribution t where Source #
Class of transformations that assign the same type of inherited and synthesized attributes to every node.
class Attribution t => At 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 MyAttGrammar `At` MyNode where
attribution MyAttGrammar{} (Identity MyNode{})
Atts{inh= fromParent,
syn= fromChildren}
= Atts{syn= toParent,
inh= toChildren}Methods
attribution :: forall (f :: Type -> Type). Functor (g f) => t -> Origin t (g f f) -> Rule (Inherited t) (Synthesized t) Source #
The attribution rule for a given transformation and node.
Instances
| Attribution t => At t g Source # | |
Defined in Transformation.AG.Dimorphic Methods attribution :: forall (f :: Type -> Type). Functor (g f) => t -> Origin t (g f f) -> Rule (Inherited t) (Synthesized t) Source # | |