Skip to main content
QUICK REVIEW

[论文解读] Kind Inference for Datatypes: Technical Supplement

Ningning Xie, Richard A. Eisenberg|arXiv (Cornell University)|Nov 11, 2019
Logic, programming, and type systems参考文献 50被引用 4
一句话总结

本技术附录为支持可见依赖量词(VDQ)、数据类型提升和部分类型签名等高级特性的Haskell数据类型形式化了种类推断。该工作提出了一套严谨的类型系统,包含形式化的类型规则、基于替换的语义以及对关键性质(如唯一性与类型安全性)的证明,从而在GHC风格系统中支持复杂类型级别构造下的安全且可扩展的种类推断。

ABSTRACT

In recent years, languages like Haskell have seen a dramatic surge of new features that significantly extends the expressive power of their type systems. With these features, the challenge of kind inference for datatype declarations has presented itself and become a worthy research problem on its own. This paper studies kind inference for datatypes. Inspired by previous research on type-inference, we offer declarative specifications for what datatype declarations should be accepted, both for Haskell98 and for a more advanced system we call PolyKinds, based on the extensions in modern Haskell, including a limited form of dependent types. We believe these formulations to be novel and without precedent, even for Haskell98. These specifications are complemented with implementable algorithmic versions. We study soundness, completeness and the existence of principal kinds in these systems, proving the properties where they hold. This work can serve as a guide both to language designers who wish to formalize their datatype declarations and also to implementors keen to have principled inference of principal types. This technical supplement to Kind Inference for Datatypes serves to expand upon the text in the main paper. It contains detailed typing rules, proofs, and connections to the Glasgow Haskell Compiler (GHC).

研究动机与目标

  • 为支持可见依赖量词(VDQ)、数据类型提升和部分类型签名等高级类型级别特性的Haskell数据类型形式化种类推断。
  • 扩展类型判断与依赖分析,以处理类型中的数据构造子及种类级别的依赖关系。
  • 在形式化演算中证明种类推断系统的若干关键元理论性质,如唯一性与类型安全性。
  • 弥合理论种类推断与GHC中实际实现之间的鸿沟,确保正确性与可扩展性。

提出的方法

  • 引入一个形式化类型系统,其类型判断用于种类推断,并扩展核心规则以处理多态与依赖种类。
  • 通过上下文Θ定义基于替换的语义,以追踪种类变量的实例化及其依赖关系。
  • 扩展依赖分析,以包含类型中数据构造子的使用,确保即使构造子出现在类型级别表达式中,种类推断仍正确。
  • 通过为依赖类型变量显式添加种类注解,支持可见依赖量词,避免推断过程中的歧义。
  • 采用基于约束的方法进行延迟求解,使系统可与GHC现有的约束求解架构无缝集成。
  • 通过结构归纳与替换引理证明种类推断的唯一性,确保种类分配的唯一性与确定性。

实验结果

研究问题

  • RQ1如何将种类推断安全地扩展以支持数据类型声明中的可见依赖量词?
  • RQ2为支持将数据构造子作为类型级别值使用,类型判断与依赖分析规则需要做出哪些修改?
  • RQ3如何在不破坏多态递归的前提下,将带有种类注解的部分类型签名集成到种类推断过程中?
  • RQ4对于支持这些高级特性的种类推断系统,可证明哪些形式化保证(如唯一性与类型安全性)?
  • RQ5所提出的系统如何与GHC现有的基于约束的类型推断架构集成?

主要发现

  • 该系统能正确推断出包含可见依赖量词的数据类型的种类,确保依赖变量被显式声明并正确作用域化。
  • 通过扩展的依赖分析支持类型中的数据构造子,该分析可追踪构造子级别的依赖关系。
  • 通过修改后的类型判断规则处理带有种类注解的部分类型签名,将种类变量引入作用域,同时保持类型安全性。
  • 该系统证明了种类推断的唯一性:若某种类可推导,则其为唯一最通用的种类。
  • 该形式化系统与GHC的基于约束的推断兼容,支持延迟约束求解,同时保持正确性与类型安全性。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。