package merlin-lib

  1. Overview
  2. Docs
Merlin's libraries

Install

Dune Dependency

Authors

Maintainers

Sources

merlin-4.17.1-501.tbz
sha256=376707aa871f09e9639456d3fbe4b89a21c9ad75c774e94cbbbe67f842b0a500
sha512=a11ea4b8e3520b3ee41ae8198cda34b2816b8dfcdcb99350ef29689a7d62bb66d17ffa075c551aa56d521120b55e6db14a106a31f7b3970ed2aa07e1db3c9b88

doc/merlin-lib.analysis/Merlin_analysis/Destruct/index.html

Module Merlin_analysis.DestructSource

Destruct at the moment works in two contexts:

  • an expression context: It will replace the expression e under the cursor with
  match e with
  | p1 -> _
  | ...

This matching will be exhaustive.

If e has a "package" type, it will be replaced by let module M = (val e) in _

  • a pattern context: Here two different behaviors can be observed:
  1. if your matching is not exhaustive, it will be made exhaustive.
  2. if your matching is exhaustive, it will refine the subpattern under the cursor if possible (i.e. if your cursor is on a variable or _ ).

* * *

Final remarks:

  • Destruct will refuse to work on expression (resp. patterns) with a functional or polymorphic type.
  • Constructors of variant types will be prefixed by their path (if necessary) but record labels will not. The reason is that we don't control the way things are printed, we reuse Pprintast which will print things like: { Module.label1 = label1 ; Module.label2 = label2} where one would rather have { Module.label1 ; label2 }. Since qualifying one label is less annoying than rewriting the whole pattern, we decided to note qualify labels (understanding that the code inserted by merlin in the buffer will sometimes be wrong).
Sourceexception Not_allowed of string
Sourceexception Useless_refine
Sourceexception Nothing_to_do
Sourceexception Ill_typed
Sourceexception Wrong_parent of string

node ~env parents current_node returns a location indicating which portion of the buffer must be replaced and the string to replace it with.

OCaml

Innovation. Community. Security.