-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Deep natural and unnatural tree transformations, including attribute grammars -- -- 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.2.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: -- --
-- 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)
-- | Like Product for data types with two type constructor
-- parameters
data Product g h (d :: Type -> Type) (s :: Type -> Type)
Pair :: s (g d d) -> s (h d d) -> Product g h (d :: Type -> Type) (s :: Type -> Type)
[fst] :: Product g h (d :: Type -> Type) (s :: Type -> Type) -> s (g d d)
[snd] :: Product g h (d :: Type -> Type) (s :: Type -> Type) -> s (h d d)
-- | Like Sum for data types with two type constructor parameters
data Sum g h (d :: Type -> Type) (s :: Type -> Type)
InL :: s (g d d) -> Sum g h (d :: Type -> Type) (s :: Type -> Type)
InR :: s (h d d) -> 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 (s (g d d)) (s (h d d))
instance (Data.Typeable.Internal.Typeable p, Data.Typeable.Internal.Typeable q, Data.Typeable.Internal.Typeable g1, Data.Typeable.Internal.Typeable g2, Data.Data.Data (q (g1 p p)), Data.Data.Data (q (g2 p p))) => Data.Data.Data (Transformation.Deep.Product g1 g2 p q)
instance (GHC.Show.Show (q (g1 p p)), GHC.Show.Show (q (g2 p p))) => GHC.Show.Show (Transformation.Deep.Product g1 g2 p q)
instance (Data.Typeable.Internal.Typeable p, Data.Typeable.Internal.Typeable q, Data.Typeable.Internal.Typeable g1, Data.Typeable.Internal.Typeable g2, Data.Data.Data (q (g1 p p)), Data.Data.Data (q (g2 p p))) => Data.Data.Data (Transformation.Deep.Sum g1 g2 p q)
instance (GHC.Show.Show (q (g1 p p)), GHC.Show.Show (q (g2 p p))) => GHC.Show.Show (Transformation.Deep.Sum g1 g2 p q)
instance Rank2.Functor (Transformation.Deep.Sum g h p)
instance Rank2.Foldable (Transformation.Deep.Sum g h p)
instance Rank2.Traversable (Transformation.Deep.Sum g h p)
instance (Transformation.Full.Functor t g, Transformation.Full.Functor t h) => Transformation.Deep.Functor t (Transformation.Deep.Sum g h)
instance (Transformation.Full.Foldable t g, Transformation.Full.Foldable t h, Transformation.Codomain t GHC.Types.~ Data.Functor.Const.Const m) => Transformation.Deep.Foldable t (Transformation.Deep.Sum g h)
instance (Transformation.Full.Traversable t g, Transformation.Full.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 (Transformation.Deep.Product g h p)
instance Rank2.Apply (Transformation.Deep.Product g h p)
instance Rank2.Applicative (Transformation.Deep.Product g h p)
instance Rank2.Foldable (Transformation.Deep.Product g h p)
instance Rank2.Traversable (Transformation.Deep.Product g h p)
instance Rank2.DistributiveTraversable (Transformation.Deep.Product g h p)
instance Rank2.Distributive (Transformation.Deep.Product g h p)
instance (Transformation.Full.Functor t g, Transformation.Full.Functor t h) => Transformation.Deep.Functor t (Transformation.Deep.Product g h)
instance (Transformation.Full.Traversable t g, Transformation.Full.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)
-- | 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] 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 b (f :: Type -> Type)
Feeder :: Feeder a b (f :: Type -> Type)
type FeederDomain a b 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 q Map :: (forall x. p x -> q x) -> Map p q newtype Fold p m Fold :: (forall x. p x -> m) -> Fold p m newtype Traversal p q m Traversal :: (forall x. p x -> m (q x)) -> Traversal p q 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.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.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.Functor t g, Transformation.Shallow.Functor t h) => Transformation.Shallow.Functor t (Data.Functor.Product.Product 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]