never executed always true always false
    1 {-# LANGUAGE GADTs #-}
    2 module GHC.Tc.Errors.Types (
    3   -- * Main types
    4     TcRnMessage(..)
    5   , TcRnMessageDetailed(..)
    6   , ErrInfo(..)
    7   , FixedRuntimeRepProvenance(..)
    8   , pprFixedRuntimeRepProvenance
    9   , ShadowedNameProvenance(..)
   10   , RecordFieldPart(..)
   11   , InjectivityErrReason(..)
   12   , HasKinds(..)
   13   , hasKinds
   14   , SuggestUndecidableInstances(..)
   15   , suggestUndecidableInstances
   16   , NotClosedReason(..)
   17   , SuggestPartialTypeSignatures(..)
   18   , suggestPartialTypeSignatures
   19   , DeriveInstanceErrReason(..)
   20   , UsingGeneralizedNewtypeDeriving(..)
   21   , usingGeneralizedNewtypeDeriving
   22   , DeriveAnyClassEnabled(..)
   23   , deriveAnyClassEnabled
   24   , DeriveInstanceBadConstructor(..)
   25   , HasWildcard(..)
   26   , hasWildcard
   27   , DeriveGenericsErrReason(..)
   28   , HasAssociatedDataFamInsts(..)
   29   , hasAssociatedDataFamInsts
   30   , AssociatedTyLastVarInKind(..)
   31   , associatedTyLastVarInKind
   32   , AssociatedTyNotParamOverLastTyVar(..)
   33   , associatedTyNotParamOverLastTyVar
   34   ) where
   35 
   36 import GHC.Prelude
   37 
   38 import GHC.Hs
   39 import {-# SOURCE #-} GHC.Tc.Types (TcIdSigInfo)
   40 import GHC.Tc.Types.Constraint
   41 import GHC.Tc.Types.Rank (Rank)
   42 import GHC.Tc.Utils.TcType (TcType)
   43 import GHC.Types.Error
   44 import GHC.Types.FieldLabel (FieldLabelString)
   45 import GHC.Types.Name (Name, OccName)
   46 import GHC.Types.Name.Reader
   47 import GHC.Types.SrcLoc
   48 import GHC.Types.TyThing (TyThing)
   49 import GHC.Types.Var (Id)
   50 import GHC.Types.Var.Set (TyVarSet, VarSet)
   51 import GHC.Unit.Types (Module)
   52 import GHC.Utils.Outputable
   53 import GHC.Core.Class (Class)
   54 import GHC.Core.Coercion.Axiom (CoAxBranch)
   55 import GHC.Core.ConLike (ConLike)
   56 import GHC.Core.DataCon (DataCon)
   57 import GHC.Core.FamInstEnv (FamInst)
   58 import GHC.Core.InstEnv (ClsInst)
   59 import GHC.Core.TyCon (TyCon, TyConFlavour)
   60 import GHC.Core.Type (Kind, Type, ThetaType, PredType)
   61 import GHC.Unit.State (UnitState)
   62 import GHC.Unit.Module.Name (ModuleName)
   63 import GHC.Types.Basic
   64 import qualified GHC.LanguageExtensions as LangExt
   65 
   66 import qualified Data.List.NonEmpty as NE
   67 import           Data.Typeable hiding (TyCon)
   68 
   69 {-
   70 Note [Migrating TcM Messages]
   71 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   72 
   73 As part of #18516, we are slowly migrating the diagnostic messages emitted
   74 and reported in the TcM from SDoc to TcRnMessage. Historically, GHC emitted
   75 some diagnostics in 3 pieces, i.e. there were lots of error-reporting functions
   76 that accepted 3 SDocs an input: one for the important part of the message,
   77 one for the context and one for any supplementary information. Consider the following:
   78 
   79     • Couldn't match expected type ‘Int’ with actual type ‘Char’
   80     • In the expression: x4
   81       In a stmt of a 'do' block: return (x2, x4)
   82       In the expression:
   83 
   84 Under the hood, the reporting functions in Tc.Utils.Monad were emitting "Couldn't match"
   85 as the important part, "In the expression" as the context and "In a stmt..In the expression"
   86 as the supplementary, with the context and supplementary usually smashed together so that
   87 the final message would be composed only by two SDoc (which would then be bulletted like in
   88 the example).
   89 
   90 In order for us to smooth out the migration to the new diagnostic infrastructure, we
   91 introduce the 'ErrInfo' and 'TcRnMessageDetailed' types, which serve exactly the purpose
   92 of bridging the two worlds together without breaking the external API or the existing
   93 format of messages reported by GHC.
   94 
   95 Using 'ErrInfo' and 'TcRnMessageDetailed' also allows us to move away from the SDoc-ridden
   96 diagnostic API inside Tc.Utils.Monad, enabling further refactorings.
   97 
   98 In the future, once the conversion will be complete and we will successfully eradicate
   99 any use of SDoc in the diagnostic reporting of GHC, we can surely revisit the usage and
  100 existence of these two types, which for now remain a "necessary evil".
  101 
  102 -}
  103 
  104 -- The majority of TcRn messages come with extra context about the error,
  105 -- and this newtype captures it. See Note [Migrating TcM messages].
  106 data ErrInfo = ErrInfo {
  107     errInfoContext :: !SDoc
  108     -- ^ Extra context associated to the error.
  109   , errInfoSupplementary :: !SDoc
  110     -- ^ Extra supplementary info associated to the error.
  111   }
  112 
  113 
  114 -- | 'TcRnMessageDetailed' is an \"internal\" type (used only inside
  115 -- 'GHC.Tc.Utils.Monad' that wraps a 'TcRnMessage' while also providing
  116 -- any extra info needed to correctly pretty-print this diagnostic later on.
  117 data TcRnMessageDetailed
  118   = TcRnMessageDetailed !ErrInfo
  119                         -- ^ Extra info associated with the message
  120                         !TcRnMessage
  121 
  122 -- | An error which might arise during typechecking/renaming.
  123 data TcRnMessage where
  124   {-| Simply wraps a generic 'Diagnostic' message @a@. It can be used by plugins
  125       to provide custom diagnostic messages originated during typechecking/renaming.
  126   -}
  127   TcRnUnknownMessage :: (Diagnostic a, Typeable a) => a -> TcRnMessage
  128 
  129   {-| TcRnMessageWithInfo is a constructor which is used when extra information is needed
  130       to be provided in order to qualify a diagnostic and where it was originated (and why).
  131       It carries an extra 'UnitState' which can be used to pretty-print some names
  132       and it wraps a 'TcRnMessageDetailed', which includes any extra context associated
  133       with this diagnostic.
  134   -}
  135   TcRnMessageWithInfo :: !UnitState
  136                       -- ^ The 'UnitState' will allow us to pretty-print
  137                       -- some diagnostics with more detail.
  138                       -> !TcRnMessageDetailed
  139                       -> TcRnMessage
  140 
  141   {-| A type which was expected to have a fixed runtime representation
  142       does not have a fixed runtime representation.
  143 
  144       Example:
  145 
  146         data D (a :: TYPE r) = MkD a
  147 
  148       Test cases: T11724, T18534,
  149                   RepPolyPatSynArg, RepPolyPatSynUnliftedNewtype,
  150                   RepPolyPatSynRes, T20423
  151   -}
  152   TcRnTypeDoesNotHaveFixedRuntimeRep :: !Type
  153                                      -> !FixedRuntimeRepProvenance
  154                                      -> !ErrInfo -- Extra info accumulated in the TcM monad
  155                                      -> TcRnMessage
  156 
  157   {-| TcRnImplicitLift is a warning (controlled with -Wimplicit-lift) that occurs when
  158       a Template Haskell quote implicitly uses 'lift'.
  159 
  160      Example:
  161        warning1 :: Lift t => t -> Q Exp
  162        warning1 x = [| x |]
  163 
  164      Test cases: th/T17804
  165   -}
  166   TcRnImplicitLift :: Outputable var => var -> !ErrInfo -> TcRnMessage
  167   {-| TcRnUnusedPatternBinds is a warning (controlled with -Wunused-pattern-binds)
  168       that occurs if a pattern binding binds no variables at all, unless it is a
  169       lone wild-card pattern, or a banged pattern.
  170 
  171      Example:
  172         Just _ = rhs3    -- Warning: unused pattern binding
  173         (_, _) = rhs4    -- Warning: unused pattern binding
  174         _  = rhs3        -- No warning: lone wild-card pattern
  175         !() = rhs4       -- No warning: banged pattern; behaves like seq
  176 
  177      Test cases: rename/{T13646,T17c,T17e,T7085}
  178   -}
  179   TcRnUnusedPatternBinds :: HsBind GhcRn -> TcRnMessage
  180   {-| TcRnDodgyImports is a warning (controlled with -Wdodgy-imports) that occurs when
  181       a datatype 'T' is imported with all constructors, i.e. 'T(..)', but has been exported
  182       abstractly, i.e. 'T'.
  183 
  184      Test cases: rename/should_compile/T7167
  185   -}
  186   TcRnDodgyImports :: RdrName -> TcRnMessage
  187   {-| TcRnDodgyExports is a warning (controlled by -Wdodgy-exports) that occurs when a datatype
  188       'T' is exported with all constructors, i.e. 'T(..)', but is it just a type synonym or a
  189       type/data family.
  190 
  191      Example:
  192        module Foo (
  193            T(..)  -- Warning: T is a type synonym
  194          , A(..)  -- Warning: A is a type family
  195          , C(..)  -- Warning: C is a data family
  196          ) where
  197 
  198        type T = Int
  199        type family A :: * -> *
  200        data family C :: * -> *
  201 
  202      Test cases: warnings/should_compile/DodgyExports01
  203   -}
  204   TcRnDodgyExports :: Name -> TcRnMessage
  205   {-| TcRnMissingImportList is a warning (controlled by -Wmissing-import-lists) that occurs when
  206       an import declaration does not explicitly list all the names brought into scope.
  207 
  208      Test cases: rename/should_compile/T4489
  209   -}
  210   TcRnMissingImportList :: IE GhcPs -> TcRnMessage
  211   {-| When a module marked trustworthy or unsafe (using -XTrustworthy or -XUnsafe) is compiled
  212       with a plugin, the TcRnUnsafeDueToPlugin warning (controlled by -Wunsafe) is used as the
  213       reason the module was inferred to be unsafe. This warning is not raised if the
  214       -fplugin-trustworthy flag is passed.
  215 
  216      Test cases: plugins/T19926
  217   -}
  218   TcRnUnsafeDueToPlugin :: TcRnMessage
  219   {-| TcRnModMissingRealSrcSpan is an error that occurrs when compiling a module that lacks
  220       an associated 'RealSrcSpan'.
  221 
  222      Test cases: None
  223   -}
  224   TcRnModMissingRealSrcSpan :: Module -> TcRnMessage
  225   {-| TcRnIdNotExportedFromModuleSig is an error pertaining to backpack that occurs
  226       when an identifier required by a signature is not exported by the module
  227       or signature that is being used as a substitution for that signature.
  228 
  229       Example(s): None
  230 
  231      Test cases: backpack/should_fail/bkpfail36
  232   -}
  233   TcRnIdNotExportedFromModuleSig :: Name -> Module -> TcRnMessage
  234   {-| TcRnIdNotExportedFromLocalSig is an error pertaining to backpack that
  235       occurs when an identifier which is necessary for implementing a module
  236       signature is not exported from that signature.
  237 
  238       Example(s): None
  239 
  240      Test cases: backpack/should_fail/bkpfail30
  241                  backpack/should_fail/bkpfail31
  242                  backpack/should_fail/bkpfail34
  243   -}
  244   TcRnIdNotExportedFromLocalSig :: Name -> TcRnMessage
  245 
  246   {-| TcRnShadowedName is a warning (controlled by -Wname-shadowing) that occurs whenever
  247       an inner-scope value has the same name as an outer-scope value, i.e. the inner
  248       value shadows the outer one. This can catch typographical errors that turn into
  249       hard-to-find bugs. The warning is suppressed for names beginning with an underscore.
  250 
  251       Examples(s):
  252         f = ... let f = id in ... f ...  -- NOT OK, 'f' is shadowed
  253         f x = do { _ignore <- this; _ignore <- that; return (the other) } -- suppressed via underscore
  254 
  255      Test cases: typecheck/should_compile/T10971a
  256                  rename/should_compile/rn039
  257                  rename/should_compile/rn064
  258                  rename/should_compile/T1972
  259                  rename/should_fail/T2723
  260                  rename/should_compile/T3262
  261                  driver/werror
  262   -}
  263   TcRnShadowedName :: OccName -> ShadowedNameProvenance -> TcRnMessage
  264 
  265   {-| TcRnDuplicateWarningDecls is an error that occurs whenever
  266       a warning is declared twice.
  267 
  268       Examples(s):
  269         None.
  270 
  271      Test cases:
  272         None.
  273   -}
  274   TcRnDuplicateWarningDecls :: !(LocatedN RdrName) -> !RdrName -> TcRnMessage
  275 
  276   {-| TcRnDuplicateWarningDecls is an error that occurs whenever
  277       the constraint solver in the simplifier hits the iterations' limit.
  278 
  279       Examples(s):
  280         None.
  281 
  282      Test cases:
  283         None.
  284   -}
  285   TcRnSimplifierTooManyIterations :: Cts
  286                                   -> !IntWithInf
  287                                   -- ^ The limit.
  288                                   -> WantedConstraints
  289                                   -> TcRnMessage
  290 
  291   {-| TcRnIllegalPatSynDecl is an error that occurs whenever
  292       there is an illegal pattern synonym declaration.
  293 
  294       Examples(s):
  295 
  296       varWithLocalPatSyn x = case x of
  297           P -> ()
  298         where
  299           pattern P = ()   -- not valid, it can't be local, it must be defined at top-level.
  300 
  301      Test cases: patsyn/should_fail/local
  302   -}
  303   TcRnIllegalPatSynDecl :: !(LIdP GhcPs) -> TcRnMessage
  304 
  305   {-| TcRnLinearPatSyn is an error that occurs whenever a pattern
  306       synonym signature uses a field that is not unrestricted.
  307 
  308       Example(s): None
  309 
  310      Test cases: linear/should_fail/LinearPatSyn2
  311   -}
  312   TcRnLinearPatSyn :: !Type -> TcRnMessage
  313 
  314   {-| TcRnEmptyRecordUpdate is an error that occurs whenever
  315       a record is updated without specifying any field.
  316 
  317       Examples(s):
  318 
  319       $(deriveJSON defaultOptions{} ''Bad) -- not ok, no fields selected for update of defaultOptions
  320 
  321      Test cases: th/T12788
  322   -}
  323   TcRnEmptyRecordUpdate :: TcRnMessage
  324 
  325   {-| TcRnIllegalFieldPunning is an error that occurs whenever
  326       field punning is used without the 'NamedFieldPuns' extension enabled.
  327 
  328       Examples(s):
  329 
  330       data Foo = Foo { a :: Int }
  331 
  332       foo :: Foo -> Int
  333       foo Foo{a} = a  -- Not ok, punning used without extension.
  334 
  335      Test cases: parser/should_fail/RecordDotSyntaxFail12
  336   -}
  337   TcRnIllegalFieldPunning :: !(Located RdrName) -> TcRnMessage
  338 
  339   {-| TcRnIllegalWildcardsInRecord is an error that occurs whenever
  340       wildcards (..) are used in a record without the relevant
  341       extension being enabled.
  342 
  343       Examples(s):
  344 
  345       data Foo = Foo { a :: Int }
  346 
  347       foo :: Foo -> Int
  348       foo Foo{..} = a  -- Not ok, wildcards used without extension.
  349 
  350      Test cases: parser/should_fail/RecordWildCardsFail
  351   -}
  352   TcRnIllegalWildcardsInRecord :: !RecordFieldPart -> TcRnMessage
  353 
  354   {-| TcRnDuplicateFieldName is an error that occurs whenever
  355       there are duplicate field names in a record.
  356 
  357       Examples(s): None.
  358 
  359      Test cases: None.
  360   -}
  361   TcRnDuplicateFieldName :: !RecordFieldPart -> NE.NonEmpty RdrName -> TcRnMessage
  362 
  363   {-| TcRnIllegalViewPattern is an error that occurs whenever
  364       the ViewPatterns syntax is used but the ViewPatterns language extension
  365       is not enabled.
  366 
  367       Examples(s):
  368       data Foo = Foo { a :: Int }
  369 
  370       foo :: Foo -> Int
  371       foo (a -> l) = l -- not OK, the 'ViewPattern' extension is not enabled.
  372 
  373      Test cases: parser/should_fail/ViewPatternsFail
  374   -}
  375   TcRnIllegalViewPattern :: !(Pat GhcPs) -> TcRnMessage
  376 
  377   {-| TcRnCharLiteralOutOfRange is an error that occurs whenever
  378       a character is out of range.
  379 
  380       Examples(s): None
  381 
  382      Test cases: None
  383   -}
  384   TcRnCharLiteralOutOfRange :: !Char -> TcRnMessage
  385 
  386   {-| TcRnIllegalWildcardsInConstructor is an error that occurs whenever
  387       the record wildcards '..' are used inside a constructor without labeled fields.
  388 
  389       Examples(s): None
  390 
  391      Test cases: None
  392   -}
  393   TcRnIllegalWildcardsInConstructor :: !Name -> TcRnMessage
  394 
  395   {-| TcRnIgnoringAnnotations is a warning that occurs when the source code
  396       contains annotation pragmas but the platform in use does not support an
  397       external interpreter such as GHCi and therefore the annotations are ignored.
  398 
  399       Example(s): None
  400 
  401      Test cases: None
  402   -}
  403   TcRnIgnoringAnnotations :: [LAnnDecl GhcRn] -> TcRnMessage
  404 
  405   {-| TcRnAnnotationInSafeHaskell is an error that occurs if annotation pragmas
  406       are used in conjunction with Safe Haskell.
  407 
  408       Example(s): None
  409 
  410      Test cases: annotations/should_fail/T10826
  411   -}
  412   TcRnAnnotationInSafeHaskell :: TcRnMessage
  413 
  414   {-| TcRnInvalidTypeApplication is an error that occurs when a visible type application
  415       is used with an expression that does not accept "specified" type arguments.
  416 
  417       Example(s):
  418       foo :: forall {a}. a -> a
  419       foo x = x
  420       bar :: ()
  421       bar = let x = foo @Int 42
  422             in ()
  423 
  424      Test cases: overloadedrecflds/should_fail/overloadedlabelsfail03
  425                  typecheck/should_fail/ExplicitSpecificity1
  426                  typecheck/should_fail/ExplicitSpecificity10
  427                  typecheck/should_fail/ExplicitSpecificity2
  428                  typecheck/should_fail/T17173
  429                  typecheck/should_fail/VtaFail
  430   -}
  431   TcRnInvalidTypeApplication :: Type -> LHsWcType GhcRn -> TcRnMessage
  432 
  433   {-| TcRnTagToEnumMissingValArg is an error that occurs when the 'tagToEnum#'
  434       function is not applied to a single value argument.
  435 
  436       Example(s):
  437       tagToEnum# 1 2
  438 
  439      Test cases: None
  440   -}
  441   TcRnTagToEnumMissingValArg :: TcRnMessage
  442 
  443   {-| TcRnTagToEnumUnspecifiedResTy is an error that occurs when the 'tagToEnum#'
  444       function is not given a concrete result type.
  445 
  446       Example(s):
  447       foo :: forall a. a
  448       foo = tagToEnum# 0#
  449 
  450      Test cases: typecheck/should_fail/tcfail164
  451   -}
  452   TcRnTagToEnumUnspecifiedResTy :: Type -> TcRnMessage
  453 
  454   {-| TcRnTagToEnumResTyNotAnEnum is an error that occurs when the 'tagToEnum#'
  455       function is given a result type that is not an enumeration type.
  456 
  457       Example(s):
  458       foo :: Int -- not an enumeration TyCon
  459       foo = tagToEnum# 0#
  460 
  461      Test cases: typecheck/should_fail/tcfail164
  462   -}
  463   TcRnTagToEnumResTyNotAnEnum :: Type -> TcRnMessage
  464 
  465   {-| TcRnArrowIfThenElsePredDependsOnResultTy is an error that occurs when the
  466       predicate type of an ifThenElse expression in arrow notation depends on
  467       the type of the result.
  468 
  469       Example(s): None
  470 
  471      Test cases: None
  472   -}
  473   TcRnArrowIfThenElsePredDependsOnResultTy :: TcRnMessage
  474 
  475   {-| TcRnArrowCommandExpected is an error that occurs if a non-arrow command
  476       is used where an arrow command is expected.
  477 
  478       Example(s): None
  479 
  480      Test cases: None
  481   -}
  482   TcRnArrowCommandExpected :: HsCmd GhcRn -> TcRnMessage
  483 
  484   {-| TcRnIllegalHsBootFileDecl is an error that occurs when an hs-boot file
  485       contains declarations that are not allowed, such as bindings.
  486 
  487       Example(s): None
  488 
  489      Test cases: None
  490   -}
  491   TcRnIllegalHsBootFileDecl :: TcRnMessage
  492 
  493   {-| TcRnRecursivePatternSynonym is an error that occurs when a pattern synonym
  494       is defined in terms of itself, either directly or indirectly.
  495 
  496       Example(s):
  497       pattern A = B
  498       pattern B = A
  499 
  500      Test cases: patsyn/should_fail/T16900
  501   -}
  502   TcRnRecursivePatternSynonym :: LHsBinds GhcRn -> TcRnMessage
  503 
  504   {-| TcRnPartialTypeSigTyVarMismatch is an error that occurs when a partial type signature
  505       attempts to unify two different types.
  506 
  507       Example(s):
  508       f :: a -> b -> _
  509       f x y = [x, y]
  510 
  511      Test cases: partial-sigs/should_fail/T14449
  512   -}
  513   TcRnPartialTypeSigTyVarMismatch
  514     :: Name -- ^ first type variable
  515     -> Name -- ^ second type variable
  516     -> Name -- ^ function name
  517     -> LHsSigWcType GhcRn -> TcRnMessage
  518 
  519   {-| TcRnPartialTypeSigBadQuantifier is an error that occurs when a type variable
  520       being quantified over in the partial type signature of a function gets unified
  521       with a type that is free in that function's context.
  522 
  523       Example(s):
  524       foo :: Num a => a -> a
  525       foo xxx = g xxx
  526         where
  527           g :: forall b. Num b => _ -> b
  528           g y = xxx + y
  529 
  530      Test cases: partial-sig/should_fail/T14479
  531   -}
  532   TcRnPartialTypeSigBadQuantifier
  533     :: Name -- ^ type variable being quantified
  534     -> Name -- ^ function name
  535     -> LHsSigWcType GhcRn -> TcRnMessage
  536 
  537   {-| TcRnPolymorphicBinderMissingSig is a warning controlled by -Wmissing-local-signatures
  538       that occurs when a local polymorphic binding lacks a type signature.
  539 
  540       Example(s):
  541       id a = a
  542 
  543      Test cases: warnings/should_compile/T12574
  544   -}
  545   TcRnPolymorphicBinderMissingSig :: Name -> Type -> TcRnMessage
  546 
  547   {-| TcRnOverloadedSig is an error that occurs when a binding group conflicts
  548       with the monomorphism restriction.
  549 
  550       Example(s):
  551       data T a = T a
  552       mono = ... where
  553         x :: Applicative f => f a
  554         T x = ...
  555 
  556      Test cases: typecheck/should_compile/T11339
  557   -}
  558   TcRnOverloadedSig :: TcIdSigInfo -> TcRnMessage
  559 
  560   {-| TcRnTupleConstraintInst is an error that occurs whenever an instance
  561       for a tuple constraint is specified.
  562 
  563       Examples(s):
  564         class C m a
  565         class D m a
  566         f :: (forall a. Eq a => (C m a, D m a)) => m a
  567         f = undefined
  568 
  569       Test cases: quantified-constraints/T15334
  570   -}
  571   TcRnTupleConstraintInst :: !Class -> TcRnMessage
  572 
  573   {-| TcRnAbstractClassInst is an error that occurs whenever an instance
  574       of an abstract class is specified.
  575 
  576       Examples(s):
  577         -- A.hs-boot
  578         module A where
  579         class C a
  580 
  581         -- B.hs
  582         module B where
  583         import {-# SOURCE #-} A
  584         instance C Int where
  585 
  586         -- A.hs
  587         module A where
  588         import B
  589         class C a where
  590           f :: a
  591 
  592         -- Main.hs
  593         import A
  594         main = print (f :: Int)
  595 
  596       Test cases: typecheck/should_fail/T13068
  597   -}
  598   TcRnAbstractClassInst :: !Class -> TcRnMessage
  599 
  600   {-| TcRnNoClassInstHead is an error that occurs whenever an instance
  601       head is not headed by a class.
  602 
  603       Examples(s):
  604         instance c
  605 
  606       Test cases: typecheck/rename/T5513
  607                   typecheck/rename/T16385
  608   -}
  609   TcRnNoClassInstHead :: !Type -> TcRnMessage
  610 
  611   {-| TcRnUserTypeError is an error that occurs due to a user's custom type error,
  612       which can be triggered by adding a `TypeError` constraint in a type signature
  613       or typeclass instance.
  614 
  615       Examples(s):
  616         f :: TypeError (Text "This is a type error")
  617         f = undefined
  618 
  619       Test cases: typecheck/should_fail/CustomTypeErrors02
  620                   typecheck/should_fail/CustomTypeErrors03
  621   -}
  622   TcRnUserTypeError :: !Type -> TcRnMessage
  623 
  624   {-| TcRnConstraintInKind is an error that occurs whenever a constraint is specified
  625       in a kind.
  626 
  627       Examples(s):
  628         data Q :: Eq a => Type where {}
  629 
  630       Test cases: dependent/should_fail/T13895
  631                   polykinds/T16263
  632                   saks/should_fail/saks_fail004
  633                   typecheck/should_fail/T16059a
  634                   typecheck/should_fail/T18714
  635   -}
  636   TcRnConstraintInKind :: !Type -> TcRnMessage
  637 
  638   {-| TcRnUnboxedTupleTypeFuncArg is an error that occurs whenever an unboxed tuple type
  639       is specified as a function argument.
  640 
  641       Examples(s):
  642         -- T15073.hs
  643         import T15073a
  644         newtype Foo a = MkFoo a
  645           deriving P
  646 
  647         -- T15073a.hs
  648         class P a where
  649           p :: a -> (# a #)
  650 
  651       Test cases: deriving/should_fail/T15073.hs
  652                   deriving/should_fail/T15073a.hs
  653                   typecheck/should_fail/T16059d
  654   -}
  655   TcRnUnboxedTupleTypeFuncArg :: !Type -> TcRnMessage
  656 
  657   {-| TcRnLinearFuncInKind is an error that occurs whenever a linear function is
  658       specified in a kind.
  659 
  660       Examples(s):
  661         data A :: * %1 -> *
  662 
  663       Test cases: linear/should_fail/LinearKind
  664                   linear/should_fail/LinearKind2
  665                   linear/should_fail/LinearKind3
  666   -}
  667   TcRnLinearFuncInKind :: !Type -> TcRnMessage
  668 
  669   {-| TcRnForAllEscapeError is an error that occurs whenever a quantified type's kind
  670       mentions quantified type variable.
  671 
  672       Examples(s):
  673         type T :: TYPE (BoxedRep l)
  674         data T = MkT
  675 
  676       Test cases: unlifted-datatypes/should_fail/UnlDataNullaryPoly
  677   -}
  678   TcRnForAllEscapeError :: !Type -> !Kind -> TcRnMessage
  679 
  680   {-| TcRnVDQInTermType is an error that occurs whenever a visible dependent quantification
  681       is specified in the type of a term.
  682 
  683       Examples(s):
  684         a = (undefined :: forall k -> k -> Type) @Int
  685 
  686       Test cases: dependent/should_fail/T15859
  687                   dependent/should_fail/T16326_Fail1
  688                   dependent/should_fail/T16326_Fail2
  689                   dependent/should_fail/T16326_Fail3
  690                   dependent/should_fail/T16326_Fail4
  691                   dependent/should_fail/T16326_Fail5
  692                   dependent/should_fail/T16326_Fail6
  693                   dependent/should_fail/T16326_Fail7
  694                   dependent/should_fail/T16326_Fail8
  695                   dependent/should_fail/T16326_Fail9
  696                   dependent/should_fail/T16326_Fail10
  697                   dependent/should_fail/T16326_Fail11
  698                   dependent/should_fail/T16326_Fail12
  699                   dependent/should_fail/T17687
  700                   dependent/should_fail/T18271
  701   -}
  702   TcRnVDQInTermType :: !Type -> TcRnMessage
  703 
  704   {-| TcRnIllegalEqualConstraints is an error that occurs whenever an illegal equational
  705       constraint is specified.
  706 
  707       Examples(s):
  708         blah :: (forall a. a b ~ a c) => b -> c
  709         blah = undefined
  710 
  711       Test cases: typecheck/should_fail/T17563
  712   -}
  713   TcRnIllegalEqualConstraints :: !Type -> TcRnMessage
  714 
  715   {-| TcRnBadQuantPredHead is an error that occurs whenever a quantified predicate
  716       lacks a class or type variable head.
  717 
  718       Examples(s):
  719         class (forall a. A t a => A t [a]) => B t where
  720           type A t a :: Constraint
  721 
  722       Test cases: quantified-constraints/T16474
  723   -}
  724   TcRnBadQuantPredHead :: !Type -> TcRnMessage
  725 
  726   {-| TcRnIllegalTupleConstraint is an error that occurs whenever an illegal tuple
  727       constraint is specified.
  728 
  729       Examples(s):
  730         g :: ((Show a, Num a), Eq a) => a -> a
  731         g = undefined
  732 
  733       Test cases: typecheck/should_fail/tcfail209a
  734   -}
  735   TcRnIllegalTupleConstraint :: !Type -> TcRnMessage
  736 
  737   {-| TcRnNonTypeVarArgInConstraint is an error that occurs whenever a non type-variable
  738       argument is specified in a constraint.
  739 
  740       Examples(s):
  741         data T
  742         instance Eq Int => Eq T
  743 
  744       Test cases: ghci/scripts/T13202
  745                   ghci/scripts/T13202a
  746                   polykinds/T12055a
  747                   typecheck/should_fail/T10351
  748                   typecheck/should_fail/T19187
  749                   typecheck/should_fail/T6022
  750                   typecheck/should_fail/T8883
  751   -}
  752   TcRnNonTypeVarArgInConstraint :: !Type -> TcRnMessage
  753 
  754   {-| TcRnIllegalImplicitParam is an error that occurs whenever an illegal implicit
  755       parameter is specified.
  756 
  757       Examples(s):
  758         type Bla = ?x::Int
  759         data T = T
  760         instance Bla => Eq T
  761 
  762       Test cases: polykinds/T11466
  763                   typecheck/should_fail/T8912
  764                   typecheck/should_fail/tcfail041
  765                   typecheck/should_fail/tcfail211
  766                   typecheck/should_fail/tcrun045
  767   -}
  768   TcRnIllegalImplicitParam :: !Type -> TcRnMessage
  769 
  770   {-| TcRnIllegalConstraintSynonymOfKind is an error that occurs whenever an illegal constraint
  771       synonym of kind is specified.
  772 
  773       Examples(s):
  774         type Showish = Show
  775         f :: (Showish a) => a -> a
  776         f = undefined
  777 
  778       Test cases: typecheck/should_fail/tcfail209
  779   -}
  780   TcRnIllegalConstraintSynonymOfKind :: !Type -> TcRnMessage
  781 
  782   {-| TcRnIllegalClassInst is an error that occurs whenever a class instance is specified
  783       for a non-class.
  784 
  785       Examples(s):
  786         type C1 a = (Show (a -> Bool))
  787         instance C1 Int where
  788 
  789       Test cases: polykinds/T13267
  790   -}
  791   TcRnIllegalClassInst :: !TyConFlavour -> TcRnMessage
  792 
  793   {-| TcRnOversaturatedVisibleKindArg is an error that occurs whenever an illegal oversaturated
  794       visible kind argument is specified.
  795 
  796       Examples(s):
  797         type family
  798           F2 :: forall (a :: Type). Type where
  799           F2 @a = Maybe a
  800 
  801       Test cases: typecheck/should_fail/T15793
  802                   typecheck/should_fail/T16255
  803   -}
  804   TcRnOversaturatedVisibleKindArg :: !Type -> TcRnMessage
  805 
  806   {-| TcRnBadAssociatedType is an error that occurs whenever a class doesn't have an
  807       associated type.
  808 
  809       Examples(s):
  810         $(do d <- instanceD (cxt []) (conT ''Eq `appT` conT ''Foo)
  811                     [tySynInstD $ tySynEqn Nothing (conT ''Rep `appT` conT ''Foo) (conT ''Maybe)]
  812              return [d])
  813         ======>
  814         instance Eq Foo where
  815           type Rep Foo = Maybe
  816 
  817       Test cases: th/T12387a
  818   -}
  819   TcRnBadAssociatedType :: {-Class-} !Name -> {-TyCon-} !Name -> TcRnMessage
  820 
  821   {-| TcRnForAllRankErr is an error that occurs whenever an illegal ranked type
  822       is specified.
  823 
  824       Examples(s):
  825         foo :: (a,b) -> (a~b => t) -> (a,b)
  826         foo p x = p
  827 
  828       Test cases:
  829         - ghci/should_run/T15806
  830         - indexed-types/should_fail/SimpleFail15
  831         - typecheck/should_fail/T11355
  832         - typecheck/should_fail/T12083a
  833         - typecheck/should_fail/T12083b
  834         - typecheck/should_fail/T16059c
  835         - typecheck/should_fail/T16059e
  836         - typecheck/should_fail/T17213
  837         - typecheck/should_fail/T18939_Fail
  838         - typecheck/should_fail/T2538
  839         - typecheck/should_fail/T5957
  840         - typecheck/should_fail/T7019
  841         - typecheck/should_fail/T7019a
  842         - typecheck/should_fail/T7809
  843         - typecheck/should_fail/T9196
  844         - typecheck/should_fail/tcfail127
  845         - typecheck/should_fail/tcfail184
  846         - typecheck/should_fail/tcfail196
  847         - typecheck/should_fail/tcfail197
  848   -}
  849   TcRnForAllRankErr :: !Rank -> !Type -> TcRnMessage
  850 
  851   {-| TcRnMonomorphicBindings is a warning (controlled by -Wmonomorphism-restriction)
  852       that arise when the monomorphism restriction applies to the given bindings.
  853 
  854       Examples(s):
  855         {-# OPTIONS_GHC -Wmonomorphism-restriction #-}
  856 
  857         bar = 10
  858 
  859         foo :: Int
  860         foo = bar
  861 
  862         main :: IO ()
  863         main = print foo
  864 
  865       The example above emits the warning (for 'bar'), because without monomorphism
  866       restriction the inferred type for 'bar' is 'bar :: Num p => p'. This warning tells us
  867       that /if/ we were to enable '-XMonomorphismRestriction' we would make 'bar'
  868       less polymorphic, as its type would become 'bar :: Int', so GHC warns us about that.
  869 
  870       Test cases: typecheck/should_compile/T13785
  871   -}
  872   TcRnMonomorphicBindings :: [Name] -> TcRnMessage
  873 
  874   {-| TcRnOrphanInstance is a warning (controlled by -Wwarn-orphans)
  875       that arises when a typeclass instance is an \"orphan\", i.e. if it appears
  876       in a module in which neither the class nor the type being instanced are
  877       declared in the same module.
  878 
  879       Examples(s): None
  880 
  881       Test cases: warnings/should_compile/T9178
  882                   typecheck/should_compile/T4912
  883   -}
  884   TcRnOrphanInstance :: ClsInst -> TcRnMessage
  885 
  886   {-| TcRnFunDepConflict is an error that occurs when there are functional dependencies
  887       conflicts between instance declarations.
  888 
  889       Examples(s): None
  890 
  891       Test cases: typecheck/should_fail/T2307
  892                   typecheck/should_fail/tcfail096
  893                   typecheck/should_fail/tcfail202
  894   -}
  895   TcRnFunDepConflict :: !UnitState -> NE.NonEmpty ClsInst -> TcRnMessage
  896 
  897   {-| TcRnDupInstanceDecls is an error that occurs when there are duplicate instance
  898       declarations.
  899 
  900       Examples(s):
  901         class Foo a where
  902           foo :: a -> Int
  903 
  904         instance Foo Int where
  905           foo = id
  906 
  907         instance Foo Int where
  908           foo = const 42
  909 
  910       Test cases: cabal/T12733/T12733
  911                   typecheck/should_fail/tcfail035
  912                   typecheck/should_fail/tcfail023
  913                   backpack/should_fail/bkpfail18
  914                   typecheck/should_fail/TcNullaryTCFail
  915                   typecheck/should_fail/tcfail036
  916                   typecheck/should_fail/tcfail073
  917                   module/mod51
  918                   module/mod52
  919                   module/mod44
  920   -}
  921   TcRnDupInstanceDecls :: !UnitState -> NE.NonEmpty ClsInst -> TcRnMessage
  922 
  923   {-| TcRnConflictingFamInstDecls is an error that occurs when there are conflicting
  924       family instance declarations.
  925 
  926       Examples(s): None.
  927 
  928       Test cases: indexed-types/should_fail/ExplicitForAllFams4b
  929                   indexed-types/should_fail/NoGood
  930                   indexed-types/should_fail/Over
  931                   indexed-types/should_fail/OverDirectThisMod
  932                   indexed-types/should_fail/OverIndirectThisMod
  933                   indexed-types/should_fail/SimpleFail11a
  934                   indexed-types/should_fail/SimpleFail11b
  935                   indexed-types/should_fail/SimpleFail11c
  936                   indexed-types/should_fail/SimpleFail11d
  937                   indexed-types/should_fail/SimpleFail2a
  938                   indexed-types/should_fail/SimpleFail2b
  939                   indexed-types/should_fail/T13092/T13092
  940                   indexed-types/should_fail/T13092c/T13092c
  941                   indexed-types/should_fail/T14179
  942                   indexed-types/should_fail/T2334A
  943                   indexed-types/should_fail/T2677
  944                   indexed-types/should_fail/T3330b
  945                   indexed-types/should_fail/T4246
  946                   indexed-types/should_fail/T7102a
  947                   indexed-types/should_fail/T9371
  948                   polykinds/T7524
  949                   typecheck/should_fail/UnliftedNewtypesOverlap
  950   -}
  951   TcRnConflictingFamInstDecls :: NE.NonEmpty FamInst -> TcRnMessage
  952 
  953   TcRnFamInstNotInjective :: InjectivityErrReason -> TyCon -> NE.NonEmpty CoAxBranch -> TcRnMessage
  954 
  955   {-| TcRnBangOnUnliftedType is a warning (controlled by -Wredundant-strictness-flags) that
  956       occurs when a strictness annotation is applied to an unlifted type.
  957 
  958       Example(s):
  959       data T = MkT !Int# -- Strictness flag has no effect on unlifted types
  960 
  961      Test cases: typecheck/should_compile/T20187a
  962                  typecheck/should_compile/T20187b
  963   -}
  964   TcRnBangOnUnliftedType :: !Type -> TcRnMessage
  965 
  966   {-| TcRnMultipleDefaultDeclarations is an error that occurs when a module has
  967       more than one default declaration.
  968 
  969       Example:
  970       default (Integer, Int)
  971       default (Double, Float) -- 2nd default declaration not allowed
  972 
  973      Text cases: module/mod58
  974   -}
  975   TcRnMultipleDefaultDeclarations :: [LDefaultDecl GhcRn] -> TcRnMessage
  976 
  977   {-| TcRnBadDefaultType is an error that occurs when a type used in a default
  978       declaration does not have an instance for any of the applicable classes.
  979 
  980       Example(s):
  981       data Foo
  982       default (Foo)
  983 
  984      Test cases: typecheck/should_fail/T11974b
  985   -}
  986   TcRnBadDefaultType :: Type -> [Class] -> TcRnMessage
  987 
  988   {-| TcRnPatSynBundledWithNonDataCon is an error that occurs when a module's
  989       export list bundles a pattern synonym with a type that is not a proper
  990       `data` or `newtype` construction.
  991 
  992       Example(s):
  993       module Foo (MyClass(.., P)) where
  994       pattern P = Nothing
  995       class MyClass a where
  996         foo :: a -> Int
  997 
  998      Test cases: patsyn/should_fail/export-class
  999   -}
 1000   TcRnPatSynBundledWithNonDataCon :: TcRnMessage
 1001 
 1002   {-| TcRnPatSynBundledWithWrongType is an error that occurs when the export list
 1003       of a module has a pattern synonym bundled with a type that does not match
 1004       the type of the pattern synonym.
 1005 
 1006       Example(s):
 1007       module Foo (R(P,x)) where
 1008       data Q = Q Int
 1009       data R = R
 1010       pattern P{x} = Q x
 1011 
 1012      Text cases: patsyn/should_fail/export-ps-rec-sel
 1013                  patsyn/should_fail/export-type-synonym
 1014                  patsyn/should_fail/export-type
 1015   -}
 1016   TcRnPatSynBundledWithWrongType :: Type -> Type -> TcRnMessage
 1017 
 1018   {-| TcRnDupeModuleExport is a warning controlled by @-Wduplicate-exports@ that
 1019       occurs when a module appears more than once in an export list.
 1020 
 1021       Example(s):
 1022       module Foo (module Bar, module Bar)
 1023       import Bar
 1024 
 1025      Text cases: None
 1026   -}
 1027   TcRnDupeModuleExport :: ModuleName -> TcRnMessage
 1028 
 1029   {-| TcRnExportedModNotImported is an error that occurs when an export list
 1030       contains a module that is not imported.
 1031 
 1032       Example(s): None
 1033 
 1034      Text cases: module/mod135
 1035                  module/mod8
 1036                  rename/should_fail/rnfail028
 1037                  backpack/should_fail/bkpfail48
 1038   -}
 1039   TcRnExportedModNotImported :: ModuleName -> TcRnMessage
 1040 
 1041   {-| TcRnNullExportedModule is a warning controlled by -Wdodgy-exports that occurs
 1042       when an export list contains a module that has no exports.
 1043 
 1044       Example(s):
 1045       module Foo (module Bar) where
 1046       import Bar ()
 1047 
 1048      Test cases: None
 1049   -}
 1050   TcRnNullExportedModule :: ModuleName -> TcRnMessage
 1051 
 1052   {-| TcRnMissingExportList is a warning controlled by -Wmissing-export-lists that
 1053       occurs when a module does not have an explicit export list.
 1054 
 1055       Example(s): None
 1056 
 1057      Test cases: typecheck/should_fail/MissingExportList03
 1058   -}
 1059   TcRnMissingExportList :: ModuleName -> TcRnMessage
 1060 
 1061   {-| TcRnExportHiddenComponents is an error that occurs when an export contains
 1062       constructor or class methods that are not visible.
 1063 
 1064       Example(s): None
 1065 
 1066      Test cases: None
 1067   -}
 1068   TcRnExportHiddenComponents :: IE GhcPs -> TcRnMessage
 1069 
 1070   {-| TcRnDuplicateExport is a warning (controlled by -Wduplicate-exports) that occurs
 1071       when an identifier appears in an export list more than once.
 1072 
 1073       Example(s): None
 1074 
 1075      Test cases: module/MultiExport
 1076                  module/mod128
 1077                  module/mod14
 1078                  module/mod5
 1079                  overloadedrecflds/should_fail/DuplicateExports
 1080                  patsyn/should_compile/T11959
 1081   -}
 1082   TcRnDuplicateExport :: GreName -> IE GhcPs -> IE GhcPs -> TcRnMessage
 1083 
 1084   {-| TcRnExportedParentChildMismatch is an error that occurs when an export is
 1085       bundled with a parent that it does not belong to
 1086 
 1087       Example(s):
 1088       module Foo (T(a)) where
 1089       data T
 1090       a = True
 1091 
 1092      Test cases: module/T11970
 1093                  module/T11970B
 1094                  module/mod17
 1095                  module/mod3
 1096                  overloadedrecflds/should_fail/NoParent
 1097   -}
 1098   TcRnExportedParentChildMismatch :: Name -> TyThing -> GreName -> [Name] -> TcRnMessage
 1099 
 1100   {-| TcRnConflictingExports is an error that occurs when different identifiers that
 1101       have the same name are being exported by a module.
 1102 
 1103       Example(s):
 1104       module Foo (Bar.f, module Baz) where
 1105       import qualified Bar (f)
 1106       import Baz (f)
 1107 
 1108      Test cases: module/mod131
 1109                  module/mod142
 1110                  module/mod143
 1111                  module/mod144
 1112                  module/mod145
 1113                  module/mod146
 1114                  module/mod150
 1115                  module/mod155
 1116                  overloadedrecflds/should_fail/T14953
 1117                  overloadedrecflds/should_fail/overloadedrecfldsfail10
 1118                  rename/should_fail/rnfail029
 1119                  rename/should_fail/rnfail040
 1120                  typecheck/should_fail/T16453E2
 1121                  typecheck/should_fail/tcfail025
 1122                  typecheck/should_fail/tcfail026
 1123   -}
 1124   TcRnConflictingExports
 1125     :: OccName -- ^ Occurrence name shared by both exports
 1126     -> GreName -- ^ Name of first export
 1127     -> GlobalRdrElt -- ^ Provenance for definition site of first export
 1128     -> IE GhcPs -- ^ Export decl of first export
 1129     -> GreName -- ^ Name of second export
 1130     -> GlobalRdrElt -- ^ Provenance for definition site of second export
 1131     -> IE GhcPs -- ^ Export decl of second export
 1132     -> TcRnMessage
 1133 
 1134   {-| TcRnAmbiguousField is a warning controlled by -Wambiguous-fields occurring
 1135       when a record update's type cannot be precisely determined. This will not
 1136       be supported by -XDuplicateRecordFields in future releases.
 1137 
 1138       Example(s):
 1139       data Person  = MkPerson  { personId :: Int, name :: String }
 1140       data Address = MkAddress { personId :: Int, address :: String }
 1141       bad1 x = x { personId = 4 } :: Person -- ambiguous
 1142       bad2 (x :: Person) = x { personId = 4 } -- ambiguous
 1143       good x = (x :: Person) { personId = 4 } -- not ambiguous
 1144 
 1145      Test cases: overloadedrecflds/should_fail/overloadedrecfldsfail06
 1146   -}
 1147   TcRnAmbiguousField
 1148     :: HsExpr GhcRn -- ^ Field update
 1149     -> TyCon -- ^ Record type
 1150     -> TcRnMessage
 1151 
 1152   {-| TcRnMissingFields is a warning controlled by -Wmissing-fields occurring
 1153       when the intialisation of a record is missing one or more (lazy) fields.
 1154 
 1155       Example(s):
 1156       data Rec = Rec { a :: Int, b :: String, c :: Bool }
 1157       x = Rec { a = 1, b = "two" } -- missing field 'c'
 1158 
 1159      Test cases: deSugar/should_compile/T13870
 1160                  deSugar/should_compile/ds041
 1161                  patsyn/should_compile/T11283
 1162                  rename/should_compile/T5334
 1163                  rename/should_compile/T12229
 1164                  rename/should_compile/T5892a
 1165                  warnings/should_fail/WerrorFail2
 1166   -}
 1167   TcRnMissingFields :: ConLike -> [(FieldLabelString, TcType)] -> TcRnMessage
 1168 
 1169   {-| TcRnFieldUpdateInvalidType is an error occurring when an updated field's
 1170       type mentions something that is outside the universally quantified variables
 1171       of the data constructor, such as an existentially quantified type.
 1172 
 1173       Example(s):
 1174       data X = forall a. MkX { f :: a }
 1175       x = (MkX ()) { f = False }
 1176 
 1177       Test cases: patsyn/should_fail/records-exquant
 1178                   typecheck/should_fail/T3323
 1179   -}
 1180   TcRnFieldUpdateInvalidType :: [(FieldLabelString,TcType)] -> TcRnMessage
 1181 
 1182   {-| TcRnNoConstructorHasAllFields is an error that occurs when a record update
 1183       has fields that no single constructor encompasses.
 1184 
 1185       Example(s):
 1186       data Foo = A { x :: Bool }
 1187                | B { y :: Int }
 1188       foo = (A False) { x = True, y = 5 }
 1189 
 1190      Test cases: overloadedrecflds/should_fail/overloadedrecfldsfail08
 1191                  patsyn/should_fail/mixed-pat-syn-record-sels
 1192                  typecheck/should_fail/T7989
 1193   -}
 1194   TcRnNoConstructorHasAllFields :: [FieldLabelString] -> TcRnMessage
 1195 
 1196   {- TcRnMixedSelectors is an error for when a mixture of pattern synonym and
 1197       record selectors are used in the same record update block.
 1198 
 1199       Example(s):
 1200       data Rec = Rec { foo :: Int, bar :: String }
 1201       pattern Pat { f1, f2 } = Rec { foo = f1, bar = f2 }
 1202       illegal :: Rec -> Rec
 1203       illegal r = r { f1 = 1, bar = "two" }
 1204 
 1205      Test cases: patsyn/should_fail/records-mixing-fields
 1206   -}
 1207   TcRnMixedSelectors
 1208     :: Name -- ^ Record
 1209     -> [Id] -- ^ Record selectors
 1210     -> Name -- ^ Pattern synonym
 1211     -> [Id] -- ^ Pattern selectors
 1212     -> TcRnMessage
 1213 
 1214   {- TcRnMissingStrictFields is an error occurring when a record field marked
 1215      as strict is omitted when constructing said record.
 1216 
 1217      Example(s):
 1218      data R = R { strictField :: !Bool, nonStrict :: Int }
 1219      x = R { nonStrict = 1 }
 1220 
 1221     Test cases: typecheck/should_fail/T18869
 1222                 typecheck/should_fail/tcfail085
 1223                 typecheck/should_fail/tcfail112
 1224   -}
 1225   TcRnMissingStrictFields :: ConLike -> [(FieldLabelString, TcType)] -> TcRnMessage
 1226 
 1227   {- TcRnNoPossibleParentForFields is an error thrown when the fields used in a
 1228      record update block do not all belong to any one type.
 1229 
 1230      Example(s):
 1231      data R1 = R1 { x :: Int, y :: Int }
 1232      data R2 = R2 { y :: Int, z :: Int }
 1233      update r = r { x = 1, y = 2, z = 3 }
 1234 
 1235     Test cases: overloadedrecflds/should_fail/overloadedrecfldsfail01
 1236                 overloadedrecflds/should_fail/overloadedrecfldsfail14
 1237   -}
 1238   TcRnNoPossibleParentForFields :: [LHsRecUpdField GhcRn] -> TcRnMessage
 1239 
 1240   {- TcRnBadOverloadedRecordUpdate is an error for a record update that cannot
 1241      be pinned down to any one constructor and thus must be given a type signature.
 1242 
 1243      Example(s):
 1244      data R1 = R1 { x :: Int }
 1245      data R2 = R2 { x :: Int }
 1246      update r = r { x = 1 } -- needs a type signature
 1247 
 1248     Test cases: overloadedrecflds/should_fail/overloadedrecfldsfail01
 1249   -}
 1250   TcRnBadOverloadedRecordUpdate :: [LHsRecUpdField GhcRn] -> TcRnMessage
 1251 
 1252   {- TcRnStaticFormNotClosed is an error pertaining to terms that are marked static
 1253      using the -XStaticPointers extension but which are not closed terms.
 1254 
 1255      Example(s):
 1256      f x = static x
 1257 
 1258     Test cases: rename/should_fail/RnStaticPointersFail01
 1259                 rename/should_fail/RnStaticPointersFail03
 1260   -}
 1261   TcRnStaticFormNotClosed :: Name -> NotClosedReason -> TcRnMessage
 1262   {-| TcRnSpecialClassInst is an error that occurs when a user
 1263       attempts to define an instance for a built-in typeclass such as
 1264       'Coercible', 'Typeable', or 'KnownNat', outside of a signature file.
 1265 
 1266      Test cases: deriving/should_fail/T9687
 1267                  deriving/should_fail/T14916
 1268                  polykinds/T8132
 1269                  typecheck/should_fail/TcCoercibleFail2
 1270                  typecheck/should_fail/T12837
 1271                  typecheck/should_fail/T14390
 1272 
 1273   -}
 1274   TcRnSpecialClassInst :: !Class
 1275                        -> !Bool -- ^ Whether the error is due to Safe Haskell being enabled
 1276                        -> TcRnMessage
 1277 
 1278   {-| TcRnUselessTypeable is a warning (controlled by -Wderiving-typeable) that
 1279       occurs when trying to derive an instance of the 'Typeable' class. Deriving
 1280       'Typeable' is no longer necessary (hence the \"useless\") as all types
 1281       automatically derive 'Typeable' in modern GHC versions.
 1282 
 1283       Example(s): None.
 1284 
 1285      Test cases: warnings/should_compile/DerivingTypeable
 1286   -}
 1287   TcRnUselessTypeable :: TcRnMessage
 1288 
 1289   {-| TcRnDerivingDefaults is a warning (controlled by -Wderiving-defaults) that
 1290       occurs when both 'DeriveAnyClass' and 'GeneralizedNewtypeDeriving' are
 1291       enabled, and therefore GHC defaults to 'DeriveAnyClass', which might not
 1292       be what the user wants.
 1293 
 1294       Example(s): None.
 1295 
 1296      Test cases: typecheck/should_compile/T15839a
 1297                  deriving/should_compile/T16179
 1298   -}
 1299   TcRnDerivingDefaults :: !Class -> TcRnMessage
 1300 
 1301   {-| TcRnNonUnaryTypeclassConstraint is an error that occurs when GHC
 1302       encounters a non-unary constraint when trying to derive a typeclass.
 1303 
 1304       Example(s):
 1305         class A
 1306         deriving instance A
 1307         data B deriving A  -- We cannot derive A, is not unary (i.e. 'class A a').
 1308 
 1309      Test cases: deriving/should_fail/T7959
 1310                  deriving/should_fail/drvfail005
 1311                  deriving/should_fail/drvfail009
 1312                  deriving/should_fail/drvfail006
 1313   -}
 1314   TcRnNonUnaryTypeclassConstraint :: !(LHsSigType GhcRn) -> TcRnMessage
 1315 
 1316   {-| TcRnPartialTypeSignatures is a warning (controlled by -Wpartial-type-signatures)
 1317       that occurs when a wildcard '_' is found in place of a type in a signature or a
 1318       type class derivation
 1319 
 1320       Example(s):
 1321         foo :: _ -> Int
 1322         foo = ...
 1323 
 1324         deriving instance _ => Eq (Foo a)
 1325 
 1326      Test cases: dependent/should_compile/T11241
 1327                  dependent/should_compile/T15076
 1328                  dependent/should_compile/T14880-2
 1329                  typecheck/should_compile/T17024
 1330                  typecheck/should_compile/T10072
 1331                  partial-sigs/should_fail/TidyClash2
 1332                  partial-sigs/should_fail/Defaulting1MROff
 1333                  partial-sigs/should_fail/WildcardsInPatternAndExprSig
 1334                  partial-sigs/should_fail/T10615
 1335                  partial-sigs/should_fail/T14584a
 1336                  partial-sigs/should_fail/TidyClash
 1337                  partial-sigs/should_fail/T11122
 1338                  partial-sigs/should_fail/T14584
 1339                  partial-sigs/should_fail/T10045
 1340                  partial-sigs/should_fail/PartialTypeSignaturesDisabled
 1341                  partial-sigs/should_fail/T10999
 1342                  partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature
 1343                  partial-sigs/should_fail/ExtraConstraintsWildcardInPatternSplice
 1344                  partial-sigs/should_fail/WildcardInstantiations
 1345                  partial-sigs/should_run/T15415
 1346                  partial-sigs/should_compile/T10463
 1347                  partial-sigs/should_compile/T15039a
 1348                  partial-sigs/should_compile/T16728b
 1349                  partial-sigs/should_compile/T15039c
 1350                  partial-sigs/should_compile/T10438
 1351                  partial-sigs/should_compile/SplicesUsed
 1352                  partial-sigs/should_compile/T18008
 1353                  partial-sigs/should_compile/ExprSigLocal
 1354                  partial-sigs/should_compile/T11339a
 1355                  partial-sigs/should_compile/T11670
 1356                  partial-sigs/should_compile/WarningWildcardInstantiations
 1357                  partial-sigs/should_compile/T16728
 1358                  partial-sigs/should_compile/T12033
 1359                  partial-sigs/should_compile/T15039b
 1360                  partial-sigs/should_compile/T10403
 1361                  partial-sigs/should_compile/T11192
 1362                  partial-sigs/should_compile/T16728a
 1363                  partial-sigs/should_compile/TypedSplice
 1364                  partial-sigs/should_compile/T15039d
 1365                  partial-sigs/should_compile/T11016
 1366                  partial-sigs/should_compile/T13324_compile2
 1367                  linear/should_fail/LinearPartialSig
 1368                  polykinds/T14265
 1369                  polykinds/T14172
 1370   -}
 1371   TcRnPartialTypeSignatures :: !SuggestPartialTypeSignatures -> !ThetaType -> TcRnMessage
 1372 
 1373   {-| TcRnCannotDeriveInstance is an error that occurs every time a typeclass instance
 1374       can't be derived. The 'DeriveInstanceErrReason' will contain the specific reason
 1375       this error arose.
 1376 
 1377       Example(s): None.
 1378 
 1379       Test cases: generics/T10604/T10604_no_PolyKinds
 1380                   deriving/should_fail/drvfail009
 1381                   deriving/should_fail/drvfail-functor2
 1382                   deriving/should_fail/T10598_fail3
 1383                   deriving/should_fail/deriving-via-fail2
 1384                   deriving/should_fail/deriving-via-fail
 1385                   deriving/should_fail/T16181
 1386   -}
 1387   TcRnCannotDeriveInstance :: !Class
 1388                            -- ^ The typeclass we are trying to derive
 1389                            -- an instance for
 1390                            -> [Type]
 1391                            -- ^ The typeclass arguments, if any.
 1392                            -> !(Maybe (DerivStrategy GhcTc))
 1393                            -- ^ The derivation strategy, if any.
 1394                            -> !UsingGeneralizedNewtypeDeriving
 1395                            -- ^ Is '-XGeneralizedNewtypeDeriving' enabled?
 1396                            -> !DeriveInstanceErrReason
 1397                            -- ^ The specific reason why we couldn't derive
 1398                            -- an instance for the class.
 1399                            -> TcRnMessage
 1400 
 1401   {-| TcRnLazyGADTPattern is an error that occurs when a user writes a nested
 1402       GADT pattern match inside a lazy (~) pattern.
 1403 
 1404       Test case: gadt/lazypat
 1405   -}
 1406   TcRnLazyGADTPattern :: TcRnMessage
 1407 
 1408   {-| TcRnArrowProcGADTPattern is an error that occurs when a user writes a
 1409       GADT pattern inside arrow proc notation.
 1410 
 1411       Test case: arrows/should_fail/arrowfail004.
 1412   -}
 1413   TcRnArrowProcGADTPattern :: TcRnMessage
 1414 
 1415 -- | Which parts of a record field are affected by a particular error or warning.
 1416 data RecordFieldPart
 1417   = RecordFieldConstructor !Name
 1418   | RecordFieldPattern !Name
 1419   | RecordFieldUpdate
 1420 
 1421 -- | Where a shadowed name comes from
 1422 data ShadowedNameProvenance
 1423   = ShadowedNameProvenanceLocal !SrcLoc
 1424     -- ^ The shadowed name is local to the module
 1425   | ShadowedNameProvenanceGlobal [GlobalRdrElt]
 1426     -- ^ The shadowed name is global, typically imported from elsewhere.
 1427 
 1428 -- | In what context did we require a type to have a fixed runtime representation?
 1429 --
 1430 -- Used by 'GHC.Tc.Utils.TcMType.checkTypeHasFixedRuntimeRep' for throwing
 1431 -- representation polymorphism errors when validity checking.
 1432 --
 1433 -- See Note [Representation polymorphism checking] in GHC.Tc.Utils.Concrete
 1434 data FixedRuntimeRepProvenance
 1435   -- | Data constructor fields must have a fixed runtime representation.
 1436   --
 1437   -- Tests: T11734, T18534.
 1438   = FixedRuntimeRepDataConField
 1439 
 1440   -- | Pattern synonym signature arguments must have a fixed runtime representation.
 1441   --
 1442   -- Test: RepPolyPatSynArg.
 1443   | FixedRuntimeRepPatSynSigArg
 1444 
 1445   -- | Pattern synonym signature scrutinee must have a fixed runtime representation.
 1446   --
 1447   -- Test: RepPolyPatSynRes.
 1448   | FixedRuntimeRepPatSynSigRes
 1449 
 1450 pprFixedRuntimeRepProvenance :: FixedRuntimeRepProvenance -> SDoc
 1451 pprFixedRuntimeRepProvenance FixedRuntimeRepDataConField = text "data constructor field"
 1452 pprFixedRuntimeRepProvenance FixedRuntimeRepPatSynSigArg = text "pattern synonym argument"
 1453 pprFixedRuntimeRepProvenance FixedRuntimeRepPatSynSigRes = text "pattern synonym scrutinee"
 1454 
 1455 -- | Why the particular injectivity error arose together with more information,
 1456 -- if any.
 1457 data InjectivityErrReason
 1458   = InjErrRhsBareTyVar [Type]
 1459   | InjErrRhsCannotBeATypeFam
 1460   | InjErrRhsOverlap
 1461   | InjErrCannotInferFromRhs !TyVarSet !HasKinds !SuggestUndecidableInstances
 1462 
 1463 data HasKinds
 1464   = YesHasKinds
 1465   | NoHasKinds
 1466   deriving (Show, Eq)
 1467 
 1468 hasKinds :: Bool -> HasKinds
 1469 hasKinds True  = YesHasKinds
 1470 hasKinds False = NoHasKinds
 1471 
 1472 data SuggestUndecidableInstances
 1473   = YesSuggestUndecidableInstaces
 1474   | NoSuggestUndecidableInstaces
 1475   deriving (Show, Eq)
 1476 
 1477 suggestUndecidableInstances :: Bool -> SuggestUndecidableInstances
 1478 suggestUndecidableInstances True  = YesSuggestUndecidableInstaces
 1479 suggestUndecidableInstances False = NoSuggestUndecidableInstaces
 1480 
 1481 -- | A data type to describe why a variable is not closed.
 1482 -- See Note [Not-closed error messages] in GHC.Tc.Gen.Expr
 1483 data NotClosedReason = NotLetBoundReason
 1484                      | NotTypeClosed VarSet
 1485                      | NotClosed Name NotClosedReason
 1486 
 1487 data SuggestPartialTypeSignatures
 1488   = YesSuggestPartialTypeSignatures
 1489   | NoSuggestPartialTypeSignatures
 1490   deriving (Show, Eq)
 1491 
 1492 suggestPartialTypeSignatures :: Bool -> SuggestPartialTypeSignatures
 1493 suggestPartialTypeSignatures True  = YesSuggestPartialTypeSignatures
 1494 suggestPartialTypeSignatures False = NoSuggestPartialTypeSignatures
 1495 
 1496 data UsingGeneralizedNewtypeDeriving
 1497   = YesGeneralizedNewtypeDeriving
 1498   | NoGeneralizedNewtypeDeriving
 1499   deriving Eq
 1500 
 1501 usingGeneralizedNewtypeDeriving :: Bool -> UsingGeneralizedNewtypeDeriving
 1502 usingGeneralizedNewtypeDeriving True  = YesGeneralizedNewtypeDeriving
 1503 usingGeneralizedNewtypeDeriving False = NoGeneralizedNewtypeDeriving
 1504 
 1505 data DeriveAnyClassEnabled
 1506   = YesDeriveAnyClassEnabled
 1507   | NoDeriveAnyClassEnabled
 1508   deriving Eq
 1509 
 1510 deriveAnyClassEnabled :: Bool -> DeriveAnyClassEnabled
 1511 deriveAnyClassEnabled True  = YesDeriveAnyClassEnabled
 1512 deriveAnyClassEnabled False = NoDeriveAnyClassEnabled
 1513 
 1514 -- | Why a particular typeclass instance couldn't be derived.
 1515 data DeriveInstanceErrReason
 1516   =
 1517     -- | The typeclass instance is not well-kinded.
 1518     DerivErrNotWellKinded !TyCon
 1519                           -- ^ The type constructor that occurs in
 1520                           -- the typeclass instance declaration.
 1521                           !Kind
 1522                           -- ^ The typeclass kind.
 1523                           !Int
 1524                           -- ^ The number of typeclass arguments that GHC
 1525                           -- kept. See Note [tc_args and tycon arity] in
 1526                           -- GHC.Tc.Deriv.
 1527   -- | Generic instances can only be derived using the stock strategy
 1528   -- in Safe Haskell.
 1529   | DerivErrSafeHaskellGenericInst
 1530   | DerivErrDerivingViaWrongKind !Kind !Type !Kind
 1531   | DerivErrNoEtaReduce !Type
 1532                         -- ^ The instance type
 1533   -- | We cannot derive instances in boot files
 1534   | DerivErrBootFileFound
 1535   | DerivErrDataConsNotAllInScope !TyCon
 1536   -- | We cannot use GND on non-newtype types
 1537   | DerivErrGNDUsedOnData
 1538   -- | We cannot derive instances of nullary classes
 1539   | DerivErrNullaryClasses
 1540   -- | Last arg must be newtype or data application
 1541   | DerivErrLastArgMustBeApp
 1542   | DerivErrNoFamilyInstance !TyCon [Type]
 1543   | DerivErrNotStockDeriveable !DeriveAnyClassEnabled
 1544   | DerivErrHasAssociatedDatatypes !HasAssociatedDataFamInsts
 1545                                    !AssociatedTyLastVarInKind
 1546                                    !AssociatedTyNotParamOverLastTyVar
 1547   | DerivErrNewtypeNonDeriveableClass
 1548   | DerivErrCannotEtaReduceEnough !Bool -- Is eta-reduction OK?
 1549   | DerivErrOnlyAnyClassDeriveable !TyCon
 1550                                    -- ^ Type constructor for which the instance
 1551                                    -- is requested
 1552                                    !DeriveAnyClassEnabled
 1553                                    -- ^ Whether or not -XDeriveAnyClass is enabled
 1554                                    -- already.
 1555   -- | Stock deriving won't work, but perhas DeriveAnyClass will.
 1556   | DerivErrNotDeriveable !DeriveAnyClassEnabled
 1557   -- | The given 'PredType' is not a class.
 1558   | DerivErrNotAClass !PredType
 1559   -- | The given (representation of the) 'TyCon' has no
 1560   -- data constructors.
 1561   | DerivErrNoConstructors !TyCon
 1562   | DerivErrLangExtRequired !LangExt.Extension
 1563   -- | GHC simply doesn't how to how derive the input 'Class' for the given
 1564   -- 'Type'.
 1565   | DerivErrDunnoHowToDeriveForType !Type
 1566   -- | The given 'TyCon' must be an enumeration.
 1567   -- See Note [Enumeration types] in GHC.Core.TyCon
 1568   | DerivErrMustBeEnumType !TyCon
 1569   -- | The given 'TyCon' must have /precisely/ one constructor.
 1570   | DerivErrMustHaveExactlyOneConstructor !TyCon
 1571   -- | The given data type must have some parameters.
 1572   | DerivErrMustHaveSomeParameters !TyCon
 1573   -- | The given data type must not have a class context.
 1574   | DerivErrMustNotHaveClassContext !TyCon !ThetaType
 1575   -- | We couldn't derive an instance for a particular data constructor
 1576   -- for a variety of reasons.
 1577   | DerivErrBadConstructor !(Maybe HasWildcard) [DeriveInstanceBadConstructor]
 1578   -- | We couldn't derive a 'Generic' instance for the given type for a
 1579   -- variety of reasons
 1580   | DerivErrGenerics [DeriveGenericsErrReason]
 1581   -- | We couldn't derive an instance either because the type was not an
 1582   -- enum type or because it did have more than one constructor.
 1583   | DerivErrEnumOrProduct !DeriveInstanceErrReason !DeriveInstanceErrReason
 1584 
 1585 data DeriveInstanceBadConstructor
 1586   =
 1587   -- | The given 'DataCon' must be truly polymorphic in the
 1588   -- last argument of the data type.
 1589     DerivErrBadConExistential !DataCon
 1590   -- | The given 'DataCon' must not use the type variable in a function argument"
 1591   | DerivErrBadConCovariant !DataCon
 1592   -- | The given 'DataCon' must not contain function types
 1593   | DerivErrBadConFunTypes !DataCon
 1594   -- | The given 'DataCon' must use the type variable only
 1595   -- as the last argument of a data type
 1596   | DerivErrBadConWrongArg !DataCon
 1597   -- | The given 'DataCon' is a GADT so we cannot directly
 1598   -- derive an istance for it.
 1599   | DerivErrBadConIsGADT !DataCon
 1600   -- | The given 'DataCon' has existentials type vars in its type.
 1601   | DerivErrBadConHasExistentials !DataCon
 1602   -- | The given 'DataCon' has constraints in its type.
 1603   | DerivErrBadConHasConstraints !DataCon
 1604   -- | The given 'DataCon' has a higher-rank type.
 1605   | DerivErrBadConHasHigherRankType !DataCon
 1606 
 1607 data DeriveGenericsErrReason
 1608   = -- | The type must not have some datatype context.
 1609     DerivErrGenericsMustNotHaveDatatypeContext !TyCon
 1610     -- | The data constructor must not have exotic unlifted
 1611     -- or polymorphic arguments.
 1612   | DerivErrGenericsMustNotHaveExoticArgs !DataCon
 1613     -- | The data constructor must be a vanilla constructor.
 1614   | DerivErrGenericsMustBeVanillaDataCon  !DataCon
 1615     -- | The type must have some type parameters.
 1616     -- check (d) from Note [Requirements for deriving Generic and Rep]
 1617     -- in GHC.Tc.Deriv.Generics.
 1618   | DerivErrGenericsMustHaveSomeTypeParams !TyCon
 1619     -- | The data constructor must not have existential arguments.
 1620   | DerivErrGenericsMustNotHaveExistentials !DataCon
 1621     -- | The derivation applies a type to an argument involving
 1622     -- the last parameter but the applied type is not of kind * -> *.
 1623   | DerivErrGenericsWrongArgKind !DataCon
 1624 
 1625 data HasWildcard
 1626   = YesHasWildcard
 1627   | NoHasWildcard
 1628   deriving Eq
 1629 
 1630 hasWildcard :: Bool -> HasWildcard
 1631 hasWildcard True  = YesHasWildcard
 1632 hasWildcard False = NoHasWildcard
 1633 
 1634 -- | A type representing whether or not the input type has associated data family instances.
 1635 data HasAssociatedDataFamInsts
 1636   = YesHasAdfs
 1637   | NoHasAdfs
 1638   deriving Eq
 1639 
 1640 hasAssociatedDataFamInsts :: Bool -> HasAssociatedDataFamInsts
 1641 hasAssociatedDataFamInsts True = YesHasAdfs
 1642 hasAssociatedDataFamInsts False = NoHasAdfs
 1643 
 1644 -- | If 'YesAssocTyLastVarInKind', the associated type of a typeclass
 1645 -- contains the last type variable of the class in a kind, which is not (yet) allowed
 1646 -- by GHC.
 1647 data AssociatedTyLastVarInKind
 1648   = YesAssocTyLastVarInKind !TyCon -- ^ The associated type family of the class
 1649   | NoAssocTyLastVarInKind
 1650   deriving Eq
 1651 
 1652 associatedTyLastVarInKind :: Maybe TyCon -> AssociatedTyLastVarInKind
 1653 associatedTyLastVarInKind (Just tc) = YesAssocTyLastVarInKind tc
 1654 associatedTyLastVarInKind Nothing   = NoAssocTyLastVarInKind
 1655 
 1656 -- | If 'NoAssociatedTyNotParamOverLastTyVar', the associated type of a
 1657 -- typeclass is not parameterized over the last type variable of the class
 1658 data AssociatedTyNotParamOverLastTyVar
 1659   = YesAssociatedTyNotParamOverLastTyVar !TyCon -- ^ The associated type family of the class
 1660   | NoAssociatedTyNotParamOverLastTyVar
 1661   deriving Eq
 1662 
 1663 associatedTyNotParamOverLastTyVar :: Maybe TyCon -> AssociatedTyNotParamOverLastTyVar
 1664 associatedTyNotParamOverLastTyVar (Just tc) = YesAssociatedTyNotParamOverLastTyVar tc
 1665 associatedTyNotParamOverLastTyVar Nothing   = NoAssociatedTyNotParamOverLastTyVar