Fairbairn threshold

From HaskellWiki
Revision as of 19:41, 23 February 2019 by Hvr (talk | contribs)

Jump to: navigation, search

Fairbairn Threshold

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.