Revamping the numeric classes

Marcin 'Qrczak' Kowalczyk qrczak@knm.org.pl
8 Feb 2001 04:53:35 GMT


Wed, 7 Feb 2001 16:17:38 -0500, Peter Douglass <peterd@availant.com> pisze:

>  What I have in mind is to remove division by zero as an untypable
> expression.  The idea is to require div, /, mod to take NonZeroNumeric
> values in their second argument.  NonZeroNumeric values could be created by
> functions of type: 
>   Number a => a -> Maybe NonZeroNumeric
> or something similar.

IMHO it would be impractical.

Often I know that the value is non-zero, but it is not
statically determined, so it would just require uglification by
doing that conversion and then coercing Maybe NonZeroNumeric to
NonZeroNumeric. It's bottom anyway when the value is 0, but bottom
would come from Maybe coercion instead of from quot, so it only gives
a worse error message.

It's so easy to define partial functions that it would not buy much
for making it explicit outside quot.

Haskell does not have subtypes so a coercion from NonZeroNumeric to
plain Numbers would have to be explicit as well, even if logically
it's just an injection. Everybody assumes that quot has a symmetric
type as in all other languages, but in your proposal quot's arguments
come from completely disjoint worlds.

Moreover, 1/0 is defined on IEEE Doubles (e.g. in ghc): infinity.

-- 
 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK