ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Types.Error

Contents

- Messages
- Classifying Messages
- Hints and refactoring actions
- Rendering Messages
- Queries
- Diagnostic codes

Synopsis

- data Messages e
- mkMessages :: Bag (MsgEnvelope e) -> Messages e
- getMessages :: Messages e -> Bag (MsgEnvelope e)
- emptyMessages :: Messages e
- isEmptyMessages :: Messages e -> Bool
- singleMessage :: MsgEnvelope e -> Messages e
- addMessage :: MsgEnvelope e -> Messages e -> Messages e
- unionMessages :: Messages e -> Messages e -> Messages e
- unionManyMessages :: Foldable f => f (Messages e) -> Messages e
- filterMessages :: (MsgEnvelope e -> Bool) -> Messages e -> Messages e
- data MsgEnvelope e = MsgEnvelope {
  - errMsgSpan :: SrcSpan
  - errMsgContext :: NamePprCtx
  - errMsgDiagnostic :: e
  - errMsgSeverity :: Severity
  - errMsgReason :: ResolvedDiagnosticReason
  }
- data MessageClass
  - = MCOutput
  - | MCFatal
  - | MCInteractive
  - | MCDump
  - | MCInfo
  - | MCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
- data Severity
  - = SevIgnore
  - | SevWarning
  - | SevError
- class (Outputable (DiagnosticHint a), HasDefaultDiagnosticOpts (DiagnosticOpts a)) => Diagnostic a where
  - type DiagnosticOpts a
  - type DiagnosticHint a
  - diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc
  - diagnosticReason :: a -> DiagnosticReason
  - diagnosticHints :: a -> [DiagnosticHint a]
  - diagnosticCode :: a -> Maybe DiagnosticCode
- data UnknownDiagnostic opts hint where
  - UnknownDiagnostic :: forall a opts hint. (Diagnostic a, Typeable a) => (opts -> DiagnosticOpts a) -> (DiagnosticHint a -> hint) -> a -> UnknownDiagnostic opts hint
- type UnknownDiagnosticFor a = UnknownDiagnostic (DiagnosticOpts a) (DiagnosticHint a)
- mkSimpleUnknownDiagnostic :: (Diagnostic a, Typeable a, DiagnosticOpts a ~ NoDiagnosticOpts) => a -> UnknownDiagnostic b (DiagnosticHint a)
- mkUnknownDiagnostic :: (Typeable a, Diagnostic a) => a -> UnknownDiagnosticFor a
- embedUnknownDiagnostic :: (Diagnostic a, Typeable a) => (opts -> DiagnosticOpts a) -> a -> UnknownDiagnostic opts (DiagnosticHint a)
- data DiagnosticMessage = DiagnosticMessage {
  - diagMessage :: !DecoratedSDoc
  - diagReason :: !DiagnosticReason
  - diagHints :: [GhcHint]
  }
- data DiagnosticReason where
  - WarningWithoutFlag
  - WarningWithFlags !(NonEmpty WarningFlag)
  - WarningWithCategory !WarningCategory
  - ErrorWithoutFlag
  - pattern WarningWithFlag :: WarningFlag -> DiagnosticReason
- newtype ResolvedDiagnosticReason = ResolvedDiagnosticReason {
  - resolvedDiagnosticReason :: DiagnosticReason
  }
- mkPlainDiagnostic :: DiagnosticReason -> [GhcHint] -> SDoc -> DiagnosticMessage
- mkPlainError :: [GhcHint] -> SDoc -> DiagnosticMessage
- mkDecoratedDiagnostic :: DiagnosticReason -> [GhcHint] -> [SDoc] -> DiagnosticMessage
- mkDecoratedError :: [GhcHint] -> [SDoc] -> DiagnosticMessage
- pprDiagnostic :: Diagnostic e => e -> SDoc
- class HasDefaultDiagnosticOpts opts where
  - defaultOpts :: opts
- defaultDiagnosticOpts :: HasDefaultDiagnosticOpts (DiagnosticOpts opts) => DiagnosticOpts opts
- data NoDiagnosticOpts = NoDiagnosticOpts
- data GhcHint
  - = (Outputable a, Typeable a) => UnknownHint a
  - | SuggestExtension !LanguageExtensionHint
  - | SuggestCorrectPragmaName ![String]
  - | SuggestMissingDo
  - | SuggestLetInDo
  - | SuggestAddSignatureCabalFile !ModuleName
  - | SuggestSignatureInstantiations !ModuleName [InstantiationSuggestion]
  - | SuggestUseSpaces
  - | SuggestUseWhitespaceAfter !OperatorWhitespaceSymbol
  - | SuggestUseWhitespaceAround !String !OperatorWhitespaceOccurrence
  - | SuggestParentheses
  - | SuggestIncreaseMaxPmCheckModels
  - | SuggestAddTypeSignatures AvailableBindings
  - | SuggestBindToWildcard !(LHsExpr GhcTc)
  - | SuggestAddInlineOrNoInlinePragma !Var !Activation
  - | SuggestAddPhaseToCompetingRule !RuleName
  - | SuggestAddToHSigExportList !Name !(Maybe Module)
  - | SuggestIncreaseSimplifierIterations
  - | SuggestUseTypeFromDataKind (Maybe RdrName)
  - | SuggestQualifiedAfterModuleName
  - | SuggestThQuotationSyntax
  - | SuggestRoles [Role]
  - | SuggestQualifyStarOperator
  - | SuggestTypeSignatureRemoveQualifier
  - | SuggestFixOrphanInst {
    - isFamilyInstance :: Maybe FamFlavor
    }
  - | SuggestAddStandaloneDerivation
  - | SuggestAddStandaloneKindSignature Name
  - | SuggestFillInWildcardConstraint
  - | SuggestAppropriateTHTick NameSpace
  - | SuggestDumpSlices
  - | SuggestAddTick UntickedPromotedThing
  - | SuggestMoveToDeclarationSite SigLike RdrName
  - | SuggestSimilarNames RdrName (NonEmpty SimilarName)
  - | RemindFieldSelectorSuppressed {
    - suppressed_selector :: RdrName
    - suppressed_parents :: [Name]
    }
  - | ImportSuggestion OccName ImportSuggestion
  - | SuggestPlacePragmaInHeader
  - | SuggestPatternMatchingSyntax
  - | SuggestSpecialiseVisibilityHints Name
  - | SuggestRenameTypeVariable
  - | SuggestExplicitBidiPatSyn Name (LPat GhcRn) [LIdP GhcRn]
  - | SuggestSafeHaskell
  - | SuggestRemoveRecordWildcard
  - | SuggestMoveNonCanonicalDefinition Name Name String
  - | SuggestIncreaseReductionDepth
  - | SuggestRemoveNonCanonicalDefinition Name Name String
  - | SuggestEtaReduceAbsDataTySyn TyCon
  - | RemindRecordMissingField FastString Type Type
  - | SuggestBindTyVarOnLhs RdrName
  - | SuggestAnonymousWildcard
  - | SuggestExplicitQuantification RdrName
  - | SuggestBindTyVarExplicitly Name
  - | SuggestDefaultDeclaration Class [Type]
  - | SuggestExplicitDerivingClauseStrategies (Map AssumedDerivingStrategy [LHsSigType GhcRn])
  - | SuggestExplicitStandaloneDerivingStrategy AssumedDerivingStrategy (LHsSigWcType GhcRn)
  - | SuggestParenthesizePatternRHS
  - | SuggestSplittingIntoSeveralSpecialisePragmas
  - | SuggestDataKeyword
- data AvailableBindings
  - = NamedBindings (NonEmpty Name)
  - | UnnamedBinding
- data LanguageExtensionHint
  - = SuggestSingleExtension !SDoc !Extension
  - | SuggestAnyExtension !SDoc [Extension]
  - | SuggestExtensions !SDoc [Extension]
  - | SuggestExtensionInOrderTo !SDoc !Extension
- suggestExtension :: Extension -> GhcHint
- suggestExtensionWithInfo :: SDoc -> Extension -> GhcHint
- suggestExtensions :: [Extension] -> GhcHint
- suggestExtensionsWithInfo :: SDoc -> [Extension] -> GhcHint
- suggestAnyExtension :: [Extension] -> GhcHint
- suggestAnyExtensionWithInfo :: SDoc -> [Extension] -> GhcHint
- useExtensionInOrderTo :: SDoc -> Extension -> GhcHint
- noHints :: [GhcHint]
- data SDoc
- data DecoratedSDoc
- mkDecorated :: [SDoc] -> DecoratedSDoc
- mkSimpleDecorated :: SDoc -> DecoratedSDoc
- unionDecoratedSDoc :: DecoratedSDoc -> DecoratedSDoc -> DecoratedSDoc
- mapDecoratedSDoc :: (SDoc -> SDoc) -> DecoratedSDoc -> DecoratedSDoc
- pprMessageBag :: Bag SDoc -> SDoc
- mkLocMessage :: MessageClass -> SrcSpan -> SDoc -> SDoc
- mkLocMessageWarningGroups :: Bool -> MessageClass -> SrcSpan -> SDoc -> SDoc
- getCaretDiagnostic :: MessageClass -> SrcSpan -> IO SDoc
- isIntrinsicErrorMessage :: Diagnostic e => MsgEnvelope e -> Bool
- isExtrinsicErrorMessage :: MsgEnvelope e -> Bool
- isWarningMessage :: Diagnostic e => MsgEnvelope e -> Bool
- getErrorMessages :: Diagnostic e => Messages e -> Bag (MsgEnvelope e)
- getWarningMessages :: Diagnostic e => Messages e -> Bag (MsgEnvelope e)
- partitionMessages :: Diagnostic e => Messages e -> (Messages e, Messages e)
- errorsFound :: Diagnostic e => Messages e -> Bool
- errorsOrFatalWarningsFound :: Messages e -> Bool
- data DiagnosticCode = DiagnosticCode {
  - diagnosticCodeNameSpace :: String
  - diagnosticCodeNumber :: Natural
  }

# Messages

data Messages e #

A collection of messages emitted by GHC during error reporting. A diagnostic message is typically a warning or an error. See Note [Messages].

INVARIANT: All the messages in this collection must be relevant, i.e. their `Severity` should not be `SevIgnore`. The smart constructor `mkMessages` will filter out any message which `Severity` is `SevIgnore`.

#### Instances

Instances details

Functor Messages # |
Instance details Defined in GHC.Types.Error Methods fmap :: (a -> b) -> Messages a -> Messages b # (<$) :: a -> Messages b -> Messages a #
Foldable Messages # |
Instance details Defined in GHC.Types.Error Methods fold :: Monoid m => Messages m -> m # foldMap :: Monoid m => (a -> m) -> Messages a -> m # foldMap' :: Monoid m => (a -> m) -> Messages a -> m # foldr :: (a -> b -> b) -> b -> Messages a -> b # foldr' :: (a -> b -> b) -> b -> Messages a -> b # foldl :: (b -> a -> b) -> b -> Messages a -> b # foldl' :: (b -> a -> b) -> b -> Messages a -> b # foldr1 :: (a -> a -> a) -> Messages a -> a # foldl1 :: (a -> a -> a) -> Messages a -> a # toList :: Messages a -> [a] # null :: Messages a -> Bool # length :: Messages a -> Int # elem :: Eq a => a -> Messages a -> Bool # maximum :: Ord a => Messages a -> a # minimum :: Ord a => Messages a -> a # sum :: Num a => Messages a -> a # product :: Num a => Messages a -> a #
Traversable Messages # |
Instance details Defined in GHC.Types.Error Methods traverse :: Applicative f => (a -> f b) -> Messages a -> f (Messages b) # sequenceA :: Applicative f => Messages (f a) -> f (Messages a) # mapM :: Monad m => (a -> m b) -> Messages a -> m (Messages b) # sequence :: Monad m => Messages (m a) -> m (Messages a) #
Monoid (Messages e) # |
Instance details Defined in GHC.Types.Error Methods mempty :: Messages e # mappend :: Messages e -> Messages e -> Messages e # mconcat :: [Messages e] -> Messages e #
Semigroup (Messages e) # |
Instance details Defined in GHC.Types.Error Methods (<>) :: Messages e -> Messages e -> Messages e # sconcat :: NonEmpty (Messages e) -> Messages e # stimes :: Integral b => b -> Messages e -> Messages e #
Diagnostic e => ToJson (Messages e) # |
Instance details Defined in GHC.Types.Error Methods json :: Messages e -> JsonDoc #
Diagnostic e => Outputable (Messages e) # |
Instance details Defined in GHC.Types.Error Methods ppr :: Messages e -> SDoc #

mkMessages :: Bag (MsgEnvelope e) -> Messages e #

getMessages :: Messages e -> Bag (MsgEnvelope e) #

emptyMessages :: Messages e #

isEmptyMessages :: Messages e -> Bool #

singleMessage :: MsgEnvelope e -> Messages e #

addMessage :: MsgEnvelope e -> Messages e -> Messages e #

Adds a `Message` to the input collection of messages. See Note [Discarding Messages].

unionMessages :: Messages e -> Messages e -> Messages e #

Joins two collections of messages together. See Note [Discarding Messages].

unionManyMessages :: Foldable f => f (Messages e) -> Messages e #

Joins many `Messages`s together

filterMessages :: (MsgEnvelope e -> Bool) -> Messages e -> Messages e #

data MsgEnvelope e #

An envelope for GHC's facts about a running program, parameterised over the domain-specific (i.e. parsing, typecheck-renaming, etc) diagnostics.

To say things differently, GHC emits diagnostics about the running program, each of which is wrapped into a `MsgEnvelope` that carries specific information like where the error happened, etc. Finally, multiple `MsgEnvelope`s are aggregated into `Messages` that are returned to the user.

Constructors

MsgEnvelope |
Fields errMsgSpan :: SrcSpan The SrcSpan is used for sorting errors into line-number order errMsgContext :: NamePprCtx errMsgDiagnostic :: e errMsgSeverity :: Severity errMsgReason :: ResolvedDiagnosticReason The actual reason caused this message See Note [Warnings controlled by multiple flags]

#### Instances

Instances details

Functor MsgEnvelope # |
Instance details Defined in GHC.Types.Error Methods fmap :: (a -> b) -> MsgEnvelope a -> MsgEnvelope b # (<$) :: a -> MsgEnvelope b -> MsgEnvelope a #
Foldable MsgEnvelope # |
Instance details Defined in GHC.Types.Error Methods fold :: Monoid m => MsgEnvelope m -> m # foldMap :: Monoid m => (a -> m) -> MsgEnvelope a -> m # foldMap' :: Monoid m => (a -> m) -> MsgEnvelope a -> m # foldr :: (a -> b -> b) -> b -> MsgEnvelope a -> b # foldr' :: (a -> b -> b) -> b -> MsgEnvelope a -> b # foldl :: (b -> a -> b) -> b -> MsgEnvelope a -> b # foldl' :: (b -> a -> b) -> b -> MsgEnvelope a -> b # foldr1 :: (a -> a -> a) -> MsgEnvelope a -> a # foldl1 :: (a -> a -> a) -> MsgEnvelope a -> a # toList :: MsgEnvelope a -> [a] # null :: MsgEnvelope a -> Bool # length :: MsgEnvelope a -> Int # elem :: Eq a => a -> MsgEnvelope a -> Bool # maximum :: Ord a => MsgEnvelope a -> a # minimum :: Ord a => MsgEnvelope a -> a # sum :: Num a => MsgEnvelope a -> a # product :: Num a => MsgEnvelope a -> a #
Traversable MsgEnvelope # |
Instance details Defined in GHC.Types.Error Methods traverse :: Applicative f => (a -> f b) -> MsgEnvelope a -> f (MsgEnvelope b) # sequenceA :: Applicative f => MsgEnvelope (f a) -> f (MsgEnvelope a) # mapM :: Monad m => (a -> m b) -> MsgEnvelope a -> m (MsgEnvelope b) # sequence :: Monad m => MsgEnvelope (m a) -> m (MsgEnvelope a) #
Show (MsgEnvelope DiagnosticMessage) # |
Instance details Defined in GHC.Types.Error Methods showsPrec :: Int -> MsgEnvelope DiagnosticMessage -> ShowS # show :: MsgEnvelope DiagnosticMessage -> String # showList :: [MsgEnvelope DiagnosticMessage] -> ShowS #
Diagnostic e => ToJson (MsgEnvelope e) # |
Instance details Defined in GHC.Types.Error Methods json :: MsgEnvelope e -> JsonDoc #

# Classifying Messages

data MessageClass #

The class for a diagnostic message. The main purpose is to classify a message within GHC, to distinguish it from a debug/dump message vs a proper diagnostic, for which we include a `DiagnosticReason`.

Constructors

MCOutput |
MCFatal |
MCInteractive |
MCDump | Log message intended for compiler developers No file/line/column stuff
MCInfo | Log messages intended for end users. No file/line/column stuff.
MCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode) | Diagnostics from the compiler. This constructor is very powerful as it allows the construction of a `MessageClass` with a completely arbitrary permutation of `Severity` and `DiagnosticReason`. As such, users are encouraged to use the `mkMCDiagnostic` smart constructor instead. Use this constructor directly only if you need to construct and manipulate diagnostic messages directly, for example inside `Error`. In all the other circumstances, especially when emitting compiler diagnostics, use the smart constructor. The `Maybe `DiagnosticCode`` field carries a code (if available) for this diagnostic. If you are creating a message not tied to any error-message type, then use Nothing. In the long run, this really should always have a `DiagnosticCode`. See Note [Diagnostic codes].

#### Instances

Instances details

ToJson MessageClass # |
Instance details Defined in GHC.Types.Error Methods json :: MessageClass -> JsonDoc #

data Severity #

Used to describe warnings and errors o The message has a file/line/column heading, plus "warning:" or "error:", added by mkLocMessage o With `SevIgnore` the message is suppressed o Output is intended for end users

Constructors

SevIgnore | Ignore this message, for example in case of suppression of warnings users don't want to see. See Note [Suppressing Messages]
SevWarning |
SevError |

#### Instances

Instances details

Show Severity # |
Instance details Defined in GHC.Types.Error Methods showsPrec :: Int -> Severity -> ShowS # show :: Severity -> String # showList :: [Severity] -> ShowS #
ToJson Severity # |
Instance details Defined in GHC.Types.Error Methods json :: Severity -> JsonDoc #
Outputable Severity # |
Instance details Defined in GHC.Types.Error Methods ppr :: Severity -> SDoc #
Eq Severity # |
Instance details Defined in GHC.Types.Error Methods (==) :: Severity -> Severity -> Bool # (/=) :: Severity -> Severity -> Bool #
Ord Severity # |
Instance details Defined in GHC.Types.Error Methods compare :: Severity -> Severity -> Ordering # (<) :: Severity -> Severity -> Bool # (<=) :: Severity -> Severity -> Bool # (>) :: Severity -> Severity -> Bool # (>=) :: Severity -> Severity -> Bool # max :: Severity -> Severity -> Severity # min :: Severity -> Severity -> Severity #

class (Outputable (DiagnosticHint a), HasDefaultDiagnosticOpts (DiagnosticOpts a)) => Diagnostic a where #

A class identifying a diagnostic. Dictionary.com defines a diagnostic as:

"a message output by a computer diagnosing an error in a computer program, computer system, or component device".

A `Diagnostic` carries the actual description of the message (which, in GHC's case, it can be an error or a warning) and the reason why such message was generated in the first place.

Associated Types

type DiagnosticOpts a #

Type of configuration options for the diagnostic.

type DiagnosticHint a #

Type of hint this diagnostic can provide. By default, this is `GhcHint`.

type DiagnosticHint a = GhcHint

Methods

diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc #

Extract the error message text from a `Diagnostic`.

diagnosticReason :: a -> DiagnosticReason #

Extract the reason for this diagnostic. For warnings, a `DiagnosticReason` includes the warning flag.

diagnosticHints :: a -> [DiagnosticHint a] #

Extract any hints a user might use to repair their code to avoid this diagnostic.

diagnosticCode :: a -> Maybe DiagnosticCode #

Get the `DiagnosticCode` associated with this `Diagnostic`. This can return `Nothing` for at least two reasons:

1. The message might be from a plugin that does not supply codes.
2. The message might not yet have been assigned a code. See the `Diagnostic` instance for `DiagnosticMessage`.

Ideally, case (2) would not happen, but because some errors in GHC still use the old system of just writing the error message in-place (instead of using a dedicated error type and constructor), we do not have error codes for all errors. #18516 tracks our progress toward this goal.

#### Instances

Instances details

Diagnostic DriverMessage # |
Instance details Defined in GHC.Driver.Errors.Ppr Associated Types
type DiagnosticOpts DriverMessage |
Instance details Defined in GHC.Driver.Errors.Ppr type DiagnosticOpts DriverMessage = DriverMessageOpts
type DiagnosticHint DriverMessage |
Instance details Defined in GHC.Driver.Errors.Ppr type DiagnosticHint DriverMessage = GhcHint
Methods diagnosticMessage :: DiagnosticOpts DriverMessage -> DriverMessage -> DecoratedSDoc # diagnosticReason :: DriverMessage -> DiagnosticReason # diagnosticHints :: DriverMessage -> [DiagnosticHint DriverMessage] # diagnosticCode :: DriverMessage -> Maybe DiagnosticCode #
Diagnostic GhcMessage # |
Instance details Defined in GHC.Driver.Errors.Ppr Associated Types
type DiagnosticOpts GhcMessage |
Instance details Defined in GHC.Driver.Errors.Ppr type DiagnosticOpts GhcMessage = GhcMessageOpts
type DiagnosticHint GhcMessage |
Instance details Defined in GHC.Driver.Errors.Ppr type DiagnosticHint GhcMessage = GhcHint
Methods diagnosticMessage :: DiagnosticOpts GhcMessage -> GhcMessage -> DecoratedSDoc # diagnosticReason :: GhcMessage -> DiagnosticReason # diagnosticHints :: GhcMessage -> [DiagnosticHint GhcMessage] # diagnosticCode :: GhcMessage -> Maybe DiagnosticCode #
Diagnostic DsMessage # |
Instance details Defined in GHC.HsToCore.Errors.Ppr Associated Types
type DiagnosticOpts DsMessage |
Instance details Defined in GHC.HsToCore.Errors.Ppr type DiagnosticOpts DsMessage = NoDiagnosticOpts
type DiagnosticHint DsMessage |
Instance details Defined in GHC.HsToCore.Errors.Ppr type DiagnosticHint DsMessage = GhcHint
Methods diagnosticMessage :: DiagnosticOpts DsMessage -> DsMessage -> DecoratedSDoc # diagnosticReason :: DsMessage -> DiagnosticReason # diagnosticHints :: DsMessage -> [DiagnosticHint DsMessage] # diagnosticCode :: DsMessage -> Maybe DiagnosticCode #
Diagnostic IfaceMessage # |
Instance details Defined in GHC.Iface.Errors.Ppr Associated Types
type DiagnosticOpts IfaceMessage |
Instance details Defined in GHC.Iface.Errors.Ppr type DiagnosticOpts IfaceMessage = IfaceMessageOpts
type DiagnosticHint IfaceMessage |
Instance details Defined in GHC.Iface.Errors.Ppr type DiagnosticHint IfaceMessage = GhcHint
Methods diagnosticMessage :: DiagnosticOpts IfaceMessage -> IfaceMessage -> DecoratedSDoc # diagnosticReason :: IfaceMessage -> DiagnosticReason # diagnosticHints :: IfaceMessage -> [DiagnosticHint IfaceMessage] # diagnosticCode :: IfaceMessage -> Maybe DiagnosticCode #
Diagnostic PsMessage # |
Instance details Defined in GHC.Parser.Errors.Ppr Associated Types
type DiagnosticOpts PsMessage |
Instance details Defined in GHC.Parser.Errors.Ppr type DiagnosticOpts PsMessage = NoDiagnosticOpts
type DiagnosticHint PsMessage |
Instance details Defined in GHC.Parser.Errors.Ppr type DiagnosticHint PsMessage = GhcHint
Methods diagnosticMessage :: DiagnosticOpts PsMessage -> PsMessage -> DecoratedSDoc # diagnosticReason :: PsMessage -> DiagnosticReason # diagnosticHints :: PsMessage -> [DiagnosticHint PsMessage] # diagnosticCode :: PsMessage -> Maybe DiagnosticCode #
Diagnostic TcRnMessage # |
Instance details Defined in GHC.Tc.Errors.Ppr Associated Types
type DiagnosticOpts TcRnMessage |
Instance details Defined in GHC.Tc.Errors.Ppr type DiagnosticOpts TcRnMessage = TcRnMessageOpts
type DiagnosticHint TcRnMessage |
Instance details Defined in GHC.Tc.Errors.Ppr type DiagnosticHint TcRnMessage = GhcHint
Methods diagnosticMessage :: DiagnosticOpts TcRnMessage -> TcRnMessage -> DecoratedSDoc # diagnosticReason :: TcRnMessage -> DiagnosticReason # diagnosticHints :: TcRnMessage -> [DiagnosticHint TcRnMessage] # diagnosticCode :: TcRnMessage -> Maybe DiagnosticCode #
Diagnostic DiagnosticMessage # |
Instance details Defined in GHC.Types.Error Associated Types
type DiagnosticOpts DiagnosticMessage |
Instance details Defined in GHC.Types.Error type DiagnosticOpts DiagnosticMessage = NoDiagnosticOpts
type DiagnosticHint DiagnosticMessage |
Instance details Defined in GHC.Types.Error type DiagnosticHint DiagnosticMessage = GhcHint
Methods diagnosticMessage :: DiagnosticOpts DiagnosticMessage -> DiagnosticMessage -> DecoratedSDoc # diagnosticReason :: DiagnosticMessage -> DiagnosticReason # diagnosticHints :: DiagnosticMessage -> [DiagnosticHint DiagnosticMessage] # diagnosticCode :: DiagnosticMessage -> Maybe DiagnosticCode #
(HasDefaultDiagnosticOpts opts, Outputable hint) => Diagnostic (UnknownDiagnostic opts hint) # |
Instance details Defined in GHC.Types.Error Associated Types
type DiagnosticOpts (UnknownDiagnostic opts hint) |
Instance details Defined in GHC.Types.Error type DiagnosticOpts (UnknownDiagnostic opts hint) = opts
type DiagnosticHint (UnknownDiagnostic opts hint) |
Instance details Defined in GHC.Types.Error type DiagnosticHint (UnknownDiagnostic opts hint) = hint
Methods diagnosticMessage :: DiagnosticOpts (UnknownDiagnostic opts hint) -> UnknownDiagnostic opts hint -> DecoratedSDoc # diagnosticReason :: UnknownDiagnostic opts hint -> DiagnosticReason # diagnosticHints :: UnknownDiagnostic opts hint -> [DiagnosticHint (UnknownDiagnostic opts hint)] # diagnosticCode :: UnknownDiagnostic opts hint -> Maybe DiagnosticCode #

data UnknownDiagnostic opts hint where #

An existential wrapper around an unknown diagnostic.

Constructors

UnknownDiagnostic :: forall a opts hint. (Diagnostic a, Typeable a) => (opts -> DiagnosticOpts a) -> (DiagnosticHint a -> hint) -> a -> UnknownDiagnostic opts hint |

#### Instances

Instances details

(HasDefaultDiagnosticOpts opts, Outputable hint) => Diagnostic (UnknownDiagnostic opts hint) # |
Instance details Defined in GHC.Types.Error Associated Types
type DiagnosticOpts (UnknownDiagnostic opts hint) |
Instance details Defined in GHC.Types.Error type DiagnosticOpts (UnknownDiagnostic opts hint) = opts
type DiagnosticHint (UnknownDiagnostic opts hint) |
Instance details Defined in GHC.Types.Error type DiagnosticHint (UnknownDiagnostic opts hint) = hint
Methods diagnosticMessage :: DiagnosticOpts (UnknownDiagnostic opts hint) -> UnknownDiagnostic opts hint -> DecoratedSDoc # diagnosticReason :: UnknownDiagnostic opts hint -> DiagnosticReason # diagnosticHints :: UnknownDiagnostic opts hint -> [DiagnosticHint (UnknownDiagnostic opts hint)] # diagnosticCode :: UnknownDiagnostic opts hint -> Maybe DiagnosticCode #
type DiagnosticHint (UnknownDiagnostic opts hint) # |
Instance details Defined in GHC.Types.Error type DiagnosticHint (UnknownDiagnostic opts hint) = hint
type DiagnosticOpts (UnknownDiagnostic opts hint) # |
Instance details Defined in GHC.Types.Error type DiagnosticOpts (UnknownDiagnostic opts hint) = opts

type UnknownDiagnosticFor a = UnknownDiagnostic (DiagnosticOpts a) (DiagnosticHint a) #

mkSimpleUnknownDiagnostic :: (Diagnostic a, Typeable a, DiagnosticOpts a ~ NoDiagnosticOpts) => a -> UnknownDiagnostic b (DiagnosticHint a) #

Make a "simple" unknown diagnostic which doesn't have any configuration options and the same hint.

mkUnknownDiagnostic :: (Typeable a, Diagnostic a) => a -> UnknownDiagnosticFor a #

Make an unknown diagnostic which uses the same options and hint as the context it will be embedded into.

embedUnknownDiagnostic :: (Diagnostic a, Typeable a) => (opts -> DiagnosticOpts a) -> a -> UnknownDiagnostic opts (DiagnosticHint a) #

Embed a more complicated diagnostic which requires a potentially different options type.

data DiagnosticMessage #

A generic `Diagnostic` message, without any further classification or provenance: By looking at a `DiagnosticMessage` we don't know neither where it was generated nor how to interpret its payload (as it's just a structured document). All we can do is to print it out and look at its `DiagnosticReason`.

Constructors

DiagnosticMessage |
Fields diagMessage :: !DecoratedSDoc diagReason :: !DiagnosticReason diagHints :: [GhcHint]

#### Instances

Instances details

Diagnostic DiagnosticMessage # |
Instance details Defined in GHC.Types.Error Associated Types
type DiagnosticOpts DiagnosticMessage |
Instance details Defined in GHC.Types.Error type DiagnosticOpts DiagnosticMessage = NoDiagnosticOpts
type DiagnosticHint DiagnosticMessage |
Instance details Defined in GHC.Types.Error type DiagnosticHint DiagnosticMessage = GhcHint
Methods diagnosticMessage :: DiagnosticOpts DiagnosticMessage -> DiagnosticMessage -> DecoratedSDoc # diagnosticReason :: DiagnosticMessage -> DiagnosticReason # diagnosticHints :: DiagnosticMessage -> [DiagnosticHint DiagnosticMessage] # diagnosticCode :: DiagnosticMessage -> Maybe DiagnosticCode #
Show (MsgEnvelope DiagnosticMessage) # |
Instance details Defined in GHC.Types.Error Methods showsPrec :: Int -> MsgEnvelope DiagnosticMessage -> ShowS # show :: MsgEnvelope DiagnosticMessage -> String # showList :: [MsgEnvelope DiagnosticMessage] -> ShowS #
type DiagnosticHint DiagnosticMessage # |
Instance details Defined in GHC.Types.Error type DiagnosticHint DiagnosticMessage = GhcHint
type DiagnosticOpts DiagnosticMessage # |
Instance details Defined in GHC.Types.Error type DiagnosticOpts DiagnosticMessage = NoDiagnosticOpts

data DiagnosticReason #

The reason why a `Diagnostic` was emitted in the first place. Diagnostic messages are born within GHC with a very precise reason, which can be completely statically-computed (i.e. this is an error or a warning no matter what), or influenced by the specific state of the `DynFlags` at the moment of the creation of a new `Diagnostic`. For example, a parsing error is always going to be an error, whereas a 'WarningWithoutFlag Opt_WarnUnusedImports' might turn into an error due to '-Werror' or '-Werror=warn-unused-imports'. Interpreting a `DiagnosticReason` together with its associated `Severity` gives us the full picture.

Constructors

WarningWithoutFlag | Born as a warning.
WarningWithFlags !(NonEmpty WarningFlag) | Warning was enabled with the flag.
WarningWithCategory !WarningCategory | Warning was enabled with a custom category.
ErrorWithoutFlag | Born as an error.

Bundled Patterns

pattern WarningWithFlag :: WarningFlag -> DiagnosticReason | The single warning case `DiagnosticReason` is very common.

#### Instances

Instances details

Show DiagnosticReason # |
Instance details Defined in GHC.Types.Error Methods showsPrec :: Int -> DiagnosticReason -> ShowS # show :: DiagnosticReason -> String # showList :: [DiagnosticReason] -> ShowS #
Outputable DiagnosticReason # |
Instance details Defined in GHC.Types.Error Methods ppr :: DiagnosticReason -> SDoc #
Eq DiagnosticReason # |
Instance details Defined in GHC.Types.Error Methods (==) :: DiagnosticReason -> DiagnosticReason -> Bool # (/=) :: DiagnosticReason -> DiagnosticReason -> Bool #

newtype ResolvedDiagnosticReason #

Like a `DiagnosticReason`, but resolved against a specific set of `DynFlags` to work out which warning flag actually enabled this warning.

Constructors

ResolvedDiagnosticReason |
Fields resolvedDiagnosticReason :: DiagnosticReason

#### Instances

Instances details

Outputable ResolvedDiagnosticReason # |
Instance details Defined in GHC.Types.Error Methods ppr :: ResolvedDiagnosticReason -> SDoc #

mkPlainDiagnostic :: DiagnosticReason -> [GhcHint] -> SDoc -> DiagnosticMessage #

mkPlainError :: [GhcHint] -> SDoc -> DiagnosticMessage #

Create an error `DiagnosticMessage` holding just a single `SDoc`

mkDecoratedDiagnostic :: DiagnosticReason -> [GhcHint] -> [SDoc] -> DiagnosticMessage #

Create a `DiagnosticMessage` from a list of bulleted SDocs and a `DiagnosticReason`

mkDecoratedError :: [GhcHint] -> [SDoc] -> DiagnosticMessage #

Create an error `DiagnosticMessage` from a list of bulleted SDocs

pprDiagnostic :: Diagnostic e => e -> SDoc #

class HasDefaultDiagnosticOpts opts where #

Methods

defaultOpts :: opts #

#### Instances

Instances details

HasDefaultDiagnosticOpts DriverMessageOpts # |
Instance details Defined in GHC.Driver.Errors.Ppr Methods defaultOpts :: DriverMessageOpts #
HasDefaultDiagnosticOpts GhcMessageOpts # |
Instance details Defined in GHC.Driver.Errors.Ppr Methods defaultOpts :: GhcMessageOpts #
HasDefaultDiagnosticOpts IfaceMessageOpts # |
Instance details Defined in GHC.Iface.Errors.Ppr Methods defaultOpts :: IfaceMessageOpts #
HasDefaultDiagnosticOpts TcRnMessageOpts # |
Instance details Defined in GHC.Tc.Errors.Ppr Methods defaultOpts :: TcRnMessageOpts #
HasDefaultDiagnosticOpts NoDiagnosticOpts # |
Instance details Defined in GHC.Types.Error Methods defaultOpts :: NoDiagnosticOpts #

defaultDiagnosticOpts :: HasDefaultDiagnosticOpts (DiagnosticOpts opts) => DiagnosticOpts opts #

data NoDiagnosticOpts #

Constructors

NoDiagnosticOpts |

#### Instances

Instances details

HasDefaultDiagnosticOpts NoDiagnosticOpts # |
Instance details Defined in GHC.Types.Error Methods defaultOpts :: NoDiagnosticOpts #

# Hints and refactoring actions

data GhcHint #

A type for hints emitted by GHC. A hint suggests a possible way to deal with a particular warning or error.

Constructors

(Outputable a, Typeable a) => UnknownHint a | An "unknown" hint. This type constructor allows arbitrary -- hints to be embedded. The typical use case would be GHC plugins -- willing to emit hints alongside their custom diagnostics.
SuggestExtension !LanguageExtensionHint | Suggests adding a particular language extension. GHC will do its best trying to guess when the user is using the syntax of a particular language extension without having the relevant extension enabled. Example: If the user uses the keyword "mdo" (and we are in a monadic block), but the relevant extension is not enabled, GHC will emit a 'SuggestExtension RecursiveDo'. Test case(s): parsershould_failT12429, parsershould_failT8501c, parsershould_failT18251e, ... (and many more)
SuggestCorrectPragmaName ![String] | Suggests possible corrections of a misspelled pragma. Its argument represents all applicable suggestions. Example: {-# LNGUAGE BangPatterns #-} Test case(s): parsershould_compileT21589
SuggestMissingDo | Suggests that a monadic code block is probably missing a "do" keyword. Example: main = putStrLn "hello" putStrLn "world" Test case(s): parsershould_failT8501a, parsershould_failreadFail007, parsershould_failInfixAppPatErr, parsershould_failT984
SuggestLetInDo | Suggests that a "let" expression is needed in a "do" block. Test cases: None (that explicitly test this particular hint is emitted).
SuggestAddSignatureCabalFile !ModuleName | Suggests to add an ".hsig" signature file to the Cabal manifest. Triggered by: `DriverUnexpectedSignature`, if Cabal is being used. Example: See comment of `DriverUnexpectedSignature`. Test case(s): driver/T12955
SuggestSignatureInstantiations !ModuleName [InstantiationSuggestion] | Suggests to explicitly list the instantiations for the signatures in the GHC invocation command. Triggered by: `DriverUnexpectedSignature`, if Cabal is not being used. Example: See comment of `DriverUnexpectedSignature`. Test case(s): driver/T12955
SuggestUseSpaces | Suggests to use spaces instead of tabs. Triggered by: `PsWarnTab`. Examples: None Test Case(s): None
SuggestUseWhitespaceAfter !OperatorWhitespaceSymbol | Suggests adding a whitespace after the given symbol. Examples: None Test Case(s): parsershould_compileT18834a.hs
SuggestUseWhitespaceAround !String !OperatorWhitespaceOccurrence | Suggests adding a whitespace around the given operator symbol, as it might be repurposed as special syntax by a future language extension. The second parameter is how such operator occurred, if in a prefix, suffix or tight infix position. Triggered by: `PsWarnOperatorWhitespace`. Example: h a b = a+b -- not OK, no spaces around `+`. Test Case(s): parsershould_compileT18834b.hs
SuggestParentheses | Suggests wrapping an expression in parentheses Examples: None Test Case(s): None
SuggestIncreaseMaxPmCheckModels | Suggests to increase the -fmax-pmcheck-models limit for the pattern match checker. Triggered by: `DsMaxPmCheckModelsReached` Test case(s): pmcheckshould_compileTooManyDeltas pmcheckshould_compileTooManyDeltas pmcheckshould_compileT11822
SuggestAddTypeSignatures AvailableBindings | Suggests adding a type signature, typically to resolve ambiguity or help GHC inferring types.
SuggestBindToWildcard !(LHsExpr GhcTc) | Suggests to explicitly discard the result of a monadic action by binding the result to the '_' wilcard. Example: main = do _ <- getCurrentTime
SuggestAddInlineOrNoInlinePragma !Var !Activation |
SuggestAddPhaseToCompetingRule !RuleName |
SuggestAddToHSigExportList !Name !(Maybe Module) | Suggests adding an identifier to the export list of a signature.
SuggestIncreaseSimplifierIterations | Suggests increasing the limit for the number of iterations in the simplifier.
SuggestUseTypeFromDataKind (Maybe RdrName) | Suggests to explicitly import `Type` from the `Kind` module, because using "*" to mean `Type` relies on the StarIsType extension, which will become deprecated in the future. Triggered by: `PsWarnStarIsType` Example: None Test case(s): wcompat-warnings/WCompatWarningsOn.hs
SuggestQualifiedAfterModuleName | Suggests placing the `qualified` keyword after the module name. Triggered by: `PsWarnImportPreQualified` Example: None Test case(s): module/mod184.hs
SuggestThQuotationSyntax | Suggests using TemplateHaskell quotation syntax. Triggered by: `PsErrEmptyDoubleQuotes` only if TemplateHaskell is enabled. Example: None Test case(s): parsershould_failT13450TH.hs
SuggestRoles [Role] | Suggests alternative roles in case we found an illegal one. Triggered by: `PsErrIllegalRoleName` Example: None Test case(s): rolesshould_failRoles7.hs
SuggestQualifyStarOperator | Suggests qualifying the `*` operator in modules where StarIsType is enabled. Triggered by: `PsWarnStarBinder` Test case(s): warningsshould_compileStarBinder.hs
SuggestTypeSignatureRemoveQualifier | Suggests that for a type signature 'M.x :: ...' the qualifier should be omitted in order to be accepted by GHC. Triggered by: `PsErrInvalidTypeSignature` Test case(s): module/mod98
SuggestFixOrphanInst | Suggests to move an orphan instance (for a typeclass or a type or data family), or to newtype-wrap it. Triggered by: `TcRnOrphanInstance` Test cases(s): warningsshould_compileT9178 typecheckshould_compileT4912 indexed-typesshould_compileT22717_fam_orph
Fields isFamilyInstance :: Maybe FamFlavor Whether this is a family instance (of the given `FamFlavor`), or a class instance (`Nothing`).
SuggestAddStandaloneDerivation | Suggests to use a standalone deriving declaration when GHC can't derive a typeclass instance in a trivial way. Triggered by: `DerivBadErrConstructor` Test cases(s): typecheckshould_failtcfail086
SuggestAddStandaloneKindSignature Name | Suggests to add a standalone kind signature when GHC can't perform kind inference. Triggered by: `TcRnInvisBndrWithoutSig` Test case(s): typecheckshould_failT22560_fail_d
SuggestFillInWildcardConstraint | Suggests the user to fill in the wildcard constraint to disambiguate which constraint that is. Example: deriving instance _ => Eq (Foo f a) Triggered by: `DerivBadErrConstructor` Test cases(s): partial-sigsshould_failT13324_fail2
SuggestAppropriateTHTick NameSpace | Suggests to use the appropriate Template Haskell tick: a single tick for a term-level `NameSpace`, or a double tick for a type-level `NameSpace`. Triggered by: `TcRnIncorrectNameSpace`.
SuggestDumpSlices | Suggests enabling -ddump-splices to help debug an issue when a `Name` is not in scope or is used in multiple different namespaces (e.g. both as a data constructor and a type constructor). Concomitant with `NoExactName` or `SameName` errors, see e.g. "GHC.Rename.Env.lookupExactOcc_either". Test cases: T5971, T7241, T13937.
SuggestAddTick UntickedPromotedThing | Suggests adding a tick to refer to something which has been promoted to the type level, e.g. a data constructor. Test cases: T9778, T19984.
SuggestMoveToDeclarationSite | Something is split off from its corresponding declaration. For example, a datatype is given a role declaration in a different module. Test cases: T495, T8485, T2713, T5533.
Fields SigLike fixity declaration, role annotation, type signature, ... RdrName the `RdrName` for the declaration site
SuggestSimilarNames RdrName (NonEmpty SimilarName) | Suggest a similar name that the user might have meant, e.g. suggest `traverse` when the user has written `travrese`. Test case: mod73.
RemindFieldSelectorSuppressed | Remind the user that the field selector has been suppressed because of -XNoFieldSelectors. Test cases: NFSSuppressed, records-nofieldselectors.
Fields suppressed_selector :: RdrName suppressed_parents :: [Name]
ImportSuggestion OccName ImportSuggestion | Suggest importing from a module, removing a `hiding` clause, or explain to the user that we couldn't find a module with the given `ModuleName`. Test cases: mod28, mod36, mod87, mod114, ...
SuggestPlacePragmaInHeader | Found a pragma in the body of a module, suggest placing it in the header.
SuggestPatternMatchingSyntax | Suggest using pattern matching syntax for a non-bidirectional pattern synonym Test cases: patsynshould_failrecord-exquant typecheckshould_failT3176
SuggestSpecialiseVisibilityHints Name | Suggest tips for making a definition visible for the purpose of writing a SPECIALISE pragma for it in a different module. Test cases: none
SuggestRenameTypeVariable | Suggest renaming implicitly quantified type variable in case it captures a term's name.
SuggestExplicitBidiPatSyn Name (LPat GhcRn) [LIdP GhcRn] |
SuggestSafeHaskell | Suggest enabling one of the SafeHaskell modes Safe, Unsafe or Trustworthy.
SuggestRemoveRecordWildcard | Suggest removing a record wildcard from a pattern when it doesn't bind anything useful.
SuggestMoveNonCanonicalDefinition | Suggest moving a method implementation to a different instance to its superclass that defines the canonical version of the method.
Fields Name move the implementation from this method Name ... to this method String Documentation URL
SuggestIncreaseReductionDepth | Suggest to increase the solver maximum reduction depth
SuggestRemoveNonCanonicalDefinition | Suggest removing a method implementation when a superclass defines the canonical version of that method.
Fields Name method with non-canonical implementation Name possible other method to use as the RHS instead String Documentation URL
SuggestEtaReduceAbsDataTySyn TyCon | Suggest eta-reducing a type synonym used in the implementation of abstract data.
RemindRecordMissingField FastString Type Type | Remind the user that there is no field of a type and name in the record, constructors are in the usual order $x$, $r$, $a$
SuggestBindTyVarOnLhs RdrName | Suggest binding the type variable on the LHS of the type declaration
SuggestAnonymousWildcard | Suggest using an anonymous wildcard instead of a named wildcard
SuggestExplicitQuantification RdrName | Suggest explicitly quantifying a type variable instead of relying on implicit quantification
SuggestBindTyVarExplicitly Name | Suggest binding explicitly; e.g data T @k (a :: F k) = ....
SuggestDefaultDeclaration Class [Type] | Suggest a default declaration; e.g `default Cls (Ty1, Ty2)`
SuggestExplicitDerivingClauseStrategies | Suggest using explicit deriving strategies for a deriving clause. Triggered by: `TcRnNoDerivingClauseStrategySpecified`. See comment of `TcRnNoDerivingClauseStrategySpecified` for context.
Fields (Map AssumedDerivingStrategy [LHsSigType GhcRn]) Those deriving clauses that we assumed a particular strategy for.
SuggestExplicitStandaloneDerivingStrategy | Suggest using an explicit deriving strategy for a standalone deriving instance. Triggered by: `TcRnNoStandaloneDerivingStrategySpecified`. See comment of `TcRnNoStandaloneDerivingStrategySpecified` for context.
Fields AssumedDerivingStrategy The deriving strategy we assumed (LHsSigWcType GhcRn) The instance signature (e.g 'Show a => Show (T a)')
SuggestParenthesizePatternRHS | Suggest add parens to pattern `e -> p :: t`
SuggestSplittingIntoSeveralSpecialisePragmas | Suggest splitting up a SPECIALISE pragmas with multiple type ascriptions into several individual SPECIALISE pragmas.
SuggestDataKeyword | Suggest using the `data` keyword

#### Instances

Instances details

Outputable GhcHint # |
Instance details Defined in GHC.Types.Hint.Ppr Methods ppr :: GhcHint -> SDoc #

data AvailableBindings #

The bindings we have available in scope when suggesting an explicit type signature.

Constructors

NamedBindings (NonEmpty Name) |
UnnamedBinding | An unknown binding (i.e. too complicated to turn into a `Name`)

data LanguageExtensionHint #

Constructors

SuggestSingleExtension !SDoc !Extension | Suggest to enable the input extension. This is the hint that GHC emits if this is not a "known" fix, i.e. this is GHC giving its best guess on what extension might be necessary to make a certain program compile. For example, GHC might suggests to enable `BlockArguments` when the user simply formatted incorrectly the input program, so GHC here is trying to be as helpful as possible. If the input `SDoc` is not empty, it will contain some extra information about the why the extension is required, but it's totally irrelevant/redundant for IDEs and other tools.
SuggestAnyExtension !SDoc [Extension] | Suggest to enable the input extensions. The list is to be intended as disjunctive i.e. the user is suggested to enable any of the extensions listed. If the input `SDoc` is not empty, it will contain some extra information about the why the extensions are required, but it's totally irrelevant/redundant for IDEs and other tools.
SuggestExtensions !SDoc [Extension] | Suggest to enable the input extensions. The list is to be intended as conjunctive i.e. the user is suggested to enable all the extensions listed. If the input `SDoc` is not empty, it will contain some extra information about the why the extensions are required, but it's totally irrelevant/redundant for IDEs and other tools.
SuggestExtensionInOrderTo !SDoc !Extension | Suggest to enable the input extension in order to fix a certain problem. This is the suggestion that GHC emits when is more-or-less clear "what's going on". For example, if both `DeriveAnyClass` and `GeneralizedNewtypeDeriving` are turned on, the right thing to do is to enabled `DerivingStrategies`, so in contrast to `SuggestSingleExtension` GHC will be a bit more "imperative" (i.e. "Use X Y Z in order to ... "). If the input `SDoc` is not empty, it will contain some extra information about the why the extensions are required, but it's totally irrelevant/redundant for IDEs and other tools.

suggestExtension :: Extension -> GhcHint #

Suggests a single extension without extra user info.

suggestExtensionWithInfo :: SDoc -> Extension -> GhcHint #

Like `suggestExtension` but allows supplying extra info for the user.

suggestExtensions :: [Extension] -> GhcHint #

Suggests to enable every extension in the list.

suggestExtensionsWithInfo :: SDoc -> [Extension] -> GhcHint #

Like `suggestExtensions` but allows supplying extra info for the user.

suggestAnyExtension :: [Extension] -> GhcHint #

Suggests to enable any extension in the list.

suggestAnyExtensionWithInfo :: SDoc -> [Extension] -> GhcHint #

Like `suggestAnyExtension` but allows supplying extra info for the user.

useExtensionInOrderTo :: SDoc -> Extension -> GhcHint #

noHints :: [GhcHint] #

Helper function to use when no hints can be provided. Currently this function can be used to construct plain `DiagnosticMessage` and add hints to them, but once #18516 will be fully executed, the main usage of this function would be in the implementation of the `diagnosticHints` typeclass method, to report the fact that a particular `Diagnostic` has no hints.

# Rendering Messages

data SDoc #

Represents a pretty-printable document.

To display an `SDoc`, use `printSDoc`, `printSDocLn`, `bufLeftRenderSDoc`, or `renderWithContext`. Avoid calling `runSDoc` directly as it breaks the abstraction layer.

#### Instances

Instances details

IsString SDoc # |
Instance details Defined in GHC.Utils.Outputable Methods fromString :: String -> SDoc #
JsRender SDoc # |
Instance details Defined in GHC.JS.Ppr Methods (<+?>) :: SDoc -> SDoc -> SDoc # ($$$) :: SDoc -> SDoc -> SDoc # jcat :: [SDoc] -> SDoc # jnest :: SDoc -> SDoc # addSemi :: SDoc -> SDoc #
IsDoc SDoc # |
Instance details Defined in GHC.Utils.Outputable Associated Types
type Line SDoc |
Instance details Defined in GHC.Utils.Outputable type Line SDoc = SDoc
Methods line :: Line SDoc -> SDoc # ($$) :: SDoc -> SDoc -> SDoc # lines_ :: [Line SDoc] -> SDoc # vcat :: [SDoc] -> SDoc # dualDoc :: SDoc -> HDoc -> SDoc #
IsLine SDoc # |
Instance details Defined in GHC.Utils.Outputable Methods char :: Char -> SDoc # text :: String -> SDoc # ftext :: FastString -> SDoc # ztext :: FastZString -> SDoc # (<>) :: SDoc -> SDoc -> SDoc # (<+>) :: SDoc -> SDoc -> SDoc # sep :: [SDoc] -> SDoc # fsep :: [SDoc] -> SDoc # hcat :: [SDoc] -> SDoc # hsep :: [SDoc] -> SDoc # dualLine :: SDoc -> HLine -> SDoc #
IsOutput SDoc # |
Instance details Defined in GHC.Utils.Outputable Methods empty :: SDoc # docWithContext :: (SDocContext -> SDoc) -> SDoc # docWithStyle :: SDoc -> (PprStyle -> SDoc) -> SDoc #
Outputable SDoc # |
Instance details Defined in GHC.Utils.Outputable Methods ppr :: SDoc -> SDoc #
OutputableP env SDoc # |
Instance details Defined in GHC.Utils.Outputable Methods pdoc :: env -> SDoc -> SDoc #
type Line SDoc # |
Instance details Defined in GHC.Utils.Outputable type Line SDoc = SDoc

data DecoratedSDoc #

A `DecoratedSDoc` is isomorphic to a '[SDoc]' but it carries the invariant that the input '[SDoc]' needs to be rendered decorated into its final form, where the typical case would be adding bullets between each elements of the list. The type of decoration depends on the formatting function used, but in practice GHC uses the `formatBulleted`.

mkDecorated :: [SDoc] -> DecoratedSDoc #

Creates a new `DecoratedSDoc` out of a list of `SDoc`.

mkSimpleDecorated :: SDoc -> DecoratedSDoc #

Creates a new `DecoratedSDoc` out of a single `SDoc`

unionDecoratedSDoc :: DecoratedSDoc -> DecoratedSDoc -> DecoratedSDoc #

Joins two `DecoratedSDoc` together. The resulting `DecoratedSDoc` will have a number of entries which is the sum of the lengths of the input.

mapDecoratedSDoc :: (SDoc -> SDoc) -> DecoratedSDoc -> DecoratedSDoc #

Apply a transformation function to all elements of a `DecoratedSDoc`.

pprMessageBag :: Bag SDoc -> SDoc #

mkLocMessage #

Arguments

:: MessageClass | What kind of message?
-> SrcSpan | location
-> SDoc | message
-> SDoc |

mkLocMessageWarningGroups #

Arguments

:: Bool | Print warning groups (if applicable)?
-> MessageClass | What kind of message?
-> SrcSpan | location
-> SDoc | message
-> SDoc |

Make an error message with location info, specifying whether to show warning groups (if applicable).

getCaretDiagnostic :: MessageClass -> SrcSpan -> IO SDoc #

# Queries

isIntrinsicErrorMessage :: Diagnostic e => MsgEnvelope e -> Bool #

Returns `True` if this is, intrinsically, a failure. See Note [Intrinsic And Extrinsic Failures].

isExtrinsicErrorMessage :: MsgEnvelope e -> Bool #

Returns `True` if the envelope contains a message that will stop compilation: either an intrinsic error or a fatal (-Werror) warning

isWarningMessage :: Diagnostic e => MsgEnvelope e -> Bool #

getErrorMessages :: Diagnostic e => Messages e -> Bag (MsgEnvelope e) #

getWarningMessages :: Diagnostic e => Messages e -> Bag (MsgEnvelope e) #

partitionMessages :: Diagnostic e => Messages e -> (Messages e, Messages e) #

Partitions the `Messages` and returns a tuple which first element are the warnings, and the second the errors.

errorsFound :: Diagnostic e => Messages e -> Bool #

Are there any hard errors here? -Werror warnings are not detected. If you want to check for -Werror warnings, use `errorsOrFatalWarningsFound`.

errorsOrFatalWarningsFound :: Messages e -> Bool #

Are there any errors or -Werror warnings here?

# Diagnostic codes

data DiagnosticCode #

A diagnostic code is a namespaced numeric identifier unique to the given diagnostic (error or warning).

All diagnostic codes defined within GHC are given the GHC namespace.

See Note [Diagnostic codes] in GHC.Types.Error.Codes.

Constructors

DiagnosticCode |
Fields diagnosticCodeNameSpace :: String diagnostic code prefix (e.g. GHC) diagnosticCodeNumber :: Natural the actual diagnostic code

#### Instances

Instances details

Show DiagnosticCode # |
Instance details Defined in GHC.Types.Error Methods showsPrec :: Int -> DiagnosticCode -> ShowS # show :: DiagnosticCode -> String # showList :: [DiagnosticCode] -> ShowS #
ToJson DiagnosticCode # |
Instance details Defined in GHC.Types.Error Methods json :: DiagnosticCode -> JsonDoc #
Outputable DiagnosticCode # |
Instance details Defined in GHC.Types.Error Methods ppr :: DiagnosticCode -> SDoc #
Eq DiagnosticCode # |
Instance details Defined in GHC.Types.Error Methods (==) :: DiagnosticCode -> DiagnosticCode -> Bool # (/=) :: DiagnosticCode -> DiagnosticCode -> Bool #
Ord DiagnosticCode # |
Instance details Defined in GHC.Types.Error Methods compare :: DiagnosticCode -> DiagnosticCode -> Ordering # (<) :: DiagnosticCode -> DiagnosticCode -> Bool # (<=) :: DiagnosticCode -> DiagnosticCode -> Bool # (>) :: DiagnosticCode -> DiagnosticCode -> Bool # (>=) :: DiagnosticCode -> DiagnosticCode -> Bool # max :: DiagnosticCode -> DiagnosticCode -> DiagnosticCode # min :: DiagnosticCode -> DiagnosticCode -> DiagnosticCode #