zlacker

[parent] [thread] 2 comments
1. AdieuT+(OP)[view] [source] 2024-08-28 23:39:43
If anyone is interested in the theoretical background to the thrush combinator, a.k.a. "|>", here is one using Ruby as the implementation language:

https://leanpub.com/combinators/read#leanpub-auto-the-thrush

Being a concept which transcends programming languages, a search for "thrush combinator" will yield examples in several languages.

replies(1): >>wslh+Jd
2. wslh+Jd[view] [source] 2024-08-29 01:50:38
>>AdieuT+(OP)
I find this [1] from this [2]. Seems like a good explanation. It doesn't exist on Wikipedia though.

[1] https://github.com/raganwald-deprecated/homoiconic/blob/mast...

[2] https://stackoverflow.com/a/285973/88231

replies(1): >>AdieuT+4m
◧◩
3. AdieuT+4m[view] [source] [discussion] 2024-08-29 03:23:21
>>wslh+Jd
A key thing to keep in mind is that the thrush combinator is a fancy name for a simple construct. The semantics it provides is a declarative form of traditional function composition.

For example, given the expression:

  f (g (h (x)))
The same can be expressed in languages which support the "|>" infix operator as:

  h (x) |> g |> f
There are other, equivalent, constructs such as the Cats Arrow[0] type class available in Scala, the same Arrow[1] concept available in Haskell, and the `andThen` method commonly available in many modern programming languages.

0 - https://typelevel.org/cats/typeclasses/arrow.html

1 - https://wiki.haskell.org/Arrow_tutorial

[go to top]