Fulfilling OCaml Modules with Transparency - Inria - Institut national de recherche en sciences et technologies du numérique
Article Dans Une Revue Proceedings of the ACM on Programming Languages Année : 2024

Fulfilling OCaml Modules with Transparency

Résumé

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.
Fichier principal
Vignette du fichier
3649818.pdf (369.19 Ko) Télécharger le fichier
Origine Publication financée par une institution

Dates et versions

hal-04794404 , version 1 (21-11-2024)

Licence

Identifiants

Citer

Blaudeau Clement, Didier Rémy, Gabriel Radanne. Fulfilling OCaml Modules with Transparency. Proceedings of the ACM on Programming Languages, 2024, 8 (OOPSLA1), pp.194-222. ⟨10.1145/3649818⟩. ⟨hal-04794404⟩
0 Consultations
0 Téléchargements

Altmetric

Partager

More