Finally remove all mentions of the old polytypes module.
It was merged with types long ago.
This commit is contained in:
parent
cdff2ea5ea
commit
a66fd8d173
|
|
@ -11800,10 +11800,10 @@ div#notebook {
|
||||||
</div>
|
</div>
|
||||||
<div class="cell border-box-sizing code_cell rendered">
|
<div class="cell border-box-sizing code_cell rendered">
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<div class="prompt input_prompt">In [2]:</div>
|
<div class="prompt input_prompt">In [3]:</div>
|
||||||
<div class="inner_cell">
|
<div class="inner_cell">
|
||||||
<div class="input_area">
|
<div class="input_area">
|
||||||
<div class=" highlight hl-ipython2"><pre><span></span><span class="kn">from</span> <span class="nn">joy.utils.polytypes</span> <span class="kn">import</span> <span class="p">(</span>
|
<div class=" highlight hl-ipython2"><pre><span></span><span class="kn">from</span> <span class="nn">joy.utils.types</span> <span class="kn">import</span> <span class="p">(</span>
|
||||||
<span class="n">doc_from_stack_effect</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">infer</span><span class="p">,</span>
|
||||||
<span class="n">reify</span><span class="p">,</span>
|
<span class="n">reify</span><span class="p">,</span>
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,11 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 2,
|
"execution_count": 3,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"from joy.utils.polytypes import (\n",
|
"from joy.utils.types import (\n",
|
||||||
" doc_from_stack_effect, \n",
|
" doc_from_stack_effect, \n",
|
||||||
" infer,\n",
|
" infer,\n",
|
||||||
" reify,\n",
|
" reify,\n",
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ logging.basicConfig(
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from joy.utils.polytypes import (
|
from joy.utils.types import (
|
||||||
doc_from_stack_effect,
|
doc_from_stack_effect,
|
||||||
infer,
|
infer,
|
||||||
reify,
|
reify,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ Type Checking
|
||||||
|
|
||||||
.. code:: ipython2
|
.. code:: ipython2
|
||||||
|
|
||||||
from joy.utils.polytypes import (
|
from joy.utils.types import (
|
||||||
doc_from_stack_effect,
|
doc_from_stack_effect,
|
||||||
infer,
|
infer,
|
||||||
reify,
|
reify,
|
||||||
|
|
|
||||||
|
|
@ -16627,14 +16627,14 @@ uncons = ([a1 .1.] -- a1 [.1.])
|
||||||
</div>
|
</div>
|
||||||
<div class="inner_cell">
|
<div class="inner_cell">
|
||||||
<div class="text_cell_render border-box-sizing rendered_html">
|
<div class="text_cell_render border-box-sizing rendered_html">
|
||||||
<h4 id="Work-in-Progress">Work in Progress<a class="anchor-link" href="#Work-in-Progress">¶</a></h4><p>And that brings us to current Work-In-Progress. The mixed-mode inferencer/interpreter <code>infer()</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>DEFS</code> to the new <code>SymbolJoyType</code> objects, and some combinators. Here is an example of output from the current code :</p>
|
<h4 id="Work-in-Progress">Work in Progress<a class="anchor-link" href="#Work-in-Progress">¶</a></h4><p>And that brings us to current Work-In-Progress. The mixed-mode inferencer/interpreter <code>infer()</code> function seems to work well. There are details I should document, and the rest of the code in the <code>types</code> module (FIXME link to its docs here!) should be explained... There is cruft to convert the definitions in <code>DEFS</code> to the new <code>SymbolJoyType</code> objects, and some combinators. Here is an example of output from the current code :</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cell border-box-sizing code_cell rendered">
|
<div class="cell border-box-sizing code_cell rendered">
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<div class="prompt input_prompt">In [ ]:</div>
|
<div class="prompt input_prompt">In [1]:</div>
|
||||||
<div class="inner_cell">
|
<div class="inner_cell">
|
||||||
<div class="input_area">
|
<div class="input_area">
|
||||||
<div class=" highlight hl-ipython2"><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>
|
<div class=" highlight hl-ipython2"><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>
|
||||||
|
|
@ -16655,6 +16655,33 @@ uncons = ([a1 .1.] -- a1 [.1.])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="output_wrapper">
|
||||||
|
<div class="output">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="output_area">
|
||||||
|
|
||||||
|
<div class="prompt"></div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="output_subarea output_text output_error">
|
||||||
|
<pre>
|
||||||
|
<span class="ansi-red-fg">---------------------------------------------------------------------------</span>
|
||||||
|
<span class="ansi-red-fg">ZeroDivisionError</span> Traceback (most recent call last)
|
||||||
|
<span class="ansi-green-fg"><ipython-input-1-9a9d60354c35></span> in <span class="ansi-cyan-fg"><module></span><span class="ansi-blue-fg">()</span>
|
||||||
|
<span class="ansi-green-fg">----> 1</span><span class="ansi-red-fg"> </span><span class="ansi-cyan-fg">1</span><span class="ansi-blue-fg">/</span><span class="ansi-cyan-fg">0</span> <span class="ansi-red-fg"># (Don't try to run this cell! It's not going to work. This is "read only" code heh..)</span>
|
||||||
|
<span class="ansi-green-intense-fg ansi-bold"> 2</span>
|
||||||
|
<span class="ansi-green-intense-fg ansi-bold"> 3</span> logging<span class="ansi-blue-fg">.</span>basicConfig<span class="ansi-blue-fg">(</span>format<span class="ansi-blue-fg">=</span><span class="ansi-blue-fg">'%(message)s'</span><span class="ansi-blue-fg">,</span> stream<span class="ansi-blue-fg">=</span>sys<span class="ansi-blue-fg">.</span>stdout<span class="ansi-blue-fg">,</span> level<span class="ansi-blue-fg">=</span>logging<span class="ansi-blue-fg">.</span>INFO<span class="ansi-blue-fg">)</span>
|
||||||
|
<span class="ansi-green-intense-fg ansi-bold"> 4</span>
|
||||||
|
<span class="ansi-green-intense-fg ansi-bold"> 5</span> globals<span class="ansi-blue-fg">(</span><span class="ansi-blue-fg">)</span><span class="ansi-blue-fg">.</span>update<span class="ansi-blue-fg">(</span>FUNCTIONS<span class="ansi-blue-fg">)</span>
|
||||||
|
|
||||||
|
<span class="ansi-red-fg">ZeroDivisionError</span>: integer division or modulo by zero</pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
|
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -16744,7 +16771,7 @@ uncons = ([a1 .1.] -- a1 [.1.])
|
||||||
</div>
|
</div>
|
||||||
<div class="inner_cell">
|
<div class="inner_cell">
|
||||||
<div class="text_cell_render border-box-sizing rendered_html">
|
<div class="text_cell_render border-box-sizing rendered_html">
|
||||||
<h2 id="Appendix:-Joy-in-the-Logical-Paradigm">Appendix: Joy in the Logical Paradigm<a class="anchor-link" href="#Appendix:-Joy-in-the-Logical-Paradigm">¶</a></h2><p>For <em>type checking</em> to work the type label classes have to be modified to let <code>T >= t</code> succeed, where e.g. <code>T</code> is <code>IntJoyType</code> and <code>t</code> is <code>int</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>polytypes</code> module. But if you're interested in all that you should just use Prolog!</p>
|
<h2 id="Appendix:-Joy-in-the-Logical-Paradigm">Appendix: Joy in the Logical Paradigm<a class="anchor-link" href="#Appendix:-Joy-in-the-Logical-Paradigm">¶</a></h2><p>For <em>type checking</em> to work the type label classes have to be modified to let <code>T >= t</code> succeed, where e.g. <code>T</code> is <code>IntJoyType</code> and <code>t</code> is <code>int</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>types</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>
|
<p>Anyhow, type <em>checking</em> is a few easy steps away.</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -3684,16 +3684,28 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"#### Work in Progress\n",
|
"#### Work in Progress\n",
|
||||||
"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 `SymbolJoyType` objects, and some combinators. Here is an example of output from the current code :"
|
"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 `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 :"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 1,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"scrolled": true
|
"scrolled": true
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"ename": "ZeroDivisionError",
|
||||||
|
"evalue": "integer division or modulo by zero",
|
||||||
|
"output_type": "error",
|
||||||
|
"traceback": [
|
||||||
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||||
|
"\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)",
|
||||||
|
"\u001b[0;32m<ipython-input-1-9a9d60354c35>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;36m1\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m0\u001b[0m \u001b[0;31m# (Don't try to run this cell! It's not going to work. This is \"read only\" code heh..)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mlogging\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbasicConfig\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'%(message)s'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstream\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstdout\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlevel\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlogging\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mINFO\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mglobals\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mFUNCTIONS\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||||
|
"\u001b[0;31mZeroDivisionError\u001b[0m: integer division or modulo by zero"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"1/0 # (Don't try to run this cell! It's not going to work. This is \"read only\" code heh..)\n",
|
"1/0 # (Don't try to run this cell! It's not going to work. This is \"read only\" code heh..)\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
@ -3790,7 +3802,7 @@
|
||||||
"source": [
|
"source": [
|
||||||
"## Appendix: Joy in the Logical Paradigm\n",
|
"## Appendix: Joy in the Logical Paradigm\n",
|
||||||
"\n",
|
"\n",
|
||||||
"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!\n",
|
"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 `types` module. But if you're interested in all that you should just use Prolog!\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Anyhow, type *checking* is a few easy steps away."
|
"Anyhow, type *checking* is a few easy steps away."
|
||||||
]
|
]
|
||||||
|
|
@ -3828,7 +3840,7 @@
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython2",
|
"pygments_lexer": "ipython2",
|
||||||
"version": "2.7.15"
|
"version": "2.7.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|
|
||||||
|
|
@ -2394,7 +2394,7 @@ def _log_it(e, F):
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Work in Progress
|
#### 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 `SymbolJoyType` objects, and some combinators. Here is an example of output from the current code :
|
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 `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 :
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
@ -2412,6 +2412,22 @@ for fi, fo in h:
|
||||||
print doc_from_stack_effect(fi, fo)
|
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 the stack effect of which is the whole object of the current example.)
|
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 the stack effect of which is the whole object of the current example.)
|
||||||
|
|
||||||
In this example we are implementing (and inferring) `ifte` as `[nullary bool] dipd branch` which shows off a lot of the current implementation in action.
|
In this example we are implementing (and inferring) `ifte` as `[nullary bool] dipd branch` which shows off a lot of the current implementation in action.
|
||||||
|
|
@ -2474,7 +2490,7 @@ Work remains to be done:
|
||||||
|
|
||||||
## Appendix: Joy in the Logical Paradigm
|
## Appendix: Joy in the Logical Paradigm
|
||||||
|
|
||||||
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!
|
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 `types` module. But if you're interested in all that you should just use Prolog!
|
||||||
|
|
||||||
Anyhow, type *checking* is a few easy steps away.
|
Anyhow, type *checking* is a few easy steps away.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2821,9 +2821,9 @@ Work in Progress
|
||||||
|
|
||||||
And that brings us to current Work-In-Progress. The mixed-mode
|
And that brings us to current Work-In-Progress. The mixed-mode
|
||||||
inferencer/interpreter ``infer()`` function seems to work well. There
|
inferencer/interpreter ``infer()`` function seems to work well. There
|
||||||
are details I should document, and the rest of the code in the
|
are details I should document, and the rest of the code in the ``types``
|
||||||
"polytypes" module (FIXME link to its docs here!) should be explained...
|
module (FIXME link to its docs here!) should be explained... There is
|
||||||
There is cruft to convert the definitions in ``DEFS`` to the new
|
cruft to convert the definitions in ``DEFS`` to the new
|
||||||
``SymbolJoyType`` objects, and some combinators. Here is an example of
|
``SymbolJoyType`` objects, and some combinators. Here is an example of
|
||||||
output from the current code :
|
output from the current code :
|
||||||
|
|
||||||
|
|
@ -2842,6 +2842,25 @@ output from the current code :
|
||||||
for fi, fo in h:
|
for fi, fo in h:
|
||||||
print doc_from_stack_effect(fi, fo)
|
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
|
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
|
Python call stack. They're followed by the current computed stack effect
|
||||||
(initialized to ``ID``) then the pending expression (the inference of
|
(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``
|
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
|
is ``int``. If you do that you can take advantage of the *logical
|
||||||
relational* nature of the stack effect comments to "compute in reverse"
|
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
|
as it were. There's a working demo of this at the end of the ``types``
|
||||||
``polytypes`` module. But if you're interested in all that you should
|
module. But if you're interested in all that you should just use Prolog!
|
||||||
just use Prolog!
|
|
||||||
|
|
||||||
Anyhow, type *checking* is a few easy steps away.
|
Anyhow, type *checking* is a few easy steps away.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,16 @@
|
||||||
<span class="p">)</span>
|
<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">_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>
|
<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="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="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="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>
|
<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>
|
<span class="p">)</span>
|
||||||
</pre></div>
|
</pre></div>
|
||||||
</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">doc_from_stack_effect</span><span class="p">,</span>
|
||||||
<span class="n">infer</span><span class="p">,</span>
|
<span class="n">infer</span><span class="p">,</span>
|
||||||
<span class="n">reify</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>
|
<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
|
<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
|
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
|
are details I should document, and the rest of the code in the <code class="docutils literal notranslate"><span class="pre">types</span></code>
|
||||||
“polytypes” module (FIXME link to its docs here!) should be explained…
|
module (FIXME link to its docs here!) should be explained… There is
|
||||||
There is cruft to convert the definitions in <code class="docutils literal notranslate"><span class="pre">DEFS</span></code> to the new
|
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
|
<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>
|
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>
|
<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>
|
<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>
|
</pre></div>
|
||||||
</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
|
<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
|
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
|
(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>
|
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
|
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”
|
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
|
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>
|
||||||
<code class="docutils literal notranslate"><span class="pre">polytypes</span></code> module. But if you’re interested in all that you should
|
module. But if you’re interested in all that you should just use Prolog!</p>
|
||||||
just use Prolog!</p>
|
|
||||||
<p>Anyhow, type <em>checking</em> is a few easy steps away.</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>
|
<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>
|
<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
|
.. code:: ipython2
|
||||||
|
|
||||||
from joy.utils.polytypes import (
|
from joy.utils.types import (
|
||||||
doc_from_stack_effect,
|
doc_from_stack_effect,
|
||||||
infer,
|
infer,
|
||||||
reify,
|
reify,
|
||||||
|
|
|
||||||
|
|
@ -2821,9 +2821,9 @@ Work in Progress
|
||||||
|
|
||||||
And that brings us to current Work-In-Progress. The mixed-mode
|
And that brings us to current Work-In-Progress. The mixed-mode
|
||||||
inferencer/interpreter ``infer()`` function seems to work well. There
|
inferencer/interpreter ``infer()`` function seems to work well. There
|
||||||
are details I should document, and the rest of the code in the
|
are details I should document, and the rest of the code in the ``types``
|
||||||
"polytypes" module (FIXME link to its docs here!) should be explained...
|
module (FIXME link to its docs here!) should be explained... There is
|
||||||
There is cruft to convert the definitions in ``DEFS`` to the new
|
cruft to convert the definitions in ``DEFS`` to the new
|
||||||
``SymbolJoyType`` objects, and some combinators. Here is an example of
|
``SymbolJoyType`` objects, and some combinators. Here is an example of
|
||||||
output from the current code :
|
output from the current code :
|
||||||
|
|
||||||
|
|
@ -2842,6 +2842,25 @@ output from the current code :
|
||||||
for fi, fo in h:
|
for fi, fo in h:
|
||||||
print doc_from_stack_effect(fi, fo)
|
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
|
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
|
Python call stack. They're followed by the current computed stack effect
|
||||||
(initialized to ``ID``) then the pending expression (the inference of
|
(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``
|
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
|
is ``int``. If you do that you can take advantage of the *logical
|
||||||
relational* nature of the stack effect comments to "compute in reverse"
|
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
|
as it were. There's a working demo of this at the end of the ``types``
|
||||||
``polytypes`` module. But if you're interested in all that you should
|
module. But if you're interested in all that you should just use Prolog!
|
||||||
just use Prolog!
|
|
||||||
|
|
||||||
Anyhow, type *checking* is a few easy steps away.
|
Anyhow, type *checking* is a few easy steps away.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue