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

Show specialized types on hover #1322

Open
voodoos opened this issue Jun 26, 2024 · 3 comments
Open

Show specialized types on hover #1322

voodoos opened this issue Jun 26, 2024 · 3 comments
Labels
discussion discussing a feature/change, roadmap

Comments

@voodoos
Copy link
Collaborator

voodoos commented Jun 26, 2024

In emacs / vim modes for Merlin the ability to grow / shrink enclosing has an interresting side effect: often the first two enclosing are identical but the second one shows the most general type while the second one show the specialized type.

For example, given the following code:

let f : 'a -> 'a = fun x -> x
let _ = f 4

Querying Merlin on the usage of f line 2 first result in 'a -> 'a, and querying the next enclosing shows the specialized type int -> int. However, in ocaml-lsp, there is no way to get that second answer since the on_hover query always consider the first enclosing.

I feel like I am more often interested in the specialized type because it also gives me information on the type of the actual parameters. I guess this is a matter of context and preference, but I generally find the current behavior not satisfying.

We might soon be able to use a custom query that would allow editors to reproduce the classic merlin enclosing behavior, but I am wondering whether we should change the default behavior for the on_hover query...

We could also show both types at the same time ?

@voodoos voodoos added the discussion discussing a feature/change, roadmap label Jun 26, 2024
@xvw
Copy link
Collaborator

xvw commented Jun 26, 2024

Yes! I think that having a nice pretty printer (ie: 'a -> 'a \n int -> int) for "applied/specialized" function can be very useful!

@rgrinberg
Copy link
Member

Sure, you can experiment with it. No particular preference on what's the best default here.

@rgrinberg
Copy link
Member

However, in ocaml-lsp, there is no way to get that second answer since the on_hover query always consider the first enclosing.

Another idea that may or not be feasible: include a markdown link that can be followed to see the expanded definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion discussing a feature/change, roadmap
Projects
None yet
Development

No branches or pull requests

3 participants