-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | This library builds on the rank2classes package to provide the -- equivalents of Functor and related classes for heterogenous -- trees, including complex abstract syntax trees of real-world -- programming languages. -- -- The functionality includes attribute grammars in -- Transformation.AG. @package deep-transformations @version 0.3 -- | A natural transformation is a concept from category theory for -- a mapping between two functors and their objects that preserves a -- naturality condition. In Haskell the naturality condition boils down -- to parametricity, so a natural transformation between two functors -- f and g is represented as -- --
-- type NaturalTransformation f g = ∀a. f a → g a ---- -- This type appears in several Haskell libraries, most obviously in -- natural-transformations. There are times, however, when we -- crave more control. Sometimes what we want to do depends on which type -- a is hiding in that f a we're given. Sometimes, in -- other words, we need an unnatural transformation. -- -- This means we have to abandon parametricity for ad-hoc polymorphism, -- and that means type classes. There are two steps to defining a -- transformation: -- --
-- >>> :{
-- data MaybeToList = MaybeToList
-- instance Transformation MaybeToList where
-- type Domain MaybeToList = Maybe
-- type Codomain MaybeToList = []
-- :}
--
class Transformation t where {
type Domain t :: Type -> Type;
type Codomain t :: Type -> Type;
}
-- | Before we can apply a Transformation, we also need to declare
-- At which base types it is applicable and how it works. If the
-- transformation is natural, we'll need only one instance declaration.
--
--
-- >>> :{
-- instance MaybeToList `Transformation.At` a where
-- MaybeToList $ Just x = [x]
-- MaybeToList $ Nothing = []
-- :}
--
--
-- -- >>> MaybeToList Transformation.$ (Just True) -- [True] ---- -- An unnatural Transformation can behave differently depending on -- the base type and even on its value. -- --
-- >>> :{
-- instance {-# OVERLAPS #-} MaybeToList `At` Char where
-- MaybeToList $ Just '\0' = []
-- MaybeToList $ Just c = [c]
-- MaybeToList $ Nothing = []
-- :}
--
class Transformation t => At t x
-- | Apply the transformation t at type x to map
-- Domain to the Codomain functor.
($) :: At t x => t -> Domain t x -> Codomain t x
infixr 0 $
-- | Alphabetical synonym for $
apply :: t `At` x => t -> Domain t x -> Codomain t x
-- | Composition of two transformations
data Compose t u
Compose :: t -> u -> Compose t u
-- | Transformation under a Functor
newtype Mapped (f :: Type -> Type) t
Mapped :: t -> Mapped (f :: Type -> Type) t
-- | Transformation under a Foldable
newtype Folded (f :: Type -> Type) t
Folded :: t -> Folded (f :: Type -> Type) t
-- | Transformation under a Traversable
newtype Traversed (f :: Type -> Type) t
Traversed :: t -> Traversed (f :: Type -> Type) t
type family ComposeOuter (c :: Type -> Type) :: Type -> Type
type family ComposeInner (c :: Type -> Type) :: Type -> Type
instance (Transformation.Transformation t, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m n) => Transformation.Transformation (Transformation.Traversed f t)
instance (Transformation.At t x, Data.Traversable.Traversable f, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m n, GHC.Base.Applicative m) => Transformation.At (Transformation.Traversed f t) x
instance Transformation.Transformation t => Transformation.Transformation (Transformation.Folded f t)
instance (Transformation.At t x, Data.Foldable.Foldable f, Transformation.Codomain t GHC.Types.~ Data.Functor.Const.Const m, GHC.Base.Monoid m) => Transformation.At (Transformation.Folded f t) x
instance Transformation.Transformation t => Transformation.Transformation (Transformation.Mapped f t)
instance (Transformation.At t x, GHC.Base.Functor f) => Transformation.At (Transformation.Mapped f t) x
instance (Transformation.Transformation t, Transformation.Transformation u, Transformation.Domain t GHC.Types.~ Transformation.Codomain u) => Transformation.Transformation (Transformation.Compose t u)
instance (Transformation.At t x, Transformation.At u x, Transformation.Domain t GHC.Types.~ Transformation.Codomain u) => Transformation.At (Transformation.Compose t u) x
instance Transformation.At (Rank2.Arrow p q x) x
instance (Transformation.At t x, Transformation.At u x, Transformation.Domain t GHC.Types.~ Transformation.Domain u) => Transformation.At (t, u) x
instance (Transformation.At t x, Transformation.At u x, Transformation.Domain t GHC.Types.~ Transformation.Domain u) => Transformation.At (Data.Either.Either t u) x
instance Transformation.Transformation (Rank2.Arrow p q x)
instance (Transformation.Transformation t1, Transformation.Transformation t2, Transformation.Domain t1 GHC.Types.~ Transformation.Domain t2) => Transformation.Transformation (t1, t2)
instance (Transformation.Transformation t1, Transformation.Transformation t2, Transformation.Domain t1 GHC.Types.~ Transformation.Domain t2) => Transformation.Transformation (Data.Either.Either t1 t2)
-- | 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.
module Transformation.AG
-- | Type family that maps a node type to the type of its attributes,
-- indexed per type constructor.
type family Atts (f :: Type -> Type) a
-- | Type constructor wrapping the inherited attributes for the given
-- transformation.
newtype Inherited t a
Inherited :: Atts (Inherited t) a -> Inherited t a
[inh] :: Inherited t a -> Atts (Inherited t) a
-- | Type constructor wrapping the synthesized attributes for the given
-- transformation.
newtype Synthesized t a
Synthesized :: Atts (Synthesized t) a -> Synthesized t a
[syn] :: Synthesized t a -> Atts (Synthesized t) a
-- | A node's Semantics is a natural tranformation from the node's
-- inherited attributes to its synthesized attributes.
type Semantics t = Inherited t ~> Synthesized t
-- | A node's PreservingSemantics is a natural tranformation from
-- the node's inherited attributes to all its attributes paired with the
-- preserved node.
type PreservingSemantics t f = Arrow (Inherited t) (Product (AllAtts t) f)
-- | All inherited and synthesized attributes
data AllAtts t a
AllAtts :: Atts (Inherited t) a -> Atts (Synthesized t) a -> AllAtts t a
[allInh] :: AllAtts t a -> Atts (Inherited t) a
[allSyn] :: AllAtts t a -> Atts (Synthesized t) a
-- | 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.
type Rule t g = forall sem. sem ~ Semantics t => (Inherited t (g sem (Semantics t)), g sem (Synthesized t)) -> (Synthesized t (g sem (Semantics t)), g sem (Inherited t))
-- | The core function to tie the recursive knot, turning a Rule for
-- a node into its Semantics.
knit :: (Apply (g sem), sem ~ Semantics t) => Rule t g -> g sem sem -> sem (g sem sem)
-- | Another way to tie the recursive knot, using a Rule to add
-- AllAtts information to every node
knitKeeping :: forall t f g sem. (sem ~ PreservingSemantics t f, Apply (g sem), Atts (Inherited t) (g sem sem) ~ Atts (Inherited t) (g (Semantics t) (Semantics t)), Atts (Synthesized t) (g sem sem) ~ Atts (Synthesized t) (g (Semantics t) (Semantics t)), g sem (Synthesized t) ~ g (Semantics t) (Synthesized t), g sem (Inherited t) ~ g (Semantics t) (Inherited t)) => (forall a. f a -> a) -> Rule t g -> f (g (PreservingSemantics t f) (PreservingSemantics t f)) -> PreservingSemantics t f (g (PreservingSemantics t f) (PreservingSemantics t f))
-- | 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.
class Attribution t g deep shallow
-- | The attribution rule for a given transformation and node.
attribution :: Attribution t g deep shallow => t -> shallow (g deep deep) -> Rule t g
-- | Drop-in implementation of $
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
-- | Drop-in implementation of $ that preserves all attributes with
-- every original node
applyDefaultWithAttributes :: (p ~ Domain t, q ~ PreservingSemantics t p, x ~ g q q, Apply (g q), Atts (Inherited t) (g q q) ~ Atts (Inherited t) (g (Semantics t) (Semantics t)), Atts (Synthesized t) (g q q) ~ Atts (Synthesized t) (g (Semantics t) (Semantics t)), g q (Synthesized t) ~ g (Semantics t) (Synthesized t), g q (Inherited t) ~ g (Semantics t) (Inherited t), Attribution t g (PreservingSemantics t p) p) => (forall a. p a -> a) -> t -> p (g (PreservingSemantics t p) (PreservingSemantics t p)) -> PreservingSemantics t p (g (PreservingSemantics t p) (PreservingSemantics t p))
instance GHC.Show.Show (Transformation.AG.Atts (Transformation.AG.Inherited t) a) => GHC.Show.Show (Transformation.AG.Inherited t a)
instance GHC.Show.Show (Transformation.AG.Atts (Transformation.AG.Synthesized t) a) => GHC.Show.Show (Transformation.AG.Synthesized t a)
-- | Type classes Functor, Foldable, and Traversable
-- that correspond to the standard type classes of the same name, but
-- applying the given transformation to the given tree node and all its
-- descendants. The corresponding classes in the
-- Transformation.Shallow moduleo perate only on the immediate
-- children, while those from the Transformation.Deep module
-- exclude the argument node itself.
module Transformation.Full
-- | Like Transformation.Deep.Functor except it maps an
-- additional wrapper around the entire tree
class (Transformation t, Functor (g (Domain t))) => Functor t g
(<$>) :: Functor t g => t -> Domain t (g (Domain t) (Domain t)) -> Codomain t (g (Codomain t) (Codomain t))
infixl 4 <$>
-- | Like Transformation.Deep.Foldable except the entire tree
-- is also wrapped
class (Transformation t, Foldable (g (Domain t))) => Foldable t g
foldMap :: (Foldable t g, Codomain t ~ Const m, Monoid m) => t -> Domain t (g (Domain t) (Domain t)) -> m
-- | Like Transformation.Deep.Traversable except it traverses
-- an additional wrapper around the entire tree
class (Transformation t, Traversable (g (Domain t))) => Traversable t g
traverse :: (Traversable t g, Codomain t ~ Compose m f) => t -> Domain t (g (Domain t) (Domain t)) -> m (f (g f f))
-- | Alphabetical synonym for <$>
fmap :: Functor t g => t -> Domain t (g (Domain t) (Domain t)) -> Codomain t (g (Codomain t) (Codomain t))
-- | Default implementation for <$> that maps the wrapper and
-- then the tree
mapDownDefault :: (Functor t g, t `At` g (Domain t) (Domain t), Functor (Codomain t)) => t -> Domain t (g (Domain t) (Domain t)) -> Codomain t (g (Codomain t) (Codomain t))
-- | Default implementation for <$> that maps the tree and
-- then the wrapper
mapUpDefault :: (Functor t g, t `At` g (Codomain t) (Codomain t), Functor (Domain t)) => t -> Domain t (g (Domain t) (Domain t)) -> Codomain t (g (Codomain t) (Codomain t))
-- | Default implementation for foldMap that folds the wrapper and
-- then the tree
foldMapDownDefault :: (t `At` g (Domain t) (Domain t), Foldable t g, Codomain t ~ Const m, Foldable (Domain t), Monoid m) => t -> Domain t (g (Domain t) (Domain t)) -> m
-- | Default implementation for foldMap that folds the tree and then
-- the wrapper
foldMapUpDefault :: (t `At` g (Domain t) (Domain t), Foldable t g, Codomain t ~ Const m, Foldable (Domain t), Monoid m) => t -> Domain t (g (Domain t) (Domain t)) -> m
-- | Default implementation for traverse that traverses the wrapper
-- and then the tree
traverseDownDefault :: (Traversable t g, t `At` g (Domain t) (Domain t), Codomain t ~ Compose m f, Traversable f, Monad m) => t -> Domain t (g (Domain t) (Domain t)) -> m (f (g f f))
-- | Default implementation for traverse that traverses the tree and
-- then the wrapper
traverseUpDefault :: (Traversable t g, Codomain t ~ Compose m f, t `At` g f f, Traversable (Domain t), Monad m) => t -> Domain t (g (Domain t) (Domain t)) -> m (f (g f f))
-- | Type classes Functor, Foldable, and Traversable
-- that correspond to the standard type classes of the same name, but
-- applying the given transformation to every descendant of the given
-- tree node. The corresponding classes in the
-- Transformation.Shallow module operate only on the immediate
-- children, while those from the Transformation.Full module
-- include the argument node itself.
module Transformation.Deep
-- | Like Transformation.Shallow.Functor except it maps all
-- descendants and not only immediate children
class (Transformation t, Functor (g (Domain t))) => Functor t g
(<$>) :: Functor t g => t -> g (Domain t) (Domain t) -> g (Codomain t) (Codomain t)
infixl 4 <$>
-- | Like Transformation.Shallow.Foldable except it folds all
-- descendants and not only immediate children
class (Transformation t, Foldable (g (Domain t))) => Foldable t g
foldMap :: (Foldable t g, Codomain t ~ Const m, Monoid m) => t -> g (Domain t) (Domain t) -> m
-- | Like Transformation.Shallow.Traversable except it folds
-- all descendants and not only immediate children
class (Transformation t, Traversable (g (Domain t))) => Traversable t g
traverse :: (Traversable t g, Codomain t ~ Compose m f) => t -> g (Domain t) (Domain t) -> m (g f f)
-- | A tuple of only one element
newtype Only g (d :: Type -> Type) (s :: Type -> Type)
Only :: s (g d d) -> Only g (d :: Type -> Type) (s :: Type -> Type)
[fromOnly] :: Only g (d :: Type -> Type) (s :: Type -> Type) -> s (g d d)
-- | Compose a regular type constructor with a data type with two type
-- constructor parameters
newtype Nest (f :: Type -> Type) g (d :: Type -> Type) (s :: Type -> Type)
Nest :: f (g d s) -> Nest (f :: Type -> Type) g (d :: Type -> Type) (s :: Type -> Type)
[unNest] :: Nest (f :: Type -> Type) g (d :: Type -> Type) (s :: Type -> Type) -> f (g d s)
-- | Like Product for data types with two type constructor
-- parameters
data Product g h (d :: Type -> Type) (s :: Type -> Type)
Pair :: g d s -> h d s -> Product g h (d :: Type -> Type) (s :: Type -> Type)
[fst] :: Product g h (d :: Type -> Type) (s :: Type -> Type) -> g d s
[snd] :: Product g h (d :: Type -> Type) (s :: Type -> Type) -> h d s
-- | Like Sum for data types with two type constructor parameters
data Sum g h (d :: Type -> Type) (s :: Type -> Type)
InL :: g d s -> Sum g h (d :: Type -> Type) (s :: Type -> Type)
InR :: h d s -> Sum g h (d :: Type -> Type) (s :: Type -> Type)
-- | Alphabetical synonym for <$>
fmap :: Functor t g => t -> g (Domain t) (Domain t) -> g (Codomain t) (Codomain t)
-- | Equivalent of either
eitherFromSum :: Sum g h d s -> Either (g d s) (h d s)
instance (Data.Typeable.Internal.Typeable s, Data.Typeable.Internal.Typeable d, Data.Typeable.Internal.Typeable g, Data.Data.Data (s (g d d))) => Data.Data.Data (Transformation.Deep.Only g d s)
instance GHC.Classes.Eq (s (g d d)) => GHC.Classes.Eq (Transformation.Deep.Only g d s)
instance GHC.Classes.Ord (s (g d d)) => GHC.Classes.Ord (Transformation.Deep.Only g d s)
instance GHC.Show.Show (s (g d d)) => GHC.Show.Show (Transformation.Deep.Only g d s)
instance (Data.Typeable.Internal.Typeable s, Data.Typeable.Internal.Typeable d, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Data.Data (f (g d s))) => Data.Data.Data (Transformation.Deep.Nest f g d s)
instance GHC.Classes.Eq (f (g d s)) => GHC.Classes.Eq (Transformation.Deep.Nest f g d s)
instance GHC.Classes.Ord (f (g d s)) => GHC.Classes.Ord (Transformation.Deep.Nest f g d s)
instance GHC.Show.Show (f (g d s)) => GHC.Show.Show (Transformation.Deep.Nest f g d s)
instance (Data.Typeable.Internal.Typeable d, Data.Typeable.Internal.Typeable s, Data.Typeable.Internal.Typeable g1, Data.Typeable.Internal.Typeable g2, Data.Data.Data (g1 d s), Data.Data.Data (g2 d s)) => Data.Data.Data (Transformation.Deep.Product g1 g2 d s)
instance (GHC.Show.Show (g1 d s), GHC.Show.Show (g2 d s)) => GHC.Show.Show (Transformation.Deep.Product g1 g2 d s)
instance (GHC.Classes.Eq (g d s), GHC.Classes.Eq (h d s)) => GHC.Classes.Eq (Transformation.Deep.Product g h d s)
instance (GHC.Classes.Ord (g d s), GHC.Classes.Ord (h d s)) => GHC.Classes.Ord (Transformation.Deep.Product g h d s)
instance (Data.Typeable.Internal.Typeable d, Data.Typeable.Internal.Typeable s, Data.Typeable.Internal.Typeable g1, Data.Typeable.Internal.Typeable g2, Data.Data.Data (g1 d s), Data.Data.Data (g2 d s)) => Data.Data.Data (Transformation.Deep.Sum g1 g2 d s)
instance (GHC.Show.Show (g1 d s), GHC.Show.Show (g2 d s)) => GHC.Show.Show (Transformation.Deep.Sum g1 g2 d s)
instance (GHC.Classes.Eq (g d s), GHC.Classes.Eq (h d s)) => GHC.Classes.Eq (Transformation.Deep.Sum g h d s)
instance (GHC.Classes.Ord (g d s), GHC.Classes.Ord (h d s)) => GHC.Classes.Ord (Transformation.Deep.Sum g h d s)
instance (Rank2.Functor (g d), Rank2.Functor (h d)) => Rank2.Functor (Transformation.Deep.Sum g h d)
instance (Rank2.Foldable (g d), Rank2.Foldable (h d)) => Rank2.Foldable (Transformation.Deep.Sum g h d)
instance (Rank2.Traversable (g d), Rank2.Traversable (h d)) => Rank2.Traversable (Transformation.Deep.Sum g h d)
instance (Transformation.Deep.Functor t g, Transformation.Deep.Functor t h) => Transformation.Deep.Functor t (Transformation.Deep.Sum g h)
instance (Transformation.Deep.Foldable t g, Transformation.Deep.Foldable t h, Transformation.Codomain t GHC.Types.~ Data.Functor.Const.Const m) => Transformation.Deep.Foldable t (Transformation.Deep.Sum g h)
instance (Transformation.Deep.Traversable t g, Transformation.Deep.Traversable t h, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m f, GHC.Base.Applicative m) => Transformation.Deep.Traversable t (Transformation.Deep.Sum g h)
instance (Rank2.Functor (g d), Rank2.Functor (h d)) => Rank2.Functor (Transformation.Deep.Product g h d)
instance (Rank2.Apply (g d), Rank2.Apply (h d)) => Rank2.Apply (Transformation.Deep.Product g h d)
instance (Rank2.Applicative (g d), Rank2.Applicative (h d)) => Rank2.Applicative (Transformation.Deep.Product g h d)
instance (Rank2.Foldable (g d), Rank2.Foldable (h d)) => Rank2.Foldable (Transformation.Deep.Product g h d)
instance (Rank2.Traversable (g d), Rank2.Traversable (h d)) => Rank2.Traversable (Transformation.Deep.Product g h d)
instance (Rank2.Distributive (g d), Rank2.Distributive (h d)) => Rank2.DistributiveTraversable (Transformation.Deep.Product g h d)
instance (Rank2.Distributive (g d), Rank2.Distributive (h d)) => Rank2.Distributive (Transformation.Deep.Product g h d)
instance (Transformation.Deep.Functor t g, Transformation.Deep.Functor t h) => Transformation.Deep.Functor t (Transformation.Deep.Product g h)
instance (Transformation.Deep.Foldable t g, Transformation.Deep.Foldable t h) => Transformation.Deep.Foldable t (Transformation.Deep.Product g h)
instance (Transformation.Deep.Traversable t g, Transformation.Deep.Traversable t h, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m f, GHC.Base.Applicative m) => Transformation.Deep.Traversable t (Transformation.Deep.Product g h)
instance (GHC.Base.Functor f, Rank2.Functor (g d)) => Rank2.Functor (Transformation.Deep.Nest f g d)
instance (GHC.Base.Applicative f, Rank2.Apply (g d)) => Rank2.Apply (Transformation.Deep.Nest f g d)
instance (GHC.Base.Applicative f, Rank2.Applicative (g d)) => Rank2.Applicative (Transformation.Deep.Nest f g d)
instance (Data.Foldable.Foldable f, Rank2.Foldable (g d)) => Rank2.Foldable (Transformation.Deep.Nest f g d)
instance (Data.Traversable.Traversable f, Rank2.Traversable (g d)) => Rank2.Traversable (Transformation.Deep.Nest f g d)
instance (GHC.Base.Functor f, Transformation.Deep.Functor t g) => Transformation.Deep.Functor t (Transformation.Deep.Nest f g)
instance (Data.Foldable.Foldable f, Transformation.Deep.Foldable t g) => Transformation.Deep.Foldable t (Transformation.Deep.Nest f g)
instance (Data.Traversable.Traversable f, Transformation.Deep.Traversable t g, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m f, GHC.Base.Applicative m) => Transformation.Deep.Traversable t (Transformation.Deep.Nest f g)
instance Rank2.Functor (Transformation.Deep.Only g d)
instance Rank2.Foldable (Transformation.Deep.Only g d)
instance Rank2.Traversable (Transformation.Deep.Only g d)
instance Rank2.Apply (Transformation.Deep.Only g d)
instance Rank2.Applicative (Transformation.Deep.Only g d)
instance Rank2.DistributiveTraversable (Transformation.Deep.Only g d)
instance Rank2.Distributive (Transformation.Deep.Only g d)
instance Transformation.Full.Functor t g => Transformation.Deep.Functor t (Transformation.Deep.Only g)
instance Transformation.Full.Foldable t g => Transformation.Deep.Foldable t (Transformation.Deep.Only g)
instance (Transformation.Full.Traversable t g, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m f, GHC.Base.Functor m) => Transformation.Deep.Traversable t (Transformation.Deep.Only g)
-- | This module exports the templates for automatic instance deriving of
-- Transformation.Deep type classes. The most common way to use it
-- would be
--
-- -- import qualified Transformation.Deep.TH -- data MyDataType f' f = ... -- $(Transformation.Deep.TH.deriveFunctor ''MyDataType) --module Transformation.Deep.TH deriveAll :: Name -> Q [Dec] deriveFunctor :: Name -> Q [Dec] deriveFoldable :: Name -> Q [Dec] deriveTraversable :: Name -> Q [Dec] -- | 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. module Transformation.AG.Dimorphic -- | Transformation wrapper that allows automatic inference of attribute -- rules. newtype Auto t Auto :: t -> Auto t -- | Transformation wrapper that allows automatic inference of attribute -- rules and preservation of the attribute with the original nodes. newtype Keep t Keep :: t -> Keep t data Atts a b Atts :: a -> b -> Atts a b [inh] :: Atts a b -> a [syn] :: Atts a b -> b -- | A node's Semantics maps its inherited attribute to its -- synthesized attribute. type Semantics a b = Const (a -> b) -- | A node's PreservingSemantics maps its inherited attribute to -- its synthesized attribute. type PreservingSemantics f a b = Compose ((->) a) (Compose ((,) (Atts a b)) f) -- | 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. type Rule a b = Atts a b -> Atts a b -- | The core function to tie the recursive knot, turning a Rule for -- a node into its Semantics. knit :: (Foldable (g sem), sem ~ Semantics a b, Monoid a, Monoid b) => Rule a b -> g sem sem -> sem (g sem sem) -- | Another way to tie the recursive knot, using a Rule to add -- attributes to every node througha stateful calculation knitKeeping :: forall a b f g sem. (Foldable (g sem), sem ~ PreservingSemantics f a b, Monoid a, Monoid b, Foldable f, Functor f) => Rule a b -> f (g sem sem) -> sem (g sem sem) -- | 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}
--
class Attribution t a b g (deep :: Type -> Type) shallow
-- | The attribution rule for a given transformation and node.
attribution :: Attribution t a b g deep shallow => t -> shallow (g deep deep) -> Rule a b
-- | Drop-in implementation of $
applyDefault :: (p ~ Domain t, q ~ Semantics a b, x ~ g q q, Foldable (g q), Attribution t a b g q p, Monoid a, Monoid b) => (forall y. p y -> y) -> t -> p x -> q x
-- | Drop-in implementation of <$>
fullMapDefault :: (p ~ Domain t, q ~ Semantics a b, q ~ Codomain t, x ~ g q q, Foldable (g q), Functor t g, Attribution t a b g p p, Monoid a, Monoid b) => (forall y. p y -> y) -> t -> p (g p p) -> q (g q q)
-- | Drop-in implementation of $ that stores all attributes with
-- every original node
applyDefaultWithAttributes :: (p ~ Domain t, q ~ PreservingSemantics p a b, x ~ g q q, Attribution t a b g q p, Foldable (g q), Monoid a, Monoid b, Foldable p, Functor p) => t -> p x -> q x
-- | Drop-in implementation of traverse that stores all attributes
-- with every original node
traverseDefaultWithAttributes :: forall t p q r a b g. (Transformation t, Domain t ~ p, Codomain t ~ Compose ((->) a) q, q ~ Compose ((,) (Atts a b)) p, r ~ Compose ((->) a) q, Traversable p, Functor t g, Traversable (Feeder a b p) g, At t (g r r)) => t -> p (g p p) -> a -> q (g q q)
data Feeder (a :: Type) (b :: Type) (f :: Type -> Type)
Feeder :: Feeder (a :: Type) (b :: Type) (f :: Type -> Type)
type FeederDomain (a :: Type) (b :: Type) f = Compose ((->) a) (Compose ((,) (Atts a b)) f)
instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Transformation.AG.Dimorphic.Atts a b)
instance (Data.Data.Data a, Data.Data.Data b) => Data.Data.Data (Transformation.AG.Dimorphic.Atts a b)
instance Transformation.Transformation (Transformation.AG.Dimorphic.Feeder a b f)
instance (Data.Traversable.Traversable f, Rank2.Traversable (g (Transformation.AG.Dimorphic.FeederDomain a b f)), Transformation.Deep.Traversable (Transformation.AG.Dimorphic.Feeder a b f) g) => Transformation.Full.Traversable (Transformation.AG.Dimorphic.Feeder a b f) g
instance (Transformation.Transformation (Transformation.AG.Dimorphic.Keep t), Transformation.Domain (Transformation.AG.Dimorphic.Keep t) GHC.Types.~ f, Data.Traversable.Traversable f, Rank2.Traversable (g f), Transformation.Codomain (Transformation.AG.Dimorphic.Keep t) GHC.Types.~ Transformation.AG.Dimorphic.PreservingSemantics f a b, Transformation.Deep.Traversable (Transformation.AG.Dimorphic.Feeder a b f) g, Transformation.Full.Functor (Transformation.AG.Dimorphic.Keep t) g, Transformation.At (Transformation.AG.Dimorphic.Keep t) (g (Transformation.AG.Dimorphic.PreservingSemantics f a b) (Transformation.AG.Dimorphic.PreservingSemantics f a b))) => Transformation.Full.Traversable (Transformation.AG.Dimorphic.Keep t) g
instance Transformation.At (Transformation.AG.Dimorphic.Feeder a b f) g
instance Transformation.AG.Dimorphic.Attribution t a b g deep shallow
instance (Transformation.Transformation (Transformation.AG.Dimorphic.Auto t), p GHC.Types.~ Transformation.Domain (Transformation.AG.Dimorphic.Auto t), q GHC.Types.~ Transformation.Codomain (Transformation.AG.Dimorphic.Auto t), q GHC.Types.~ Transformation.AG.Dimorphic.Semantics a b, Rank2.Foldable (g q), GHC.Base.Monoid a, GHC.Base.Monoid b, Data.Foldable.Foldable p, Transformation.AG.Dimorphic.Attribution (Transformation.AG.Dimorphic.Auto t) a b g q p) => Transformation.At (Transformation.AG.Dimorphic.Auto t) (g (Transformation.AG.Dimorphic.Semantics a b) (Transformation.AG.Dimorphic.Semantics a b))
instance (Transformation.Transformation (Transformation.AG.Dimorphic.Keep t), p GHC.Types.~ Transformation.Domain (Transformation.AG.Dimorphic.Keep t), q GHC.Types.~ Transformation.Codomain (Transformation.AG.Dimorphic.Keep t), q GHC.Types.~ Transformation.AG.Dimorphic.PreservingSemantics p a b, Rank2.Foldable (g q), GHC.Base.Monoid a, GHC.Base.Monoid b, Data.Foldable.Foldable p, GHC.Base.Functor p, Transformation.AG.Dimorphic.Attribution (Transformation.AG.Dimorphic.Keep t) a b g q p) => Transformation.At (Transformation.AG.Dimorphic.Keep t) (g (Transformation.AG.Dimorphic.PreservingSemantics p a b) (Transformation.AG.Dimorphic.PreservingSemantics p a b))
instance (Transformation.Transformation (Transformation.AG.Dimorphic.Keep t), Transformation.Domain (Transformation.AG.Dimorphic.Keep t) GHC.Types.~ f, GHC.Base.Functor f, Transformation.Codomain (Transformation.AG.Dimorphic.Keep t) GHC.Types.~ Transformation.AG.Dimorphic.PreservingSemantics f a b, Rank2.Functor (g f), Transformation.Deep.Functor (Transformation.AG.Dimorphic.Keep t) g, Transformation.At (Transformation.AG.Dimorphic.Keep t) (g (Transformation.AG.Dimorphic.PreservingSemantics f a b) (Transformation.AG.Dimorphic.PreservingSemantics f a b))) => Transformation.Full.Functor (Transformation.AG.Dimorphic.Keep t) g
instance (Transformation.Transformation (Transformation.AG.Dimorphic.Auto t), Transformation.Domain (Transformation.AG.Dimorphic.Auto t) GHC.Types.~ f, GHC.Base.Functor f, Transformation.Codomain (Transformation.AG.Dimorphic.Auto t) GHC.Types.~ Transformation.AG.Dimorphic.Semantics a b, Rank2.Functor (g f), Transformation.Deep.Functor (Transformation.AG.Dimorphic.Auto t) g, Transformation.At (Transformation.AG.Dimorphic.Auto t) (g (Transformation.AG.Dimorphic.Semantics a b) (Transformation.AG.Dimorphic.Semantics a b))) => Transformation.Full.Functor (Transformation.AG.Dimorphic.Auto t) g
instance (GHC.Base.Semigroup a, GHC.Base.Semigroup b) => GHC.Base.Semigroup (Transformation.AG.Dimorphic.Atts a b)
instance (GHC.Base.Monoid a, GHC.Base.Monoid b) => GHC.Base.Monoid (Transformation.AG.Dimorphic.Atts a b)
-- | 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.
module Transformation.AG.Monomorphic
-- | Transformation wrapper that allows automatic inference of attribute
-- rules.
newtype Auto t
Auto :: t -> Auto t
-- | Transformation wrapper that allows automatic inference of attribute
-- rules and preservation of the attribute with the original nodes.
newtype Keep t
Keep :: t -> Keep t
type Atts a = Atts a a
pattern Atts :: a -> a -> Atts a
inh :: Atts a -> a
syn :: Atts a -> a
-- | A node's Semantics maps its inherited attribute to its
-- synthesized attribute.
type Semantics a = Const (a -> a)
-- | A node's PreservingSemantics maps its inherited attribute to
-- its synthesized attribute.
type PreservingSemantics f a = Compose ((->) a) (Compose ((,) (Atts a)) f)
-- | 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.
type Rule a = Atts a -> Atts a
-- | 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}
--
class Attribution t a g (deep :: Type -> Type) shallow
-- | The attribution rule for a given transformation and node.
attribution :: Attribution t a g deep shallow => t -> shallow (g deep deep) -> Rule a
type Feeder a = Feeder a a
-- | The core function to tie the recursive knot, turning a Rule for
-- a node into its Semantics.
knit :: (Foldable (g sem), sem ~ Semantics a b, Monoid a, Monoid b) => Rule a b -> g sem sem -> sem (g sem sem)
-- | Another way to tie the recursive knot, using a Rule to add
-- attributes to every node througha stateful calculation
knitKeeping :: forall a b f g sem. (Foldable (g sem), sem ~ PreservingSemantics f a b, Monoid a, Monoid b, Foldable f, Functor f) => Rule a b -> f (g sem sem) -> sem (g sem sem)
-- | Drop-in implementation of $
applyDefault :: (p ~ Domain t, q ~ Semantics a, x ~ g q q, Foldable (g q), Attribution t a g q p, Monoid a) => (forall y. p y -> y) -> t -> p x -> q x
-- | Drop-in implementation of $ that stores all attributes with
-- every original node
applyDefaultWithAttributes :: (p ~ Domain t, q ~ PreservingSemantics p a, x ~ g q q, Attribution t a g q p, Foldable (g q), Monoid a, Foldable p, Functor p) => t -> p x -> q x
-- | Drop-in implementation of <$>
fullMapDefault :: (p ~ Domain t, q ~ Semantics a, q ~ Codomain t, x ~ g q q, Foldable (g q), Functor t g, Attribution t a g p p, Monoid a) => (forall y. p y -> y) -> t -> p (g p p) -> q (g q q)
-- | Drop-in implementation of traverse that stores all attributes
-- with every original node
traverseDefaultWithAttributes :: forall t p q r a b g. (Transformation t, Domain t ~ p, Codomain t ~ Compose ((->) a) q, q ~ Compose ((,) (Atts a b)) p, r ~ Compose ((->) a) q, Traversable p, Functor t g, Traversable (Feeder a b p) g, At t (g r r)) => t -> p (g p p) -> a -> q (g q q)
instance (Transformation.Transformation (Transformation.AG.Monomorphic.Keep t), Transformation.Domain (Transformation.AG.Monomorphic.Keep t) GHC.Types.~ f, Data.Traversable.Traversable f, Rank2.Traversable (g f), Transformation.Codomain (Transformation.AG.Monomorphic.Keep t) GHC.Types.~ Transformation.AG.Monomorphic.PreservingSemantics f a, Transformation.Deep.Traversable (Transformation.AG.Monomorphic.Feeder a f) g, Transformation.Full.Functor (Transformation.AG.Monomorphic.Keep t) g, Transformation.At (Transformation.AG.Monomorphic.Keep t) (g (Transformation.AG.Monomorphic.PreservingSemantics f a) (Transformation.AG.Monomorphic.PreservingSemantics f a))) => Transformation.Full.Traversable (Transformation.AG.Monomorphic.Keep t) g
instance Transformation.AG.Monomorphic.Attribution t a g deep shallow
instance (Transformation.Transformation (Transformation.AG.Monomorphic.Auto t), p GHC.Types.~ Transformation.Domain (Transformation.AG.Monomorphic.Auto t), q GHC.Types.~ Transformation.Codomain (Transformation.AG.Monomorphic.Auto t), q GHC.Types.~ Transformation.AG.Monomorphic.Semantics a, Rank2.Foldable (g q), GHC.Base.Monoid a, Data.Foldable.Foldable p, Transformation.AG.Monomorphic.Attribution (Transformation.AG.Monomorphic.Auto t) a g q p) => Transformation.At (Transformation.AG.Monomorphic.Auto t) (g (Transformation.AG.Monomorphic.Semantics a) (Transformation.AG.Monomorphic.Semantics a))
instance (Transformation.Transformation (Transformation.AG.Monomorphic.Keep t), p GHC.Types.~ Transformation.Domain (Transformation.AG.Monomorphic.Keep t), q GHC.Types.~ Transformation.Codomain (Transformation.AG.Monomorphic.Keep t), q GHC.Types.~ Transformation.AG.Monomorphic.PreservingSemantics p a, Rank2.Foldable (g q), GHC.Base.Monoid a, Data.Foldable.Foldable p, GHC.Base.Functor p, Transformation.AG.Monomorphic.Attribution (Transformation.AG.Monomorphic.Keep t) a g q p) => Transformation.At (Transformation.AG.Monomorphic.Keep t) (g (Transformation.AG.Monomorphic.PreservingSemantics p a) (Transformation.AG.Monomorphic.PreservingSemantics p a))
instance (Transformation.Transformation (Transformation.AG.Monomorphic.Keep t), Transformation.Domain (Transformation.AG.Monomorphic.Keep t) GHC.Types.~ f, GHC.Base.Functor f, Transformation.Codomain (Transformation.AG.Monomorphic.Keep t) GHC.Types.~ Transformation.AG.Monomorphic.PreservingSemantics f a, GHC.Base.Functor f, Rank2.Functor (g f), Transformation.Deep.Functor (Transformation.AG.Monomorphic.Keep t) g, Transformation.At (Transformation.AG.Monomorphic.Keep t) (g (Transformation.AG.Monomorphic.PreservingSemantics f a) (Transformation.AG.Monomorphic.PreservingSemantics f a))) => Transformation.Full.Functor (Transformation.AG.Monomorphic.Keep t) g
instance (Transformation.Transformation (Transformation.AG.Monomorphic.Auto t), Transformation.Domain (Transformation.AG.Monomorphic.Auto t) GHC.Types.~ f, GHC.Base.Functor f, Transformation.Codomain (Transformation.AG.Monomorphic.Auto t) GHC.Types.~ Transformation.AG.Monomorphic.Semantics a, Rank2.Functor (g f), Transformation.Deep.Functor (Transformation.AG.Monomorphic.Auto t) g, Transformation.At (Transformation.AG.Monomorphic.Auto t) (g (Transformation.AG.Monomorphic.Semantics a) (Transformation.AG.Monomorphic.Semantics a))) => Transformation.Full.Functor (Transformation.AG.Monomorphic.Auto t) g
-- | This module exports the templates for automatic instance deriving of
-- Transformation.Full type classes. The most common way to use it
-- would be
--
-- -- import qualified Transformation.Full.TH -- data MyDataType f' f = ... -- $(Transformation.Full.TH.deriveUpFunctor (conT ''MyTransformation) (conT ''MyDataType)) --module Transformation.Full.TH deriveDownFunctor :: Q Type -> Q Type -> Q [Dec] deriveDownFoldable :: Q Type -> Q Type -> Q [Dec] deriveDownTraversable :: Q Type -> Q Type -> Q [Dec] deriveUpFunctor :: Q Type -> Q Type -> Q [Dec] deriveUpFoldable :: Q Type -> Q Type -> Q [Dec] deriveUpTraversable :: Q Type -> Q Type -> Q [Dec] -- | This module provides natural transformations Map, Fold, -- and Traversal, as well as three rank-2 functions that wrap them -- in a convenient interface. module Transformation.Rank2 -- | Transform (naturally) the containing functor of every node in the -- given tree. (<$>) :: Functor (Map p q) g => (forall a. p a -> q a) -> g p p -> g q q infixl 4 <$> -- | Fold the containing functor of every node in the given tree. foldMap :: (Foldable (Fold p m) g, Monoid m) => (forall a. p a -> m) -> g p p -> m -- | Traverse the containing functors of all nodes in the given tree. traverse :: Traversable (Traversal p q m) g => (forall a. p a -> m (q a)) -> g p p -> m (g q q) newtype Map (p :: Type -> Type) (q :: Type -> Type) Map :: (forall x. p x -> q x) -> Map (p :: Type -> Type) (q :: Type -> Type) newtype Fold (p :: Type -> Type) m Fold :: (forall x. p x -> m) -> Fold (p :: Type -> Type) m newtype Traversal (p :: Type -> Type) (q :: Type -> Type) m Traversal :: (forall x. p x -> m (q x)) -> Traversal (p :: Type -> Type) (q :: Type -> Type) m instance Transformation.Transformation (Transformation.Rank2.Traversal p q m) instance Transformation.At (Transformation.Rank2.Traversal p q m) x instance Transformation.Transformation (Transformation.Rank2.Fold p m) instance Transformation.At (Transformation.Rank2.Fold p m) x instance Transformation.Transformation (Transformation.Rank2.Map p q) instance Transformation.At (Transformation.Rank2.Map p q) x instance (Rank2.Functor (g p), Transformation.Deep.Functor (Transformation.Rank2.Map p q) g, GHC.Base.Functor p) => Transformation.Full.Functor (Transformation.Rank2.Map p q) g -- | Type classes Functor, Foldable, and Traversable -- that correspond to the standard type classes of the same name. The -- rank2classes package provides the equivalent set of classes for -- natural transformations. This module extends the functionality to -- unnatural transformations. module Transformation.Shallow -- | Like Rank2.Functor except it takes a Transformation -- instead of a polymorphic function class (Transformation t, Functor g) => Functor t g (<$>) :: Functor t g => t -> g (Domain t) -> g (Codomain t) infixl 4 <$> -- | Like Rank2.Foldable except it takes a Transformation -- instead of a polymorphic function class (Transformation t, Foldable g) => Foldable t g foldMap :: (Foldable t g, Codomain t ~ Const m, Monoid m) => t -> g (Domain t) -> m -- | Like Rank2.Traversable except it takes a Transformation -- instead of a polymorphic function class (Transformation t, Traversable g) => Traversable t g traverse :: (Traversable t g, Codomain t ~ Compose m f) => t -> g (Domain t) -> m (g f) -- | Alphabetical synonym for <$> fmap :: Functor t g => t -> g (Domain t) -> g (Codomain t) instance (Transformation.Transformation t, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose q r) => Transformation.Transformation (Transformation.Shallow.TraversableCompose p t) instance (Data.Traversable.Traversable p, GHC.Base.Applicative q, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose q r, Transformation.At t a) => Transformation.At (Transformation.Shallow.TraversableCompose p t) a instance (Transformation.Transformation t, Transformation.Shallow.Traversable (Transformation.Shallow.TraversableCompose p t) g, Data.Traversable.Traversable p, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose q r, GHC.Base.Functor q) => Transformation.Shallow.Traversable t (Rank2.Compose g p) instance Transformation.Transformation t => Transformation.Transformation (Transformation.Shallow.FoldableCompose p t) instance (Data.Foldable.Foldable p, Transformation.Codomain t GHC.Types.~ Data.Functor.Const.Const m, GHC.Base.Monoid m, Transformation.At t a) => Transformation.At (Transformation.Shallow.FoldableCompose p t) a instance (Transformation.Transformation t, Transformation.Shallow.Foldable (Transformation.Shallow.FoldableCompose p t) g, Data.Foldable.Foldable p) => Transformation.Shallow.Foldable t (Rank2.Compose g p) instance Transformation.Transformation t => Transformation.Transformation (Transformation.Shallow.FunctorCompose p t) instance (GHC.Base.Functor p, Transformation.At t a) => Transformation.At (Transformation.Shallow.FunctorCompose p t) a instance (Transformation.Transformation t, Transformation.Shallow.Functor (Transformation.Shallow.FunctorCompose p t) g, GHC.Base.Functor p) => Transformation.Shallow.Functor t (Rank2.Compose g p) instance (Transformation.Transformation t, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m f, GHC.Base.Applicative m) => Transformation.Shallow.Traversable t Rank2.Empty instance (Transformation.Transformation t, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m f, GHC.Base.Applicative m) => Transformation.Shallow.Traversable t Data.Proxy.Proxy instance (Transformation.Transformation t, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m f, GHC.Base.Applicative m) => Transformation.Shallow.Traversable t (Data.Functor.Const.Const x) instance (Transformation.Transformation t, Transformation.At t a, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m f, GHC.Base.Functor m) => Transformation.Shallow.Traversable t (Rank2.Only a) instance (Transformation.Shallow.Traversable t g, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m f, GHC.Base.Functor m) => Transformation.Shallow.Traversable t (Rank2.Identity g) instance (Transformation.Transformation t, Transformation.At t a, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m f, GHC.Base.Applicative m, Data.Traversable.Traversable g) => Transformation.Shallow.Traversable t (Rank2.Flip g a) instance (Transformation.Shallow.Traversable t g, Transformation.Shallow.Traversable t h, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m f, GHC.Base.Applicative m) => Transformation.Shallow.Traversable t (Data.Functor.Product.Product g h) instance (Transformation.Shallow.Traversable t g, Transformation.Shallow.Traversable t h, Transformation.Codomain t GHC.Types.~ Data.Functor.Compose.Compose m f, GHC.Base.Functor m) => Transformation.Shallow.Traversable t (Data.Functor.Sum.Sum g h) instance Transformation.Transformation t => Transformation.Shallow.Foldable t Rank2.Empty instance Transformation.Transformation t => Transformation.Shallow.Foldable t Data.Proxy.Proxy instance Transformation.Transformation t => Transformation.Shallow.Foldable t (Data.Functor.Const.Const x) instance (Transformation.Transformation t, Transformation.At t a, Transformation.Codomain t GHC.Types.~ Data.Functor.Const.Const m) => Transformation.Shallow.Foldable t (Rank2.Only a) instance Transformation.Shallow.Foldable t g => Transformation.Shallow.Foldable t (Rank2.Identity g) instance (Transformation.Transformation t, Transformation.At t a, Transformation.Codomain t GHC.Types.~ Data.Functor.Const.Const m, Data.Foldable.Foldable g) => Transformation.Shallow.Foldable t (Rank2.Flip g a) instance (Transformation.Shallow.Foldable t g, Transformation.Shallow.Foldable t h, Transformation.Codomain t GHC.Types.~ Data.Functor.Const.Const m, GHC.Base.Monoid m) => Transformation.Shallow.Foldable t (Data.Functor.Product.Product g h) instance (Transformation.Shallow.Foldable t g, Transformation.Shallow.Foldable t h) => Transformation.Shallow.Foldable t (Data.Functor.Sum.Sum g h) instance Transformation.Transformation t => Transformation.Shallow.Functor t Rank2.Empty instance Transformation.Transformation t => Transformation.Shallow.Functor t Data.Proxy.Proxy instance Transformation.Transformation t => Transformation.Shallow.Functor t (Data.Functor.Const.Const a) instance (Transformation.Transformation t, Transformation.At t a) => Transformation.Shallow.Functor t (Rank2.Only a) instance Transformation.Shallow.Functor t g => Transformation.Shallow.Functor t (Rank2.Identity g) instance (Transformation.Transformation t, Transformation.At t a, GHC.Base.Functor g) => Transformation.Shallow.Functor t (Rank2.Flip g a) instance (Transformation.Shallow.Functor t g, Transformation.Shallow.Functor t h) => Transformation.Shallow.Functor t (Data.Functor.Product.Product g h) instance (Transformation.Shallow.Functor t g, Transformation.Shallow.Functor t h) => Transformation.Shallow.Functor t (Data.Functor.Sum.Sum g h) -- | This module can be used to scrap the boilerplate attribute -- declarations. In particular: -- --
-- import qualified Transformation.Shallow.TH -- data MyDataType f' f = ... -- $(Transformation.Shallow.TH.deriveFunctor ''MyDataType) --module Transformation.Shallow.TH deriveAll :: Name -> Q [Dec] deriveFunctor :: Name -> Q [Dec] deriveFoldable :: Name -> Q [Dec] deriveTraversable :: Name -> Q [Dec]