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

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

Documentation

newtype T t Source #

Wrapper that provides a Transformation instance for any Attribution

Constructors

T t 

Instances

Instances details
Attribution t => Transformation (T t) Source # 
Instance details

Defined in Transformation.AG.Dimorphic

Associated Types

type Domain (T t) 
Instance details

Defined in Transformation.AG.Dimorphic

type Domain (T t) = Origin t
type Codomain (T t) 
Instance details

Defined in Transformation.AG.Dimorphic

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

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

Defined in Transformation.AG.Dimorphic

Methods

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

type Codomain (T t) Source # 
Instance details

Defined in Transformation.AG.Dimorphic

type Domain (T t) Source # 
Instance details

Defined in Transformation.AG.Dimorphic

type Domain (T t) = Origin t

newtype Auto t Source #

Wrapper that provides a default Attribution and (via AG.Knit) Transformation instance for any Attribution

Constructors

Auto t 

Instances

Instances details
(Attribution t, Foldable (Origin t)) => Attribution (Auto t) Source # 
Instance details

Defined in Transformation.AG.Dimorphic

Associated Types

type Origin (Auto t) 
Instance details

Defined in Transformation.AG.Dimorphic

type Origin (Auto t) = Origin t

Methods

unwrap :: Auto t -> Origin (Auto t) x -> x 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 # 
Instance details

Defined in Transformation.AG.Dimorphic

Methods

attribution :: forall (sem :: Type -> Type). Traversable (g sem) => Auto t -> Origin (Auto t) (g sem sem) -> (Inherited (Auto t) (g sem sem), g sem (Synthesized (Auto t))) -> (Synthesized (Auto t) (g sem sem), g sem (Inherited (Auto t))) Source #

type Origin (Auto t) Source # 
Instance details

Defined in Transformation.AG.Dimorphic

type Origin (Auto t) = Origin t
type Atts (Inherited (Auto t)) g Source # 
Instance details

Defined in Transformation.AG.Dimorphic

type Atts (Inherited (Auto t)) g = Inherited t
type Atts (Synthesized (Auto t)) g Source # 
Instance details

Defined in Transformation.AG.Dimorphic

type Atts (Synthesized (Auto t)) g = Synthesized t

data Atts a b Source #

Node attributes

Constructors

Atts 

Fields

  • inh :: a

    inherited

  • syn :: b

    synthesized

Instances

Instances details
(Data a, Data b) => Data (Atts a b) Source # 
Instance details

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

Defined in Transformation.AG.Dimorphic

Methods

mempty :: Atts a b #

mappend :: Atts a b -> Atts a b -> Atts a b #

mconcat :: [Atts a b] -> Atts a b #

(Semigroup a, Semigroup b) => Semigroup (Atts a b) Source # 
Instance details

Defined in Transformation.AG.Dimorphic

Methods

(<>) :: Atts a b -> Atts a b -> Atts a b #

sconcat :: NonEmpty (Atts a b) -> Atts a b #

stimes :: Integral b0 => b0 -> Atts a b -> Atts a b #

(Show a, Show b) => Show (Atts a b) Source # 
Instance details

Defined in Transformation.AG.Dimorphic

Methods

showsPrec :: Int -> Atts a b -> ShowS #

show :: Atts a b -> String #

showList :: [Atts a b] -> ShowS #

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.

Associated Types

type Origin t :: Type -> Type Source #

type Inherited t Source #

type Synthesized t Source #

Methods

unwrap :: t -> Origin t x -> x Source #

Unwrap the value from the original attribution domain

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

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

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 #

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.