Table of Contents
Fetching ...

Goanna: Resolving Haskell Type Errors With Minimal Correction Subsets

Shuai Fu, Tim Dwyer, Peter J. Stuckey, John Grundy

TL;DR

Goanna tackles the challenge of debugging type errors in Haskell by introducing an MCS-based type checker and an interactive IDE (Goanna-IDE). Its core approach enumerates minimal correction subsets to produce a comprehensive set of potential error causes, which are then grouped, ranked, and reduced to concise, actionable suggestions. The system supports cross-module debugging, offers dynamic in-editor type hints, and provides mechanisms to improve efficiency and relevance through constraint aggregation, overfitting avoidance, and set-cover-based reductions. Empirical evaluation on 86 ill-typed Haskell programs demonstrates Goanna's strong top-3 accuracy and concise diagnostics, albeit with higher runtime than some baselines. The work contributes an open-source tool and methodology that can extend to other strongly typed languages, with future work focusing on human studies, editor integrations, and broader language support.

Abstract

Statically typed languages offer significant advantages, such as bug prevention, enhanced code quality, and reduced maintenance costs. However, these benefits often come at the expense of a steep learning curve and a slower development pace. Haskell, known for its expressive and strict type system, poses challenges for inexperienced programmers in learning and using its type system, especially in debugging type errors. We introduce Goanna, a novel tool that serves as a type checker and an interactive type error debugging tool for Haskell. When encountering type errors, Goanna identifies a comprehensive list of potential causes and resolutions based on the minimum correction subsets (MCS) enumeration. We evaluated Goanna's effectiveness using 86 diverse Haskell programs from online discourse, demonstrating its ability to accurately identify and resolve type errors. Additionally, we present a collection of techniques and heuristics to enhance Goanna's suggestion-based error diagnosis and show their effectiveness from our evaluation.

Goanna: Resolving Haskell Type Errors With Minimal Correction Subsets

TL;DR

Goanna tackles the challenge of debugging type errors in Haskell by introducing an MCS-based type checker and an interactive IDE (Goanna-IDE). Its core approach enumerates minimal correction subsets to produce a comprehensive set of potential error causes, which are then grouped, ranked, and reduced to concise, actionable suggestions. The system supports cross-module debugging, offers dynamic in-editor type hints, and provides mechanisms to improve efficiency and relevance through constraint aggregation, overfitting avoidance, and set-cover-based reductions. Empirical evaluation on 86 ill-typed Haskell programs demonstrates Goanna's strong top-3 accuracy and concise diagnostics, albeit with higher runtime than some baselines. The work contributes an open-source tool and methodology that can extend to other strongly typed languages, with future work focusing on human studies, editor integrations, and broader language support.

Abstract

Statically typed languages offer significant advantages, such as bug prevention, enhanced code quality, and reduced maintenance costs. However, these benefits often come at the expense of a steep learning curve and a slower development pace. Haskell, known for its expressive and strict type system, poses challenges for inexperienced programmers in learning and using its type system, especially in debugging type errors. We introduce Goanna, a novel tool that serves as a type checker and an interactive type error debugging tool for Haskell. When encountering type errors, Goanna identifies a comprehensive list of potential causes and resolutions based on the minimum correction subsets (MCS) enumeration. We evaluated Goanna's effectiveness using 86 diverse Haskell programs from online discourse, demonstrating its ability to accurately identify and resolve type errors. Additionally, we present a collection of techniques and heuristics to enhance Goanna's suggestion-based error diagnosis and show their effectiveness from our evaluation.
Paper Structure (44 sections, 19 figures)

This paper contains 44 sections, 19 figures.

Figures (19)

  • Figure 1: Inspecting a type error using the Haskell compiler GHC (Glasgow Haskell Compiler)
  • Figure 2: Goanna's error diagnosis Goanna shows that to fix the type error, the literals 1, 2, and 3 on line 1 need to be changed to Char type.
  • Figure 3: Goanna's error diagnosis. Goanna shows that the type error can be fixed by changing the literal $'1'$ on line 3, which needs an Int type. This, according to Goanna, is the most likely cause of the type error.
  • Figure 4: Selecting a different error in Goanna. Selecting a different error using Goanna's error selector. The debugging panel will show potential cause locations for the selected error. The highlights and type hints in the editor panel will focus on the selected error.
  • Figure 5: Inspecting a defective Haskell Program (left) in relation to the error messages output by the standard GHC compiler (right) -- 3 separate type errors are reported. The editor (VS Code is used here) underlines the error locations reported in the messages, but all other contextual information must be understood from the error text.
  • ...and 14 more figures