-
-
Notifications
You must be signed in to change notification settings - Fork 371
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
Improved fill hole suggestions #883
Comments
This is a candidate good first issue @ndmitchell @cocreature |
Further discussion in this Reddit thread |
ping @Tritlo |
Refinements hole fits are valid! They just need additional arguments. A very nice developer flow would be to add those suggestions as well, and then users can fill holes with functions with additional holes! I wouldn't suggest sort by subsumption. It only gives slightly better order, but it is much slower (especially when there's lots of matches. Show constraints is the best, since you can tell at a glance what's happening. Though it doesn't work without TypeApplications on (since the resulting @ would be a parse error). Showing the docs would be nice too, though it can produce a lot of output if the docs are long! |
noob question:
Do you mean that if there is a suggestion of, for example, I'm confused because constraints shown don't seem bound on specific suggestions For example:
|
Looks like |
Another thing that could be very useful would be to not suggest trivial infinite recursion. If I write the code foobar :: Foo -> Bar
foobar = _ I probably don't want the definition foobar :: Foo -> Bar
foobar = foobar Currently, this is the first suggestion it gives. Maybe I should open a separate issue for that though? |
Yet another thing that might be very useful, but maybe is much work (including more work on ghc), would be the ability to fill holes with a function that require more arguments, which would then become new holes. E.g.
which it would suggest filling with either
This particular case could also be resolved as introduction forms for the data type, but I was thinking of a more general version for arbitrary functions. These suggestions should probably be lower down in the list than the more precise suggestions. And it probably shouldn't suggest generic functions like |
This is precisely what |
Note! Valid hole-fits are a lot faster now on HEAD, so this might not be required anymore. |
A lot of work has gone into making GHC able to produce suggestions and the current code action falls short of making the most of it. The possibilities include:
-fshow-hole-constraints
to make added constraints explicit?-fshow-docs-of-hole-fits
to show the docs of the suggestion?-frefinement-level-hole-fits=1
to show almost-valid fits?-fsort-by-subsumption-hole-fits
?The text was updated successfully, but these errors were encountered: