{"id":21866819,"url":"https://github.com/connor-makowski/pamda","last_synced_at":"2025-04-14T22:22:02.804Z","repository":{"id":57450358,"uuid":"361005930","full_name":"connor-makowski/pamda","owner":"connor-makowski","description":"Functional programming for python","archived":false,"fork":false,"pushed_at":"2025-03-14T18:41:43.000Z","size":2170,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T10:21:20.800Z","etag":null,"topics":["functional-programming","python"],"latest_commit_sha":null,"homepage":"","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/connor-makowski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-23T21:08:00.000Z","updated_at":"2025-03-14T18:41:46.000Z","dependencies_parsed_at":"2025-03-14T19:28:07.494Z","dependency_job_id":"f25196e5-6520-473d-84c0-554c99e9d329","html_url":"https://github.com/connor-makowski/pamda","commit_stats":{"total_commits":61,"total_committers":3,"mean_commits":"20.333333333333332","dds":"0.032786885245901676","last_synced_commit":"f568f41f65cb04c9f7518d818acfd6005522c79a"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/connor-makowski%2Fpamda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/connor-makowski%2Fpamda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/connor-makowski%2Fpamda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/connor-makowski%2Fpamda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/connor-makowski","download_url":"https://codeload.github.com/connor-makowski/pamda/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248969143,"owners_count":21191199,"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":["functional-programming","python"],"created_at":"2024-11-28T05:07:36.781Z","updated_at":"2025-04-14T22:22:02.783Z","avatar_url":"https://github.com/connor-makowski.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pamda\n[![PyPI version](https://badge.fury.io/py/pamda.svg)](https://badge.fury.io/py/pamda)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nPython wrapper for functional programming in object oriented structures.\n\nInspired heavily by [Ramda](https://ramdajs.com/docs/).\n\n\n## Documentation for Pamda Functions\nhttps://connor-makowski.github.io/pamda/pamda/pamda.html\n\n## Key Features\n\n- Simplified functional programming for python\n- Core Functions include:\n  - `curry` arbitrary methods and functions\n  - `thunkify` arbitrary methods and functions\n  - `pipe` data iteratively through n functions\n- List based path access and features for nested dictionaries\n\n\n## Setup\n\nMake sure you have Python 3.9.x (or higher) installed on your system. You can download it [here](https://www.python.org/downloads/).\n\n### Installation\n\n```\npip install pamda\n```\n\n## Getting Started\n\n### Basic Usage\n```py\nfrom pamda import pamda\n\ndata={'a':{'b':1, 'c':2}}\n# Example: Select data given a path and a dictionary\npamda.path(['a','b'])(data) #=\u003e 1\n\n# See documentation for all core pamda functions at\n# https://connor-makowski.github.io/pamda/pamda.html\n```\n\n### Curry Usage\n```py\nfrom pamda import pamda\n\n# Define a function that you want to curry\ndef myFunction(a,b,c):\n    return [a,b,c]\n\n# You can call pamda.curry as a function to curry your functions\ncurriedMyFn=pamda.curry(myFunction)\n\n# Inputs can now be passed in an async fashion\n# The function is evaluated when all inputs are added\nx=curriedMyFn(1,2)\nx(3) #=\u003e [1,2,3]\nx(4) #=\u003e [1,2,4]\n\n# Each set of inputs returns a callable function\n# You can stack inputs on a single line for clean functional programming\ncurriedMyFn(1,2)(3) #=\u003e [1,2,3]\n```\n\nFor enforcing types, pamda relies on [type_enforced](https://github.com/connor-makowski/type_enforced) but curried objects do not play nice with `type_enforced` objects. To fix this, there is a special curry function, `curryType`, that enables type_enforced annotations for your curried functions:\n\n```py\n\u003e\u003e\u003e from pamda import pamda\n\u003e\u003e\u003e \n\u003e\u003e\u003e # Pamda CurryTyped\n\u003e\u003e\u003e @pamda.curryTyped\n... def add(a:int,b:int):\n...     return a+b\n... \n\u003e\u003e\u003e add(1)(1)\n2\n\u003e\u003e\u003e add(1)(1.5)\nTraceback (most recent call last):\n  File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n  File \"/home/conmak/development/personal/pamda/pamda/pamda_curry.py\", line 43, in __call__\n    results = self.__fnExecute__(*new_args, **new_kwargs)\n  File \"/home/conmak/development/personal/pamda/venv/lib/python3.10/site-packages/type_enforced/enforcer.py\", line 90, in __call__\n    self.__check_type__(assigned_vars.get(key), value, key)\n  File \"/home/conmak/development/personal/pamda/venv/lib/python3.10/site-packages/type_enforced/enforcer.py\", line 112, in __check_type__\n    self.__exception__(\n  File \"/home/conmak/development/personal/pamda/venv/lib/python3.10/site-packages/type_enforced/enforcer.py\", line 34, in __exception__\n    raise TypeError(f\"({self.__fn__.__qualname__}): {message}\")\nTypeError: (add): Type mismatch for typed variable `b`. Expected one of the following `[\u003cclass 'int'\u003e]` but got `\u003cclass 'float'\u003e` instead.\n```\n\n\n### Thunkify Usage\n```py\nfrom pamda import pamda\n\n# Define a function that you want to thunkify\n# thunkify can be called as a function or decorator\n@pamda.thunkify\ndef myFunction(a,b,c):\n    return [a,b,c]\n\n# The function is now curried and the evaluation is lazy\n# This means the function is not evaluated until called\nx=myFunction(1,2)\nx(3) #=\u003e \u003cpamda.curry_obj object at 0x7fd514e4c820\u003e\nx(3)() #=\u003e [1,2,3]\n\ny=x(4)\ny() #=\u003e [1,2,4]\n```\n\nThunkified functions can be executed asynchronously.\n\n```py\nfrom pamda import pamda\nimport time\n\n@pamda.thunkify\ndef test(name, wait):\n    print(f'{name} start')\n    time.sleep(wait)\n    print(f'{name} end')\n    return wait\n\nasync_test_a = pamda.asyncRun(test('a',2))\nasync_test_b = pamda.asyncRun(test('b',1))\nasync_test_a.asyncWait()\nasync_test_c = pamda.asyncRun(test('c',1))\n```\n\nThe above code would output:\n```\na start\nb start\nb end\na end\nc start\nc end\n```\n\n### Pipe\n```py\nfrom pamda import pamda\n\ndef square(x):\n    return x**2\n\ndef half(x):\n    return x/2\n\ndef negate(x):\n    return -x\n\n# You can pipe data through multiple functions for clean functional programming\npamda.pipe([square, half, negate])(args=(6,),kwargs={}) #=\u003e -18\n```\n\n### Use pamda as a subclass\n```py\nfrom pamda import pamda\n\nclass myClass(pamda):\n    def myFunction(self, a):\n        return self.inc(a)\n\nmc=myClass()\nmc.myFunction(2) #=\u003e 3\n\n@mc.curry\ndef addUp(a,b):\n    return a+b\n\naddUp(1)(2) #=\u003e 3\n```\n\n## Pamda Utils\n\n- Pamda also ships with a few helpful utilities\n- Check out the documentation here:\n  - https://connor-makowski.github.io/pamda/pamda_utils.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconnor-makowski%2Fpamda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconnor-makowski%2Fpamda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconnor-makowski%2Fpamda/lists"}