moonpool/dev/ocaml/Longident/index.html

3 lines
No EOL
4.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Longident (ocaml.Longident)</title><link rel="stylesheet" href="../../_odoc-theme/odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.2.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../index.html">ocaml</a> &#x00BB; Longident</nav><header class="odoc-preamble"><h1>Module <code><span>Longident</span></code></h1><p>Long identifiers, used in parsetree.</p><p><b>Warning:</b> this module is unstable and part of <span class="xref-unresolved">compiler-libs</span>.</p><p>To print a longident, see <a href="../Pprintast/index.html#val-longident"><code>Pprintast.longident</code></a>, using <code>Format</code>.asprintf to convert to a string.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span><span> = </span></code><ol><li id="type-t.Lident" class="def variant constructor anchored"><a href="#type-t.Lident" class="anchor"></a><code><span>| </span><span><span class="constructor">Lident</span> <span class="keyword">of</span> string</span></code></li><li id="type-t.Ldot" class="def variant constructor anchored"><a href="#type-t.Ldot" class="anchor"></a><code><span>| </span><span><span class="constructor">Ldot</span> <span class="keyword">of</span> <a href="#type-t">t</a> * string</span></code></li><li id="type-t.Lapply" class="def variant constructor anchored"><a href="#type-t.Lapply" class="anchor"></a><code><span>| </span><span><span class="constructor">Lapply</span> <span class="keyword">of</span> <a href="#type-t">t</a> * <a href="#type-t">t</a></span></code></li></ol></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-flatten"><a href="#val-flatten" class="anchor"></a><code><span><span class="keyword">val</span> flatten : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>string list</span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-unflatten"><a href="#val-unflatten" class="anchor"></a><code><span><span class="keyword">val</span> unflatten : <span><span>string list</span> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> option</span></span></code></div><div class="spec-doc"><p>For a non-empty list <code>l</code>, <code>unflatten l</code> is <code>Some lid</code> where <code>lid</code> is the long identifier created by concatenating the elements of <code>l</code> with <code>Ldot</code>. <code>unflatten []</code> is <code>None</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-last"><a href="#val-last" class="anchor"></a><code><span><span class="keyword">val</span> last : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> string</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-parse"><a href="#val-parse" class="anchor"></a><code><span><span class="keyword">val</span> parse : <span>string <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>This function is broken on identifiers that are not just &quot;Word.Word.word&quot;; for example, it returns incorrect results on infix operators and extended module paths.</p><p>If you want to generate long identifiers that are a list of dot-separated identifiers, the function <a href="#val-unflatten"><code>unflatten</code></a> is safer and faster. <a href="#val-unflatten"><code>unflatten</code></a> is available since OCaml 4.06.0.</p><p>If you want to parse any identifier correctly, use the long-identifiers functions from the <a href="../Parse/index.html"><code>Parse</code></a> module, in particular <a href="../Parse/index.html#val-longident"><code>Parse.longident</code></a>. They are available since OCaml 4.11, and also provide proper input-location support.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> this function may misparse its input,
use &quot;Parse.longident&quot; or &quot;Longident.unflatten&quot;</li></ul></div></div></div></body></html>