Fall over more gracefully when there's a Template Haskell error
For a long time, Template Haskell has fallen over in a very un-graceful
way (i.e. panic) even when it encounters a programmer error. In particular,
when DsMeta converts HsSyn to TH syntax, it may find Haskell code that
TH does not understand. This should be reported as a normal programmer
error, not with a compiler panic!
Originally the desugarer was supposed to never generate error
messages, but this TH desugaring thing does make it do so. And in
fact, for other reasons, the desugarer now uses the TcRnIf monad, the
common monad used by the renamer, typechecker, interface checker, and
desugarer.
This patch completes the job, by
- allowing the desugarer to generate errors
- re-plumbing the error handling to take account of this
- making DsMeta use the new facilities to report error gracefully
Quite a few lines of code are touched, but nothing deep is going on.
Fixes Trac# 760.