Hey y’all,
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.
Demo: https://youtube.com/watch?v=s82mvG9nkR4
18 Likes
No way! Would this hypothetically let you hover over let bindings and where bindings to see type info?!?!
2 Likes
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.
8 Likes