<div dir="ltr">Johan,<div><br></div><div>to summarize:</div><div><br></div><div>1. If an instance is marked as OVERLAPPABLE, then clients may overlap it without having any pragmas</div><div>2. If an instance is NOT marked OVERLAPPABLE, then clients may still overlap it, but then they have to use an explicit OVERLAPPING pragma.</div><div><br></div><div>So you should either add OVERLAPPABLE to your library, and then clients don't need to do anything, or</div><div>you should remove it, and require that clients add OVERLAPPING.</div><div><br></div><div>Note that using this mechanism across modules can be quite error prone. For example, you have to be very careful</div><div>not to use an OVERLAPPABLE instance in your library, as if you do parts of the program might end up using</div><div>one instance, and other parts may end up using another instance---GHC has no way of knowing about overlapping</div><div>instance in client libraries, so it will simply use the best possible *local* instance.</div><div><br></div><div>-Iavor</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 25, 2015 at 8:46 AM, Mikhail Glushenkov <span dir="ltr"><<a href="mailto:the.dead.shall.rise@gmail.com" target="_blank">the.dead.shall.rise@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<span class=""><br>
On 25 August 2015 at 14:18, Johan Tibell <<a href="mailto:johan.tibell@gmail.com">johan.tibell@gmail.com</a>> wrote:<br>
> The proposed change to my library is here:<br>
> <a href="https://github.com/tibbe/cassava/pull/95/files" rel="noreferrer" target="_blank">https://github.com/tibbe/cassava/pull/95/files</a><br>
><br>
> We remove the OverlappingInstances pragma and instead add an OVERLAPPABLE<br>
> pragma like so:<br>
><br>
> instance {-# OVERLAPPABLE #-} FromField a => FromField (Maybe a) where<br>
><br>
> This causes clients of the library that previously compiled (e.g. the<br>
> music-parts package) to no longer compile, due to a now lacking OVERLAPPING<br>
> pragma in their code.<br>
<br>
</span>No, it's not quite like that. Client code can start to break when {-#<br>
LANGUAGE OverlappingInstances #-} is removed, as happened with the<br>
music-parts package. Adding an OVERLAPPABLE pragma to cassava's code<br>
made that error go away.<br>
<br>
Client code can usually work around the problem of missing<br>
OVERLAPPABLE pragmas in the library by adding OVERLAPPING pragmas to<br>
their instances. The reason I suggested bumping cassava's version is<br>
that there may be some places in cassava that still need new pragmas<br>
that I've overlooked.<br>
<br>
If GHC had an option for detecting overlapping instances at definition<br>
site, that'd help, I think, since then it'd be easier to find<br>
instances that need new pragmas.<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div><br></div>