-
-
Notifications
You must be signed in to change notification settings - Fork 389
Enhancement: parenthesise compound completion snippets #1700
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
Comments
This is a bit tricky:
Given 2 and 3, I don't think this will work so well in practice. But I might be wrong! The only way to find out is prototype it and have a play with some real code. Note that untyped holes don't have any of these problems, so I think that's probably an unambiguous improvement over the current situation. Also, about the current situation, I don't think that generating invalid programs is necessarily an issue - in languages with named parameters the snippet includes the name of the parameter and not its type, which usually leads to an invalid program too since the name is not a binding in scope. But that's not an issue because the user is expected to rewrite the snippets immediately and editors optimise for this by deleting the whole snippet as soon as the user starts typing, and keybinding TAB to move to the next snippet. |
I agree that we dont need to generate well-formed programs and the first simply parenthesised solution would do.
I'm slightly against on this point from my experience. We might ponder what to fill in the placeholders for a while, and browses to other location or modules to get insights. Or, some placeholder gets somewhat complicated during the edition. We can easilly end up with exitting placeholders in such cases. |
To make my point clearer: the intention of this proposal is to make the argument boundaries in snippets clear. Well-formedness is just a bonus. |
Just adding parentheses when needed is an unambiguous improvement - +1 |
* Enhancement: #1700 * changed bracketed typed hole completions to regular bracketed completions * removed redudant comment * removed whitespace * Updated test cases to expect bracketed completions, Type constructors with no arguments no longer bracketed * Updated hls tests for bracketed completions * added missing ghcide/example/HLS file * moved ghcide/examoke.HLS to ghcide/bench/example/HLS * Restored ghcide/bench/example/HLS * restored ghcide/bench/example/HLS * removed unnecessary 'T.pack' (OverloadedStrings) Co-authored-by: Oliver Madine <olliemadine@gmail.com> Co-authored-by: Junyoung/Clare Jang <jjc9310@gmail.com> Co-authored-by: Potato Hatsue <1793913507@qq.com>
Currently, HLS's completion snippet inserts types or kinds as-is.
For example,
foldl
gets completed to:
where
b -> a -> b
,b
andt a
are three separate snippet placeholders.This makes it harder to detect boundaries of generated "placeholders" after a snippet is completed tentatively.
It might be good to parenthesise each placeholder when it is compound.
For example, the above must be at least:
or:
Hole-based approach works better as it generates well-formed programs; however, holes can make GHC significantly slower, it might be good to parenthesise plain placeholders (with types or kinds alone) could be enough.
The text was updated successfully, but these errors were encountered: