deep-transformations-0.4.0.1: Deep natural and unnatural tree transformations, including attribute grammars
Safe HaskellNone
LanguageHaskell2010

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

Documentation

newtype Auto t Source #

Transformation wrapper that allows automatic inference of attribute rules.

Constructors

Auto t 

Instances

Instances details
(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 # 
Instance details

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 # 
Instance details

Defined in Transformation.AG.Monomorphic

Methods

($) :: Auto t -> Domain (Auto t) (g (Semantics a) (Semantics a)) -> Codomain (Auto t) (g (Semantics a) (Semantics a)) Source #

newtype Keep t Source #

Transformation wrapper that allows automatic inference of attribute rules and preservation of the attribute with the original nodes.

Constructors

Keep t 

type Atts a = Atts a a Source #

pattern Atts :: a -> a -> Atts a Source #

inh :: Atts a -> a Source #

syn :: Atts a -> a Source #

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

Instances details
AttributeTransformation t => Attribution t g Source # 
Instance details

Defined in Transformation.AG.Monomorphic

Methods

attribution :: t -> Domain t (g (Codomain t) (Codomain t)) -> Rule (Attributes t) Source #

knit :: (Foldable (g sem), sem ~ Semantics a b, Monoid a, Monoid b) => Rule a b -> g sem sem -> sem (g sem sem) Source #

The core function to tie the recursive knot, turning a Rule for a node into its Semantics.

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 Source #

Drop-in implementation of $

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) Source #

Drop-in implementation of <$>