HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulebase-compat-0.14.1Haskell2010

Type.Reflection.Compat

  • 6 types
  • 1 class
  • 21 values
classclass Typeable (a :: k) where
#

The class Typeable allows a concrete representation of a type to be calculated.

datadata TypeRep (a :: k) where
#

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

Instances5TestEquality, Eq, Ord, Show, NFData
  • TestEquality TypeRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • Eq (TypeRep a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • Ord (TypeRep a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • Show (TypeRep a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • NFData (TypeRep a)Defined in deepseq-1.5.0.0 · Control.DeepSeq
patternpattern TypeRep :: () => Typeable a => TypeRep a
#

A explicitly bidirectional pattern synonym to construct a concrete representation of a type.

As an expression: Constructs a singleton TypeRep a given a implicit 'Typeable a' constraint:

TypeRep @a :: Typeable a => TypeRep a

As a pattern: Matches on an explicit TypeRep a witness bringing an implicit Typeable a constraint into scope.

f :: TypeRep a -> ..
f TypeRep = {- Typeable a in scope -}
datadata Module
#
Instances3Eq, Show, NFData
  • Eq ModuleDefined in ghc-prim-0.12.0 · GHC.Classes
  • Show ModuleDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • NFData ModuleDefined in deepseq-1.5.0.0 · Control.DeepSeq
datadata TyCon
#
Instances4Eq, Ord, Show, NFData
  • Eq TyConDefined in ghc-prim-0.12.0 · GHC.Classes
  • Ord TyConDefined in ghc-prim-0.12.0 · GHC.Classes
  • Show TyConDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • NFData TyConDefined in deepseq-1.5.0.0 · Control.DeepSeq

    NOTE: Prior to deepseq-1.4.4.0 this instance was only defined for base-4.8.0.0 and later.

datadata (:~~:) (a :: k1) (b :: k2) where
#

Kind heterogeneous propositional equality. Like :~:, a :~~: b is inhabited by a terminating value if and only if a is the same type as b.

Constructors

Instances13Category, TestCoercion, TestEquality, NFData2, NFData1, Bounded, …
  • Category (:~~:)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Category
  • TestCoercion ((:~~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • TestEquality ((:~~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • NFData2 (:~~:)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • NFData1 ((:~~:) a)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • a ~~ b => Bounded (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • a ~~ b => Enum (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Eq (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • (Typeable i, Typeable j, Typeable a, Typeable b, a ~~ b) => Data (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Ord (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • a ~~ b => Read (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Show (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • NFData (a :~~: b)Defined in deepseq-1.5.0.0 · Control.DeepSeq
datadata (:~:) (a :: k) (b :: k) where
#

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.

Constructors

Instances13Category, TestCoercion, TestEquality, NFData2, NFData1, Bounded, …
  • Category (:~:)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Category
  • TestCoercion ((:~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • TestEquality ((:~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • NFData2 (:~:)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • NFData1 ((:~:) a)Defined in deepseq-1.5.0.0 · Control.DeepSeq
  • a ~ b => Bounded (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • a ~ b => Enum (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Eq (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • (a ~ b, Data a) => Data (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Ord (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • a ~ b => Read (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Show (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • NFData (a :~: b)Defined in deepseq-1.5.0.0 · Control.DeepSeq
patternpattern Fun :: () => (k ~ Type, fun ~~ (arg -> res)) => TypeRep arg -> TypeRep res -> TypeRep fun
#

The function type constructor.

For instance,

typeRep @(Int -> Char) === Fun (typeRep @Int) (typeRep @Char)
patternpattern App :: () => t ~ a b => TypeRep a -> TypeRep b -> TypeRep t
#

A type application.

For instance,

typeRep @(Maybe Int) === App (typeRep @Maybe) (typeRep @Int)

Note that this will also match a function type,

typeRep @(Int# -> Char)
  ===
App (App arrow (typeRep @Int#)) (typeRep @Char)

where arrow :: TypeRep ((->) :: TYPE IntRep -> Type -> Type).

patternpattern Con :: () => NotApplication a => TyCon -> TypeRep a
#

Pattern match on a type constructor

patternpattern Con' :: () => NotApplication a => TyCon -> [SomeTypeRep] -> TypeRep a
#

Pattern match on a type constructor including its instantiated kind variables.

For instance,

App (Con' proxyTyCon ks) intRep = typeRep @(Proxy @Int)

will bring into scope,

proxyTyCon :: TyCon
ks         == [someTypeRep Type] :: [SomeTypeRep]
intRep     == typeRep Int
patternpattern TypeRep :: () => Typeable a => TypeRep a
#

A explicitly bidirectional pattern synonym to construct a concrete representation of a type.

As an expression: Constructs a singleton TypeRep a given a implicit 'Typeable a' constraint:

TypeRep @a :: Typeable a => TypeRep a

As a pattern: Matches on an explicit TypeRep a witness bringing an implicit Typeable a constraint into scope.

f :: TypeRep a -> ..
f TypeRep = {- Typeable a in scope -}