News for hackers. Stuff that matters.
Re:Pipes and Filters by tomgg on Wednesday September 17, 2014 @08:21AM (#8329593)
I've been playing around with julia[1] this week and discovered the inclusion of a pipe-like operator that removes a lot of the parentheses from functional programming; you can write,

    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

Re:Pipes and Filters by tel on Wednesday September 17, 2014 @09:13AM (#8329756)
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.
Re:Pipes and Filters by hvidgaard on Wednesday September 17, 2014 @08:49AM (#8329678)
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.
Re:Pipes and Filters by dTal on Wednesday September 17, 2014 @11:47AM (#8330566)
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.