Skip to content

hls-hectare-plugin #3159

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

Closed
wants to merge 8 commits into from
Closed

hls-hectare-plugin #3159

wants to merge 8 commits into from

Conversation

pepeiborra
Copy link
Collaborator

@pepeiborra pepeiborra commented Sep 14, 2022

Hectare is a type-driven code synthesis tool presented at ICFP by @jkoppel. @Tritlo packaged it in a GHC plugin that packages the results as typed hole suggestions, and this is a simple HLS plugin that conveniently packages the GHC plugin. Paper

The plugin is opt-in as it is disabled by default. This is because the Hectare search is triggered automatically for all typed holes as part of type checking, which means no diagnostics until the search is finished. To enable the plugin, you can set the following LSP property:

  "haskell.plugin.hectare.globalOn": true,

This will enable the Plugin immediately, no restart needed. However, Hectare seems to be quite buggy at the moment, check the HLS logs where exceptions will be dumped.

@jkoppel
Copy link

jkoppel commented Sep 14, 2022

Correction: ECTAs are a new data structure and constraint solver for enumerative program synthesis, available from https://hackage.haskell.org/package/ecta . The tool is Hectare. I failed one of the goals of the presentation if some people think it was just a tool.

@Tritlo
Copy link

Tritlo commented Sep 14, 2022

I think then that the plugin I published might be misnamed. Since the package on Hackage is called ecta, I named the plugin the ecta-plugin. We could rename it hectare-plugin, but since it's already published to hackage, the old one will still be there. Let's at least make the name correct in HLS, @pepeiborra.

@pepeiborra pepeiborra changed the title WIP hls-ecta-plugin WIP hls-hectare-plugin Sep 22, 2022
@pepeiborra
Copy link
Collaborator Author

The plan here is to launch hls-hectare-plugin as an optional HLS plugin, disabled by default and enabled explicitly by the user. This requires #3193 to land first

@jkoppel
Copy link

jkoppel commented Nov 29, 2022

What's blocking this from getting merged?

@pepeiborra
Copy link
Collaborator Author

#3193

@pepeiborra pepeiborra changed the title WIP hls-hectare-plugin hls-hectare-plugin Dec 11, 2022
@pepeiborra pepeiborra marked this pull request as ready for review December 17, 2022 22:16

descriptor :: PluginId -> PluginDescriptor s
descriptor pluginId = (defaultPluginDescriptor pluginId)
{ pluginModifyDynflags = staticPlugin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So all this does is enable the Hectare plugin? I'm a bit confused by this. I would expect that if users want a GHC plugin then they can just add it to their project themselves. It seems a a bit roundabout (and extra work for us) to have HLS plugin for every GHC plugin like that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question. The Hectare GHC plugin doesn't make programs type check, it does not add a static analysis pass, nor does it rewrite your program to make it faster. It is an IDE plugin, designed to help you write programs faster.

Why is it packaged as a GHC plugin instead of as an HLS plugin then? Well, I guess a GHC plugin is more reusable - anyone can import it in their project, not just HLS users.

Why repackage it as an HLS plugin?

  • For convenience, just as we repackage code formatters and linters.
  • For discoverability, although that is a weaker argument since the plugin is disabled by default.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comparison with formatters and linters is interesting:

  • For formatters, you get a new way of interacting with the tool, including things like convenient range formatting
  • For linters you get the diagnostics integrated with HLS

If we needed this plugin in order for the Hectare diagnostics to work I'd definitely be in favour - it's just that the Hectare developers have been so clever in getting their diagnostics into hole fit suggestions that we don't actually need to do anything if the user turns on the plugin themselves. In no other case is the plugin actually unnecessary.

But I do take your argument about it being a pure IDE plugin. There wouldn't be much point enabling it in your cabal file, really!

All of which is to say: I don't know 🤷 so I guess if you're willing to maintain it we can include it!

LICENSE

library
if impl(ghc >= 8.10) && impl(ghc < 9.0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we might drop support for 8.10.7 after the next major release, do we want to add plugins that only work on 8.10?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hectare itself should work for any GHC version,
@Tritlo do you plan to upgrade the GHC plugin?
cc @jkoppel

@fendor
Copy link
Collaborator

fendor commented Jun 9, 2023

rebased the PR, ready to get merged now?

@pepeiborra
Copy link
Collaborator Author

rebased the PR, ready to get merged now?

Haven't heard from @jkoppel and @Tritlo for a while, so I'll be closing this PR until further notice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants