OCaml: When the guard is in "fun"

If I read it correctly, the OCaml documentation ( here , in particular) says it fun

can have "when" guards, for example:

fun a b when a < b -> a + b;;

      

However, this generates a syntax error on "when". What gives? Am I reading this wrong?

Additional Information

The relevant parts from the documentation are copied below in the BNF type syntax:

expr ::= ...
       | fun multiple-matching
       | ...

multiple-matching ::= { pattern }+ [when expr] -> expr

      

+3


source to share


1 answer


You have found an error in the documentation. fun

cannot take guard.



Note: a fix is ​​already being requested on request: https://github.com/ocaml/ocaml-manual/pull/2

+2


source







All Articles