{ "info": { "author": "Jaden Geller", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Intended Audience :: Education", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries" ], "description": "Monadic Do-Notation\r\n-------------------\r\n\r\nGuac provides monadic do-notation, inspired by Haskell, in Python. Monads provide \"programmable semicolons\" by which the behavior of programs can be changed. A common, useful monad is the list monad, which represents non-deterministic computations. The list monad makes it very easy to write backtracking searches.\r\n\r\nRequirements\r\n-------------\r\n\r\nGuac requires an implementation of Python 3 that supports ``copy.deepcopy`` on generator functions. The most common distribution, CPython, is lacking this feature, but pypy implements it!\r\n\r\nExample\r\n--------\r\n\r\nHere's an example that computes all the possible ways you can give $0.47 change with pennies, nickels, dimes, and quarters:\r\n\r\n.. code:: python\r\n\r\n from guac import *\r\n \r\n @monadic(ListMonad)\r\n def make_change(amount_still_owed, possible_coins):\r\n change = []\r\n \r\n # Keep adding coins while we owe them money and there are still coins.\r\n while amount_still_owed > 0 and possible_coins:\r\n \r\n # \"Nondeterministically\" choose whether to give anther coin of this value.\r\n # Aka, try both branches, and return both results.\r\n give_min_coin = yield [True, False]\r\n \r\n if give_min_coin:\r\n # Give coin\r\n min_coin = possible_coins[0]\r\n change.append(min_coin)\r\n amount_still_owed -= min_coin\r\n else:\r\n # Never give this coin value again (in this branch!)\r\n del possible_coins[0]\r\n \r\n # Did we charge them the right amount?\r\n yield guard(amount_still_owed == 0)\r\n \r\n # Lift the result back into the monad.\r\n yield lift(change)\r\n \r\n print(make_change(27, [1, 5, 10, 25]))\r\n\r\nRunning this program will print a list of lists, each list containing a different set of numbers that add up to 27. You can imagine lots of cool ways this could be used, from unification to parsing!\r\n\r\nTo learn more, check out the README.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/JadenGeller/Guac/archive/1.0.0.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/JadenGeller/Guac", "keywords": "monad,monadic,coroutine,generator,pypy,backtracking", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "guac", "package_url": "https://pypi.org/project/guac/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/guac/", "project_urls": { "Download": "https://github.com/JadenGeller/Guac/archive/1.0.0.tar.gz", "Homepage": "https://github.com/JadenGeller/Guac" }, "release_url": "https://pypi.org/project/guac/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "Hakell-inspired monadic do-notation in Python", "version": "1.0.0" }, "last_serial": 2856612, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "46236af70264f9418dfc73b0b368bff6", "sha256": "979c209ce91cfa81d24968e682f1fff640e9b58ff6bd40e4fb41ed61a4ece0f1" }, "downloads": -1, "filename": "guac-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "46236af70264f9418dfc73b0b368bff6", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 6480, "upload_time": "2017-05-07T02:39:31", "url": "https://files.pythonhosted.org/packages/49/5f/12b61bb6fc640ecd3e74021adc9c05b7e6f9d1d22e4ee64800d87ae7b408/guac-1.0.0-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "46236af70264f9418dfc73b0b368bff6", "sha256": "979c209ce91cfa81d24968e682f1fff640e9b58ff6bd40e4fb41ed61a4ece0f1" }, "downloads": -1, "filename": "guac-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "46236af70264f9418dfc73b0b368bff6", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 6480, "upload_time": "2017-05-07T02:39:31", "url": "https://files.pythonhosted.org/packages/49/5f/12b61bb6fc640ecd3e74021adc9c05b7e6f9d1d22e4ee64800d87ae7b408/guac-1.0.0-py3-none-any.whl" } ] }