{"id":17048205,"url":"https://github.com/segfaultax/pyeither","last_synced_at":"2026-02-25T20:01:46.244Z","repository":{"id":57470236,"uuid":"117177631","full_name":"SegFaultAX/pyeither","owner":"SegFaultAX","description":"An implementation of Data.Either from Haskell in Python","archived":false,"fork":false,"pushed_at":"2018-01-30T21:54:42.000Z","size":34,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-28T04:53:04.461Z","etag":null,"topics":["applicative","either","functional-programming","functional-python","functor","haskell","monad","python"],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","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/SegFaultAX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-12T01:50:54.000Z","updated_at":"2018-02-05T07:36:53.000Z","dependencies_parsed_at":"2022-09-19T14:36:18.264Z","dependency_job_id":null,"html_url":"https://github.com/SegFaultAX/pyeither","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/SegFaultAX/pyeither","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SegFaultAX%2Fpyeither","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SegFaultAX%2Fpyeither/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SegFaultAX%2Fpyeither/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SegFaultAX%2Fpyeither/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SegFaultAX","download_url":"https://codeload.github.com/SegFaultAX/pyeither/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SegFaultAX%2Fpyeither/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29837434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T19:08:47.527Z","status":"ssl_error","status_checked_at":"2026-02-25T18:59:04.705Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["applicative","either","functional-programming","functional-python","functor","haskell","monad","python"],"created_at":"2024-10-14T09:51:19.927Z","updated_at":"2026-02-25T20:01:46.225Z","avatar_url":"https://github.com/SegFaultAX.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyeither\n\nA functional Python library that exposes `Data.Either` from Haskell.\n\n```haskell\ndata Either e a = Left e | Right a\n```\n\n## Example Usage\n\n```python\nimport os\nimport json\nimport either\n\ndef main():\n    path = \"~/myfile.json\"\n    \n    # Lift a normal value into Either\n    e_path = either.pure(path)\n\n    # Ensure the path is valid, returning Right(path) if it is or Left(\"not a file\") if it isn't\n    e_valid = e_path.bind(either.predicate(os.path.isfile, \"not a file\"))\n\n    # Load a file as json, returning Right(contents) if it works, or Left(exc) if it doesn't\n    e_data = e_valid.bind(lambda p: either.attempt(json.load, p))\n\n    # It's annoying to assign intermediate values to variables, so you can chain expressions\n    # Equivalent to above:\n\n    e_data2 = (either.pure(path)\n        .bind(either.predicate(os.path.isfile, \"not a file\"))\n        .bind(lambda p: either.attempt(json.load, p)))\n\n    # Python lacks do-notation, so there's not a nice equivalent syntax\n\n    # Build pipelines of actions using monadic composition\n\n    ensure_path = either.predicate(os.path.isfile, \"not a file\")\n    load_file = lambda p: either.attempt(json.load, p)\n\n    process = either.kleisli(ensure_path, load_file)\n\n    # Equivalent to above:\n    e_data3 = either.pure(path).bind(process)\n```\n\n## Getting pyeither\n\n```\npip install pyeither\n```\n\n## Motivation\n\nI've created an IPython Notebook that describes the motivation for this project\nas an interactive tutorial building an analogous system from scratch. If you're\ninterested in learning more about the **why** of this project, please check it\nout!\n\n[**Motivation Notebook**](https://github.com/SegFaultAX/pyeither/blob/master/pyeither_demo.ipynb)\n\n## Special Thanks\n\nThis library depends on the absolutely wonderful\n[`attrs`](http://www.attrs.org/en/stable/) library, without which there would\nhave been far more ugly boilerplate.\n\n## License\n\nCopyright 2018 Michael-Keith Bernard \n\nSee LICENSE.txt for the full license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsegfaultax%2Fpyeither","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsegfaultax%2Fpyeither","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsegfaultax%2Fpyeither/lists"}