plan-kernel 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: plan-kernel
3
+ Version: 0.1.1
4
+ Summary: Jupyter kernel for interactive PLAN evaluation.
5
+ Author-email: Neal Davis <davisneale@gmail.com>
6
+ Project-URL: Homepage, https://github.com/sigilante/marduk
7
+ Project-URL: Repository, https://github.com/sigilante/marduk
8
+ Keywords: plan,jupyter,kernel,ipykernel,gallowglass
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Framework :: IPython
12
+ Classifier: Framework :: Jupyter
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Education
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Topic :: Education
18
+ Classifier: Topic :: Software Development :: Interpreters
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: ipykernel>=6.0
22
+ Requires-Dist: marduk-plan>=0.2.0
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7.0; extra == "dev"
25
+
26
+ # plan-kernel
27
+
28
+ ![](https://upload.wikimedia.org/wikipedia/commons/c/c3/Chaos_Monster_and_Sun_God.png)
29
+
30
+ A Jupyter kernel for the [PLAN virtual machine](https://github.com/xocore-tech/PLAN).
31
+ Type Plan Asm in a cell, see the reduced PLAN value back.
32
+
33
+ plan-kernel is intended for tutorial use: learning what PLAN's three opcodes
34
+ (Pin / Law / Elim) do, exercising BPLAN's named primitives, and walking
35
+ through small programs (Church booleans, factorial, Y-combinator) one
36
+ reduction at a time.
37
+
38
+ ## Status
39
+
40
+ Alpha. All nine phases of [`PLAN.md`](PLAN.md) are complete: vendored
41
+ runtime, Plan Asm parser, macro expander, cell-level evaluator,
42
+ structural renderer, cell magics, BPLAN op prelude, Jupyter kernel +
43
+ CLI, and a starter set of teaching fixtures + tour notebook. A fresh
44
+ notebook can evaluate `(Add 2 3)` in cell 1.
45
+
46
+ PyPI publication is the next step.
47
+
48
+ ## Install
49
+
50
+ ### From PyPI (once published)
51
+
52
+ ```bash
53
+ pip install plan-kernel
54
+ python -m plan_kernel install # registers the kernelspec with Jupyter
55
+ jupyter notebook # "PLAN" appears in the kernel picker
56
+ ```
57
+
58
+ `plan-kernel` is the PyPI package; `plan_kernel` is the import name. The same
59
+ package supplies both the Python library and the Jupyter kernel — there is
60
+ no separate `plan-kernel-kernel` distribution.
61
+
62
+ ### From a clone (local development)
63
+
64
+ If you've cloned this repo (the typical case while plan-kernel is pre-1.0), do an
65
+ editable install so changes to the source tree take effect without
66
+ re-installing:
67
+
68
+ ```bash
69
+ git clone git@github.com:sigilante/marduk.git
70
+ cd marduk/packages/plan-kernel
71
+ python -m venv .venv && source .venv/bin/activate # optional but recommended
72
+ pip install -e '.[dev]' # installs ipykernel + pytest
73
+ pytest # confirm the runtime smoke test passes
74
+ ```
75
+
76
+ To register the kernel with Jupyter so it appears in the notebook kernel
77
+ picker:
78
+
79
+ ```bash
80
+ python -m plan_kernel install # user-level install (writes to ~/.local/share/jupyter/kernels/plan-kernel/)
81
+ # or
82
+ python -m plan_kernel install --prefix .venv # install only inside the active virtualenv
83
+ ```
84
+
85
+ Verify the registration:
86
+
87
+ ```bash
88
+ jupyter kernelspec list # "plan-kernel" should appear
89
+ ```
90
+
91
+ Launch:
92
+
93
+ ```bash
94
+ jupyter notebook # or: jupyter lab
95
+ ```
96
+
97
+ In a new notebook, choose **"PLAN"** from the kernel picker. A
98
+ fresh notebook has the BPLAN op prelude pre-bound, so `(Add 2 3)` evaluates
99
+ to `5` in cell 1.
100
+
101
+ ### Uninstall
102
+
103
+ ```bash
104
+ jupyter kernelspec remove plan-kernel # remove kernelspec only
105
+ pip uninstall plan-kernel # remove the package
106
+ ```
107
+
108
+ ## Quickstart
109
+
110
+ A cell is a sequence of Plan Asm forms. The result of the last non-bind
111
+ form displays; bind-only cells render `bind <name>` summary lines.
112
+
113
+ ```text
114
+ (Add 2 3)
115
+ ```
116
+
117
+ ```text
118
+ 5
119
+ ```
120
+
121
+ Define a law and apply it:
122
+
123
+ ```text
124
+ (#bind id
125
+ (#pin
126
+ (#law "id" (id x)
127
+ x)))
128
+
129
+ (id 42)
130
+ ```
131
+
132
+ ```text
133
+ 42
134
+ ```
135
+
136
+ The K combinator and a use:
137
+
138
+ ```text
139
+ (#bind k
140
+ (#pin
141
+ (#law "k" (k a b)
142
+ a)))
143
+
144
+ (k 7 99)
145
+ ```
146
+
147
+ ```text
148
+ 7
149
+ ```
150
+
151
+ The fixtures in [`tests/fixtures/`](tests/fixtures/) cover identity,
152
+ K, S, arithmetic, `Elim` on a nat, and Church booleans — copy any of
153
+ them into a cell to see them run.
154
+
155
+ ## What's a cell?
156
+
157
+ A cell is a sequence of Plan Asm forms — the same syntax accepted by the
158
+ canonical Reaver parser
159
+ ([`vendor/reaver/src/hs/PlanAssembler.hs`](https://github.com/xocore-tech/PLAN)),
160
+ minus `#macro`, `#export`, and `@include` (those need module-loading semantics
161
+ that don't make sense in a notebook).
162
+
163
+ Supported macros: `#pin`, `#law`, `#app`, `#bind`. The BPLAN op prelude
164
+ auto-loads on kernel start, so `(Add 2 3)` works in cell 1.
165
+
166
+ ## Magic reference
167
+
168
+ Magics live on lines that start with `%`, at the very top of the cell.
169
+ Comments and blank lines above them stop magic parsing — magics must
170
+ lead the cell body.
171
+
172
+ | Magic | Scope | Effect |
173
+ |---------------------------|--------------|-------------------------------------------------------------------------|
174
+ | `%backend evaluate` | this cell | Use the formal Python evaluator (default). |
175
+ | `%backend bevaluate` | this cell | Use the jet-aware evaluator. Faster for arithmetic-heavy programs. |
176
+ | `%reset` | persistent | Drop all user bindings. The BPLAN op prelude is reloaded. |
177
+ | `%env` | read-only | Display user bindings (sorted, comma-separated). Prelude names are filtered out. |
178
+
179
+ `%backend` reverts at end-of-cell. `%reset` is permanent until the next
180
+ `%reset`. `%env`'s output prepends to the cell's value text when the
181
+ cell also has a body.
182
+
183
+ ## Troubleshooting
184
+
185
+ **`No module named 'plan_kernel'` when launching the kernel.** The kernel.json's
186
+ `argv` uses the Python interpreter that ran `plan-kernel install`. Reinstall
187
+ from the active venv: `pip install -e '.[dev]'` and `python -m plan_kernel install`.
188
+
189
+ **plan-kernel not in the kernel picker.** Confirm the install:
190
+ `jupyter kernelspec list` should show a `plan-kernel` row. If `--prefix .venv`
191
+ was used, only that venv's Jupyter sees it; install without `--prefix`
192
+ for a user-wide registration.
193
+
194
+ **`unbound: <name>` for a name that's clearly defined.** Macro expansion
195
+ runs before the body's evaluation, so a bind form `(#bind name expr)`
196
+ must appear *before* any reference to `name` in cell-execution order.
197
+ Within a cell, this is the form order; across cells, the binding from
198
+ cell N is in scope for cell N+1.
199
+
200
+ **Recursive laws hit `RecursionError`.** plan-kernel bumps Python's recursion
201
+ limit to 200K during evaluation — past that, the BPLAN harness's own
202
+ depth guard fires. Most tutorial-scale recursion is fine; deep
203
+ factorials or Y-combinator-driven loops may exhaust it.
204
+
205
+ **`%env` shows nothing.** It filters the BPLAN op prelude. Pass
206
+ `prelude=False` when constructing `PlanKernelEvaluator` programmatically to
207
+ see *all* names, or just rely on the filtered view in the kernel.
208
+
209
+ ## Naming
210
+
211
+ This package was originally called *Marduk*. As the runtime portion grew
212
+ into a generally useful artifact in its own right, it took the name; the
213
+ kernel was renamed `plan-kernel` and the runtime now lives at
214
+ [`packages/marduk/`](../marduk/) in this monorepo. See
215
+ [`PLAN_KERNEL.md`](PLAN_KERNEL.md) for design notes.
216
+
217
+ ## License
218
+
219
+ MIT.
@@ -0,0 +1,17 @@
1
+ plan_kernel/__init__.py,sha256=XrckjJFGEAG8L2H6Lee7ofaZQeX8FMSbLTem1As3bIA,92
2
+ plan_kernel/__main__.py,sha256=rFB3KmlNoaBslcN7FtnvNH2au8zcwV2x0oBczmfR_rI,308
3
+ plan_kernel/evaluator.py,sha256=EaY5t_Blq9BZohIE1k9WogJOnBtjH5mWoX9VFB3yIxU,10861
4
+ plan_kernel/expander.py,sha256=8yHGbLXkSmhdybKmM-euuyIWsD5oK7ILu7_QNwCqPFM,459
5
+ plan_kernel/kernel.py,sha256=6BBPVDcFUFsJfw0BS9jPdoL3JpR7dqtETd5u486mYaw,7464
6
+ plan_kernel/magics.py,sha256=sz0tUY9PSiHUu1Hre6aLlqlvYGh-NoLhvLhxQqjC4qo,2565
7
+ plan_kernel/parser.py,sha256=RaAtLoodIxxT2yltONobbpT_d-JoNP3q4BwM8r61zqQ,368
8
+ plan_kernel/prelude.py,sha256=dKUcNwu7wJROAcs2C-sUe9yM-CUquYaE-SiYXQfMSAU,2524
9
+ plan_kernel/render.py,sha256=sOXijg7sEvtvP07vLDApJyFs9uMh5mCeduJu5vXbSzc,5966
10
+ plan_kernel/runtime/__init__.py,sha256=5-saLoOtSyKnrnojRAhw4aA_7x7BRut4hJMkfsvGiQk,85
11
+ plan_kernel/runtime/bplan.py,sha256=P5aSeCTmuwEQCoObnMehWstNAFRhEceaouOniRtMhss,844
12
+ plan_kernel/runtime/bplan_deps.py,sha256=gnFBrT5Cjlk2Iy4FuT00ulqpdXhd_Iv54sFnxUFQ3rI,3325
13
+ plan_kernel/runtime/plan.py,sha256=eJD_ZaCHR9eoNCNCHZ5LnE3BGB9pGx_cf5eTJWShBqg,3641
14
+ plan_kernel-0.1.1.dist-info/METADATA,sha256=cD2NsJBbTeUisx4StPwQdoNxQ5TO8bX02XXGECryIlQ,7372
15
+ plan_kernel-0.1.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
16
+ plan_kernel-0.1.1.dist-info/top_level.txt,sha256=OI5McY_g_dra-wsX_bfP5uwda_DUmfJtBP6vBz959KY,12
17
+ plan_kernel-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ plan_kernel