HORIZON HASKELLDocslts/ghc-10.0.x04404a62026-10-19Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 04404a6 · 2026-10-19

Types

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
  • 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
  • Data TypeDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.Rep
  • Outputable TypeDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.Rep
  • Eq (DeBruijn Type)Defined in ghc-10.0.0.20260917 · GHC.Core.Map.Type
typetype Kind = Type

The key type representing kinds in the compiler.

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

Instances8Eq, Data, Ord, NFData, Binary, OutputableBndrFlag, …
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

Instances6Eq, Data, Ord, NFData, Outputable, Binary

Coercions

datadata Coercion
Instances3Data, Outputable, Eq

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

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

  • ProofIrrelProv

    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 and the variable set are for the use by the plugin.

  • SubMultProv

    A submultiplicity coercion

Instances6Eq, Data, Ord, NFData, Outputable, Binary
newtypenewtype CoHoleSet

A CoHoleSet stores a set of CoercionHoles that have been used to rewrite a constraint. See Note [Wanteds rewrite Wanteds: rewriter-sets] in GHC.Tc.Types.Constraint

Instances3Semigroup, Monoid, Outputable

Functions over types

Functions over coercions

Analyzing types

Sizes

Multiplicities

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.