• David Terei's avatar
    New handling of overlapping inst in Safe Haskell · 4fffbc34
    David Terei authored
    We do much better now due to the newish per-instance flags. Rather than
    mark any module that uses `-XOverlappingInstances`,
    `-XIncoherentInstances` or the new `OVERLAP*` pragmas as unsafe, we
    regard them all as safe and defer the check until an overlap occurs.
    An type-class method call that involves overlapping instances is
    considered _unsafe_ when:
    1) The most specific instance, Ix, is from a module marked `-XSafe`
    2) Ix is an orphan instance or a MPTC
    3) At least one instance that Ix overlaps, Iy, is:
       a) from a different module than Ix
       b) Iy is not marked `OVERLAPPABLE`
    This check is only enforced in modules compiled with `-XSafe` or
    This fixes Safe Haskell to work with the latest overlapping instance
    pragmas, and also brings consistent behavior. Previously, Safe Inferred
    modules behaved differently than `-XSafe` modules.