summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorBrian McKenna <brian@brianmckenna.org>2014-12-02 17:53:38 +0100
committerHerbert Valerio Riedel <hvr@gnu.org>2014-12-02 17:54:50 +0100
commit7c38e985aa211ca44039c6d1db9fa13690749c59 (patch)
tree1c97a63cd1e023644bc97c8144ed348dab6dffb9 /packages
parent6b063ef2a1f68290b51778a38e9b89b6fec5e170 (diff)
downloadhaskell-7c38e985aa211ca44039c6d1db9fa13690749c59.tar.gz
Make `read . show = id` for Data.Fixed (fix #9240)
The QuickCheck property now succeeds: prop :: Fixed B7 -> Bool prop a = read (show a) == a This changes the Show instance for Fixed to round up, rather than down when calculating a digit. This needs to happen because Read also rounds down: data B7 instance HasResolution B7 where resolution _ = 128 1 / 128 = 0.0078125 read "0.007" = (0.000 :: Fixed B7) Here is an example of the change to Show: showFixed False (0.009 :: Fixed B7) -- Broken: "0.007" -- Fixed: "0.008" And now Read can continue to round down: read "0.008" = (0.0078125 :: Fixed B7) Reviewed By: hvr, ekmett Differential Revision: https://phabricator.haskell.org/D547
Diffstat (limited to 'packages')
0 files changed, 0 insertions, 0 deletions