ghc-lib-parser-9.12.2.20250421: 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 HasDefaultDiagnosticOpts (DiagnosticOpts a) => Diagnostic a where
  - type DiagnosticOpts a
  - diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc
  - diagnosticReason :: a -> DiagnosticReason
  - diagnosticHints :: a -> [GhcHint]
  - diagnosticCode :: a -> Maybe DiagnosticCode
- data UnknownDiagnostic opts where
  - UnknownDiagnostic :: forall a opts. (Diagnostic a, Typeable a) => (opts -> DiagnosticOpts a) -> a -> UnknownDiagnostic opts
- mkSimpleUnknownDiagnostic :: (Diagnostic a, Typeable a, DiagnosticOpts a ~ NoDiagnosticOpts) => a -> UnknownDiagnostic b
- mkUnknownDiagnostic :: (Typeable a, Diagnostic a) => a -> UnknownDiagnostic (DiagnosticOpts a)
- embedUnknownDiagnostic :: (Diagnostic a, Typeable a) => (opts -> DiagnosticOpts a) -> a -> UnknownDiagnostic opts
- 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
  }
- data DiagnosticHint = DiagnosticHint !SDoc
- 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 SDoc 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 TyCon [Type]
  - | SuggestExplicitDerivingClauseStrategies (Map AssumedDerivingStrategy [LHsSigType GhcRn])
  - | SuggestExplicitStandaloneDerivingStrategy AssumedDerivingStrategy (LHsSigWcType GhcRn)
  - | SuggestParenthesizePatternRHS
- 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 Source #

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 Source # |
Instance details Defined in GHC.Types.Error Methods fmap :: (a -> b) -> Messages a -> Messages b Source # (<$) :: a -> Messages b -> Messages a Source #
Foldable Messages Source # |

Instance details

Defined in GHC.Types.Error

Methods

fold :: Monoid m => Messages m -> m Source #

foldMap :: Monoid m => (a -> m) -> Messages a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Messages a -> m Source #

foldr :: (a -> b -> b) -> b -> Messages a -> b Source #

foldr' :: (a -> b -> b) -> b -> Messages a -> b Source #

foldl :: (b -> a -> b) -> b -> Messages a -> b Source #

foldl' :: (b -> a -> b) -> b -> Messages a -> b Source #

foldr1 :: (a -> a -> a) -> Messages a -> a Source #

foldl1 :: (a -> a -> a) -> Messages a -> a Source #

toList :: Messages a -> [a] Source #

null :: Messages a -> Bool Source #

length :: Messages a -> Int Source #

elem :: Eq a => a -> Messages a -> Bool Source #

maximum :: Ord a => Messages a -> a Source #

minimum :: Ord a => Messages a -> a Source #

sum :: Num a => Messages a -> a Source #

product :: Num a => Messages a -> a Source #

Traversable Messages Source # |
Instance details Defined in GHC.Types.Error Methods traverse :: Applicative f => (a -> f b) -> Messages a -> f (Messages b) Source # sequenceA :: Applicative f => Messages (f a) -> f (Messages a) Source # mapM :: Monad m => (a -> m b) -> Messages a -> m (Messages b) Source # sequence :: Monad m => Messages (m a) -> m (Messages a) Source #
Monoid (Messages e) Source # |
Instance details Defined in GHC.Types.Error Methods mempty :: Messages e Source # mappend :: Messages e -> Messages e -> Messages e Source # mconcat :: [Messages e] -> Messages e Source #
Semigroup (Messages e) Source # |
Instance details Defined in GHC.Types.Error Methods (<>) :: Messages e -> Messages e -> Messages e Source # sconcat :: NonEmpty (Messages e) -> Messages e Source # stimes :: Integral b => b -> Messages e -> Messages e Source #
Diagnostic e => ToJson (Messages e) Source # |
Instance details Defined in GHC.Types.Error Methods json :: Messages e -> JsonDoc Source #
Diagnostic e => Outputable (Messages e) Source # |
Instance details Defined in GHC.Types.Error Methods ppr :: Messages e -> SDoc Source #

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

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

emptyMessages :: Messages e Source #

isEmptyMessages :: Messages e -> Bool Source #

singleMessage :: MsgEnvelope e -> Messages e Source #

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

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

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

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

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

Joins many `Messages`s together

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

data MsgEnvelope e Source #

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 Source # |
Instance details Defined in GHC.Types.Error Methods fmap :: (a -> b) -> MsgEnvelope a -> MsgEnvelope b Source # (<$) :: a -> MsgEnvelope b -> MsgEnvelope a Source #
Foldable MsgEnvelope Source # |

Instance details

Defined in GHC.Types.Error

Methods

fold :: Monoid m => MsgEnvelope m -> m Source #

foldMap :: Monoid m => (a -> m) -> MsgEnvelope a -> m Source #

foldMap' :: Monoid m => (a -> m) -> MsgEnvelope a -> m Source #

foldr :: (a -> b -> b) -> b -> MsgEnvelope a -> b Source #

foldr' :: (a -> b -> b) -> b -> MsgEnvelope a -> b Source #

foldl :: (b -> a -> b) -> b -> MsgEnvelope a -> b Source #

foldl' :: (b -> a -> b) -> b -> MsgEnvelope a -> b Source #

foldr1 :: (a -> a -> a) -> MsgEnvelope a -> a Source #

foldl1 :: (a -> a -> a) -> MsgEnvelope a -> a Source #

toList :: MsgEnvelope a -> [a] Source #

null :: MsgEnvelope a -> Bool Source #

length :: MsgEnvelope a -> Int Source #

elem :: Eq a => a -> MsgEnvelope a -> Bool Source #

maximum :: Ord a => MsgEnvelope a -> a Source #

minimum :: Ord a => MsgEnvelope a -> a Source #

sum :: Num a => MsgEnvelope a -> a Source #

product :: Num a => MsgEnvelope a -> a Source #

Traversable MsgEnvelope Source # |
Instance details Defined in GHC.Types.Error Methods traverse :: Applicative f => (a -> f b) -> MsgEnvelope a -> f (MsgEnvelope b) Source # sequenceA :: Applicative f => MsgEnvelope (f a) -> f (MsgEnvelope a) Source # mapM :: Monad m => (a -> m b) -> MsgEnvelope a -> m (MsgEnvelope b) Source # sequence :: Monad m => MsgEnvelope (m a) -> m (MsgEnvelope a) Source #
Show (MsgEnvelope DiagnosticMessage) Source # |
Instance details Defined in GHC.Types.Error Methods showsPrec :: Int -> MsgEnvelope DiagnosticMessage -> ShowS Source # show :: MsgEnvelope DiagnosticMessage -> String Source # showList :: [MsgEnvelope DiagnosticMessage] -> ShowS Source #
Diagnostic e => ToJson (MsgEnvelope e) Source # |
Instance details Defined in GHC.Types.Error Methods json :: MsgEnvelope e -> JsonDoc Source #

# Classifying Messages

data MessageClass Source #

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 Source # |
Instance details Defined in GHC.Types.Error Methods json :: MessageClass -> JsonDoc Source #

data Severity Source #

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

class HasDefaultDiagnosticOpts (DiagnosticOpts a) => Diagnostic a where Source #

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 Source #

Type of configuration options for the diagnostic.

Methods

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

Extract the error message text from a `Diagnostic`.

diagnosticReason :: a -> DiagnosticReason Source #

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

diagnosticHints :: a -> [GhcHint] Source #

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

diagnosticCode :: a -> Maybe DiagnosticCode Source #

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 Source # |

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

Methods

diagnosticMessage :: DiagnosticOpts DriverMessage -> DriverMessage -> DecoratedSDoc Source #

diagnosticReason :: DriverMessage -> DiagnosticReason Source #

diagnosticHints :: DriverMessage -> [GhcHint] Source #

diagnosticCode :: DriverMessage -> Maybe DiagnosticCode Source #

Diagnostic GhcMessage Source # |

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

Methods

diagnosticMessage :: DiagnosticOpts GhcMessage -> GhcMessage -> DecoratedSDoc Source #

diagnosticReason :: GhcMessage -> DiagnosticReason Source #

diagnosticHints :: GhcMessage -> [GhcHint] Source #

diagnosticCode :: GhcMessage -> Maybe DiagnosticCode Source #

Diagnostic DsMessage Source # |

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

Methods

diagnosticMessage :: DiagnosticOpts DsMessage -> DsMessage -> DecoratedSDoc Source #

diagnosticReason :: DsMessage -> DiagnosticReason Source #

diagnosticHints :: DsMessage -> [GhcHint] Source #

diagnosticCode :: DsMessage -> Maybe DiagnosticCode Source #

Diagnostic IfaceMessage Source # |

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

Methods

diagnosticMessage :: DiagnosticOpts IfaceMessage -> IfaceMessage -> DecoratedSDoc Source #

diagnosticReason :: IfaceMessage -> DiagnosticReason Source #

diagnosticHints :: IfaceMessage -> [GhcHint] Source #

diagnosticCode :: IfaceMessage -> Maybe DiagnosticCode Source #

Diagnostic PsMessage Source # |

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

Methods

diagnosticMessage :: DiagnosticOpts PsMessage -> PsMessage -> DecoratedSDoc Source #

diagnosticReason :: PsMessage -> DiagnosticReason Source #

diagnosticHints :: PsMessage -> [GhcHint] Source #

diagnosticCode :: PsMessage -> Maybe DiagnosticCode Source #

Diagnostic TcRnMessage Source # |

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

Methods

diagnosticMessage :: DiagnosticOpts TcRnMessage -> TcRnMessage -> DecoratedSDoc Source #

diagnosticReason :: TcRnMessage -> DiagnosticReason Source #

diagnosticHints :: TcRnMessage -> [GhcHint] Source #

diagnosticCode :: TcRnMessage -> Maybe DiagnosticCode Source #

Diagnostic DiagnosticMessage Source # |

Instance details

Defined in GHC.Types.Error

Associated Types

type DiagnosticOpts DiagnosticMessage |
Instance details Defined in GHC.Types.Error type DiagnosticOpts DiagnosticMessage = NoDiagnosticOpts

Methods

diagnosticMessage :: DiagnosticOpts DiagnosticMessage -> DiagnosticMessage -> DecoratedSDoc Source #

diagnosticReason :: DiagnosticMessage -> DiagnosticReason Source #

diagnosticHints :: DiagnosticMessage -> [GhcHint] Source #

diagnosticCode :: DiagnosticMessage -> Maybe DiagnosticCode Source #

HasDefaultDiagnosticOpts opts => Diagnostic (UnknownDiagnostic opts) Source # |

Instance details

Defined in GHC.Types.Error

Associated Types

type DiagnosticOpts (UnknownDiagnostic opts) |
Instance details Defined in GHC.Types.Error type DiagnosticOpts (UnknownDiagnostic opts) = opts

Methods

diagnosticMessage :: DiagnosticOpts (UnknownDiagnostic opts) -> UnknownDiagnostic opts -> DecoratedSDoc Source #

diagnosticReason :: UnknownDiagnostic opts -> DiagnosticReason Source #

diagnosticHints :: UnknownDiagnostic opts -> [GhcHint] Source #

diagnosticCode :: UnknownDiagnostic opts -> Maybe DiagnosticCode Source #

data UnknownDiagnostic opts where Source #

An existential wrapper around an unknown diagnostic.

Constructors

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

#### Instances

Instances details

HasDefaultDiagnosticOpts opts => Diagnostic (UnknownDiagnostic opts) Source # |

Instance details

Defined in GHC.Types.Error

Associated Types

type DiagnosticOpts (UnknownDiagnostic opts) |
Instance details Defined in GHC.Types.Error type DiagnosticOpts (UnknownDiagnostic opts) = opts

Methods

diagnosticMessage :: DiagnosticOpts (UnknownDiagnostic opts) -> UnknownDiagnostic opts -> DecoratedSDoc Source #

diagnosticReason :: UnknownDiagnostic opts -> DiagnosticReason Source #

diagnosticHints :: UnknownDiagnostic opts -> [GhcHint] Source #

diagnosticCode :: UnknownDiagnostic opts -> Maybe DiagnosticCode Source #

type DiagnosticOpts (UnknownDiagnostic opts) Source # |
Instance details Defined in GHC.Types.Error type DiagnosticOpts (UnknownDiagnostic opts) = opts

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

Make a "simple" unknown diagnostic which doesn't have any configuration options.

mkUnknownDiagnostic :: (Typeable a, Diagnostic a) => a -> UnknownDiagnostic (DiagnosticOpts a) Source #

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

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

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

data DiagnosticMessage Source #

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 Source # |

Instance details

Defined in GHC.Types.Error

Associated Types

type DiagnosticOpts DiagnosticMessage |
Instance details Defined in GHC.Types.Error type DiagnosticOpts DiagnosticMessage = NoDiagnosticOpts

Methods

diagnosticMessage :: DiagnosticOpts DiagnosticMessage -> DiagnosticMessage -> DecoratedSDoc Source #

diagnosticReason :: DiagnosticMessage -> DiagnosticReason Source #

diagnosticHints :: DiagnosticMessage -> [GhcHint] Source #

diagnosticCode :: DiagnosticMessage -> Maybe DiagnosticCode Source #

Show (MsgEnvelope DiagnosticMessage) Source # |
Instance details Defined in GHC.Types.Error Methods showsPrec :: Int -> MsgEnvelope DiagnosticMessage -> ShowS Source # show :: MsgEnvelope DiagnosticMessage -> String Source # showList :: [MsgEnvelope DiagnosticMessage] -> ShowS Source #
type DiagnosticOpts DiagnosticMessage Source # |
Instance details Defined in GHC.Types.Error type DiagnosticOpts DiagnosticMessage = NoDiagnosticOpts

data DiagnosticReason Source #

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

newtype ResolvedDiagnosticReason Source #

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 Source # |
Instance details Defined in GHC.Types.Error Methods ppr :: ResolvedDiagnosticReason -> SDoc Source #

data DiagnosticHint Source #

A generic `Hint` message, to be used with `DiagnosticMessage`.

Constructors

DiagnosticHint !SDoc |

#### Instances

Instances details

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

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

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

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

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

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

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

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

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

class HasDefaultDiagnosticOpts opts where Source #

Methods

defaultOpts :: opts Source #

#### Instances

Instances details

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

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

data NoDiagnosticOpts Source #

Constructors

NoDiagnosticOpts |

#### Instances

Instances details

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

# Hints and refactoring actions

data GhcHint Source #

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

- SDoc

  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 TyCon [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`

#### Instances

Instances details

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

data AvailableBindings Source #

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 Source #

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 Source #

Suggests a single extension without extra user info.

suggestExtensionWithInfo :: SDoc -> Extension -> GhcHint Source #

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

suggestExtensions :: [Extension] -> GhcHint Source #

Suggests to enable every extension in the list.

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

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

suggestAnyExtension :: [Extension] -> GhcHint Source #

Suggests to enable any extension in the list.

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

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

useExtensionInOrderTo :: SDoc -> Extension -> GhcHint Source #

noHints :: [GhcHint] Source #

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 Source #

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 Source # |
Instance details Defined in GHC.Utils.Outputable Methods fromString :: String -> SDoc Source #
JsRender SDoc Source # |
Instance details Defined in GHC.JS.Ppr Methods (<+?>) :: SDoc -> SDoc -> SDoc Source # ($$$) :: SDoc -> SDoc -> SDoc Source # jcat :: [SDoc] -> SDoc Source # jnest :: SDoc -> SDoc Source # addSemi :: SDoc -> SDoc Source #
IsDoc SDoc Source # |

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 Source #

($$) :: SDoc -> SDoc -> SDoc Source #

lines_ :: [Line SDoc] -> SDoc Source #

vcat :: [SDoc] -> SDoc Source #

dualDoc :: SDoc -> HDoc -> SDoc Source #

IsLine SDoc Source # |

Instance details

Defined in GHC.Utils.Outputable

Methods

char :: Char -> SDoc Source #

text :: String -> SDoc Source #

ftext :: FastString -> SDoc Source #

ztext :: FastZString -> SDoc Source #

(<>) :: SDoc -> SDoc -> SDoc Source #

(<+>) :: SDoc -> SDoc -> SDoc Source #

sep :: [SDoc] -> SDoc Source #

fsep :: [SDoc] -> SDoc Source #

hcat :: [SDoc] -> SDoc Source #

hsep :: [SDoc] -> SDoc Source #

dualLine :: SDoc -> HLine -> SDoc Source #

IsOutput SDoc Source # |
Instance details Defined in GHC.Utils.Outputable Methods empty :: SDoc Source # docWithContext :: (SDocContext -> SDoc) -> SDoc Source # docWithStyle :: SDoc -> (PprStyle -> SDoc) -> SDoc Source #
Outputable SDoc Source # |
Instance details Defined in GHC.Utils.Outputable Methods ppr :: SDoc -> SDoc Source #
OutputableP env SDoc Source # |
Instance details Defined in GHC.Utils.Outputable Methods pdoc :: env -> SDoc -> SDoc Source #
type Line SDoc Source # |
Instance details Defined in GHC.Utils.Outputable type Line SDoc = SDoc

data DecoratedSDoc Source #

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 Source #

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

mkSimpleDecorated :: SDoc -> DecoratedSDoc Source #

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

unionDecoratedSDoc :: DecoratedSDoc -> DecoratedSDoc -> DecoratedSDoc Source #

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 Source #

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

pprMessageBag :: Bag SDoc -> SDoc Source #

mkLocMessage Source #

Arguments

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

mkLocMessageWarningGroups Source #

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 Source #

# Queries

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

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

isExtrinsicErrorMessage :: MsgEnvelope e -> Bool Source #

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 Source #

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

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

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

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

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

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 Source #

Are there any errors or -Werror warnings here?

# Diagnostic codes

data DiagnosticCode Source #

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 Source # |
Instance details Defined in GHC.Types.Error Methods showsPrec :: Int -> DiagnosticCode -> ShowS Source # show :: DiagnosticCode -> String Source # showList :: [DiagnosticCode] -> ShowS Source #
ToJson DiagnosticCode Source # |
Instance details Defined in GHC.Types.Error Methods json :: DiagnosticCode -> JsonDoc Source #
Outputable DiagnosticCode Source # |
Instance details Defined in GHC.Types.Error Methods ppr :: DiagnosticCode -> SDoc Source #
Eq DiagnosticCode Source # |
Instance details Defined in GHC.Types.Error Methods (==) :: DiagnosticCode -> DiagnosticCode -> Bool Source # (/=) :: DiagnosticCode -> DiagnosticCode -> Bool Source #
Ord DiagnosticCode Source # |

Instance details

Defined in GHC.Types.Error

Methods

compare :: DiagnosticCode -> DiagnosticCode -> Ordering Source #

(<) :: DiagnosticCode -> DiagnosticCode -> Bool Source #

(<=) :: DiagnosticCode -> DiagnosticCode -> Bool Source #

(>) :: DiagnosticCode -> DiagnosticCode -> Bool Source #

(>=) :: DiagnosticCode -> DiagnosticCode -> Bool Source #

max :: DiagnosticCode -> DiagnosticCode -> DiagnosticCode Source #

min :: DiagnosticCode -> DiagnosticCode -> DiagnosticCode Source #