Align parser types to the new diagnostic design
See #18516 , !5509 (comment 346928) and https://gitlab.haskell.org/ghc/ghc/-/wikis/Errors-as-(structured)-values#integrating-parser-diagnostics-into-the-new-infrastructure
This already-big MR will eventually convert the parser types to use the new diagnostic infrastructure. There is a bit of historical context here: @hsyl20 was the original author of the types present in the GHC.Parser.Errors
module, which converted parser diagnostics from unstructured SDoc
in nice Haskell types.
In the context of #18516, we are now trying to bring everything under a common umbrella.
This MR is temporarily opened against my other wip/adinapoli-hints-design
branch, waiting for the former to be merged.
This MR does a lot; not only does it convert the messages, but it also brings order to the GhcHint
type by removing two hints which were out of place (see here). That required a bit of surgery, but the end result is, I think, decent.
I have tested this MR against my classic selection of roughly 200 tests, CI will cover the rest and tell us if this is sound or not
A fair warning: this MR also starts the conversion process in the rendered diagnostics: due to the fact we now have hints added as part of the typeclass, we can render them properly, separate from the diagnostic message body. Example:
T8501a.hs:5:3: error:
Parse error in pattern: rec
Suggested fixes:
Perhaps you intended to use RecursiveDo
Possibly caused by a missing 'do'?
We will have to probably reword some of these hints, but you get the idea. This MR deliberately doesn't improve the hints for the PsMessage
or change the wording for some of these hints, to avoid inflating the size of this MR too much. Further MRs will follow.