In Haskell there are two varieties on this. "Apply" and "compose":
f (g (h x)) == f $ g $ h $ x
== f . g . h $ x
\x -> f (g (h x)) == f . g . h
The "compose" combinator, (.), is especially pertinent for making pipelines. Idiomatic Haskell code uses it constantly---especially for its natural mechanism of eliminating "points" like that `x` above. These are usually better described by their type than any variable name given (especially since the variable name cannot be machine checked for meaningfulness, unlike the type) and so are best eliminated.In many libraries there is also a reverse apply function defined, often as &
f (g (h x)) == x & h & g & f
== x & f . g . h
which is more popular when using other operator chains to describe functions as in lens.F# and OCaml uses this forward pipe operator as well. It's very useful and makes the flow much more apparent, in other words, it increases readability, a lot.
I'll add to the list of replies with languages with this feature: Hylang, the "Lisp-stick on a Python", where it is called the "threading macro".
Re:Pipes and Filters
by icebraining on Wednesday September 17, 2014 @09:36AM
(#8329844)
There's a Python lib that implements it: https://github.com/JulienPalard/Pipe
Re:Pipes and Filters
by lostcolony on Wednesday September 17, 2014 @08:58AM
(#8329714)
Elixir has the same syntax for the same operator.
[1] julialang.org