
Am 29.07.2014 um 11:11 schrieb Simon Peyton Jones:
Iavor has recently implemented per-instance-declaration pragmas, so you can say
instance {-# OVERLAPPABLE #-} Show a => Show [a] where …
instance {-# OVERLAPPING #-} Show [Char] where …
This is much more precise (it affects only those specific instances) and it is much clearer (you see it when you see the instance declaration).
This new feature will be in GHC 7.10 and I’m sure you will be happy about that. *But I propose also to deprecate the LANGUAGE pragmas OverlappingInstances and IncoherentInstances*, as way to encourage everyone to use the new feature instead of the old big hammer. The old LANGUAGE pragmas will continue to work, of course, for at least another complete release cycle. We could make that two cycles if it was helpful.
However, if you want deprecation-free libraries, it will entail a wave of library updates.
I think it is a good opportunity to check whether overlapping instances are really needed. There might be cases where instances actually do not overlap (anymore), like you encountered, and cases where a little redesign avoids overlapping. As far as I remember I could eventually avoid any overlapping instance in my packages. That said, I prefer to write the pragma before the instances, like INLINE pragmas.