Tagged as: fp , php .

by Clement Delafargue on April 1, 2013

These last months, I had to work with PHP. The lack of functional constructs was really a PITA, so I’ve developped a small library to bring burritos to PHP.

Now you can enjoy some ivory-towerish programming style while staying in the real world pragmatic trenches of PHP \o/.

PHPz brings the power and expressiveness of functional programming to the PHP masses. It is heavily inspired from scalaz, which also brings functional constructs to an otherwise imperative language.

Like scalaz, PHPz uses the typeclass pattern to bind new behaviour to existing constructs.

$xs = __t ( array ( "foo" , "foobar" , "foobarqix" )) = __t ( function ( $x ) { return strlen ( $x ); } ) ->map ( function ( $x ) { return array ( $x - 5 , $x , $x + 5 ) ; } ); ->bind print_r ( $xs ());

The code is on github: http://github.com/divarvel/phpz. Enjoy :)

The next step is the implementation of zygohistomorphic prepromorphisms.