我发现以下内容资源有助于理解类型推断,按照难度增加的顺序:
I found the following resources helpful for understanding type inference, in order of increasing difficulty:
- 免费提供的图书PLAI ,编程语言:应用程序和解释,草图基于统一的类型推断。 b $ b
- 夏季课程 将类型解释为抽象值 使用Haskell作为元语言呈现优雅的求值器,类型检查器,类型重建器和推理器。
- 图书EOPL ,编程语言要点。
- 书籍第22章(类型重构) TAPL ,类型和编程语言以及相应的OCaml实现 recon 和 fullrecon 。
- 第13章(类型重建)新书DCPL ,编程语言中的设计概念。
- 选择学术论文。
- 关闭编译器 TypeInference 是类型推理的数据流分析方法的示例,其更适合于动态语言Milner方法。
- Chapter 30 (Type Inference) of the freely available book PLAI, Programming Languages: Application and Interpretation, sketches unification-based type inference.
- The summer course Interpreting types as abstract values presents elegant evaluators, type checkers, type reconstructors and inferencers using Haskell as a metalanguage.
- Chapter 7 (Types) of the book EOPL, Essentials of Programming Languages.
- Chapter 22 (Type Reconstruction) of the book TAPL, Types and Programming Languages, and the corresponding OCaml implementations recon and fullrecon.
- Chapter 13 (Type Reconstruction) of the new book DCPL, Design Concepts in Programming Languages.
- Selection of academic papers.
- Closure compiler's TypeInference is an example of the data-flow analysis approach to type inference, which is better suited to dynamic languages that the Hindler Milner approach.
但是,由于***的学习方法是做,所以我强烈建议为玩具功能语言实现类型推断
However, since the best way to learn is to do, I strongly suggest implementing type inference for a toy functional language by working through a homework assignment of a programming languages course.
我推荐这两个可用的家庭作业在ML,你可以在不到一天内完成:
I recommend these two accessible homeworks in ML, which you can both complete in less than a day:
- PCF翻译(解决方案)
- PCF类型推断(解决方案)实施算法W
- PCF Interpreter (a solution) to warm up.
- PCF Type Inference (a solution) to implement algorithm W for Hindley-Milner type inference.
这些作业来自更高级的课程:
-
实施MiniML a>
多态,存在,递归类型(PDF)
双向类型检查(PDF)
子类型和对象(PDF)