TcHsType

ghc-8.8.0.20190721: 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)
- 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 :: forall a. Maybe (DerivStrategy GhcRn) -> TcM ([TyVar], a) -> TcM (Maybe (DerivStrategy GhcTc), [TyVar], a)
- tcHsTypeApp :: LHsWcType GhcRn -> Kind -> TcM Type
- data UserTypeCtxt
  - = FunSigCtxt Name Bool
  - | InfSigCtxt Name
  - | ExprSigCtxt
  - | KindSigCtxt
  - | 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]
- kcLHsQTyVars :: Name -> TyConFlavour -> Bool -> LHsQTyVars GhcRn -> TcM Kind -> TcM TcTyCon
- tcWildCardBinders :: [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 -> TcKind -> [LHsTypeArg GhcRn] -> TcM (TcType, TcKind)
- failIfEmitsConstraints :: TcM a -> TcM a
- solveEqualities :: TcM a -> TcM a
- typeLevelMode :: TcTyMode
- kindLevelMode :: TcTyMode
- kindGeneralize :: TcType -> TcM [KindVar]
- checkExpectedKind :: HasDebugCallStack => RequireSaturation -> SDoc -> TcType -> TcKind -> TcKind -> TcM TcType
- data RequireSaturation
  - = YesSaturation
  - | NoSaturation
- reportFloatingKvs :: Name -> TyConFlavour -> [TcTyVar] -> [TcTyVar] -> TcM ()
- tcLHsKindSig :: UserTypeCtxt -> LHsKind GhcRn -> TcM Kind
- badKindSig :: Bool -> Kind -> SDoc
- zonkPromoteType :: TcType -> TcM TcType
- 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 () Source #

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

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

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

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

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

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

tcDerivStrategy Source #

Arguments

:: forall a. Maybe (DerivStrategy GhcRn) | The deriving strategy
-> TcM ([TyVar], a) | The thing to typecheck within the context of the deriving strategy, which might quantify some type variables of its own.
-> TcM (Maybe (DerivStrategy GhcTc), [TyVar], a) | The typechecked deriving strategy, all quantified tyvars, and the payload of the typechecked thing.

Typecheck something within the context of a deriving strategy. This is of particular importance when the deriving strategy is `via`. For instance:

    deriving via (S a) instance C (T a)

We need to typecheck `S a`, and moreover, we need to extend the tyvar environment with `a` before typechecking `C (T a)`, since `S a` quantified the type variable `a`.

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

Type-check a visible type application

data UserTypeCtxt Source #

Constructors

FunSigCtxt Name Bool |
InfSigCtxt Name |
ExprSigCtxt |
KindSigCtxt |
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) Source #

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

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

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

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

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

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

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

data ContextKind Source #

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

bindTyClTyVars :: Name -> ([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 #

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

kcLHsQTyVars Source #

Arguments

:: Name | of the thing being checked
-> TyConFlavour | What sort of `TyCon` is being checked
-> Bool | True = the decl being checked has a CUSK
-> LHsQTyVars GhcRn |
-> TcM Kind | The result kind
-> TcM TcTyCon | A suitably-kinded TcTyCon

Kind-check a `LHsQTyVars`. If the decl under consideration has a complete, user-supplied kind signature (CUSK), generalise the result. Used in `getInitialKind` (for tycon kinds and other kinds) and in kind-checking (but not for tycon kinds, which are checked with tcTyClDecls). See Note [CUSKs: complete user-supplied kind signatures] in HsDecls.

This function does not do telescope checking.

tcWildCardBinders :: [Name] -> ([(Name, TcTyVar)] -> TcM a) -> TcM a 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 #

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

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

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

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

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

tcLHsPredType :: LHsType GhcRn -> TcM PredType Source #

tcInferApps Source #

Arguments

:: TcTyMode |
-> LHsType GhcRn | Function (for printing only)
-> TcType | Function
-> TcKind | Function kind (zonked)
-> [LHsTypeArg GhcRn] | Args
-> TcM (TcType, TcKind) | (f args, args, result kind) Precondition: tcTypeKind fun_ty = fun_ki Reason: we will return a type application like (fun_ty arg1 ... argn), and that type must be well-kinded See Note [The tcType invariant] Postcondition: Result kind is zonked.

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.

failIfEmitsConstraints :: TcM a -> TcM a Source #

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)

typeLevelMode :: TcTyMode Source #

kindLevelMode :: TcTyMode Source #

kindGeneralize :: TcType -> TcM [KindVar] Source #

checkExpectedKind Source #

Arguments

:: HasDebugCallStack |
=> RequireSaturation | Do we require all type families to be saturated?
-> SDoc | type we're checking (for printing)
-> TcType | type we're checking
-> TcKind | the known kind of that type
-> TcKind | the expected kind
-> TcM TcType |

This instantiates invisible arguments for the type being checked if it must be saturated and is not yet saturated. It then calls and uses the result from checkExpectedKindX to build the final type Obeys Note [The tcType invariant]

data RequireSaturation Source #

Do we require type families to be saturated?

Constructors

YesSaturation |
NoSaturation |

#### Instances

Instances details

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

reportFloatingKvs :: Name -> TyConFlavour -> [TcTyVar] -> [TcTyVar] -> TcM () Source #

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

badKindSig :: Bool -> Kind -> SDoc Source #

zonkPromoteType :: TcType -> TcM TcType Source #

Whenever a type is about to be added to the environment, it's necessary to make sure that any free meta-tyvars in the type are promoted to the current TcLevel. (They might be at a higher level due to the level-bumping in tcExplicitTKBndrs, for example.) This function both zonks *and* promotes. Why at the same time? See Note [Recipe for checking a signature]

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

tcPatSig :: Bool -> LHsSigWcType GhcRn -> ExpSigmaType -> TcM (TcType, [(Name, TcTyVar)], [(Name, TcTyVar)], HsWrapper) 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 -> TcM a -> TcM a Source #

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