Note [No top-level newtypes on RHS of representational equalities]
Suppose we're in this situation:
work item: [W] c1 : a ~R b
inert: [G] c2 : b ~R Id a
where
newtype Id a = Id a
We want to make sure canEqCanLHS sees [W] a ~R a, after b is rewritten
and the Id newtype is unwrapped. This is assured by requiring only rewritten
types in canEqCanLHS *and* having the newtype-unwrapping check above
the tyvar check in can_eq_nc.
Note that this only applies to saturated applications of newtype TyCons, as
we can't rewrite an unsaturated application. See for example T22310, where
we ended up with:
newtype Compose f g a = ...
[W] t[tau] ~# Compose Foo Bar References 0
This Note does not link to any other.
Referenced by 2
- GHC.Tc.Solver.Equality call site
- Canonical equalities GHC.Tc.Types.Constraint