Improved Inference for Checking Annotations

We consider type inference in the Hindley/Milner system extended with type annotations and constraints with a particular focus on Haskell-style type classes. We observe that standard inference algorithms are incomplete in the presence of nested type annotations. To improve the situation we introduce a novel inference scheme for checking type annotations. Our inference scheme is also incomplete in general but improves over existing implementations as found e.g. in the Glasgow Haskell Compiler (GHC). For certain cases (e.g. Haskell 98) our inference scheme is complete. Our approach has been fully implemented as part of the Chameleon system (experimental version of Haskell).

[1]  John C. Mitchell,et al.  Theoretical aspects of object-oriented programming: types, semantics, and language design , 1994, Choice Reviews Online.

[2]  Peter J. Stuckey,et al.  Interactive type debugging in Haskell , 2003, Haskell '03.

[3]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.

[4]  P. Hudak,et al.  A general framework for hindley/milner type systems with constraints , 2000 .

[5]  Simon L. Peyton Jones,et al.  Derivable Type Classes , 2001, Haskell.

[6]  Karl-Filip Faxén Haskell and principal types , 2003, Haskell '03.

[7]  Martin Odersky,et al.  Type Inference with Constrained Types , 1999, Theory Pract. Object Syst..

[8]  Peter Buneman,et al.  Theoretical Aspects of Object-Oriented Programming , 1994 .

[9]  Didier Rémy,et al.  Type inference for records in natural extension of ML , 1994 .

[10]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[11]  VytiniotisDimitrios,et al.  Practical type inference for arbitrary-rank types , 2007 .

[12]  Simon L. Peyton Jones,et al.  Type Classes in Haskell , 1994, ESOP.

[13]  Peter J. Stuckey,et al.  Improving type error diagnosis , 2004, Haskell '04.

[14]  Mark P. Jones,et al.  Type Classes with Functional Dependencies , 2000, ESOP.

[15]  Thom W. Frühwirth,et al.  Constraint Handling Rules , 2009, Constraint Programming.

[16]  Martin Odersky,et al.  Putting type annotations to work , 1996, POPL '96.

[17]  François Pottier,et al.  A framework for type inference with subtyping , 1998, ICFP '98.

[18]  Benjamin C. Pierce,et al.  Local type inference , 1998, POPL '98.

[19]  Dale Miller,et al.  Unification Under a Mixed Prefix , 1992, J. Symb. Comput..

[20]  Mark P. Jones,et al.  Typing Haskell in Haskell , 1999 .

[21]  Simon L. Peyton Jones,et al.  Practical type inference for arbitrary-rank types , 2007, Journal of Functional Programming.

[22]  François Pottier,et al.  Constraint-Based Type Inference for Guarded Algebraic Data Types , 2005 .

[23]  Mark P. Jones Qualified Types: Theory and Practice , 1994 .