For the past month, I’ve been working on the purescript-analyzer project, which is a language server for PureScript. The project is in its very early stages, though I’ve gotten to the point of a super constrained end-to-end demo w/ hover information.
The project is written in Rust, which is a language I’m comfortable in because of existing tooling and libraries. In fact, most of the analyzer code is inspired by GitHub - rust-lang/rust-analyzer: A Rust compiler front-end for IDEs with its query-based approach towards gathering information about source files.
Local type information is one of the goals, yup! The demo I built doesn’t actually do type inference for anything other than literals and variables yet but the scaffolding for let-bindings is there.
How it works internally is it emits a source map for each declaration which maps some position to an expression (and vice versa). Type inference then emits a mapping from said expressions to their types, so you can go from position (provided by hover) to a type. For something like let bindings, it should be possible to emit a similar source map but specialized for local names instead.
I think one of the bigger challenges would be supporting the entirety of PureScript’s type system, but I think the analyzer allows for these features to be added incrementally.
It’s been a little while since the last update—I’ve been actively working on the analyzer for the past 5 or 6 months (I ended up rewriting most of it ).
I’m planning to release an alpha for the LSP server with support for textDocument/definition and textDocument/references sometime this June.
I’m also enthusiastic to talk about the design of the analyzer, so ask away if you have any questions!
It’ll be a separate extension/language server, although this raises a concern about ergonomics since I believe editors like VS Code would ask you which language server to send the request to.