Duplicate instance declarations of a methodless class

Alfonso Acosta alfonso.acosta at gmail.com
Tue Mar 6 14:49:25 EST 2007


Did you try to compile with -fallow-overlapping-instances

On 3/6/07, mm <schneegloeckchen at gmx.li> wrote:
> Hello,
>
> 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:
>
> test5.lhs:22:1:
>     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
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>


More information about the Glasgow-haskell-users mailing list