ikr / fyrfyrfyr
Basic tools for composing functions, to write simpler and safer programs
Installs: 21 096
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is not auto-updated.
Last update: 2025-03-01 20:50:49 UTC
README
About
Basic tools for composing functions, to write simpler and safer programs in PHP 5.4+. Heavily inspired by @drboolean's book, the Ramda library, and the Fantasy Land JS project.
Why?
This library grew out of frustration with old PHP code I have to maintain. I'm convinced that functional programming can lead us Out of the Tar Pit. I do know about Phamda and Pramda; very cool projects, but they both require PHP 5.6+. Then, I was also not 100% on board with some design choices those 2 make. I'd like to keep fyr-fyr-fyr tiny and lean, away from all sorts of cruft and magic. In many ways that's a matter of taste though.
API
Constructing functions
Composition
(f⋅g⋅h)(x) <-> f(g(h(x)))
Currying
f(x, y) <-> f(x)(y)
Flipping the arguments
flip
Primary higher order functions
map
chain
reduce
converge
Associative arrays
assoc
assocPath
fromPairs
merge
mergeAll
pick
pickAll
prop
propOr
Lists
append
indexBy
minBy
Utilities
add
always
identity
inc
Algebraic structures
IO
Maybe
Status: WORK IN PROGRESS
Not yet ready for using in production