ocaml.org
ocaml.org copied to clipboard
Explain why t-first works with labels
To make it possible to write composition chains (such as x |> f |> g |> h) it is preferable to declare functions with their work data last (the t-last convention). Pipeline steps are partial applications. Each intermediate value is the result from the previous step and the t-last argument into the next step.
When using functions with labelled parameters, one must remain unlabelled. To allow writing pipes, it should be the one work data one. It becomes possible to declare that parameter as the first one (the t-first convention) which is convenient for API documentation and reading (the work data parameter is the first).
This needs to be explained and illustrated with examples in the Labelled and Optional Arguments tutorial.
@cuihtlauac Please check if this explanation is fine. I was trying not to mention much theory behind that, balancing between not going far into details and keeping the documentation well-explained.