overlapping instances and constraints

Bulat Ziganshin bulat.ziganshin at gmail.com
Wed Mar 1 11:30:35 EST 2006

Hello Ben,

Wednesday, March 1, 2006, 6:23:00 PM, you wrote:

>> 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.

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

no problem:

precedence 1 : instance (Show a) => IsXML a where ...
precedence 9 : instance IsXML String where ...

of overlapping instances, win the one with higher precedence

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-prime mailing list