OVERLAPPABLE/OVERLAPPING/OVERLAPS pragmas are confusing

Mikhail Glushenkov the.dead.shall.rise at gmail.com
Tue Aug 25 15:46:33 UTC 2015


Hi,

On 25 August 2015 at 14:18, Johan Tibell <johan.tibell at gmail.com> wrote:
> The proposed change to my library is here:
> https://github.com/tibbe/cassava/pull/95/files
>
> We remove the OverlappingInstances pragma and instead add an OVERLAPPABLE
> pragma like so:
>
>     instance {-# OVERLAPPABLE #-} FromField a => FromField (Maybe a) where
>
> This causes clients of the library that previously compiled (e.g. the
> music-parts package) to no longer compile, due to a now lacking OVERLAPPING
> pragma in their code.

No, it's not quite like that. Client code can start to break when {-#
LANGUAGE OverlappingInstances #-} is removed, as happened with the
music-parts package. Adding an OVERLAPPABLE pragma to cassava's code
made that error go away.

Client code can usually work around the problem of missing
OVERLAPPABLE pragmas in the library by adding OVERLAPPING pragmas to
their instances. The reason I suggested bumping cassava's version is
that there may be some places in cassava that still need new pragmas
that I've overlooked.

If GHC had an option for detecting overlapping instances at definition
site, that'd help, I think, since then it'd be easier to find
instances that need new pragmas.


More information about the ghc-devs mailing list