GHC.Tc.Gen.HsType

ghc-9.10.0.20240426: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.Tc.Gen.HsType

Description

Typechecking user-specified `MonoTypes`

Synopsis

- kcClassSigType :: [LocatedN Name] -> LHsSigType GhcRn -> TcM ()
- tcClassSigType :: [LocatedN Name] -> LHsSigType GhcRn -> TcM Type
- tcHsSigType :: UserTypeCtxt -> LHsSigType GhcRn -> TcM Type
- tcHsSigWcType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM Type
- tcHsPartialSigType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM ([(Name, TcTyVar)], Maybe TcType, [(Name, InvisTVBinder)], TcThetaType, TcType)
- tcStandaloneKindSig :: LStandaloneKindSig GhcRn -> TcM (Name, Kind)
- funsSigCtxt :: [LocatedN Name] -> UserTypeCtxt
- addSigCtxt :: Outputable hs_ty => UserTypeCtxt -> LocatedA hs_ty -> TcM a -> TcM a
- pprSigCtxt :: Outputable hs_ty => UserTypeCtxt -> LocatedA hs_ty -> SDoc
- tcHsClsInstType :: UserTypeCtxt -> LHsSigType GhcRn -> TcM Type
- tcHsDeriv :: LHsSigType GhcRn -> TcM ([TyVar], Class, [Type], [Kind])
- tcDerivStrategy :: Maybe (LDerivStrategy GhcRn) -> TcM (Maybe (LDerivStrategy GhcTc), [TcTyVar])
- tcHsTypeApp :: LHsWcType GhcRn -> Kind -> TcM Type
- data UserTypeCtxt
  - = FunSigCtxt Name ReportRedundantConstraints
  - | InfSigCtxt Name
  - | ExprSigCtxt ReportRedundantConstraints
  - | KindSigCtxt
  - | StandaloneKindSigCtxt Name
  - | TypeAppCtxt
  - | ConArgCtxt Name
  - | TySynCtxt Name
  - | PatSynCtxt Name
  - | PatSigCtxt
  - | RuleSigCtxt FastString Name
  - | ForSigCtxt Name
  - | DefaultDeclCtxt
  - | InstDeclCtxt Bool
  - | SpecInstCtxt
  - | GenSigCtxt
  - | GhciCtxt Bool
  - | ClassSCCtxt Name
  - | SigmaCtxt
  - | DataTyCtxt Name
  - | DerivClauseCtxt
  - | TyVarBndrKindCtxt Name
  - | DataKindCtxt Name
  - | TySynKindCtxt Name
  - | TyFamResKindCtxt Name
- bindImplicitTKBndrs_Tv :: [Name] -> TcM a -> TcM ([TcTyVar], a)
- bindImplicitTKBndrs_Skol :: SkolemInfo -> [Name] -> TcM a -> TcM ([TcTyVar], a)
- bindImplicitTKBndrs_Q_Tv :: [Name] -> TcM a -> TcM ([TcTyVar], a)
- bindImplicitTKBndrs_Q_Skol :: SkolemInfo -> [Name] -> TcM a -> TcM ([TcTyVar], a)
- bindExplicitTKBndrs_Tv :: OutputableBndrFlag flag 'Renamed => [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a)
- bindExplicitTKBndrs_Skol :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a)
- bindExplicitTKBndrs_Q_Tv :: OutputableBndrFlag flag 'Renamed => ContextKind -> [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a)
- bindExplicitTKBndrs_Q_Skol :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> ContextKind -> [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a)
- bindOuterFamEqnTKBndrs_Q_Tv :: HsOuterFamEqnTyVarBndrs GhcRn -> TcM a -> TcM (HsOuterFamEqnTyVarBndrs GhcTc, a)
- bindOuterFamEqnTKBndrs :: SkolemInfo -> HsOuterFamEqnTyVarBndrs GhcRn -> TcM a -> TcM (HsOuterFamEqnTyVarBndrs GhcTc, a)
- tcOuterTKBndrs :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> HsOuterTyVarBndrs flag GhcRn -> TcM a -> TcM (HsOuterTyVarBndrs flag GhcTc, a)
- scopedSortOuter :: HsOuterTyVarBndrs flag GhcTc -> TcM (HsOuterTyVarBndrs flag GhcTc)
- outerTyVars :: HsOuterTyVarBndrs flag GhcTc -> [TcTyVar]
- outerTyVarBndrs :: HsOuterTyVarBndrs Specificity GhcTc -> [InvisTVBinder]
- bindOuterSigTKBndrs_Tv :: HsOuterSigTyVarBndrs GhcRn -> TcM a -> TcM (HsOuterSigTyVarBndrs GhcTc, a)
- tcExplicitTKBndrs :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a)
- bindNamedWildCardBinders :: [Name] -> ([(Name, TcTyVar)] -> TcM a) -> TcM a
- bindTyClTyVars :: Name -> ([TcTyConBinder] -> TcKind -> TcM a) -> TcM a
- bindTyClTyVarsAndZonk :: Name -> ([TyConBinder] -> Kind -> TcM a) -> TcM a
- tcFamTyPats :: TyCon -> HsFamEqnPats GhcRn -> TcM (TcType, TcKind)
- etaExpandAlgTyCon :: TyConFlavour tc -> SkolemInfo -> [TcTyConBinder] -> Kind -> TcM ([TcTyConBinder], Kind)
- tcbVisibilities :: TyCon -> [Type] -> [TyConBndrVis]
- zonkAndScopedSort :: [TcTyVar] -> TcM [TcTyVar]
- data InitialKindStrategy
  - = InitialKindCheck SAKS_or_CUSK
  - | InitialKindInfer
- data SAKS_or_CUSK
  - = SAKS Kind
  - | CUSK
- data ContextKind
  - = TheKind TcKind
  - | AnyKind
  - | OpenKind
- kcDeclHeader :: InitialKindStrategy -> Name -> TyConFlavour TyCon -> LHsQTyVars GhcRn -> TcM ContextKind -> TcM TcTyCon
- checkForDuplicateScopedTyVars :: [(Name, TcTyVar)] -> TcM ()
- tcHsLiftedType :: LHsType GhcRn -> TcM TcType
- tcHsOpenType :: LHsType GhcRn -> TcM TcType
- tcHsLiftedTypeNC :: LHsType GhcRn -> TcM TcType
- tcHsOpenTypeNC :: LHsType GhcRn -> TcM TcType
- tcInferLHsType :: LHsType GhcRn -> TcM TcType
- tcInferLHsTypeKind :: LHsType GhcRn -> TcM (TcType, TcKind)
- tcInferLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind)
- tcCheckLHsType :: LHsType GhcRn -> ContextKind -> TcM TcType
- tcHsContext :: Maybe (LHsContext GhcRn) -> TcM [PredType]
- tcLHsPredType :: LHsType GhcRn -> TcM PredType
- kindGeneralizeAll :: SkolemInfo -> TcType -> TcM [KindVar]
- tcLHsKindSig :: UserTypeCtxt -> LHsKind GhcRn -> TcM Kind
- checkDataKindSig :: DataSort -> Kind -> TcM ()
- data DataSort
  - = DataDeclSort NewOrData
  - | DataInstanceSort NewOrData
  - | DataFamilySort
- checkClassKindSig :: Kind -> TcM ()
- tcMult :: HsArrow GhcRn -> TcM Mult
- tcHsPatSigType :: UserTypeCtxt -> HoleMode -> HsPatSigType GhcRn -> ContextKind -> TcM ([(Name, TcTyVar)], [(Name, TcTyVar)], TcType)
- tcHsTyPat :: HsTyPat GhcRn -> Kind -> TcM ([(Name, TcTyVar)], [(Name, TcTyVar)], TcType)
- data HoleMode
  - = HM_Sig
  - | HM_FamPat
  - | HM_VTA
  - | HM_TyAppPat
- funAppCtxt :: (Outputable fun, Outputable arg) => fun -> arg -> Int -> SDoc
- addTyConFlavCtxt :: Name -> TyConFlavour tc -> TcM a -> TcM a

# Documentation

kcClassSigType :: [LocatedN Name] -> LHsSigType GhcRn -> TcM () Source #

tcClassSigType :: [LocatedN Name] -> LHsSigType GhcRn -> TcM Type Source #

tcHsSigType :: UserTypeCtxt -> LHsSigType GhcRn -> TcM Type Source #

tcHsSigWcType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM Type Source #

tcHsPartialSigType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM ([(Name, TcTyVar)], Maybe TcType, [(Name, InvisTVBinder)], TcThetaType, TcType) Source #

tcStandaloneKindSig :: LStandaloneKindSig GhcRn -> TcM (Name, Kind) Source #

funsSigCtxt :: [LocatedN Name] -> UserTypeCtxt Source #

addSigCtxt :: Outputable hs_ty => UserTypeCtxt -> LocatedA hs_ty -> TcM a -> TcM a Source #

pprSigCtxt :: Outputable hs_ty => UserTypeCtxt -> LocatedA hs_ty -> SDoc Source #

tcHsClsInstType :: UserTypeCtxt -> LHsSigType GhcRn -> TcM Type Source #

tcHsDeriv :: LHsSigType GhcRn -> TcM ([TyVar], Class, [Type], [Kind]) Source #

tcDerivStrategy Source #

Arguments

:: Maybe (LDerivStrategy GhcRn) | The deriving strategy
-> TcM (Maybe (LDerivStrategy GhcTc), [TcTyVar]) | The typechecked deriving strategy and the tyvars that it binds (if using `ViaStrategy`).

Typecheck a deriving strategy. For most deriving strategies, this is a no-op, but for the `via` strategy, this requires typechecking the `via` type.

tcHsTypeApp :: LHsWcType GhcRn -> Kind -> TcM Type Source #

Type-check a visible type application

data UserTypeCtxt Source #

UserTypeCtxt describes the origin of the polymorphic type in the places where we need an expression to have that type

Constructors

FunSigCtxt Name ReportRedundantConstraints |
InfSigCtxt Name |
ExprSigCtxt ReportRedundantConstraints |
KindSigCtxt |
StandaloneKindSigCtxt Name |
TypeAppCtxt |
ConArgCtxt Name |
TySynCtxt Name |
PatSynCtxt Name |
PatSigCtxt |
RuleSigCtxt FastString Name |
ForSigCtxt Name |
DefaultDeclCtxt |
InstDeclCtxt Bool |
SpecInstCtxt |
GenSigCtxt |
GhciCtxt Bool |
ClassSCCtxt Name |
SigmaCtxt |
DataTyCtxt Name |
DerivClauseCtxt |
TyVarBndrKindCtxt Name |
DataKindCtxt Name |
TySynKindCtxt Name |
TyFamResKindCtxt Name |

#### Instances

Instances details

Eq UserTypeCtxt Source # |
Instance details Defined in GHC.Tc.Types.Origin Methods (==) :: UserTypeCtxt -> UserTypeCtxt -> Bool # (/=) :: UserTypeCtxt -> UserTypeCtxt -> Bool #

bindImplicitTKBndrs_Tv :: [Name] -> TcM a -> TcM ([TcTyVar], a) Source #

bindImplicitTKBndrs_Skol :: SkolemInfo -> [Name] -> TcM a -> TcM ([TcTyVar], a) Source #

bindImplicitTKBndrs_Q_Tv :: [Name] -> TcM a -> TcM ([TcTyVar], a) Source #

bindImplicitTKBndrs_Q_Skol :: SkolemInfo -> [Name] -> TcM a -> TcM ([TcTyVar], a) Source #

bindExplicitTKBndrs_Tv :: OutputableBndrFlag flag 'Renamed => [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a) Source #

bindExplicitTKBndrs_Skol :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a) Source #

Skolemise the `HsTyVarBndr`s in an `HsForAllTelescope` with the supplied `TcTyMode`.

bindExplicitTKBndrs_Q_Tv :: OutputableBndrFlag flag 'Renamed => ContextKind -> [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a) Source #

bindExplicitTKBndrs_Q_Skol :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> ContextKind -> [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a) Source #

bindOuterFamEqnTKBndrs_Q_Tv :: HsOuterFamEqnTyVarBndrs GhcRn -> TcM a -> TcM (HsOuterFamEqnTyVarBndrs GhcTc, a) Source #

bindOuterFamEqnTKBndrs :: SkolemInfo -> HsOuterFamEqnTyVarBndrs GhcRn -> TcM a -> TcM (HsOuterFamEqnTyVarBndrs GhcTc, a) Source #

tcOuterTKBndrs :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> HsOuterTyVarBndrs flag GhcRn -> TcM a -> TcM (HsOuterTyVarBndrs flag GhcTc, a) Source #

scopedSortOuter :: HsOuterTyVarBndrs flag GhcTc -> TcM (HsOuterTyVarBndrs flag GhcTc) Source #

outerTyVars :: HsOuterTyVarBndrs flag GhcTc -> [TcTyVar] Source #

outerTyVarBndrs :: HsOuterTyVarBndrs Specificity GhcTc -> [InvisTVBinder] Source #

bindOuterSigTKBndrs_Tv :: HsOuterSigTyVarBndrs GhcRn -> TcM a -> TcM (HsOuterSigTyVarBndrs GhcTc, a) Source #

tcExplicitTKBndrs :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a) Source #

bindNamedWildCardBinders :: [Name] -> ([(Name, TcTyVar)] -> TcM a) -> TcM a Source #

bindTyClTyVars :: Name -> ([TcTyConBinder] -> TcKind -> TcM a) -> TcM a Source #

Bring into scope the binders of a PolyTcTyCon Used for the type variables of a type or class decl in the "kind checking" and "type checking" pass, but not in the initial-kind run.

bindTyClTyVarsAndZonk :: Name -> ([TyConBinder] -> Kind -> TcM a) -> TcM a Source #

tcFamTyPats :: TyCon -> HsFamEqnPats GhcRn -> TcM (TcType, TcKind) Source #

etaExpandAlgTyCon :: TyConFlavour tc -> SkolemInfo -> [TcTyConBinder] -> Kind -> TcM ([TcTyConBinder], Kind) Source #

tcbVisibilities :: TyCon -> [Type] -> [TyConBndrVis] Source #

zonkAndScopedSort :: [TcTyVar] -> TcM [TcTyVar] Source #

data InitialKindStrategy Source #

Constructors

InitialKindCheck SAKS_or_CUSK |
InitialKindInfer |

data SAKS_or_CUSK Source #

Constructors

SAKS Kind |
CUSK |

#### Instances

Instances details

Outputable SAKS_or_CUSK Source # |
Instance details Defined in GHC.Tc.Gen.HsType Methods ppr :: SAKS_or_CUSK -> SDoc Source #

data ContextKind Source #

Describes the kind expected in a certain context.

Constructors

TheKind TcKind | a specific kind
AnyKind | any kind will do
OpenKind | something of the form `TYPE _`

#### Instances

Instances details

Outputable ContextKind Source # |
Instance details Defined in GHC.Tc.Gen.HsType Methods ppr :: ContextKind -> SDoc Source #

kcDeclHeader Source #

Arguments

:: InitialKindStrategy |
-> Name | of the thing being checked
-> TyConFlavour TyCon | What sort of `TyCon` is being checked
-> LHsQTyVars GhcRn | Binders in the header
-> TcM ContextKind | The result kind
-> TcM TcTyCon | A suitably-kinded TcTyCon

checkForDuplicateScopedTyVars :: [(Name, TcTyVar)] -> TcM () Source #

tcHsLiftedType :: LHsType GhcRn -> TcM TcType Source #

tcHsOpenType :: LHsType GhcRn -> TcM TcType Source #

tcHsLiftedTypeNC :: LHsType GhcRn -> TcM TcType Source #

tcHsOpenTypeNC :: LHsType GhcRn -> TcM TcType Source #

tcInferLHsType :: LHsType GhcRn -> TcM TcType Source #

tcInferLHsTypeKind :: LHsType GhcRn -> TcM (TcType, TcKind) Source #

tcInferLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind) Source #

tcCheckLHsType :: LHsType GhcRn -> ContextKind -> TcM TcType Source #

tcHsContext :: Maybe (LHsContext GhcRn) -> TcM [PredType] Source #

tcLHsPredType :: LHsType GhcRn -> TcM PredType Source #

kindGeneralizeAll :: SkolemInfo -> TcType -> TcM [KindVar] Source #

- Specialised version of `kindGeneralizeSome`, but with empty WantedConstraints, so no filtering is needed i.e. kindGeneraliseAll = kindGeneralizeSome emptyWC

tcLHsKindSig :: UserTypeCtxt -> LHsKind GhcRn -> TcM Kind Source #

checkDataKindSig :: DataSort -> Kind -> TcM () Source #

Checks that the return kind in a data declaration's kind signature is permissible. There are three cases:

If dealing with a `data`, `newtype`, `data instance`, or `newtype instance` declaration, check that the return kind is `Type`.

If the declaration is a `newtype` or `newtype instance` and the `UnliftedNewtypes` extension is enabled, this check is slightly relaxed so that a return kind of the form `TYPE r` (for some `r`) is permitted. See `Note [Implementation of UnliftedNewtypes]` in GHC.Tc.TyCl.

If dealing with a `data family` declaration, check that the return kind is either of the form:

1. `TYPE r` (for some `r`), or
2. `k` (where `k` is a bare kind variable; see #12369)

See also Note [Datatype return kinds] in GHC.Tc.TyCl

data DataSort Source #

A description of whether something is a

- `data` or `newtype` (`DataDeclSort`)
- `data instance` or `newtype instance` (`DataInstanceSort`)
- `data family` (`DataFamilySort`)

At present, this data type is only consumed by `checkDataKindSig`.

Constructors

DataDeclSort NewOrData |
DataInstanceSort NewOrData |
DataFamilySort |

checkClassKindSig :: Kind -> TcM () Source #

Checks that the result kind of a class is exactly `Constraint`, rejecting type synonyms and type families that reduce to `Constraint`. See #16826.

tcMult :: HsArrow GhcRn -> TcM Mult Source #

tcHsPatSigType :: UserTypeCtxt -> HoleMode -> HsPatSigType GhcRn -> ContextKind -> TcM ([(Name, TcTyVar)], [(Name, TcTyVar)], TcType) Source #

tcHsTyPat :: HsTyPat GhcRn -> Kind -> TcM ([(Name, TcTyVar)], [(Name, TcTyVar)], TcType) Source #

data HoleMode Source #

Constructors

HM_Sig |
HM_FamPat |
HM_VTA |
HM_TyAppPat |

#### Instances

Instances details

Outputable HoleMode Source # |
Instance details Defined in GHC.Tc.Gen.HsType Methods ppr :: HoleMode -> SDoc Source #

funAppCtxt :: (Outputable fun, Outputable arg) => fun -> arg -> Int -> SDoc Source #

Make an appropriate message for an error in a function argument. Used for both expressions and types.

addTyConFlavCtxt :: Name -> TyConFlavour tc -> TcM a -> TcM a Source #

Add a "In the data declaration for T" or some such.