type-0.2.0: Dynamic casting library with support for arbitrary rank type kinds.

Data.Type.Typeable

Description

Contains functions to help making Typeable instances from Meta instances.

Warning: The TypeRep is derived from the Meta instances even if they might have a Typeable instance. These functions use non-qualified names to make up the TypeReps, which seems to be common.

Synopsis

Documentation

deriveTypeableFromMetaSource

Arguments

:: Name

The name of the type constructor.

-> Q [Dec] 

Used to derive instances of the Typeable classes from the Meta classes. Requires the ScopedTypeVariables language option.

 import Data.Type
 import Data.Type.Typeable

 data T (m :: * -> *) a = ...
 deriveMeta ''T
 deriveTypeableFromMeta ''T

Yields a Typeable instance like:

 instance (MetaX m) => Typeable1 (T m) where
   ...

The template haskell funtions in this module expect to find symbols exported from Data.Type module under Data.Type. Thus change:

 import qualified Data.Type as T

Into:

 import qualified Data.Type
 import qualified Data.Type as T

It would be possible to drop this requirement, but currently not without bloating the library unnecessarily.

declareTypeableFromMetaSource

Arguments

:: Kind

The kind of the type constructor.

-> Name

The name of the type constructor.

-> Q [Dec] 

Used internally to declare instances of the Typeable classes from the Meta classes.

convertTypeIDToTypeRep :: TypeID -> TypeRepSource

Used internally to convert TypeIDs to TypeReps. Gives non-qualified names to mkTyCon.