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
- Packageghc-10.0.0.20260917
- Exports190
- LanguageGHC2024
- LicenceBSD-3-Clause
- SourceConstraint.hs
Constraint
Constructors
CDictCan DictCtA dictionary constraint (canonical)
CIrredCan IrredCtAn irreducible constraint (non-canonical)
CEqCan EqCtAn equality constraint (canonical)
CQuantCan QCInstA quantified constraint (canonical)
CNonCanonical CtEvidenceA non-canonical constraint
See Note [NonCanonical Semantics] in GHC.Tc.Solver.Monad
Instances1Outputable
Outputable CtDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
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]
userTypeError_maybe :: BoolLook everywhere: inside type-family applications, class constraints, AppTys etc?
-> Type-> 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].
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].
Is this type an unsatisfiable constraint? If so, return the error message.
Get the flavour of the given Ct
Get the equality relation for the given Ct
Makes a new equality predicate with the same role as the given evidence.
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.
Returns free variables of constraints as a deterministically ordered list. See Note [Deterministic FV] in GHC.Utils.FV.
Returns free variables of a bag of constraints as a deterministically ordered list. See Note [Deterministic FV] in GHC.Types.Var.FV.
A canonical equality constraint.
See Note [Canonical equalities] in GHC.Tc.Types.Constraint.
Instances1Outputable
Outputable EqCtDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
A canonical dictionary constraint
Constructors
DictCtdi_ev :: CtEvidencedi_cls :: Classdi_tys :: [Xi]di_pend_sc :: ExpansionFuel
Instances1Outputable
Outputable DictCtDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
Constructors
Instances1Outputable
Outputable IrredCtDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
A quantified constraint, also called a "local instance"
(a simplified version of ClsInst).
See Note [Quantified constraints] in GHC.Tc.Solver.Solve
Constructors
QCIA quantified constraint, of type
forall tvs. context => tyqci_ev :: CtEvidenceqci_tvs :: [TcTyVar]tvsqci_theta :: TcThetaTypeqci_body :: TcPredTypethe body of the
forall, i.e.tyqci_pend_sc :: ExpansionFuelInvariants: qci_pend_sc > 0 =>
(a) qci_body is a ClassPred (b) this class has superclass(es), and (c) the superclass(es) are not explored yet
Same as di_pend_sc flag in DictCt See Note [Expanding Recursive Superclasses and ExpansionFuel] in GHC.Tc.Solver
Instances1Outputable
Outputable QCInstDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
Says how many layers of superclasses can we expand. Invariant: ExpansionFuel should always be >= 0 see Note [Expanding Recursive Superclasses and ExpansionFuel]
Do not expand superclasses any further
Consumes one unit of fuel. Precondition: fuel > 0
Returns True if we have any fuel left for superclass expansion
asserts if fuel is non-negative
asserts if fuel is strictly greater than 0
Used to indicate extra information about why a CIrredCan is irreducible
Constructors
IrredShapeReasonThis constraint has a non-canonical shape (e.g.
c Int, for a variablec)NonCanonicalReason CheckTyEqResultAn equality where some invariant other than (TyEq:H) of CEqCan is not satisfied; the CheckTyEqResult states exactly why
ReprEqReasonAn 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 constraintShapeMismatchReasonA nominal equality that relates two wholly different types, like
Int ~# Boolora b ~# 3. INVARIANT: The constraint is a nominal equality constraintAbstractTyConReasonAn equality like
T a b c ~ Q d ewhere eitherTorQis an abstract type constructor. See Note [Skolem abstract data] in GHC.Core.TyCon. INVARIANT: The constraint is an equality constraint between two TyConAppsPluginReasonA typechecker plugin returned this in the pluginBadCts field of TcPluginProgress
InsolubleFunDepReason BoolThis 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
Outputable CtIrredReasonDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
Are we sure that more solving will never solve this constraint?
A set of problems in checking the validity of a type equality.
See checkTypeEq.
Instances3Semigroup, Monoid, Outputable
Semigroup CheckTyEqResultDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.ConstraintMonoid CheckTyEqResultDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.ConstraintOutputable CheckTyEqResultDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
An individual problem that might be logged in a CheckTyEqResult
Instances2Eq, Outputable
Eq CheckTyEqProblemDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.ConstraintOutputable CheckTyEqProblemDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
No problems in checking the validity of a type equality.
Mark a CheckTyEqResult as not having an insoluble occurs-check: any occurs check under a type family or in a representation equality is soluble.
Check whether a CheckTyEqResult is marked successful.
Check whether a CheckTyEqResult has a CheckTyEqProblem
Check whether a CheckTyEqResult has one CheckTyEqProblem and no other
Retain only information about occurs-check failures, because only that matters after recurring into a kind.
A CanEqLHS is a type that can appear on the left of a canonical equality: a type variable or exactly-saturated type family application.
Instances1Outputable
Outputable CanEqLHSDefined in ghc-10.0.0.20260917 · GHC.Core.Predicate
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.
Retrieve the kind of a CanEqLHS
Are two CanEqLHSs equal?
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.
Instances1Outputable
Outputable HoleDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
Used to indicate which sort of hole we have.
Constructors
ExprHole HoleExprRefEither 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.
TypeHoleA hole in a type (PartialTypeSignatures)
ConstraintHoleA 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
Outputable HoleSortDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
Does this hole represent an "out of scope" error?
See Note [Insoluble holes]
A delayed error, to be reported after constraint solving, in order to benefit from deferred unifications.
Constructors
DE_Hole HoleA hole (in a type or in a term).
See Note [Holes in expressions].
DE_NotConcrete NotConcreteErrorA type could not be ensured to be concrete.
See Note [The Concrete mechanism] in GHC.Tc.Utils.Concrete.
DE_Multiplicity TcCoercion CtLocAn error if the TcCoercion isn't a reflexivity constraint.
See Note [Coercion errors in tcSubMult] in GHC.Tc.Utils.Unify.
Instances1Outputable
Outputable DelayedErrorDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
Why did we require that a certain type be concrete?
Constructors
NCE_FRRConcreteness was required by a representation-polymorphism check.
See Note [The Concrete mechanism] in GHC.Tc.Utils.Concrete.
nce_loc :: CtLocWhere did this check take place?
nce_frr_origin :: FixedRuntimeRepOriginWhich representation-polymorphism check did we perform?
Instances1Outputable
Outputable NotConcreteErrorDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
Constructors
Instances3Semigroup, Monoid, Outputable
Semigroup WantedConstraintsDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.ConstraintMonoid WantedConstraintsDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.ConstraintOutputable WantedConstraintsDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
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.
Returns free variables of WantedConstraints as a non-deterministic set. See Note [Deterministic FV] in GHC.Types.Var.FV.
Returns free variables of WantedConstraints as a deterministically ordered list. See Note [Deterministic FV] in GHC.Types.Var.FV.
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]
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.
Gather all the type variables from WantedConstraints that it would be unhelpful to default. For the moment, these are only ConcreteTv metavariables participating in a nominal equality whose other side is not concrete; it's usually better to report those as errors instead of defaulting.
Constructors
Instances1Outputable
Outputable ImplicationDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
Constructors
Instances1Outputable
Outputable ImplicStatusDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
Instances4Eq, Semigroup, Monoid, Outputable
Eq HasGivenEqsDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.ConstraintSemigroup HasGivenEqsDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.ConstraintMonoid HasGivenEqsDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.ConstraintOutputable HasGivenEqsDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
Local typechecker environment for a constraint.
Used to restore the environment of a constraint
when reporting errors, see setCtLocM.
See also TcLclCtxt.
Constructors
Constructors
Instances1Outputable
Outputable CtEvidenceDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
A place for type-checking evidence to go after it is generated.
Wanted equalities use HoleDest,
other Wanteds use EvVarDest.
Constructors
EvVarDest EvVarbind this var to the evidence EvVarDest is always used for non-type-equalities e.g. class constraints
HoleDest CoercionHolefill in this hole with the evidence HoleDest is always used for type-equalities See Note [Coercion holes] in GHC.Core.TyCo.Rep
Instances1Outputable
Outputable TcEvDestDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
Get the equality relation relevant for a CtEvidence
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.
Set the rewriter set of a Wanted constraint.
Get the rewrite-role relevant for a CtEvidence See Note [The rewrite-role of a constraint]
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
Set the type of CtEvidence.
This function ensures that the invariants on CtEvidence hold, by updating the evidence and the ctev_pred in sync with each other. See Note [CtEvidence invariants].
Returns free variables of constraints as a deterministically ordered list. See Note [Deterministic FV] in GHC.Types.Var.FV.
Returns free variables of constraints as a non-deterministic set
Returns free variables of a bag of constraints as a deterministically ordered list. See Note [Deterministic FV] in GHC.Types.Var.FV.
Evidence for a Given constraint
Instances1Outputable
Outputable GivenCtEvidenceDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
Evidence for a Wanted constraint
Constructors
Instances1Outputable
Outputable WantedCtEvidenceDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
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
Constructors
Instances1Outputable
Outputable CoercionPlusHolesDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.Rep
Instances2Eq, Outputable
Eq CtFlavourDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.ConstraintOutputable CtFlavourDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.Constraint
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
Extract the flavour, role, and boxity from a CtEvidence
Extract the flavour and role from a Ct
Extract the flavour and role from a Ct