Laws for Show and Read?
Bertram Felgenhauer
bertram.felgenhauer at googlemail.com
Wed Jun 5 20:37:18 UTC 2019
Sven Panne wrote:
> We already have the law
> read . show = id
> which implies the injectivity and surjectivity conditions you specify.
>
> I think this doesn't hold for the standard Read/Show instances for
> Double/Float: IEEE-754 NaNs have a sign bit and a payload, and both
> parts are probably lost by the "read . show"-combination. The 2
> infinities are probably OK, but what about -0 vs. +0?
ghci> show (-0 :: Double)
"-0.0"
ghci> read (show (-0 :: Double)) :: Double
-0.0
It's true that extra information in NaNs is lost, but they all behave
the same anyway...
Cheers,
Bertram
More information about the Libraries
mailing list