Note [Recording coherence information in `PotentialUnifiers`]
When we find a matching instance, there might be other instances that could potentially unify with the goal. For `INCOHERENT` instances, we don't care (see step (IL6) in Note [Rules for instance lookup]). But if we have potentially unifying coherent instance, we report these `OneOrMoreUnifiers` so that `matchInstEnv` can go down the `NotSure` route. If this hurdle is passed, i.e. we have a unique solution up to `INCOHERENT` instances, the specialiser needs to know if that unique solution is canonical or not (see Note [Coherence and specialisation: overview] for why we care at all). So when the set of potential unifiers is empty, we record in `NoUnifiers` if the one solution is `Canonical`. For example, suppose we have: class C x y instance C a Bool -- (1) instance {-# INCOHERENT #
References 1
- Rules for instance lookup GHC.Core.InstEnv
Referenced by 4
- GHC.Core.InstEnv call site ×2
- Rules for instance lookup GHC.Core.InstEnv
- Canonicity for incoherent matches GHC.Core.InstEnv