In the document of Module Printf, I don't understand the mechanism of ('a, out_channel, unit) format, thought I use that a lot in practice.
For instance, the following functions type well while compiling:
type t =
{ x: int;
y: int }
let print (chan: out_channel) (co: t) : unit =
Printf.fprintf chan "(%d, %d)" x y
let try (co0: t) (co1: t) =
Printf.fprintf Pervasives.stdout "From %a To %a" print co0 print co1
The signature of Printf.fprintf is : out_channel -> ('a, out_channel, unit) format -> 'a, but I don't see what ('a, out_channel, unit) format matches in "From %a To %a" print co0 print co1.
Also, the signature of print is out_channel -> t -> unit, why is print co0 print co1 acceptable in the code?
In one word, could anyone explain how Printf.fprintf Pervasives.stdout "From %a To %a" print co0 print co1 is typed?