by tomgg · 12y ago · 0 comments
x |> a|> b |> c|>s->d(s,y)|>e|>...
in julia instead of e(d(c(b(a(x))),y)) or (e (d (c (b (a x)) y))
...or whatever is your flavour. I reckon it is impossible to make a serious case against that readability gain.[1] julialang.org
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.