From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA28269 for caml-red; Thu, 23 Nov 2000 13:42:39 +0100 (MET) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA30206 for caml-list; Thu, 23 Nov 2000 13:26:07 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA30678 for ; Thu, 23 Nov 2000 12:55:12 +0100 (MET) Received: from sdmmx1.sdm.de (sdmmx1.sdm.de [192.76.162.232]) by nez-perce.inria.fr (8.11.1/8.10.0) with SMTP id eANBtBb10279 for ; Thu, 23 Nov 2000 12:55:11 +0100 (MET) Received: FROM muccpu1.muc.sdm.de BY sdmmx1.sdm.de ; Thu Nov 23 12:54:24 2000 0000 Received: by muccpu1.muc.sdm.de (Sendmail 8.9.3+Sun) via ESMTP for from mucexch2.muc.sdm.de id MAA27626; Thu, 23 Nov 2000 12:55:22 +0100 (MET) Received: by mucexch.muc.sdm.de with Internet Mail Service (5.5.2650.21) id ; Thu, 23 Nov 2000 12:54:19 +0100 Message-ID: From: jim.rauser@sdm.de To: caml-list@inria.fr Subject: Format.sprintf and "%a" Date: Thu, 23 Nov 2000 12:54:18 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" Sender: weis@pauillac.inria.fr Hello, I'm teaching myself Ocaml and have run up against a problem I can't solve in connection with the format module. For many of the types in my code, I have defined pretty-printing functions with type (Format.formatter -> -> unit), e.g., type foo = Foo | Bar let fmt_foo f x = match x with Foo -> Format.fprintf f "Foo" | Bar -> Format.fprintf f "Bar" in Format.printf "Test: %a@." fmt_foo Foo Works great, but when I try it with sprintf, I get the following: let s = Format.sprintf "Test: %a@." fmt_foo Foo This expression has type ((Format.formatter -> foo -> unit) -> foo -> unit, Format.formatter, unit) format but is here used with type ((Format.formatter -> foo -> unit) -> foo -> unit, unit, string) format [Note: I retyped these examples by hand, I hope they're accurate.] I can see the correlation of the signatures in the error message to those of fprintf and sprintf in Format.mli, but the type magic that seems to be occuring in the implementation of the Format modules is beyond me. Can someone explain what is going on here? Is there a way to use my formatting functions with sprintf? Thanks, Jim ------------------------------------------------------------------------ Jim Rauser mailto:rauser@qcentic.de Qcentic GmbH Max-Planck-Str. 39a Tel: 02234/950 36 16 D-50858 Koeln Fax: 02234/27 19 17