Duplicate instance declarations of a methodless class

mm schneegloeckchen at gmx.li
Tue Mar 6 10:18:18 EST 2007


I was thinking that it could maybe be useful to allow duplicate instance
declarations, if the class has no methods. From my naive point of view, i
can not see problems, scince there are no conflicting methods to choose
from. But the following program fails to be compiled by ghc-6.6:

> {-# OPTIONS -fglasgow-exts -fallow-undecidable-instances #-}

> class GT a b
> class Succ a b

> data Zero
> data One
> data Two
> data Three

> instance Succ One Zero
> instance Succ Two One
> instance Succ Three Two

> instance Succ a b => GT a b
> instance (Succ a b, GT b c) => GT a c

The former two lines lead to:

    Duplicate instance declarations:
      instance (Succ a b) => GT a b -- Defined at test5.lhs:22:1
      instance (Succ a b, GT b c) => GT a c -- Defined at test5.lhs:23:1

More information about the Glasgow-haskell-users mailing list