On 10/07/2013 17:02, John Carr wrote: A function with an unconstrained type variable on the right hand side of its type can potentially take an unlimited number of arguments. You have the equivalent of a shift-reduce conflict in a grammar. The compiler can choose to reduce (apply f to the argument) or shift (save the arguments waiting for more). The choice to shift seems odd but there may be a situation where it is useful. If your function were defined let f ~a = a + 0 it would be monomorphic. The compiler would match an unlabeled argument with parameter a. That is to say : # let f ~a = a + 0;; val f : a:int -> int = # f 12;; - : int = 12
Please, can someone explain the reason behind the following behaviour: # let f ~a = a;; val f : a:'a -> 'a = if I apply function f, omiting the label, instead of an error I'll get: # f 12;; - : a:(int -> 'a) -> 'a = ... a function that accepts a labeled arguments, that is a function from int to 'a, and returns a result of this function: # f 12 ~a:(fun x -> x + 1);; - : int = 13 and even more, if I apply it to more unlabled arguments: # f 1 2 3 4 5;; - : a:(int -> int -> int -> int -> int -> 'a) -> 'a = It is very confusing... -- Caml-list mailing list. Subscription management and archives: https://sympa.inria.fr/sympa/arc/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs