Overlapping and incoherent instances

Ben Millwood haskell at benmachine.co.uk
Sat Aug 2 15:27:14 UTC 2014


On Thu, Jul 31, 2014 at 07:20:31AM +0000, Simon Peyton Jones wrote:
>My main motivation was to signal the proposed deprecation of the global per-module flag -XoverlappingInstances.  Happily people generally seem fine with this.   It is, after all, precisely what deprecations are for ("the old thing still works for now, but it won't do so for ever, and you should change as soon as is convenient").

Here's one concern I have with the deprecation of 
-XOverlappingInstances: I don't like overlapping instances, I find them 
confusing and weird and prefer to use code that doesn't include them, 
because they violate my expectations about how type classes work. When 
there is a single LANGUAGE pragma, that's a simple, easily-checkable 
signpost of "this code uses techniques that Ben doesn't understand". 
When it is all controlled by pragmas I basically have to check every 
instance declaration individually.

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? In the 
latter model, as long as none of the instances I write have pragmas, I 
can be sure none of them overlap. In the former model, any instance I 
write for an existing typeclass might overlap another instance, even if 
I don't want it to. Do we have any specific use cases in mind for 
OVERLAPPABLE?


More information about the Libraries mailing list