Numeric literals: Haskell 98
Simon Peyton-Jones
simonpj@microsoft.com
Tue, 28 Aug 2001 03:43:28 -0700
Mark Caroll points out that the Haskell 98 Numeric library should be
able
to read the numbers "Infinity" and "NaN", which can be printed by
formatRealFloat.
So I propose the following ammendment to the Numeric library:
Page 16, Section 4, Numeric library. In the definition
of readFloat, after "... (k,t) <- readExpr s]" add
=09
++ [ (0/0, t) | ("NaN",t) <- lex r]
++ [ (1/0, t) | ("Infinity",t) <- lex r]
However, the Haskell language report seems to say that it's optional for
a
Haskell implementation to actually support NaNs and Inifinity. I don't
propose
to change this, though it's a bit unsatisfactory because one can't rely
on it. =20
I'm proposing the above change to the Numeric library just
for consistency: if 'show' can print "Infinitity" (and it can), then
'read' should=20
be able to read it.
Thanks, Mark.
Simon
| -----Original Message-----
| From: Mark Carroll [mailto:mark@chaos.x-philes.com]=20
| Sent: 27 August 2001 20:40
| To: haskell-cafe@haskell.org
| Subject: Numeric literals
|=20
|=20
| Today's other question has to do with numeric literals. How=20
| do I write literals for interesting IEEE values, e.g.
|=20
| Prelude> x
| Infinity
| Prelude> :type x
| Double
| Prelude> (read "Infinity") :: Double
| *** Exception: Ratio.%: zero denominator
| Prelude>=20
|=20
| ...?
|=20
| If I'm just missing something obvious in the standard=20
| documentation, please feel free to just give me a citation.=20
| I've already tried sections 2.5 and 6.4.1 of the Haskell=20
| Report, etc. though.
|=20
| Thanks.
|=20
| -- Mark
|=20
|=20
| _______________________________________________
| Haskell-Cafe mailing list
| Haskell-Cafe@haskell.org=20
| http://www.haskell.org/mailman/listinfo/haskell-cafe
|=20