Heuristics for Type Error Discovery and Recovery
Type error messages that are reported for incorrect functional programs can be difficult to understand. The reason for this is that most type inference algorithms proceed in a mechanical, syntax-directed way, and are unaware of inference techniques used by experts to explain type inconsistencies. We formulate type inference as a constraint problem, and analyze the collected constraints to improve the error messages (and, as a result, programming efficiency). A special data structure, the type graph, is used to detect global properties of a program, and furthermore enables us to uniformly describe a large collection of heuristics which embed expert knowledge in explaining type errors. Some of these also suggest corrections to the programmer. Our work has been fully implemented and is used in practical situations, showing that it scales up well. We include a number of statistics from actual use of the compiler showing us the frequency with which heuristics are used, and the kind and number of suggested corrections.
Keywordstype inferencing type graph constraints heuristics error messages error recovery
Unable to display preview. Download preview PDF.
- 1.Hage, J., Heeren, B.: Ordering type constraints: A structured approach. Technical Report UU-CS-2005-016, Department of Information and Computing Science, Utrecht University, Netherlands, Technical Report (April 2005)Google Scholar
- 2.Heeren, B.: Top Quality Type Error Messages. PhD thesis, Universiteit Utrecht, The Netherlands (2005), http://www.cs.uu.nl/people/bastiaan/phdthesis
- 3.Heeren, B., Hage, J.: A first attempt at type class directives. Technical Report UU-CS-2002-031, Department of Information and Computing Science, University Utrecht, Netherlands, Technical Report (September 2004)Google Scholar
- 4.Heeren, B., Hage, J.: Type class directives. In: Seventh International Symposium on Practical Aspects of Declarative Languages, pp. 253–267. Springer, Heidelberg (2005)Google Scholar
- 7.Langebaerd, A.: Repair systems, automatic correction of type errors in functional programs. http://www.cs.uu.nl/wiki/Top/Publications
- 9.McAdam, B.J.: Generalising techniques for type debugging. In: Trinder, P.,Michaelson, G., Loidl, H-W. (eds.) Trends in Functional Programming, Bristol, UK, Intellect, vol. 1, pp. 50–59 (2000)Google Scholar
- 10.McAdam, B.J.: How to repair type errors automatically. Trends in Functional Programming 3, 87–98 (2002)Google Scholar
- 11.Port, G.S.: A simple approach to finding the cause of non-unifiability. In: Kowalski, R.A., Bowen, K.A. (eds.) Proceedings of the Fifth International Conference and Symposium on Logic Programming, pp. 651–665. The MIT Press, Cambridge (1988)Google Scholar
- 14.Walz, J.A., Johnson, G.F.: A maximum flow approach to anomaly isolation in unification-based incremental type inference. In: Conference Record of the 13th Annual ACM Symposium on Principles of Programming Languages, pp. 44–57, St. Petersburg, FL (January 1986)Google Scholar
- 15.Yang, J.: Explaining type errors by finding the sources of type conflicts. In: Michaelson, G., Trindler, P., Loidl, H.-W. (eds.) Trends in Functional Programming. Intellect Books, pp. 58–66 (2000)Google Scholar