TcHsType

ghc-8.10.3: The GHC API

Safe Haskell | None
Language | Haskell2010

TcHsType

Synopsis

- kcClassSigType :: SkolemInfo -> [Located Name] -> LHsSigType GhcRn -> TcM ()
- tcClassSigType :: SkolemInfo -> [Located 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, TcTyVar)], TcThetaType, TcType)
- tcStandaloneKindSig :: LStandaloneKindSig GhcRn -> TcM (Name, Kind)
- funsSigCtxt :: [Located Name] -> UserTypeCtxt
- addSigCtxt :: UserTypeCtxt -> LHsType GhcRn -> TcM a -> TcM a
- pprSigCtxt :: UserTypeCtxt -> LHsType GhcRn -> 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
  - | ResSigCtxt
  - | ForSigCtxt Name
  - | DefaultDeclCtxt
  - | InstDeclCtxt Bool
  - | SpecInstCtxt
  - | ThBrackCtxt
  - | 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 :: [LHsTyVarBndr GhcRn] -> TcM a -> TcM ([TcTyVar], a)
- bindExplicitTKBndrs_Skol :: [LHsTyVarBndr GhcRn] -> TcM a -> TcM ([TcTyVar], a)
- bindExplicitTKBndrs_Q_Tv :: ContextKind -> [LHsTyVarBndr GhcRn] -> TcM a -> TcM ([TcTyVar], a)
- bindExplicitTKBndrs_Q_Skol :: ContextKind -> [LHsTyVarBndr GhcRn] -> TcM a -> TcM ([TcTyVar], a)
- data ContextKind
  - = TheKind Kind
  - | AnyKind
  - | OpenKind
- kcLookupTcTyCon :: Name -> TcM TcTyCon
- bindTyClTyVars :: Name -> ([TyConBinder] -> Kind -> TcM a) -> TcM a
- etaExpandAlgTyCon :: [TyConBinder] -> Kind -> TcM ([TyConBinder], Kind)
- tcbVisibilities :: TyCon -> [Type] -> [TyConBndrVis]
- zonkAndScopedSort :: [TcTyVar] -> TcM [TcTyVar]
- data InitialKindStrategy
  - = InitialKindCheck SAKS_or_CUSK
  - | InitialKindInfer
- data SAKS_or_CUSK
  - = SAKS Kind
  - | CUSK
- kcDeclHeader :: InitialKindStrategy -> Name -> TyConFlavour -> LHsQTyVars GhcRn -> TcM ContextKind -> TcM TcTyCon
- tcNamedWildCardBinders :: [Name] -> ([(Name, TcTyVar)] -> TcM a) -> TcM a
- tcHsLiftedType :: LHsType GhcRn -> TcM TcType
- tcHsOpenType :: LHsType GhcRn -> TcM TcType
- tcHsLiftedTypeNC :: LHsType GhcRn -> TcM TcType
- tcHsOpenTypeNC :: LHsType GhcRn -> TcM TcType
- tcLHsType :: LHsType GhcRn -> TcM (TcType, TcKind)
- tcLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind)
- tcCheckLHsType :: LHsType GhcRn -> Kind -> TcM TcType
- tcHsMbContext :: Maybe (LHsContext GhcRn) -> TcM [PredType]
- tcHsContext :: LHsContext GhcRn -> TcM [PredType]
- tcLHsPredType :: LHsType GhcRn -> TcM PredType
- tcInferApps :: TcTyMode -> LHsType GhcRn -> TcType -> [LHsTypeArg GhcRn] -> TcM (TcType, TcKind)
- failIfEmitsConstraints :: TcM a -> TcM a
- solveEqualities :: TcM a -> TcM a
- typeLevelMode :: TcTyMode
- kindLevelMode :: TcTyMode
- kindGeneralizeAll :: TcType -> TcM [KindVar]
- kindGeneralizeSome :: (TcTyVar -> Bool) -> TcType -> TcM [KindVar]
- kindGeneralizeNone :: TcType -> TcM ()
- checkExpectedKind_pp :: HasDebugCallStack => SDoc -> TcType -> TcKind -> TcKind -> TcM TcType
- tcLHsKindSig :: UserTypeCtxt -> LHsKind GhcRn -> TcM Kind
- checkDataKindSig :: DataSort -> Kind -> TcM ()
- data DataSort
  - = DataDeclSort NewOrData
  - | DataInstanceSort NewOrData
  - | DataFamilySort
- checkClassKindSig :: Kind -> TcM ()
- tcHsPatSigType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM ([(Name, TcTyVar)], [(Name, TcTyVar)], TcType)
- tcPatSig :: Bool -> LHsSigWcType GhcRn -> ExpSigmaType -> TcM (TcType, [(Name, TcTyVar)], [(Name, TcTyVar)], HsWrapper)
- funAppCtxt :: (Outputable fun, Outputable arg) => fun -> arg -> Int -> SDoc
- addTyConFlavCtxt :: Name -> TyConFlavour -> TcM a -> TcM a

# Documentation

kcClassSigType :: SkolemInfo -> [Located Name] -> LHsSigType GhcRn -> TcM () #

tcClassSigType :: SkolemInfo -> [Located 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, TcTyVar)], TcThetaType, TcType) #

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

funsSigCtxt :: [Located Name] -> UserTypeCtxt #

addSigCtxt :: UserTypeCtxt -> LHsType GhcRn -> TcM a -> TcM a #

pprSigCtxt :: UserTypeCtxt -> LHsType GhcRn -> SDoc #

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

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

tcDerivStrategy #

Arguments

:: Maybe (LDerivStrategy GhcRn) | The deriving strategy
-> TcM (Maybe (LDerivStrategy GhcTc), [TyVar]) | 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 #

Type-check a visible type application

data UserTypeCtxt #

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

Constructors

FunSigCtxt Name Bool |
InfSigCtxt Name |
ExprSigCtxt |
KindSigCtxt |
StandaloneKindSigCtxt Name |
TypeAppCtxt |
ConArgCtxt Name |
TySynCtxt Name |
PatSynCtxt Name |
PatSigCtxt |
RuleSigCtxt Name |
ResSigCtxt |
ForSigCtxt Name |
DefaultDeclCtxt |
InstDeclCtxt Bool |
SpecInstCtxt |
ThBrackCtxt |
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 :: [LHsTyVarBndr GhcRn] -> TcM a -> TcM ([TcTyVar], a) #

bindExplicitTKBndrs_Skol :: [LHsTyVarBndr GhcRn] -> TcM a -> TcM ([TcTyVar], a) #

bindExplicitTKBndrs_Q_Tv :: ContextKind -> [LHsTyVarBndr GhcRn] -> TcM a -> TcM ([TcTyVar], a) #

bindExplicitTKBndrs_Q_Skol :: ContextKind -> [LHsTyVarBndr GhcRn] -> TcM a -> TcM ([TcTyVar], a) #

data ContextKind #

Describes the kind expected in a certain context.

Constructors

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

kcLookupTcTyCon :: Name -> TcM TcTyCon #

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

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) #

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

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

data InitialKindStrategy #

Constructors

InitialKindCheck SAKS_or_CUSK |
InitialKindInfer |

data SAKS_or_CUSK #

Constructors

SAKS Kind |
CUSK |

#### Instances

Instances details

Outputable SAKS_or_CUSK # |
Instance details Defined in TcHsType Methods ppr :: SAKS_or_CUSK -> SDoc # pprPrec :: Rational -> SAKS_or_CUSK -> SDoc #

kcDeclHeader #

Arguments

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

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

tcHsLiftedType :: LHsType GhcRn -> TcM TcType #

tcHsOpenType :: LHsType GhcRn -> TcM TcType #

tcHsLiftedTypeNC :: LHsType GhcRn -> TcM TcType #

tcHsOpenTypeNC :: LHsType GhcRn -> TcM TcType #

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

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

tcCheckLHsType :: LHsType GhcRn -> Kind -> TcM TcType #

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

tcHsContext :: LHsContext GhcRn -> TcM [PredType] #

tcLHsPredType :: LHsType GhcRn -> TcM PredType #

tcInferApps #

Arguments

:: TcTyMode |
-> LHsType GhcRn | Function (for printing only)
-> TcType | Function
-> [LHsTypeArg GhcRn] | Args
-> TcM (TcType, TcKind) | (f args, args, result kind)

Apply a type of a given kind to a list of arguments. This instantiates invisible parameters as necessary. Always consumes all the arguments, using matchExpectedFunKind as necessary. This takes an optional `VarEnv Kind` which maps kind variables to kinds.- These kinds should be used to instantiate invisible kind variables; they come from an enclosing class for an associated type/data family.

tcInferApps also arranges to saturate any trailing invisible arguments of a type-family application, which is usually the right thing to do tcInferApps_nosat does not do this saturation; it is used only by ":kind" in GHCi

failIfEmitsConstraints :: TcM a -> TcM a #

If the inner action emits constraints, report them as errors and fail; otherwise, propagates the return value. Useful as a wrapper around `tcImplicitTKBndrs`, which uses solveLocalEqualities, when there won't be another chance to solve constraints

solveEqualities :: TcM a -> TcM a #

Type-check a thing that emits only equality constraints, then solve those constraints. Fails outright if there is trouble. Use this if you're not going to get another crack at solving (because, e.g., you're checking a datatype declaration)

typeLevelMode :: TcTyMode #

kindLevelMode :: TcTyMode #

kindGeneralizeAll :: TcType -> TcM [KindVar] #

Specialized version of `kindGeneralizeSome`, but where all variables can be generalized. Use this variant when you can be sure that no more constraints on the type's metavariables will arise or be solved.

kindGeneralizeSome #

Arguments

:: (TcTyVar -> Bool) |
-> 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 supplied predicate says which free variables to quantify. 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 TcSimplify 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 () #

Specialized version of `kindGeneralizeSome`, but where no variables can be generalized, but perhaps some may neeed 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].

checkExpectedKind_pp #

Arguments

:: HasDebugCallStack |
=> SDoc | The thing we are checking
-> TcType | type we're checking
-> TcKind | the known kind of that type
-> TcKind | the expected kind
-> TcM TcType |

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

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

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 TcTyClsDecls.

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)

data DataSort #

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 () #

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 -> LHsSigWcType GhcRn -> TcM ([(Name, TcTyVar)], [(Name, TcTyVar)], TcType) #

tcPatSig :: Bool -> LHsSigWcType GhcRn -> ExpSigmaType -> TcM (TcType, [(Name, TcTyVar)], [(Name, TcTyVar)], HsWrapper) #

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

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

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

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