-
-
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
Reintroduce ghc-lib flag for hlint plugin #3757
Conversation
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.
I guess I'm not clear about the motivation, can you say more? Do you want to do this for all the other packages too? Where is this going? I don't mind this too much but I would like to have a clear policy (our policy so far has been moving towards using ghc-lib-parser
unconditionally as much as possible).
Use ghc-lib-parser rather than the ghc library (requires hlint and | ||
ghc-lib-parser-ex to also be built with it) | ||
default: True | ||
manual: False |
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.
Surely manual: True
? We only want this to be toggled deliberately, I think.
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.
Yes I think you're right.
I have been trying to get hls in the horizon package set working better, and in that case where you have full control over the toolchain it seems it would make more sense to be able to use the GHC library rather than having to recompile it all in ghc-lib-parser. hlint, ghc-lib-parser-ex and even hie-compat have similar flags so I thought it made sense to do something similar here. I think the only other plugin that only uses ghc-lib-parser is fourmolu, but that change would be outside of hls anyway. @fendor pointed out on IRC that using the GHC library should allow the hlint plugin to not have to reparse the file which would be a nice benefit, it looks like the old gated code was trying to do that so I'm trying to get it working again now, though I'm running into issues with apply-refact working on already parsed modules. |
So the main motivation is reduced compile time? I'm not sure that's worth the added complexity on our side, tbh. That said, I'm not sure I totally understand why we are using the |
Ah right, I think I remember. The issue is that version X of |
Does this not reduce complexity as is? The package imports weren't needed and the unused cpp gated code has been removed. The flag swaps out dependencies with the only difference in the plugin being how it checks the GHC API version which was there already. That said, I'll spend a bit more time today seeing if I can get |
That change is great and I love it :)
This gives us two ways to do things. The second way (using the GHC API) will not currently be tested (and I'd rather not add yet another dimension to our test matrix), so we won't know if it works. Having multiple ways to do things that aren't all tested seems like more complexity to me, and quite probably a source of bugs in the future. |
Is this not sufficiently tested anyway? For what its worth I managed to get the hlint plugin to work directly on the already parsed modules, though it requires a fix to apply-refact to be released as it seems |
Okay, I'm still unsure this is necessarily a good idea, but if you want it and will be testing it then I'm not sure it causes much harm, so let's bring it in. There is a conflict. |
df8ea6c
to
b6aa8e5
Compare
Updated. I notice that #3804 removes |
@michaelpj The Arch package of @RaoulHC Some of the checks are failing with conflicts detected. Can you take a look to bring the PR back into a mergeable state? -- Vekhir |
9c52825
to
cd7ed10
Compare
@Vekhir I've updated it to be mergable. It's worth noting that to avoid ghc-lib-parser you'd have to avoid the ormolu/fourmolu plugins because they depend on ghc-lib-parser and it looks like they've made the decision to not to have an option to depend on GHC: tweag/ormolu#948. I think there's less value to this change with that in mind, but maybe you can try and convince them. |
@RaoulHC W.r.t. ormolu/fourmolu, that's not an issue right now. Medium-term it could be a goal, and then it would help to have hlint as a showcase that it can be done and is worth it. |
Actually given our discussion, I'm fine just merging this, but thanks for taking the trouble to try splitting it up, that's appreciated. |
A lot of the HLINT_ON_GHC_LIB gated code has been bitrotting since this flag was removed. This could be reintroduced if we wanted to directly work on the same parsed AST, but as the hlint ghc plugin showed this may not make much difference: https://www.haskellforall.com/2023/09/ghc-plugin-for-hlint.html
The ghc-lib flag was removed in haskell#3015, but it's still useful to be able to compile hls-hlint-plugin using the GHC API if you've done so for hlint and ghc-lib-parser-ex, rather than using ghc-lib-parser as it simplifies the build and dependencies.
Head branch was pushed to by a user without write access
Updated so at least the individual commits work by themselves. |
Don't think the test failure is related to any of my changes, is that a known flaky test? |
Yes, this is one of the flaky tests. I restarted the failed job. |
The ghc-lib flag was removed in #3015, but it's still useful to be able
to compile hls-hlint-plugin using the GHC API if you've done so for
hlint and ghc-lib-parser-ex, rather than using ghc-lib-parser.
A lot of the HLINT_ON_GHC_LIB gated code which has probably been
bitrotting since this flag was removed has also been removed, and is
probably from when hlint used to work on haskell-src-exts. As
ghc-lib-parser has the same API as GHC itself, there's no need for code
to be cpp gated.
I've also updated the
configuration-ghc94.nix
file to show how it can be builtusing the GHC libraries instead of ghc-lib-parser.