-
-
Notifications
You must be signed in to change notification settings - Fork 388
Check types of missing definition in add import quick suggestions #754
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 would be a really great improvement and i dare to say it should no be too difficult. Also, i think i read that suggestion in another issue but i cant find it out right now. |
There are two quick fixes involved here: suggest new import and suggest extend import. The code for these quick fixes is at: haskell-language-server/ghcide/src/Development/IDE/Plugin/CodeAction.hs Lines 796 to 805 in 0b3bb10
and at haskell-language-server/ghcide/src/Development/IDE/Plugin/CodeAction.hs Lines 1241 to 1250 in 0b3bb10
In order to implement this, you will need to:
I'm not really sure what's the best way to retrieve I, possibly parsing the error message? Retrieving C should be easy - just look through the To check if they are compatible, I would do this with |
The error message seems like a stable one to match against (data constructor has a slightly different message): I'll try with approach outlined in #754 (comment) and see how it goes. |
@pepeiborra Sorry to disturb you, I took a look at this and found the type of identifier can get from |
@July541 have you seen my recent comment in #2081 about this? It describes an easier approach, albeit too slow. To answer your question: To retrieve the type of the candidate you would need to use the GHC api, similar to what ghci |
I think we could try the direct ghc api approach until typed holes are usable, if using the API does not introduce too much complexity |
Thank you, I'll try it.
Yes, I think we can move a little step at the beginning. |
https://hackage.haskell.org/package/ghc-8.10.2/docs/GHC.html#v:lookupName might be helpful for getting the candidate types. |
Woohoo, thanks for your guide, it seems pretty nice!!! |
Do we have a function like
haskell-language-server/ghcide/src/Development/IDE/Types/Exports.hs Lines 117 to 132 in dab8d00
|
This continue being unimplememted and it is so annoying that i am tempted to label it as a bug @July541 do you still planning continue working on that? do you have some work which could help other to continue this? |
If at least we would have #2436 it would make sense to propose definitions with other types, as you could apply but if we have several definitions with the same name and different types, they should be filtered unconditionally, imo |
As my latest comment mentioned, the difficult part is I'll have a look this weekend. |
Don't have a proper solution:(, feel free to pick this if anyone has ideas |
Current behavior:
Even though the type of
toLower
is known from the context (Char -> Char
), "quick fix" purposes to import functions that, despite having the same name, are known not to be correct type-wise (Data.Text.Lazy (toLower)
for example).Proposed behavior:
When the type of the undefined function is fully known, filter quick fixes by type.
The text was updated successfully, but these errors were encountered: