ocaml-containers/dev/containers/CCSexp/index.html
2021-02-03 04:26:55 +00:00

2 lines
No EOL
16 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>CCSexp (containers.CCSexp)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.2"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> <a href="../index.html">containers</a> &#x00BB; CCSexp</nav><h1>Module <code>CCSexp</code></h1><h2 id="handling-s-expressions"><a href="#handling-s-expressions" class="anchor"></a>Handling S-expressions</h2><dl><dt>since</dt><dd>3.0 moved into containers-core, previously in [containers.sexp]</dd></dl><nav class="toc"><ul><li><a href="#basics">Basics</a></li></ul></nav></header><dl><dt class="spec type" id="type-or_error"><a href="#type-or_error" class="anchor"></a><code><span class="keyword">type</span> <span>'a or_error</span></code><code> = <span><span>(<span class="type-var">'a</span>, string)</span> Stdlib.result</span></code></dt><dt class="spec type" id="type-gen"><a href="#type-gen" class="anchor"></a><code><span class="keyword">type</span> <span>'a gen</span></code><code> = unit <span>&#45;&gt;</span> <span><span class="type-var">'a</span> option</span></code></dt></dl><dl><dt class="spec module-type" id="module-type-SEXP"><a href="#module-type-SEXP" class="anchor"></a><code><span class="keyword">module</span> <span class="keyword">type</span> <a href="module-type-SEXP/index.html">SEXP</a> = <a href="../CCSexp_intf/index.html#module-type-SEXP">CCSexp_intf.SEXP</a></code></dt><dd></dd></dl><dl><dt class="spec module-type" id="module-type-S"><a href="#module-type-S" class="anchor"></a><code><span class="keyword">module</span> <span class="keyword">type</span> <a href="module-type-S/index.html">S</a> = <a href="../CCSexp_intf/index.html#module-type-S">CCSexp_intf.S</a></code></dt><dd></dd></dl><dl><dt class="spec module" id="module-Make"><a href="#module-Make" class="anchor"></a><code><span class="keyword">module</span> <a href="Make/index.html">Make</a> : <span class="keyword">functor</span> (<a href="Make/argument-1-Sexp/index.html">Sexp</a> : <a href="index.html#module-type-SEXP">SEXP</a>) <span>&#45;&gt;</span> <a href="index.html#module-type-S">S</a> <span class="keyword">with</span> <span class="keyword">type</span> <a href="Make/index.html#type-t">t</a> = <a href="Make/argument-1-Sexp/index.html#type-t">Sexp.t</a></code></dt><dd></dd></dl><section><header><h3 id="basics"><a href="#basics" class="anchor"></a>Basics</h3></header><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> t</code> = <code>[ </code><table class="variant"><tr id="type-t.Atom" class="anchored"><td class="def constructor"><a href="#type-t.Atom" class="anchor"></a><code>| </code><code>`Atom <span class="keyword">of</span> string</code></td></tr><tr id="type-t.List" class="anchored"><td class="def constructor"><a href="#type-t.List" class="anchor"></a><code>| </code><code>`List <span class="keyword">of</span> <span><a href="index.html#type-t">t</a> list</span></code></td></tr></table><code> ]</code></dt><dd><p>A simple, structural representation of S-expressions.</p></dd></dl><div><div class="spec include"><div class="doc"><details open="open"><summary><span class="def"><code><span class="keyword">include</span> <a href="index.html#module-type-S">S</a> <span class="keyword">with</span> <span class="keyword">type</span> <a href="index.html#module-type-S">S</a>.t := <a href="index.html#type-t">t</a></code></span></summary><div><div class="spec include"><div class="doc"><details open="open"><summary><span class="def"><code><span class="keyword">include</span> <a href="../CCSexp_intf/index.html#module-type-S0">CCSexp_intf.S0</a></code></span></summary><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> t</code></dt><dt class="spec type" id="type-sexp"><a href="#type-sexp" class="anchor"></a><code><span class="keyword">type</span> sexp</code><code> = <a href="index.html#type-t">t</a></code></dt></dl><section><header><h3 id="re-exports"><a href="#re-exports" class="anchor"></a>Re-exports</h3></header><dl><dt class="spec value" id="val-atom"><a href="#val-atom" class="anchor"></a><code><span class="keyword">val</span> atom : string <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Make an atom out of this string.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-list"><a href="#val-list" class="anchor"></a><code><span class="keyword">val</span> list : <span><a href="index.html#type-t">t</a> list</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Make a Sexpr of this list.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl></section><section><header><h3 id="constructors"><a href="#constructors" class="anchor"></a>Constructors</h3></header><dl><dt class="spec value" id="val-of_int"><a href="#val-of_int" class="anchor"></a><code><span class="keyword">val</span> of_int : int <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_bool"><a href="#val-of_bool" class="anchor"></a><code><span class="keyword">val</span> of_bool : bool <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_list"><a href="#val-of_list" class="anchor"></a><code><span class="keyword">val</span> of_list : <span><a href="index.html#type-t">t</a> list</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_rev_list"><a href="#val-of_rev_list" class="anchor"></a><code><span class="keyword">val</span> of_rev_list : <span><a href="index.html#type-t">t</a> list</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Reverse the list.</p></dd></dl><dl><dt class="spec value" id="val-of_float"><a href="#val-of_float" class="anchor"></a><code><span class="keyword">val</span> of_float : float <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_unit"><a href="#val-of_unit" class="anchor"></a><code><span class="keyword">val</span> of_unit : <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_pair"><a href="#val-of_pair" class="anchor"></a><code><span class="keyword">val</span> of_pair : <span>(<a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a>)</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_triple"><a href="#val-of_triple" class="anchor"></a><code><span class="keyword">val</span> of_triple : <span>(<a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a>)</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_quad"><a href="#val-of_quad" class="anchor"></a><code><span class="keyword">val</span> of_quad : <span>(<a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a>)</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_variant"><a href="#val-of_variant" class="anchor"></a><code><span class="keyword">val</span> of_variant : string <span>&#45;&gt;</span> <span><a href="index.html#type-t">t</a> list</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p><code>of_variant name args</code> is used to encode algebraic variants into a S-expr. For instance <code>of_variant &quot;some&quot; [of_int 1]</code> represents the value <code>Some 1</code>.</p></dd></dl><dl><dt class="spec value" id="val-of_field"><a href="#val-of_field" class="anchor"></a><code><span class="keyword">val</span> of_field : string <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Used to represent one record field.</p></dd></dl><dl><dt class="spec value" id="val-of_record"><a href="#val-of_record" class="anchor"></a><code><span class="keyword">val</span> of_record : <span><span>(string * <a href="index.html#type-t">t</a>)</span> list</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Represent a record by its named fields.</p></dd></dl></section><section><header><h3 id="printing"><a href="#printing" class="anchor"></a>Printing</h3></header><dl><dt class="spec value" id="val-to_buf"><a href="#val-to_buf" class="anchor"></a><code><span class="keyword">val</span> to_buf : Stdlib.Buffer.t <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> unit</code></dt><dt class="spec value" id="val-to_string"><a href="#val-to_string" class="anchor"></a><code><span class="keyword">val</span> to_string : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> string</code></dt><dt class="spec value" id="val-to_file"><a href="#val-to_file" class="anchor"></a><code><span class="keyword">val</span> to_file : string <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> unit</code></dt><dt class="spec value" id="val-to_file_iter"><a href="#val-to_file_iter" class="anchor"></a><code><span class="keyword">val</span> to_file_iter : string <span>&#45;&gt;</span> <span><a href="index.html#type-t">t</a> <a href="../CCSexp_intf/index.html#type-iter">CCSexp_intf.iter</a></span> <span>&#45;&gt;</span> unit</code></dt><dd><p>Print the given iter of expressions to a file.</p></dd></dl><dl><dt class="spec value" id="val-to_chan"><a href="#val-to_chan" class="anchor"></a><code><span class="keyword">val</span> to_chan : Stdlib.out_channel <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> unit</code></dt><dt class="spec value" id="val-pp"><a href="#val-pp" class="anchor"></a><code><span class="keyword">val</span> pp : Stdlib.Format.formatter <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> unit</code></dt><dd><p>Pretty-printer nice on human eyes (including indentation).</p></dd></dl><dl><dt class="spec value" id="val-pp_noindent"><a href="#val-pp_noindent" class="anchor"></a><code><span class="keyword">val</span> pp_noindent : Stdlib.Format.formatter <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> unit</code></dt><dd><p>Raw, direct printing as compact as possible.</p></dd></dl></section><section><header><h3 id="parsing"><a href="#parsing" class="anchor"></a>Parsing</h3></header><dl><dt class="spec value" id="val-parse_string"><a href="#val-parse_string" class="anchor"></a><code><span class="keyword">val</span> parse_string : string <span>&#45;&gt;</span> <span><a href="index.html#type-t">t</a> <a href="../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span></code></dt><dd><p>Parse a string.</p></dd></dl><dl><dt class="spec value" id="val-parse_string_list"><a href="#val-parse_string_list" class="anchor"></a><code><span class="keyword">val</span> parse_string_list : string <span>&#45;&gt;</span> <span><span><a href="index.html#type-t">t</a> list</span> <a href="../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span></code></dt><dd><p>Parse a string into a list of S-exprs.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-parse_chan"><a href="#val-parse_chan" class="anchor"></a><code><span class="keyword">val</span> parse_chan : Stdlib.in_channel <span>&#45;&gt;</span> <span><a href="index.html#type-t">t</a> <a href="../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span></code></dt><dd><p>Parse a S-expression from the given channel. Can read more data than necessary, so don't use this if you need finer-grained control (e.g. to read something else <b>after</b> the S-exp).</p></dd></dl><dl><dt class="spec value" id="val-parse_chan_gen"><a href="#val-parse_chan_gen" class="anchor"></a><code><span class="keyword">val</span> parse_chan_gen : Stdlib.in_channel <span>&#45;&gt;</span> <span><span><a href="index.html#type-t">t</a> <a href="../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span> <a href="../CCSexp_intf/index.html#type-gen">CCSexp_intf.gen</a></span></code></dt><dd><p>Parse a channel into a generator of S-expressions.</p></dd></dl><dl><dt class="spec value" id="val-parse_chan_list"><a href="#val-parse_chan_list" class="anchor"></a><code><span class="keyword">val</span> parse_chan_list : Stdlib.in_channel <span>&#45;&gt;</span> <span><span><a href="index.html#type-t">t</a> list</span> <a href="../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span></code></dt><dt class="spec value" id="val-parse_file"><a href="#val-parse_file" class="anchor"></a><code><span class="keyword">val</span> parse_file : string <span>&#45;&gt;</span> <span><a href="index.html#type-t">t</a> <a href="../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span></code></dt><dd><p>Open the file and read a S-exp from it.</p></dd></dl><dl><dt class="spec value" id="val-parse_file_list"><a href="#val-parse_file_list" class="anchor"></a><code><span class="keyword">val</span> parse_file_list : string <span>&#45;&gt;</span> <span><span><a href="index.html#type-t">t</a> list</span> <a href="../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span></code></dt><dd><p>Open the file and read a S-exp from it.</p></dd></dl></section></details></div></div></div><section><header><h3 id="parsing"><a href="#parsing" class="anchor"></a>Parsing</h3></header><dl><dt class="spec type" id="type-parse_result"><a href="#type-parse_result" class="anchor"></a><code><span class="keyword">type</span> <span>'a parse_result</span></code><code> = </code><table class="variant"><tr id="type-parse_result.Yield" class="anchored"><td class="def constructor"><a href="#type-parse_result.Yield" class="anchor"></a><code>| </code><code><span class="constructor">Yield</span> <span class="keyword">of</span> <span class="type-var">'a</span></code></td></tr><tr id="type-parse_result.Fail" class="anchored"><td class="def constructor"><a href="#type-parse_result.Fail" class="anchor"></a><code>| </code><code><span class="constructor">Fail</span> <span class="keyword">of</span> string</code></td></tr><tr id="type-parse_result.End" class="anchored"><td class="def constructor"><a href="#type-parse_result.End" class="anchor"></a><code>| </code><code><span class="constructor">End</span></code></td></tr></table></dt><dd><p>A parser of <code>'a</code> can return <code>Yield x</code> when it parsed a value, or <code>Fail e</code> when a parse error was encountered, or <code>End</code> if the input was empty.</p></dd></dl><div class="spec module" id="module-Decoder"><a href="#module-Decoder" class="anchor"></a><code><span class="keyword">module</span> <a href="Decoder/index.html">Decoder</a> : <span class="keyword">sig</span> ... <span class="keyword">end</span></code></div></section></details></div></div></div><dl><dt class="spec value" id="val-equal"><a href="#val-equal" class="anchor"></a><code><span class="keyword">val</span> equal : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><dl><dt>since</dt><dd>3.0</dd></dl></dd></dl><dl><dt class="spec value" id="val-compare"><a href="#val-compare" class="anchor"></a><code><span class="keyword">val</span> compare : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> int</code></dt><dd><dl><dt>since</dt><dd>3.0</dd></dl></dd></dl><dl><dt class="spec value" id="val-atom"><a href="#val-atom" class="anchor"></a><code><span class="keyword">val</span> atom : string <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Build an atom directly from a string.</p></dd></dl></section></div></body></html>