I'm writing a TH library and I have a situation where I'm doing some module-wide stuff. In a nutshell, I'm collecting information from all quasiquotes and putQ
-ing it into Q
.
Then, once the Haskell module has been typechecked, I look up all this state and do some stuff with it. I'm managing that by recording this final action in using addModFinalizer
.
Now, the problem: sometimes, this final action can fail. If it does, I want to report a compile error. Doing this with fail
, I get error messages that look like:
Main.hs:1:1: error: My message of something going wrong with the whole module...
|
1 | {-# LANGUAGE TemplateHaskell, QuasiQuotes #-}
| ^
As you can see, GHC decides to associate my error message to the top of the file. Is there any way I can tell GHC not to associate my error with a bit of code? I'd prefer something like:
Main.hs: error: My message of something going wrong with the whole module...