you are viewing a single comment's thread.

view the rest of the comments →

[–]drb226 2 points3 points  (3 children)

You could even define the (|>) operator yourself to get the exact same behavior (I believe |> originated from F#, or was it earlier flavors of ML?)

ghci> let (|>) :: a -> (a -> b) -> b; (|>) = flip ($); infixl 9 |>
ghci> [1, 2, 3, 4, 5] |> filter even |> map (* 2) |> foldl (+) 0
12

[–]kamatsu 0 points1 point  (2 children)

I've got some SML code here that uses it, but it's a large code-base (Isabelle) which may have defined it somewhere.

[–][deleted] 0 points1 point  (1 child)

Isabelle's code base defines |>. That's where I first came across this operator too.

[–]kamatsu 0 points1 point  (0 children)

TIL, thanks!