HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Moduleghc-9.14.1GHC2021

GHC.Types.Error.Codes

Defines diagnostic codes for the diagnostics emitted by GHC.

A diagnostic code is a numeric unique identifier for a diagnostic. See Note [Diagnostic codes].

  • 2 types
  • 1 class
  • 2 values
  • Packageghc-9.14.1
  • Exports7
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceCodes.hs

General diagnostic code infrastructure

4 declarations
classclass DiagnosticCodeNameSpace namespace where
#

A constraint for a namespace which has its own diagnostic codes.

See Note [Diagnostic code namespaces].

Associated types

Instances1DiagnosticCodeNameSpace
typetype Outdated (a :: k) = a
#

Use this type synonym to mark a diagnostic code as outdated.

The presence of this type synonym is used by the codes test to determine which diagnostic codes to check for testsuite coverage.

valueconstructorCodes :: (Generic diag, GDiagnosticCodes namespace '[diag] (Rep diag)) => Map DiagnosticCode String
#

This function computes all diagnostic codes that occur inside a given type using generics and the DiagnosticCode type family.

For example, if T = MkT1 | MkT2, GhcDiagnosticCode "MkT1" = 123 and GhcDiagnosticCode "MkT2" = 456, then we will get > constructorCodes GHC T = fromList [ (DiagnosticCode GHC 123, "MkT1"), (DiagnosticCode GHC 456, "MkT2") ]

GHC diagnostic codes

3 declarations
familytype family GhcDiagnosticCode (c :: Symbol) :: Nat where
#

Type family computing the numeric diagnostic code for a given error message constructor.

Its injectivity annotation ensures uniqueness of error codes.

Never remove a return value from this type family! Outdated error messages must still be tracked here to ensure uniqueness of diagnostic codes across GHC versions.

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

Equations

familytype family ConRecursInto (con :: Symbol) :: Maybe Type where
#

Some constructors of diagnostic datatypes don't have corresponding error codes, because we recur inside them.

For example, we don't have an error code for the TcRnCannotDeriveInstance constructor of TcRnMessage, because we recur into the DeriveInstanceErrReason to obtain an error code.

This type family keeps track of such constructors.

Equations