Philip Wadler's Pretty Printer for OCaml

From: Christian Lindig (
Date: Fri May 08 1998 - 08:41:42 MET DST

Date: Fri, 8 May 1998 08:41:42 +0200
Message-Id: <>
From: Christian Lindig <>
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

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:14 MET