curryparty 0.1.0__tar.gz → 0.2.0__tar.gz

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.
@@ -1,10 +1,9 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: curryparty
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Python playground to learn lambda calculus
5
5
  Author: Antonin P
6
6
  Author-email: Antonin P <antonin.peronnet@telecom-paris.fr>
7
- Requires-Dist: polars>=1.36.1
8
7
  Requires-Dist: svg-py>=1.9.2
9
8
  Requires-Python: >=3.13
10
9
  Description-Content-Type: text/markdown
@@ -57,11 +56,18 @@ for x in term.reduction_chain():
57
56
  But the main point of this library is the svg-based display system.
58
57
  If you use a notebook such as jupyternotebook or marimo, you will see something like this:
59
58
 
60
- ![](./assets/notebook_display.png)
59
+ <img width="1140" height="440" alt="notebook_display" src="https://github.com/user-attachments/assets/6ac48738-eb58-4f7c-908f-567a855f37f5" />
60
+
61
61
 
62
62
 
63
63
  You can also use `term.show_reduction` to get an animated version.
64
64
 
65
+ # Tutorial
66
+
67
+ `lambda.py` shows a tutorial in marimo format. Click on the button to try it out:
68
+
69
+ [![Open with marimo](https://marimo.io/shield.svg)](https://marimo.app/github.com/rambip/curryparty/blob/main/lambda.py)
70
+
65
71
  # How it works
66
72
 
67
73
  Under the wood, all the terms are converted into a list of nodes, that can either be a `lambda`, an `application` (with 2 arguments) or a `variable` (with 0 arguments).
@@ -46,11 +46,18 @@ for x in term.reduction_chain():
46
46
  But the main point of this library is the svg-based display system.
47
47
  If you use a notebook such as jupyternotebook or marimo, you will see something like this:
48
48
 
49
- ![](./assets/notebook_display.png)
49
+ <img width="1140" height="440" alt="notebook_display" src="https://github.com/user-attachments/assets/6ac48738-eb58-4f7c-908f-567a855f37f5" />
50
+
50
51
 
51
52
 
52
53
  You can also use `term.show_reduction` to get an animated version.
53
54
 
55
+ # Tutorial
56
+
57
+ `lambda.py` shows a tutorial in marimo format. Click on the button to try it out:
58
+
59
+ [![Open with marimo](https://marimo.io/shield.svg)](https://marimo.app/github.com/rambip/curryparty/blob/main/lambda.py)
60
+
54
61
  # How it works
55
62
 
56
63
  Under the wood, all the terms are converted into a list of nodes, that can either be a `lambda`, an `application` (with 2 arguments) or a `variable` (with 0 arguments).
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "curryparty"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "Python playground to learn lambda calculus"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -8,7 +8,6 @@ authors = [
8
8
  ]
9
9
  requires-python = ">=3.13"
10
10
  dependencies = [
11
- "polars>=1.36.1",
12
11
  "svg-py>=1.9.2",
13
12
  ]
14
13
 
@@ -19,5 +18,6 @@ build-backend = "uv_build"
19
18
  [dependency-groups]
20
19
  dev = [
21
20
  "marimo>=0.18.4",
21
+ "polars>=1.36.1",
22
22
  "ruff>=0.14.8",
23
23
  ]
@@ -1,6 +1,11 @@
1
1
  from typing import Iterable, List, Optional, Union
2
2
 
3
- import polars as pl
3
+ try:
4
+ import polars as pl
5
+ except ImportError:
6
+ raise ImportError(
7
+ "curryparty needs the `polars` library. \n Please install it, typically with `pip install polars`"
8
+ )
4
9
  from svg import SVG
5
10
 
6
11
  from .core import SCHEMA, beta_reduce, compose, find_redexes, find_variables, subtree
@@ -36,6 +41,12 @@ class Term:
36
41
  reduced = beta_reduce(self.nodes, lamb, b)
37
42
  return Term(reduced)
38
43
 
44
+ def reduce(self):
45
+ last_non_reduced = self
46
+ for term in self.reduction_chain():
47
+ last_non_reduced = term
48
+ return last_non_reduced
49
+
39
50
  def reduction_chain(self) -> Iterable["Term"]:
40
51
  term = self
41
52
  while True:
@@ -44,7 +55,7 @@ class Term:
44
55
  if term is None:
45
56
  break
46
57
 
47
- def show_reduction(self):
58
+ def show_beta(self):
48
59
  candidates = find_redexes(self.nodes)
49
60
  if len(candidates) == 0:
50
61
  return None