readFloat

Simon Peyton-Jones simonpj@microsoft.com
Tue, 4 Jun 2002 05:27:00 -0700


| Especially converting rationals to a string and back should=20
| always be the identity. It would be better to print rationals in the
| form      =20
|        numerator % denominator
|=20
| and read them in the same form.

Oh yes, that is absolutely what Haskell does for Rationals.
The 'read' and 'show' for Rational uses the % notation.  No
proposed change here.

The point is instead this: if you specifically want to read a Rational
from
a string like "3.24", which is perfectly reasonable (324 % 100),
then the same function (readFloat) should do it as read a Float from the
string in that format.  That's what type-class overloading is for.

Simon