Skip to content
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

Automatically add imports when adding type signature #173

Open
i-am-the-slime opened this issue Jan 30, 2022 · 1 comment
Open

Automatically add imports when adding type signature #173

i-am-the-slime opened this issue Jan 30, 2022 · 1 comment

Comments

@i-am-the-slime
Copy link
Contributor

i-am-the-slime commented Jan 30, 2022

This is one of the most robotic things I do everyday. I let the IDE add a signature for me but then the types in this signature can't be found. It would be nice if I could apply this signature and add any missing imports in one step.

@nwolverson
Copy link
Owner

This is a compiler issue. Both type information returned via the purs ide protocol and type warnings/errors from the compiler (and the fixes it suggests in the json output) are textual representions of types assuming appropriate imports, leading eg to the classic "expected Type but found Type" error pattern.

But I agree, I think that separate things to do there are

  1. Compiler warnings suggest imports as required (at least in JSON form, with multiple edit suggestion)
  2. Compiler warnings qualify to avoid ambiguity (not entirely relevant to this but probably linked where there are identifiers that must be imported qualified)
  3. Separately, purs ide outputting types as structured (hence qualified) objects instead of textual representations

We could add any unambiguous imports - in fact similarly could have a "add all imports" command for unambigous imports, eg for copy-pasted code but I don't have a great feeling how useful that is

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

No branches or pull requests

2 participants