多态变体的集合论类型
Set-Theoretic Types for Polymorphic Variants
摘要:
多态变体是OCaml语言的一个有用的特性,其当前的定义和实现依赖于kinding约束来通过统一来模拟子类型关系。这会产生一种尴尬的形式化,并导致类型系统的行为在某些情况下不直观和/或限制性过强。在这项工作中,我们提出了一种替代形式化的多态变体,基于集合理论的类型和子类型,产生一个更干净,更精简的系统。我们的形式化比当前的形式化更有表现力(它在保持类型安全的同时输入更多的程序),它可以内化一些元理论属性,并且它删除了当前实现的一些病态情况,从而产生了一个更直观,因此,可预测的类型系统。更一般地说,这项工作展示了如何将成熟的联合类型添加到ML家族的函数式语言中,这些语言通常依赖于Hindley-Milner类型系统。另外,我们的系统还改进了语义子类型的理论,特别是通过证明类型重建算法的完备性。
英文摘要:
Polymorphic variants are a useful feature of the OCaml language whose current definition and implementation rely on kinding constraints to simulate a subtyping relation via unification. This yields an awkward formalization and results in a type system whose behaviour is in some cases unintuitive and/or unduly restrictive. In this work, we present an alternative formalization of poly-morphic variants, based on set-theoretic types and subtyping, that yields a cleaner and more streamlined system. Our formalization is more expressive than the current one (it types more programs while preserving type safety), it can internalize some meta-theoretic properties, and it removes some pathological cases of the current implementation resulting in a more intuitive and, thus, predictable type system. More generally, this work shows how to add full-fledged union types to functional languages of the ML family that usually rely on the Hindley-Milner type system. As an aside, our system also improves the theory of semantic subtyping, notably by proving completeness for the type reconstruction algorithm.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。