{"id":17997493,"url":"https://github.com/thma/lambda-cat","last_synced_at":"2025-08-07T01:13:07.850Z","repository":{"id":146285947,"uuid":"351897987","full_name":"thma/lambda-cat","owner":"thma","description":"Compiling typed lambda calculus to closed cartesian categories","archived":false,"fork":false,"pushed_at":"2021-05-21T15:46:26.000Z","size":43303,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T06:24:23.436Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thma.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-26T20:00:15.000Z","updated_at":"2021-05-21T15:46:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe55f7d1-18e0-4e56-b909-060d7c5dd7a8","html_url":"https://github.com/thma/lambda-cat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thma/lambda-cat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thma%2Flambda-cat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thma%2Flambda-cat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thma%2Flambda-cat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thma%2Flambda-cat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thma","download_url":"https://codeload.github.com/thma/lambda-cat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thma%2Flambda-cat/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269182283,"owners_count":24374096,"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","status":"online","status_checked_at":"2025-08-06T02:00:09.910Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-29T21:18:53.628Z","updated_at":"2025-08-07T01:13:07.792Z","avatar_url":"https://github.com/thma.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lambda Cat\n\n### This is still heavily work in progress!!!\n\n\u003cimg src=\"./lambda-cat-logo.png\" width=\"400\" height=\"400\" alt=\"Mieke the official lambda cat 2021\"/\u003e\n\n\n## disclaimer:\n\nThis code is based on Philip Zuckers\n[http://www.philipzucker.com/compiling-to-categories-3-a-bit-cuter/](http://www.philipzucker.com/compiling-to-categories-3-a-bit-cuter/)\n\nI forked from a [specific branch of his repository](https://github.com/philzook58/not-bad-ccc/tree/fan2).\nAll the really complicated stuff is his invention. I just filled the blanks, cleaned up the code a bit and added an interpreter that executes CCC code.\n\n\n## Introduction\n\nRecently I read the very interesting [Compiling to Categories](http://conal.net/papers/compiling-to-categories/compiling-to-categories.pdf) paper by Conal Elliot.\n\nHe presents the idea to compile haskell programs into expressions of cartesian closed categories by λ-elimination.\nThese expressions can then be used for different purposes like alternative program evaluation, graphic representation\nof program graphs, designing hardware layouts for algorithms, etc.\n\n\n## Cartesian Closed Categories (CCC)\n\nIn his famous paper [Compiling to Categories](http://conal.net/papers/compiling-to-categories/compiling-to-categories.pdf) Conal Elliot describes a way to compile from simply typed lambda-calculus terms to cartesian closed categories(CCC).\n\nAt the core of his approach sits a transformation from lambda-terms to CCC expressions that are done by eliminating variables by an abstraction function `absCCC` (again in pseudo-Haskell):\n\n```haskell\nabsCCC (\\x -\u003e x)   = id\nabsCCC (\\x -\u003e y)   = const y\nabsCCC (\\x -\u003e p q) = apply . ((\\x -\u003e p) △ (\\x -\u003e q))\n```\n\nWhere `(△)` is introduced by the `Cartesian` category:\n\n```haskell\nclass Category k =\u003e Cartesian k where\n  (△) :: (a `k` c) -\u003e (a `k` d) -\u003e (a `k` (c, d))\n```\n\nIn the `(-\u003e)` instance of `Cartesian` `(△)` is defined as: \n\n```haskell\n(△):: (t -\u003e a) -\u003e (t -\u003e b) -\u003e t -\u003e (a, b)\n(f △ g) x = (f x, g x)\n```\n\nAnd where `apply` is introduced by the `Closed` category:\n\n```haskell\nclass Cartesian k =\u003e Closed k where\n  apply :: ((a -\u003e b), a) `k` b\n```\n\nIn the `(-\u003e)` instance of `Closed` `apply` is defined as \n\n```haskell\napply :: (a -\u003e b, a) -\u003e b\napply (f, x) = f x\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthma%2Flambda-cat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthma%2Flambda-cat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthma%2Flambda-cat/lists"}