Open SquidDev opened 4 years ago
Now that v3.15 of the protocol has been released, it'd be worth adding support for diagnostic tags. This is used in VS Code to render unused variables and deprecated variables in specific ways.
We'll need to submit a PR to haskell-lsp in order to enable that. I put something together when the spec was a draft, but that needs finishing off and pushing.
Features
[ ] Explain error at point:
This will either involve embedding the explanation information within the language server, or shelling out to "amc explain". Note, this will require explicit support within the editor.
One thing to be aware of is the complexities in mapping locations back to the typed AST. Typing and desugaring introduces additional nodes, so we need to be careful that what we point to is the correct definition.
Minor cleanup
Further notes
The compiler is currently very much structured in a fail fast manner. Resolution (and TC to a lesser extent) either succeed, or fail and throw away all information. This is obviously not ideal as far as editing goes, as you are rarely operating on a well-formed tree.
There's a couple of things we could do to improve this:
Make parsing more fault-tolerant. It's really not clear how to do this using Happy, and I don't really fancy home-growing another parser generator. There's some interesting notes in this document, which basically distils what things like Roslyn.
Resolution could definitely return an unresolved tree - we already do something similar with
junkVar
. If we were really fancy, we could even parse such a tree off to TC, and make it smart enough to skip unresolved nodes.Some operations can operate on older versions of the tree - we just need a function to map positions between old and current locations.
Some elements of verification could be done earlier (foreign parse errors only needs the parsed tree, unused variables could be done within resolve).