RE: Numeric literals: Haskell 98
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 ++ [ (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. I'm proposing the above change to the Numeric library just for consistency: if 'show' can print "Infinitity" (and it can), then 'read' should be able to read it. Thanks, Mark. Simon | -----Original Message----- | From: Mark Carroll [mailto:mark@chaos.x-philes.com] | Sent: 27 August 2001 20:40 | To: haskell-cafe@haskell.org | Subject: Numeric literals | | | Today's other question has to do with numeric literals. How | do I write literals for interesting IEEE values, e.g. | | Prelude> x | Infinity | Prelude> :type x | Double | Prelude> (read "Infinity") :: Double | *** Exception: Ratio.%: zero denominator | Prelude> | | ...? | | If I'm just missing something obvious in the standard | documentation, please feel free to just give me a citation. | I've already tried sections 2.5 and 6.4.1 of the Haskell | Report, etc. though. | | Thanks. | | -- Mark | | | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe |
participants (1)
-
Simon Peyton-Jones