+%************************************************************************
+%* *
+ Shared error message stuff: renamer and typechecker
+%* *
+%************************************************************************
+
+\begin{code}
+addReport :: Message -> Message -> TcRn ()
+addReport msg extra_info = do loc <- getSrcSpanM; addReportAt loc msg extra_info
+
+addReportAt :: SrcSpan -> Message -> Message -> TcRn ()
+addReportAt loc msg extra_info
+ = do { errs_var <- getErrsVar ;
+ rdr_env <- getGlobalRdrEnv ;
+ dflags <- getDOpts ;
+ let { warn = mkLongWarnMsg loc (mkPrintUnqualified dflags rdr_env)
+ msg extra_info } ;
+ (warns, errs) <- readTcRef errs_var ;
+ writeTcRef errs_var (warns `snocBag` warn, errs) }
+
+addLongErrAt :: SrcSpan -> Message -> Message -> TcRn ()
+addLongErrAt loc msg extra
+ = do { traceTc "Adding error:" (mkLocMessage loc (msg $$ extra)) ;
+ errs_var <- getErrsVar ;
+ rdr_env <- getGlobalRdrEnv ;
+ dflags <- getDOpts ;
+ let { err = mkLongErrMsg loc (mkPrintUnqualified dflags rdr_env) msg extra } ;
+ (warns, errs) <- readTcRef errs_var ;
+ writeTcRef errs_var (warns, errs `snocBag` err) }
+
+dumpDerivingInfo :: SDoc -> TcM ()
+dumpDerivingInfo doc
+ = do { dflags <- getDOpts
+ ; when (dopt Opt_D_dump_deriv dflags) $ do
+ { rdr_env <- getGlobalRdrEnv
+ ; let unqual = mkPrintUnqualified dflags rdr_env
+ ; liftIO (putMsgWith dflags unqual doc) } }
+\end{code}
+
+