Improving Type Error Reporting for Type Classes
Debugging type errors when type inference fails is a challenging problem since there are many different ways to remove the type error, and it’s unclear which way is intended. While numerous approaches have been proposed to more precisely locate the real error causes, most of them do not deal with po...
Saved in:
Published in | Functional and Logic Programming Vol. 13215; pp. 19 - 38 |
---|---|
Main Authors | , |
Format | Book Chapter |
Language | English |
Published |
Switzerland
Springer International Publishing AG
2022
Springer International Publishing |
Series | Lecture Notes in Computer Science |
Online Access | Get full text |
ISBN | 3030994600 9783030994600 |
ISSN | 0302-9743 1611-3349 |
DOI | 10.1007/978-3-030-99461-7_2 |
Cover
Summary: | Debugging type errors when type inference fails is a challenging problem since there are many different ways to remove the type error, and it’s unclear which way is intended. While numerous approaches have been proposed to more precisely locate the real error causes, most of them do not deal with popular type system extensions, such as type classes. A second problem is that most approaches do not provide enough information for removing the type error or do so for a few error causes only.
In this work, we develop an approach called TEC to address both problems. Given an ill-typed expression that may involve type classes, TEC finds comprehensive error causes and generates for each cause an error fix with detailed information for removing the type error. TEC computes all error fixes, ranks them, and iteratively presents the most likely error fix to the user until a fix is accepted. TEC reduces the problem of finding all error fixes to variational typing, which systematically reuses typing results. Our main technical innovation is a variational context reduction algorithm that simplifies type class constraints containing variations. We have evaluated the precision of TEC and found that it outperforms existing approaches in locating type errors arising from type class uses. |
---|---|
Bibliography: | This work is supported by the National Science Foundation under the grant CCF-1750886. |
ISBN: | 3030994600 9783030994600 |
ISSN: | 0302-9743 1611-3349 |
DOI: | 10.1007/978-3-030-99461-7_2 |