Replies: 6 comments 6 replies
-
That sounds useful, specially for advanced haskellers, we even have a feature request about: #1925 |
Beta Was this translation helpful? Give feedback.
-
This would be lovely! Agreed that semantic tokens and hover details would be a better fit than code lenses. Please put this in a plugin, not in core ghcide, for easier maintenance. I wonder how relevant the strictness analysis will be without the other simplifier passes. |
Beta Was this translation helpful? Give feedback.
-
Sounds like a good idea! However, I would gate it behind configuration as the demand analyser is expensive to run (we don't usually run it in the IDE). |
Beta Was this translation helpful? Give feedback.
-
Yeah, moreover beginners can feel lost so i would set the plugin disabled by default at runtime via lsp config |
Beta Was this translation helpful? Give feedback.
-
I would also find this handy! Perhaps it could be a full-on "GHC internal info" plugin and include e.g. all the stuff in |
Beta Was this translation helpful? Give feedback.
-
Related: #1925 |
Beta Was this translation helpful? Give feedback.
-
GHC has a very powerful demand and strictness analyzer. The output is usually hidden, but can be shown using the
-fstrictness
flag. Reporting this information during compilation is not so useful; but a code editor seems to be like a great place to show this information. I am happy to put some work on this matter, but first we would need to figure out how to show this. Here are some ideas:Show cardinalities on hover
In the same way that we show the type signature and the Haddocks when hovering over a symbol, we could also show the demand signature. GHC shows it in a very compact way (for example, the signature for
fst
is<1P(1L,A)>
), but there's room for more explanation in the pop up window we get.Highlight evaluation
Change the color or the appearance of a pattern to highlight that evaluation takes place. I'm imagining for example that if you write:
Then
True
would change its color to explain that evaluation takes place there. The rest of the code is not highlighted, which means that neithert
ore
are evaluated as result of executing this function.Semantic tokens is a LSP feature which seems like a candidate to implement this feature.
Show demand signatures
We could show the demand signature of each function on top of it, as a code lens, in the same way we do for signatures which the user hasn't written. However, I have no idea how this could be done in a non-intrusive way, thus I prefer the solution above of highlighting evaluation.
Beta Was this translation helpful? Give feedback.
All reactions