Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aeson 1.5-2.0 compat #9

Open
tomjaguarpaw opened this issue Feb 27, 2022 · 6 comments
Open

Aeson 1.5-2.0 compat #9

tomjaguarpaw opened this issue Feb 27, 2022 · 6 comments

Comments

@tomjaguarpaw
Copy link
Contributor

Here is a suggestion for an Aeson 1.5-2.0 compatibilty story. The technique is simple: take Aeson 2.0 and change the version 2 abstract types to type synonyms as below (plus chasing up the ensuing, minor, type errors).

This backports the 2.0 API to 1.5, and ought to allow Aeson users to write code that works at the same time against version 1.5 and version 2.0, providing a smooth upgrade path and avoiding the need for a "big bang" switch of the entire Aeson ecosystem at once.

-newtype Key = Key { unKey :: Text }
+type Key = Text

-newtype KeyMap v = KeyMap { unKeyMap :: Map Key v }
+type KeyMap v = Map Key v

I don't actually use Aeson myself, so I would welcome the input of Aeson users and maintainers (esp. @bergmark) regarding

  1. whether this is actually useful, and if so
  2. whether I've got everything correct (the tests pass)
@NorfairKing
Copy link

+1 for a CPP-less migration option!

@bergmark
Copy link
Collaborator

bergmark commented Mar 3, 2022

I think this is a good addition.

One upside is that it doesn't require usage of a compat package.

The downside is that every major aeson series we wish to support for this migration needs to be amended with this patch. Bounds on dependents would need to be adjusted to e.g. ^>= 1.5.7 || ^>= 2.0. I think that would be fine, as aeson 1.5.x has been out for almost two years and has pretty good backwards compat for its dependencies. And if someone needs more backwards compat on aeson they are free to not use this.

The compat package approach (we could always do both) would allow us to support more versions of aeson (bounds could be simplified to e.g. >= 1 && < 1.6 || ^>= 2.0) with only one release of that package.

FWIW I think that filing this directly against aeson would be better. I'm one of three maintainers but I'm currently the least active one so I think it's better to discuss it over there.

Just noting a detail in case this turns into a full PR: The change should probably be made against the latest 1.5.x commit.

@tomjaguarpaw
Copy link
Contributor Author

OK, migrated to Aeson at haskell/aeson#932

@cdornan cdornan reopened this Mar 7, 2022
@cdornan
Copy link
Contributor

cdornan commented Mar 7, 2022

Reopening as there seems to be some difference of opinion as to whether this belongs in Aeson.

@tomjaguarpaw
Copy link
Contributor Author

I think I may not have explained very well what my suggestion actually is. It seems that it was interpreted to be a change to 2.0 to revert making Key and KeyMap abstract.

@cdornan
Copy link
Contributor

cdornan commented Mar 7, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants