Scared of the Peacock Revolution since 2006
Blog » Research proposal
I propose conducting research into improving the error messages provided by the Haskell type system. This would be done by implementing a different algorithm for the type checking system that provides more information about type errors.
This project intends to provide better type failure errors in Haskell, specifically when using the Glasgow Haskell Compiler (GHC), by changing the algorithm used in the type checking system to one capable of conveying more information.
The current algorithm used for type checking in GHC, while correct, has a tendency to provide slightly cryptic error messages. These can confuse people learning the Haskell language and make it harder to find the exact source(s) of an error, as the source is likely to only have a minor effect on the line that explicitly causes the error.
The aim of this project is to investigate a possible alternative algorithm for use in GHC and, if it is feasible, implement a version of GHC that uses this algorithm for its type checking.
In Explaining Type Inference, an algorithm is set forth that collects more accurate type information during the type inference process, allowing for more informative error messages when a type check fails. This project will endeavour to use this algorithm.
To achieve this, I will need to research how the current type checking system in GHC works and if this algorithm has previously been considered instead of the current one. I estimate this will take about two weeks.
Secondly, I will need to research how the Duggan-Bent algorithm may need to be altered to fit in with Haskell’s type system. I estimate this will take between two and four weeks.
Finally, I will need to adapt GHC’s type checking system to use the Duggan-Bent algorithm for its inference, checking and error messages. I envision this will take the remainder of project to complete. Part of this process will involve research into alternative ways of displaying the additional information.
The solution will be evaluated on its ability to correctly infer and check the types of Haskell programmes, the error messages it produces and its efficiency in relation to the current type check system.
At the present time, no extra resources are expected to be required.
 D. Duggan and F. Bent, “Explaining type inference,” Science of Computer Programming, vol. 27, no. 1, pp. 37–83, 1996.