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.
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- M. P. Jones. Dictionary-free overloading by partial evaluation. Lisp Symb. Comput., 8(3):229–248, Sept. 1995. Google ScholarDigital Library
- 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 ScholarDigital Library
- O. Kiselyov. Delimited control in OCaml, abstractly and concretely. Theor. Comput. Sci., 435:56–76, June 2012. ISSN 0304-3975. Google ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- 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 Scholar
- The GHC Team. The Glorious Glasgow Haskell Compilation System User’s Guide, 7.10.2 edition, July 2015.Google Scholar
- T. L. Veldhuizen. Active Libraries and Universal Languages. PhD thesis, Indiana University Computer Science, May 2004. Google ScholarDigital Library
- L. White, F. Bour, and J. Yallop. Modular implicits. ACM Workshop on ML 2014 post-proceedings, September 2015.Google ScholarCross Ref
- J. Yallop and L. White. Modular macros. OCaml Users and Developers Workshop 2015, September 2015.Google Scholar
- 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 Scholar
Index Terms
- Staging generic programming
Recommendations
Staged generic programming
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 ...
Compiling a reflective language using MetaOCaml
GPCE 2014: Proceedings of the 2014 International Conference on Generative Programming: Concepts and ExperiencesA reflective language makes the language semantics open to user programs and allows them to access, extend, and modify it from within the same language framework. Because of its high flexibility and expressiveness, it can be an ideal platform for ...
Compiling a reflective language using MetaOCaml
GPCE '14A reflective language makes the language semantics open to user programs and allows them to access, extend, and modify it from within the same language framework. Because of its high flexibility and expressiveness, it can be an ideal platform for ...
Comments