{"id":37001426,"url":"https://github.com/phpfn/curry","last_synced_at":"2026-01-14T00:10:29.528Z","repository":{"id":57040397,"uuid":"129454862","full_name":"phpfn/curry","owner":"phpfn","description":"[READONLY] Convenient implementation of function currying and partial application","archived":false,"fork":false,"pushed_at":"2020-11-22T21:18:15.000Z","size":20,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-04T04:24:37.481Z","etag":null,"topics":["curry","functional","partial-application","php"],"latest_commit_sha":null,"homepage":"https://github.com/phpfn/phpfn","language":"PHP","has_issues":false,"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/phpfn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-13T21:23:51.000Z","updated_at":"2022-10-11T13:09:37.000Z","dependencies_parsed_at":"2022-08-23T23:30:39.120Z","dependency_job_id":null,"html_url":"https://github.com/phpfn/curry","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/phpfn/curry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpfn%2Fcurry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpfn%2Fcurry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpfn%2Fcurry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpfn%2Fcurry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpfn","download_url":"https://codeload.github.com/phpfn/curry/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpfn%2Fcurry/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["curry","functional","partial-application","php"],"created_at":"2026-01-14T00:10:28.938Z","updated_at":"2026-01-14T00:10:29.501Z","avatar_url":"https://github.com/phpfn.png","language":"PHP","readme":"# Curry\n\nConvenient implementation of function \ncurrying and partial application.\n\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Left currying](#left-currying)\n    - [Right currying](#right-currying)\n    - [Partial application](#partial-application)\n- [Api](#api)\n    - [Functions](#functions)\n    - [Methods of the curried function](#curried)\n\n## Installation\n\nLibrary can be installed into any PHP application:\n- Using [`Composer`](https://getcomposer.org/) dependency manager \n- [The Force](https://www.youtube.com/watch?v=o2we_B6hDrY) for the Jedi Developers\n\n```sh\n$ composer require phpfn/curry\n```\n\nIn order to access library make sure to include `vendor/autoload.php` \nin your file.\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n```\n\n## Usage\n\n### Left currying\n\nThe left currying can be perceived as adding arguments to an array. \nAnd then applying this array of arguments to the function.\n\n\nThe left currying returns the partially applied function \nfrom the first argument.\n\n```php\n$fn = \\curry(function($a, $b) { return $a + $b; });\n\n$fn(3);      // ($a = 3) + ($b = ?)\n$fn(3)(4);   // ($a = 3) + ($b = 4)\n```\n\n### Right currying\n\nAt the same time, right-hand currying can be \nperceived as adding arguments to the right.\n\n```php\n$fn = \\rcurry(function($a, $b) { return $a + $b; });\n\n$fn(3);      // ($a = ?) + ($b = 3)\n$fn(3)(4);   // ($a = 4) + ($b = 3)\n```\n\n### Partial application\n\nPartial application is when you can specify completely \nrandom arguments, skipping unnecessary using placeholder `_`.\n\n```php\n$fn = \\curry(function($a, $b, $c) { return $a + $b * $c; });\n\n$fn = $fn(_, 3, 4); // ($a = ?)  + ($b = 3) * ($c = 4)\necho  $fn(42);      // ($a = 42) + ($b = 3) * ($c = 4)\n```\n\n```php\n$fn = \\curry(function($a, $b, $c) { return $a + $b * $c; });\n\n$fn = $fn(_, 3, _); // ($a = ?)  + ($b = 3) * ($c = ?)\n$fn-\u003elcurry(42);    // ($a = 42) + ($b = 3) * ($c = ?)\n$fn-\u003ercurry(23);    // ($a = ?)  + ($b = 3) * ($c = 23)\n```\n\n```php\n$fn = \\curry(function($a, $b, $c) { return $a + $b * $c; });\n\n$sum  = $fn(7, 9);    // 7 + 9 * ?\n$sum(6);              // 7 + 9 * 6 \n\n$mul  = $fn(_, 7, 9); // ? + 7 * 9\n$mul(6);              // 6 + 7 * 9\n\n$test = $fn(_, 7, _); // ? + 7 * ?\n$test(6);             // 6 + 7 * ? \n\n$test = $fn(_, 7);    // ? + 7 * ?\n$test-\u003ercurry(6);     // ? + 7 * 6 \n```\n\n## Api\n\n### Functions\n\n- `lcurry(callable $fn, ...$args): Curried` or `curry`\n\u003e Left currying (like array_push arguments)\n\n- `rcurry(callable $fn, ...$args): Curried` \n\u003e Right currying\n\n- `uncurry(callable $fn): mixed`\n\u003e Returns result or partially applied function\n\n\n### Curried\n\n- `$fn-\u003e__invoke(...$args)` or `$fn(...$args)`\n\u003e The magic method that allows an object to a callable type\n\n- `$fn-\u003elcurry(...$args)`\n\u003e A method that returns a new function with left currying\n\n- `$fn-\u003ercurry(...$args)`\n\u003e A method that returns a new function with right currying\n\n- `$fn-\u003ereduce()`\n\u003e Reduction of the composition of functions. Those. bringing the function to a single value - the result of this function.\n\n- `$fn-\u003euncurry()`\n\u003e An attempt is made to reduce, or bring the function to another, which will return the result\n\n- `$fn-\u003e__toString()`\n\u003e Just a function dump\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpfn%2Fcurry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpfn%2Fcurry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpfn%2Fcurry/lists"}