Reputation: 5540
As I use a lot Printf.fprintf stdout ...
in my programs, I would like to rename it by a shorter function. So I write:
let p = Printf.fprintf stdout
And I would hope p "%s" "string"
works. However, the compilation gives an error:
File "lib/utility.ml", line 27, characters 8-29:
Error: The type of this expression, ('_a, out_channel, unit) format -> '_a,
contains type variables that cannot be generalized
Does anyone have an idea to rename it so that the application could be as simple as possible?
Upvotes: 2
Views: 110
Reputation: 66823
I think it will work if you eta-expand your definition:
let p fmt = Printf.fprintf stdout fmt
Upvotes: 1