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.
Mots clés
Software and its engineering → Functional languages Semantics Modules / packages • Theory of computation → Type theory Type structures existential types
signature avoidance
applicative functors
F-omega
ML
Functional languages
Semantics
Modules / packages
Type theory
Existential types
CCS Concepts: Software and its engineering → Functional languages Semantics Modules / packages • Theory of computation → Type theory Type structures existential types
CCS Concepts:
Software and its engineering → Functional languages
• Theory of computation → Type theory
Type structures existential types
Domaines
Langage de programmation [cs.PL]Origine | Publication financée par une institution |
---|