diff options
Diffstat (limited to 'compiler/GHC/Tc/Utils/Monad.hs')
-rw-r--r-- | compiler/GHC/Tc/Utils/Monad.hs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/compiler/GHC/Tc/Utils/Monad.hs b/compiler/GHC/Tc/Utils/Monad.hs index f1a5425b6f..730e666a2a 100644 --- a/compiler/GHC/Tc/Utils/Monad.hs +++ b/compiler/GHC/Tc/Utils/Monad.hs @@ -92,7 +92,7 @@ module GHC.Tc.Utils.Monad( failWithTc, failWithTcM, checkTc, checkTcM, failIfTc, failIfTcM, - warnIfFlag, warnIf, diagnosticTc, diagnosticTcM, + warnIfFlag, warnIf, diagnosticTc, diagnosticTcM, addDetailedDiagnostic, addTcRnDiagnostic, addDiagnosticTc, addDiagnosticTcM, addDiagnostic, addDiagnosticAt, add_diagnostic, mkErrInfo, @@ -1548,6 +1548,25 @@ addDiagnosticTcM reason (env0, msg) addDiagnostic :: DiagnosticReason -> SDoc -> TcRn () addDiagnostic reason msg = add_diagnostic reason msg Outputable.empty +-- | A variation of 'addDiagnostic' that takes a function to produce a 'TcRnDsMessage' +-- given some additional context about the diagnostic. +addDetailedDiagnostic :: (ErrInfo -> TcRnMessage) -> TcM () +addDetailedDiagnostic mkMsg = do + loc <- getSrcSpanM + printer <- getPrintUnqualified + dflags <- getDynFlags + env0 <- tcInitTidyEnv + ctxt <- getErrCtxt + err_info <- mkErrInfo env0 ctxt + reportDiagnostic (mkMsgEnvelope dflags loc printer (mkMsg (ErrInfo err_info))) + +addTcRnDiagnostic :: TcRnMessage -> TcM () +addTcRnDiagnostic msg = do + loc <- getSrcSpanM + printer <- getPrintUnqualified + dflags <- getDynFlags + reportDiagnostic (mkMsgEnvelope dflags loc printer msg) + -- | Display a diagnostic for a given source location. addDiagnosticAt :: DiagnosticReason -> SrcSpan -> SDoc -> TcRn () addDiagnosticAt reason loc msg = add_diagnostic_at reason loc msg Outputable.empty |