haskell extensions question

Wolfgang Jeltsch wolfgang at jeltsch.net
Mon Dec 1 11:10:36 EST 2003


Am Montag, 1. Dezember 2003 05:44 schrieb Ken Shan:
> [...]

> > ERROR "Test.hs":12 - Overlapping instances for class "B"
> > *** This instance   : B ()
> > *** Overlaps with   : B a
> > *** Common instance : B ()
> >
> > but I don't have an instance "A ()" from which haskell can infer an
> > instance "B ()".
> > can somebody explain me that it is happening here?
>
> Unfortunately, contexts in instance definitions are not taken into account
> when checking for overlapping instances.  That is, two instances are
> regarded as overlapping as long as their heads can be unified.

The reason for this is that Haskell doesn't make the closed world assumption. 
It is taken into account that one could easily define an instance A () (e.g., 
in another module importing your module) which would immediately lead to a 
real overlapping.

Wolfgang



More information about the Haskell mailing list