|Copyright||(c) The University of Glasgow, CWI 2001--2004|
|License||BSD-style (see the file libraries/base/LICENSE)|
Typeable class reifies types to some extent by associating type representations to types. These type representations can be compared, and one can in turn define a type-safe cast operation. To this end, an unsafe cast is guarded by a test for type (representation) equivalence. The module Data.Dynamic uses Typeable for an implementation of dynamics. The module Data.Data uses Typeable and type-safe cast (but not dynamics) to support the "Scrap your boilerplate" style of generic programming.
Since GHC 7.8,
Typeable is poly-kinded. The changes required for this might break some old programs involving
Typeable. More details on this, including how to fix your code, can be found on the PolyTypeable wiki page
Typeable allows a concrete representation of a type to be calculated.
Takes a value of type
a and returns a concrete representation of that type.
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.
The type-safe cast operation
Extract a witness of equality of two types
A flexible variation parameterised in a type constructor
k1 -> k2
k1 -> k2 -> k3
A concrete, poly-kinded proxy type
|Monad (Proxy *)|
|Functor (Proxy *)|
|Applicative (Proxy *)|
|Foldable (Proxy *)|
|Traversable (Proxy *)|
|Bounded (Proxy k s)|
|Enum (Proxy k s)|
|Eq (Proxy k s)|
|Data t => Data (Proxy * t)|
|Ord (Proxy k s)|
|Read (Proxy k s)|
|Show (Proxy k s)|
|Ix (Proxy k s)|
|Generic (Proxy * t)|
|Monoid (Proxy k s)|
|type Rep (Proxy k t)|
A concrete representation of a (monomorphic) type.
TypeRep supports reasonably efficient equality.
Fingerprint of a type representation
Helper to fully evaluate
TypeRep for use as
Observe string encoding of a type representation
Helper to fully evaluate
TyCon for use as
the name of the type constructor
A==A' ^ B==B' ^ C==C' ==> mkTyCon A B C == mkTyCon A' B' C'
Applies a monomorphic type constructor to a sequence of types
Adds a TypeRep argument to a TypeRep.
A special case of
mkTyConApp, which applies the function type constructor to a pair of types.
Splits a type constructor application. Note that if the type construcotr is polymorphic, this will not return the kinds that were used. See
splitPolyTyConApp if you need all parts.
Observe the type constructor of a type representation
Observe the argument types of a type representation
© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).