{"id":16765339,"url":"https://github.com/lewisgaul/python_adt","last_synced_at":"2026-02-25T11:36:26.292Z","repository":{"id":72209634,"uuid":"340767652","full_name":"LewisGaul/python_adt","owner":"LewisGaul","description":"Implementation of Alegbraic Data Types (ADTs) in Python","archived":false,"fork":false,"pushed_at":"2025-02-17T23:19:21.000Z","size":40,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-21T19:38:45.541Z","etag":null,"topics":["algebraic-data-types","python3","sum-types","tagged-unions"],"latest_commit_sha":null,"homepage":"https://adt.readthedocs.io","language":"Python","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/LewisGaul.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,"zenodo":null}},"created_at":"2021-02-20T22:33:04.000Z","updated_at":"2025-03-27T20:38:43.000Z","dependencies_parsed_at":"2025-08-02T10:35:33.982Z","dependency_job_id":"de86dbd0-d786-41ab-be65-c6614c82de7a","html_url":"https://github.com/LewisGaul/python_adt","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/LewisGaul/python_adt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LewisGaul%2Fpython_adt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LewisGaul%2Fpython_adt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LewisGaul%2Fpython_adt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LewisGaul%2Fpython_adt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LewisGaul","download_url":"https://codeload.github.com/LewisGaul/python_adt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LewisGaul%2Fpython_adt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29819408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T05:36:42.804Z","status":"ssl_error","status_checked_at":"2026-02-25T05:36:31.934Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["algebraic-data-types","python3","sum-types","tagged-unions"],"created_at":"2024-10-13T05:42:25.066Z","updated_at":"2026-02-25T11:36:26.286Z","avatar_url":"https://github.com/LewisGaul.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build badge](https://img.shields.io/github/workflow/status/LewisGaul/python_adt/basic-tests/main)](https://github.com/LewisGaul/python_adt/actions/workflows/basic-tests.yml?query=branch%3Amain)\n[![Codecov badge](https://img.shields.io/codecov/c/github/LewisGaul/python_adt/main)](https://codecov.io/gh/LewisGaul/python_adt/)\n[![Documentation Status](https://readthedocs.org/projects/adt/badge/?version=latest)](https://adt.readthedocs.io/en/latest/?badge=latest)\n\n# Algebraic Data Types in Python\n\n```python\nimport adt\n\nclass MyADT(adt.ADT):\n    foo: ()\n    bar: (int,)\n    baz: (int, bool, str, None)\n\n    @adt.fieldmethod\n    def double_first(field, basecls) -\u003e \"MyADT\":\n        if isinstance(field, basecls.foo):\n            raise TypeError(\n                f\"{basecls.foo.__qualname__} does not support doubling\"\n            )\n        field_type = type(field)\n        first, *rem = field\n        return field_type(first * 2, *rem)\n\nfoo = MyADT.foo()\nbar = MyADT.bar(4)\nbaz = MyADT.baz(3, False, \"hi\", None)\n\nfor val in [foo, bar, baz]:\n    print(val)\n    try:\n        doubled = val.double_first()\n        print(\"Doubled:\", doubled)\n    except TypeError:\n        print(\"Failed to double\")\n    print()\n```\n\nSee `examples/`, `adt/example.py` and `tests/test.py`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flewisgaul%2Fpython_adt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flewisgaul%2Fpython_adt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flewisgaul%2Fpython_adt/lists"}