{ "info": { "author": "Michael-Keith Bernard", "author_email": "mkbernard.dev@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3" ], "description": "# 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.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/segfaultax/pyeither", "keywords": "either haskell data.either monad applicative functor", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pyeither", "package_url": "https://pypi.org/project/pyeither/", "platform": "", "project_url": "https://pypi.org/project/pyeither/", "project_urls": { "Homepage": "https://github.com/segfaultax/pyeither" }, "release_url": "https://pypi.org/project/pyeither/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "An implementation of Data.Either from Haskell in Python", "version": "0.1.1" }, "last_serial": 3536499, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "5b525c0a1de61cf3961b80da0d1fd005", "sha256": "a6d2cefacbf3bfb7e9e3dee26f4fd7dafdb79659ab21d79ab97792a59166f74a" }, "downloads": -1, "filename": "pyeither-0.0.1.tar.gz", "has_sig": false, "md5_digest": "5b525c0a1de61cf3961b80da0d1fd005", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5610, "upload_time": "2018-01-12T01:49:31", "url": "https://files.pythonhosted.org/packages/51/b8/b0ad6beeb62f03f9bf5f47044fc47d72b50d4cbd6932a9731f5c2f0ffe8f/pyeither-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "bb82d44dd2a672d166891aa866df0807", "sha256": "6382bdab5e4cc424af2cf92074cedc4863bd739786eac893b7fc2d8b70f8cfb3" }, "downloads": -1, "filename": "pyeither-0.0.2.tar.gz", "has_sig": false, "md5_digest": "bb82d44dd2a672d166891aa866df0807", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4512, "upload_time": "2018-01-12T03:29:06", "url": "https://files.pythonhosted.org/packages/48/c3/14e1c56f7c232e5ffd1efb056eeb8cc5b6fa55f9d6bc6110ae1a2833081b/pyeither-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "4d09e3c592ac5cc63ae048fd6ea3718a", "sha256": "3c38a169d7227a7435c502afab1d9e160ee74b5cbaadcbc846a0df3990e15462" }, "downloads": -1, "filename": "pyeither-0.0.3.tar.gz", "has_sig": false, "md5_digest": "4d09e3c592ac5cc63ae048fd6ea3718a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5286, "upload_time": "2018-01-15T07:29:10", "url": "https://files.pythonhosted.org/packages/81/85/d7b6c8e092032f669621381148d76350b73b1d5450c87f85598e70642525/pyeither-0.0.3.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "672a4a26d83e4ee0ec05ce3efcab9976", "sha256": "8b966abda52cdad50f30ba331fcfcd0b9ff2fe70addc0dc80a6c5db42b85623c" }, "downloads": -1, "filename": "pyeither-0.1.0.tar.gz", "has_sig": false, "md5_digest": "672a4a26d83e4ee0ec05ce3efcab9976", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5867, "upload_time": "2018-01-30T02:36:58", "url": "https://files.pythonhosted.org/packages/55/ba/8160cf17a48e8d85bfaafb9b88d7f822dd2e77f54108498ff99ebca4574a/pyeither-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "d97de96748459c7e04da707fc16f2894", "sha256": "94b81cfee95babe28e00ece54f376969d48e0721bc9ba109e90a5aa1e1393cbc" }, "downloads": -1, "filename": "pyeither-0.1.1.tar.gz", "has_sig": false, "md5_digest": "d97de96748459c7e04da707fc16f2894", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7563, "upload_time": "2018-01-30T21:54:03", "url": "https://files.pythonhosted.org/packages/03/eb/f3aa3a384c1e9548e77c24ecc81944b1076ad9fdfc343bc9237e45be2708/pyeither-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d97de96748459c7e04da707fc16f2894", "sha256": "94b81cfee95babe28e00ece54f376969d48e0721bc9ba109e90a5aa1e1393cbc" }, "downloads": -1, "filename": "pyeither-0.1.1.tar.gz", "has_sig": false, "md5_digest": "d97de96748459c7e04da707fc16f2894", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7563, "upload_time": "2018-01-30T21:54:03", "url": "https://files.pythonhosted.org/packages/03/eb/f3aa3a384c1e9548e77c24ecc81944b1076ad9fdfc343bc9237e45be2708/pyeither-0.1.1.tar.gz" } ] }