The class Typeable allows a concrete representation of a type to be calculated.
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
Instances6Eq, Data, Ord, Show, NFData, Binary
Eq TyConDefined in ghc-prim-0.12.0 · GHC.ClassesData TyConDefined in syb-0.7.3 · Data.Generics.Instances · orphanOrd TyConDefined in ghc-prim-0.12.0 · GHC.ClassesShow TyConDefined in ghc-internal-9.1003.0 · GHC.Internal.ShowNFData TyConDefined in deepseq-1.5.0.0 · Control.DeepSeqNOTE: Prior to
deepseq-1.4.4.0this instance was only defined forbase-4.8.0.0and later.Binary TyConDefined in binary-0.8.9.3 · Data.Binary.Class
The type-safe cast operation
Decide an equality of two types
Extract a witness of equality of two types
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.
A flexible variation parameterised in a type constructor
Cast over k1 -> k2
Cast over k1 -> k2 -> k3
Decide heterogeneous equality of two types.
Extract a witness of heterogeneous equality of two types
Build a function type.
Force a TypeRep to normal form.
Show a type representation
Splits a type constructor application. Note that if the type constructor is polymorphic, this will not return the kinds that were used.
Observe a type representation for the type of a value.
Takes a value of type a and returns a concrete representation
of that type.
Observe the argument types of a type representation
Takes a value of type a and returns a concrete representation
of that type.
Observe the type constructor of a quantified type representation.
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.
Proxy :: Proxy (Void, Int -> Int)Proxy
Proxy can even hold types of higher kinds,
Proxy :: Proxy EitherProxy
Proxy :: Proxy FunctorProxy
Proxy :: Proxy complicatedStructureProxy
Instances31Generic1, Monad, Functor, Applicative, Foldable, Traversable, …
Generic1 ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsMonad ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyFunctor ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyApplicative ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyFoldable ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.FoldableTraversable ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.TraversableAlternative ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyMonadPlus ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyMonadZip ProxyDefined in base-4.20.2.0 · Control.Monad.ZipEq1 ProxyDefined in base-4.20.2.0 · Data.Functor.ClassesOrd1 ProxyDefined in base-4.20.2.0 · Data.Functor.ClassesRead1 ProxyDefined in base-4.20.2.0 · Data.Functor.ClassesShow1 ProxyDefined in base-4.20.2.0 · Data.Functor.ClassesContravariant ProxyDefined in base-4.20.2.0 · Data.Functor.ContravariantNFData1 ProxyDefined in deepseq-1.5.0.0 · Control.DeepSeqHashable1 ProxyDefined in hashable-1.4.7.0 · Data.Hashable.ClassBounded (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyEnum (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyEq (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyData t => Data (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.DataOrd (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyRead (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyShow (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyIx (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyGeneric (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsSemigroup (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyMonoid (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyNFData (Proxy a)Defined in deepseq-1.5.0.0 · Control.DeepSeqHashable (Proxy a)Defined in hashable-1.4.7.0 · Data.Hashable.Classtype Rep (Proxy t) = D1 ('MetaDataDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics"Proxy"
"GHC.Internal.Data.Proxy"
"ghc-internal"
'False) (C1 ('MetaCons"Proxy"
'PrefixI 'False) U1)type Rep1 Proxy = D1 ('MetaDataDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics"Proxy"
"GHC.Internal.Data.Proxy"
"ghc-internal"
'False) (C1 ('MetaCons"Proxy"
'PrefixI 'False) U1)
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.
Instances13Category, TestCoercion, TestEquality, NFData2, NFData1, Bounded, …
Category (:~:)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.CategoryTestCoercion ((:~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.CoercionTestEquality ((:~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityNFData2 (:~:)Defined in deepseq-1.5.0.0 · Control.DeepSeqNFData1 ((:~:) a)Defined in deepseq-1.5.0.0 · Control.DeepSeqa ~ b => Bounded (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equalitya ~ b => Enum (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityEq (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.DataOrd (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equalitya ~ b => Read (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityShow (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityNFData (a :~: b)Defined in deepseq-1.5.0.0 · Control.DeepSeq
Kind heterogeneous propositional equality. Like :~:, a :~~: b is
inhabited by a terminating value if and only if a is the same type as b.
Instances13Category, TestCoercion, TestEquality, NFData2, NFData1, Bounded, …
Category (:~~:)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.CategoryTestCoercion ((:~~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.CoercionTestEquality ((:~~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityNFData2 (:~~:)Defined in deepseq-1.5.0.0 · Control.DeepSeqNFData1 ((:~~:) a)Defined in deepseq-1.5.0.0 · Control.DeepSeqa ~~ b => Bounded (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equalitya ~~ b => Enum (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityEq (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.DataOrd (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equalitya ~~ b => Read (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityShow (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityNFData (a :~~: b)Defined in deepseq-1.5.0.0 · Control.DeepSeq
A quantified type representation.
The Class
1 declarationThis class should be defined for each data type of interest.
Instances15PlateAll, …
PlateAll Integer toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.TypeablePlateAll Bool toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.TypeablePlateAll Char toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.TypeablePlateAll Double toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.TypeablePlateAll Float toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.TypeablePlateAll Int toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.TypeablePlateAll () toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Typeable(Integral a, PlateAll a to, Typeable a, Typeable to, Uniplate to) => PlateAll (Ratio a) toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Typeable(PlateAll from to, Typeable from, Typeable to, Uniplate to) => PlateAll (Maybe from) toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Typeable(PlateAll from to, Typeable from, Typeable to, Uniplate to) => PlateAll [from] toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Typeable(PlateAll a to, Typeable a, PlateAll b to, Typeable b, Typeable to, Uniplate to) => PlateAll (Either a b) toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Typeable(PlateAll a to, Typeable a, PlateAll b to, Typeable b, Typeable to, Uniplate to) => PlateAll (a, b) toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Typeable(PlateAll a to, Typeable a, PlateAll b to, Typeable b, PlateAll c to, Typeable c, Typeable to, Uniplate to) => PlateAll (a, b, c) toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Typeable(PlateAll a to, Typeable a, PlateAll b to, Typeable b, PlateAll c to, Typeable c, PlateAll d to, Typeable d, Typeable to, Uniplate to) => PlateAll (a, b, c, d) toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Typeable(PlateAll a to, Typeable a, PlateAll b to, Typeable b, PlateAll c to, Typeable c, PlateAll d to, Typeable d, PlateAll e to, Typeable e, Typeable to, Uniplate to) => PlateAll (a, b, c, d, e) toDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Typeable
The Combinators
4 declarationsThe main combinator used to start the chain.
The field to the right may contain the target.
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.
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