{"id":21932026,"url":"https://github.com/woodrush/lambdacraft","last_synced_at":"2026-01-05T13:03:08.970Z","repository":{"id":59613708,"uuid":"534977647","full_name":"woodrush/lambdacraft","owner":"woodrush","description":"Common Lisp DSL for building untyped lambda calculus expressions","archived":false,"fork":false,"pushed_at":"2024-12-03T06:05:44.000Z","size":444,"stargazers_count":24,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-27T12:24:05.881Z","etag":null,"topics":["common-lisp","lambda-calculus"],"latest_commit_sha":null,"homepage":"","language":"Common Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/woodrush.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-10T11:29:44.000Z","updated_at":"2024-12-03T06:05:47.000Z","dependencies_parsed_at":"2022-09-25T18:32:13.621Z","dependency_job_id":null,"html_url":"https://github.com/woodrush/lambdacraft","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woodrush%2Flambdacraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woodrush%2Flambdacraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woodrush%2Flambdacraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/woodrush%2Flambdacraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/woodrush","download_url":"https://codeload.github.com/woodrush/lambdacraft/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244959454,"owners_count":20538628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["common-lisp","lambda-calculus"],"created_at":"2024-11-28T23:16:40.136Z","updated_at":"2026-01-05T13:03:03.928Z","avatar_url":"https://github.com/woodrush.png","language":"Common Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"![LambdaCraftLisp's logo](./bin/lambdacraft_logo.png)\n\u003cbr\u003e\n[![test](https://github.com/woodrush/lambdacraft/actions/workflows/test.yml/badge.svg)](https://github.com/woodrush/lambdacraft/actions/workflows/test.yml)\n\nLambdaCraft is a Common Lisp DSL for building untyped lambda calculus terms in a macro-based style.\nIt is inspired by Ben Rudiak-Gould's Scheme program Lazier, a compiler from lambda terms written in Scheme to [Lazy K](https://tromp.github.io/cl/lazy-k.html).\n\nLambdaCraft is used to build [LambdaLisp](https://github.com/woodrush/lambdalisp), a Lisp interpreter written in untyped lambda calculus.\nIt can be used to write large programs in the following lambda-calculus-based languages:\n\n- [Binary Lambda Calculus](https://tromp.github.io/cl/cl.html)\n- [Universal Lambda](http://www.golfscript.com/lam/)\n- [Lazy K](https://tromp.github.io/cl/lazy-k.html)\n\nLambdaCraft can also be used to build general-purpose generic lambda terms for educational purposes as well.\nMany output formats shown in the [supported output formats](#supported-output-formats) section are supported.\n\n\n## Example\n```sh\n(load \"./lambdacraft.cl\")\n\n(defrec-lazy fact (n)\n  (if (\u003c= n 0)\n    1\n    (* n (fact (- n 1)))))\n\n(format t (compile-to-plaintext-lambda-lazy fact))\n```\n\nwill print\n\n```\n(λx.(λy.(x (y y)) λy.(x (y y))) λx.λy.((((((λz.λa.a λy.λa.λb.(((y λc.λd.(d (c a))) λc.b) λc.c)) y) λz.λz.λb.b) λz.λa.z) λz.λa.(z a)) λz.λa.((y ((x ((λz.λa.(z a) y.λz.λa.(((y λe.λf.(f (e z))) λe.a) λe.e)) y)) z)) a)))\n```\n\nWhich is a lambda calculus term that takes a [Church-encoded](https://en.wikipedia.org/wiki/Church_encoding) number and returns its factorial.\nHere, `defrec-lazy` is a LambdaCraft macro that uses the [Y combinator](https://en.wikipedia.org/wiki/Fixed-point_combinator) for self-recursion.\nThe source code is available as [example.cl](./example.cl).\n\n\n## Usage for Lambda-Calculus-Based Programming Languages\nLambdaCraft supports the following lambda-calculus-based and SKI-combinator-based languages:\n\n- [Binary Lambda Calculus](https://tromp.github.io/cl/cl.html)\n- [Universal Lambda](http://www.golfscript.com/lam/)\n- [Lazy K](https://tromp.github.io/cl/lazy-k.html)\n\nThese languages accept a lambda calculus term or a [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus) term as a program.\nUsing a stream-based I/O with strings encoded in the [Mogensen-Scott encoding](https://en.wikipedia.org/wiki/Mogensen%E2%80%93Scott_encoding),\nthese languages are able to handle lambda terms as a function that takes a string and outputs a string,\nwhere each string represents the standard input and output.\n\n`examples/*.cl` are sample scripts for these languages, which compiles to a program that prints the letter `A` and exits.\nThe outputs of `examples/*.cl` can be run on each language as:\n```sh\nsbcl --script ./examples/blc.cl | asc2bin | tromp        # Binary Lambda Calculus\nsbcl --script ./examples/ulamb.cl | asc2bin | clamb -u   # Universal Lambda\nlazyk \u003c(sbcl --script ./examples/lazyk.cl) -u            # Lazy K\n```\n\nInstructions for building the interpreters for these languages are described in detail in my other project, [LambdaLisp](https://github.com/woodrush/lambdalisp).\n\n\n## Supported Output Formats\nLambdaCraft can compile lambda terms into the following formats:\n\n| Format                                                                                                | Example                      | API                                |\n|------------------------------------------------------------------------------------------------------ |------------------------------|------------------------------------|\n| Plaintext lambda notation                                                                             | `\\x.x`                       | `compile-to-plaintext-lambda-lazy` |\n| [Binary lambda calculus](https://tromp.github.io/cl/cl.html) notation                                 | `0010`                       | `compile-to-blc-lazy`              |\n| SKI combinator calculus term in [Unlambda](http://www.madore.org/~david/programs/unlambda/) notation  | ``` ``skk```                 | `compile-to-ski-lazy`              |\n| SKI combinator calculus term                                                                          | `((SK)K)`                    | `compile-to-ski-parens-lazy`       |\n| Plaintext lambda compatible with [https://github.com/tromp/AIT](https://github.com/tromp/AIT)         | `(\\x.x)`                     | `compile-to-lam-lazy`              |\n| Lisp S-expression                                                                                     | `(lambda (x) x)`             | `compile-to-lisp-lazy`             |\n| Lisp S-expression, pretty-printed                                                                     | `(lambda (x) x)`             | `compile-to-lisp-pretty-lazy`      |\n| JavaScript function                                                                                   | `function (x) { return x; }` | `compile-to-js-lazy`               |\n| JavaScript function in arrow notation                                                                 | `(x) =\u003e x`                   | `compile-to-js-arrow-lazy`         |\n| Python lambda                                                                                         | `lambda x: x`                | `compile-to-python-lazy`           |\n\n\n## Usage\nLambdaCraft is written in Common Lisp. It should run in any Common Lisp interpreter of your choice.\nI particularly use SBCL (Steel Bank Common Lisp), which is installable by:\n\n```sh\nsudo apt install sbcl\n```\n\nor on a Mac with:\n```sh\nbrew install sbcl\n```\n\nLambdaCraft can then be used by simply including the program as a header,\nand running the source as a Common Lisp program.\nFor example, [example.cl](example.cl) can be run as:\n\n```sh\nsbcl --script example.cl\n```\n\nwhich will print the factorial function defined in the script.\n\nLambdaCraft also runs on [LambdaLisp](https://github.com/woodrush/lambdalisp) as well, since it is written as a\nCommon-Lisp-LambdaLisp polyglot program. Practically, running it on Common Lisp is faster.\n\n\n## Testing\nThe test runs `make test`, which does the following:\n\n- Runs [./examples/ulamb.cl](./examples/ulamb.cl) with SBCL, and saves the output as `a.ulamb`\n- Builds [clamb](https://github.com/irori/clamb), a [Universal Lambda](http://www.golfscript.com/lam/) interpreter written by Kunihiko Sakamoto ([@irori](https://github.com/irori/))\n- Runs `a.ulamb` on `clamb` and confirms that it prints the letter `A`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwoodrush%2Flambdacraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwoodrush%2Flambdacraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwoodrush%2Flambdacraft/lists"}