Reasons behind the "one instance per type" limitation

Ashley Yakeley ashley@semantic.org
Mon, 8 Oct 2001 15:03:15 -0700


At 2001-10-08 09:27, Diego Dainese wrote:

>what are the reasons behind the rule stating that a type must not be
>declared as an instance of a particular class, more than once in the
>program?

It's so that the members of the class are unambiguous.

    --
    class C t where
        foo :: t -> Integer

    instance C Bool where
        foo _ = 3;

    instance C Bool where
        foo _ = 5;

    ambiguous = foo True;
    --

GHC has a flag that will turn the rule off.

-- 
Ashley Yakeley, Seattle WA