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 $\lambda_{2,G\mu}$, a classical constraint-based GADT calculus, into cDOT.


翻译:许多面向对象传统的编程语言现已以某种形式支持模式匹配。历史范例包括Scala和Ceylon,以及较新加入的Java、Kotlin、TypeScript和Flow。然而,在这些语言中,对泛型类层次结构的模式匹配通常会导致令人困惑的类型错误。然而,这种特性组合在许多场景中自然出现,例如在操作类型化抽象语法树(AST)时。为了正确支持这一特性,编译器需要实现一种子类型重构的形式:即在模式匹配过程中重构运行时发现的子类型信息的能力。我们引入了cDOT,这是一种属于依赖对象类型(DOT)家族的新演算,旨在作为子类型重构的形式化基础。cDOT继承自pDOT(其本身是Scala的形式化基础),可用于编码高级面向对象特性,例如泛型继承、类型构造器变体、F有界多态性和一等递归模块。我们通过将经典的基于约束的GADT演算$\lambda_{2,G\mu}$编码为cDOT,证明了子类型重构涵盖了GADT。

1
下载
关闭预览

相关内容

专知会员服务
162+阅读 · 2020年1月16日
机器学习入门的经验与建议
专知会员服务
94+阅读 · 2019年10月10日
【哈佛大学商学院课程Fall 2019】机器学习可解释性
专知会员服务
105+阅读 · 2019年10月9日
GNN 新基准!Long Range Graph Benchmark
图与推荐
0+阅读 · 2022年10月18日
VCIP 2022 Call for Demos
CCF多媒体专委会
1+阅读 · 2022年6月6日
Hierarchically Structured Meta-learning
CreateAMind
27+阅读 · 2019年5月22日
Transferring Knowledge across Learning Processes
CreateAMind
29+阅读 · 2019年5月18日
IEEE | DSC 2019诚邀稿件 (EI检索)
Call4Papers
10+阅读 · 2019年2月25日
Unsupervised Learning via Meta-Learning
CreateAMind
44+阅读 · 2019年1月3日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
18+阅读 · 2018年12月24日
【论文】变分推断(Variational inference)的总结
机器学习研究会
39+阅读 · 2017年11月16日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
1+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
An Overview on Machine Translation Evaluation
Arxiv
14+阅读 · 2022年2月22日
Arxiv
12+阅读 · 2021年6月29日
Arxiv
13+阅读 · 2021年5月25日
Arxiv
15+阅读 · 2020年12月17日
Arxiv
20+阅读 · 2020年6月8日
Arxiv
13+阅读 · 2019年11月14日
Arxiv
10+阅读 · 2017年12月29日
VIP会员
最新内容
BES:让语言模型通过双向进化搜索自我改进
专知会员服务
0+阅读 · 5月30日
以色列-美国-伊朗战争中的无人机:关键要点
专知会员服务
3+阅读 · 5月30日
《Palantir任务保障性软件安全标准(MA-S2)》
专知会员服务
7+阅读 · 5月30日
基于声学的无人机检测技术综述
专知会员服务
5+阅读 · 5月30日
《当代混合战争分析框架:俄乌战争经验教训》
战略前沿人工智能的再思考(中文)
专知会员服务
7+阅读 · 5月29日
《量化地基防空系统间接效应的博弈论方法》
专知会员服务
5+阅读 · 5月29日
相关资讯
GNN 新基准!Long Range Graph Benchmark
图与推荐
0+阅读 · 2022年10月18日
VCIP 2022 Call for Demos
CCF多媒体专委会
1+阅读 · 2022年6月6日
Hierarchically Structured Meta-learning
CreateAMind
27+阅读 · 2019年5月22日
Transferring Knowledge across Learning Processes
CreateAMind
29+阅读 · 2019年5月18日
IEEE | DSC 2019诚邀稿件 (EI检索)
Call4Papers
10+阅读 · 2019年2月25日
Unsupervised Learning via Meta-Learning
CreateAMind
44+阅读 · 2019年1月3日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
18+阅读 · 2018年12月24日
【论文】变分推断(Variational inference)的总结
机器学习研究会
39+阅读 · 2017年11月16日
相关论文
An Overview on Machine Translation Evaluation
Arxiv
14+阅读 · 2022年2月22日
Arxiv
12+阅读 · 2021年6月29日
Arxiv
13+阅读 · 2021年5月25日
Arxiv
15+阅读 · 2020年12月17日
Arxiv
20+阅读 · 2020年6月8日
Arxiv
13+阅读 · 2019年11月14日
Arxiv
10+阅读 · 2017年12月29日
相关基金
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
1+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
Top
微信扫码咨询专知VIP会员