caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] pretty-printing with camlp4?
@ 2012-07-08 17:09 Daniel de Rauglaudre
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel de Rauglaudre @ 2012-07-08 17:09 UTC (permalink / raw)
  To: caml-list

Hi,

On Sun, Jul 08, 2012 at 04:34:34PM +0200, Nicolas Ojeda Bar wrote:

> On the other hand, with Camlp5 it is possible to write pretty
> printers for arbitrary ASTs
> (see <http://pauillac.inria.fr/~ddr/camlp5/doc/html/printers.html>),
> so I imagine there must be a way to do the same thing with Camlp4...

No. This feature has been developped only in Camlp5.

-- 
Daniel de Rauglaudre
http://pauillac.inria.fr/~ddr/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] pretty-printing with camlp4?
  2012-07-08 14:34 Nicolas Ojeda Bar
@ 2012-07-08 15:02 ` Gabriel Scherer
  0 siblings, 0 replies; 3+ messages in thread
From: Gabriel Scherer @ 2012-07-08 15:02 UTC (permalink / raw)
  To: Nicolas Ojeda Bar; +Cc: caml-list

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çois 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 <nojb@math.harvard.edu> wrote:
> 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 <http://pauillac.inria.fr/~ddr/camlp5/doc/html/printers.html>),
> 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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Caml-list] pretty-printing with camlp4?
@ 2012-07-08 14:34 Nicolas Ojeda Bar
  2012-07-08 15:02 ` Gabriel Scherer
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Ojeda Bar @ 2012-07-08 14:34 UTC (permalink / raw)
  To: caml-list

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 <http://pauillac.inria.fr/~ddr/camlp5/doc/html/printers.html>),
so I imagine there must be a way to do the same thing with Camlp4...

Thanks!
Nicolas

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-08 17:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-08 17:09 [Caml-list] pretty-printing with camlp4? Daniel de Rauglaudre
  -- strict thread matches above, loose matches on Subject: below --
2012-07-08 14:34 Nicolas Ojeda Bar
2012-07-08 15:02 ` Gabriel Scherer

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).