Skip to main content
×
×
Home

Systematic identification and communication of type errors*

  • SHENG CHEN (a1) and MARTIN ERWIG (a2)
Abstract

When type inference fails, it is often difficult to pinpoint the cause of the type error among many potential candidates. Generating informative messages to remove the type error is another difficult task due to the limited availability of type information. Over the last three decades many approaches have been developed to help debug type errors. However, most of these methods suffer from one or more of the following problems: (1) Being incomplete, they miss the real cause. (2) They cover many potential causes without distinguishing them. (3) They provide little or no information for how to remove the type error. Any one of this problems can turn the type-error debugging process into a tedious and ineffective endeavor. To address this issue, we have developed a method named counter-factual typing, which (1) finds a comprehensive set of error causes in AST leaves, (2) computes an informative message on how to get rid of the type error for each error cause, and (3) ranks all messages and iteratively presents the message for the most likely error cause. The biggest technical challenge is the efficient generation of all error messages, which seems to be exponential in the size of the expression. We address this challenge by employing the idea of variational typing that systematically reuses computations for shared parts and generates all messages by typing the whole ill-typed expression only once. We have evaluated our approach over a large set of examples collected from previous publications in the literature. The evaluation result shows that our approach outperforms previous approaches and is computationally feasible.

Copyright
Footnotes
Hide All
*

This work is supported by the National Science Foundation under the grants IIS-1314384, CCF-1717300, and CCF-1750886. We thank the anonymous POPL and JFP reviewers, whose feedback has improved both the content and the presentation of the paper.

Footnotes
References
Hide All
Beaven, M. & Stansifer, R. (1994) Explaining type errors in polymorphic languages. ACM Lett. Program. Lang. Syst. 2, 1730.
Bernstein, K. L. & Stark, E. W. (1995) Debugging Type Errors. Tech. rept. State University of New York at Stony Brook.
Braßel, B. (2004) Typehope: There is hope for your type errors. In Proceedings of International Workshop on Implementation of Functional Languages.
Chambers, C., Chen, S., Le, D. & Scaffidi, C. (2012) The function, and dysfunction, of information sources in learning functional programming. J. Comput. Sci. Colleges. 28 (1), 220226.
Chen, S. & Erwig, M. (2014a) Counter-factual typing for debugging type errors. In Proceedings of ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 583–594.
Chen, S. & Erwig, M. (2014b) Guided type debugging. In Proceedings of International Symposium on Functional and Logic Programming, LNCS, vol. 8475, pp. 35–51.
Chen, S., Erwig, M. & Walkingshaw, E. (2012) An error-tolerant type system for variational lambda calculus. In Proceedings of ACM International Conference on Functional Programming, pp. 29–40.
Chen, S., Erwig, M. & Walkingshaw, E. (2014) Extending type inference to variational programs. ACM Trans. Program. Lang. Syst. 36 (1), 1:11:54.
Chen, S., Erwig, M. & Smeltzer, K. (2017) Exploiting diversity in type checkers for better error messages. J. Vis. Lang. Comput. 39 (C), 1021.
Chitil, O. (2001 September) Compositional explanation of types and algorithmic debugging of type errors. In Proceedings of ACM International Conference on Functional Programming, pp. 193–204.
Choppella, V. (2002) Unification Source-Tracking with Application to Diagnosis of Type Inference. Ph.D. thesis, Indiana University.
Damas, L. & Milner, R. (1982) Principal type-schemes for functional programs. In Proceedings of ACM Symposium on Principles of Programming Languages, pp. 207–212.
Duggan, D. & Bent, F. (1995) Explaining type inference. Sci. Comput. Program. 27 (1), 3783.
Eo, H., Lee, O. & Yi, K. (2004) Proofs of a set of hybrid let-polymorphic type inference algorithms. New Gener. Comput. 22 (1), 136.
Erwig, M. (2006) Visual Type Inference. J. Vis. Lang. Comput. 17 (2), 161186.
Erwig, M. & Walkingshaw, E. (2011) The choice calculus: A representation for software variation. ACM Trans. Softw. Eng. Methodol. 21 (1), 6:16:27.
Haack, C. & Wells, J. B. (2003) Type error slicing in implicitly typed higher-order languages. In Proceedings of European Symposium on Programming, pp. 284–301.
Hage, J. (2013) Helium Benchmark Programs (2002–2005). Private communication.
Hage, J. & Heeren, B. (2007) Heuristics for type error discovery and recovery. In Proceedings of Implementation and Application of Functional Languages, pp. 199–216.
Heeren, B., Leijen, D. & van, I. A. (2003) Helium, for learning haskell. In Proceedings of ACM SIGPLAN Workshop on Haskell, pp. 62–71.
Heeren, B. J. (2005) Top Quality Type Error Messages. Ph.D. thesis, Universiteit Utrecht, The Netherlands.
Johnson, G. F. & Walz, J. A. (1986) A maximum-flow approach to anomaly isolation in unification-based incremental type inference. In Proceedings of ACM Symposium on Principles of Programming Languages, pp. 44–57.
Lee, O. & Yi, K. (1998) Proofs about a folklore let-polymorphic type inference algorithm. ACM Trans. Program. Lang. Syst. 20 (4), 707723.
Lee, O. & Yi, K. (2000) A Generalized Let-Polymorphic Type Inference Algorithm. Tech. rept. Technical Memorandum ROPAS-2000-5, Research on Program Analysis System, Korea Advanced Institute of Science and Technology.
Lerner, B., Flower, M., Grossman, D. & Chambers, C. (2007) Searching for type-error messages. In Proceedings of ACM International Conference on Programming Language Design and Implementation, pp. 425–434.
Lerner, B., Grossman, D. & Chambers, C. (2006) Seminal: Searching for ml type-error messages. In Proceedings of Workshop on ml, pp. 63–73.
Loncaric, C., Chandra, S., Schlesinger, C. & Sridharan, M. (2016). A practical framework for type inference error explanation. In Proceedings of the 2016 Acm Sigplan International Conference on Object-Oriented Programming, Systems, Languages, and Applications. OOPSLA 2016. New York, NY, USA: ACM, pp. 781–799.
McAdam, B. J. (1999). Graphs for Recording Type Information. Technical Report ECS-LFCS-99-415. University of Edinburgh.
McAdam, B. J. (2002a). Reporting Type Errors in Functional Programs. Ph.D. thesis, Larboratory for Foundations of Computer Science, The University of Edinburgh.
McAdam, B. J. (2002b). Repairing Type Errors in Functional Programs. Ph.D. thesis, University of Edinburgh. College of Science and Engineering. School of Informatics.
Neubauer, M. & Thiemann, P. (2003) Discriminative sum types locate the source of type errors. In Proceedings of ACM International Conference on Functional Programming, pp. 15–26
Pavlinovic, Z., King, T. & Wies, T. (2014) Finding minimum type error sources. In Proceedings of ACM International Conference on Object Oriented Programming Systems Languages & Applications, pp. 525–542
Pavlinovic, Z., King, T. & Wies, T. (2015) Practical SMT-based type error localization. In Proceedings of ACM International Conference on Functional Programming, pp. 412–423.
Pfenning, F. (1991) Unification and anti-unification in the calculus of constructions. In Proceedings of IEEE Symposium on Logic in Computer Science, pp. 74–85.
Schilling, T. (2012) Constraint-free type error slicing. In Proceedings of Trends in Functional Programming. Springer, pp. 1–16.
Seidel, E. L., Jhala, R. & Weimer, W. (2016) Dynamic witnesses for static type errors (or, ill-typed programs usually go wrong). In Proceedings of ACM International Conference on Functional Programming, pp. 228–242.
Seidel, E. L., Sibghat, H., Chaudhuri, K., Weimer, W. & Jhala, R. (2017) Learning to blame: Localizing novice type errors with data-driven diagnosis. Proc. ACM Program. Lang. 1 (OOPSLA), 60:160:27.
Stuckey, P. J., Sulzmann, M. & Wazny, J. (2003) Interactive type debugging in haskell. InProceedings of ACM Sigplan Workshop on Haskell, pp. 72–83.
Tip, F. & Dinesh, T. B. (2001) A slicing-based approach for locating type errors. ACM Trans. Softw. Eng. Methodol., 10 (1), 555.
Tirronen, V., Uusi-mäkelä, S. & Isomöttönen, V. (2015) Understanding beginners' mistakes with Haskell. J. Funct. Program., 25, 131.
Tsushima, K. & Chitil, O. (2014) Enumerating counter-factual type error messages with an existing type checker. In Proceedings of 16th Workshop on Programming and Programming Languages.
Wand, M. (1986) Finding the source of type errors. In Proceedings of ACM Symposium on Principles of Programming Languages, pp. 38–43.
Wazny, J. R. (2006 January) Type Inference and Type Error Diagnosis for Hindley/Milner with Extensions. Ph.D. thesis, The University of Melbourne.
Wu, B. & Chen, S. (2017) How type errors were fixed and what students did? Proc. ACM Program. Lang. 1 (OOPSLA), 105:1105:27.
Wu, B., Campora, John P. III & Chen, S. (2017) Learning user friendly type-error messages. Proc. ACM Program. Lang. 1 (OOPSLA), 106:1106:29.
Yang, J. (2000) Explaining type errors by finding the source of a type conflict. In Proceedings of Trends in Functional Programming. Intellect Books, pp. 58–66.
Yang, J. (2001 May). Improving Polymorphic Type Explanations. Ph.D. thesis, Heriot-Watt University.
Yang, J., Michaelson, G., Trinder, P. & Wells, J. B. (2000) Improved type error reporting. In Proceedings of International Workshop on Implementation of Functional Languages, pp. 71–86.
Zhang, D. & Myers, A. C. (2014) Toward general diagnosis of static errors. In Proceedings of ACM Symposium on Principles of Programming Languages, pp. 569–581.
Zhang, D., Myers, A. C., Vytiniotis, D. & Peyton-Jones, S. (2015) Diagnosing type errors with class. In Proceedings of ACM Conference on Programming Language Design and Implementation, pp. 12–21.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×

Metrics

Altmetric attention score

Full text views

Total number of HTML views: 0
Total number of PDF views: 52 *
Loading metrics...

Abstract views

Total abstract views: 462 *
Loading metrics...

* Views captured on Cambridge Core between 25th January 2018 - 26th May 2018. This data will be updated every 24 hours.

Systematic identification and communication of type errors*

  • SHENG CHEN (a1) and MARTIN ERWIG (a2)
Submit a response

Discussion

No Discussion have been published for this article.

×

Reply to: Submit a response


Your details


Conflicting interests

Do you have any conflicting interests? *