-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
907: Fix `FromText` instance for `Double` (and `FeePolicy`). r=jonathanknowles a=jonathanknowles # Issue Number None. Discovered while testing PR #889. # Overview This PR: - [x] Changes the implementation of `FromText` for `Double` to use `read @Double` rather than `Data.Text.Read.rational`. This matches the `ToText` implementation, which just uses `show`. - [x] Simplifies the roundtrip textual encoding test for `Double`. - [x] Simplifies the roundtrip textual encoding test for `FeePolicy`. # Explanation The implementations of `show` and `read` for `Double` are expected to obey the following property: ``` read . show = id ``` The implementation of `Data.Text.Read.rational`, on the other hand, differs slightly from that of `read @Double`. This difference occasionally introduces small errors across roundtrip serialization & deserialization. For example: ```hs > a = -9.0e-3 :: Double > a -9.0e-3 > read @double (show a) -9.0e-3 > rational @double (pack $ show a) Right (-9.000000000000001e-3,"") ``` Co-authored-by: Jonathan Knowles <[email protected]>
- Loading branch information
Showing
3 changed files
with
8 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters