Show HN: PHPunctional, a PHP Functional Programming Library
github.com
github.com
Readable? Concise? Esthetical? :)
FP with PHP is like putting a saddle on a cow.
Interesting as an experiment, but I can't really imagine using it in production - I can't imagine someone preferring to have this version of Fibonacci in their codebase over whatever any sane programmer would write instead
For anyone else looking, they are located here: https://github.com/r-cyr/PHPunctional/tree/master/P/Examples
For example
function($n) use ($partial) { return $partial($n - 1) + $partial($n - 2);
could become 'partial(n - 1) + partial(n - 2)'
Compiling the string lambda to a function can be memoized with the string itself as the key (as many regex implementations do with the regex text) so each is only ever compiled once.Now it would be nice to make a wrapper to convert exception-throwing calls into Either-returning calls (or it's there and I missed it?). This would help with accessing standard / third-party libraries.
Tackle problem same problem as your library, also in PHP.
Eseentially, you write Perl but get PHP. Or vice-versa. Doesn't really matter because it's a joke anyway.