skip to main content
research-article
Open Access

A pretty but not greedy printer (functional pearl)

Published:29 August 2017Publication History
Skip Abstract Section

Abstract

This paper proposes a new specification of pretty printing which is stronger than the state of the art: we require the output to be the shortest possible, and we also offer the ability to align sub-documents at will. We argue that our specification precludes a greedy implementation. Yet, we provide an implementation which behaves linearly in the size of the output. The derivation of the implementation demonstrates functional programming methodology.

References

  1. Pablo R. Azero and S. Doaitse Swierstra. 1998. Optimal Pretty Printing Combinators. (1998). Submitted to ICFP 1998.Google ScholarGoogle Scholar
  2. Richard Bird and Oege de Moor. 1997. Algebra of programming. Prentice-Hall, Inc. http://portal.acm.org/citation.cfm?id= 248932Google ScholarGoogle Scholar
  3. Kalyanmoy Deb, Karthik Sindhya, and Jussi Hakanen. 2016. Multi-objective optimization. In Decision Sciences: Theory and Practice. CRC Press, 145–184. Google ScholarGoogle ScholarCross RefCross Ref
  4. John Hughes. 1995. The Design of a Pretty-printing Library. In Advanced Functional Programming, First International Spring School on Advanced Functional Programming Techniques-Tutorial Text. Springer-Verlag, 53–96. http://portal.acm.org/ citation.cfm?id=734154 Google ScholarGoogle ScholarCross RefCross Ref
  5. Conor McBride and Ross Paterson. 2007. Applicative programming with effects. Journal of Functional Programming 18, 01 (2007), 1–13. DOI: Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Anton Podkopaev and Dmitri Boulytchev. 2014. Polynomial-Time Optimal Pretty-Printing Combinators with Choice. In Perspectives of System Informatics - 9th International Ershov Informatics Conference, PSI 2014, St. Petersburg, Russia, June 24-27, 2014. Revised Selected Papers. 257–265. DOI: Google ScholarGoogle ScholarCross RefCross Ref
  7. S. Doaitse Swierstra and Olaf Chitil. 2009. Linear, bounded, functional pretty-printing. Journal of Functional Programming 19, 01 (2009), 1–16. DOI: Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Philip Wadler. 1987. A critique of Abelson and Sussman or why calculating is better than scheming. ACM SIGPLAN Notices 22, 3 (1987), 83–94. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Philip Wadler. 2003. A prettier printer. Palgrave MacMillan, 223–243. Google ScholarGoogle ScholarCross RefCross Ref

Index Terms

  1. A pretty but not greedy printer (functional pearl)

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image Proceedings of the ACM on Programming Languages
        Proceedings of the ACM on Programming Languages  Volume 1, Issue ICFP
        September 2017
        1173 pages
        EISSN:2475-1421
        DOI:10.1145/3136534
        Issue’s Table of Contents

        Copyright © 2017 Owner/Author

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 29 August 2017
        Published in pacmpl Volume 1, Issue ICFP

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Author Tags

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!