3 ms·
Yes, that's right. Infix function names (anything made of symbols or delimited by backticks) are allowed on the LHS of a defining equation. An alternative synta
by ionfish 16y ago
Yes, that's right. Infix function names (anything made of symbols or delimited by backticks) are allowed on the LHS of a defining equation. An alternative syntax for this function would be this:
(|>) f x = f x
The parentheses just serve to denote an infix operator being used in a prefix way.
A type signature makes this clearer:
(|>) :: a -> (a -> b) -> b
As you can see, (|>) is a function which accepts an argument of type a, a function which takes an argument of type a and returns something of type b, and returns something of type b. In this way it's just a flipped version of the application operator ($), which has this type:
($) :: (a -> b) -> a -> b