Show, Eq not necessary for Num [Was: Revamping the numeric classes]
Sun, 11 Feb 2001 13:37:28 +1300
Marcin 'Qrczak' Kowalczyk wrote:
> Sat, 10 Feb 2001 14:09:59 +1300, Brian Boutel <email@example.com> pisze:
> > Can you demonstrate a revised hierarchy without Eq? What would happen to
> > Ord, and the numeric classes that require Eq because they need signum?
> signum doesn't require Eq. You can use signum without having Eq, and
> you can sometimes define signum without having Eq (e.g. on functions).
> Sometimes you do require (==) to define signum, but it has nothing to
> do with superclasses.
Let me restate my question more carefully:
Can you demonstrate a revised hierarchy without Eq? What would happen to
Ord and the numeric classes with default class method definitions that
use (==) either explicitly or in pattern matching against numeric
literals? Both Integral and RealFrac do this to compare or test the
value of signum.
In an instance declaration, if a method requires operations of another
class which is not a superclass of the class being instanced, it is
sufficient to place the requirement in the context, but for default
class method definitions, all class methods used must belong to the
class being defined or its superclasses.