caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Remi VANICAT <vanicat@labri.u-bordeaux.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Does this function exist?
Date: Tue, 10 Sep 2002 00:48:40 +0200	[thread overview]
Message-ID: <87y9aavkxj.dlv@wanadoo.fr> (raw)
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")

Chris Hecker <checker@d6.com> 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


  reply	other threads:[~2002-09-09 22:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-09 17:56 Lukasz Lew
2002-09-09 19:34 ` John Prevost
2002-09-09 20:18   ` Lukasz Lew
2002-09-09 20:55     ` John Prevost
2002-09-09 20:59       ` Lukasz Lew
2002-09-17 16:21       ` Kontra, Gergely
2002-09-17 17:17         ` Florian Hars
2002-09-09 21:40     ` Yutaka OIWA
2002-09-09 23:10     ` Nicolas Cannasse
     [not found]   ` <Pine.LNX.4.44.0209092212360.21417-100000@zodiac.mimuw.edu. pl>
2002-09-09 22:05     ` Chris Hecker
2002-09-09 22:48       ` Remi VANICAT [this message]
2002-09-10  1:10         ` Daniel de Rauglaudre
2002-09-16 16:56   ` Kontra, Gergely
2002-09-12 15:31 ` [Caml-list] " Michaël Grünewald
2002-09-18 23:01 [Caml-list] " Gurr, David (MED, self)
2002-09-18 23:01 Gurr, David (MED, self)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y9aavkxj.dlv@wanadoo.fr \
    --to=vanicat@labri.u-bordeaux.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).