summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser/Errors/Ppr.hs
diff options
context:
space:
mode:
authorAlfredo Di Napoli <alfredo@well-typed.com>2021-01-04 15:35:47 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-01-22 15:00:47 -0500
commita64f21e9f6bd949847d3c8fa1e427e5c763ccd7f (patch)
treecdf6eb8daa58254190a0c8dacdc681b13c3ba884 /compiler/GHC/Parser/Errors/Ppr.hs
parent34950fb84b85d964e30ae9eca995b84fbf4fd165 (diff)
downloadhaskell-a64f21e9f6bd949847d3c8fa1e427e5c763ccd7f.tar.gz
Parameterise Messages over e
This commit paves the way to a richer and more structured representation of GHC error messages, as per GHC proposal #306. More specifically 'Messages' from 'GHC.Types.Error' now gains an extra type parameter, that we instantiate to 'ErrDoc' for now. Later, this will allow us to replace ErrDoc with something more structure (for example messages coming from the parser, the typechecker etc).
Diffstat (limited to 'compiler/GHC/Parser/Errors/Ppr.hs')
-rw-r--r--compiler/GHC/Parser/Errors/Ppr.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/GHC/Parser/Errors/Ppr.hs b/compiler/GHC/Parser/Errors/Ppr.hs
index 98b2341cf1..671453e4c1 100644
--- a/compiler/GHC/Parser/Errors/Ppr.hs
+++ b/compiler/GHC/Parser/Errors/Ppr.hs
@@ -24,25 +24,25 @@ import GHC.Hs.Type (pprLHsContext)
import GHC.Builtin.Names (allNameStrings)
import GHC.Builtin.Types (filterCTuple)
-mkParserErr :: SrcSpan -> SDoc -> ErrMsg
+mkParserErr :: SrcSpan -> SDoc -> ErrMsg ErrDoc
mkParserErr span doc = ErrMsg
{ errMsgSpan = span
, errMsgContext = alwaysQualify
- , errMsgDoc = ErrDoc [doc] [] []
+ , errMsgDiagnostic = ErrDoc [doc] [] []
, errMsgSeverity = SevError
, errMsgReason = NoReason
}
-mkParserWarn :: WarningFlag -> SrcSpan -> SDoc -> ErrMsg
+mkParserWarn :: WarningFlag -> SrcSpan -> SDoc -> ErrMsg ErrDoc
mkParserWarn flag span doc = ErrMsg
{ errMsgSpan = span
, errMsgContext = alwaysQualify
- , errMsgDoc = ErrDoc [doc] [] []
+ , errMsgDiagnostic = ErrDoc [doc] [] []
, errMsgSeverity = SevWarning
, errMsgReason = Reason flag
}
-pprWarning :: PsWarning -> ErrMsg
+pprWarning :: PsWarning -> ErrMsg ErrDoc
pprWarning = \case
PsWarnTab loc tc
-> mkParserWarn Opt_WarnTabs loc $
@@ -128,7 +128,7 @@ pprWarning = \case
OperatorWhitespaceOccurrence_Suffix -> mk_msg "suffix"
OperatorWhitespaceOccurrence_TightInfix -> mk_msg "tight infix"
-pprError :: PsError -> ErrMsg
+pprError :: PsError -> ErrMsg ErrDoc
pprError err = mkParserErr (errLoc err) $ vcat
(pp_err (errDesc err) : map pp_hint (errHints err))