{"id":16098961,"url":"https://github.com/hellerve/hawkweed","last_synced_at":"2025-03-18T07:30:56.385Z","repository":{"id":57436881,"uuid":"60630926","full_name":"hellerve/hawkweed","owner":"hellerve","description":"Yet another implementation of missing functions for Python","archived":false,"fork":false,"pushed_at":"2017-05-06T12:06:55.000Z","size":265,"stargazers_count":20,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-07T09:05:22.503Z","etag":null,"topics":["currying","datastructures","functional","monads"],"latest_commit_sha":null,"homepage":null,"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/hellerve.png","metadata":{"files":{"readme":"README.rst","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":"2016-06-07T16:57:52.000Z","updated_at":"2024-11-25T01:17:59.000Z","dependencies_parsed_at":"2022-09-10T05:40:33.139Z","dependency_job_id":null,"html_url":"https://github.com/hellerve/hawkweed","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellerve%2Fhawkweed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellerve%2Fhawkweed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellerve%2Fhawkweed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellerve%2Fhawkweed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hellerve","download_url":"https://codeload.github.com/hellerve/hawkweed/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243910715,"owners_count":20367538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["currying","datastructures","functional","monads"],"created_at":"2024-10-09T18:25:12.985Z","updated_at":"2025-03-18T07:30:55.848Z","avatar_url":"https://github.com/hellerve.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nhawkweed\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() # =\u003e List([1, 2, 3, 4])\n    List(range(10)).take(5) # =\u003e generator from 0 to 4\n    List(range(10)).drop(5) # =\u003e generator from 5 to 9\n    List(range(10)).take_while(lambda x: x \u003c 5) # =\u003e generator from 0 to 4\n    List(range(10)).drop_while(lambda x: x \u003c 5) # =\u003e generator from 4 to 9\n    List(range(10)).nth(3) # =\u003e generator yielding 0, 3, 6 and 9 (lazily); works with any subclass of Iterable\n    List(range(10)).reset(range(5)) # =\u003e List([0, 1, 2, 3, 4])\n\n    Dict({1: 2, 3: 4}).reverse() # =\u003e Dict({2: 1, 4: 3})\n    Dict({1: 2, 3: 4, 2: None}).remove_empty() # =\u003e Dict({1: 2, 3: 4})\n    Dict({1: 2, 3: 4, None: \"go away\"}).remove_empty(filter_keys=True) # =\u003e Dict({1: 2, 3: 4})\n    Dict({1: 2, 3: 4, 2: 3}).remove_empty(fun=lambda x: x!=2) # =\u003e Dict({1: 2, 3: 4})\n    Dict({1: 2, 3: 4}).reduce(fun=lambda acc, k, v: acc + k + v, acc=0) # =\u003e 10\n    Dict({1: 2, 3: 4}).reduce(fun=lambda acc, k, v: acc + (k, v)) # =\u003e (1, 2, 3, 4)\n    Dict({1: 2, 3: 4, 5: 6}).pick(1, 5) # =\u003e Dict({1: 2, 5: 6})\n\n    Set({1, 2, 3, 4}).remove_empty(fun=lambda x: x!=3) # =\u003e 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\") # =\u003e \"baz\"\n    Dict({\n      \"foo\": List([1, 2, 3, Dict({\"bar\": \"baz\"})])\n    }).get_in(\"foo\", 100, \"bar\") # =\u003e None\n    Dict({\n      \"foo\": List([1, 2, 3, Dict({\"bar\": \"baz\"})])\n    }).get_in(\"foo\", 100, \"bar\", dflt=\"i am a default value\") # =\u003e \"i am a default value\"\n    Dict({\n      \"foo\": List([1, 2, 3, Dict({\"bar\": \"baz\"})])\n    }).update_in(\"foo\", 1, \"bar\", to=\"update\") # =\u003e 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)) # =\u003e range(1, 101)\n  incrementor = map(inc)\n  incrementor(List(range(100))) # =\u003e range(1, 101)\n  summator = reduce(add)\n  summator(range(5)) # =\u003e 10\n  all(lambda x: x \u003e 100, [101, 102, 103]) # =\u003e True\n  any(lambda x: x \u003e 10, [3, 5, 8]) # =\u003e False\n  constantly(10) # =\u003e an infinite generator of 10\n  delayed = delay(print, 'Hello, World!') # =\u003e 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()) # =\u003e Just(11)\n  \n  wrapM(Just(10)).real\n  # =\u003e 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!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellerve%2Fhawkweed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhellerve%2Fhawkweed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellerve%2Fhawkweed/lists"}