overlapping instances and constraints

Ben Rudiak-Gould Benjamin.Rudiak-Gould at cl.cam.ac.uk
Wed Mar 1 10:23:00 EST 2006


Niklas Broberg wrote:
> Ben Rudiak-Gould wrote:
>> Are there uses of overlapping
>> instances for which this isn't flexible enough?
> 
> Certainly!

Hmm... well, what about at least permitting intra-module overlap in Haskell' 
(and in GHC without -foverlapping-instances)? It's good enough for many 
things, and it's relatively well-behaved.

> instance (Show a) => IsXML a where
>  toXML = toXML . show
> 
> The intention of the latter is to be a default instance unless another
> instance is specified.

I can see how this is useful, but I'm surprised that it's robust. None of 
the extensions people have suggested to avoid overlap would help here, clearly.

Are there uses of overlapping instances for which the single-module 
restriction isn't flexible enough, but extensions that avoid overlap are 
flexible enough?

-- Ben



More information about the Haskell-prime mailing list