arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2209.07427cs.PL
收藏

DOT的一个实例:具有模式匹配和GADT式推理的对象的理论基础

A case for DOT: Theoretical Foundations for Objects With Pattern Matching and GADT-style Reasoning

Aleksander Boruch-Gruszecki, Radosław Waśko, Yichen Xu, Lionel Parreaux

摘要:

许多OO传统的程序设计语言现在都以某种形式支持模式匹配。历史上的例子包括Scala和Ceylon,以及最近增加的Java,Kotlin,TypeScript和Flow。但是,目前在这些语言中,泛型类层次结构上的模式匹配会导致令人费解的类型错误。然而,这种特性的组合在许多场景中会自然发生,比如在操作类型化的AST时。为了正确地支持它,编译器需要实现一种形式的子类型重构:重构在运行时在模式匹配期间未发现的子类型信息的能力。我们介绍cDOT,一个新的演算在家庭的依赖对象类型(DOT)打算作为一个正式的基础子类型重建。作为pDOT的后代,cDOT本身是Scala的正式基础,cDOT可用于编码高级面向对象功能,如泛型继承,类型构造函数变化,F有界多态性和第一类递归模块。我们证明了子类型重建包含GADT编码$λ_{2,Gμ}$,一个经典的基于约束的GADT演算,到cDOT。

英文摘要:

Many programming languages in the OO tradition now support pattern matching in some form. Historical examples include Scala and Ceylon, with the more recent additions of Java, Kotlin, TypeScript, and Flow. But pattern matching on generic class hierarchies currently results in puzzling type errors in most of these languages. Yet this combination of features occurs naturally in many scenarios, such as when manipulating typed ASTs. To support it properly, compilers need to implement a form of subtyping reconstruction: the ability to reconstruct subtyping information uncovered at runtime during pattern matching. We introduce cDOT, a new calculus in the family of Dependent Object Types (DOT) intended to serve as a formal foundation for subtyping reconstruction. Being descended from pDOT, itself a formal foundation for Scala, cDOT can be used to encode advanced object-oriented features such as generic inheritance, type constructor variance, F-bounded polymorphism, and first-class recursive modules. We demonstrate that subtyping reconstruction subsumes GADTs by encoding $λ_{2,Gμ}$, a classical constraint-based GADT calculus, into cDOT.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑