Compositional explanation of types and algorithmic debugging of type errors

The type systems of most typed functional programming languages arebased on the Hindley-Milner type system. A practical problem withthese type systems is that it is often hard to understand why aprogram is not type correct or a function does not have theintended type. We suggest that at the core of this problem is thedifficulty of explaining why a given expression has a certain type.The type system is not defined compositionally. We propose toexplain types using a variant of the Hindley-Milner type systemthat defines a compositional type explanation graph of principaltyping. We describe how the programmer understands types byinteractive navigation through the explanation graph. Furthermore,the explanation graph can be the foundation for algorithmicdebugging of type errors, that is, semi-automatic localisation ofthe source of a type error without even having to understand thetype inference steps. We implemented a prototype of a tool toexplore the usefulness of the proposed methods.

[1]  Greg J. Michaelson,et al.  A visualisation of polymorphic type checking , 2000, J. Funct. Program..

[2]  Bruce James McAdam On the unification of substitutions in type inference , 1999 .

[3]  Bruce J. McAdam On the Unification of Substitutions in Type Interfaces , 1998, IFL.

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

[5]  Ralf Hinze,et al.  Haskell 98 — A Non−strict‚ Purely Functional Language , 1999 .

[6]  Flemming Nielson,et al.  Principles of Program Analysis , 1999, Springer Berlin Heidelberg.

[7]  John C. Mitchell,et al.  Foundations for programming languages , 1996, Foundation of computing series.

[8]  Henrik Nilsson,et al.  Declarative debugging for lazy functional languages , 1998 .

[9]  Axel Simon,et al.  Typeview: A Tool for Understanding Type Errors , 2000 .

[10]  Dominic Duggan,et al.  Explaining Type Inference , 1996, Sci. Comput. Program..

[11]  Trevor Jim What are principal typings and what are they good for? , 1996, POPL '96.

[12]  Ryan Stansifer,et al.  Explaining type errors in polymorphic languages , 1993, LOPL.

[13]  Kwangkeun Yi,et al.  Proofs about a folklore let-polymorphic type inference algorithm , 1998, TOPL.

[14]  Gregory John Michaelson,et al.  Improved Type Error Reporting , 2000 .

[15]  Peter Fritzson,et al.  Generalized algorithmic debugging and testing , 1991, LOPL.

[16]  Gregory F. Johnson,et al.  A maximum-flow approach to anomaly isolation in unification-based incremental type inference , 1986, POPL '86.

[17]  Ehud Shapiro,et al.  Algorithmic Program Debugging , 1983 .

[18]  Mitchell Wand Finding the source of type errors , 1986, POPL '86.

[19]  Mikael Rittri Finding the Source of Type Errors Interactively (draft) , 1993 .

[20]  Yang Jun,et al.  How do people check polymorphic types? , 2000, PPIG.

[21]  Lee Naish A Declarative Debugging Scheme , 1997, J. Funct. Log. Program..

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

[23]  Bruce J. McAdam Generalising Techniques for Type Debugging , 1999, Scottish Functional Programming Workshop.

[24]  Jun Yang Explaining Type Errors by Finding the Source of a Type Conflict , 1999, Scottish Functional Programming Workshop.

[25]  Venkatesh Choppella,et al.  Diagnosis of Ill-typed Programs , 1995 .