Complete support for GHC 9.0 & 9.2 as well as aeson 2.0#35
Open
l-epple wants to merge 4 commits intoagrafix:masterfrom
Open
Complete support for GHC 9.0 & 9.2 as well as aeson 2.0#35l-epple wants to merge 4 commits intoagrafix:masterfrom
l-epple wants to merge 4 commits intoagrafix:masterfrom
Conversation
Arguably, emptyVariant is more like Void than (), given that it is
actually not possible to obtain its value via fromVariant and if it
were, a program would explode due to undefined.
In JSON there is not really a way to have a void value, a JSON value is
always *something*, so it makes no sense to have a Variant '[] parser
that succeeds in any condition. More importantly, the FromJSON instance
for Variant (t ': ts) actually *requires* the instance for Variant '[]
to fail! If parseJSON is called for Variant '[] from that instance, it
means that the value didn't match any of the types the Variant accepts.
This causes the bug that, if parseJSON :: Parser () succeeds for a JSON
value, we can obtain an arbitrary Variant that would fail to evaluate,
as it'd be constructed via extendVariant emptyVariant. For aeson < 1.6
this is a pretty obscure bug, since FromJSON () only accepts the empty
array:
>>> decode "[]" :: Maybe (Variant '[Int])
Just *** Exception: Prelude.undefined
Since aeson 2.0, FromJSON () [accepts] all JSON values, meaning that any
failed parse to Variant results in a program crash!
Tagged Variants also exhibit this problem, of course. The bug is fixed
by making the FromJSON (Variant '[]) instance fail always via parseFail.
[accepts]: haskell/aeson@677daf0
This adds a bit more ifdef zoo to be compatible with the breaking change in aeson. Tested manually against aeson 2.0.3.0 and 1.5.6.0. Might want to update the CI as well, but I don’t have the time to touch CircleCI yaml. Co-authored-by: Lukas Epple <lukas.epple@possehl-analytics.com>
Support for * is disabled in GHC 9.2 by default and causes a lot of annoying warnings in 9.0. Tested against 8.10.7, 9.0.2 and 9.2.4. The base constraint seems to be correct, as Data.Kind was added in base 4.9. Co-authored-by: Lukas Epple <lukas.epple@possehl-analytics.com>
This seems to be required now to compile the Variant code.
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.
This PR builds on #32, adding support for aeson 2.0 as well as GHC >= 9.0, but fixes some mistakes, gets the
Variantcode to work again and adds support for GHC 9.2.Typeover*, also gets rid of the warnings for 9.0FlexibleContextswhere necessaryFromJSONfor (tagged)Variants. This bug hinges onparseJSON x :: Parser ()succeeding which is always the case foraeson >= 2.0, making this bug quite prevalent. See the commit message for further details.aeson == 1.5.*aeson == 2.0.*aeson-1.5.6.0❔