Track JSONPath in autoderived parsers. Fixes #357 #398
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.
The first commit is not a direct fix, but gets rid of some redundancy in error messages in nested records.
In the definition of
(.:)
(as well as its siblings(.:?)
, etc.) the location information is provided twice.This results in this kind of error when using
decodeEither
:The location is given in two different forms; the second one is extremely verbose and also incomplete, missing the
[2]
.This commit simply removes the use of
modifyFailure
in the combinators, so that only the compact path description is left.One thing that might be problematic with this solution is that the function
parse :: (a -> Parser b) -> a -> Result b
no longer has any location information by default since it discards theJSONPath
parameter. OTOH some users might prefer to insertmodifyFailure
themselves to customize their error messages, which previously prevented the use of(.:)
.