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

Go to definition of the instance of a method instead of its type definition in type class #2922

Open
anka-213 opened this issue May 23, 2022 · 2 comments
Labels
type: enhancement New feature or request

Comments

@anka-213
Copy link
Contributor

Is your feature request related to a problem? Please describe.

When code uses a lot of type classes, it would be useful to go to the definition of the actual method that will be called in the concrete instance instead of the abstract declaration in the class.

For example, when using Data.Binary, code often looks like this:

instance Binary Foo where
  get = Foo <$> get <*> get

in this case, go to definition is not very useful, since it only takes you to the Binary class itself instead of something concrete.

Describe the solution you'd like

If the concrete instance that will be used is known at compile time (i.e. when there is no SomeTypeClass a => context on the current function), go to definition should take you to the instance's method instead of the class. Otherwise, the current behaviour would be preserved.

Describe alternatives you've considered

An alternative would be to have this be some separate command, rather than the go-to-definition. I am not sure if this new behaviour would make it more difficult to go to the class declaration.

Additional context

Related to #2478

@michaelpj
Copy link
Collaborator

I wonder if this would be fixed by #1983 ?

@anka-213
Copy link
Contributor Author

Yes, that sounds like exactly what I was looking for!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants