skip to main content
research-article
Open Access

Staged generic programming

Published:29 August 2017Publication History
Skip Abstract Section

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 regrettable choice between writing succinct but slow programs and writing tedious but efficient programs.

Applying structured multi-stage programming techniques transforms Scrap Your Boilerplate from an inefficient library into a typed optimising code generator, bringing its performance in line with hand-written code, and so combining high-level programming with uncompromised performance.

References

  1. Michael D. Adams, Andrew Farmer, and José Pedro Magalhães. 2014. Optimizing SYB is Easy!. In Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation (PEPM ’14). ACM, New York, NY, USA, 71–82. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Michael D. Adams, Andrew Farmer, and José Pedro Magalhães. 2015. Optimizing SYB traversals is easy! Science of Computer Programming 112, Part 2 (2015), 170 – 193. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Vincent Balat, Roberto Di Cosmo, and Marcelo Fiore. 2004. Extensional Normalisation and Type-directed Partial Evaluation for Typed Lambda Calculus with Sums. In POPL ’04. ACM, New York, NY, USA, 64–76. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Andrej Bauer and Matija Pretnar. 2012. Programming with Algebraic Effects and Handlers. CoRR abs/1203.1539 (2012). http://arxiv.org/abs/1203.1539Google ScholarGoogle Scholar
  5. Anders Bondorf. 1992. Improving Binding Times Without Explicit CPS-conversion. In Proceedings of the 1992 ACM Conference on LISP and Functional Programming (LFP ’92). ACM, New York, NY, USA, 1–10. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Dmitri Boulytchev and Sergey Mechtaev. 2011. Efficiently scrapping boilerplate code in OCaml. (September 2011). ACM Workshop on ML 2011.Google ScholarGoogle Scholar
  7. Jacques Carette, Oleg Kiselyov, and Chung-chieh Shan. 2009. Finally Tagless, Partially Evaluated: Tagless Staged Interpreters for Simpler Typed Languages. J. Funct. Program. 19, 5 (Sept. 2009), 509–543. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Olivier Danvy, Karoline Malmkjær, and Jens Palsberg. 1995. The essence of eta-expansion in partial evaluation. LISP and Symbolic Computation 8, 3 (1995), 209–227. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Olivier Danvy, Karoline Malmkjær, and Jens Palsberg. 1996. Eta-expansion Does The Trick. ACM Trans. Program. Lang. Syst. 18, 6 (Nov. 1996), 730–751. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Stephen Dolan, Leo White, KC Sivaramakrishnan, Jeremy Yallop, and Anil Madhavapeddy. 2015. Effective Concurrency through Algebraic Effects. (September 2015). OCaml Users and Developers Workshop 2015.Google ScholarGoogle Scholar
  11. Andrew Farmer, Andy Gill, Ed Komp, and Neil Sculthorpe. 2012. The HERMIT in the Machine: A Plugin for the Interactive Transformation of GHC Core Language Programs. In Proceedings of the 2012 Haskell Symposium (Haskell ’12). ACM, New York, NY, USA, 1–12. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Andrzej Filinski. 2001. Normalization by Evaluation for the Computational Lambda-calculus (TLCA’01). Springer-Verlag, Berlin, Heidelberg, 151–165. http://dl.acm.org/citation.cfm?id=1754621.1754638Google ScholarGoogle Scholar
  13. Christopher S. Hardin and Roshan P. James. 2013. Core bench: micro-benchmarking for OCaml. OCaml Users and Developers Workshop. (September 2013).Google ScholarGoogle Scholar
  14. John Hughes. 1999. A Type Specialisation Tutorial. Springer Berlin Heidelberg, Berlin, Heidelberg, 293–325. Google ScholarGoogle ScholarCross RefCross Ref
  15. Jun Inoue. 2014. Supercompilation via staging. In Fourth International Valentin Turchin Workshop on Metacomputation.Google ScholarGoogle Scholar
  16. Patricia Johann and Neil Ghani. 2008. Foundations for structured programming with GADTs (POPL 2008). ACM.Google ScholarGoogle Scholar
  17. Mark P. Jones. 1995. Dictionary-free Overloading by Partial Evaluation. Lisp Symb. Comput. 8, 3 (Sept. 1995), 229–248. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. 1993. Partial Evaluation and Automatic Program Generation. Prentice-Hall, Inc., Upper Saddle River, NJ, USA.Google ScholarGoogle Scholar
  19. Manohar Jonnalagedda, Thierry Coppey, Sandro Stucki, Tiark Rompf, and Martin Odersky. 2014. Staged Parser Combinators for Efficient Data Processing. In Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA ’14). ACM, New York, NY, USA, 637–653. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. David Kaloper-Meršinjak and Jeremy Yallop. 2016. Generic Partially-static Data (Extended Abstract). In Proceedings of the 1st International Workshop on Type-Driven Development (TyDe 2016). ACM, New York, NY, USA, 39–40. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Yukiyoshi Kameyama, Oleg Kiselyov, and Chung-chieh Shan. 2011. Shifting the Stage: Staging with Delimited Control. J. Funct. Program. 21, 6 (Nov. 2011), 617–662. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Yukiyoshi Kameyama, Oleg Kiselyov, and Chung-chieh Shan. 2014. Combinators for Impure Yet Hygienic Code Generation. In Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation (PEPM ’14). ACM, New York, NY, USA, 3–14. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Andrew J. Kennedy. 2004. Functional Pearl: Pickler Combinators. Journal of Functional Programming 14, 6 (November 2004). Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Oleg Kiselyov. 2012. Delimited Control in OCaml, Abstractly and Concretely. Theor. Comput. Sci. 435 (June 2012), 56–76. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Oleg Kiselyov. 2014. The Design and Implementation of BER MetaOCaml. In Functional and Logic Programming, Michael Codish and Eijiro Sumii (Eds.). Lecture Notes in Computer Science, Vol. 8475. Springer International Publishing, 86–102. Google ScholarGoogle ScholarCross RefCross Ref
  26. Oleg Kiselyov, Aggelos Biboudis, Nick Palladinos, and Yannis Smaragdakis. 2017. Stream Fusion, to Completeness. In POPL 2017. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Oleg Kiselyov, Kedar N. Swadi, and Walid Taha. 2004. A Methodology for Generating Verified Combinatorial Circuits. In Proceedings of the 4th ACM International Conference on Embedded Software (EMSOFT ’04). ACM, New York, NY, USA, 249–258. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Ralf Lämmel and Simon Peyton Jones. 2003. Scrap Your Boilerplate: A Practical Design Pattern for Generic Programming (TLDI ’03). ACM, New York, NY, USA, 26–37. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Ralf Lämmel and Simon Peyton Jones. 2004. Scrap More Boilerplate: Reflection, Zips, and Generalised Casts. In Proceedings of the Ninth ACM SIGPLAN International Conference on Functional Programming (ICFP ’04). ACM, New York, NY, USA, 244–255. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. P. J. Landin. 1964. The Mechanical Evaluation of Expressions. Comput. J. 6, 4 (1964), 308–320. Google ScholarGoogle ScholarCross RefCross Ref
  31. J. Launchbury. 1991. Project Factorisations in Partial Evaluation. Cambridge University Press. https://books.google.co.uk/ books?id=B1UTK2j8rksCGoogle ScholarGoogle Scholar
  32. Julia L. Lawall and Olivier Danvy. 1994. Continuation-based Partial Evaluation. In Proceedings of the 1994 ACM Conference on LISP and Functional Programming (LFP ’94). ACM, New York, NY, USA, 227–238. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Xavier Leroy. 2003. A proposal for recursive modules in Objective Caml. INRIA Rocquencourt. (May 2003). Version 1.1.Google ScholarGoogle Scholar
  34. Sam Lindley. 2007. Extensional Rewriting with Sums. In Proceedings of the 8th International Conference on Typed Lambda Calculi and Applications (TLCA’07). Springer-Verlag, Berlin, Heidelberg, 255–271. http://dl.acm.org/citation.cfm?id= 1770203.1770222Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Andres Löh and Ralf Hinze. 2006. Open Data Types and Open Functions. In Proceedings of the 8th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP ’06). ACM, New York, NY, USA, 133–144. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. José Pedro Magalhães. 2013. Optimisation of Generic Programs through Inlining. In Accepted for publication at the 24th Symposium on Implementation and Application of Functional Languages (IFL’12) (IFL ’12). Google ScholarGoogle ScholarCross RefCross Ref
  37. Sergey Mechtaev. 2011. Eliminating boilerplate code in Objective Caml programs. System Programming 6, 1 (2011). In Russian.Google ScholarGoogle Scholar
  38. Kristian Nielsen and Morten Heine Sørensen. 1995. Call-By-Name CPS-Translation As a Binding-Time Improvement. In Proceedings of the Second International Symposium on Static Analysis (SAS ’95). Springer-Verlag, London, UK, UK, 296–313. http://dl.acm.org/citation.cfm?id=647163.717677 Google ScholarGoogle ScholarCross RefCross Ref
  39. Simon Peyton Jones. 2016. Template Haskell, 14 years on. Talk given at the International Summer School on Metaprogramming, Cambridge, UK. (August 2016). https://www.cl.cam.ac.uk/events/metaprog2016/Template-Haskell-Aug16.pptx .Google ScholarGoogle Scholar
  40. Simon Peyton Jones and Simon Marlow. 2002. Secrets of the Glasgow Haskell Compiler Inliner. J. Funct. Program. 12, 5 (July 2002), 393–434.Google ScholarGoogle Scholar
  41. Tiark Rompf and Martin Odersky. 2010. Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. In Proceedings of the Ninth International Conference on Generative Programming and Component Engineering (GPCE ’10). ACM, New York, NY, USA, 127–136. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Tim Sheard and Iavor S. Diatchki. 2002. Staging Algebraic Datatypes. Unpublished manuscript. (2002). http://web.cecs.pdx.edu/~sheard/papers/stagedData.ps .Google ScholarGoogle Scholar
  43. Walid Mohamed Taha. 1999. Multistage Programming: Its Theory and Applications. Ph.D. Dissertation. Oregon Graduate Institute of Science and Technology. AAI9949870.Google ScholarGoogle Scholar
  44. The GHC Team. 2015. The Glorious Glasgow Haskell Compilation System User’s Guide (7.10.2 ed.).Google ScholarGoogle Scholar
  45. Peter Thiemann. 2013. Partially Static Operations (PEPM ’13). ACM, New York, NY, USA, 75–76. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Todd L. Veldhuizen. 2004. Active Libraries and Universal Languages. Ph.D. Dissertation. Indiana University Computer Science.Google ScholarGoogle Scholar
  47. Leo White, Frédéric Bour, and Jeremy Yallop. 2015. Modular Implicits. ACM Workshop on ML 2014 post-proceedings. (September 2015). Google ScholarGoogle ScholarCross RefCross Ref
  48. Jeremy Yallop. 2007. Practical Generic Programming in OCaml. In ACM SIGPLAN Workshop on ML, Derek Dreyer (Ed.). Freiburg, Germany. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Jeremy Yallop. 2016. Staging Generic Programming. In Proceedings of the 2016 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation (PEPM ’16). ACM, New York, NY, USA, 85–96. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Staged 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

      Full Access

      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!