Note [Don't cycle-break Wanteds when not unifying]
Consdier [W] a[2] ~ Maybe (F a[2]) Should we cycle-break this Wanted, thus? [W] a[2] ~ Maybe delta[2] [W] delta[2] ~ F a[2] For a start, this is dodgy because we might just unify delta, thus undoing what we have done, and getting an infinite loop in the solver. Even if we somehow prevented ourselves from doing so, is there any merit in the split? Maybe: perhaps we can use that equality on `a` to unlock other constraints? Consider type instance F (Maybe _) = Bool [G] g1: a ~ Maybe Bool [W] w1: a ~ Maybe (F a) If we loop-break w1 to get [W] w1': a ~ Maybe gamma [W] w3: gamma ~ F a Now rewrite w3 with w1' [W] w3': gamma ~ F (Maybe gamma) Now use the type instance to get gamma := Bool Now we are left with [W] w1': a ~ Maybe Bool which we can solve from the Given. BUT in this situation we could have rewritten the /original/ Wanted from the Given, like this: [W] w1': Maybe Bool ~ Maybe (F (Maybe Bool)) and that is readily soluble. In short: loop-breaking Wanteds, when we aren't unifying, seems of no merit. Hence TEFA_Recurse, rather than TEFA_Break, in `wanted_flags` in `checkTypeEq`.
References 0
This Note does not link to any other.
Referenced by 2
- Type equality cycles GHC.Tc.Solver.Equality
- GHC.Tc.Utils.Unify call site