base-4.20.2.0: Core data structures and operations

Copyright | (c) The University of Glasgow CWI 2001--2015
License | BSD-style (see the file libraries/base/LICENSE)
Safe Haskell | None
Language | Haskell2010

Type.Reflection.Unsafe

Contents

- Type representations
- Kind representations
- Type constructors

Description

The representations of the types `TyCon` and `TypeRep`, and the function `mkTyCon` which is used by derived instances of `Typeable` to construct `TyCon`s.

Be warned, these functions can be used to construct ill-kinded type representations.

Synopsis

- data TypeRep (a :: k)
- mkTrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). TypeRep a -> TypeRep b -> TypeRep (a b)
- mkTyCon :: String -> String -> String -> Int -> KindRep -> TyCon
- typeRepFingerprint :: forall {k} (a :: k). TypeRep a -> Fingerprint
- someTypeRepFingerprint :: SomeTypeRep -> Fingerprint
- data KindRep where
  - KindRepTyConApp TyCon [KindRep]
  - KindRepVar !KindBndr
  - KindRepApp KindRep KindRep
  - KindRepFun KindRep KindRep
  - KindRepTYPE !RuntimeRep
  - KindRepTypeLitS TypeLitSort Addr#
  - KindRepTypeLitD TypeLitSort [Char]
  - pattern KindRepTypeLit :: TypeLitSort -> String -> KindRep
- data TypeLitSort
  - = TypeLitSymbol
  - | TypeLitNat
  - | TypeLitChar
- data TyCon
- mkTrCon :: forall k (a :: k). TyCon -> [SomeTypeRep] -> TypeRep a
- tyConKindRep :: TyCon -> KindRep
- tyConKindArgs :: TyCon -> Int
- tyConFingerprint :: TyCon -> Fingerprint

# Type representations

data TypeRep (a :: k) Source #

TypeRep is a concrete representation of a (monomorphic) type. `TypeRep` supports reasonably efficient equality. See Note [Grand plan for Typeable] in GHC.Tc.Instance.Typeable

#### Instances

Instances details

TestEquality (TypeRep :: k -> Type) |
Instance details Defined in GHC.Internal.Data.Typeable.Internal Methods testEquality :: forall (a :: k) (b :: k). TypeRep a -> TypeRep b -> Maybe (a :~: b) Source #
Show (TypeRep a) |
Instance details Defined in GHC.Internal.Data.Typeable.Internal Methods showsPrec :: Int -> TypeRep a -> ShowS Source # show :: TypeRep a -> String Source # showList :: [TypeRep a] -> ShowS Source #
Eq (TypeRep a) | Since: base-2.1
Instance details Defined in GHC.Internal.Data.Typeable.Internal Methods (==) :: TypeRep a -> TypeRep a -> Bool Source # (/=) :: TypeRep a -> TypeRep a -> Bool Source #
Ord (TypeRep a) | Since: base-4.4.0.0

Instance details

Defined in GHC.Internal.Data.Typeable.Internal

Methods

compare :: TypeRep a -> TypeRep a -> Ordering Source #

(<) :: TypeRep a -> TypeRep a -> Bool Source #

(<=) :: TypeRep a -> TypeRep a -> Bool Source #

(>) :: TypeRep a -> TypeRep a -> Bool Source #

(>=) :: TypeRep a -> TypeRep a -> Bool Source #

max :: TypeRep a -> TypeRep a -> TypeRep a Source #

min :: TypeRep a -> TypeRep a -> TypeRep a Source #

mkTrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). TypeRep a -> TypeRep b -> TypeRep (a b) Source #

Construct a representation for a type application.

mkTyCon Source #

Arguments

:: String | package name
-> String | module name
-> String | the name of the type constructor
-> Int | number of kind variables
-> KindRep | kind representation
-> TyCon | A unique `TyCon` object Used when the strings are dynamically allocated, eg from binary deserialisation

Exquisitely unsafe.

typeRepFingerprint :: forall {k} (a :: k). TypeRep a -> Fingerprint Source #

Observe the `Fingerprint` of a type representation

Since: base-4.8.0.0

someTypeRepFingerprint :: SomeTypeRep -> Fingerprint Source #

# Kind representations

data KindRep Source #

The representation produced by GHC for conjuring up the kind of a `TypeRep`.

Constructors

KindRepTyConApp TyCon [KindRep] |
KindRepVar !KindBndr |
KindRepApp KindRep KindRep |
KindRepFun KindRep KindRep |
KindRepTYPE !RuntimeRep |
KindRepTypeLitS TypeLitSort Addr# |
KindRepTypeLitD TypeLitSort [Char] |

Bundled Patterns

pattern KindRepTypeLit :: TypeLitSort -> String -> KindRep |

#### Instances

Instances details

Show KindRep |
Instance details Defined in GHC.Internal.Show Methods showsPrec :: Int -> KindRep -> ShowS Source # show :: KindRep -> String Source # showList :: [KindRep] -> ShowS Source #

data TypeLitSort Source #

Constructors

TypeLitSymbol |
TypeLitNat |
TypeLitChar |

#### Instances

Instances details

Show TypeLitSort | Since: base-4.11.0.0
Instance details Defined in GHC.Internal.Show Methods showsPrec :: Int -> TypeLitSort -> ShowS Source # show :: TypeLitSort -> String Source # showList :: [TypeLitSort] -> ShowS Source #

# Type constructors

data TyCon Source #

#### Instances

Instances details

Show TyCon | Since: base-2.1
Instance details Defined in GHC.Internal.Show Methods showsPrec :: Int -> TyCon -> ShowS Source # show :: TyCon -> String Source # showList :: [TyCon] -> ShowS Source #
Eq TyCon |
Instance details Defined in GHC.Classes Methods (==) :: TyCon -> TyCon -> Bool Source # (/=) :: TyCon -> TyCon -> Bool Source #
Ord TyCon |
Instance details Defined in GHC.Classes Methods compare :: TyCon -> TyCon -> Ordering Source # (<) :: TyCon -> TyCon -> Bool Source # (<=) :: TyCon -> TyCon -> Bool Source # (>) :: TyCon -> TyCon -> Bool Source # (>=) :: TyCon -> TyCon -> Bool Source # max :: TyCon -> TyCon -> TyCon Source # min :: TyCon -> TyCon -> TyCon Source #

mkTrCon :: forall k (a :: k). TyCon -> [SomeTypeRep] -> TypeRep a Source #

Construct a representation for a type constructor applied at a monomorphic kind.

Note that this is unsafe as it allows you to construct ill-kinded types.

tyConKindRep :: TyCon -> KindRep Source #

tyConKindArgs :: TyCon -> Int Source #

tyConFingerprint :: TyCon -> Fingerprint Source #