mirror of
https://github.com/c-cube/linol.git
synced 2025-12-09 04:35:37 -05:00
14 lines
7.7 KiB
HTML
14 lines
7.7 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Infix (lwt.Lwt.Infix)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.2"/><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">lwt</a> » <a href="../index.html">Lwt</a> » Infix</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt.Infix</span></code></h1><p>This module provides several infix operators for making programming with Lwt more convenient.</p><p>To use it, open <code>Lwt.Infix</code>.</p><p>Of the operators declared in this module, only <code>>|=</code> is recommended for new code. The only other commonly-used operator is <code>>>=</code>.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-(>>=)"><a href="#val-(>>=)" class="anchor"></a><code><span><span class="keyword">val</span> (>>=) : <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>p >>= f</code> is the same as <a href="../index.html#val-bind"><code>Lwt.bind</code></a><code> p f</code>. It requires <code>Lwt.Infix</code> to be opened in scope:</p><pre class="language-ocaml"><code>open Lwt.Infix
|
||
|
||
let () =
|
||
Lwt_main.run
|
||
(Lwt_io.(read_line stdin) >>= Lwt_io.printl)
|
||
|
||
(* ocamlfind opt -linkpkg -thread -package lwt.unix code.ml && ./a.out *)</code></pre><p>It is recommended to use the PPX <code>let%lwt</code> syntax instead. This operator is the next-best choice. It is frequently found while reading existing Lwt code.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-(>|=)"><a href="#val-(>|=)" class="anchor"></a><code><span><span class="keyword">val</span> (>|=) : <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span class="type-var">'b</span>)</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>p >|= f</code> is the same as <a href="../index.html#val-map"><code>Lwt.map</code></a><code> f p</code>. It requires <code>Lwt.Infix</code> to be opened in scope.</p><pre class="language-ocaml"><code>open Lwt.Infix
|
||
|
||
let () =
|
||
Lwt_main.run
|
||
(Lwt_io.(read_line stdin) >|= ignore)
|
||
|
||
(* ocamlfind opt -linkpkg -thread -package lwt.unix code.ml && ./a.out *)</code></pre></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-(<&>)"><a href="#val-(<&>)" class="anchor"></a><code><span><span class="keyword">val</span> (<&>) : <span><span>unit <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span>unit <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span>unit <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>p1 <&> p2</code> is the same as <a href="../index.html#val-join"><code>Lwt.join</code></a><code> [p1; p2]</code>. It requires <code>Lwt.Infix</code> to be opened in scope.</p><p>Unlike with <a href="../index.html#val-bind"><code>Lwt.bind</code></a> and <a href="../index.html#val-map"><code>Lwt.map</code></a>, there are no problems with explicit <a href="../index.html#val-join"><code>Lwt.join</code></a> syntax, so using this operator is not recommended.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-(<?>)"><a href="#val-(<?>)" class="anchor"></a><code><span><span class="keyword">val</span> (<?>) : <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>p1 <?> p2</code> is the same as <a href="../index.html#val-choose"><code>Lwt.choose</code></a><code> [p1; p2]</code>. It requires <code>Lwt.Infix</code> to be opened in scope.</p><p>Unlike with <a href="../index.html#val-bind"><code>Lwt.bind</code></a> and <a href="../index.html#val-map"><code>Lwt.map</code></a>, there are no problems with explicit <a href="../index.html#val-choose"><code>Lwt.choose</code></a> syntax, so using this operator is not recommended.</p><p>Furthermore, most users actually need <a href="../index.html#val-pick"><code>Lwt.pick</code></a> instead of <a href="../index.html#val-choose"><code>Lwt.choose</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-(=<<)"><a href="#val-(=<<)" class="anchor"></a><code><span><span class="keyword">val</span> (=<<) : <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span>)</span> <span class="arrow">-></span></span> <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>f =<< p</code> is the same as <a href="../index.html#val-bind"><code>Lwt.bind</code></a><code> p f</code>. It requires <code>Lwt.Infix</code> to be opened in scope.</p><p>This operator is obscure and its use is discouraged. It is the same as <code>p >>= f</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-(=|<)"><a href="#val-(=|<)" class="anchor"></a><code><span><span class="keyword">val</span> (=|<) : <span><span>(<span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span class="type-var">'b</span>)</span> <span class="arrow">-></span></span> <span><span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>f =|< p</code> is the same as <a href="../index.html#val-map"><code>Lwt.map</code></a><code> f p</code>. It requires <code>Lwt.Infix</code> to be opened in scope.</p><p>This operator is obscure and its use is discouraged. It is the same as <code>p >|= f</code>.</p></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Let_syntax"><a href="#module-Let_syntax" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Let_syntax/index.html">Let_syntax</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>This module provides support for <a href="https://github.com/janestreet/ppx_let">ppx_let</a>.</p></div></div></div></body></html>
|