Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Fulfilling OCaml Modules with Transparency

Published: 29 April 2024 Publication History
  • Get Citation Alerts
  • Abstract

    ML modules come as an additional layer on top of a core language to offer large-scale notions of composition and abstraction. They largely contributed to the success of OCaml and SML. While modules are easy to write for common cases, their advanced use may become tricky. Additionally, despite a long line of works, their meta-theory remains difficult to comprehend, with involved soundness proofs. In fact, the module layer of OCaml does not currently have a formal specification and its implementation has some surprising behaviors.
    Building on previous translations from ML modules to Fω, we propose a type system, called Mω, that covers a large subset of OCaml modules, including both applicative and generative functors, and extended with transparent ascription. This system produces signatures in an OCaml-like syntax extended with Fω quantifiers. We provide a reverse translation from Mω signatures to path-based source signatures along with a characterization of signature avoidance cases, making Mω signatures well suited to serve as a new internal representation for a typechecker.
    The soundness of the type system is shown by elaboration in Fω. We improve over previous encodings of sealing within applicative functors, by the introduction of transparent existential types, a weaker form of existential types that can be lifted out of universal and arrow types. This shines a new light on the form of abstraction provided by applicative functors and brings their treatment much closer to those of generative functors.

    Supplementary Material

    Auxiliary Archive (oopslaa24main-p23-p-archive.zip)
    This document contains the supplementary material for the main paper Fulfilling OCaml modules with transparency. §1 contains a few small additional illustrative examples. This document also provides the complete set of typing rules (§2) and anchoring rules (§3) for M𝜔, typing rules for F𝜔 (§4) and the elaboration rules of M𝜔 into F𝜔 (§5). Proofs of the anchoring properties can be found in §3.

    References

    [1]
    Sandip K. Biswas. 1995. Higher-Order Functors with Transparent Signatures. In Proceedings of the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’95). Association for Computing Machinery, New York, NY, USA. 154–163. isbn:0897916921 https://doi.org/10.1145/199448.199478
    [2]
    Clément Blaudeau, Didier Rémy, and Gabriel Radanne. 2024. Fulfilling OCaml modules with transparency (supplementary material). https://doi.org/10.1145/3649818
    [3]
    Karl Crary. 2017. Modules, Abstraction, and Parametric Polymorphism. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). ACM, New York, NY, USA. 100–113. isbn:978-1-4503-4660-3 https://doi.org/10.1145/3009837.3009892 event-place: Paris, France
    [4]
    Karl Crary. 2019. Fully abstract module compilation. Proc. ACM Program. Lang., 3, POPL (2019), Article 10, jan, 29 pages. https://doi.org/10.1145/3290323
    [5]
    Karl Crary. 2020. A focused solution to the avoidance problem. Journal of Functional Programming, 30 (2020), e24. issn:0956-7968, 1469-7653 https://doi.org/10.1017/S0956796820000222
    [6]
    Derek Dreyer. 2007. Recursive type generativity. Journal of Functional Programming, 17, 4-5 (2007), 433–471. https://doi.org/10.1017/S0956796807006429
    [7]
    Derek Dreyer, Karl Crary, and Robert Harper. 2003. A type system for higher-order modules. In Conference Record of POPL 2003: The 30th SIGPLAN-SIGACT Symposium on Principles of Programming Languages, New Orleans, Louisisana, USA, January 15-17, 2003, Alex Aiken and Greg Morrisett (Eds.). ACM, 236–249. https://doi.org/10.1145/604131.604151
    [8]
    Derek Dreyer, Robert Harper, and Karl Crary. 2005. Understanding and evolving the ML module system. Ph. D. Dissertation. USA. isbn:0542015501 AAI3166274
    [9]
    Jacques Guarrigue and Leo White. 2014. Type-level module aliases: independent and equal. ML Family/OCaml Users and Developers workshops. https://www.math.nagoya-u.ac.jp/~garrigue/papers/modalias.pdf
    [10]
    Robert Harper and Mark Lillibridge. 1994. A Type-Theoretic Approach to Higher-Order Modules with Sharing. In Proceedings of the 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’94). Association for Computing Machinery, New York, NY, USA. 123–137. isbn:0897916360 https://doi.org/10.1145/174675.176927
    [11]
    Robert Harper, John C. Mitchell, and Eugenio Moggi. 1989. Higher-Order Modules and the Phase Distinction. In Proceedings of the 17th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’90). Association for Computing Machinery, New York, NY, USA. 341–354. isbn:0897913434 https://doi.org/10.1145/96709.96744
    [12]
    Xavier Leroy. 1994. Manifest Types, Modules, and Separate Compilation. In Proceedings of the 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’94). Association for Computing Machinery, New York, NY, USA. 109–122. isbn:0897916360 https://doi.org/10.1145/174675.176926
    [13]
    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. ACM Press, San Francisco, California, United States. 142–153. isbn:978-0-89791-692-9 https://doi.org/10.1145/199448.199476
    [14]
    Xavier Leroy. 2000. A modular module system. J. Funct. Program., 10, 3 (2000), 269–303. http://journals.cambridge.org/action/displayAbstract?aid=54525
    [15]
    David B. MacQueen. 1986. Using Dependent Types to Express Modular Structure. Association for Computing Machinery, New York, NY, USA. 277–286. isbn:9781450373470 https://doi.org/10.1145/512644.512670
    [16]
    Anil Madhavapeddy, Richard Mortier, Charalampos Rotsos, David J. Scott, Balraj Singh, Thomas Gazagnaire, Steven Smith, Steven Hand, and Jon Crowcroft. 2013. Unikernels: library operating systems for the cloud. In Architectural Support for Programming Languages and Operating Systems, ASPLOS 2013, Houston, TX, USA, March 16-20, 2013, Vivek Sarkar and Rastislav Bodík (Eds.). ACM, 461–472. https://doi.org/10.1145/2451116.2451167
    [17]
    John C. Mitchell and Gordon D. Plotkin. 1985. Abstract Types Have Existential Types. In Proceedings of the 12th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL ’85). Association for Computing Machinery, New York, NY, USA. 37–51. isbn:0897911474 https://doi.org/10.1145/318593.318606
    [18]
    Benoît Montagu. 2010. Programming with first-class modules in a core language with subtyping, singleton kinds and open existential types. (Programmer avec des modules de première classe dans un langage noyau pourvu de sous-typage, sortes singletons et types existentiels ouverts). École Polytechnique, Palaiseau, France. https://tel.archives-ouvertes.fr/tel-00550331
    [19]
    Benoît Montagu and Didier Rémy. 2009. Modeling Abstract Types in Modules with Open Existential Types. In Proceedings of the 36th ACM Symposium on Principles of Programming Languages (POPL’09). Savannah, GA, USA. 354–365. isbn:978-1-60558-379-2 https://doi.org/10.1145/1480881.1480926
    [20]
    Gabriel Radanne, Thomas Gazagnaire, Anil Madhavapeddy, Jeremy Yallop, Richard Mortier, Hannes Mehnert, Mindy Perston, and David Scott. 2019. Programming Unikernels in the Large via Functor Driven Development. arxiv:1905.02529.
    [21]
    Andreas Rossberg. 2018. 1ML - Core and modules united. J. Funct. Program., 28 (2018), e22. https://doi.org/10.1017/S0956796818000205
    [22]
    Andreas Rossberg and Derek Dreyer. 2013. Mixin’Up the ML Module System. ACM Trans. Program. Lang. Syst., 35, 1 (2013), April, 2:1–2:84. issn:0164-0925 https://doi.org/10.1145/2450136.2450137
    [23]
    Andreas Rossberg, Claudio Russo, and Derek Dreyer. 2014. F-ing modules. Journal of Functional Programming, 24, 5 (2014), Sept., 529–607. issn:0956-7968, 1469-7653 https://doi.org/10.1017/S0956796814000264
    [24]
    Claudio V. Russo. 2000. First-Class Structures for Standard ML. Nord. J. Comput., 7, 4 (2000), 348–374.
    [25]
    Claudio V. Russo. 2004. Types for Modules. Electronic Notes in Theoretical Computer Science, 60 (2004), 3–421. issn:1571-0661 https://doi.org/10.1016/S1571-0661(05)82621-0
    [26]
    Chung-Chieh Shan. 2004. Higher-order modules in System F^ω and Haskell. 01.
    [27]
    Zhong Shao. 1999. Transparent Modules with Fully Syntactic Signatures. In Proceedings of the fourth ACM SIGPLAN International Conference on Functional Programming (ICFP ’99), Paris, France, September 27-29, 1999. ACM, 220–232. https://doi.org/10.1145/317636.317801
    [28]
    Filip Sieczkowski, Sergei Stepanenko, Jonathan Sterling, and Lars Birkedal. 2024. The Essence of Generalized Algebraic Data Types. Proc. ACM Program. Lang., 8, POPL (2024), Article 24, jan, 29 pages. https://doi.org/10.1145/3632866
    [29]
    Leo White, Frédéric Bour, and Jeremy Yallop. 2014. Modular implicits. In Proceedings ML Family/OCaml Users and Developers workshops, ML/OCaml 2014, Gothenburg, Sweden, September 4-5, 2014. 22–63. https://doi.org/10.4204/EPTCS.198.2

    Cited By

    View all

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 8, Issue OOPSLA1
    April 2024
    1492 pages
    EISSN:2475-1421
    DOI:10.1145/3554316
    Issue’s Table of Contents
    This work is licensed under a Creative Commons Attribution International 4.0 License.

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 29 April 2024
    Published in PACMPL Volume 8, Issue OOPSLA1

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. F-omega
    2. ML
    3. applicative functors
    4. existential types
    5. signature avoidance

    Qualifiers

    • Research-article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • 0
      Total Citations
    • 84
      Total Downloads
    • Downloads (Last 12 months)84
    • Downloads (Last 6 weeks)24
    Reflects downloads up to 10 Aug 2024

    Other Metrics

    Citations

    Cited By

    View all

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Full Access

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media