Hi all,
I'm curious about the asymmetry between printf and scanf.
I like the modularity I can get by user defined printers, i.e.
module Foo =
struct
type t = int
let print ppf = fprintf "%d"
end
printf "My %a" Foo.print some_foo
But how do I get the same abstraction with scanf?
let id a = a
module Foo =
struct
type t = int
let read buf = bscanf "%d" id
end
(*Seemed natural*)
let some_foo = bscanf "My %a" Foo.read id
Thanks,
/Sasha