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
Instances1Outputable
Outputable CtDefined in ghc-9.10.3 · 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]
Is this an user error message type, i.e. either the form TypeError err or
Unsatisfiable err?
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.
A constraint is considered to be a custom type error, if it contains custom type errors anywhere in it. 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
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.Utils.FV.
Instances1Outputable
Outputable EqCtDefined in ghc-9.10.3 · GHC.Tc.Types.Constraint
Constructors
DictCtdi_ev :: CtEvidencedi_cls :: Classdi_tys :: [Xi]di_pend_sc :: ExpansionFuel
Instances1Outputable
Outputable DictCtDefined in ghc-9.10.3 · GHC.Tc.Types.Constraint
Constructors
Instances1Outputable
Outputable IrredCtDefined in ghc-9.10.3 · GHC.Tc.Types.Constraint
Constructors
Instances1Outputable
Outputable QCInstDefined in ghc-9.10.3 · 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
Instances1Outputable
Outputable CtIrredReasonDefined in ghc-9.10.3 · 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-9.10.3 · GHC.Tc.Types.ConstraintMonoid CheckTyEqResultDefined in ghc-9.10.3 · GHC.Tc.Types.ConstraintOutputable CheckTyEqResultDefined in ghc-9.10.3 · GHC.Tc.Types.Constraint
An individual problem that might be logged in a CheckTyEqResult
Instances2Eq, Outputable
Eq CheckTyEqProblemDefined in ghc-9.10.3 · GHC.Tc.Types.ConstraintOutputable CheckTyEqProblemDefined in ghc-9.10.3 · 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-9.10.3 · GHC.Tc.Types.Constraint
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].
Instances1Outputable
Outputable HoleDefined in ghc-9.10.3 · 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-9.10.3 · 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].
DE_NotConcrete NotConcreteErrorA type could not be ensured to be concrete.
See Note [The Concrete mechanism] in GHC.Tc.Utils.Concrete.
Instances1Outputable
Outputable DelayedErrorDefined in ghc-9.10.3 · 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?
nce_reasons :: NonEmpty NotConcreteReasonWhy did the check fail?
Instances1Outputable
Outputable NotConcreteErrorDefined in ghc-9.10.3 · GHC.Tc.Types.Constraint
Why did we decide that a type was not concrete?
Constructors
NonConcreteTyCon TyCon [TcType]The type contains a
TyConAppof a non-concrete TyCon.See Note [Concrete types] in GHC.Tc.Utils.Concrete.
NonConcretisableTyVar TyVarThe type contains a type variable that could not be made concrete (e.g. a skolem type variable).
ContainsCast TcType TcCoercionNThe type contains a cast.
ContainsForall ForAllTyBinder TcTypeThe type contains a forall.
ContainsCoercionTy TcCoercionThe type contains a
CoercionTy.
Constructors
Instances1Outputable
Outputable WantedConstraintsDefined in ghc-9.10.3 · GHC.Tc.Types.Constraint
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.Utils.FV.
Returns free variables of WantedConstraints as a deterministically ordered list. See Note [Deterministic FV] in GHC.Utils.FV.
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
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-9.10.3 · GHC.Tc.Types.Constraint
Constructors
Instances1Outputable
Outputable ImplicStatusDefined in ghc-9.10.3 · GHC.Tc.Types.Constraint
Instances4Eq, Semigroup, Monoid, Outputable
Eq HasGivenEqsDefined in ghc-9.10.3 · GHC.Tc.Types.ConstraintSemigroup HasGivenEqsDefined in ghc-9.10.3 · GHC.Tc.Types.ConstraintMonoid HasGivenEqsDefined in ghc-9.10.3 · GHC.Tc.Types.ConstraintOutputable HasGivenEqsDefined in ghc-9.10.3 · GHC.Tc.Types.Constraint
See Note [SubGoalDepth]
Instances3Eq, Ord, Outputable
Eq SubGoalDepthDefined in ghc-9.10.3 · GHC.Tc.Types.ConstraintOrd SubGoalDepthDefined in ghc-9.10.3 · GHC.Tc.Types.ConstraintOutputable SubGoalDepthDefined in ghc-9.10.3 · GHC.Tc.Types.Constraint
Constructors
Local typechecker environment for a constraint.
Used to restore the environment of a constraint
when reporting errors, see setCtLocM.
See also TcLclCtxt.
Constructors
CtLocEnvctl_ctxt :: ![ErrCtxt]ctl_loc :: !RealSrcSpanctl_bndrs :: !TcBinderStackctl_tclvl :: !TcLevelctl_in_gen_code :: !Boolctl_rdr :: !LocalRdrEnv
Constructors
Instances1Outputable
Outputable CtEvidenceDefined in ghc-9.10.3 · 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-9.10.3 · 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] If the provided CtEvidence is not for a Wanted, just return an empty set.
Take a CtLoc and moves it to the kind level
Get the role relevant for a CtEvidence
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.Utils.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.Utils.FV.
Stores a set of CoercionHoles that have been used to rewrite a constraint. See Note [Wanteds rewrite Wanteds].
Constructors
Instances3Semigroup, Monoid, Outputable
Semigroup RewriterSetDefined in ghc-9.10.3 · GHC.Tc.Types.ConstraintMonoid RewriterSetDefined in ghc-9.10.3 · GHC.Tc.Types.ConstraintOutputable RewriterSetDefined in ghc-9.10.3 · GHC.Tc.Types.Constraint
Instances2Eq, Outputable
Eq CtFlavourDefined in ghc-9.10.3 · GHC.Tc.Types.ConstraintOutputable CtFlavourDefined in ghc-9.10.3 · 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