Let's say we have the following function (body isn't very important):
let writelogf greeting x =
Printf.printf "%A" greeting
Printf.printf "%A" x
The type of this function is 'a -> 'b -> unit
which is what I want.
Now I define a partially applied function:
let logf x = writelogf "Hello!" x
The type of this function is 'a -> unit
which is what I expect. I'm able to use it with arguments of any type:
logf "Test"
logf 1
But if I try to simplify the declaration and repeat the calls:
let logf2 = writelogf "Hello!"
logf2 "Test"
logf2 1
it won't compile anymore, because logf2
is not generalized, it has type string -> unit
(infered from first usage).
Why is that? If I have a function with 5 parameters and I need to partially apply one, do I have to repeat the other 4?