ikr/fyrfyrfyr

Basic tools for composing functions, to write simpler and safer programs

v0.1.0 2016-05-13 14:10 UTC

This package is not auto-updated.

Last update: 2024-04-13 16:01:54 UTC


README

Build Status

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.

fox logo

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