Iavor Diatchki iavor.diatchki at gmail.com
Tue Aug 25 16:15:31 UTC 2015


to summarize:

1. If an instance is marked as OVERLAPPABLE, then clients may overlap it
without having any pragmas
2. If an instance is NOT marked OVERLAPPABLE, then clients may still
overlap it, but then they have to use an explicit OVERLAPPING pragma.

So you should either add OVERLAPPABLE to your library, and then clients
don't need to do anything, or
you should remove it, and require that clients add OVERLAPPING.

Note that using this mechanism across modules can be quite error prone.
For example, you have to be very careful
not to use an OVERLAPPABLE instance in your library, as if you do parts of
the program might end up using
one instance, and other parts may end up using another instance---GHC has
no way of knowing about overlapping
instance in client libraries, so it will simply use the best possible
*local* instance.


On Tue, Aug 25, 2015 at 8:46 AM, Mikhail Glushenkov <
the.dead.shall.rise at gmail.com> wrote:

> 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
> > 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.
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20150825/8f4e17d2/attachment.html>

More information about the ghc-devs mailing list