Revamping the numeric classes

Dylan Thurston
Wed, 7 Feb 2001 20:25:03 -0500

On Tue, Feb 06, 2001 at 10:29:36PM +0100, Andreas Gruenbacher wrote:
> ...
> Also not all instances of Num can be shown. I have a monad that is an
> instance of Num, for example. I cannot possibly show the monad.

I've been thinking about this a little.  It's quite an interesting problem
in general to write classes that can be defined for monads.  This
can be done for any class in which each member returns the type variable:

class C a where
  foo :: ... -> a

is good, but anything else seems to cause problems.  So '+', '-',
'max', etc., are good, but '<' and 'show' cause problems.  'quotRem'
and 'divMod' are interesting cases: they return a pair (a,a), which is
OK for some monads but not for others.

I wonder if there is a way to set things up so that all classes could
be written for monadic types.

	Dylan Thurston