ghc-9.0.2: The GHC API

GHC.Tc.Gen.HsType

Description

Typechecking user-specified MonoTypes

Synopsis

# Documentation

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.

Type-check a visible type application

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

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 _

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.

Constructors

 InitialKindCheck SAKS_or_CUSK InitialKindInfer

Constructors

 SAKS Kind CUSK

#### Instances

Instances details
 Source # Instance detailsDefined in GHC.Tc.Gen.HsType Methods

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

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

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)

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.

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

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

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)

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

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