Printf.printf "uri: %a" Uri.pp Uri.empty

gives me

Error: This expression has type Format.formatter -> Uri.t -> unit
       but an expression was expected of type out_channel -> 'a -> unit
       Type Format.formatter is not compatible with type out_channel

how can I use %a with printf then? I know OCaml library : Printf but just can’t make sense of it.

Uri.pp is designed to work with Format.printf (works with formatters), not Printf.printf (works with channels).


So I guess I will mostly phase out Printf in favour of Format.

Edit: uh, I guess I will keep it for everything machine readable.

oh, please llow me one more question, shouldn’t

Format.sprintf "%a" Uri.pp Uri.empty

return an empty string? Instead I get a type error I can’t make sense of.

You should try with Format.asprintf.