-
-
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
Feature Request: Automatic Expansion of uninitialized record fields #462
Comments
More sophisticated versions of this could infer what fields are already initialized, and only supply the ones that are missing in this way. |
Is this something that belongs in |
Even cooler would be, agda supports straight up introducing the entire record.
|
I would say that i could be done in a plugin in hls, but not sure. |
@googleson78 yeah that's also great. That said, when the typedef expands (like many records do over time), I'd still like to be able to introduce the missing fields. |
* Detect ghc version mismatches * Add ghc-check to stack extra deps * ghc-check: explicit libdir and delay version error
Somewhat related, it would be nice to have a shortcut to convert from using the "normal" constructor to using record syntax. For example if I have the following: data Person = Person { firstName :: Text, lastName :: Text }
let p = Person "Robert" "Dupont" Some shortcut could convert the second line to: let p = Person { firstName = "Robert", lastName = "Dupont" } |
Now tactics has a code action: person :: Person
person = _ in person :: Person
person = Person {firstName = _wf, lastName = _wg} So i think the suggestion of @googleson78 is already covered. It still misses the other two requests:
For the first one there is a dedicated ghc warning usable to add a quick fix:
So i would say it should not be very much dificult to get |
Had a look at the codebase and I think this might be a good start for me to start contributing. Can I attempt this issue? My outline would be to add a code action for the For suggestion 2 I'd probably have to have a look on how LHS detects if a token is a record constructor invoked using function syntax. Hoping to spend the week on this 🤞 |
@naufik nice! thanks for willing to contribute, feel free to ask anything here or in the chat channels. |
Is this still open for contributions? |
Hey @salman69e27, unfortunately when I picked this up I couldn't get the build env to work at the time and currently have time constraints to contribute. You can pick up |
Thank you @naufik . I will start working on it in a couple of days |
Contributions are welcome 🤗 I just want to point out, as it is not mentioned in the thread, that HLS already generates record fields when autocompleting a record constructor. Is this good enough? Does it just need to be publicised more? |
The original request is really around having HLS intelligently expand any constructor that had a warning on "uninitialized record fields". |
This is, of course, an issue with my setup - but actions were trivially set up for me and I use them extensively, while I still haven't gotten around to making the record field autocomplete, so I would be happy with having this as a code action. |
I'd like to work on this ticket! :) |
I'm working on this during Zurihac 2024. |
Just an update that my usecase is no longer covered either, since wingman is not maintained since 9.0 afaik |
Update from me: I have a branch with something that kinda works, just adds some extra new lines (not sure what's going on). I will try to resolve it this weekend, if not I will create a draft for someone more experienced with ghc-exactprint to take a look. |
When a warning for "Fields of ‘SomeRecord’ not initialised: a, b, c, d" fires, I'd like a
CodeAction
that allows it to initialize all of those rows with typed holes.Flow would look like this:
let thing = SomeRecord{}--> let thing = SomeRecord { a = _, b = _, c = _, d = _ }The reason that this is somewhat of a big deal is that in the presence of long record names with the conventional prefix based row names (someRecordA, someRecordB, ...), the typing for this is nontrivial and also entirely mechanical and so the editor is perfectly capable of doing this for me.
The text was updated successfully, but these errors were encountered: