<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.26">
<title>MLtonCont</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<link rel="stylesheet" href="./asciidoctor.css">
<link rel="stylesheet" href="./mlton.css">

</head>
<body class="article">
<div id="mlton-header">
<div id="mlton-header-text">
<h2>
<a href="./Home">
MLton
20241230+git20251029+dfsg-5
</a>
</h2>
</div>
</div>
<div id="header">
<h1>MLtonCont</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="sml">signature MLTON_CONT =
   sig
      type 'a t

      val callcc: ('a t -&gt; 'a) -&gt; 'a
      val isolate: ('a -&gt; unit) -&gt; 'a t
      val prepend: 'a t * ('b -&gt; 'a) -&gt; 'b t
      val throw: 'a t * 'a -&gt; 'b
      val throw': 'a t * (unit -&gt; 'a) -&gt; 'b
   end</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p><code>type 'a t</code></p>
<div class="paragraph">
<p>the type of continuations that expect a value of type <code>'a</code>.</p>
</div>
</li>
<li>
<p><code>callcc f</code></p>
<div class="paragraph">
<p>applies <code>f</code> to the current continuation.  This copies the entire
stack; hence, <code>callcc</code> takes time proportional to the size of the
current stack.</p>
</div>
</li>
<li>
<p><code>isolate f</code></p>
<div class="paragraph">
<p>creates a continuation that evaluates <code>f</code> in an empty context.  This
is a constant time operation, and yields a constant size stack.</p>
</div>
</li>
<li>
<p><code>prepend (k, f)</code></p>
<div class="paragraph">
<p>composes a function <code>f</code> with a continuation <code>k</code> to create a
continuation that first does <code>f</code> and then does <code>k</code>.  This is a
constant time operation.</p>
</div>
</li>
<li>
<p><code>throw (k, v)</code></p>
<div class="paragraph">
<p>throws value <code>v</code> to continuation <code>k</code>.  This copies the entire stack of
<code>k</code>; hence, <code>throw</code> takes time proportional to the size of this stack.</p>
</div>
</li>
<li>
<p><code>throw' (k, th)</code></p>
<div class="paragraph">
<p>a generalization of throw that evaluates <code>th ()</code> in the context of
<code>k</code>.  Thus, for example, if <code>th ()</code> raises an exception or captures
another continuation, it will see <code>k</code>, not the current continuation.</p>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_also_see">Also see</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="MLtonContIsolateImplementation">MLtonContIsolateImplementation</a></p>
</li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>