HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduleghc-10.0.0.20260917GHC2024

GHC.Tc.Types.Constraint

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

  • 30 types
  • 160 values
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]

valueuserTypeError_maybe
  1. :: Bool

    Look everywhere: inside type-family applications, class constraints, AppTys etc?

  2. -> Type
  3. -> Maybe ErrorMsgType
#

Does this type contain 'TypeError msg', either at the top-level or nested within it somewhere?

If so, return the error message.

See Note [Custom type errors in constraints].

valuecontainsUserTypeError
  1. :: Bool

    look inside type-family applications, AppTy, etc?

  2. -> PredType
  3. -> Bool
#

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.

See Note [Custom type errors in constraints].

valuetyCoVarsOfCt :: Ct -> TcTyCoVarSet
#

Returns free variables of constraints as a non-deterministic set This must consult only the ctPred, so that it gets *tidied* fvs if the constraint has been tidied. Tidying a constraint does not tidy the fields of the Ct, only the predicate in the CtEvidence.

Returns free variables of a bag of constraints as a non-deterministic set. See Note [Deterministic FV] in GHC.Utils.FV.

valuetyCoVarsOfCtList :: Ct -> [TcTyCoVar]
#

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

datadata QCInst
#

A quantified constraint, also called a "local instance" (a simplified version of ClsInst).

See Note [Quantified constraints] in GHC.Tc.Solver.Solve

Constructors

Instances1Outputable
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

  • InsolubleFunDepReason Bool

    This constraint generated a functional dependency that is insoluble -- so we can regard this constraint too as insoluble See Note [Insoluble fundeps] in GHC.Tc.Solver.FunDeps

    Bool = True = insolubility arises from top-level constraints only See (IFD2) in the Note [Insoluble fundeps]

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 in expressions] for holes in terms.

Constructors

Instances1Outputable
  • Outputable HoleDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
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

  • DE_Hole Hole

    A hole (in a type or in a term).

    See Note [Holes in expressions].

  • DE_NotConcrete NotConcreteError

    A type could not be ensured to be concrete.

    See Note [The Concrete mechanism] in GHC.Tc.Utils.Concrete.

  • DE_Multiplicity TcCoercion CtLoc

    An error if the TcCoercion isn't a reflexivity constraint.

    See Note [Coercion errors in tcSubMult] in GHC.Tc.Utils.Unify.

Instances1Outputable

isEmptyWC sees if a WantedConstraints is truly empty, including having no implications.

It's possible that it might have solved implications, which are left around just so we can report unreachable code. So: isEmptyWC implies isSolvedWC but not vice versa

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

valueinsolubleWantedCt :: Ct -> Bool
#

Is this a definitely insoluble Wanted constraint? Namely:

  • a Wanted,

  • which is insoluble (as per insolubleCt),

  • that does not arise from a Given or a Wanted/Wanted fundep interaction.

See Note [Insoluble Wanteds]

valueinsolubleCt :: Ct -> Bool
#

Returns True of constraints that are definitely insoluble, including constraints that include custom type errors, as per (1) in Note [Custom type errors in constraints].

Can return True for Given constraints, unlike insolubleWantedCt.

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

Extract the set of rewriters from a CtEvidence See Note [Wanteds rewrite Wanteds: rewriter-sets] If the provided CtEvidence is not for a Wanted, just return an empty set.

Return the rewrite-role of an abitrary CtEvidence See Note [The rewrite-role of a constraint] We return ReprEq for (a ~R# b) and NomEq for all other preds

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
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