[clean-list] Overlapping discriminated instances without type aliases does not work

John van Groningen johnvg at cs.ru.nl
Thu Jul 2 11:51:37 MEST 2009


Vag wrote:
>why
>
>Start = (C (D '1'),C (D 1))
>:: D a = D a
>instance C (D Int) where C _ = 2
>instance C (D Char) where C _ = 1
>class C a :: a -> Int
>
>does not work (`multiply defined`),

This is correct, only one instance for type D is allowed.

> but
>
>Start = (C (D '1'),C (D 1))
>:: D a = D a
>:: T :== D Char
>instance C (D Int) where C _ = 2
>instance C T where C _ = 1
>class C a :: a -> Int
>
>works ok (1,2)?

No, this should be rejected by the compiler. Detecting overlapping
instances does not work correctly if type synonyms are used in
the type of an instance.


>_______________________________________________
>clean-list mailing list
>clean-list at science.ru.nl
>http://mailman.science.ru.nl/mailman/listinfo/clean-list



More information about the clean-list mailing list