-
-
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
Add plugins conditionally at compile time #687
Conversation
It is so unavoidably ugly. Did you consider Backpack? My limited understanding is that an external module system is the best possible solution to this problem, but I have never used backpack myself. |
@pepeiborra maybe backpack could work but stack does not support it for now so we could not use it. And i am afraid there are a bunch of not resolved issues in cabal. I am afraid i can't think off in other, better, alternative that would be very very welcomed |
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's horribly ugly, but in line with the approach we should be following in time.
I wonder if we shouldn't default to default True, so we don't break expectations for people just building as normal.
The default is build all plugins and formatters due to
flag all-plugins
description: Enable all non formatter plugins
default: True
manual: True
flag all-formatters
description: Enable all fomatters
default: True
manual: True you have to disable those flags to build plugins one by one explicitly |
I am gonna wait for a while just in case someone comes with a better alternative.
|
I think we could dynamically load HLS plugins (like we dynamically load GHC plugins). Then the user won't even need to recompile HLS in order to change their plugins. |
Will using dynamic loading increase cross-platform maintenance costs? Even so, I think it would be a better way than the conditional compilation... |
@wz1000 i mentioned that in #1 (comment) and #1 (comment) and we discarded it at that point (#1 (comment)) |
I'm not convinced, since we already support this for GHC plugins. /cc @ndmitchell |
If dynamic plugins are reliable i think they could be a better alternative for sure. Some thoughts:
|
I maintain a GHC plugin, record-dot-preprocessor. Getting it working on Windows without segfaults is basically impossible - I debug it via CI, and developed it on a Mac. Dynamic plugins would be a great way to go, but currently, are not practical. Likewise, Backpack is poorly supported on Stack, and leads to numerous problems. CPP and Cabal flags is the only way to go :( |
I actually think a custom tool to generate a "local" cabal package that has just the plugins a given site wants is the way to go. And if the generated packages are popular enough,they can be published in hackage. This means we bring in one novel step, a converter from a config file to a package, and everything else is ecosystem standard. |
That could be a good idea, close to my proposal on automate the generation of the boilerplate imo, but doing it in a new .cabal config file instead in update the main We would exchange the boilerplate for a program that generates it.
That would be the weaker point, cause with this pr you'll have all possible variants (and there would be a lot of them, minimum one for formatter) in one package "for free" (well, paying the boilerplate tax). And users could assemble it at will at the call site, without waiting for us to release the package (or to have to release it themselves). Given that we will not publish this in hackage yet (so we will not have our hands tied yet), i would merge it, as the custom tool has to be implemented, what do you think? Of course if anybody wants to work in that tool i would not merge. |
I am happy with this as an interim step, it does not get in the way of possible future alternatives. |
ok I would not mention it in docs and no change the install script to make easy its use, to add it as a feature for advanced users |
To assemble the desired hls version you could do:
cabal install
: all plugins and formatters by default like the actual behaviourcabal install -f-all-plugins -f-all-formatters
: only ghcide plugin (it is fixed)cabal install -f-all-formatters -f+floskell
: all non formatting plugins and only floskell as formattercabal install -f-all-plugins -f-all-formatters -f+hlint -f+fourmolu
: only ghcide (fixed) and hlint plugins and fourmolu as formatterThe plan would be change the install script to take in account plugins and:
The .cabal file has grown with quite boilerplate and add a plugin involves insert more locs, but it is almost mechanical. So add a new one it could be automated if we find it too cumbersome.