Description
The 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.
The class Typeable
allows a concrete representation of a type to be calculated.
Methods
Takes a value of type a
and returns a concrete representation of that type. The value of the argument should be ignored by any instance of Typeable
, so that it is safe to pass undefined
as the argument.
A concrete representation of a (monomorphic) type. TypeRep
supports reasonably efficient equality.
showsTypeRep :: TypeRep -> ShowSSource
tyConPackage :: TyCon -> StringSource
tyConModule :: TyCon -> StringSource
tyConName :: TyCon -> StringSource
Construction of type representationsDeprecated: either derive Typeable, or use mkTyCon3 instead
Backwards-compatible API
Builds a TyCon
object representing a type constructor. An implementation of Data.Typeable should ensure that the following holds:
A==A' ^ B==B' ^ C==C' ==> mkTyCon A B C == mkTyCon A' B' C'Observation of type representations The other Typeable classes
Note: The general instances are provided for GHC only.
Default instancesNote: These are not needed by GHC, for which these instances are generated by general instance declarations.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4