Skip to content

WIP: compiler: introduce ADTs to represent errors

Alp Mestanogullari requested to merge alp/ghc:alp/error-adts into master

The design and plan of this branch are discussed in:

tl;dr: this generalizes the existing error infrastructure a little bit, introduces error data types for the parser and TcRn, as well as a toplevel error sum type. This also moves a few existing errors (from the parser and renamer/typechecker) over to dedicated constructors of the subsystem error types, to give us an idea of how this design pans out in GHC's codebase and provide us with something to discuss and refine. I've made a few choices here and there that we might or might not run with, and we might want to introduce some less document-centric error utilities in a few places, like the typechecker.

In order to digest this patch in small chunks, I tried to implement individual logical steps as one commit, and GHC builds/passes the testsuite on most of those commits. It might therefore make sense to look at one commit at a time instead of the entire diff. I will be polishing a lot of things once the dust settles, including:

  • making sure that we end up with some generic infrastructure to throw error values, not just the one-off documents or error reports
  • progressively removing or transforming the existing error infrastructure, to avoid keeping around lots of dead code
  • writing a note

But since we're still in an early stage and things might change, I'm leaving this for later. And for the note, we already have the proposal and the wiki page, to give a 10,000 ft view.

Note: this bumps haddock to a commit of mine which I will be submitting as a haddock patch soon.

(This is another take on !3300 (closed).)

cc @simonpj @rae

Edited by Ben Gamari

Merge request reports