|>
or ▹
- Pipe
- The Thrush combinator
- Improved readability for a pipeline of functions.
- Use where the value of one function is fed as an input to the next function.
- Analogous to the UNIX pipe operator (
|
).
##Example
Instead of...
nearby(extractLocations(tweets))
... you can pipe these functions together:
import scalaz.syntax.id._
tweets |> extractLocations |> nearby
where:
tweets
is a value;- the type of that value is expected as a parameter to
extractLocations
; and - the result of
extractLocations
is the input to thenearby
function.
Working with an alternative API, using maps and predicates, you might write:
tweets.flatMap(findLocation).filter(isNearby)
The name "thrush" originates in Raymond Smullyan's To Mock a Mockingbird (and other logic puzzles). From page 100:
"A bird closely related to the cardinal is the thrush," said Bravura. "Why, there is one right over there! A thrush T is defined by the following condition:
Txy = yx
"The thrush is the simplest of the permuting birds," said Bravura. "It is derivable from a cardinal C and an identity bird I. Can you see how?"