haskell/haskell-language-server

Implement "Go to implementation" request for type/data families

dschrempf opened this issue · 0 comments

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

"Go to implementation" already allows to jump from the use site of a class method to the implementation of the class method (if a specific instance is used).

It would be extremely useful, to also jump from the use site of a type or data family to the implementation of that type or data family (if a specific instance is used).

Using the classical example of a list-like data family:

-- Declare a list-like data family.
data family XList a                                          -- [1]
-- Declare a list-like instance for 'Char'.
data instance XList Char = XCons !Char !(XList Char) | XNil  -- [2]

A possible use site could be

toString :: XList Char -> String
toString = _

If the cursor position is on XList, we can jump to [1] using "Go to definition".

Describe the solution you'd like

However, many times, especially in more complex code bases, the definition of the data family XList, and the definition of instances are far apart, and we want to jump to the implementation [2] of the instance for Char. This would be done using "Go to implementation", but does not yet (?) work in these cases.

Describe alternatives you've considered

None.

Additional context

You tell me!