asai icon indicating copy to clipboard operation
asai copied to clipboard

🔣 A domain-specific language with handler combinators

Open favonia opened this issue 1 year ago • 4 comments

  1. Dispatching diagnostics to different handlers
  2. Duplicating diagnostics to multiple handlers
  3. Filtering diagnostics
  4. Accumulating diagnostics (?)

favonia avatar Nov 01 '24 13:11 favonia

I was going to write a response here that something like a handler combinator thingy is the more natural way to proceed, but you beat me to it :)

kentookura avatar Nov 01 '24 13:11 kentookura

@kentookura Are you claiming that with these three combinators you can already implement the features you wanted trivially?

favonia avatar Nov 01 '24 14:11 favonia

Yes, I think so

kentookura avatar Nov 02 '24 10:11 kentookura

One thing that I want to point out is that when implementing a language server, it is important that an empty list of diagnostics gets pushed when a computation that previously failed now succeeded. Right now I am checking this manually, but maybe this is an interesting factor when designing this.

Another thing is that diagnostics need a URI to be published to, and a computation might raise diagnostics for many files. I am handling this by

  • making sure that all diagnostic loctexts get created with the source argument
  • accumulating them in a (Lsp.Uri.t, diagnostic list) Hashtbl.t that gets populated by emit and fatal: I am inspecting the loctext of the diagnostic and creating an Lsp.Uri.t from it.

This is not enough, though: Say that evaluating file A previously failed and had a diagnostic pushed to it. Running the evaluator again now succeeds, but now I need to know that A failed the last time in order to push an empty list to clear the diagnostics, so I need to track some state.

kentookura avatar Nov 08 '24 09:11 kentookura