413 lines
13 KiB
HTML
413 lines
13 KiB
HTML
<!DOCTYPE html>
|
|
|
|
<html lang="en" data-content_root="../">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
|
|
<title>Template Instantiator State Transition Rules — rl' documentation</title>
|
|
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=4f649999" />
|
|
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css?v=039e1c02" />
|
|
<script src="../_static/documentation_options.js?v=5929fcd5"></script>
|
|
<script src="../_static/doctools.js?v=888ff710"></script>
|
|
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
|
|
<link rel="index" title="Index" href="../genindex.html" />
|
|
<link rel="search" title="Search" href="../search.html" />
|
|
<link rel="prev" title="G-Machine State Transition Rules" href="gm-state-transitions.html" />
|
|
|
|
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
|
|
|
|
</head><body>
|
|
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
|
|
|
|
<div class="body" role="main">
|
|
|
|
<section id="template-instantiator-state-transition-rules">
|
|
<h1>Template Instantiator State Transition Rules<a class="headerlink" href="#template-instantiator-state-transition-rules" title="Link to this heading">¶</a></h1>
|
|
<p>Evaluation is complete when a single <code class="code docutils literal notranslate"><span class="pre">NNum</span></code> remains on the stack and the
|
|
dump is empty.</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/96cf11c4b33f0179fcb72d62060f25fc6fa8b550.svg" alt="\transrule
|
|
{ a : \nillist
|
|
& \nillist
|
|
& h
|
|
\begin{bmatrix}
|
|
a : \mathtt{NNum} \; n
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ \mathtt{HALT}
|
|
}"/></p>
|
|
</div><p>Dereference an indirection passed as an argument to a function.</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/ecdbb83ab452d27fcd79c1567929508177d87f1f.svg" alt="\transrule
|
|
{a : s & d & h
|
|
\begin{bmatrix}
|
|
a : \mathtt{NAp} \; a_1 \; a_2 \\
|
|
a_2 : \mathtt{NInd} \; a_3
|
|
\end{bmatrix} & g}
|
|
{a : s & d & h[a : \mathtt{NAp} \; a_1 \; a_3] & g}"/></p>
|
|
</div><p>Dereference an indirection on top of the stack.</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/f51999c7c2b53f5ff66f0d4f339a64b99dccbbc0.svg" alt="\transrule
|
|
{p : s & d & h
|
|
\begin{bmatrix}
|
|
p : \mathtt{NInd} \; a
|
|
\end{bmatrix} & g}
|
|
{a : s & d & h & g}"/></p>
|
|
</div><p>Perform a unary operation <img class="math" src="../_images/math/11e676863b0ccfe854bc89167c23a5bd514bf5f9.svg" alt="o(n)" style="vertical-align: -5px"/> with internal <code class="code docutils literal notranslate"><span class="pre">Prim</span></code> constructor
|
|
<code class="code docutils literal notranslate"><span class="pre">O</span></code> on an argument in normal form.</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/c2ff2f8e287ecf001479d047291f611c49ae7bde.svg" alt="\transrule
|
|
{ f : a : s
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
f : \mathtt{NPrim} \; \mathtt{O} \\
|
|
a : \mathtt{NAp} \; f \; x \\
|
|
x : \mathtt{NNum} \; n
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ a : s
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
a : \mathtt{NNum} \; (o(n))
|
|
\end{bmatrix}
|
|
& g
|
|
}"/></p>
|
|
</div><p>Evaluate the argument of a unary operation with internal <code class="code docutils literal notranslate"><span class="pre">Prim</span></code>
|
|
constructor <code class="code docutils literal notranslate"><span class="pre">O</span></code>.</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/226b15d1faaf510988b3ca3cb75ddd6c120c53ea.svg" alt="\transrule
|
|
{ f : a : \nillist
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
f : \mathtt{NPrim} \; \mathtt{O} \\
|
|
a : \mathtt{NAp} \; f \; x
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ x : \nillist
|
|
& (f : a : \nillist) : d
|
|
& h
|
|
& g
|
|
}"/></p>
|
|
</div><p>Restore the stack when a sub-computation has completed.</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/1c0e1003d2e9980d635c8e79475e53226b5e7264.svg" alt="\transrule
|
|
{ a : \nillist
|
|
& s : d
|
|
& h
|
|
\begin{bmatrix}
|
|
a : \mathtt{NNum} \; n
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ s
|
|
& d
|
|
& h
|
|
& g
|
|
}"/></p>
|
|
</div><p>Reduce a supercombinator and update the root with the <img class="math" src="../_images/math/4e04b3f70eef23aff9592405c5b32293f5f8f3d0.svg" alt="\beta" style="vertical-align: -4px"/>-reduced form</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/80185f417c32abbbd850f4429d27d4111dd55ce6.svg" alt="\transrule
|
|
{ a_0 : a_1 : \ldots : a_n : s
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
a_0 : \mathtt{NSupercomb} \; [x_1,\ldots,x_n] \; e
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ a_n : s
|
|
& d
|
|
& h'
|
|
& g
|
|
\\
|
|
& \SetCell[c=3]{c}
|
|
\text{where } h' = \mathtt{instantiateU} \; e \; a_n \; h \; g
|
|
}"/></p>
|
|
</div><p>Perform a binary operation <img class="math" src="../_images/math/70ba514f09b40f948e1a3673347f656c7dc33f27.svg" alt="o(x,y)" style="vertical-align: -5px"/> associated with internal <code class="code docutils literal notranslate"><span class="pre">Prim</span></code>
|
|
constructor <code class="code docutils literal notranslate"><span class="pre">O</span></code> on two <code class="code docutils literal notranslate"><span class="pre">NNum</span></code> s both in normal form.</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/703648dab56048f07869054b5257b846f55a4dec.svg" alt="\transrule
|
|
{ f : a_1 : a_2 : s
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
f : \mathtt{NPrim} \; \mathtt{O} \\
|
|
a_1 : \mathtt{NAp} \; f \; (\mathtt{NNum} \; x) \\
|
|
a_2 : \mathtt{NAp} \; a_1 \; (\mathtt{NNum} \; y)
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ a_2 : s
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
a_2 : \mathtt{NNum} \; (o(x,y))
|
|
\end{bmatrix}
|
|
& g
|
|
}"/></p>
|
|
</div><p>In a conditional primitive, perform the reduction if the condition has been
|
|
evaluated as True (<code class="code docutils literal notranslate"><span class="pre">NData</span> <span class="pre">1</span> <span class="pre">[]</span></code>).</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/d9911cffb6ee41316d3f017754491dab76c920a9.svg" alt="\transrule
|
|
{ f : a_1 : a_2 : a_3 : s
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
f : \mathtt{NPrim} \; \mathtt{IfP} \\
|
|
c : \mathtt{NPrim} \; (\mathtt{NData} \; 1 \; \nillist) \\
|
|
a_1 : \mathtt{NAp} \; f \; c \\
|
|
a_2 : \mathtt{NAp} \; a_1 \; x \\
|
|
a_3 : \mathtt{NAp} \; a_2 \; y
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ x : s
|
|
& d
|
|
& h
|
|
& g
|
|
}"/></p>
|
|
</div><p>In a conditional primitive, perform the reduction if the condition has been
|
|
evaluated as False (<code class="code docutils literal notranslate"><span class="pre">NData</span> <span class="pre">0</span> <span class="pre">[]</span></code>).</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/11e48d7396763a8f0e16cba061b46966844e3191.svg" alt="\transrule
|
|
{ f : a_1 : a_2 : a_3 : s
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
f : \mathtt{NPrim} \; \mathtt{IfP} \\
|
|
c : \mathtt{NPrim} \; (\mathtt{NData} \; 0 \; \nillist) \\
|
|
a_1 : \mathtt{NAp} \; f \; c \\
|
|
a_2 : \mathtt{NAp} \; a_1 \; x \\
|
|
a_3 : \mathtt{NAp} \; a_2 \; y
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ y : s
|
|
& d
|
|
& h
|
|
& g
|
|
}"/></p>
|
|
</div><p>In a conditional primitive, evaluate the condition.</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/4480a4e8409efd17a2bb57789e584bba66af268c.svg" alt="\transrule
|
|
{ f : a_1 : \nillist
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
f : \mathtt{NPrim} \; \mathtt{IfP} \\
|
|
a_1 : \mathtt{NAp} \; f \; x
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ x : \nillist
|
|
& (f : a_1 : \nillist) : d
|
|
& h
|
|
& g
|
|
}"/></p>
|
|
</div><p>Construct <code class="code docutils literal notranslate"><span class="pre">NData</span></code> out of a constructor and its arguments</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/8d27e16980b44cbe4694fb91353c71239780608d.svg" alt="\transrule
|
|
{ c : a_1 : \ldots : a_n : \nillist
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
c : \mathtt{NPrim} \; (\mathtt{ConP} \; t \; n) \\
|
|
a_1 : \mathtt{NAp} \; c \; x_1 \\
|
|
\vdots \\
|
|
a_n : \mathtt{NAp} \; a_{n-1} \; x_n
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ a_n : \nillist
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
a_n : \mathtt{NData} \; t \; [x_1, \ldots, x_n]
|
|
\end{bmatrix}
|
|
& g
|
|
}"/></p>
|
|
</div><section id="pairs">
|
|
<h2>Pairs<a class="headerlink" href="#pairs" title="Link to this heading">¶</a></h2>
|
|
<p>Evaluate the first argument if necessary</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/292cba3e41608acd2957a5e9aa29ab8f2cbc346d.svg" alt="\transrule
|
|
{ c : a_1 : a_2 : \nillist
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
c : \mathtt{NPrim} \; \mathtt{CasePairP} \\
|
|
p : \mathtt{NAp} \; \_ \: \_ \\
|
|
a_1 : \mathtt{NAp} \; c \; p \\
|
|
a_2 : \mathtt{NAp} \; a_2 \; f
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ p : \nillist
|
|
& (a_1 : a_2 : \nillist) : d
|
|
& h
|
|
& g
|
|
}"/></p>
|
|
</div><p>Perform the reduction if the first argument is in normal form</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/34c5ba211557474d30a91f5ea6cf5692b3b88610.svg" alt="\transrule
|
|
{ c : a_1 : a_2 : s
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
c : \mathtt{NPrim} \; \mathtt{CasePairP} \\
|
|
p : \mathtt{NData} \; 0 \; [x,y] \\
|
|
a_1 : \mathtt{NAp} \; c \; p \\
|
|
a_2 : \mathtt{NAp} \; a_1 \; f
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ a_1 : a_2 : s
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
a_1 : \mathtt{NAp} \; f \; x \\
|
|
a_2 : \mathtt{NAp} \; a_1 \; y
|
|
\end{bmatrix}
|
|
& g
|
|
}"/></p>
|
|
</div></section>
|
|
<section id="lists">
|
|
<h2>Lists<a class="headerlink" href="#lists" title="Link to this heading">¶</a></h2>
|
|
<p>Evaluate the scrutinee</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/f653751fa1b1ef5e1eb9a12fbb4df556a501606f.svg" alt="\transrule
|
|
{ c : a_1 : a_2 : a_3 : \nillist
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
c : \mathtt{NPrim} \; \mathtt{CaseListP} \\
|
|
a_1 : \mathtt{NAp} \; c \; x
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ x
|
|
& (a_1 : a_2 : a_3) : \nillist
|
|
& h
|
|
& g
|
|
}"/></p>
|
|
</div><p>If the scrutinee is <code class="code docutils literal notranslate"><span class="pre">Nil</span></code>, perform the appropriate reduction.</p>
|
|
<div class="math">
|
|
<p><img src="../_images/math/fd3674c541392d348d835034f858018e7a614a41.svg" alt="\transrule
|
|
{ c : a_1 : a_2 : a_3 : s
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
c : \mathtt{NPrim} \; \mathtt{CaseListP} \\
|
|
p : \mathtt{NData} \; 1 \; \nillist \\
|
|
a_1 : \mathtt{NAp} \; c \; p \\
|
|
a_2 : \mathtt{NAp} \; p \; f_\text{nil} \\
|
|
a_3 : \mathtt{NAp} \; a_2 \; f_\text{cons}
|
|
\end{bmatrix}
|
|
& g
|
|
}
|
|
{ a_3 : s
|
|
& d
|
|
& h
|
|
\begin{bmatrix}
|
|
a_3 : \mathtt{NAp} \; f_\text{nil}
|
|
\end{bmatrix}
|
|
& g
|
|
}"/></p>
|
|
</div></section>
|
|
</section>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
|
<div class="sphinxsidebarwrapper">
|
|
<h1 class="logo"><a href="../index.html">rl'</a></h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3>Navigation</h3>
|
|
<p class="caption" role="heading"><span class="caption-text">Index</span></p>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
|
|
</ul>
|
|
<p class="caption" role="heading"><span class="caption-text">Commentary</span></p>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../commentary/gm.html">The <em>G-Machine</em></a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="../commentary/layout-lexing.html">Lexing, Parsing, and Layouts</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="../commentary/ti.html">The <em>Template Instantiator</em></a></li>
|
|
</ul>
|
|
<p class="caption" role="heading"><span class="caption-text">References</span></p>
|
|
<ul class="current">
|
|
<li class="toctree-l1"><a class="reference internal" href="gm-state-transitions.html">G-Machine State Transition Rules</a></li>
|
|
<li class="toctree-l1 current"><a class="current reference internal" href="#">Template Instantiator State Transition Rules</a></li>
|
|
</ul>
|
|
|
|
<div class="relations">
|
|
<h3>Related Topics</h3>
|
|
<ul>
|
|
<li><a href="../index.html">Documentation overview</a><ul>
|
|
<li>Previous: <a href="gm-state-transitions.html" title="previous chapter">G-Machine State Transition Rules</a></li>
|
|
</ul></li>
|
|
</ul>
|
|
</div>
|
|
<div id="searchbox" style="display: none" role="search">
|
|
<h3 id="searchlabel">Quick search</h3>
|
|
<div class="searchformwrapper">
|
|
<form class="search" action="../search.html" method="get">
|
|
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
|
<input type="submit" value="Go" />
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<script>document.getElementById('searchbox').style.display = "block"</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="footer">
|
|
©2023, madeleine sydney ślaga.
|
|
|
|
|
|
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 7.2.6</a>
|
|
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.13</a>
|
|
|
|
|
|
|
<a href="../_sources/references/ti-state-transitions.rst.txt"
|
|
rel="nofollow">Page source</a>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
</html> |