Semantics of signum

Dylan Thurston
Sat, 10 Feb 2001 11:25:46 -0500

On Sat, Feb 10, 2001 at 07:17:57AM +0000, Marcin 'Qrczak' Kowalczyk wrote:
> Sat, 10 Feb 2001 14:09:59 +1300, Brian Boutel <> 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.

Can you elaborate?  What do you mean by signum for functions?  The 
pointwise signum?  Then abs would be the pointwise abs as well, right?
That might work, but I'm nervous because I don't know the semantics
for signum/abs in such generality.  What identities should they
satisfy?  (The current Haskell report says nothing about the meaning
of these operations, in the same way it says nothing about the meaning
of (+), (-), and (*).  Compare this to the situation for the Monad class,
where the fundamental identities are given.  Oddly, there are identities
listed for 'quot', 'rem', 'div', and 'mod'.  For +, -, and * I can guess
what identities they should satisfy, but not for signum and abs.)

(Note that pointwise abs of functions yields a positive function, which
are not ordered but do have a sensible notion of max and min.)

	Dylan Thurston