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

Build with aeson >= 2.0 #2477

Closed
4 of 8 tasks
jneira opened this issue Dec 13, 2021 · 16 comments · Fixed by #2551
Closed
4 of 8 tasks

Build with aeson >= 2.0 #2477

jneira opened this issue Dec 13, 2021 · 16 comments · Fixed by #2551
Assignees
Labels
CI Continuous integration old_type: distribution type: enhancement New feature or request
Milestone

Comments

@jneira
Copy link
Member

jneira commented Dec 13, 2021

@jneira jneira added type: enhancement New feature or request CI Continuous integration old_type: distribution labels Dec 13, 2021
@jneira jneira changed the title Build with aeson >= 2.0 (needed for brittany for ghc-9.0.1) Build with aeson >= 2.0 (needed for brittany and ghc-9.0.1) Dec 13, 2021
@jneira
Copy link
Member Author

jneira commented Dec 13, 2021

Of course floskell is not buildable with aeson >= 2.0:

src/Floskell/ConfigFile.hs:93:26: error:
Error:     • Couldn't match type: HashMap.HashMap k0 JSON.Value
                     with: Data.Aeson.KeyMap.KeyMap JSON.Value
      Expected: JSON.Object
        Actual: HashMap.HashMap k0 JSON.Value
    • In the first argument of ‘JSON.Object’, namely
        ‘(HashMap.unionWith mergeJSON l r)’
      In the expression: JSON.Object (HashMap.unionWith mergeJSON l r)
      In an equation for ‘mergeJSON’:
          mergeJSON (JSON.Object l) (JSON.Object r)
            = JSON.Object (HashMap.unionWith mergeJSON l r)
   |
93 |             JSON.Object (HashMap.unionWith mergeJSON l r)
   |                          ^^^^^^^^^^^^^^^

@jneira
Copy link
Member Author

jneira commented Dec 13, 2021

or patch brittany to support aeson <= 2.0 and ghc-9.0.1 at same time

given aeson >= 2.0 inlcudes an important security related patch i think we should try to use it here

@jneira
Copy link
Member Author

jneira commented Dec 13, 2021

PR to add aeson >= 2.0 to floskell: ennocramer/floskell#69

@Ailrun Ailrun added the ghc-9 label Dec 14, 2021
@jneira
Copy link
Member Author

jneira commented Dec 14, 2021

hls-plugin-api needs to be patched, several errors like:

src\Ide\Plugin\Properties.hs:240:25: error:
Error:     • Couldn't match expected type ‘A.Key’ with actual type ‘T.Text’
    • In the second argument of ‘(A..:)’, namely ‘keyName’
      In a stmt of a 'do' block: txt <- o A..: keyName
      In the expression:
        do txt <- o A..: keyName
           if txt `elem` enumValues then
               pure txt
           else
               fail
                 $ "invalid enum member: "
                     <> show txt <> ". Expected one of " <> show enumValues
    |
240 |           txt <- o A..: keyName

    | 

the fix should be backwards compatible as we have to support libraries with only support for aeson < 2.0 (hlint-3.2) or aeson >= 2.0 (brittany)

@jneira jneira self-assigned this Dec 14, 2021
@jneira
Copy link
Member Author

jneira commented Dec 14, 2021

After checking master version of lsp packages works with hls, including the test suite, will release new versions

@michaelpj
Copy link
Collaborator

I suspect we can sort out hls-plugin-api in a way that works nicely both pre- and post-2.0

@jneira
Copy link
Member Author

jneira commented Dec 14, 2021

I suspect we can sort out hls-plugin-api in a way that works nicely both pre- and post-2.0

@michaelpj
haskell/aeson#881 (comment) suggests create a fromKey/toKey and make it work with Text and Aeson.Key using CPP but i would love to do it without cpp conditions (like you did for lsp, using hte Aeson api differently)

@jneira
Copy link
Member Author

jneira commented Dec 15, 2021

stylish-haskell also would need support for aeson >= 2.0: haskell/stylish-haskell#387

@jneira
Copy link
Member Author

jneira commented Dec 16, 2021

And packages (hls-plugin-api, ghcide,..) need to be adapted to the new lsp version, which supports in turn aeson-2.
As the aeson-2 thin is getting more complex, i would focus in lsp packages first, leveraging @michaelpj work here: https://github.com/michaelpj/haskell-language-server/tree/mpj/wip-hls-lsp-upgrade
I am continuing the work there in this one https://github.com/haskell/haskell-language-server/tree/hls-lsp-upgrade

@michaelpj
Copy link
Collaborator

given aeson >= 2.0 inlcudes an important security related patch i think we should try to use it here

Just to reiterate on this, I'm fairly sure that the security issue is not relevant for HLS as it isn't parsing untrusted input.

@jneira
Copy link
Member Author

jneira commented Jan 12, 2022

I am gonna reopen to track the possible use of aeson 2 for ghc < 9.0.1 and brittany upstream deps needing support for ghc >= 9.0.1

@jneira jneira reopened this Jan 12, 2022
@jneira jneira changed the title Build with aeson >= 2.0 (needed for brittany and ghc-9.0.1) Build with aeson >= 2.0 Jan 24, 2022
@michaelpj
Copy link
Collaborator

I am gonna reopen to track the possible use of aeson 2 for ghc < 9.0.1

Do we need to do this?

@jneira
Copy link
Member Author

jneira commented Jan 24, 2022

I am gonna reopen to track the possible use of aeson 2 for ghc < 9.0.1

Do we need to do this?

No strictly, but we can take ride of some pesky fromString . unpack which can be reaplaced with directs Aeson.Key.fromText.
And well we could use new aeson-2.x versions with possible new bug fixes or perf improvements for ghc < 9.0.1

@michaelpj
Copy link
Collaborator

IMO it's not worth spending lots of effort on. We can force it once we're only supporting GHC 9 :p

@jneira
Copy link
Member Author

jneira commented Jan 24, 2022

IMO it's not worth spending lots of effort on. We can force it once we're only supporting GHC 9 :p

agree, we are also tracking here stylish-haskell and Brittany deps support for aeson/ghc-9.0 but maybe we could move that to the ghc-9.0 support and close this

will do

@jneira
Copy link
Member Author

jneira commented Jan 24, 2022

ok, i've moved the pending tasks to #297 and give up on get aeson-2.0 support for ghc < 9.0.1 so closing this

@jneira jneira closed this as completed Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous integration old_type: distribution type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants