Brandon S. Allbery KF8NH wrote:
On May 16, 2007, at 0:57 , Adrian Hey wrote:
-- GT class --
class Ord key => GT map key | map -> key where
assocsAscending :: map a -> [(key,a)] -- Just 1 of many methods
-- Instances of GT are instances of Eq --
Instances of Ord are instances of Eq, so defining your own instance Eq
for a subclass of Ord causes confusion. Specifically, depending on how
the value is used, the compiler may not be able to decide between the
standard Eq instance or your added one. "Don't do that."
I don't think I understand. How would you suggest I make Eq instances
from GT? AFAICS it won't happen automatically without something like
this. Or are you saying they shouldn't be instances of Eq?
Perhaps it should be done separately on each and every type that is
made an instance of GT, as Oleg has suggested. That seems a little
awkward as they will all be essentially identical. (I thought one
of the advantages of type classes was to avoid this kind of
repetition.)
Thanks
--
Adrian Hey
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe