Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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), [TyVar])
- tcHsTypeApp :: LHsWcType GhcRn -> Kind -> TcM Type
- data UserTypeCtxt
- = FunSigCtxt Name Bool
- | InfSigCtxt Name
- | ExprSigCtxt
- | KindSigCtxt
- | StandaloneKindSigCtxt Name
- | TypeAppCtxt
- | ConArgCtxt Name
- | TySynCtxt Name
- | PatSynCtxt Name
- | PatSigCtxt
- | RuleSigCtxt 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 :: [Name] -> TcM a -> TcM ([TcTyVar], a)
- bindImplicitTKBndrs_Q_Tv :: [Name] -> TcM a -> TcM ([TcTyVar], a)
- bindImplicitTKBndrs_Q_Skol :: [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 => [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a)
- bindExplicitTKBndrs_Q_Tv :: ContextKind -> [LHsTyVarBndr () GhcRn] -> TcM a -> TcM ([TcTyVar], a)
- bindExplicitTKBndrs_Q_Skol :: ContextKind -> [LHsTyVarBndr () GhcRn] -> TcM a -> TcM ([TcTyVar], a)
- bindOuterFamEqnTKBndrs :: HsOuterFamEqnTyVarBndrs GhcRn -> TcM a -> TcM ([TcTyVar], a)
- bindOuterFamEqnTKBndrs_Q_Tv :: HsOuterFamEqnTyVarBndrs GhcRn -> TcM a -> TcM ([TcTyVar], a)
- tcOuterTKBndrs :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> HsOuterTyVarBndrs flag GhcRn -> TcM a -> TcM (HsOuterTyVarBndrs flag GhcTc, a)
- scopedSortOuter :: HsOuterTyVarBndrs Specificity GhcTc -> TcM [InvisTVBinder]
- bindOuterSigTKBndrs_Tv :: HsOuterSigTyVarBndrs GhcRn -> TcM a -> TcM (HsOuterSigTyVarBndrs GhcTc, a)
- tcExplicitTKBndrs :: OutputableBndrFlag flag 'Renamed => [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a)
- bindNamedWildCardBinders :: [Name] -> ([(Name, TcTyVar)] -> TcM a) -> TcM a
- bindTyClTyVars :: Name -> (TcTyCon -> [TyConBinder] -> Kind -> TcM a) -> TcM a
- tcFamTyPats :: TyCon -> HsTyPats GhcRn -> TcM (TcType, TcKind)
- etaExpandAlgTyCon :: [TyConBinder] -> Kind -> TcM ([TyConBinder], Kind)
- tcbVisibilities :: TyCon -> [Type] -> [TyConBndrVis]
- zonkAndScopedSort :: [TcTyVar] -> TcM [TcTyVar]
- data InitialKindStrategy
- data SAKS_or_CUSK
- data ContextKind
- kcDeclHeader :: InitialKindStrategy -> Name -> TyConFlavour -> LHsQTyVars GhcRn -> TcM ContextKind -> TcM TcTyCon
- 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 :: TcType -> TcM [KindVar]
- kindGeneralizeSome :: WantedConstraints -> TcType -> TcM [KindVar]
- kindGeneralizeNone :: TcType -> TcM ()
- tcLHsKindSig :: UserTypeCtxt -> LHsKind GhcRn -> TcM Kind
- checkDataKindSig :: DataSort -> Kind -> TcM ()
- data DataSort
- checkClassKindSig :: Kind -> TcM ()
- tcMult :: HsArrow GhcRn -> TcM Mult
- tcHsPatSigType :: UserTypeCtxt -> HoleMode -> HsPatSigType GhcRn -> ContextKind -> 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 -> 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 #
:: Maybe (LDerivStrategy GhcRn) | The deriving strategy |
-> TcM (Maybe (LDerivStrategy GhcTc), [TyVar]) | The typechecked deriving strategy and the tyvars that it binds
(if using |
Typecheck a deriving strategy. For most deriving strategies, this is a
no-op, but for the via
strategy, this requires typechecking the via
type.
data UserTypeCtxt Source #
UserTypeCtxt describes the origin of the polymorphic type in the places where we need an expression to have that type
bindExplicitTKBndrs_Tv :: OutputableBndrFlag flag 'Renamed => [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a) Source #
Skolemise the HsTyVarBndr
s in an HsForAllTelescope
with the supplied
TcTyMode
.
bindExplicitTKBndrs_Skol :: OutputableBndrFlag flag 'Renamed => [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 :: ContextKind -> [LHsTyVarBndr () GhcRn] -> TcM a -> TcM ([TcTyVar], a) Source #
bindExplicitTKBndrs_Q_Skol :: ContextKind -> [LHsTyVarBndr () GhcRn] -> TcM a -> TcM ([TcTyVar], a) Source #
bindOuterFamEqnTKBndrs :: HsOuterFamEqnTyVarBndrs GhcRn -> TcM a -> TcM ([TcTyVar], a) Source #
bindOuterFamEqnTKBndrs_Q_Tv :: HsOuterFamEqnTyVarBndrs GhcRn -> TcM a -> TcM ([TcTyVar], a) Source #
tcOuterTKBndrs :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> HsOuterTyVarBndrs flag GhcRn -> TcM a -> TcM (HsOuterTyVarBndrs flag GhcTc, a) Source #
bindOuterSigTKBndrs_Tv :: HsOuterSigTyVarBndrs GhcRn -> TcM a -> TcM (HsOuterSigTyVarBndrs GhcTc, a) Source #
tcExplicitTKBndrs :: OutputableBndrFlag flag 'Renamed => [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a) Source #
bindTyClTyVars :: Name -> (TcTyCon -> [TyConBinder] -> Kind -> TcM a) -> TcM a Source #
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.
etaExpandAlgTyCon :: [TyConBinder] -> Kind -> TcM ([TyConBinder], Kind) Source #
tcbVisibilities :: TyCon -> [Type] -> [TyConBndrVis] Source #
data SAKS_or_CUSK Source #
Instances
Outputable SAKS_or_CUSK # | |
Defined in GHC.Tc.Gen.HsType ppr :: SAKS_or_CUSK -> SDoc Source # |
data ContextKind Source #
Describes the kind expected in a certain context.
:: InitialKindStrategy | |
-> Name | of the thing being checked |
-> TyConFlavour | What sort of |
-> LHsQTyVars GhcRn | Binders in the header |
-> TcM ContextKind | The result kind |
-> TcM TcTyCon | A suitably-kinded TcTyCon |
tcCheckLHsType :: LHsType GhcRn -> ContextKind -> TcM TcType Source #
tcHsContext :: Maybe (LHsContext GhcRn) -> TcM [PredType] Source #
kindGeneralizeAll :: TcType -> TcM [KindVar] Source #
- Specialised version of
kindGeneralizeSome
, but with empty WantedConstraints, so no filtering is needed i.e. kindGeneraliseAll = kindGeneralizeSome emptyWC
:: WantedConstraints | |
-> TcType | needn't be zonked |
-> TcM [KindVar] |
Generalize some of the free variables in the given type.
All such variables should be *kind* variables; any type variables
should be explicitly quantified (with a forall
) before now.
The WantedConstraints are un-solved kind constraints. Generally they'll be reported as errors later, but meanwhile we refrain from quantifying over any variable free in these unsolved constraints. See Note [Failure in local type signatures].
But in all cases, generalize only those variables whose TcLevel is strictly greater than the ambient level. This "strictly greater than" means that you likely need to push the level before creating whatever type gets passed here.
Any variable whose level is greater than the ambient level but is not selected to be generalized will be promoted. (See [Promoting unification variables] in GHC.Tc.Solver and Note [Recipe for checking a signature].)
The resulting KindVar are the variables to quantify over, in the correct, well-scoped order. They should generally be Inferred, not Specified, but that's really up to the caller of this function.
kindGeneralizeNone :: TcType -> TcM () Source #
Specialized version of kindGeneralizeSome
, but where no variables
can be generalized, but perhaps some may need to be promoted.
Use this variant when it is unknowable whether metavariables might
later be constrained.
To see why this promotion is needed, see Note [Recipe for checking a signature], and especially Note [Promotion in signatures].
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:
TYPE r
(for somer
), ork
(wherek
is a bare kind variable; see #12369)
See also Note [Datatype return kinds] in GHC.Tc.TyCl
A description of whether something is a
data
ornewtype
(DataDeclSort
)data instance
ornewtype instance
(DataInstanceSort
)data family
(DataFamilySort
)
At present, this data type is only consumed by checkDataKindSig
.
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.
tcHsPatSigType :: UserTypeCtxt -> HoleMode -> HsPatSigType GhcRn -> ContextKind -> TcM ([(Name, TcTyVar)], [(Name, TcTyVar)], TcType) Source #
Instances
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 -> TcM a -> TcM a Source #
Add a "In the data declaration for T" or some such.