HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleuniplate-1.6.13Haskell2010

Data.Generics.Uniplate.Typeable

RECOMMENDATION: Use Data.Generics.Uniplate.Data instead - it usually performs faster (sometimes significantly so) and requires no special instance declarations.

This module supplies a method for writing Uniplate / Biplate instances. One instance declaration is required for each data type you wish to work with. The instances can be generated using Derive: http://community.haskell.org/~ndm/derive/.

To take an example:

data Expr = Var Int | Neg Expr | Add Expr Expr
            deriving Typeable

instance (Typeable a, Uniplate a) => PlateAll Expr a where
    plateAll (Var x  ) = plate Var |+ x
    plateAll (Neg x  ) = plate Neg |+ x
    plateAll (Add x y) = plate Add |+ x |+ y
  • 5 types
  • 2 classes
  • 35 values
  • Packageuniplate-1.6.13
  • Exports42
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceTypeable.hs
classclass Typeable (a :: k) where
#

The class Typeable allows a concrete representation of a type to be calculated.

datadata TyCon
#
Instances6Eq, Data, Ord, Show, NFData, Binary
  • Eq TyConDefined in ghc-prim-0.12.0 · GHC.Classes
  • Data TyConDefined in syb-0.7.3 · Data.Generics.Instances · orphan
  • Ord TyConDefined in ghc-prim-0.12.0 · GHC.Classes
  • Show TyConDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • NFData TyConDefined in deepseq-1.5.0.0 · Control.DeepSeq

    NOTE: Prior to deepseq-1.4.4.0 this instance was only defined for base-4.8.0.0 and later.

  • Binary TyConDefined in binary-0.8.9.3 · Data.Binary.Class

Applies a type to a function type. Returns: Just u if the first argument represents a function of type t -> u and the second argument represents a function of type t. Otherwise, returns Nothing.

valuesplitTyConApp :: TypeRep -> (TyCon, [TypeRep])
#

Splits a type constructor application. Note that if the type constructor is polymorphic, this will not return the kinds that were used.

valuetypeRep :: Typeable a => proxy a -> TypeRep
#

Takes a value of type a and returns a concrete representation of that type.

datadata Proxy (t :: k)
#

Proxy is a type that holds no data, but has a phantom parameter of arbitrary type (or even kind). Its use is to provide type information, even though there is no value available of that type (or it may be too costly to create one).

Historically, Proxy :: Proxy a is a safer alternative to the undefined :: a idiom.

Example1 expression
Proxy :: Proxy (Void, Int -> Int)Proxy

Proxy can even hold types of higher kinds,

Example1 expression
Proxy :: Proxy EitherProxy
Example1 expression
Proxy :: Proxy FunctorProxy
Example1 expression
Proxy :: Proxy complicatedStructureProxy
Instances31Generic1, Monad, Functor, Applicative, Foldable, Traversable, …
  • Generic1 ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monad ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Functor ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Applicative ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Foldable ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Foldable
  • Traversable ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Traversable
  • Alternative ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • MonadPlus ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • MonadZip ProxyDefined in base-4.20.2.0 · Control.Monad.Zip
  • Eq1 ProxyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Ord1 ProxyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Read1 ProxyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Show1 ProxyDefined in base-4.20.2.0 · Data.Functor.Classes
  • Contravariant ProxyDefined in base-4.20.2.0 · Data.Functor.Contravariant
  • NFData1 ProxyDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Hashable1 ProxyDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Bounded (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Enum (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Eq (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Data t => Data (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Ord (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Read (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Show (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Ix (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Generic (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Semigroup (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Monoid (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • NFData (Proxy a)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • Hashable (Proxy a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • type Rep (Proxy t) = D1 ('MetaData "Proxy" "GHC.Internal.Data.Proxy" "ghc-internal" 'False) (C1 ('MetaCons "Proxy" 'PrefixI 'False) U1)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type Rep1 Proxy = D1 ('MetaData "Proxy" "GHC.Internal.Data.Proxy" "ghc-internal" 'False) (C1 ('MetaCons "Proxy" 'PrefixI 'False) U1)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
datadata (:~:) (a :: k) (b :: k) where
#

Propositional equality. If a :~: b is inhabited by some terminating value, then the type a is the same as the type b. To use this equality in practice, pattern-match on the a :~: b to get out the Refl constructor; in the body of the pattern-match, the compiler knows that a ~ b.

Constructors

Instances13Category, TestCoercion, TestEquality, NFData2, NFData1, Bounded, …
  • Category (:~:)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Category
  • TestCoercion ((:~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • TestEquality ((:~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • NFData2 (:~:)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • NFData1 ((:~:) a)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • a ~ b => Bounded (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • a ~ b => Enum (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Eq (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • (a ~ b, Data a) => Data (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Ord (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • a ~ b => Read (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Show (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • NFData (a :~: b)Defined in deepseq-1.5.0.0 · Control.DeepSeq
datadata (:~~:) (a :: k1) (b :: k2) where
#

Kind heterogeneous propositional equality. Like :~:, a :~~: b is inhabited by a terminating value if and only if a is the same type as b.

Constructors

Instances13Category, TestCoercion, TestEquality, NFData2, NFData1, Bounded, …
  • Category (:~~:)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Category
  • TestCoercion ((:~~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • TestEquality ((:~~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • NFData2 (:~~:)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • NFData1 ((:~~:) a)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • a ~~ b => Bounded (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • a ~~ b => Enum (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Eq (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • (Typeable i, Typeable j, Typeable a, Typeable b, a ~~ b) => Data (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Ord (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • a ~~ b => Read (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Show (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • NFData (a :~~: b)Defined in deepseq-1.5.0.0 · Control.DeepSeq
typetype TypeRep = SomeTypeRep
#

A quantified type representation.

Instances1NFData
  • NFData TypeRepDefined in deepseq-1.5.0.0 · Control.DeepSeq

    NOTE: Prior to deepseq-1.4.4.0 this instance was only defined for base-4.8.0.0 and later.

The Class

1 declaration
classclass PlateAll from to where
#

This class should be defined for each data type of interest.

Methods

  • plateAll :: from -> Type from to

    This method should be defined using plate and |+, |-.

Instances15PlateAll, …

The Combinators

4 declarations
valueplate :: from -> Type from to
#

The main combinator used to start the chain.

value(|+)
  1. :: (Typeable item, Typeable to, PlateAll item to)
  2. => Type (item -> from) to
  3. -> item
  4. -> Type from to
#

The field to the right may contain the target.

value(|-) :: Type (item -> from) to -> item -> Type from to
#

The field to the right does not contain the target. This can be used as either an optimisation, or more commonly for excluding primitives such as Int.

valueplateProject
  1. :: (Typeable item, Typeable to, PlateAll item to)
  2. => from -> item
  3. -> item -> from
  4. -> from
  5. -> Type from to
#

Write an instance in terms of a projection/injection pair. Usually used to define instances for abstract containers such as Map:

instance (Ord a, Typeable a, PlateAll a c, Typeable b, PlateAll b c,
         Typeable c, PlateAll c c) => PlateAll (Map.Map a b) c where
    plateAll = plateProject Map.toList Map.fromList

Orphan instances

2 instances