OCaml modules: formalization, insights and improvements
Abstract
Modularity is a key tool for building reusable and structured code. While the OCaml module system is known for being expressive and powerful, specifying its behavior and formalizing its properties has proven to be hard. We propose a comprehensive description of a generative subset of the OCaml module system (called the source system), with a focus on the signature avoidance problem. By extending the signature syntax with existential types (inspired by Fω ), we describe an alternate system (called canonical ) with a simpler set of judgments that both solves the issues of the source description and provides formal guarantees through elaboration into Fω . We show that the canonical system is more expressive than the source one and state at which conditions canonical typing derivations can be translated back into the source typing. As a middle point between the path-based representation of OCaml and the formal description of Fω , the canonical presentation is a framework which we believe could support numerous features (applicative functors, transparent ascription, module aliases, etc.) and could serve as a basis for a redefinition of module system of an industry-grade language as OCaml.
Domains
Computer Science [cs]Origin | Files produced by the author(s) |
---|