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

David Benbennick dbenbenn at gmail.com
Tue Feb 12 01:50:44 EST 2008


On Feb 11, 2008 10:18 PM, Uwe Hollerbach <uhollerbach at gmail.com> wrote:
> If I fire up ghci, import
> Data.Ratio and GHC.Real, and then ask about the type of "infinity", it
> tells me Rational, which as far as I can tell is Ratio Integer...?

Yes, Rational is Ratio Integer.  It might not be a good idea to import
GHC.Real, since it doesn't seem to be documented at
http://www.haskell.org/ghc/docs/latest/html/libraries/.  If you just
import Data.Ratio, and define

> pinf :: Integer
> pinf = 1 % 0

> ninf :: Integer
> ninf = (-1) % 0

Then things fail the way you expect (basically, Data.Ratio isn't
written to support infinity).  But it's really odd the way the
infinity from GHC.Real works.  Anyone have an explanation?

-- 
I'm doing Science and I'm still alive.


More information about the Haskell-Cafe mailing list