4 ms·
Show HN: PHPunctional, a PHP Functional Programming Library
- ben_pr 11y agoNice work! I'll have to explore a bit more.
- gmack 11y agoSo, when does P#P come out?
- johnmaguire2013 11y agoI've been considering PCP... PHP: Compiled Perl. Eseentially, you write Perl but get PHP. Or vice-versa. Doesn't really matter because it's a joke anyway.
- nine_k 11y agoQuite jolly! I hope that performance impact is negligible. 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.
- r-cyr 11y agoI will try to profile it soon but basically, until now, it was more about "what's possible" than "how fast can I make it" kind of project. Also, that exception-handling either is a great idea, thank you.
- rjbrock 11y agoYou should definitely add a link to your examples in your README. For anyone else looking, they are located here: https://github.com/r-cyr/PHPunctional/tree/master/P/Examples https://github.com/r-cyr/PHPunctional/tree/master/P/Examples
- r-cyr 11y agoThank you, just added the link to the README like you suggested
- mfonda 11y agoAnother awesome functional library / extension for PHP is https://github.com/lstrojny/functional-php https://github.com/lstrojny/functional-php
- V-2 11y agohttps://github.com/r-cyr/PHPunctional/blob/master/P/Examples/Fun.php https://github.com/r-cyr/PHPunctional/blob/master/P/Examples... 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
- mambodog 11y agoYou could improve the usability of this library (or FP in PHP in general), by implementing 'string lambdas' such as those found in Oliver Steele's Functional.js[0], which was a clever, if controversial, workaround for Javascript's lack of a concise anonymous function syntax at the time. 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. [0] http://osteele.com/sources/javascript/functional/ http://osteele.com/sources/javascript/functional/
- widmogrod 11y agoHave you seen this project? https://github.com/widmogrod/php-functional https://github.com/widmogrod/php-functional Tackle problem same problem as your library, also in PHP.