skip to main content
10.1145/2847538.2847546acmconferencesArticle/Chapter ViewAbstractPublication PagespepmConference Proceedingsconference-collections
research-article

Staging generic programming

Published:11 January 2016Publication History

ABSTRACT

Generic programming libraries such as Scrap Your Boilerplate eliminate the need to write repetitive code, but typically introduce significant performance overheads. This leaves programmers with the unfortunate choice of writing succinct but slow programs or writing tedious but efficient programs. We show how to systematically transform an implementation of the Scrap Your Boilerplate library in the multi-stage programming language MetaOCaml to eliminate the overhead, making it possible to combine the benefits of high-level abstract programming with the efficiency of low-level code.

References

  1. O. Danvy, K. Malmkjær, and J. Palsberg. Eta-expansion does the trick. ACM Trans. Program. Lang. Syst., 18(6):730–751, Nov. 1996. ISSN 0164-0925. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. S. Dolan, L. White, K. Sivaramakrishnan, J. Yallop, and A. Madhavapeddy. Effective concurrency through algebraic effects. OCaml Users and Developers Workshop 2015, September 2015.Google ScholarGoogle Scholar
  3. A. Farmer, A. Gill, E. Komp, and N. Sculthorpe. The HERMIT in the machine: A plugin for the interactive transformation of GHC core language programs. SIGPLAN Not., 47(12):1–12, Sept. 2012. ISSN 0362-1340. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. J. Gibbons. Datatype-generic programming. In R. Backhouse, J. Gibbons, R. Hinze, and J. Jeuring, editors, Spring School on Datatype-Generic Programming, volume 4719 of Lecture Notes in Computer Science. Springer-Verlag, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. R. Hinze and A. Löh. “Scrap your boilerplate” revolutions. In Proceedings of the 8th International Conference on Mathematics of Program Construction, MPC’06, pages 180–208, Berlin, Heidelberg, 2006. Springer-Verlag. ISBN 3-540-35631-2, 978-3-540-35631-8. P. Johann and N. Ghani. Foundations for structured programming with GADTs. In Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2008. ACM, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. M. P. Jones. Dictionary-free overloading by partial evaluation. Lisp Symb. Comput., 8(3):229–248, Sept. 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. N. D. Jones, C. K. Gomard, and P. Sestoft. Partial Evaluation and Automatic Program Generation. Prentice-Hall, Inc., Upper Saddle River, NJ, USA, 1993. ISBN 0-13-020249-5. Y. Kameyama, O. Kiselyov, and C.-c. Shan. Shifting the stage: Staging with delimited control. J. Funct. Program., 21(6):617–662, Nov. 2011. ISSN 0956-7968. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. O. Kiselyov. Delimited control in OCaml, abstractly and concretely. Theor. Comput. Sci., 435:56–76, June 2012. ISSN 0304-3975. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. O. Kiselyov. The design and implementation of BER MetaOCaml. In M. Codish and E. Sumii, editors, Functional and Logic Programming, volume 8475 of Lecture Notes in Computer Science, pages 86–102. Springer International Publishing, 2014. ISBN 978-3-319-07150-3. R. Lämmel and S. P. Jones. Scrap your boilerplate: A practical design pattern for generic programming. In Proceedings of the 2003 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, TLDI ’03, pages 26–37, New York, NY, USA, 2003.Google ScholarGoogle Scholar
  10. S. Mechtaev. Eliminating boilerplate code in Objective Caml programs. System Programming, 6(1), 2011. In Russian. K. Nielsen and M. H. Srensen. Call-by-name CPS-translation as a bindingtime improvement. In STATIC ANALYSIS, NUMBER 983 IN LECTURE NOTES IN COMPUTER SCIENCE, pages 296–313. Springer-Verlag, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. B. C. d. S. Oliveira, R. Hinze, and A. Loeh. Extensible and modular generics for the masses. In H. Nilsson, editor, Trends in Functional Programming. 2007.Google ScholarGoogle Scholar
  12. The GHC Team. The Glorious Glasgow Haskell Compilation System User’s Guide, 7.10.2 edition, July 2015.Google ScholarGoogle Scholar
  13. T. L. Veldhuizen. Active Libraries and Universal Languages. PhD thesis, Indiana University Computer Science, May 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. L. White, F. Bour, and J. Yallop. Modular implicits. ACM Workshop on ML 2014 post-proceedings, September 2015.Google ScholarGoogle ScholarCross RefCross Ref
  15. J. Yallop and L. White. Modular macros. OCaml Users and Developers Workshop 2015, September 2015.Google ScholarGoogle Scholar
  16. A. Installation Instructions The staged SYB library is written using a fork of the OCaml distribution that combines the ongoing work on BER MetaOCaml (Kiselyov 2014) and modular implicits (White et al. 2015) in a single compiler. OPAM users can install the compiler by running the following command: opam switch 4.02.1+modular-implicits-ber The staged SYB library implementation may be installed by running the following command: opam pin add metaocaml-syb \ https://github.com/yallop/metaocaml-syb The code is available to browse and download at the same URL.Google ScholarGoogle Scholar

Index Terms

  1. Staging generic programming

    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
    • Published in

      cover image ACM Conferences
      PEPM '16: Proceedings of the 2016 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation
      January 2016
      108 pages
      ISBN:9781450340977
      DOI:10.1145/2847538

      Copyright © 2016 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 11 January 2016

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate22of42submissions,52%

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader