Diagnosing type errors with class

Danfeng Zhang, Andrew C. Myers, Dimitrios Vytiniotis, Simon Peyton-Jones

Research output: Contribution to journalArticle

4 Citations (Scopus)

Abstract

Type inference engines often give terrible error messages, and the more sophisticated the type system the worse the problem. We show that even with the highly expressive type system implemented by the Glasgow Haskell Compiler (GHC)-including type classes, GADTs, and type families-it is possible to identify the most likely source of the type error, rather than the first source that the inference engine trips over. To determine which are the likely error sources, we apply a simple Bayesian model to a graph representation of the typing constraints; the satisfiability or unsatisfiability of paths within the graph provides evidence for or against possible explanations. While we build on prior work on error diagnosis for simpler type systems, inference in the richer type system of Haskell requires extending the graph with new nodes. The augmentation of the graph creates challenges both for Bayesian reasoning and for ensuring termination. Using a large corpus of Haskell programs, we show that this error localization technique is practical and significantly improves accuracy over the state of the art.

Original languageEnglish (US)
Pages (from-to)12-21
Number of pages10
JournalACM SIGPLAN Notices
Volume50
Issue number6
DOIs
StatePublished - Jun 1 2015

Fingerprint

Inference engines

All Science Journal Classification (ASJC) codes

  • Computer Science(all)

Cite this

Zhang, D., Myers, A. C., Vytiniotis, D., & Peyton-Jones, S. (2015). Diagnosing type errors with class. ACM SIGPLAN Notices, 50(6), 12-21. https://doi.org/10.1145/2737924.2738009
Zhang, Danfeng ; Myers, Andrew C. ; Vytiniotis, Dimitrios ; Peyton-Jones, Simon. / Diagnosing type errors with class. In: ACM SIGPLAN Notices. 2015 ; Vol. 50, No. 6. pp. 12-21.
@article{e8e5523575ef4ab88e6647520d4f9a99,
title = "Diagnosing type errors with class",
abstract = "Type inference engines often give terrible error messages, and the more sophisticated the type system the worse the problem. We show that even with the highly expressive type system implemented by the Glasgow Haskell Compiler (GHC)-including type classes, GADTs, and type families-it is possible to identify the most likely source of the type error, rather than the first source that the inference engine trips over. To determine which are the likely error sources, we apply a simple Bayesian model to a graph representation of the typing constraints; the satisfiability or unsatisfiability of paths within the graph provides evidence for or against possible explanations. While we build on prior work on error diagnosis for simpler type systems, inference in the richer type system of Haskell requires extending the graph with new nodes. The augmentation of the graph creates challenges both for Bayesian reasoning and for ensuring termination. Using a large corpus of Haskell programs, we show that this error localization technique is practical and significantly improves accuracy over the state of the art.",
author = "Danfeng Zhang and Myers, {Andrew C.} and Dimitrios Vytiniotis and Simon Peyton-Jones",
year = "2015",
month = "6",
day = "1",
doi = "10.1145/2737924.2738009",
language = "English (US)",
volume = "50",
pages = "12--21",
journal = "ACM SIGPLAN Notices",
issn = "1523-2867",
publisher = "Association for Computing Machinery (ACM)",
number = "6",

}

Zhang, D, Myers, AC, Vytiniotis, D & Peyton-Jones, S 2015, 'Diagnosing type errors with class', ACM SIGPLAN Notices, vol. 50, no. 6, pp. 12-21. https://doi.org/10.1145/2737924.2738009

Diagnosing type errors with class. / Zhang, Danfeng; Myers, Andrew C.; Vytiniotis, Dimitrios; Peyton-Jones, Simon.

In: ACM SIGPLAN Notices, Vol. 50, No. 6, 01.06.2015, p. 12-21.

Research output: Contribution to journalArticle

TY - JOUR

T1 - Diagnosing type errors with class

AU - Zhang, Danfeng

AU - Myers, Andrew C.

AU - Vytiniotis, Dimitrios

AU - Peyton-Jones, Simon

PY - 2015/6/1

Y1 - 2015/6/1

N2 - Type inference engines often give terrible error messages, and the more sophisticated the type system the worse the problem. We show that even with the highly expressive type system implemented by the Glasgow Haskell Compiler (GHC)-including type classes, GADTs, and type families-it is possible to identify the most likely source of the type error, rather than the first source that the inference engine trips over. To determine which are the likely error sources, we apply a simple Bayesian model to a graph representation of the typing constraints; the satisfiability or unsatisfiability of paths within the graph provides evidence for or against possible explanations. While we build on prior work on error diagnosis for simpler type systems, inference in the richer type system of Haskell requires extending the graph with new nodes. The augmentation of the graph creates challenges both for Bayesian reasoning and for ensuring termination. Using a large corpus of Haskell programs, we show that this error localization technique is practical and significantly improves accuracy over the state of the art.

AB - Type inference engines often give terrible error messages, and the more sophisticated the type system the worse the problem. We show that even with the highly expressive type system implemented by the Glasgow Haskell Compiler (GHC)-including type classes, GADTs, and type families-it is possible to identify the most likely source of the type error, rather than the first source that the inference engine trips over. To determine which are the likely error sources, we apply a simple Bayesian model to a graph representation of the typing constraints; the satisfiability or unsatisfiability of paths within the graph provides evidence for or against possible explanations. While we build on prior work on error diagnosis for simpler type systems, inference in the richer type system of Haskell requires extending the graph with new nodes. The augmentation of the graph creates challenges both for Bayesian reasoning and for ensuring termination. Using a large corpus of Haskell programs, we show that this error localization technique is practical and significantly improves accuracy over the state of the art.

UR - http://www.scopus.com/inward/record.url?scp=84951117067&partnerID=8YFLogxK

UR - http://www.scopus.com/inward/citedby.url?scp=84951117067&partnerID=8YFLogxK

U2 - 10.1145/2737924.2738009

DO - 10.1145/2737924.2738009

M3 - Article

AN - SCOPUS:84951117067

VL - 50

SP - 12

EP - 21

JO - ACM SIGPLAN Notices

JF - ACM SIGPLAN Notices

SN - 1523-2867

IS - 6

ER -

Zhang D, Myers AC, Vytiniotis D, Peyton-Jones S. Diagnosing type errors with class. ACM SIGPLAN Notices. 2015 Jun 1;50(6):12-21. https://doi.org/10.1145/2737924.2738009