by AdieuToLogic · 1y ago · 0 comments
Essentially, what this combinator does is allow expressing a nested invocation such as:
f(g(h(x)))
To be instead: h(x) |> g |> f
For languages which support defining infix operators.EDIT:
For languages which do not support defining infix operators, there is often a functor method named `andThen` which serves the same purpose. For example:
h(x).andThen(g).andThen(f)
0 - https://leanpub.com/combinators/read#leanpub-auto-the-thrush map : (a -> b) -> a list -> b list
instead of map : a list -> (a -> b) -> b list
The main argument (data to be operated on) is positioned last, after the others which are more like parameters that tune the function.
It's to allow chaining these things up left to right like Unix pipes: map f l |> filter g |> ...The technique of currying method parameters such that the last one is the input to the operation also makes chaining Kleislis[0] quite nice, albeit using a bind operator (such as `>>=`) instead of the Thrush combinator operator (`|>`).
0 - https://bartoszmilewski.com/2014/12/23/kleisli-categories/