caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Scanf question
@ 2007-02-16 16:28 Sasha Rush
  0 siblings, 0 replies; only message in thread
From: Sasha Rush @ 2007-02-16 16:28 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 459 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 655 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-02-16 16:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-16 16:28 Scanf question Sasha Rush

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).