vscode-reasonml icon indicating copy to clipboard operation
vscode-reasonml copied to clipboard

Make it possible to expand types via Merlin

Open yminsky opened this issue 7 years ago • 4 comments

Merlin's emacs support lets you expand the type shown for a given expression by requesting the type a second time. (e.g., you type C-c t twice.) The expansion that Merlin supports is to expand type aliases, and in some cases it's quite important for making the types easier to understand.

It would be great if the vscode support allowed access to this Merlin feature as well.

yminsky avatar Jan 28 '18 21:01 yminsky

This is something I'm currently working on in the development branch. Specifically, the new merlin backend will allow adjusting the "verbosity" (in merlin terminology) of the query.

One problem is how to expose this to the user. The emacs style interface of repeated queries doesn't work so well in VS Code with the language server because the queries are supposed to be handled asynchronously. There isn't really a clean way for a certain block of queries to be "atomic", so to speak; something might be happening elsewhere in the editor which triggers another unrelated query to merlin in between the first and second typing query.

One solution, which how the other plugin works, is to always use the verbose form of the query, i.e., just always do the typing queries twice. This is probably better than what we do now since it should give useful information more often. Expanding everything may not be ideal either though.

Another possibility would be to allow some sort of toggle state (maybe indicated in the status bar) that would allow the user to control whether the results shown on hover use the verbose form or not.

ghost avatar Jan 28 '18 23:01 ghost

I guess I could imagine having something you could click on the pop-up to expand the types. It's a little slow and mouse-intensive, but not too bad.

On a related note, is there a way of looking up types from the keyboard? Right now, I hover over a value with my mouse when I want to see the type. That's nice for teaching my kids to code, but painful if trying to do anything more substantive.

yminsky avatar Jan 29 '18 13:01 yminsky

On a related note, is there a way of looking up types from the keyboard? Right now, I hover over a value with my mouse when I want to see the type. That's nice for teaching my kids to code, but painful if trying to do anything more substantive.

You can open the hover widget from the keyboard with the key chord combination ⌘K ⌘I. There is a list of such commands here.

ghost avatar Jan 29 '18 21:01 ghost

Thanks! I was looking for show-type, but show-hover makes sense too.

yminsky avatar Jan 29 '18 22:01 yminsky