Open leana8959 opened 1 year ago
Hey 😊👋
Thanks for the request. Unfortunately, I don't think this would be easy to implement in haskell-tools.nvim, as it is haskell-language-server that evaluates the code snippet and adds the result to the document.
I like the idea though. Maybe it could be added to haskell-language-server, in the form of a code action that produces diagnostics or inlay hints or something similar that can be displayed as virtual text. I fear trying to evaluate code snippets on the fly would be too risky (e.g. what happens if a snippet recurses infinitely?)
I'm not sure, but I think what you're seeing in Scala are inlay hints, not actual code snippet evaluations?
Unfortunately, I don't think this would be easy to implement in haskell-tools.nvim, as it is haskell-language-server that evaluates the code snippet and adds the result to the document.
I see, maybe I'll create a feature suggestion in their repo :)
I fear trying to evaluate code snippets on the fly would be too risky (e.g. what happens if a snippet recurses infinitely?)
That's also a valid concern that I haven't thought of. In metals
it just shows an error diagnostics, and stop evaluating the rest of the code. I think we might need a way to restart the repl if it loops too long.
I'm not sure, but I think what you're seeing in Scala are inlay hints, not actual code snippet evaluations?
These are "worksheets", I'm not sure if there is an equivalent of it in Haskell. Basically, it evaluates the value of each line and shows hints on the right side. It's a lot more than just type hints.
Also thank you for the haskell-tools
project, and for taking your time reading my suggestion :)
maybe I'll create a feature suggestion in their repo :)
It definitely sounds like a good idea :smile:
In metals it just shows an error diagnostics
Haskell doesn't have a recursion limit (it doesn't have a traditional call stack. So the evaluation would probably have to be an async action with a timeout.
Basically, it evaluates the value of each line and shows hints on the right side. It's a lot more than just type hints.
I could imagine this being very practical for pure evaluations (not in IO
).
Also thank you for the haskell-tools project, and for taking your time reading my suggestion :)
No problem. I'm happy to share :smile:
These are "worksheets", I'm not sure if there is an equivalent of it in Haskell.
Just read through the Scala documentation on worksheets
So if I understand correctly, this is available in files with a special extension, but not regular scala files. Hmm, that could be an interesting feature...
Let's leave this issue open and I'll think about whether it makes sense to contribute it to haskell-language-server. But please feel free to open an issue there. Maybe someone will be faster to implement it than me 😊
Feature description
Hello,
I noticed that with Scala's
metals
, the results of an evaluation show up as virtual text; on the other hand,haskell-tools
puts them in comments.Is it possible to have the option to use virtual text instead of comments for evaluation results? I simply think it's neater to not have the file changed when one's simply "probing variables and functions"
A possible problem I can foresee is that longer messages won't fit. A solution could be to place a code action over the evaluated line, which when triggered, shows the complete result.
Here's an image how it looks like for Scala. Note that I can't actually change the text on the right after
//
because it's virtual text.Thanks, have a nice day :)