Note [Do not add duplicate quantified instances]
As an optimisation, we avoid adding duplicate quantified instances to the inert set; we use a simple duplicate check using tcEqType for simplicity, even though it doesn't account for superficial differences, e.g. it will count the following two constraints as different (#22223): - forall a b. C a b - forall b a. C a b The main logic that allows us to pick local instances, even in the presence of duplicates, is explained in Note [Use only the best matching quantified constraint] in GHC.Tc.Solver.Dict.
References 1
- Use only the best matching quantified constraint GHC.Tc.Solver.Dict
Referenced by 2
- Use only the best matching quantified constraint GHC.Tc.Solver.Dict
- GHC.Tc.Solver.Monad call site