hls-render-plugin: Proof of Concept for a mechanism for customizable type driven "Actions" #4604
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, new contributor here
I'm opening this as much as a proof of concept as anything.
This PR adds a new plugin, which is conceptually very similar to (and cribs heavily from) hls-eval-plugin.
However, unlike hls-eval-plugin, it's not triggered by doctest comments, instead it takes a "configuration" file, containing a number of Haskell functions, and for each combination of "value in the current module" and "function in the config", if the result of applying the function to the value is
IO ()
it generates a code lens which runs that result.There's a lot of duplication between this and the eval plugin, and I'd be open to adding this behaviour to the eval plugin instead, but my thought process was that a standalong plugin is more modular, and people might want to turn this off, and not the eval plugin,
I've recorded a demo of the plugin in use, which I've uploaded here
There are a handful of things that I think make this un-mergable as is:
The big one is the mechanism by which I'm evaluating the configuration file; I'm doing this with
runDecls
(after parsing out any imports).This seems to me to be inferior to compiling the file as a module, and then importing it qualified. As there's currently a risk of naming collisions (and the code I have for separating out imports is incomplete, and requires each import to take exactly one line).
I'm also open to changing the name "hls-render-plugin". I didn't want to use the word "action", because I'm aware that actions already means something else in the context of the Language Server Protocol.
I'm using the
Pretty
instance onType
, to convert the type of the applied "action" to a string in order to compare it toIO ()
, I highly suspect this isn't the right way to go about that.The "stylish-haskell" post-commit action doesn't seem to work if modified files contain C++ preprocessor directives?
Finally, this code is completely untested, and I'm more than happy to fix that if you have any suggestions for sensible tests.