Type.Reflection.Unsafe

base-4.10.1.0: Basic libraries

Copyright | (c) The University of Glasgow CWI 2001--2015
License | BSD-style (see the file libraries/base/LICENSE)
Safe Haskell | Safe
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 :: k1 -> k2) -> TypeRep (b :: k1) -> TypeRep (a b)
- mkTyCon :: String -> String -> String -> Int -> KindRep -> TyCon
- typeRepFingerprint :: TypeRep a -> Fingerprint
- someTypeRepFingerprint :: SomeTypeRep -> Fingerprint
- data KindRep :: *
  - = KindRepTyConApp TyCon [KindRep]
  - | KindRepVar !KindBndr
  - | KindRepApp KindRep KindRep
  - | KindRepFun KindRep KindRep
  - | KindRepTYPE !RuntimeRep
  - | KindRepTypeLitS TypeLitSort Addr#
  - | KindRepTypeLitD TypeLitSort [Char]
- data TypeLitSort :: *
  - = TypeLitSymbol
  - | TypeLitNat
- 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 #

A concrete representation of a (monomorphic) type. `TypeRep` supports reasonably efficient equality.

Instances

TestEquality k (TypeRep k) # |
Methods testEquality :: f a -> f b -> Maybe ((TypeRep k :~: a) b) Source #
Eq (TypeRep k a) # | Since: 2.1
Methods (==) :: TypeRep k a -> TypeRep k a -> Bool Source # (/=) :: TypeRep k a -> TypeRep k a -> Bool Source #
Ord (TypeRep k a) # | Since: 4.4.0.0
Methods compare :: TypeRep k a -> TypeRep k a -> Ordering Source # (<) :: TypeRep k a -> TypeRep k a -> Bool Source # (<=) :: TypeRep k a -> TypeRep k a -> Bool Source # (>) :: TypeRep k a -> TypeRep k a -> Bool Source # (>=) :: TypeRep k a -> TypeRep k a -> Bool Source # max :: TypeRep k a -> TypeRep k a -> TypeRep k a Source # min :: TypeRep k a -> TypeRep k a -> TypeRep k a Source #
Show (TypeRep k a) # |
Methods showsPrec :: Int -> TypeRep k a -> ShowS Source # show :: TypeRep k a -> String Source # showList :: [TypeRep k a] -> ShowS Source #

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

Construct a representation for a type application.

Note that this is known-key to the compiler, which uses it in desugar `Typeable` evidence.

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 :: TypeRep a -> Fingerprint Source #

Observe the `Fingerprint` of a type representation

Since: 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] |

data TypeLitSort :: * Source #

Constructors

TypeLitSymbol |
TypeLitNat |

# Type constructors

data TyCon :: * Source #

Instances

Eq TyCon |
Methods (==) :: TyCon -> TyCon -> Bool Source # (/=) :: TyCon -> TyCon -> Bool Source #
Ord TyCon |
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 #
Show TyCon # | Since: 2.1
Methods showsPrec :: Int -> TyCon -> ShowS Source # show :: TyCon -> String Source # showList :: [TyCon] -> ShowS 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 #