-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Support hls-hlint-plugin and hls-stylish-plugin for ghc9.0 and ghc9.2 #2854
Conversation
What about 9.0? Should be able to play the same trick |
Haha, sorry for my unclear words, I just want to express that this pr will support hlint-plugin and stylish-haskell-plugin to 9.2(include any version less than 9.2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also update the plugin support table in the docs when this is ready? (#2840 brings it up to date with the current state, but this PR makes it better!)
cabal-ghc92.project
Outdated
hlint +ghc-lib, | ||
stylish-haskell +ghc-lib | ||
|
||
source-repository-package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this? when can we remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to the limitation of hls-hlint-plugin
code structure, we must force ghc-lib-parser
uses ghc-lib
instead of ghc to make compile, this repo adds a flag to allow us to force use ghc-lib
in stylish-haskell
(or is there another way to do this with out edit the package?)
Why do we have to use
ghc-lib
?
- We have two code path in hls-hlint-plugin, includes using
ghc
and usingghc-lib
. theghc
codebase relies on our compiled module bygetParsedModuleWithComments
which has someann
operation that ghc-9.2 has totally different views, we can makeghc-9.2
also use this after some revise(Not much work, but will introduce more complex compat). Theghc-lib
codebase parses the source code directly and we can use this for any ghc-lib easily. - We use
apply-refact
to apply hlint, and for ghc before 9.2, it requiresapply-refact-0.9
and in ghc-9.2, it needsapply-refact-0.10
. Since inghc
codebase we pass parsed module to apply-refact, it works in 0.9 but not in 0.10.apply-refact-0.10
uses an internalIORef
(https://github.com/mpickering/apply-refact/blob/cb8464af74ce9c1cee26fa4862c713bb5ff96114/src/Refact/Internal.hs#L751-L755) and the only entrance is parse the source byapply-refact
. (https://github.com/mpickering/apply-refact/blob/cb8464af74ce9c1cee26fa4862c713bb5ff96114/src/Refact/Internal.hs#L709). If we still pass a parsed module toapply-refact-0.10
, it crashed withundefined
(https://github.com/mpickering/apply-refact/blob/cb8464af74ce9c1cee26fa4862c713bb5ff96114/src/Refact/Internal.hs#L557)
I think we can remove this after the new stylish-haskell
with ghc-lib
flag is released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks we can turn to ghc-lib
and abandon ghc
in hls-hlint-plugin
, can we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pr created haskell/stylish-haskell#402
@@ -23,7 +23,7 @@ library | |||
build-depends: | |||
, base >=4.12 && <5 | |||
, filepath | |||
, fourmolu ^>=0.3 || ^>=0.4 || ^>= 0.5 | |||
, fourmolu ^>=0.3 || ^>=0.4 || ^>= 0.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to disallow 0.5 or should we just add 0.6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.5 and 0.6 have the same requirements but 0.6 has bug fix, I don't think we have a reason to allow 0.5. https://github.com/fourmolu/fourmolu/blob/master/CHANGELOG.md
@@ -28,6 +28,7 @@ library | |||
, base >=4.12 && <5 | |||
, containers | |||
, ghc | |||
-- Require ghc-exactprint >= 1.5 on ghc9.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean to also actually change the bound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, I think we can only add a constraint in .project or stack-x.yaml since ghc-exactprint-0.6 is required from ghc8 to ghc9.0. I'll add a comment here.
Unfuntunately, just a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could have a cabal conditional based on the GHC version? Maybe it's not worth it.
I think this pr is ready to be merged. Everything is ok except the nix config, we have a working pr to upgrade it, #2853, we can add nix contents after nix scripts upgrade. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Can't comment on the ghc-lib
stuff because I never really understood it.
…haskell#2854) * hls-hlint-plugin & hls-stylish-haskell-plugin rush to ghc92 * Restore allow-newer * Add BufSpan for lower version ghc * Add Cabal constraint for stack-9.0.1.yaml * Try ghc-lib-parser for BufSpan * Loose tactic compiling constraint * Rename hlint34 * Rerun test * Update doc * Comment ghc-exactprint requirements * Add test for apply-refact-0.10 * Use hackage stylish-haskell * ghc-exactprint constraints for hls-class-plugin * Remove uncompiled if Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…haskell#2854) * hls-hlint-plugin & hls-stylish-haskell-plugin rush to ghc92 * Restore allow-newer * Add BufSpan for lower version ghc * Add Cabal constraint for stack-9.0.1.yaml * Try ghc-lib-parser for BufSpan * Loose tactic compiling constraint * Rename hlint34 * Rerun test * Update doc * Comment ghc-exactprint requirements * Add test for apply-refact-0.10 * Use hackage stylish-haskell * ghc-exactprint constraints for hls-class-plugin * Remove uncompiled if Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
No description provided.