Closed guibou closed 2 years ago
Since this is a hack (that might break in future GHC versions), can we somehow ask upstream to expose the necessary functions?
@Profpatsch for sure, the ticket is here: https://gitlab.haskell.org/ghc/ghc/-/issues/10330
Actually, I was trying to address this ticket when I realized that this hack could be used.
AFAIK that's a 10 minute GHC hack, we just need a new function in the Quasi
interface, and write the different implementation. This can even be done in a backward compatible way so the new function just provides an irrelevant location if not propertly written.
Hm, I’m trying out the new version, but I can’t get it to only report the subset (e.g. here I typoed “hostname”):
Maybe I need a newer version of hls? I’m pretty sure I’m using the patched version of PyF.
> haskell-language-server --version
haskell-language-server version: 1.7.0.0 (GHC: 9.0.2)
Instead of manually generating the error message with line / caret / ... and passing this string to TH
fail
, we use GHC native error reporting functionality.The benefits are:
This was achieved using an
unsafeCoerce
, to access the complete GHC api. I've found about this hack when reading GHC source code and later found that it was described inhttps://www.tweag.io/blog/2021-01-07-haskell-dark-arts-part-i/