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 AAA15771; Tue, 10 Sep 2002 00:47:55 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA15932 for ; Tue, 10 Sep 2002 00:47:54 +0200 (MET DST) Received: from mel-rto4.wanadoo.fr (smtp-out-4.wanadoo.fr [193.252.19.23]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g89Mlr103611 for ; Tue, 10 Sep 2002 00:47:53 +0200 (MET DST) Received: from mel-rta7.wanadoo.fr (193.252.19.61) by mel-rto4.wanadoo.fr (6.5.007) id 3D760D080030D521 for caml-list@inria.fr; Tue, 10 Sep 2002 00:47:53 +0200 Received: from debian (80.8.85.4) by mel-rta7.wanadoo.fr (6.5.007) id 3D775ADD0022F7AB for caml-list@inria.fr; Tue, 10 Sep 2002 00:47:53 +0200 Received: from moi by debian with local (Exim 3.36 #1 (Debian)) id 17oXKj-0004a6-00 for ; Tue, 10 Sep 2002 00:48:41 +0200 To: caml-list@inria.fr Subject: Re: [Caml-list] Does this function exist? References: <86hegzarek.fsf@laurelin.dementia.org> <4.3.2.7.2.20020909144531.04529c20@mail.d6.com> Mail-Copy-To: never From: Remi VANICAT Date: Tue, 10 Sep 2002 00:48:40 +0200 In-Reply-To: <4.3.2.7.2.20020909144531.04529c20@mail.d6.com> (Chris Hecker's message of "Mon, 09 Sep 2002 15:05:22 -0700") Message-ID: <87y9aavkxj.dlv@wanadoo.fr> User-Agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i386-debian-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Chris Hecker writes: > type foo = A of int | B of int list > > Then have camlp4 generate > > let print_foo fmt f = > Format.fprintf fmt "@[foo = "; > begin match f with > A i -> Format.fprintf fmt "A %d" i > | B il -> Format.fprintf fmt "B [%s]" > (List.fold_left ~f:(fun s i -> s ^ Printf.sprintf "%s%d" (if > s <> "" then "; " else "") i) ~init:"" il) > end; > Format.fprintf fmt "@]" > > or whatever (you'd probably want it to just return a string so you > could compose them, but then you'd want the formatting stuff in there, > so it's unclear exactly which would be better...maybe Format.sprintf > works). The idea is you don't want to have to write that code by > hand, but generating it would be fine. > > Is this something camlp4 can do? There is ioXML (http://pauillac.inria.fr/~ddr/IoXML/index.html) that make more or less that (but with XML). -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~vanicat ------------------- 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