作为参数化多态的结构子类型化
Structural Subtyping as Parametric Polymorphism
AI总结:
本文系统研究结构子类型化与参数化多态的相对表达能力,基于Church风格λ-演算证明完全子类型化无法通过多态编码,但受限子类型化可由特定多态形式编码。
摘要:
结构子类型化和参数化多态为程序员提供了相似的灵活性和可重用性。例如,这两个特性都使程序员能够将一个更宽的记录作为参数传递给一个期望较窄记录的函数。然而,它们实现这一目标的方式大不相同,且它们之间关系的精确细节在文献中充其量只作为民间知识存在。在本文中,我们系统地研究了结构子类型化和参数化多态的相对表达能力。我们将研究重点放在确定参数化多态(以行多态和存在多态的形式)在多大程度上能够为变体类型和记录类型编码结构子类型化。我们的研究基于各种扩展了记录和变体的 Church 风格 $λ$-演算、不同形式的结构子类型化,以及行多态和存在多态。我们通过展示演算之间的组合式翻译来表征表达能力。对于每种翻译,我们证明了类型保持和操作对应性结果。我们还证明了一些不存在性结果。通过对源类型和目标类型施加限制,我们揭示了表达能力图景中更深层的微妙之处,这些限制使得原本不可能的翻译得以定义。更具体地说,我们证明了完全子类型化无法通过多态来编码,但我们展示了受限形式的子类型化可以通过特定形式的多态来编码。
英文摘要:
Structural subtyping and parametric polymorphism provide similar flexibility and reusability to programmers. For example, both features enable the programmer to provide a wider record as an argument to a function that expects a narrower one. However, the means by which they do so differs substantially, and the precise details of the relationship between them exists, at best, as folklore in literature. In this paper, we systematically study the relative expressive power of structural subtyping and parametric polymorphism. We focus our investigation on establishing the extent to which parametric polymorphism, in the form of row and presence polymorphism, can encode structural subtyping for variant and record types. We base our study on various Church-style $λ$-calculi extended with records and variants, different forms of structural subtyping, and row and presence polymorphism. We characterise expressiveness by exhibiting compositional translations between calculi. For each translation we prove a type preservation and operational correspondence result. We also prove a number of non-existence results. By imposing restrictions on both source and target types, we reveal further subtleties in the expressiveness landscape, the restrictions enabling otherwise impossible translations to be defined. More specifically, we prove that full subtyping cannot be encoded via polymorphism, but we show that several restricted forms of subtyping can be encoded via particular forms of polymorphism.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。