Draft: Towards Fault-tolerant GHC compilation pipeline
This is a draft work in order to have a fault-tolerant ghc, where fault-tolerant means that it reports as much errors as possible for the compilation unit (a .hs file for example), so a parser error wouldn't halt the pipeline, instead the pipeline reaches the desugarer, where other errors from other passes (Renamer, Typechecker) would be accumulated and they can all be reported together.
This is done by modifying happy, the parser generator, in order to have an adhoc error reporting mechanism similar to yacc, using a token called catch (in yacc it's called error, but that's reserved in happy), and then insert catch rules in the grammar. The modified parser generates a partial ast which is consumed by the following stages.
The current design is to add a Partial constructor to every HsSyn related type in the tool-agnostic representation, Currently, only HsPartial constructor for HsExpr type is implemented in this draft. It is implemented similar to HsUnboundVar, with no annotations/srclocs. The Renamer stage deals with the partial output by pattern matching on HsPartial in several functions, the type-checking of the partial ast is done similarly.
It would be helpful if the maintainers tell what they think about this, should Partial constructors for HsSyn types
be independent from TTG extension points, or should they be part of the GHC-specific extension points.
This work is part of Summer of Haskell, mentored by @sgraf812 .