Note [TyEqFlags]
When we call the eager unifier, e.g. through 'checkTyEqRhs', we specify what
kind of checks the unifier performs via the 'TyEqFlags' argument. In particular,
when the LHS type in a unification is a type variable, we might want to perform
different checks; this is achieved using the 'TEFTyVar' constructor to 'TyEqFlags':
1. `notUnifying_TEFTask`
LHS is a skolem tyvar, or an untouchable meta-tyvar.
We are not unifying; we only want to perform occurs-checks.
TEFTyVar
{ tefTyVar_occursCheck = OC_Check ...
, tefTyVar_levelCheck = LC_None
, tefTyVar_concreteCheck = CC_None
, tef_fam_app = TEFA_Recurse
}
2a. `unifyingLHSMetaTyVar_TEFTask`
We are unifying; we want to perform an occurs check, a level check,
and a concreteness check (when the meta-tyvar is a ConcreteTv).
TEFTyVar
{ tefTyVar_occursCheck = OC_Check ...
, tefTyVar_levelCheck = LC_Promote ...
, tefTyVar_concreteCheck = CC_Promote or CC_None
depending on whether or not the lhs tv is concrete
, tef_fam_app = TEFA_Recurse
}
2b. `defaulting_TEFTask`
We are in the top-level defaulting code, considering unifying a
touchable meta-tyvar with a type.
TEFTyVar
{ tefTyVar_occursCheck = OC_None
, tefTyVar_levelCheck = LC_None
, tefTyVar_concreteCheck = CC_Promote or CC_None
depending on whether or not the lhs tv is concrete
, tef_fam_app = TEFA_Recurse
}
3. `makeTypeConcrete`
LHS is a fresh ConcreteTv meta-tyvar (see call to 'checkTyEqRhs' in
`makeTypeConcrete`). We are unifying; we only want to perform
a concreteness check.
TEFTyVar
{ tefTyVar_occursCheck = OC_None
, tefTyVar_levelCheck = LC_None
, tefTyVar_concreteCheck = CC_Promote conc_orig
, tef_fam_app = TEFA_Recurse
}
4. `pureTyEqFlags_LHSMetaTyVar`
We want to perform a non-monadic check, i.e. we want to know whether we are able
to unify 'lhs_tv' with 'rhs_ty', but don't want to actually perform
a side-effecting unification. This is used in 'mightEqualLater'.
TEFTyVar
{ tefTyVar_occursCheck = OC_Check ...
, tefTyVar_levelCheck = LC_Check ...
, tefTyVar_concreteCheck = CC_Check or CC_None
depending on whether or not the lhs tv is concrete
, tef_fam_app = TEFA_Recurse
}
Here 'LC_Check True' and 'ConcreteSimpleCheck' make 'checkTyEqRhs' perform
conservative pure checks, without actually carrying out any promotion. References 0
This Note does not link to any other.
Referenced by 3
- GHC.Tc.Utils.Unify call site ×2
- checkTyEqRhs GHC.Tc.Utils.Unify