skip to main content
10.1145/3486609.3487209acmconferencesArticle/Chapter ViewAbstractPublication PagesgpceConference Proceedingsconference-collections
research-article

Type-safe generation of modules in applicative and generative styles

Published:22 November 2021Publication History

ABSTRACT

The MetaML approach for multi-stage programming provides the static guarantee of type safety and scope safety for generated code, regardless of the values of static parameters. Modules are indispensable to build large-scale programs in ML-like languages, however, they have a performance problem. To solve this problem, several languages proposed recently allow one to generate ML-style modules. Unfortunately, those languages had the problems of limited expressiveness, incomplete proofs, and code explosion.

This paper proposes two-stage programming languages for module generation, which solve all the above issues. Our languages accommodate two styles: first-class modules with generative functors and second-class modules with applicative functors. Module generation in both styles is shown to have their own merits by concrete examples. We present type systems, and type-preserving translations from our languages to plain MetaOCaml. We also show the results of performance measurements, which confirms the effectiveness of our languages.

Skip Supplemental Material Section

Supplemental Material

splashws21gpcemain-p35-p-video.mp4

mp4

89.8 MB

References

  1. Cristiano Calcagno, Eugenio Moggi, and Walid Taha. 2004. ML-Like Inference for Classifiers. In Programming Languages and Systems, 13th European Symposium on Programming, ESOP 2004, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2004, Barcelona, Spain, March 29 - April 2, 2004, Proceedings, David A. Schmidt (Ed.) (Lecture Notes in Computer Science, Vol. 2986). Springer, 79–93. https://doi.org/10.1007/978-3-540-24725-8_7 Google ScholarGoogle ScholarCross RefCross Ref
  2. 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 (2009), 509–543. https://doi.org/10.1017/S0956796809007205 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Rowan Davies. 1996. A Temporal-Logic Approach to Binding-Time Analysis. In Proceedings, 11th Annual IEEE Symposium on Logic in Computer Science, New Brunswick, New Jersey, USA, July 27-30, 1996. 184–195. https://doi.org/10.1109/LICS.1996.561317 Google ScholarGoogle ScholarCross RefCross Ref
  4. Derek Dreyer. 2005. Understanding and Evolving the ML Module System. Ph.D. Dissertation. USA. isbn:0542015501 AAI3166274.Google ScholarGoogle Scholar
  5. Sebastian Erdweg and Klaus Ostermann. 2017. A Module-System Discipline for Model-Driven Software Development. Art Sci. Eng. Program., 1, 2 (2017), 9. https://doi.org/10.22152/programming-journal.org/2017/1/9Google ScholarGoogle ScholarCross RefCross Ref
  6. Xavier Leroy et al.. 2019. Chapter 21. Optimisation with Flambda. The OCaml system release 4.09. https://caml.inria.fr/pub/docs/manual-ocaml/flambda.htmlGoogle ScholarGoogle Scholar
  7. Matthew Flatt. 2013. Submodules in racket: you want it when, again? In Generative Programming: Concepts and Experiences, GPCE’13, Indianapolis, IN, USA - October 27 - 28, 2013, Jaakko Järvi and Christian Kästner (Eds.). ACM, 13–22. https://doi.org/10.1145/2517208.2517211 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Yuichiro Hanada and Atsushi Igarashi. 2014. On Cross-Stage Persistence in Multi-Stage Programming. In Functional and Logic Programming - 12th International Symposium, FLOPS 2014, Kanazawa, Japan, June 4-6, 2014. Proceedings, Michael Codish and Eijiro Sumii (Eds.) (Lecture Notes in Computer Science, Vol. 8475). Springer, 103–118. https://doi.org/10.1007/978-3-319-07151-0_7 Google ScholarGoogle ScholarCross RefCross Ref
  9. Jun Inoue, Oleg Kiselyov, and Yukiyoshi Kameyama. 2016. Staging beyond terms: prospects and challenges. In Proceedings of the 2016 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, PEPM 2016, St. Petersburg, FL, USA, January 20 - 22, 2016. 103–108. https://doi.org/10.1145/2847538.2847548 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Oleg Kiselyov. 2014. The Design and Implementation of BER MetaOCaml - System Description. In Functional and Logic Programming - 12th International Symposium, FLOPS 2014, Kanazawa, Japan, June 4-6, 2014. Proceedings. 86–102. https://doi.org/10.1007/978-3-319-07151-0_6 Google ScholarGoogle ScholarCross RefCross Ref
  11. Xavier Leroy. 1995. Applicative Functors and Fully Transparent Higher-Order Modules. In Proceedings of the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’95). Association for Computing Machinery, New York, NY, USA. 142–153. isbn:0897916921 https://doi.org/10.1145/199448.199476 Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Lionel Parreaux and Amir Shaikhha. 2020. Multi-Stage Programming in the Large with Staged Classes. In Proceedings of the 19th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences (GPCE 2020). Association for Computing Machinery, New York, NY, USA. 35–49. isbn:9781450381741 https://doi.org/10.1145/3425898.3426961 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Lionel Parreaux, Amir Shaikhha, and Christoph E. Koch. 2017. Squid: type-safe, hygienic, and reusable quasiquotes. In Proceedings of the 8th ACM SIGPLAN International Symposium on Scala, SCALA@SPLASH 2017, Vancouver, BC, Canada, October 22-23, 2017, Heather Miller, Philipp Haller, and Ondrej Lhoták (Eds.). ACM, 56–66. https://doi.org/10.1145/3136000.3136005 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Gabriel Radanne, Thomas Gazagnaire, Anil Madhavapeddy, Jeremy Yallop, Richard Mortier, Hannes Mehnert, Mindy Preston, and David J. Scott. 2019. Programming Unikernels in the Large via Functor Driven Development. CoRR, abs/1905.02529 (2019), arxiv:1905.02529. arxiv:1905.02529Google ScholarGoogle Scholar
  15. Yuhi Sato, Yukiyoshi Kameyama, and Takahisa Watanabe. 2020. Module generation without regret. In Proceedings of the 2020 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, PEPM@POPL 2020, New Orleans, LA, USA, January 20, 2020, Casper Bach Poulsen and Zhenjiang Hu (Eds.). ACM, 1–13. https://doi.org/10.1145/3372884.3373160 Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Tim Sheard. 1998. Using MetaML: A Staged Programming Language. In Advanced Functional Programming, Third International School, Braga, Portugal, September 12-19, 1998, Revised Lectures, S. Doaitse Swierstra, Pedro Rangel Henriques, and José Nuno Oliveira (Eds.) (Lecture Notes in Computer Science, Vol. 1608). Springer, 207–239. https://doi.org/10.1007/10704973_5 Google ScholarGoogle ScholarCross RefCross Ref
  17. Walid Taha. 2003. A Gentle Introduction to Multi-stage Programming. In Domain-Specific Program Generation, International Seminar, Dagstuhl Castle, Germany, March 23-28, 2003, Revised Papers. 30–50. https://doi.org/10.1007/978-3-540-25935-0_3 Google ScholarGoogle ScholarCross RefCross Ref
  18. Walid Taha and Michael Florentin Nielsen. 2003. Environment Classifiers. SIGPLAN Not., 38, 1 (2003), Jan., 26–37. issn:0362-1340 https://doi.org/10.1145/640128.604134 Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Walid Taha and Tim Sheard. 1997. Multi-Stage Programming. In Proceedings of the 1997 ACM SIGPLAN International Conference on Functional Programming (ICFP ’97), Amsterdam, The Netherlands, June 9-11, 1997, Simon L. Peyton Jones, Mads Tofte, and A. Michael Berman (Eds.). ACM, 321. https://doi.org/10.1145/258948.258990 Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Takahisa Watanabe and Yukiyoshi Kameyama. 2018. Program generation for ML modules (short paper). In Proceedings of the ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, Los Angeles, CA, USA, January 8-9, 2018. 60–66. https://doi.org/10.1145/3162072 Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Jeremy Yallop. 2016. Staging generic programming. In Proceedings of the 2016 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, PEPM 2016, St. Petersburg, FL, USA, January 20 - 22, 2016. 85–96. https://doi.org/10.1145/2847538.2847546 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Type-safe generation of modules in applicative and generative styles

      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
        GPCE 2021: Proceedings of the 20th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences
        October 2021
        209 pages
        ISBN:9781450391122
        DOI:10.1145/3486609

        Copyright © 2021 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 ACM 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: 22 November 2021

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        Overall Acceptance Rate56of180submissions,31%

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader