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

Moduleghc-9.10.3GHC2021

GHC.Core.TyCo.Rep

  • 27 types
  • 37 values
  • Packageghc-9.10.3
  • Exports66
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceRep.hs

Types

14 declarations
datadata Type
#

Constructors

  • TyVarTy Var

    Vanilla type or kind variable (*never* a coercion variable)

  • AppTy Type Type

    Type application to something other than a TyCon. Parameters:

    1) Function: must not be a TyConApp or CastTy, must be another AppTy, or TyVarTy See Note [Respecting definitional equality] (EQ1) about the no CastTy requirement

    2) Argument type

  • TyConApp TyCon [KindOrType]

    Application of a TyCon, including newtypes and synonyms. Invariant: saturated applications of FunTyCon must use FunTy and saturated synonyms must use their own constructors. However, unsaturated FunTyCons do appear as TyConApps. Parameters:

    1) Type constructor being applied to.

    2) Type arguments. Might not have enough type arguments here to saturate the constructor. Even type synonyms are not necessarily saturated; for example unsaturated type synonyms can appear as the right hand side of a type synonym.

  • ForAllTy !ForAllTyBinder Type

    A Π type. See Note [Why ForAllTy can quantify over a coercion variable] INVARIANT: If the binder is a coercion variable, it must be mentioned in the Type. See Note [Unused coercion variable in ForAllTy]

  • FunTy

    FUN m t1 t2 Very common, so an important special case See Note [Function types]

  • LitTy TyLit

    Type literals are similar to type constructors.

  • CastTy Type KindCoercion

    A kind cast. The coercion is always nominal. INVARIANT: The cast is never reflexive (EQ2) INVARIANT: The Type is not a CastTy (use TransCo instead) (EQ3) INVARIANT: The Type is not a ForAllTy over a tyvar (EQ4) See Note [Respecting definitional equality]

  • CoercionTy Coercion

    Injection of a Coercion into a type This should only ever be used in the RHS of an AppTy, in the list of a TyConApp, when applying a promoted GADT data constructor

Instances3Data, Outputable, Eq
typetype KindOrType = Type
#

The key representation of types within the compiler

typetype Kind = Type
#

The key type representing kinds in the compiler.

typetype LevityType = Type
#

Type synonym used for types of kind Levity.

typetype KnotTied (ty :: k) = ty
#

A type labeled KnotTied might have knot-tied tycons in it. See Note [Type checking recursive type and class declarations] in GHC.Tc.TyCl

typetype PredType = Type
#

A type of the form p of constraint kind represents a value whose type is the Haskell predicate p, where a predicate is what occurs before the => in a Haskell type.

We use PredType as documentation to mark those types that we guarantee to have this kind.

It can be expanded into its representation, but:

  • The type checker must treat it as opaque

  • The rest of the compiler treats it as transparent

Consider these examples:

f :: (Eq a) => a -> Int
g :: (?x :: Int -> Int) => a -> Int
h :: (r\l) => {r} => {l::Int | r}

Here the Eq a and ?x :: Int -> Int and rl are all called "predicates"

datadata ForAllTyFlag
#

ForAllTyFlag

Is something required to appear in source Haskell (Required), permitted by request (Specified) (visible type application), or prohibited entirely from appearing in source Haskell (Inferred)? See Note [VarBndrs, ForAllTyBinders, TyConBinders, and visibility] in GHC.Core.TyCo.Rep

Instances7Eq, Data, Ord, NFData, Binary, Outputable, …
datadata FunTyFlag
#

The non-dependent version of ForAllTyFlag. See Note [FunTyFlag] Appears here partly so that it's together with its friends ForAllTyFlag and ForallVisFlag, but also because it is used in IfaceType, rather early in the compilation chain

Instances5Eq, Data, Ord, Outputable, Binary

Coercions

15 declarations
datadata Coercion
#
Instances3Data, Outputable, Eq
datadata UnivCoProvenance
#

For simplicity, we have just one UnivCo that represents a coercion from some type to some other type, with (in general) no restrictions on the type. The UnivCoProvenance specifies more exactly what the coercion really is and why a program should (or shouldn't!) trust the coercion. It is reasonable to consider each constructor of UnivCoProvenance as a totally independent coercion form; their only commonality is that they don't tell you what types they coercion between. (That info is in the UnivCo constructor of Coercion.

Constructors

  • PhantomProv KindCoercion

    See Note [Phantom coercions]. Only in Phantom roled coercions

  • ProofIrrelProv KindCoercion

    From the fact that any two coercions are considered equivalent. See Note [ProofIrrelProv]. Can be used in Nominal or Representational coercions

  • PluginProv String

    From a plugin, which asserts that this coercion is sound. The string is for the use of the plugin.

Instances2Data, Outputable

Functions over types

24 declarations
valuemkNakedTyConTy :: TyCon -> Type
#

mkNakedTyConTy creates a nullary TyConApp. In general you should rather use GHC.Core.Type.mkTyConTy, which picks the shared nullary TyConApp from inside the TyCon (via tyConNullaryTy. But we have to build the TyConApp tc [] in that TyCon field; that's what mkNakedTyConTy is for.

valuemkForAllTy :: ForAllTyBinder -> Type -> Type
#

Like mkTyCoForAllTy, but does not check the occurrence of the binder See Note [Unused coercion variable in ForAllTy]

Functions over coercions

1 declaration

Analyzing types

Sizes

4 declarations

Multiplicities

5 declarations
typetype Mult = Type
#

Mult is a type alias for Type.

Mult must contain Type because multiplicity variables are mere type variables (of kind Multiplicity) in Haskell. So the simplest implementation is to make Mult be Type.

Multiplicities can be formed with: - One: GHC.Types.One (= oneDataCon) - Many: GHC.Types.Many (= manyDataCon) - Multiplication: GHC.Types.MultMul (= multMulTyCon)

So that Mult feels a bit more structured, we provide pattern synonyms and smart constructors for these.