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 FAA24479; Mon, 4 Nov 2002 05:00:14 +0100 (MET) 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 FAA08827 for ; Mon, 4 Nov 2002 05:00:13 +0100 (MET) Received: from mx2.net.titech.ac.jp (mx2.net.titech.ac.jp [131.112.125.31]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id gA440BD21223 for ; Mon, 4 Nov 2002 05:00:12 +0100 (MET) Received: (qmail 25997 invoked from network); 4 Nov 2002 04:00:08 -0000 Received: from unknown (HELO vc2.net.titech.ac.jp) (131.112.125.36) by 0 with SMTP; 4 Nov 2002 04:00:08 -0000 Received: from unknown (HELO ?192.168.2.55?) (127.0.0.1) by localhost with SMTP; 4 Nov 2002 04:00:08 -0000 User-Agent: Microsoft-Entourage/10.1.1.2418 Date: Mon, 04 Nov 2002 13:00:06 +0900 Subject: Re: [Caml-list] format type From: Ken Wakita To: Cezary Kaliszyk , caml-list Message-ID: In-Reply-To: <20021103070858.GB24702@zodiac.mimuw.edu.pl> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Did you try "%t"? Printf.printf "%t": (out_channel -> unit) -> unit = You could simply ignore out_channel if you are not interested. Ken Wakita > From: Cezary Kaliszyk > Date: Sun, 3 Nov 2002 08:08:58 +0100 > To: caml-list@inria.fr > Subject: [Caml-list] format type > > I'm trying to write a function that takes a format and a function and > applies some (got from elsewere) arguments to the function. > > All works ok for nonempty format. > Ie: > myfun "%c%s" > is of type: > (char -> string -> unit) -> unit > > IS IT POSSIBLE (with the current implementation) of the format type type > checking to pass some format that would require a (unit -> unit) > function? > > Ie: I'd like: > myfun "" > to be of type: > (unit -> unit) -> unit > > If such construnction is not possible at all perheapes some new > identifier "%?" should be added to fromat type type checking. This > argument would take exacly one argument of type unit. > > My current implementation: > > let receive (fmt : (('a, unit, unit) format)) (f : 'a) : unit = > let fmt_str = string_of_format fmt in > let rec parse f i = > match fmt.[i] with > ... > I call recursively: > parse (lazified ((forced f) with applied arg)) (i + 1) > ... > in > Obj.magic (parse (fun () -> f) 0) () > ;; > > The only known workaround for me for now is to pass "%t" and > make my function not (unit -> unit) but ('a -> unit). > > Writing code with changed types just for the sake of the language is > very bad. And with "%t" 'a seems to be (unit -> unit). > > Cezary Kaliszyk > -- > ------------------- 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