X Design Notes: Unifying OCaml Modules and Values
5 days ago
- #type-systems
- #OCaml
- #programming-languages
- Cubiml and PolySubML introduced structural subtyping and higher rank types in ML-like languages.
- The next language, X, aims to support all notable OCaml features, starting with modules.
- OCaml modules bundle data and types, allowing them to be passed around like records.
- X plans to unify OCaml's module and value syntax, reducing complexity.
- OCaml's module system is separate from its value system, with distinct syntax for modules (struct/sig) and values.
- X will support both OCaml's struct/sig syntax and plain record syntax for modules.
- X introduces 'alias members' in records to support type aliases within modules.
- Existential types in X allow for abstraction, hiding implementation details from users.
- X's 'let mod' syntax simplifies the creation of abstract modules, similar to OCaml's functors.
- Functors in X are treated as ordinary functions operating on modules, simplifying the language.
- X requires explicit type annotations for module bindings to handle existential types correctly.
- Generative functors in X ensure fresh types are created on each call, unlike OCaml's applicative functors.
- Unifying modules and values in X reduces language complexity while maintaining expressivity.