dev-master
9999999-devFunctional programming tools for PHP
MIT
The Development Requires
by Carlos Gottberg
Functional programming tools for PHP
A small library porting tools from functional world (tm) to PHP. This is an ongoing effort and I'm doing it while learning about FP, along with category theory., (*1)
I've written a few tests. All functions are curried., (*2)
use CLinoge\Functional\F; function myFunction(... $args) { $myFunction = F::curry(function($arg1, $arg2) { // Operate on $arg1 and $arg2 return $result; }); return call_user_func_array($myFunction, $args); }
There's basic support for IO, Maybe and Left/Right. Their implementation is based upon the ideas exposed in the Mostly Adequate Guide by Dr. Boolean and RamdaJS, (*3)
For a curried function n-ary f the following holds true:, (*4)
use CLinoge\Functional\Placeholder; f(a1, a2, ..., a(N - 1), aN) == f(a1, new Placeholder, ..., new Placeholder, aN)(a2)(a(N-1));
Experimental feature, you can test it:, (*5)
use CLinoge\Functional\CurryTransform; $constructor = CurryTransform::take(SomeClass::class); $object = $constructor(a1, a2, ..., aN); $object->someMethod($a1)($a2) == $object->someMethod($a1, $a2);
Add docs, improve perfomance, write tests :-). I'm improving this day by day and haven't still reached stable ^^., (*6)
Functional programming tools for PHP
MIT