moonpool/dev/ocaml/Stdlib/Effect/Deep/index.html
2023-08-29 18:39:53 +00:00

6 lines
No EOL
8.8 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>Deep (ocaml.Stdlib.Effect.Deep)</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; <a href="../../index.html">Stdlib</a> &#x00BB; <a href="../index.html">Effect</a> &#x00BB; Deep</nav><header class="odoc-preamble"><h1>Module <code><span>Effect.Deep</span></code></h1><p>Deep handlers</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-continuation"><a href="#type-continuation" class="anchor"></a><code><span><span class="keyword">type</span> <span>('a, 'b) continuation</span></span></code></div><div class="spec-doc"><p><code>('a,'b) continuation</code> is a delimited continuation that expects a <code>'a</code> value and returns a <code>'b</code> value.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-continue"><a href="#val-continue" class="anchor"></a><code><span><span class="keyword">val</span> continue : <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'b</span>)</span> <a href="#type-continuation">continuation</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'b</span></span></code></div><div class="spec-doc"><p><code>continue k x</code> resumes the continuation <code>k</code> by passing <code>x</code> to <code>k</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Continuation_already_resumed</span> <p>if the continuation has already been resumed.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-discontinue"><a href="#val-discontinue" class="anchor"></a><code><span><span class="keyword">val</span> discontinue : <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'b</span>)</span> <a href="#type-continuation">continuation</a></span> <span class="arrow">&#45;&gt;</span></span> <span>exn <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'b</span></span></code></div><div class="spec-doc"><p><code>discontinue k e</code> resumes the continuation <code>k</code> by raising the exception <code>e</code> in <code>k</code>.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Continuation_already_resumed</span> <p>if the continuation has already been resumed.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-discontinue_with_backtrace"><a href="#val-discontinue_with_backtrace" class="anchor"></a><code><span><span class="keyword">val</span> discontinue_with_backtrace :
<span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'b</span>)</span> <a href="#type-continuation">continuation</a></span> <span class="arrow">&#45;&gt;</span></span>
<span>exn <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../Printexc/index.html#type-raw_backtrace">Printexc.raw_backtrace</a> <span class="arrow">&#45;&gt;</span></span>
<span class="type-var">'b</span></span></code></div><div class="spec-doc"><p><code>discontinue_with_backtrace k e bt</code> resumes the continuation <code>k</code> by raising the exception <code>e</code> in <code>k</code> using <code>bt</code> as the origin for the exception.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Continuation_already_resumed</span> <p>if the continuation has already been resumed.</p></li></ul></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-handler"><a href="#type-handler" class="anchor"></a><code><span><span class="keyword">type</span> <span>('a, 'b) handler</span></span><span> = </span><span>{</span></code><ol><li id="type-handler.retc" class="def record field anchored"><a href="#type-handler.retc" class="anchor"></a><code><span>retc : <span><span class="type-var">'a</span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'b</span>;</span></code></li><li id="type-handler.exnc" class="def record field anchored"><a href="#type-handler.exnc" class="anchor"></a><code><span>exnc : <span>exn <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'b</span>;</span></code></li><li id="type-handler.effc" class="def record field anchored"><a href="#type-handler.effc" class="anchor"></a><code><span>effc : 'c. <span><span><span class="type-var">'c</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span>(<span><span><span>(<span class="type-var">'c</span>, <span class="type-var">'b</span>)</span> <a href="#type-continuation">continuation</a></span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'b</span>)</span> option</span>;</span></code></li></ol><code><span>}</span></code></div><div class="spec-doc"><p><code>('a,'b) handler</code> is a handler record with three fields -- <code>retc</code> is the value handler, <code>exnc</code> handles exceptions, and <code>effc</code> handles the effects performed by the computation enclosed by the handler.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-match_with"><a href="#val-match_with" class="anchor"></a><code><span><span class="keyword">val</span> match_with : <span><span>(<span><span class="type-var">'c</span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'c</span> <span class="arrow">&#45;&gt;</span></span> <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'b</span>)</span> <a href="#type-handler">handler</a></span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'b</span></span></code></div><div class="spec-doc"><p><code>match_with f v h</code> runs the computation <code>f v</code> in the handler <code>h</code>.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-effect_handler"><a href="#type-effect_handler" class="anchor"></a><code><span><span class="keyword">type</span> <span>'a effect_handler</span></span><span> = </span><span>{</span></code><ol><li id="type-effect_handler.effc" class="def record field anchored"><a href="#type-effect_handler.effc" class="anchor"></a><code><span>effc : 'b. <span><span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span>(<span><span><span>(<span class="type-var">'b</span>, <span class="type-var">'a</span>)</span> <a href="#type-continuation">continuation</a></span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> option</span>;</span></code></li></ol><code><span>}</span></code></div><div class="spec-doc"><p><code>'a effect_handler</code> is a deep handler with an identity value handler <code>fun x -&gt; x</code> and an exception handler that raises any exception <code>fun e -&gt; raise e</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-try_with"><a href="#val-try_with" class="anchor"></a><code><span><span class="keyword">val</span> try_with : <span><span>(<span><span class="type-var">'b</span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span> <span><span class="type-var">'b</span> <span class="arrow">&#45;&gt;</span></span> <span><span><span class="type-var">'a</span> <a href="#type-effect_handler">effect_handler</a></span> <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span></span></code></div><div class="spec-doc"><p><code>try_with f v h</code> runs the computation <code>f v</code> under the handler <code>h</code>.</p></div></div><div class="odoc-spec"><div class="spec value external anchored" id="val-get_callstack"><a href="#val-get_callstack" class="anchor"></a><code><span><span class="keyword">val</span> get_callstack : <span><span><span>(<span class="type-var">'a</span>, <span class="type-var">'b</span>)</span> <a href="#type-continuation">continuation</a></span> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <a href="../../Printexc/index.html#type-raw_backtrace">Printexc.raw_backtrace</a></span></code></div><div class="spec-doc"><p><code>get_callstack c n</code> returns a description of the top of the call stack on the continuation <code>c</code>, with at most <code>n</code> entries.</p></div></div></div></body></html>