Abstract
Strongly-typed languages present programmers with compile-time feedback about the type correctness of programs. Errors during polymorphic type checking take the form of a unification failure for two types. Finding the source of the type error in the code is often difficult because the error may occur far from the spot where the inconsistency is detected. As functional languages use more and more complex type systems, the difficulty of interpreting and locating these errors will increase. To locate the source of type errors the programmer must unravel the long chain of deductions and type instantiations made during type reconstruction. This paper describes an approach that maintains the deductive steps of type inference and the reasons for type instantiations. The approach could be used in an interactive system to guide the programmer to the source of a type error or to explain why the compiler assigned a particular type to an expression.
- APPEL, A. W., AND MACQUEEN, D.B. 1991. Standard ML of New Jersey. In Programming Language Implementation and Logic Programming (Berlin). M. Wirsing, Ed., Springer-Verlag, New York, 1-13.Google Scholar
- CARDELLI, L. 1987. Basic polymorphic type checking. Sci. Comput. Program. 8, 2 (April), 147-172. Google Scholar
- JOHNSON, G. F., AND WALZ, J.A. 1986. 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 (Jan.), 44-57. Google Scholar
- MILNER, Ro 1987. A theory of type polymorphism. J. Comput. Syst. Sci. 17, 348-375.Google Scholar
- MILNER, R., TOFTE, M., AND HARPER, R. 1990. The Definition of Standard ML. MIT Press, Cambridge, Mass. Google Scholar
- READE, C. 1989. Elements of Functional Programming Addison Wesley, Reading, Mass. Google Scholar
- SERGOT, M. J., SADRI, F., KOWALSKI, R. A., KRIWAACZEK, F., HAMMOND, P., AND CORY, H.T. 1986. The British Nationality Act. Commun. ACM 29, 5 (May), 370-386. Google Scholar
- SOOSAIPILLAI, H. 1990. An explanation based polymorphic type check for Standard ML. Master's thesis. Heriot-Watt Univ., Edinburgh, U.K.Google Scholar
- WAND, M. 1986. Finding the source of type errors. In Conference Record of the 13th Annual ACM Symposium on Principles of Programming Languages (Jan.) 38-43. Google Scholar
Index Terms
Explaining type errors in polymorphic languages
Recommendations
Discriminative sum types locate the source of type errors
We propose a type system for locating the source of type errors in an applied lambda calculus with ML-style polymorphism. The system is based on discriminative sum types---known from work on soft typing---with annotation subtyping and recursive types. ...
Discriminative sum types locate the source of type errors
ICFP '03: Proceedings of the eighth ACM SIGPLAN international conference on Functional programmingWe propose a type system for locating the source of type errors in an applied lambda calculus with ML-style polymorphism. The system is based on discriminative sum types---known from work on soft typing---with annotation subtyping and recursive types. ...






Comments