Abstract
Changing a program in response to a type error plays an important part in modern software development. However, the generation of good type error messages remains a problem for highly expressive type systems. Existing approaches often suffer from a lack of precision in locating errors and proposing remedies. Specifically, they either fail to locate the source of the type error consistently, or they report too many potential error locations. Moreover, the change suggestions offered are often incorrect. This makes the debugging process tedious and ineffective.
We present an approach to the problem of type debugging that is based on generating and filtering a comprehensive set of type-change suggestions. Specifically, we generate all (program-structure-preserving) type changes that can possibly fix the type error. These suggestions will be ranked and presented to the programmer in an iterative fashion. In some cases we also produce suggestions to change the program. In most situations, this strategy delivers the correct change suggestions quickly, and at the same time never misses any rare suggestions. The computation of the potentially huge set of type-change suggestions is efficient since it is based on a variational type inference algorithm that type checks a program with variations only once, efficiently reusing type information for shared parts.
We have evaluated our method and compared it with previous approaches. Based on a large set of examples drawn from the literature, we have found that our method outperforms other approaches and provides a viable alternative.
Supplemental Material
- M. Beaven and R. Stansifer. Explaining type errors in polymorphic languages. ACM Letters on Programming Languages and Systems, 2:17--30, 1994. Google Scholar
Digital Library
- K. L. Bernstein and E. W. Stark. Debugging type errors. Technical report, State University of New York at Stony Brook, 1995.Google Scholar
- B. Braßel. Typehope: There is hope for your type errors. In Int.\ Workshop on Implementation of Functional Languages, 2004.Google Scholar
- S. Chen, M. Erwig, and E. Walkingshaw. An Error-Tolerant Type System for Variational Lambda Calculus. In ACM Int.\ Conf.\ on Functional Programming, pages 29--40, 2012. Google Scholar
Digital Library
- S. Chen, M. Erwig, and E. Walkingshaw. Extending Type Inference to Variational Programs. ACM Trans.\ on Programming Languages and Systems, 2013. To appear.Google Scholar
- O. Chitil. Compositional explanation of types and algorithmic debugging of type errors. In ACM Int.\ Conf.\ on Functional Programming, pages 193--204, September 2001. Google Scholar
Digital Library
- V. Choppella. Unification Source-Tracking with Application To Diagnosis of Type Inference. PhD thesis, Indiana University, 2002. Google Scholar
Digital Library
- L. Damas and R. Milner. Principal type-schemes for functional programs. In ACM Symp.\ on Principles of Programming Languages, pages 207--212, 1982. Google Scholar
Digital Library
- D. Duggan and F. Bent. Explaining type inference. In Science of Computer Programming, pages 37--83, 1995. Google Scholar
Digital Library
- H. Eo, O. Lee, and K. Yi. Proofs of a set of hybrid let-polymorphic type inference algorithms. New Generation Computing, 22(1):1--36, 2004.Google Scholar
Cross Ref
- M. Erwig and E. Walkingshaw. The Choice Calculus: A Representation for Software Variation. ACM Trans.\ on Software Engineering and Methodology, 21(1):6:1--6:27, 2011. Google Scholar
Digital Library
- C. Haack and J. B. Wells. Type error slicing in implicitly typed higher-order languages. In European Symposium on Programming, pages 284--301, 2003. Google Scholar
Digital Library
- B. Heeren, D. Leijen, and A. van IJzendoorn. Helium, for learning haskell. In Proceedings of the 2003 ACM SIGPLAN workshop on Haskell, Haskell '03, pages 62--71, New York, NY, USA, 2003. ACM. Google Scholar
Digital Library
- B. J. Heeren. Top Quality Type Error Messages. PhD thesis, Universiteit Utrecht, The Netherlands, Sept. 2005.Google Scholar
- G. F. Johnson and J. A. Walz. A maximum-flow approach to anomaly isolation in unification-based incremental type inference. In ACM Symp.\ on Principles of Programming Languages, pages 44--57, 1986. Google Scholar
Digital Library
- O. Lee and K. Yi. Proofs about a folklore let-polymorphic type inference algorithm. ACM Trans.\ on Programming Languages and Systems, 20(4):707--723, July 1998. Google Scholar
Digital Library
- O. Lee and K. Yi. A generalized let-polymorphic type inference algorithm. Technical report, Technical Memorandum ROPAS-2000--5, Research on Program Analysis System, Korea Advanced Institute of Science and Technology, 2000.Google Scholar
- B. Lerner, M. Flower, D. Grossman, and C. Chambers. Searching for type-error messages. In ACM Int.\ Conf.\ on Programming Language Design and Implementation, pages 425--434, 2007. Google Scholar
Digital Library
- B. Lerner, D. Grossman, and C. Chambers. Seminal: searching for ml type-error messages. In Workshop on ML, pages 63--73, 2006. Google Scholar
Digital Library
- B. J. McAdam. Repairing type errors in functional programs. PhD thesis, University of Edinburgh. College of Science and Engineering. School of Informatics., 2002.Google Scholar
- B. J. McAdam. Reporting Type Errors in Functional Programs. PhD thesis, Larboratory for Foundations of Computer Science, The University of Edinburgh, 2002.Google Scholar
- M. Neubauer and P. Thiemann. Discriminative sum types locate the source of type errors. In ACM Int.\ Conf.\ on Functional Programming, pages 15--26, 2003. Google Scholar
Digital Library
- T. Schilling. Constraint-free type error slicing. In Trends in Functional Programming, pages 1--16. Springer, 2012. Google Scholar
Digital Library
- P. J. Stuckey, M. Sulzmann, and J. Wazny. Interactive type debugging in haskell. In ACM SIGPLAN Workshop on Haskell, pages 72--83, 2003. Google Scholar
Digital Library
- F. Tip and T. B. Dinesh. A slicing-based approach for locating type errors. ACM Trans.\ on Software Engineering and Methodology, 10(1):5--55, Jan. 2001. Google Scholar
Digital Library
- M. Wand. Finding the source of type errors. In ACM Symp.\ on Principles of Programming Languages, pages 38--43, 1986. Google Scholar
Digital Library
- J. R. Wazny. Type inference and type error diagnosis for Hindley/Milner with extensions. PhD thesis, The University of Melbourne, January 2006.Google Scholar
- J. Yang. Explaining type errors by finding the source of a type conflict. In Trends in Functional Programming, pages 58--66. Intellect Books, 2000.Google Scholar
- J. Yang. Improving Polymorphic Type Explanations. PhD thesis, Heriot-Watt University, May 2001.Google Scholar
- J. Yang, G. Michaelson, P. Trinder, and J. B. Wells. Improved type error reporting. In Int.\ Workshop on Implementation of Functional Languages, pages 71--86, 2000.Google Scholar
Index Terms
Counter-factual typing for debugging type errors
Recommendations
Counter-factual typing for debugging type errors
POPL '14: Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesChanging a program in response to a type error plays an important part in modern software development. However, the generation of good type error messages remains a problem for highly expressive type systems. Existing approaches often suffer from a lack ...
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. ...
How type errors were fixed and what students did?
Providing better supports for debugging type errors has been an active research area in the last three decades. Numerous approaches from different perspectives have been developed. Most approaches work well under certain conditions only, for example, ...







Comments