Finally remove all mentions of the old polytypes module.
It was merged with types long ago.
This commit is contained in:
@@ -105,6 +105,16 @@
|
||||
<span class="p">)</span>
|
||||
|
||||
|
||||
<span class="n">HELP_TEMPLATE</span> <span class="o">=</span> <span class="s1">'''</span><span class="se">\</span>
|
||||
|
||||
<span class="s1">==== Help on </span><span class="si">%s</span><span class="s1"> ====</span>
|
||||
|
||||
<span class="si">%s</span><span class="s1"></span>
|
||||
|
||||
<span class="s1">---- end (</span><span class="si">%s</span><span class="s1">)</span>
|
||||
<span class="s1">'''</span>
|
||||
|
||||
|
||||
<span class="n">_SYM_NUMS</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">c</span><span class="o">=</span><span class="n">count</span><span class="p">():</span> <span class="nb">next</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>
|
||||
<span class="n">_COMB_NUMS</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">c</span><span class="o">=</span><span class="n">count</span><span class="p">():</span> <span class="nb">next</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>
|
||||
|
||||
@@ -923,7 +933,7 @@
|
||||
<span class="sd">'''Accepts a quoted symbol on the top of the stack and prints its docs.'''</span>
|
||||
<span class="p">((</span><span class="n">symbol</span><span class="p">,</span> <span class="n">_</span><span class="p">),</span> <span class="n">stack</span><span class="p">)</span> <span class="o">=</span> <span class="n">S</span>
|
||||
<span class="n">word</span> <span class="o">=</span> <span class="n">dictionary</span><span class="p">[</span><span class="n">symbol</span><span class="p">]</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">getdoc</span><span class="p">(</span><span class="n">word</span><span class="p">))</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">HELP_TEMPLATE</span> <span class="o">%</span> <span class="p">(</span><span class="n">symbol</span><span class="p">,</span> <span class="n">getdoc</span><span class="p">(</span><span class="n">word</span><span class="p">),</span> <span class="n">symbol</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="n">stack</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">dictionary</span></div>
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">joy.utils.polytypes</span> <span class="k">import</span> <span class="p">(</span>
|
||||
<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">joy.utils.types</span> <span class="k">import</span> <span class="p">(</span>
|
||||
<span class="n">doc_from_stack_effect</span><span class="p">,</span>
|
||||
<span class="n">infer</span><span class="p">,</span>
|
||||
<span class="n">reify</span><span class="p">,</span>
|
||||
|
||||
@@ -2243,9 +2243,9 @@ modification to the call structure of <code class="docutils literal notranslate"
|
||||
<h4>Work in Progress<a class="headerlink" href="#work-in-progress" title="Permalink to this headline">¶</a></h4>
|
||||
<p>And that brings us to current Work-In-Progress. The mixed-mode
|
||||
inferencer/interpreter <code class="docutils literal notranslate"><span class="pre">infer()</span></code> function seems to work well. There
|
||||
are details I should document, and the rest of the code in the
|
||||
“polytypes” module (FIXME link to its docs here!) should be explained…
|
||||
There is cruft to convert the definitions in <code class="docutils literal notranslate"><span class="pre">DEFS</span></code> to the new
|
||||
are details I should document, and the rest of the code in the <code class="docutils literal notranslate"><span class="pre">types</span></code>
|
||||
module (FIXME link to its docs here!) should be explained… There is
|
||||
cruft to convert the definitions in <code class="docutils literal notranslate"><span class="pre">DEFS</span></code> to the new
|
||||
<code class="docutils literal notranslate"><span class="pre">SymbolJoyType</span></code> objects, and some combinators. Here is an example of
|
||||
output from the current code :</p>
|
||||
<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span><span class="o">/</span><span class="mi">0</span> <span class="c1"># (Don't try to run this cell! It's not going to work. This is "read only" code heh..)</span>
|
||||
@@ -2262,6 +2262,21 @@ output from the current code :</p>
|
||||
<span class="nb">print</span> <span class="n">doc_from_stack_effect</span><span class="p">(</span><span class="n">fi</span><span class="p">,</span> <span class="n">fo</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">---------------------------------------------------------------------------</span>
|
||||
|
||||
<span class="ne">ZeroDivisionError</span> <span class="n">Traceback</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">last</span><span class="p">)</span>
|
||||
|
||||
<span class="o"><</span><span class="n">ipython</span><span class="o">-</span><span class="nb">input</span><span class="o">-</span><span class="mi">1</span><span class="o">-</span><span class="mi">9</span><span class="n">a9d60354c35</span><span class="o">></span> <span class="ow">in</span> <span class="o"><</span><span class="n">module</span><span class="o">></span><span class="p">()</span>
|
||||
<span class="o">----></span> <span class="mi">1</span> <span class="mi">1</span><span class="o">/</span><span class="mi">0</span> <span class="c1"># (Don't try to run this cell! It's not going to work. This is "read only" code heh..)</span>
|
||||
<span class="mi">2</span>
|
||||
<span class="mi">3</span> <span class="n">logging</span><span class="o">.</span><span class="n">basicConfig</span><span class="p">(</span><span class="nb">format</span><span class="o">=</span><span class="s1">'</span><span class="si">%(message)s</span><span class="s1">'</span><span class="p">,</span> <span class="n">stream</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span>
|
||||
<span class="mi">4</span>
|
||||
<span class="mi">5</span> <span class="nb">globals</span><span class="p">()</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">FUNCTIONS</span><span class="p">)</span>
|
||||
|
||||
|
||||
<span class="ne">ZeroDivisionError</span><span class="p">:</span> <span class="n">integer</span> <span class="n">division</span> <span class="ow">or</span> <span class="n">modulo</span> <span class="n">by</span> <span class="n">zero</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The numbers at the start of the lines are the current depth of the
|
||||
Python call stack. They’re followed by the current computed stack effect
|
||||
(initialized to <code class="docutils literal notranslate"><span class="pre">ID</span></code>) then the pending expression (the inference of
|
||||
@@ -2340,9 +2355,8 @@ does, but now I have to come back and describe here what I did.</li>
|
||||
to let <code class="docutils literal notranslate"><span class="pre">T</span> <span class="pre">>=</span> <span class="pre">t</span></code> succeed, where e.g. <code class="docutils literal notranslate"><span class="pre">T</span></code> is <code class="docutils literal notranslate"><span class="pre">IntJoyType</span></code> and <code class="docutils literal notranslate"><span class="pre">t</span></code>
|
||||
is <code class="docutils literal notranslate"><span class="pre">int</span></code>. If you do that you can take advantage of the <em>logical
|
||||
relational</em> nature of the stack effect comments to “compute in reverse”
|
||||
as it were. There’s a working demo of this at the end of the
|
||||
<code class="docutils literal notranslate"><span class="pre">polytypes</span></code> module. But if you’re interested in all that you should
|
||||
just use Prolog!</p>
|
||||
as it were. There’s a working demo of this at the end of the <code class="docutils literal notranslate"><span class="pre">types</span></code>
|
||||
module. But if you’re interested in all that you should just use Prolog!</p>
|
||||
<p>Anyhow, type <em>checking</em> is a few easy steps away.</p>
|
||||
<div class="code ipython2 highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">_ge</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="p">(</span><span class="nb">issubclass</span><span class="p">(</span><span class="n">other</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -14,7 +14,7 @@ Type Checking
|
||||
|
||||
.. code:: ipython2
|
||||
|
||||
from joy.utils.polytypes import (
|
||||
from joy.utils.types import (
|
||||
doc_from_stack_effect,
|
||||
infer,
|
||||
reify,
|
||||
|
||||
@@ -2821,9 +2821,9 @@ Work in Progress
|
||||
|
||||
And that brings us to current Work-In-Progress. The mixed-mode
|
||||
inferencer/interpreter ``infer()`` function seems to work well. There
|
||||
are details I should document, and the rest of the code in the
|
||||
"polytypes" module (FIXME link to its docs here!) should be explained...
|
||||
There is cruft to convert the definitions in ``DEFS`` to the new
|
||||
are details I should document, and the rest of the code in the ``types``
|
||||
module (FIXME link to its docs here!) should be explained... There is
|
||||
cruft to convert the definitions in ``DEFS`` to the new
|
||||
``SymbolJoyType`` objects, and some combinators. Here is an example of
|
||||
output from the current code :
|
||||
|
||||
@@ -2842,6 +2842,25 @@ output from the current code :
|
||||
for fi, fo in h:
|
||||
print doc_from_stack_effect(fi, fo)
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
ZeroDivisionError Traceback (most recent call last)
|
||||
|
||||
<ipython-input-1-9a9d60354c35> in <module>()
|
||||
----> 1 1/0 # (Don't try to run this cell! It's not going to work. This is "read only" code heh..)
|
||||
2
|
||||
3 logging.basicConfig(format='%(message)s', stream=sys.stdout, level=logging.INFO)
|
||||
4
|
||||
5 globals().update(FUNCTIONS)
|
||||
|
||||
|
||||
ZeroDivisionError: integer division or modulo by zero
|
||||
|
||||
|
||||
The numbers at the start of the lines are the current depth of the
|
||||
Python call stack. They're followed by the current computed stack effect
|
||||
(initialized to ``ID``) then the pending expression (the inference of
|
||||
@@ -2922,9 +2941,8 @@ For *type checking* to work the type label classes have to be modified
|
||||
to let ``T >= t`` succeed, where e.g. ``T`` is ``IntJoyType`` and ``t``
|
||||
is ``int``. If you do that you can take advantage of the *logical
|
||||
relational* nature of the stack effect comments to "compute in reverse"
|
||||
as it were. There's a working demo of this at the end of the
|
||||
``polytypes`` module. But if you're interested in all that you should
|
||||
just use Prolog!
|
||||
as it were. There's a working demo of this at the end of the ``types``
|
||||
module. But if you're interested in all that you should just use Prolog!
|
||||
|
||||
Anyhow, type *checking* is a few easy steps away.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user