[Haskell-cafe] Type class help please

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Wed May 16 01:07:40 EDT 2007


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."

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH




More information about the Haskell-Cafe mailing list