PHPackages                             mckayb/phantasy-recursion-schemes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. mckayb/phantasy-recursion-schemes

ActiveLibrary

mckayb/phantasy-recursion-schemes
=================================

Common recursion schemes implemented in PHP

v1.0.0(7y ago)112MITPHPPHP &gt;=7.1.0

Since Feb 24Pushed 7y ago1 watchersCompare

[ Source](https://github.com/mckayb/phantasy-recursion-schemes)[ Packagist](https://packagist.org/packages/mckayb/phantasy-recursion-schemes)[ RSS](/packages/mckayb-phantasy-recursion-schemes/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Phantasy Recursion Schemes [![CircleCI](https://camo.githubusercontent.com/a1899289cc183aac0546e695c63e7d585861c5f40c640f264c26b0e49c5295b3/68747470733a2f2f636972636c6563692e636f6d2f67682f6d636b6179622f7068616e746173792d726563757273696f6e2d736368656d65732e7376673f7374796c653d737667)](https://circleci.com/gh/mckayb/phantasy-recursion-schemes)[![Coverage Status](https://camo.githubusercontent.com/a320b6898c91c075cffb2595563c274ea1273f56c04a209df1a18a40b50c6c79/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d636b6179622f7068616e746173792d726563757273696f6e2d736368656d65732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/mckayb/phantasy-recursion-schemes)
======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#phantasy-recursion-schemes-)

Common recursion schemes implemented in PHP.

Getting Started
---------------

[](#getting-started)

### Installation

[](#installation)

`composer require mckayb/phantasy-recursion-schemes`

### Usage

[](#usage)

```
// This comes from https://github.com/mckayb/phantasy-types
use function Phantasy\Types\sum;
use function Phantasy\Recursion\cata;

$LL = sum('LinkedList', [
	'Cons' => ['head', 'tail'],
	'Nil' => []
]);
$LL->map = function (callable $f) {
	return $this->cata([
		'Cons' => function ($head, $tail) use ($f) {
			return $this->Cons($head, $f($tail));
 		},
		'Nil' => function () {
			return $this->Nil();
		}
	]);
};
$LL->isNil = function () {
	return $this->cata([
		'Cons' => function ($head, $tail) {
			return false;
		},
		'Nil' => function () {
			return true;
		}
	]);
};
$alg = function ($x) {
	return $x->isNil() ? 0 : $x->head + $x->tail;
};
$a = $LL->Cons(3, $LL->Cons(2, $LL->Cons(1, $LL->Nil())));
echo cata($alg, $a);
// 6
```

For more information, read the [docs!](docs)

What's Included
---------------

[](#whats-included)

- Catamorphisms, Anamorphisms, Hylomorphisms

Contributing
------------

[](#contributing)

Find a bug? Want to make any additions? Just create an issue or open up a pull request.

Want more?
----------

[](#want-more)

For other helpers not included in this repo, check out

- [Phantasy](https://github.com/mckayb/phantasy)
- [Phantasy-PHP](https://github.com/mckayb/phantasy-php)
- [Phantasy-Types](https://github.com/mckayb/phantasy-types)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2631d ago

### Community

---

Top Contributors

[![mckayb](https://avatars.githubusercontent.com/u/1355708?v=4)](https://github.com/mckayb "mckayb (14 commits)")

---

Tags

functionalphantasyphantasy-recursion-schemesphprecursion-schemes

### Embed Badge

![Health badge](/badges/mckayb-phantasy-recursion-schemes/health.svg)

```
[![Health](https://phpackages.com/badges/mckayb-phantasy-recursion-schemes/health.svg)](https://phpackages.com/packages/mckayb-phantasy-recursion-schemes)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
