Polynomial-Time Optimal Pretty-Printing Combinators with Choice

  • Anton Podkopaev
  • Dmitri Boulytchev
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8974)


We describe pretty-printing combinators with choice which provide optimal document layout in polynomial time. Bottom-up tree rewriting and dynamic programming (BURS) is used to calculate a set of possible layouts for a given output width. We also present the results of suggested approach evaluation and discuss its application for the implementation of pretty-printers.


Pretty-printing Combinators Bottom-up rewriting systems 


  1. 1.
    Aho, A.V., Ganapathi, M., Tjiang, S.W.K.: Code generation using tree matching and dynamic programming. ACM Trans. Program. Lang. Syst. 11(4), 491–516 (1989)CrossRefGoogle Scholar
  2. 2.
    Azero, P., Swierstra, S.D.: Optimal Pretty-Printing Combinators., (1998)
  3. 3.
    Swierstra, S.D., Alcocer, P.R.A., Saraiva, J.: Designing and implementing combinator languages. In: Swierstra, S.D., Oliveira, J.N., Henriques, P.R. (eds.) AFP 1998. LNCS, vol. 1608. Springer, Heidelberg (1999) CrossRefGoogle Scholar
  4. 4.
    Chitil, O.: Pretty printing with lazy dequeues. ACM Trans. Program. Lang. Syst. 27, 163–184 (2005)CrossRefGoogle Scholar
  5. 5.
    Comon, H., Dauchet, M., Gilleron, R. et al.: Tree Automata Techniques and Applications., (2007)
  6. 6.
    Hughes, J.: The design of a pretty-printing library. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925. Springer, Heidelberg (1995) CrossRefGoogle Scholar
  7. 7.
    Jackson, S., Devanbu, P., Ma, K.: Stable, flexible, peephole pretty-printing. J. Sci. Comput. Program. 72(1–2), 40–51 (2008)CrossRefMathSciNetGoogle Scholar
  8. 8.
    De Jonge, M.: A pretty-printer for every occasion. In: Proceedings of the 2nd International Symposium on Constructing Software Engineering Tools (2000)Google Scholar
  9. 9.
    De Jonge, M.: Pretty-printing for software reengineering. In: Proceedings of the International Conference On Software Maintenance (2002)Google Scholar
  10. 10.
    Costanzo, D., Shao, Z.: A case for behavior-preserving actions in separation logic. In: Jhala, R., Igarashi, A. (eds.) APLAS 2012. LNCS, vol. 7705, pp. 332–349. Springer, Heidelberg (2012) CrossRefGoogle Scholar
  11. 11.
    Oppen, D.C.: Pretty-printing. ACM Transact. Program. Lang. Syst. 2(4), 465–483 (1980)CrossRefGoogle Scholar
  12. 12.
    Swierstra, S.D.: Linear, Online, Functional Pretty Printing (corrected and extended version). Technical report, UU-CS-2004-025a. Institute of Information and Computing Sciences, Utrecht University (2004)Google Scholar
  13. 13.
    Swierstra, S.D., Chitil, O.: Linear, bounded, functional pretty-printing. J. Funct. Program. 19, 1–16 (2009)CrossRefzbMATHGoogle Scholar
  14. 14.
    van den Brand, M., Visser, E.: Generation of formatters for context-free languages. ACM Trans. Softw. Eng. Methodol. 5(1), 1–41 (1996)CrossRefGoogle Scholar
  15. 15.
    Wadler, P.: A Prettier Printer: The Fun of Programming. Palgrave MacMillan (2003)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2015

Authors and Affiliations

  1. 1.Intellij Labs Co. LtdSt.PetersburgRussia
  2. 2.St.Petersburg State UniversitySt.PetersburgRussia

Personalised recommendations