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

Drop ghc-api-compat from dependency closure #2128

Merged
merged 22 commits into from
Sep 15, 2021
Merged

Conversation

fendor
Copy link
Collaborator

@fendor fendor commented Aug 27, 2021

Requires re-structuring GHC API Compatibility.

We try to go with the latest GHC API and provide backwards compatible
functions for older GHC versions. The intention is that ghcide code is
written with the latest GHC API in mind, older GHC versions may have
inefficiencies in order to satisfy the newer API.

This way dropping support for older GHC versions is trivial (only delete
a couple of '#if ... #endif' and maybe update some imports), and ghcide
does suffer less from bit-rot. Additionally, we want to have the latest
and best GHC API, not some semi-outdated frankenstein.

The implementation adds a new Compat sub-hierarchy that defines
backwards compatible functions for the GHC API, where possible
higher-level abstractions.

The module hierarchy re-organisation of GHC is taken care of by
'Development.IDE.GHC.Compat.Core', which takes care of almost every
definition used by ghcide. If this becomes to unwieldy, it makes sense
to split it up into smaller logical pieces.

Design Decisions:

  • In ghcide, no GHC API import is allowed except for GHC.
  • Restrict usage of CPP to modules in Compat hierarchy as much as possible.
  • Plugins are allowed to provide their Backwards Compat methods.
    • E.g. they may use CPP instead of ghcide's Compat modules.

TODOS:

Status:
With all supported plugins, HLS compiles for GHC 8.6.5 ... 9.0.1.

@jneira jneira marked this pull request as draft August 27, 2021 14:05
@jneira jneira changed the title Draft: Drop ghc-api-compat from dependency closure Draft: Drop ghc-api-compat from dependency closure and add ghc-9.2 support Aug 27, 2021
@jneira jneira changed the title Draft: Drop ghc-api-compat from dependency closure and add ghc-9.2 support Drop ghc-api-compat from dependency closure and add ghc-9.2 support Aug 27, 2021
@jneira
Copy link
Member

jneira commented Aug 27, 2021

Incredible herculean work here, many many thanks. I hope you dont mind cause ive marked it as a draft (following the title) and chenge the title itself to note it adds ghc-9.2 support

@jneira jneira mentioned this pull request Aug 27, 2021
35 tasks
@fendor fendor force-pushed the ghc92 branch 2 times, most recently from 58993f7 to 9d1cd2e Compare August 29, 2021 12:21
@fendor
Copy link
Collaborator Author

fendor commented Aug 29, 2021

@jneira this PR can be merged before GHC 9.2 support lands

cabal-ghc921.project Show resolved Hide resolved
ghcide/.ghci Show resolved Hide resolved
ghcide/bench/example/HLS Show resolved Hide resolved
ghcide/src/Development/IDE/Core/Compile.hs Outdated Show resolved Hide resolved
ghcide/src/Development/IDE/GHC/Compat.hs Show resolved Hide resolved
ghcide/src/Development/IDE/GHC/Compat/Core.hs Show resolved Hide resolved
@fendor fendor force-pushed the ghc92 branch 2 times, most recently from 88f10ce to 6821ffb Compare August 30, 2021 10:15
@fendor
Copy link
Collaborator Author

fendor commented Aug 30, 2021

This adds GHC 9.0 support for the splice, rename, call-hierarchy and refineImports plugins.

I don't guarantee that they work correctly, but they compile :)

@fendor fendor force-pushed the ghc92 branch 4 times, most recently from 2f517e4 to c89afc1 Compare August 31, 2021 08:18
@jneira
Copy link
Member

jneira commented Sep 1, 2021

@fendor will try to help with stack files asap

@jneira
Copy link
Member

jneira commented Sep 2, 2021

Solver error for ghc-9.0.1:

Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: hls-1.3.0.0 (user goal)
[__1] trying: hls:+refineimports
[__2] trying: hls-refine-imports-plugin-1.0.0.0 (dependency of hls
+refineimports)
[__3] next goal: hls-plugin-api (user goal)
[__3] rejecting: hls-plugin-api-1.2.0.1 (conflict: hls-refine-imports-plugin
=> hls-plugin-api^>=1.1)
[__3] rejecting: hls-plugin-api-1.1.0.2, hls-plugin-api-1.1.0.1,
hls-plugin-api-1.1.0.0, hls-plugin-api-1.0.0.0, hls-plugin-api-0.7.1.0,
hls-plugin-api-0.7.0.0, hls-plugin-api-0.6.0.0, hls-plugin-api-0.5.0.1,
hls-plugin-api-0.5.0.0, hls-plugin-api-0.4.1.0, hls-plugin-api-0.4.0.0
(constraint from user target requires ==1.2.0.1)
[__3] fail (backjumping, conflict set: hls-plugin-api,
hls-refine-imports-plugin)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: hls-plugin-api, hls,
hls-refine-imports-plugin, hls:refineimports
Try running with --minimize-conflict-set to improve the error message.

I think it will be fixed by 19e0681

@jneira
Copy link
Member

jneira commented Sep 2, 2021

I've started to work on stack.yaml's here: https://github.com/jneira/haskell-language-server/tree/ghc92

@fendor fendor changed the title Drop ghc-api-compat from dependency closure and add ghc-9.2 support Drop ghc-api-compat from dependency closure Sep 2, 2021
pepeiborra added a commit that referenced this pull request Sep 4, 2021
We can replace the source snapshot with Cabal conditions.
This will unblock Hackage uploads until
#2128 lands
pepeiborra added a commit that referenced this pull request Sep 4, 2021
We can replace the source snapshot with Cabal conditions.
This will unblock Hackage uploads until
#2128 lands
pepeiborra added a commit that referenced this pull request Sep 4, 2021
We can replace the source snapshot with Cabal conditions.
This will unblock Hackage uploads until
#2128 lands
pepeiborra added a commit that referenced this pull request Sep 4, 2021
We can replace the source snapshot with Cabal conditions.
This will unblock Hackage uploads until
#2128 lands
Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for this again

@anka-213
Copy link
Contributor

Thanks for cleaning up the mess I caused/contributed to when adding GHC-9.0 support! ❤️

@fendor
Copy link
Collaborator Author

fendor commented Sep 15, 2021

@anka-213 Thank you for your GHC 9.0 support contribution, without this would have been harder!
You patched so many dependencies, it is awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants