Skip to content

The aviary

All 36 combinators, grouped by what they do. Definitions are read directly from the TSDoc in src/birds/, so this table cannot drift from the implementations.

Every bird is curried: B(f)(g)(x), never B(f, g, x). Each is exported under its symbol, its bird name, and its familiar FP name where one exists — all aliases of a single implementation.

Identity and constants

BirdSymbolDefinitionAlso exported as
IdiotII x = xidiot, identity
KestrelKK x y = xkestrel, constant
KiteKIKI x y = ykite

Composition

BirdSymbolDefinitionAlso exported as
BluebirdBB f g x = f (g x)bluebird, compose
BlackbirdB1B1 f g x y = f (g x y)blackbird, compose2
BuntingB2B2 f g x y z = f (g x y z)bunting
BecardB3B3 f g h x = f (g (h x))becard, compose3
Queer birdQQ f g x = g (f x)queer, pipe2

Argument manipulation

BirdSymbolDefinitionAlso exported as
CardinalCC f x y = f y xcardinal, flip
WarblerWW f x = f x xwarbler, duplicate
ThrushTT x f = f xthrush, applyTo
RobinRR x f y = f y xrobin
FinchFF x y f = f y xfinch
VireoVV x y f = f x yvireo, pair
HummingbirdHH f x y = f x y xhummingbird
JayJJ f x y z = f x (f z y)jay

Application and convergence

BirdSymbolDefinitionAlso exported as
StarlingSS f g x = f x (g x)starling, ap
Psi birdΨΨ f g x y = f (g x) (g y)P, on
PhoenixΦΦ f g h x = f (g x) (h x)Phi, converge
GoldfinchGG f g x y = f y (g x)goldfinch

The Q-birds

BirdSymbolDefinitionAlso exported as
Quixotic birdQ1Q1 f g x = f (x g)quixotic
Quizzical birdQ2Q2 f g x = g (x f)quizzical
Quirky birdQ3Q3 f g x = x (f g)quirky
Quacky birdQ4Q4 f g x = x (g f)quacky

The D-birds

BirdSymbolDefinitionAlso exported as
DoveDD f x g y = f x (g y)dove
DickcisselD1D1 f x y g z = f x y (g z)dickcissel
DovekiesD2D2 f g x h y = f (g x) (h y)dovekies
EagleEE f x g y z = f x (g y z)eagle

Once removed

BirdSymbolDefinitionAlso exported as
Idiot once removedI*I* f x = f xidiotOnceRemoved, apply
Warbler once removedW*W* f x y = f x y ywarblerOnceRemoved
Cardinal once removedC*C* f x y z = f x z ycardinalOnceRemoved

The hard forest

These five involve self-application and are not typeable in a simply-typed lambda calculus. See Where the types give out for how TypeScript expresses them and what it costs.

BirdSymbolDefinitionAlso exported as
MockingbirdMM x = x xmockingbird
LarkLL x y = x (y y)lark
OwlOO f g = g (f g)owl
Turing birdUU x y = y (x x y)turing
Sage birdYY f = f (Y f)sage, fix

Full signatures

Every combinator's complete type, TSDoc and examples are in the API reference.

Laws

These identities are asserted as property tests, so the implementations must agree with each other:

text
S K K   ≡ I          W K ≡ I            C (C f) ≡ f
KI      ≡ C K        KI  ≡ K I          T       ≡ C I
Q       ≡ C B        O   ≡ S I          C*      is its own inverse
D2 f g g ≡ Ψ f g     B3 f g h ≡ B (B f g) h
V a b K ≡ a          V a b KI ≡ b

Note what is absent: the classical B1 ≡ B B B is true at runtime but not expressible in TypeScript. See Where the types give out.

MIT licensed.