ocaml.org icon indicating copy to clipboard operation
ocaml.org copied to clipboard

Explain why t-first works with labels

Open cuihtlauac opened this issue 1 year ago • 1 comments

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 avatar Feb 22 '24 10:02 cuihtlauac

@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.

mikhailazaryan avatar Mar 10 '24 19:03 mikhailazaryan