{ "info": { "author": "Veit Heller", "author_email": "veit@veitheller.de", "bugtrack_url": null, "classifiers": [], "description": "hawkweed\n=============\n\nYet another implementation of missing functions.\n\nInstallation\n------------\n\n::\n\n pip install hawkweed\n\nUsage\n-----\n\nhawkweed is roughly divided into three different parts: datatypes, monads and\nfunctions. All the functions are exhaustively documented with pydoc, all the\nparameters, the functions' time complexity (if applicable) and the return value\nare given.\n\nDatatypes\n---------\n\nMost of the datatypes implemented in hawkweed are mere wrappers around Python\nstandard datatypes. If the function does not return anything in the Python\ndatatype, this implementation will return ``self`` to allow for chaining.\n\nA notable exception is the largely unstable and undocumented ``Future`` class.\n\n.. code-block:: python\n\n from hawkweed import List, Dict, Set\n\n List([1]).append(2).extend([3, None, 4]).remove_empty() # => List([1, 2, 3, 4])\n List(range(10)).take(5) # => generator from 0 to 4\n List(range(10)).drop(5) # => generator from 5 to 9\n List(range(10)).take_while(lambda x: x < 5) # => generator from 0 to 4\n List(range(10)).drop_while(lambda x: x < 5) # => generator from 4 to 9\n List(range(10)).nth(3) # => generator yielding 0, 3, 6 and 9 (lazily); works with any subclass of Iterable\n List(range(10)).reset(range(5)) # => List([0, 1, 2, 3, 4])\n\n Dict({1: 2, 3: 4}).reverse() # => Dict({2: 1, 4: 3})\n Dict({1: 2, 3: 4, 2: None}).remove_empty() # => Dict({1: 2, 3: 4})\n Dict({1: 2, 3: 4, None: \"go away\"}).remove_empty(filter_keys=True) # => Dict({1: 2, 3: 4})\n Dict({1: 2, 3: 4, 2: 3}).remove_empty(fun=lambda x: x!=2) # => Dict({1: 2, 3: 4})\n Dict({1: 2, 3: 4}).reduce(fun=lambda acc, k, v: acc + k + v, acc=0) # => 10\n Dict({1: 2, 3: 4}).reduce(fun=lambda acc, k, v: acc + (k, v)) # => (1, 2, 3, 4)\n Dict({1: 2, 3: 4, 5: 6}).pick(1, 5) # => Dict({1: 2, 5: 6})\n\n Set({1, 2, 3, 4}).remove_empty(fun=lambda x: x!=3) # => Set({1, 2, 4})\n\n # And now for something completely different\n Dict({\n \"foo\": List([1, 2, 3, Dict({\"bar\": \"baz\"})])\n }).get_in(\"foo\", 3, \"bar\") # => \"baz\"\n Dict({\n \"foo\": List([1, 2, 3, Dict({\"bar\": \"baz\"})])\n }).get_in(\"foo\", 100, \"bar\") # => None\n Dict({\n \"foo\": List([1, 2, 3, Dict({\"bar\": \"baz\"})])\n }).get_in(\"foo\", 100, \"bar\", dflt=\"i am a default value\") # => \"i am a default value\"\n Dict({\n \"foo\": List([1, 2, 3, Dict({\"bar\": \"baz\"})])\n }).update_in(\"foo\", 1, \"bar\", to=\"update\") # => Dict({\"foo\": List([1, 2, 3, Dict({\"bar\": \"update\"})])})\n # if you want to insert your own datatype, just inherit from hawkweed.Collection\n # and implement get(key, dflt=None) and __setitem__\n\nFunctions\n---------\n\nAll of the functions are standalone and curried whenever possible. They do not depend\non hawkweeds datatypes in any way.\n\n.. code-block:: python\n\n from hawkweed import map, reduce, List, all, any, constantly, delay\n\n map(inc, range(100)) # => range(1, 101)\n incrementor = map(inc)\n incrementor(List(range(100))) # => range(1, 101)\n summator = reduce(add)\n summator(range(5)) # => 10\n all(lambda x: x > 100, [101, 102, 103]) # => True\n any(lambda x: x > 10, [3, 5, 8]) # => False\n constantly(10) # => an infinite generator of 10\n delayed = delay(print, 'Hello, World!') # => this will return a variable that, when called, will compute the result of print with the argument 'Hello, World!'\n # it will cache the result instead of recomputing it upon reevaluation, i.e. `delayed() or delayed()` will only print 'Hello, World!' once\n\nA few other functions that you might expect from a functional programming library (``compose``,\n``pipe``, ``identity``, ``apply``, ``flip``, ``curry`` and the like) are also implemented. They\nshould be intuitive and work as expected. If they do not or are not consider it a bug.\n\nMonads\n------\n\nThe implemented monads are: Identity, Maybe (Just/Nothing), Continuation, Either, IO, CachedIO,\nand List (called ListM). do notation is also supported.\n\n.. code-block:: python\n\n from hawkweed import doM, wrapM, Just\n\n def doMe():\n res1 = yield Just(1)\n res2 = yield Just(10)\n yield Just(res1+ res2)\n\n doM(doMe()) # => Just(11)\n \n wrapM(Just(10)).real\n # => 10; the wrapper will try to call the wrapped values' function whenever it does not exist in the monad\n\nThere is a callcc function and all of the functions in Haskell's Data.Maybe_ and Data.Either_ are implemented.\n\n.. _Data.Maybe: https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Maybe.html\n.. _Data.Either: https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Either.html\n\n\nHave fun!", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/hellerve/hawkweed/tarball/0.1.5", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hellerve/hawkweed", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "hawkweed", "package_url": "https://pypi.org/project/hawkweed/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/hawkweed/", "project_urls": { "Download": "https://github.com/hellerve/hawkweed/tarball/0.1.5", "Homepage": "https://github.com/hellerve/hawkweed" }, "release_url": "https://pypi.org/project/hawkweed/0.1.5/", "requires_dist": null, "requires_python": null, "summary": "Extending Python builtin types", "version": "0.1.5" }, "last_serial": 2421965, "releases": { "0.0.2": [], "0.0.3": [], "0.0.4": [ { "comment_text": "", "digests": { "md5": "6f61034d3997b7d01dd2ac26ff76f132", "sha256": "c20fc5c0a8da7790b6a21981e18cf3c73f6fdf3add829ae68bfb8892214162c6" }, "downloads": -1, "filename": "hawkweed-0.0.4.tar.gz", "has_sig": false, "md5_digest": "6f61034d3997b7d01dd2ac26ff76f132", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7183, "upload_time": "2016-06-09T17:00:40", "url": "https://files.pythonhosted.org/packages/15/4b/2a863c15dbaabbd074665db715fa030e4d01635f60e984e2bbcb117e5911/hawkweed-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "a19579cf2ceace58a99cf0476d94eeb0", "sha256": "871ee125a4fcd52eb19beb74f6e565bcde4f63d7fb5d1efc252d9203af5ca5a7" }, "downloads": -1, "filename": "hawkweed-0.0.5.tar.gz", "has_sig": false, "md5_digest": "a19579cf2ceace58a99cf0476d94eeb0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7601, "upload_time": "2016-06-10T16:43:10", "url": "https://files.pythonhosted.org/packages/63/83/c7f0c19cbf0a3740b913dc633df8209e6085a26063839ba2e3387978e9f6/hawkweed-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "870c2ea12d91671061bdfc432200e07b", "sha256": "31a95124db6138247dd100e009abb57a240135b2e454a723b6757e32b5a382c7" }, "downloads": -1, "filename": "hawkweed-0.0.6.tar.gz", "has_sig": false, "md5_digest": "870c2ea12d91671061bdfc432200e07b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13324, "upload_time": "2016-06-13T17:57:28", "url": "https://files.pythonhosted.org/packages/8c/c1/33245ee23852e8d1547e3b5fe2a5d5917312d3534fba282d2b62abd28541/hawkweed-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "f9609a09a1c0b24350ba7574b5cdcb42", "sha256": "5074d4ba45c9dfe80bf0e1c6d696bfd3e9ab09f8f0adb3dc7f19caa9eec5f2b0" }, "downloads": -1, "filename": "hawkweed-0.0.7.tar.gz", "has_sig": false, "md5_digest": "f9609a09a1c0b24350ba7574b5cdcb42", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15696, "upload_time": "2016-06-16T16:56:56", "url": "https://files.pythonhosted.org/packages/df/a3/26dacdc548751e41fd8f4ef8ca0aedcf52f0bab8c2b229f39a29b4b42fee/hawkweed-0.0.7.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "a9bf2b5487b45478518a76ee165919e1", "sha256": "02f6177fd7aa8abf191a0085ced2e10a7a8bb22dced670e77f0a097bc0cb6979" }, "downloads": -1, "filename": "hawkweed-0.1.0.tar.gz", "has_sig": false, "md5_digest": "a9bf2b5487b45478518a76ee165919e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15758, "upload_time": "2016-07-18T12:43:17", "url": "https://files.pythonhosted.org/packages/ea/89/42b4e5caaa4b85dd8319eafdb614ff2bb6f79ee62b6e9336e98a6ac5635f/hawkweed-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "df5ad560922a7b0ba1b873453fe44a06", "sha256": "1b349d8ceb7d215390950da5cf1ca9d5ba7bf76bd7182e6b2dd6ef1e586d0228" }, "downloads": -1, "filename": "hawkweed-0.1.1.tar.gz", "has_sig": false, "md5_digest": "df5ad560922a7b0ba1b873453fe44a06", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15758, "upload_time": "2016-07-18T12:48:14", "url": "https://files.pythonhosted.org/packages/46/a5/5c5b16ae7f682badb12f7ac6f5f8e0f351075ca05254f2ca6a49af90fb24/hawkweed-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "61b62558f99fd3d505c32333615db045", "sha256": "1fa4a34f88a93cb3e1b66805c30717ac1f9fb1c6f54d039b625ea7567a79f33b" }, "downloads": -1, "filename": "hawkweed-0.1.2.tar.gz", "has_sig": false, "md5_digest": "61b62558f99fd3d505c32333615db045", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15961, "upload_time": "2016-08-04T14:38:56", "url": "https://files.pythonhosted.org/packages/90/60/b86783c89c50c15d84bb6a9572ceab6155d42105ba91f48f62aeb1e15f90/hawkweed-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "00d27ab9fc4f3ee39e294789a4a5e995", "sha256": "c5b8cfd90bb3a04ec89dc107ed4c29fe39baf82c7320290b955925a729c256e7" }, "downloads": -1, "filename": "hawkweed-0.1.3.tar.gz", "has_sig": false, "md5_digest": "00d27ab9fc4f3ee39e294789a4a5e995", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16363, "upload_time": "2016-10-07T13:08:06", "url": "https://files.pythonhosted.org/packages/f1/05/9a94c2414ae0c6961c4444ef185d5ec25b66237dc441967b26bb600649fa/hawkweed-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "2c4bdf8aee7cf830340543491b330eef", "sha256": "45e9f03382985725b86aaaa73cce34b2f21b1a78f1709a3fa90eba3c725f4134" }, "downloads": -1, "filename": "hawkweed-0.1.4.tar.gz", "has_sig": false, "md5_digest": "2c4bdf8aee7cf830340543491b330eef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16481, "upload_time": "2016-10-25T12:47:37", "url": "https://files.pythonhosted.org/packages/07/43/09c5a997224e6073702777a8d1dc971df4340d847310473c68bdaa67b66c/hawkweed-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "720485565ae96307d70bc1ba5f7a4da6", "sha256": "ce12f3eb7a9aef793fdac09466aafbb8e0835683e181c0df567fdaf5b5704164" }, "downloads": -1, "filename": "hawkweed-0.1.5.tar.gz", "has_sig": false, "md5_digest": "720485565ae96307d70bc1ba5f7a4da6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16476, "upload_time": "2016-10-25T12:51:48", "url": "https://files.pythonhosted.org/packages/17/ff/aff034ab7b5660c640f091b215643ad911d51a5a41160c5c5b64c45ed9ea/hawkweed-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "720485565ae96307d70bc1ba5f7a4da6", "sha256": "ce12f3eb7a9aef793fdac09466aafbb8e0835683e181c0df567fdaf5b5704164" }, "downloads": -1, "filename": "hawkweed-0.1.5.tar.gz", "has_sig": false, "md5_digest": "720485565ae96307d70bc1ba5f7a4da6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16476, "upload_time": "2016-10-25T12:51:48", "url": "https://files.pythonhosted.org/packages/17/ff/aff034ab7b5660c640f091b215643ad911d51a5a41160c5c5b64c45ed9ea/hawkweed-0.1.5.tar.gz" } ] }