-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
Simpler Tier 1 tactics for case splits #3525
Comments
Hi @ejconlon I've been AFK from HLS development for a few months. Let me give you my status. I do not find myself excited to work on GHC-related refactoring tools. I personally find that the stability and quality of the ghc-exactprint API has made it unpleasant for me to work on new refactoring tools. There were other reasons as well (personal), but the technical reasons are worth going into... Why tactics and co haven't mergedThe reason I've never merged hls-tactics-plugin, even though it works, is because maintaining it is just a massive pain. There are I think no more than 10 tests that are a little broken out of 130. It is worth merging as is if someone updates those test files to accept the slightly-broken results. The new plugin is, as you describe, a simplified view of tactics, thanks to @isovector's work, which paved the way for me to update to 9.2 and migrate to the new exactprint API. The same applies to [those] [3] [code] [actions] I [developed]. However, I personally am very frightened of the stability of GHC's exactprint API. Migrating to using GHC 9.2 was really quite exasperating for me. And developing tools against the 9.2 API from scratch was also exasperating. My feelings on
|
@santiweight This is really great context! Thanks for sharing it and thanks for all your hard work on the project! Let me digest a bit now… |
OK, I understand better what some of the issues are. It seems like When you talk about the issues you had with the exactprint API, is the problem that the exactprint annotations and their meaning have been changing, or GHC syntax itself? Or is it that the Transform API, for example, has not been stable? (I don't have any context on this library.) Finally, is there an understanding of what all the relevant transforms are for HLS as a whole? Would documenting this help clarify what a good transformation API would offer? |
That is still my hope! Happy to work on such ideas...
I do, in general, mean the exactprint API, referring to the TransformT API. Here are some of my recollections:
I'm not aware of an exhaustive list. The places to look are in the big file of code actions, and also the tactics plugin. Those two places contain most of the usages. I once attempted to start congregating these usages into a new group of utilities. It was certainly challenging (I might still have that branch lying about).
I don't think that the Transform API has been unstable, but it has been hard to use. For example, I would have guessed that the "add new declaration to a where clause; or introduce a new where clause if there wasn't one" would be hard, but it was much harder in ways that I didn't expect, and the implementation is iirc still not great. It's important, however not to just write another API, but to build a group that maintains something together. Such higher-level APIs have been developed at least three times (HaRe, the tactics plugin, and that library that the tactics plugin uses), but they all seem to fall out of date. If you want, a good place to start is probably to define some high level functionality that should be in the exactprint API, such as the one I tried to upstream. Perhaps we can get a foot in the door that way, and slowly upstream exactprint functionality? If you'd like to work on that ghc-exactprint MR I linked above, I'd be happy to get that pushed through. |
Just to reiterate; the hard part here is updating the text buffer with the results of having synthesized new code. Dealing with layout and comments and where blocks and all of Haskell's syntax is a Herculean effort that we used to pass the buck to the exactprint API to do. Which was still enormously difficult, but at least possible. Since ~9.2, exactprint got merged into GHC proper as part of the Trees That Grow infrastructure... which is a better place to have it than in some weird separate library, but it's still way too close to the metal. Getting proper GHC-level support for grafting the AST and dumping it back out, comments and layouts and all, is the only tenable path forwards that I can see. For a bounty on the order or $5k I could be talked into getting tactics working again in HLS for a specific version of GHC, and we could use that same energy to think through what API GHC would need to provide us. |
Right @isovector I thought originally the problem was lack of maintainer time for tactics, but I see that the problem is really in textual transformation. (Thanks for your efforts!) I can close this issue if you would like to continue the discussion in a clearer thread. |
Just putting this link here since I think we should consider going this route if we resurrect a case-splitting plugin: #2437 |
Is your enhancement request related to a problem? Please describe.
First, let me say that I appreciate all of the hard work the maintainers of HLS and plugins do and have done - you guys are superheroes!
It looks like
hls-tactics-plugin
has been disabled due to some conflict with GHC 9.2 that has not been resolved. This means that features like case splitting are no longer available in HLS. I am probably not along in having become very used to this feature, as it allows one to destruct large sum types quickly. In my opinion, this tactic should be a Tier 1 feature of HLS, at least for "simple" types (ADTs, maybe not GADTs). It would be great to see it re-enabled, but it seems like the machinery of thetactics
plugin is a bit daunting for new contributors! It has support for type-directed program synthesis that may not be needed for simple tactics such as destruct (but please correct me if I am wrong).Describe the solution you'd like
I propose a separate plugin that supports the simplest tactics like destruct and intros, and only on simple types. Ideally we would get it into a state where enough people would feel comfortable with maintenance that it could be a Tier 1 plugin. Doing this might be a good opportunity to pull out some reusable functionality that can be shared between tactics implementations and other plugins. (For example, right now
tactics
relies onrefactor
for printing and insertion.) Such reusable functionality might include:(I know where some of this functionality is, but it's not easy to find and isolate! Documentation may help.)
The
tactics
plugin could then be focused on more advanced program synthesis.Describe alternatives you've considered
The alternative is the status quo, where
tactics
may disappear in HLS releases as it is not Tier 1. Additional maintainers could change that, though. Improved documentation of thetactics
plugin would also help.Additional context
I am happy to contribute what I can, but I definitely need some help. I am also happy to try to break down and organize tasks.
The text was updated successfully, but these errors were encountered: