package merlin-lib

  1. Overview
  2. Docs
Merlin's libraries

Install

Dune Dependency

Authors

Maintainers

Sources

merlin-5.4.1-503.tbz
sha256=49b3b4c778c12125fc7405e73790b0b312d5d79749dd73d4838b6562a2533022
sha512=6350ff076ac61727c48bc098a05520c5d343f3323b2f3b6d7d69fdd568e51abca6945cbcbc3a6ae97fd198bd7bbdcae823fbd0f3f14a37972fe713da2ed14f2d

doc/merlin-lib.ocaml_parsing/Ocaml_parsing/Longident/index.html

Module Ocaml_parsing.LongidentSource

Long identifiers, used in parsetree.

Warning: this module is unstable and part of compiler-libs.

To print a longident, see Pprintast.longident, using Format.asprintf to convert to a string.

Sourcetype t =
  1. | Lident of string
  2. | Ldot of t * string
  3. | Lapply of t * t
Sourceval flatten : t -> string list
Sourceval unflatten : string list -> t option

For a non-empty list l, unflatten l is Some lid where lid is the long identifier created by concatenating the elements of l with Ldot. unflatten [] is None.

Sourceval head : t -> string

head lid returns the leftmost part of lid, e.g., given String.Map.empty, returns String.

Sourceval last : t -> string
Sourceval parse : string -> t

This function is broken on identifiers that are not just "Word.Word.word"; for example, it returns incorrect results on infix operators and extended module paths.

If you want to generate long identifiers that are a list of dot-separated identifiers, the function unflatten is safer and faster. unflatten is available since OCaml 4.06.0.

If you want to parse any identifier correctly, use the long-identifiers functions from the Parse module, in particular Parse.longident. They are available since OCaml 4.11, and also provide proper input-location support.

Sourceval keep_suffix : t -> t * bool

if li', b = keep_suffix li then:

  • the prefix of li' is a module path
  • b = false iff li' = li. Corollary: b = true if li is a label access (i.e. li = X.Y.z.Foo.Bar...)
OCaml

Innovation. Community. Security.