From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 768257ED34 for ; Sun, 8 Jul 2012 17:02:54 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.214.180; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.214.180 as permitted sender) identity=mailfrom; client-ip=209.85.214.180; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ob0-f180.google.com) identity=helo; client-ip=209.85.214.180; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-ob0-f180.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmkBAL2g+U/RVda0kGdsb2JhbABFDgimPJEDCCIBAQEBCQkNBxQEI4IgAQEBBBICLAEbEgsBAwwGBQsHBg0hIgERAQUBCgQOBhMSEIdbAQMMC5tsCQOMI4Jxg3MKGScDCleIcQEFDIs0hgwDlTaBEo0WPoNFOw X-IronPort-AV: E=Sophos;i="4.77,547,1336341600"; d="scan'208";a="149985433" Received: from mail-ob0-f180.google.com ([209.85.214.180]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 08 Jul 2012 17:02:53 +0200 Received: by obbuo19 with SMTP id uo19so28227839obb.39 for ; Sun, 08 Jul 2012 08:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=zdUucUrFnI5W/WCusUa6qq62LmWsXhFFDiOx9naE2aY=; b=w7/GuwnOZBV5kEMOoHdpb8PB0C/Bys/D/RB6N1gcmon6+j9Fvg3IPY27eSmLzU/MEz feFRxijyLo1aAc/gT0VkjQa6+C6K8d3uRsu+s0r2uLqe43XVbE7HDGaOC2fJGFFJqfsI G1Lx1IMMqcFngbflyp3ix2Y0j7ppsL2ExcGWex0k6ropp1pNFkNFKzfeHVLh5ivyPvWI JTx9QtKNSJQ40CFZxzqr/wAnJORHWUmiwkncckBRksX4FQ6uhHA89bfAw4Ypp7+vu1na hhLVqJfc+FmGEhzC5eq3m/SQmMBvdTb8jINCZF+55LWpDiYt7hWMAq51EjjuwU5wjrK9 PO1Q== Received: by 10.50.171.41 with SMTP id ar9mr6476842igc.56.1341759771824; Sun, 08 Jul 2012 08:02:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.94.39 with HTTP; Sun, 8 Jul 2012 08:02:11 -0700 (PDT) In-Reply-To: <1652E741-8D61-4AFB-BB94-57FD60915BE4@math.harvard.edu> References: <1652E741-8D61-4AFB-BB94-57FD60915BE4@math.harvard.edu> From: Gabriel Scherer Date: Sun, 8 Jul 2012 17:02:11 +0200 Message-ID: To: Nicolas Ojeda Bar Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] pretty-printing with camlp4? As far as I know, no such facility exists in Camlp4. Note however that there is quite a difference between parsers and printers. Supporting extensible parsing is very difficult, because parsing is quite a complex process. On the contrary, "printers" as presented here or as implemented in Camlp4 are more like regular tree traversals, calling a pretty-printing library that takes care of the visual formatting aspects. An "extensible printer" can therefore be summarized as an extensible tree traversal, something that is not too difficult to achieve with a decent software architecture; for example Camlp4's MapGenerator framework. If you don't need the "extensible" parts of Camlp5 printer's support, because your datatype to print is fixed, you can use the pretty-printing library directly. Camlp4 uses the Format module of the standard library, but I personally found it to be a bit painful to use, and have a preference for the Pprint library of Fran=E7ois Pottier: http://gallium.inria.fr/~fpottier/pprint/pprint.tar.gz (There are other pretty-printing libraries for OCaml that I haven't tried, such as Martin Jambon's easy-format: http://mjambon.com/easy-format.html ) My advice would be to use one of those pretty-printing libraries, to see if it fits your bill, or if you really need another abstraction layer such as Camlp5 printers. (Of course you can also use Camlp5 directly if it solves you problem.) On Sun, Jul 8, 2012 at 4:34 PM, Nicolas Ojeda Bar w= rote: > Hi, > > Is it possible to use Camlp4 to write pretty printers of arbitrary > data? The signature Camlp4.Sig.Printer seems to indicate the pretty > printing facility only works with OCaml ASTs... > > On the other hand, with Camlp5 it is possible to write pretty > printers for arbitrary ASTs > (see ), > so I imagine there must be a way to do the same thing with Camlp4... > > Thanks! > Nicolas > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >