package ocamlformat-lib

  1. Overview
  2. Docs
OCaml Code Formatter

Install

Dune Dependency

Authors

Maintainers

Sources

ocamlformat-0.27.0.tbz
sha256=ddbf484c076d08f99400ee84b790ec231f5c8fcbd5d3324a6400d5388e846d15
sha512=4d2a8965a7b7ad45f8f4e76c01cf38bfa68462b07dfa7bdb2db23bd3e3017b214e6780f036679fa8595dde4167a01d957e3af8837274320449014e306773f917

doc/ocamlformat-lib.ocaml_common/Ocamlformat_ocaml_common/Longident/index.html

Module Ocamlformat_ocaml_common.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 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.

  • deprecated this function may misparse its input, use "Parse.longident" or "Longident.unflatten"
OCaml

Innovation. Community. Security.