I don't think we want Exceptions here.
Agreed
And I'm sceptical about whether the recovery code wants to inspect the errors and warnings.
Probably not.
Just possibly, the recovery code could get the String passed to 'fail'.
I think it needs to get something (String, Doc, etc.) so that it can control whether it is displayed and where it is displayed. I don't care what that something is.
Personally I like the recovery code (= handler) to be the first argument, because it's usually small.
I'm completely open to any argument ordering.
report :: Bool -> String -> Q () -- Report an error (True) or warning (False)
I'm a bit uncertain about your failWithEx. Maybe a more elaborated version of report? I wonder if it's worth it.
I think it's cheap to implement (isn't it?) and supports those who want to use TH to implement language extensions as opposed to those using TH to make things go faster. -- Alastair Reid