From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA14535; Wed, 19 May 2004 18:15:49 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 SAA14301 for ; Wed, 19 May 2004 18:15:48 +0200 (MET DST) Received: from caged.spacebird.net (caged.spacebird.net [66.92.161.180]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i4JGFkEV029622 for ; Wed, 19 May 2004 18:15:47 +0200 Received: from [10.92.1.1] (helo=word) by caged.spacebird.net with smtp (Exim 3.36 #1 (Debian)) id 1BQURl-0000NL-00; Wed, 19 May 2004 13:01:37 -0400 Message-ID: <006f01c43dbc$4642deb0$10015c0a@word> From: "David J. Trombley" To: "Olivier Andrieu" Cc: , References: <004901c43d68$aa348bc0$10015c0a@word> <20040519.092218.74745648.oandrieu@nerim.net> Subject: Re: [Caml-list] format4 query Date: Wed, 19 May 2004 12:13:32 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-Miltered: at nez-perce with ID 40AB8833.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 fmt:01 printf:01 kprintf:01 fmt:01 val:01 inferred:01 kprintf:01 andrieu:01 andrieu:01 caml-list:01 2004:99 2004:99 demonstrate:01 sprintf:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Right, as I said I can get simple examples to work. But I can't get syntax such as # let g (l : listener) (k : int) fmt = match k with 0 -> 0 | x -> Printf.kprintf l fmt; k;; val g : listener -> int -> ('a, unit, string, unit) format4 -> int = to function, as you can see the format type has been inferred to a type that is not useful at all. I'd like to use kprintf as a side effect to a function which evaluates to some type, but I would not like that type or the unit type of a ; evaluation to affect the format type. -dj ----- Original Message ----- From: "Olivier Andrieu" To: Cc: ; Sent: Wednesday, May 19, 2004 3:22 AM Subject: Re: [Caml-list] format4 query > David J. Trombley [Wed, 19 May 2004]: > > > > Suppose I have > > > > type listener = string -> unit > > > > which is intended to receive a string type as a value. > > > > Could someone demonstrate a function that takes a listener > > and a format as arguments, and uses sprintf to obtain a > > string, and then calls the listener with the string > > argument? > > That is precisely what kprintf does. > > # type listener = string -> unit;; > type listener = string -> unit > # let f (l : listener) fmt = Printf.kprintf l fmt ;; > val f : listener -> ('a, unit, string, unit) format4 -> 'a = > # f print_endline "%s %d" "abc" 23 ;; > abc 23 > - : unit = () > > -- > Olivier > ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners