A type variable with an underscore as a prefix tells us that the variable is weakly polymorphic. A weakly polymorphic variable can be used with only one type, however, the compiler cannot deduce the exact type, therefore the type variable has an underscore.
When you provide an argument for the first time, the variable will no longer be polymorphic and will only be able to accept arguments of one type.
, , . , , , , List.fold_left .
Edit:
( eta) ( )?
, , . :
let count f =
let inc = ref 0 in
(fun x -> inc := !inc + 1; print_int !inc; f x);;
: ('a -> 'b) -> 'a -> 'b.
. :
let max' = count max;;
val max' : '_a -> '_a -> '_a = <fun>
:
let max'' x = count max x;;
val max'' : 'a -> 'a -> 'a = <fun>
, :
max' 1 2;; (* prints 1 *)
max' 1 2;; (* prints 2 *)
max' 1 2;; (* prints 3 *)
max'' 1 2;; (* prints 1 *)
max'' 1 2;; (* prints 1 *)
max'' 1 2;; (* prints 1 *)
, , , , , , , .
, .