{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE UndecidableInstances #-}
module GHC.Tc.Types.ErrCtxt
( ErrCtxt, ErrCtxtMsg(..)
, UserSigType(..), FunAppCtxtFunArg(..)
, TyConInstFlavour(..)
)
where
import GHC.Prelude
import GHC.Hs.Expr
import GHC.Hs.Extension
import GHC.Parser.Annotation ( LocatedN, SrcSpanAnnA )
import GHC.Tc.Errors.Types.PromotionErr ( TermLevelUseCtxt )
import GHC.Tc.Types.Origin ( CtOrigin, UserTypeCtxt, ExpectedFunTyOrigin )
import GHC.Tc.Utils.TcType ( TcType, TcTyCon )
import GHC.Tc.Zonk.Monad ( ZonkM )
import GHC.Types.Basic ( TyConFlavour )
import GHC.Types.Name ( Name )
import GHC.Types.SrcLoc ( SrcSpan )
import GHC.Types.Var ( Id, TyCoVar )
import GHC.Types.Var.Env ( TidyEnv )
import GHC.Unit.Types ( Module, InstantiatedModule )
import GHC.Core.Class ( Class )
import GHC.Core.ConLike ( ConLike )
import GHC.Core.PatSyn ( PatSyn )
import GHC.Core.TyCon ( TyCon )
import GHC.Core.TyCo.Rep ( Type, ThetaType, PredType )
import GHC.Unit.State ( UnitState )
import GHC.Data.FastString ( FastString )
import GHC.Utils.Outputable ( Outputable(..) )
import Language.Haskell.Syntax.Basic ( FieldLabelString(..) )
import Language.Haskell.Syntax
import GHC.Internal.TH.Syntax qualified as TH
import qualified Data.List.NonEmpty as NE
type ErrCtxt = (Bool, TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg))
data UserSigType p
= UserLHsSigType !(LHsSigType p)
| UserLHsType !(LHsType p)
instance OutputableBndrId p => Outputable (UserSigType (GhcPass p)) where
ppr :: UserSigType (GhcPass p) -> SDoc
ppr (UserLHsSigType LHsSigType (GhcPass p)
ty) = GenLocated SrcSpanAnnA (HsSigType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsSigType (GhcPass p)
GenLocated SrcSpanAnnA (HsSigType (GhcPass p))
ty
ppr (UserLHsType LHsType (GhcPass p)
ty) = GenLocated SrcSpanAnnA (HsType (GhcPass p)) -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsType (GhcPass p)
GenLocated SrcSpanAnnA (HsType (GhcPass p))
ty
data FunAppCtxtFunArg
= FunAppCtxtExpr !(HsExpr GhcRn) !(HsExpr GhcRn)
| FunAppCtxtTy !(LHsType GhcRn) !(LHsType GhcRn)
data TyConInstFlavour
= TyConInstFlavour
{ TyConInstFlavour -> TyConFlavour TyCon
tyConInstFlavour :: !(TyConFlavour TyCon)
, TyConInstFlavour -> Bool
tyConInstIsDefault :: !Bool
}
data ErrCtxtMsg
= ExprCtxt !(HsExpr GhcRn)
| ThetaCtxt !UserTypeCtxt !ThetaType
| QuantifiedCtCtxt !PredType
| InferredTypeCtxt !Name !TcType
| SigCtxt !(Sig GhcRn)
| UserSigCtxt !UserTypeCtxt !(UserSigType GhcRn)
| RecordUpdCtxt !(NE.NonEmpty ConLike) ![Name] ![TyCoVar]
| ClassOpCtxt !Id !Type
| MethSigCtxt !Name !TcType !TcType
| PatSigErrCtxt !TcType !TcType
| PatCtxt !(Pat GhcRn)
| PatSynDeclCtxt !Name
| MatchCtxt !HsMatchContextRn
| forall body. (Outputable body)
=> MatchInCtxt !(Match GhcRn body)
| FunAppCtxt !FunAppCtxtFunArg !Int
| FunTysCtxt !ExpectedFunTyOrigin !Type !Int !Int
| FunResCtxt !(HsExpr GhcTc) !Int !Type !Type !Int !Int
| TyConDeclCtxt !Name !(TyConFlavour TyCon)
| TyConInstCtxt !Name !TyConInstFlavour
| DataConDefCtxt !(NE.NonEmpty (LocatedN Name))
| DataConResTyCtxt !(NE.NonEmpty (LocatedN Name))
| ClosedFamEqnCtxt !TyCon
| TySynErrCtxt !TyCon
| RoleAnnotErrCtxt !Name
| CmdCtxt !(HsCmd GhcRn)
| InstDeclErrCtxt !(Either (LHsType GhcRn) PredType)
| DefaultDeclErrCtxt
| StaticFormCtxt !(LHsExpr GhcRn)
| forall p. OutputableBndrId p
=> PatMonoBindsCtxt !(LPat (GhcPass p)) !(GRHSs GhcRn (LHsExpr GhcRn))
| ForeignDeclCtxt !(ForeignDecl GhcRn)
| FieldCtxt !FieldLabelString
| TypeCtxt !(LHsType GhcRn)
| KindCtxt !(LHsKind GhcRn)
| AmbiguityCheckCtxt !UserTypeCtxt !Bool
| TermLevelUseCtxt !Name !TermLevelUseCtxt
| MainCtxt !Name
| VDQWarningCtxt !TcTyCon
| forall body.
( Anno (StmtLR GhcRn GhcRn body) ~ SrcSpanAnnA
, Outputable body
) => StmtErrCtxt !HsStmtContextRn !(StmtLR GhcRn GhcRn body)
| SyntaxNameCtxt !(HsExpr GhcRn) !CtOrigin !TcType !SrcSpan
| RuleCtxt !FastString
| SubTypeCtxt !TcType !TcType
| forall p. OutputableBndrId p
=> ExportCtxt (IE (GhcPass p))
| PatSynExportCtxt !PatSyn
| PatSynRecSelExportCtxt !PatSyn !Name
| forall p. OutputableBndrId p
=> AnnCtxt (AnnDecl (GhcPass p))
| SpecPragmaCtxt !(Sig GhcRn)
| DerivInstCtxt !PredType
| StandaloneDerivCtxt !(LHsSigWcType GhcRn)
| DerivBindCtxt !Id !Class ![Type]
| UntypedTHBracketCtxt !(HsQuote GhcPs)
| forall p. OutputableBndrId p
=> TypedTHBracketCtxt !(LHsExpr (GhcPass p))
| UntypedSpliceCtxt !(HsUntypedSplice GhcPs)
| forall p. OutputableBndrId p
=> TypedSpliceCtxt !(Maybe SplicePointName) !(LHsExpr (GhcPass p))
| TypedSpliceResultCtxt !(LHsExpr GhcTc)
| ReifyInstancesCtxt !TH.Name ![TH.Type]
| MergeSignaturesCtxt !UnitState !ModuleName ![InstantiatedModule]
| CheckImplementsCtxt !UnitState !Module !InstantiatedModule