Add a FromJSONKey instance for Data.Fixed#1165
Open
VictorCMiraldo wants to merge 2 commits intohaskell:masterfrom
Open
Add a FromJSONKey instance for Data.Fixed#1165VictorCMiraldo wants to merge 2 commits intohaskell:masterfrom
FromJSONKey instance for Data.Fixed#1165VictorCMiraldo wants to merge 2 commits intohaskell:masterfrom
Conversation
phadej
requested changes
Apr 13, 2026
| parseBoundedScientificText t = parseScientificText t >>= rejectLargeExponent | ||
| where | ||
| rejectLargeExponent :: Scientific -> Parser Scientific | ||
| rejectLargeExponent s = withBoundedScientific' pure (Number s) |
Collaborator
There was a problem hiding this comment.
This duplicates too much of parseIntegralText; I don't like this duplication.
Author
There was a problem hiding this comment.
Reasonable! I refactored parseIntegralText; how does it look now?
| import Prelude.Compat | ||
|
|
||
| import Control.Applicative (Const) | ||
| import Data.Fixed |
Author
There was a problem hiding this comment.
Respectfully disagree. Happy to oblige. :)
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We have a
ToJSONKey (Fixed a)instance:aeson/src/Data/Aeson/Types/ToJSON.hs
Lines 1432 to 1433 in 45d31f1
But there's no corresponding
FromJSONKey (Fixed a)available. Because we have aFromJSONKey Double, it seems like this was just never added and never needed. I now have someMaps with fixed-point numbers as their keys and therefore would benefit from aFromJSONKey (Fixed a)instance. A lot of the scientific parsing functionality is internal toaesonand not exported, so I can't just add it the orphan instance on my project and call it a day, plus, if I can fix it for everyone, than it's better for everyone! :)I tried reusing the
Scientificparsing as much as possible and checked it does indeed reject large exponents in acabal repl: