Weeknotes 2025-W15Forester 5.0 development: canonical URLs, atom feeds, and LSP › Language server; code completion via effects and handlers [01A9]

Kento is hard at work hardening Forester’s language server. I am hoping that we will have something to show on the scale of a week.

There were some subtleties about how to provide completion information at a source location—which is at least as complex as the expander itself, since scope emerges from the expansion process. We had something fairly broken in place, which I have spent Thursday and Friday morning replacing with something cool using OCaml 5’s effects and handlers. The idea is to instrument the expander with an effect that notifies observes that it has entered a source range; this can be handled as a no-op, or by querying the scope’s available symbols when it enters the desired range and throwing away the continuation, and resuming the continuation otherwise to keep searching. This approach allows all the scope-handling code to be unified into a single routine, whose behaviour is controlled by effect handlers on the outside.

As a side note, I am looking forward to when the next version of Topiary is released, which should contain support for formatting OCaml’s effect handlers. Right now we don’t use the nice notation because we are stuck on Topiary 0.6.0.