Version française
Home     About     Download     Resources     Contact us    
Browse thread
Philip Wadler's Pretty Printer for OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christian Lindig <lindig@i...>
Subject: Philip Wadler's Pretty Printer for OCaml

Philip Wadler recently has proposed a pretty printer algebra and an
implementation for Haskell. The pretty printer is simple to use,
predictable, and powerful - unlike many other pretty printers I have
seen.

http://cm.bell-labs.com/cm/cs/who/wadler/
http://cm.bell-labs.com/cm/cs/who/wadler/topics/recent.html

The implementation relies on the lazy evaluation of Haskell so a
direct translation to Objective Caml would not be efficient.

I have tried to write an OCaml version of the pretty printer which is
suitable for strict evaluation. First experiences are very
encouraging: a joint work with Andreas Rossberg uses the new
implementation to pretty print C type defintions. We have pretty
printed a sequence of C type defintions of 80 kloc in total.  The
pretty printer was used separately for each definition but single
definitions spanned over more than 1000 lines. On a 200 MHz Linux
Pentium machine pretty printing that 80 kloc output takes around 10
seconds.

You can find my implementation on the web. Some comments inside the
code explain the basic concept. However, reading the (short) original
paper 'A prettier printer' by Philip Wadler is usefull. Comments and
improvements are always welcome. 

http://www.cs.tu-bs.de/softech/people/lindig/pretty.html


Christian

------------------------------------------------------------------------------
 Christian Lindig  				       lindig@ips.cs.tu-bs.de
 TU Braunschweig				       fon   +49 531 391 7465
 Institut fuer Programmiersprachen		       fax   +49 531 391 8140
 D-38106 Braunschweig             		       http://www.cs.tu-bs.de