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?
Printf.printf
, right?let p = Printf.fprintf stdout;; p "%s" "string"
works for me'_a
is weak polymorphism, which if fine, but if it is an error it usually means you need to eta-expand.