[Haskell-cafe] type class design

Tillmann Rendel rendel at informatik.uni-marburg.de
Fri Oct 29 08:33:31 EDT 2010


Uwe Schmidt wrote:
> In the standard Haskell classes we can find both cases,
> even within a single class.
> Eq with (==) as f and (/=) as g belongs to the 1. case

Note that the case of (==) and (/=) is slightly different, because not 
only can (/=) be defined in terms (==), but also the other way around. 
The default definitions of (==) and (/=) are mutually recursive, and 
trivially nonterminating. This leaves the choice to the instance writer 
to either implement (==) or (/=). Or, for performance reasons, both.


More information about the Haskell-Cafe mailing list