Note [Coherence and specialisation: overview]
GHC's specialiser relies on the Coherence Assumption: that if
d1 :: C tys
d2 :: C tys
then the dictionary d1 can be used in place of d2 and vice versa; it is as if
(C tys) is a singleton type. If d1 and d2 are interchangeable, we say that
they constitute /canonical evidence/ for (C tys). We have a special data type,
`CanonoicalEvidence`, for recording whether evidence is canonical.
Let's use this example
class C a where { op :: a -> Int }
instance C [a] where {...} -- (I1)
instance {-# OVERLAPPING # References 0
This Note does not link to any other.
Referenced by 9
- GHC.Core.InstEnv call site ×2
- Canonicity for incoherent matches GHC.Core.InstEnv
- Desugaring non-canonical evidence GHC.HsToCore.Expr
- GHC.Tc.Instance.Class call site
- CallStack and ExceptionContext hack GHC.Tc.Solver.Dict
- GHC.Tc.Utils.Instantiate call site
- GHC.Types.Basic call site
- nospecId magic GHC.Types.Id.Make