Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 1998-05-11 (09:30)
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

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

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.


 Christian Lindig  	
 TU Braunschweig				       fon   +49 531 391 7465
 Institut fuer Programmiersprachen		       fax   +49 531 391 8140
 D-38106 Braunschweig