Type Systems with Constraints for ML Type Inference with the Implementation in Haskell
Types in programming languages serve to rule out nonsensical programs. Although untyped languages provide flexibility, they can contain subtle bugs. Types can be intrinsic or extrinsic depending on whether they appear annotated in the source program or not. For intrinsic types, the compiler verifies that a program admits a given type (type checking); for extrinsic types the compiler infers an appropriate type (type inference). Type annotations can be cumbersome in a practice, and so extrinsic types are desirable.
There are trade-offs between expressiveness and static guarantees. System F is an expressive type system that exhibits parametric polymorphism, which can enable code reuse in practice. Unfortunately, type inference is undecidable for System F. Robin Milner invented the ML language as a restricted variant of System F with a decidable type inference.
In this talk, I will discuss how we adapted results of constraint-based type systems to develop a modular ML type inference algorithm in Haskell. We use constraints as an intermediate representation, which enables a modular type inference algorithm.
The idea of a modularity is that a compiler only produces constraints and invokes an independent solver. The strengths are extensibility, complexity reasoning, and easier proofs of properties. HM(X) is a constraint-based generalization of Damas-Milner type system parametrized by constraints. For ML, we use syntactic equality constraints. Our representation consists of generation, transformation, and constraint solving. We present the generation and transformation functions suitable for a Haskell implementation. In the constraint generation stage, a ML program is translated to constraints. The constraint transformation stage translates constraints to a form solvable by first-order unification. We consider an important optimization step: avoiding multiple solving of a same constraint set that can be caused by let expression. In the constraint solving stage, the Robinson’s algorithm for first-order unification is implemented.
Thu 22 NovDisplayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change
15:40 - 17:20 | |||
15:40 25mTalk | Degrees of Relatedness - A Unified Framework for Parametricity, Irrelevance, Ad Hoc Polymorphism, Intersections, Unions and Algebra in Dependent Type Theory PLNL | ||
16:05 25mTalk | A Verified Automatic Prover Based on Ordered Resolution PLNL Anders Schlichtkrull Technical University of Denmark, Jasmin Blanchette Vrije Universiteit Amsterdam, Dmitriy Traytel ETH Zurich | ||
16:30 25mTalk | Type Systems with Constraints for ML Type Inference with the Implementation in Haskell PLNL Alen Arslanagić University of Groningen | ||
16:55 25mTalk | Improving pattern matching style PLNL Alejandro Serrano Utrecht University, Netherlands |