Difference between revisions of "Fairbairn threshold"
(Add reference to Jón Fairbairn, email)
|Line 41:||Line 41:|
The Fairbairn threshold is named after Jón Fairbairn, one of the original Haskell committee members. An argument of his that may have originated the term is [https://mail.haskell.org/pipermail/libraries/2006-October/005959.html this email to the libraries mailing list].
Latest revision as of 14:41, 4 May 2020
Quoting Edward Kmett (src):
The Fairbairn threshold is the point at which the effort of looking up or keeping track of the definition is outweighed by the effort of rederiving it or inlining it.
The term was in much more common use several years ago.
Adding every variant on every operation to the Prelude is certainly possible given infinite time, but this of course imposes a sort of indexing overhead mentally.
The primary use of the Fairbairn threshold is as a litmus test to avoid giving names to trivial compositions, as there are a potentially explosive number of them. In particular any method whose definition isn't much longer than its name (e.g. fooBar = foo . bar) falls below the threshold.
There are reasonable exceptions for especially common idioms, but it does provide a good rule of thumb.
The effect is to encourage simple combinators that can be used in multiple situations, while avoiding naming the explosive number of combinations of those combinators.
Given n combinators I can probably combine two of them in something like O(n^2) ways, so without the threshold as a rule of thumb you wind up with a much larger library, but no real greater utility and much higher cognitive overhead to track all the combinations.
Further, the existence of some combinations tends to drive you to look for other ever larger combinations rather than learn how to compose combinators or spot the more general usage patterns yourself, so from a POSIWID perspective, the threshold encourages better use of the functional programming style as well.
The Fairbairn threshold is named after Jón Fairbairn, one of the original Haskell committee members. An argument of his that may have originated the term is this email to the libraries mailing list.