Skip to main content

Python playground to learn lambda calculus

Project description

Curry party

curryparty is a library created to explore, visualize and teach lambda-calculus concepts.

Install

Run pip install curryparty or uv add curryparty depending on your package manager.

How to use

from curryparty import L, V

# build expressions idiomatically
identity = L("x")._("x").build()

zero = L("f", "x")._("x").build()

omega = L("x")._("x").call("x").build()

# you can create more complex terms:

succ = L("n", "f", "x")._("f").call(
    V("n").call("f").call("x")
)

# If you try to combine them, nothing will happen:
bomb = omega(omega)
one = s(zero)

# You need to beta-reduce them:
bomb.beta()
one_with_first_reduction = one.beta()

# if you want the final form:
term = s(zero)
while term is not None:
    term = term.beta()
    print(term)

# this is equivalent to:
for x in term.reduction_chain():
    print(x)

But the main point of this library is the svg-based display system. If you use a notebook such as jupyternotebook or marimo, you will see something like this:

notebook_display

You can also use term.show_reduction to get an animated version.

Tutorial

lambda.py shows a tutorial in marimo format. Click on the button to try it out:

Open with marimo

How it works

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).

For efficiency, they are converted to a polars dataframe in prefix traversal order. If you want to understand how it works, start by looking at the .nodes attribute of any term.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

curryparty-0.2.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

curryparty-0.2.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file curryparty-0.2.0.tar.gz.

File metadata

  • Download URL: curryparty-0.2.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for curryparty-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dc5310619238c0f0bc2d6bd61142e48f71e79d849e547502d97b27457aa5cc90
MD5 cd50153b8c29a9f10f596e21f4a42392
BLAKE2b-256 7f98df2a4d7d0fa09ea64490c0f271e7a3fdb828fb88d6846d988a7eec67a0ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for curryparty-0.2.0.tar.gz:

Publisher: publish.yml on rambip/curryparty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file curryparty-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: curryparty-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for curryparty-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87d735e6adfa30adc59c8f94d038672e7493cd6b47a10f15a8c31034fc9ace25
MD5 c7a7d0ee5a310f9070f3959c3be912a3
BLAKE2b-256 42909da0c9f7a5f5830730eeca49dc0aa14c142632e2c0ee236ad6c1cfc52f30

See more details on using hashes here.

Provenance

The following attestation bundles were made for curryparty-0.2.0-py3-none-any.whl:

Publisher: publish.yml on rambip/curryparty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page