Note [Danger of adding superclasses during solving]
Here's a serious, but now out-dated example, from #4497: class Num (RealOf t) => Normed t type family RealOf x Assume the generated wanted constraint is: [W] RealOf e ~ e [W] Normed e If we were to be adding the superclasses during simplification we'd get: [W] RealOf e ~ e [W] Normed e [W] RealOf e ~ fuv [W] Num fuv ==> e := fuv, Num fuv, Normed fuv, RealOf fuv ~ fuv While looks exactly like our original constraint. If we add the superclass of (Normed fuv) again we'd loop. By adding superclasses definitely only once, during canonicalisation, this situation can't happen.
References 0
This Note does not link to any other.
Referenced by 1
- The superclass story GHC.Tc.Solver.Dict