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 ScholarDigital 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 ScholarDigital 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 ScholarDigital Library
- V. Choppella. Unification Source-Tracking with Application To Diagnosis of Type Inference. PhD thesis, Indiana University, 2002. Google ScholarDigital 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 ScholarDigital Library
- D. Duggan and F. Bent. Explaining type inference. In Science of Computer Programming, pages 37--83, 1995. Google ScholarDigital 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 ScholarCross 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 ScholarDigital 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 ScholarDigital 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 ScholarDigital 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 ScholarDigital 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 ScholarDigital 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 ScholarDigital Library
- B. Lerner, D. Grossman, and C. Chambers. Seminal: searching for ml type-error messages. In Workshop on ML, pages 63--73, 2006. Google ScholarDigital 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 ScholarDigital Library
- T. Schilling. Constraint-free type error slicing. In Trends in Functional Programming, pages 1--16. Springer, 2012. Google ScholarDigital 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 ScholarDigital 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 ScholarDigital Library
- M. Wand. Finding the source of type errors. In ACM Symp.\ on Principles of Programming Languages, pages 38--43, 1986. Google ScholarDigital 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
Interactive type debugging in Haskell
Haskell '03: Proceedings of the 2003 ACM SIGPLAN workshop on HaskellIn this paper we illustrate the facilities for type debugging of Haskell programs in the Chameleon programming environment. Chameleon provides an extension to Haskell supporting advanced and programmable type extensions. Chameleon maps the typing ...
Counter-factual typing for debugging type errors
POPL '14Changing 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 ...
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