Note [Equality superclasses in quantified constraints]
Consider (#15359, #15593, #15625) f :: (forall a. theta => a ~ b) => stuff It's a bit odd to have a local, quantified constraint for `(a~b)`, but some people want such a thing (see the tickets). And for Coercible it is definitely useful f :: forall m. (forall p q. Coercible p q => Coercible (m p) (m q))) => stuff Moreover it's not hard to arrange; we just need to look up /equality/ constraints in the quantified-constraint environment, which we do in GHC.Tc.Solver.Equality.tryQCsEqCt. There is a wrinkle though, in the case where 'theta' is empty, so we have f :: (forall a. a~b) => stuff Now, potentially, the superclass machinery kicks in, in makeSuperClasses, giving us a a second quantified constraint (forall a. a ~# b) BUT this is an unboxed value! And nothing has prepared us for dictionary "functions" that are unboxed. Actually it does just about work, but the simplifier ends up with stuff like case (/\a. eq_sel d) of df -> ...(df @Int)... and fails to simplify that any further. So for now we simply decline to take superclasses in the quantified case. Instead we have a special case in GHC.Tc.Solver.Equality.tryQCsEqCt which looks for primitive equalities specially in the quantified constraints. See also Note [Evidence for quantified constraints] in GHC.Core.Predicate.
References 1
- Evidence for quantified constraints GHC.Core.Predicate
Referenced by 5
- Core type and coercion invariant GHC.Core
- Evidence for quantified constraints GHC.Core.Predicate
- GHC.Tc.Solver.Dict call site
- Looking up primitive equalities in quantified constraints GHC.Tc.Solver.Equality
- GHC.Tc.Solver.Equality call site