Using functional design to reduce arity

There are a lot of confused explanations for partial application and currying.

I’m going back to why currying was invented in the first place:

Haskell book, p.10:

Each lambda can only bind one parameter and can only accept one argument. Functions that require multiple arguments have multiple, nested heads. When you apply it once and eliminate the first (leftmost) head, the next one is applied and so on. This formulation was originally discovered by Moses Schönfinkel in the 1920s but was later rediscovered and named after Haskell Curry and is commonly called currying.

In partial application you start with a function with multiple parameters and each partial application provides some of the arguments, creating a function with the remaining unapplied parameters.

Example language implementations:
Clojure
JavaScript

The point being - when performing partial application one of the arguments is usually the function that is subject to partial application.

FYI: SRP is misnamed:

Gather together those things that change for the same reason, and separate those things that change for different reasons.

So it’s about “reasons to change” rather than “single responsibility”.

I recommend watching
YOW! 2013 Kevlin Henney - The SOLID Design Principles Deconstructed

2 Likes