OCaml doesn’t actually let you define infix functions as you want in general. Basically, you can only:
-
Define a function with an alphanumeric identifier as in let ident123 a b = ...
. The function will be prefix.
-
Define a function with ASCII symbols between brackets, as in let (++) a b = ...
. The function will be infix when you use it without the brackets as in a ++ b
(though you can also do (++) a b
).
If you try to define an infix function whose name is alphanumeric (let (ident) a b = ...
), you get a syntax error.
At this point you might be wondering what about mod
then? Well mod
and the bitwise manipulation operators (lsl
, lsr
, land
etc) are special-cased so that they are infix even though they’re alphanumeric. So the way you know if a function is infix, to answer your question, is just that you have to remember that mod
and the bitwise operators (and nothing else I think) are infix.