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

[Feature request] Type sigs on class plugin #1157

Closed
googleson78 opened this issue Jan 4, 2021 · 13 comments · Fixed by #2920
Closed

[Feature request] Type sigs on class plugin #1157

googleson78 opened this issue Jan 4, 2021 · 13 comments · Fixed by #2920

Comments

@googleson78
Copy link
Contributor

Would it be possible to look at the current source file, and if InstanceSigs is enabled, also add type signatures to the methods that the "Add placeholders" action generates?

I would add this too, but I don't know

  • how to get the type information
  • how to get "currently enabled extensions" (if it's possible to do so)
@Ailrun
Copy link
Member

Ailrun commented Jan 5, 2021

For 1., I believe the current plugin already uses type information of instantiated class.

@jneira
Copy link
Member

jneira commented Jan 5, 2021

For 2, you can take a look to the hlint plugin, there we are querying the actual extensions used by a module

@ndmitchell
Copy link
Collaborator

Alternative design would be to always show the signatures (they can be quite helpful) and if someone clicks on the hyperlink and InstanceSigs aren't enabled you insert it too.

@googleson78
Copy link
Contributor Author

googleson78 commented Jan 6, 2021

Which "hyperlink" are you referring to? (using vim, so I'm not too sure about what gets shown in vscode and the like..)

Right now there's

  • a diagnostic message mentioning the unimplemented method
  • a code action associated with the instance declaration, where it inserts the method

Where could the signatures be? I can think of having a code lens on the method, like there currently is for top level declarations with no types, which you can trigger to add the type.

@googleson78
Copy link
Contributor Author

As far as I can tell, the only information I have available regarding class methods is their names (and whether they have default definitions).

I guess this needs to get fetched in a similar way to how the Tactics plugin fetches type info.

@googleson78
Copy link
Contributor Author

Their approach won't work here, since they're interested in getting bindings, not the type of an arbitrary identifier.

Perhaps something like requesting a typecheck and/or a ghc session and looking in there might work..

@Ailrun
Copy link
Member

Ailrun commented Jan 7, 2021

@googleson78 We already request a typecheck and ghc session in the action part of the plugin, so I believe you can reuse those if you need them (and create type info in the action part instead of the command part).

@July541
Copy link
Collaborator

July541 commented May 18, 2022

Hello @googleson78, do you still work on this? I'll pick this if you don't have more plan on it.

@googleson78
Copy link
Contributor Author

Go ahead and pick it up, I'd completely forgotten it 😅 Sorry!

@michaelpj
Copy link
Collaborator

My $0.02 on design would be:

  • Always show the type signature in a code lens (like we do for normal bindings without type signatures)
  • If the user clicks it and InstanceSigs isn't enabled, add it.
  • Also provide a code action to add the signature, this can make automation easier.

@July541
Copy link
Collaborator

July541 commented May 20, 2022

Very handy 😉

codelens.mp4

@michaelpj
Copy link
Collaborator

Also provide a code action to add the signature, this can make automation easier.

Incidentally, I believe the current add-type-signatures lens doesn't do this, and it would be nice if it did.

@July541
Copy link
Collaborator

July541 commented May 20, 2022

Also provide a code action to add the signature, this can make automation easier.

Incidentally, I believe the current add-type-signatures lens doesn't do this, and it would be nice if it did.

Sure, I'm working on this.

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

Successfully merging a pull request may close this issue.

6 participants