DEV Community

Discussion on: First Impressions of F#

Collapse
asik profile image
André Slupik • Edited on

Like you've correctly identified, >> is the composition operator. If you have two functions:

f: A -> B
g: B -> C
Enter fullscreen mode Exit fullscreen mode

Then f >> g is a new function from A to C. Concretely:

let h = f >> g
h(x) = g(f(x))
Enter fullscreen mode Exit fullscreen mode

The pipe operator is just a way to reverse function invocation. Concretely:

f(x) = x |> f
Enter fullscreen mode Exit fullscreen mode

It allows you to write the argument before the function. You'll find this useful in many situations.
In general, the pipe operator is used everywhere (that's where F# gets its logo!); the composition operator sees more limited use. See docs.microsoft.com/en-us/dotnet/fs... - implicit arguments don't play well with tooling, so they are a tool to use sparingly.