HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleghc-9.10.3GHC2021

GHC.Tc.Types.Constraint

This module defines types and simple operations over constraints, as used in the type-checker and constraint solver.

  • 30 types
  • 170 values
  • Packageghc-9.10.3
  • Exports200
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceConstraint.hs
typetype Xi = TcType
#

A Xi-type is one that has been fully rewritten with respect to the inert set; that is, it has been rewritten by the algorithm in GHC.Tc.Solver.Rewrite. (Historical note: Xi, for years and years, meant that a type was type-family-free. It does *not* mean this any more.)

True if taking superclasses of givens, or of wanteds (to perhaps expose more equalities or functional dependencies) might help to solve this constraint. See Note [When superclasses help]

Does this constraint contain an user error message?

That is, the type is either of the form Unsatisfiable err, or it contains a type of the form TypeError msg, either at the top level or nested inside the type.

valuetyCoVarsOfCtList :: Ct -> [TcTyCoVar]
#

Returns free variables of constraints as a deterministically ordered list. See Note [Deterministic FV] in GHC.Utils.FV.

typetype ExpansionFuel = Int
#

Says how many layers of superclasses can we expand. Invariant: ExpansionFuel should always be >= 0 see Note [Expanding Recursive Superclasses and ExpansionFuel]

datadata CtIrredReason
#

Used to indicate extra information about why a CIrredCan is irreducible

Constructors

  • IrredShapeReason

    This constraint has a non-canonical shape (e.g. c Int, for a variable c)

  • NonCanonicalReason CheckTyEqResult

    An equality where some invariant other than (TyEq:H) of CEqCan is not satisfied; the CheckTyEqResult states exactly why

  • ReprEqReason

    An equality that cannot be decomposed because it is representational. Example: a b ~R# Int. These might still be solved later. INVARIANT: The constraint is a representational equality constraint

  • ShapeMismatchReason

    A nominal equality that relates two wholly different types, like Int ~# Bool or a b ~# 3. INVARIANT: The constraint is a nominal equality constraint

  • AbstractTyConReason

    An equality like T a b c ~ Q d e where either T or Q is an abstract type constructor. See Note [Skolem abstract data] in GHC.Core.TyCon. INVARIANT: The constraint is an equality constraint between two TyConApps

  • PluginReason

    A typechecker plugin returned this in the pluginBadCts field of TcPluginProgress

Instances1Outputable

Is a type a canonical LHS? That is, is it a tyvar or an exactly-saturated type family application? Does not look through type synonyms.

datadata Hole
#

A hole stores the information needed to report diagnostics about holes in terms (unbound identifiers or underscores) or in types (also called wildcards, as used in partial type signatures). See Note [Holes].

Constructors

Instances1Outputable
datadata HoleSort
#

Used to indicate which sort of hole we have.

Constructors

  • ExprHole HoleExprRef

    Either an out-of-scope variable or a "true" hole in an expression (TypedHoles). The HoleExprRef says where to write the the erroring expression for -fdefer-type-errors.

  • TypeHole

    A hole in a type (PartialTypeSignatures)

  • ConstraintHole

    A hole in a constraint, like @f :: (_, Eq a) => ... Differentiated from TypeHole because a ConstraintHole is simplified differently. See Note [Do not simplify ConstraintHoles] in GHC.Tc.Solver.

Instances1Outputable
datadata DelayedError
#

A delayed error, to be reported after constraint solving, in order to benefit from deferred unifications.

Constructors

Instances1Outputable
datadata NotConcreteError
#

Why did we require that a certain type be concrete?

Constructors

Instances1Outputable
datadata NotConcreteReason
#

Why did we decide that a type was not concrete?

Constructors

Checks whether a the given wanted constraints are solved, i.e. that there are no simple constraints left and all the implications are solved.

valueinsolubleCt :: Ct -> Bool
#

Returns True of constraints that are definitely insoluble, as well as TypeError constraints. Can return True for Given constraints, unlike insolubleWantedCt.

The function is tuned for application after constraint solving i.e. assuming canonicalisation has been done That's why it looks only for IrredCt; all insoluble constraints are put into CIrredCan

datadata TcEvDest
#

A place for type-checking evidence to go after it is generated.

  • Wanted equalities use HoleDest,

  • other Wanteds use EvVarDest.

Constructors

  • EvVarDest EvVar

    bind this var to the evidence EvVarDest is always used for non-type-equalities e.g. class constraints

  • HoleDest CoercionHole

    fill in this hole with the evidence HoleDest is always used for type-equalities See Note [Coercion holes] in GHC.Core.TyCo.Rep

Instances1Outputable
typetype CtFlavourRole = (CtFlavour, EqRel)
#

Whether or not one Ct can rewrite another is determined by its flavour and its equality relation. See also Note [Flavours with roles] in GHC.Tc.Solver.InertSet