John Hughes wrote:
> Taking Ian Stark's example a little bit further,
>
>       Main> let x=6.0e-8 in (1.0,1.0+x,1.0==1.0+x)
>       (1.0,1.0,False)
>
> is a useful reminder that show isn't one-to-one.

Dunno much about FP arithmetic, but maybe there should be a primitive
showFloatExact which yields the representation itself rather than an
approximation. It might even be necessary for applications that use show* to
implement persistence.

It seems to me there is a tension between using show as a way of doing quick
and dirty pretty-printing and as a way of getting a portable representation
of data. I run across this sometimes when I forget that show :: String ->
String surrounds the input string with quotes, behavior leads me to believe
that show is really intended for the latter purpose, portability and
persistence. By that token at least it doesn't seem too unreasonable to
output an FP representation rather than an approximation for real-ish
datatypes.

--fac

Reply via email to