skip to main content
10.1145/2535838.2535863acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

Counter-factual typing for debugging type errors

Published:08 January 2014Publication History

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.

Skip Supplemental Material Section

Supplemental Material

d3_right_t5.mp4

mp4

311.9 MB

References

  1. M. Beaven and R. Stansifer. Explaining type errors in polymorphic languages. ACM Letters on Programming Languages and Systems, 2:17--30, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. K. L. Bernstein and E. W. Stark. Debugging type errors. Technical report, State University of New York at Stony Brook, 1995.Google ScholarGoogle Scholar
  3. B. Braßel. Typehope: There is hope for your type errors. In Int.\ Workshop on Implementation of Functional Languages, 2004.Google ScholarGoogle Scholar
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. S. Chen, M. Erwig, and E. Walkingshaw. Extending Type Inference to Variational Programs. ACM Trans.\ on Programming Languages and Systems, 2013. To appear.Google ScholarGoogle Scholar
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. V. Choppella. Unification Source-Tracking with Application To Diagnosis of Type Inference. PhD thesis, Indiana University, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. L. Damas and R. Milner. Principal type-schemes for functional programs. In ACM Symp.\ on Principles of Programming Languages, pages 207--212, 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. D. Duggan and F. Bent. Explaining type inference. In Science of Computer Programming, pages 37--83, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle ScholarCross RefCross Ref
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. B. J. Heeren. Top Quality Type Error Messages. PhD thesis, Universiteit Utrecht, The Netherlands, Sept. 2005.Google ScholarGoogle Scholar
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle Scholar
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. B. Lerner, D. Grossman, and C. Chambers. Seminal: searching for ml type-error messages. In Workshop on ML, pages 63--73, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. B. J. McAdam. Repairing type errors in functional programs. PhD thesis, University of Edinburgh. College of Science and Engineering. School of Informatics., 2002.Google ScholarGoogle Scholar
  21. B. J. McAdam. Reporting Type Errors in Functional Programs. PhD thesis, Larboratory for Foundations of Computer Science, The University of Edinburgh, 2002.Google ScholarGoogle Scholar
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. T. Schilling. Constraint-free type error slicing. In Trends in Functional Programming, pages 1--16. Springer, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. P. J. Stuckey, M. Sulzmann, and J. Wazny. Interactive type debugging in haskell. In ACM SIGPLAN Workshop on Haskell, pages 72--83, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. M. Wand. Finding the source of type errors. In ACM Symp.\ on Principles of Programming Languages, pages 38--43, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. J. R. Wazny. Type inference and type error diagnosis for Hindley/Milner with extensions. PhD thesis, The University of Melbourne, January 2006.Google ScholarGoogle Scholar
  28. 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 ScholarGoogle Scholar
  29. J. Yang. Improving Polymorphic Type Explanations. PhD thesis, Heriot-Watt University, May 2001.Google ScholarGoogle Scholar
  30. 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 ScholarGoogle Scholar

Index Terms

  1. Counter-factual typing for debugging type errors

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in
        • Published in

          cover image ACM Conferences
          POPL '14: Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages
          January 2014
          702 pages
          ISBN:9781450325448
          DOI:10.1145/2535838

          Copyright © 2014 ACM

          Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 8 January 2014

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • research-article

          Acceptance Rates

          POPL '14 Paper Acceptance Rate51of220submissions,23%Overall Acceptance Rate824of4,130submissions,20%

          Upcoming Conference

          POPL '25

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader