Skip to content

Commit

Permalink
remove the discussion of labels-omitted application in the label tuto…
Browse files Browse the repository at this point in the history
…rial
  • Loading branch information
gasche committed Jan 22, 2021
1 parent 46f2624 commit efccb01
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions manual/manual/tutorials/lablexamples.etex
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,6 @@ let hline ~x:x1 ~x:x2 ~y = (x1, x2, y);;
hline ~x:3 ~y:2 ~x:5;;
\end{caml_example}

As an exception to the above parameter matching rules, if an
application is total (omitting all optional arguments), labels may be
omitted.
In practice, many applications are total, so that labels can often be
omitted.
\begin{caml_example}{toplevel}
f 3 2;;
ListLabels.map succ [1;2;3];;
\end{caml_example}
But beware that functions like "ListLabels.fold_left" whose result
type is a type variable will never be considered as totally applied.
\begin{caml_example}{toplevel}[error]
ListLabels.fold_left ( + ) 0 [1;2;3];;
\end{caml_example}

When a function is passed as an argument to a higher-order function,
labels must match in both types. Neither adding nor removing labels
are allowed.
\begin{caml_example}{toplevel}
let h g = g ~x:3 ~y:2;;
h f;;
h ( + ) [@@expect error];;
\end{caml_example}
Note that when you don't need an argument, you can still use a wildcard
pattern, but you must prefix it with the label.
\begin{caml_example}{toplevel}
Expand Down

0 comments on commit efccb01

Please sign in to comment.