[Haskell-cafe] A question about "monad laws"

Luke Palmer lrpalmer at gmail.com
Tue Feb 12 13:49:53 EST 2008

2008/2/12 Uwe Hollerbach <uhollerbach at gmail.com>:
> Well... I dunno. Looking at the source to GHC.Real, I see
>  infinity, notANumber :: Rational
> infinity = 1 :% 0
> notANumber = 0 :% 0
>  This is actually the reason I imported GHC.Real, because just plain %
> normalizes the rational number it creates, and that barfs very quickly when
> the denominator is 0. But the values themselves look perfectly reasonable...
> no?

Ummm... I'm going to have to go with no.

In particular we can't have signed infinity represented like this and
maintain reasonable numeric laws:

  1/0 = 1/(-0) = (-1)/0

Rationals are defined not to have a zero denomiator, so I'll bet in
more than one place in Data.Ratio that assumption is made.


More information about the Haskell-Cafe mailing list