Overlapping and incoherent instances

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Thu Aug 7 15:24:53 UTC 2014

Simon Peyton Jones wrote:
> | >>On a largely unrelated note, here's another thing I don't
> | >>understand: when is OVERLAPPABLE at one instance declaration
> | >>preferable to using only OVERLAPPING at the instance declarations
> | >>that overlap it?
> It's a user decision.  GHC allows
>   - OVERLAPPABLE at the instance that is being overlapped, or
>   - OVERLAPPING at the instance that is doing the overlapping, or
>   - both

I'm curious how this affects simplification of contexts. If I have

  class Foo a
  instance Foo a => Foo [a]

then GHC will simplify

  foo :: Foo [a] => a -> ()


  foo :: Foo a => a -> ()

Would this be prevented by declaring the Foo [a] instance as
overlappable? In other words, does OVERLAPPABLE instruct the
type checker to expect overlapping instances even if none of
them are visible?



More information about the Glasgow-haskell-users mailing list