The package contains
instance Ring a => Group a where ...
The instance head a
corresponds to each type expression, so any instance with any expression of another type will overlap. This overlap causes an error if such an instance is actually used somewhere. In your module you are using an instance in
instance Module Integer A where r *> (A as) = A [(r <*> k,c) | (k,c) <- as]
The Module
class has an AbelianGroup
constraint for the m
parameter. This implies a limitation of the Group
. Therefore, for this instance, you must verify the instance of Group
a
. The compiler finds two matching instances.
This is the first bug recorded.
In the following case, the compiler tries to find an instance of AbelianGroup
for a
. The only instance the compiler knows about at this point is
instance (Group a, Ring a) => AbelianGroup a
so he tries to find instance Ring A where ...
but of course he is not.
Instead of commenting on instance Group A where ...
you should add
instance AbelianGroup a
(even if it is a lie, we just want to compile it at the moment), and also add OverlappingInstances
to the {-# LANGUAGE #-}
pragma directory.
With OverlappingInstances
, the most appropriate instance of the match is selected, so it does what you want here.
¹ By the way, your a
not an instance of AbelianGroup
and rightfully cannot be, if the order does not matter in the list [(Integer,String)]
.