Note [Redundant constraints in instance decls]
Instance declarations are special in two ways: * We don't report unused givens if they can give rise to improvement. Example (#10100): class Add a b ab | a b -> ab, a ab -> b instance Add Zero b b instance Add a b ab => Add (Succ a) b (Succ ab) The context (Add a b ab) for the instance is clearly unused in terms of evidence, since the dictionary has no fields. But it is still needed! With the context, a wanted constraint Add (Succ Zero) beta (Succ Zero) we will reduce to (Add Zero beta Zero), and thence we get beta := Zero. But without the context we won't find beta := Zero. This only matters in instance declarations. * We don't report givens that are a superclass of another given. E.g. class Ord r => UserOfRegs r a where ... instance (Ord r, UserOfRegs r CmmReg) => UserOfRegs r CmmExpr where The (Ord r) is not redundant, even though it is a superclass of (UserOfRegs r CmmReg). See Note [Recursive superclasses] in GHC.Tc.TyCl.Instance. Again this is specific to instance declarations.
References 1
- Recursive superclasses GHC.Tc.TyCl.Instance
Referenced by 1
- GHC.Tc.Solver.Solve call site