3 ms·
I don't know Haskell very well, but I assume you're defining an |> function? If so that's pretty neat. Haskell's flexibility always impresses me. I think the F#
by overgard 16y ago
I don't know Haskell very well, but I assume you're defining an |> function? If so that's pretty neat. Haskell's flexibility always impresses me. I think the F# version generally assumes one argument too, though I think you could use partial function application to work with multiple parameters.
- ionfish 16y agoYes, 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