The destruct command simplifies the use of pattern matching by generating exhaustive match statements, as we’ll illustrate in this article. The command has recently received a bit of love, making it more usable, and we are taking advantage of this refresh to introduce it and showcase some use cases.
Feels like this should be a code action (a lightbulb), which is a standard discoverable interface, rather than a custom command/shortcut the user needs to learn about. Or rather, it can still be a dedicated command as well, so that the user can skip “select which code action is applicable here”, but I think a lightbulb would solve most of discoverability issues here.
You’re absolutely right, and that’s the case. The command is accessible via an action code when using LSP. I don’t say much about it because my article focuses on usage and I used Emacs (without elgot). But yes, there is an action code for destruct.
Didn’t OCaml LSP use Merlin behind the scenes?
OCaml LSP actually uses the Merlin API, via a library called
merlin-lib(so yes, you are right). But there is also a server (ocamlmerlin) which is analogous to the LSP server. Even though, for reasons of maintainability, we would like the LSP server to be the uniform Merlin API and Merlin to be “only” the library providing the functionality (requiring only a special effort for vim/emacs/vscode and others to support code-actions and specific custom-requests).