Journal of Functional Programming · 2006 · 213 citations · 38 references
ComputingComputer ScienceFormal MethodsProgramming LanguagesTheory Of ComputationData TypesFunctional ProgrammingType CheckingType SystemsLocal InferencePolymorphic Type SystemsPolymorphic TypesPractical InferenceType InferenceType PolymorphismType TheoryTyped Lambda Calculus
Abstract Haskell's popularity has driven the need for ever more expressive type system features, most of which threaten the decidability and practicality of Damas-Milner type inference. One such feature is the ability to write functions with higher-rank types – that is, functions that take polymorphic functions as their arguments. Complete type inference is known to be undecidable for higher-rank (impredicative) type systems, but in practice programmers are more than willing to add type annotations to guide the type inference engine, and to document their code. However, the choice of just what annotations are required, and what changes are required in the type system and its inference algorithm, has been an ongoing topic of research. We take as our starting point a λ-calculus proposed by Odersky and Läufer. Their system supports arbitrary-rank polymorphism through the exploitation of type annotations on λ-bound arguments and arbitrary sub-terms. Though elegant, and more convenient than some other proposals, Odersky and Läufer's system requires many annotations. We show how to use local type inference (invented by Pierce and Turner) to greatly reduce the annotation burden, to the point where higher-rank types become eminently usable. Higher-rank types have a very modest impact on type inference. We substantiate this claim in a very concrete way, by presenting a complete type-inference engine, written in Haskell, for a traditional Damas-Milner type system, and then showing how to extend it for higher-rank types. We write the type-inference engine using a monadic framework: it turns out to be a particularly compelling example of monads in action. The paper is long, but is strongly tutorial in style. Although we use Haskell as our example source language, and our implementation language, much of our work is directly applicable to any ML-like functional language.
38
A theory of type polymorphism in programming
Robin Milner · Journal of Computer and System Sciences · 1978 · 2.2K citations · Full text
Imperative functional programming
Simon Jones, Philip Wadler · 1993 · 1.2K citations · Full text
Principal type-schemes for functional programs
Robin Milner · 1982 · 1.1K citations
The implementation of functional programming languages
Microprocessors and Microsystems · 1987 · 1.1K citations
Andrew Gill, John Launchbury, Simon Jones · 1993 · 415 citations · Full text