TcMType

ghc-8.8.4: The GHC API

Safe Haskell | None
Language | Haskell2010

TcMType

Synopsis

- type TcTyVar = Var
- type TcKind = Kind
- type TcType = Type
- type TcTauType = TcType
- type TcThetaType = ThetaType
- type TcTyVarSet = TyVarSet
- newFlexiTyVar :: Kind -> TcM TcTyVar
- newFlexiTyVarTy :: Kind -> TcM TcType
- newFlexiTyVarTys :: Int -> Kind -> TcM [TcType]
- newOpenFlexiTyVarTy :: TcM TcType
- newOpenTypeKind :: TcM TcKind
- newMetaKindVar :: TcM TcKind
- newMetaKindVars :: Int -> TcM [TcKind]
- newMetaTyVarTyAtLevel :: TcLevel -> TcKind -> TcM TcType
- cloneMetaTyVar :: TcTyVar -> TcM TcTyVar
- newFmvTyVar :: TcType -> TcM TcTyVar
- newFskTyVar :: TcType -> TcM TcTyVar
- readMetaTyVar :: TyVar -> TcM MetaDetails
- writeMetaTyVar :: TcTyVar -> TcType -> TcM ()
- writeMetaTyVarRef :: TcTyVar -> TcRef MetaDetails -> TcType -> TcM ()
- newMetaDetails :: MetaInfo -> TcM TcTyVarDetails
- isFilledMetaTyVar_maybe :: TcTyVar -> TcM (Maybe Type)
- isFilledMetaTyVar :: TyVar -> TcM Bool
- isUnfilledMetaTyVar :: TyVar -> TcM Bool
- data ExpType
  - = Check TcType
  - | Infer !InferResult
- type ExpSigmaType = ExpType
- type ExpRhoType = ExpType
- mkCheckExpType :: TcType -> ExpType
- newInferExpType :: Bool -> TcM ExpType
- newInferExpTypeInst :: TcM ExpRhoType
- newInferExpTypeNoInst :: TcM ExpSigmaType
- readExpType :: ExpType -> TcM TcType
- readExpType_maybe :: ExpType -> TcM (Maybe TcType)
- expTypeToType :: ExpType -> TcM TcType
- checkingExpType_maybe :: ExpType -> Maybe TcType
- checkingExpType :: String -> ExpType -> TcType
- tauifyExpType :: ExpType -> TcM ExpType
- inferResultToType :: InferResult -> TcM Type
- newEvVar :: TcPredType -> TcRnIf gbl lcl EvVar
- newEvVars :: TcThetaType -> TcM [EvVar]
- newDict :: Class -> [TcType] -> TcM DictId
- newWanted :: CtOrigin -> Maybe TypeOrKind -> PredType -> TcM CtEvidence
- newWanteds :: CtOrigin -> ThetaType -> TcM [CtEvidence]
- newHoleCt :: Hole -> Id -> Type -> TcM Ct
- cloneWanted :: Ct -> TcM Ct
- cloneWC :: WantedConstraints -> TcM WantedConstraints
- emitWanted :: CtOrigin -> TcPredType -> TcM EvTerm
- emitWantedEq :: CtOrigin -> TypeOrKind -> Role -> TcType -> TcType -> TcM Coercion
- emitWantedEvVar :: CtOrigin -> TcPredType -> TcM EvVar
- emitWantedEvVars :: CtOrigin -> [TcPredType] -> TcM [EvVar]
- emitDerivedEqs :: CtOrigin -> [(TcType, TcType)] -> TcM ()
- newTcEvBinds :: TcM EvBindsVar
- newNoTcEvBinds :: TcM EvBindsVar
- addTcEvBind :: EvBindsVar -> EvBind -> TcM ()
- newCoercionHole :: TcPredType -> TcM CoercionHole
- fillCoercionHole :: CoercionHole -> Coercion -> TcM ()
- isFilledCoercionHole :: CoercionHole -> TcM Bool
- unpackCoercionHole :: CoercionHole -> TcM Coercion
- unpackCoercionHole_maybe :: CoercionHole -> TcM (Maybe Coercion)
- checkCoercionHole :: CoVar -> Coercion -> TcM Coercion
- newMetaTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar])
- newMetaTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar)
- newMetaTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar])
- newMetaTyVarTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar])
- newMetaTyVarTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar)
- newTyVarTyVar :: Name -> Kind -> TcM TcTyVar
- newTauTyVar :: Name -> Kind -> TcM TcTyVar
- newSkolemTyVar :: Name -> Kind -> TcM TcTyVar
- newWildCardX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar)
- tcInstType :: ([TyVar] -> TcM (TCvSubst, [TcTyVar])) -> Id -> TcM ([(Name, TcTyVar)], TcThetaType, TcType)
- tcInstSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar])
- tcInstSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar])
- tcInstSkolTyVarsAt :: TcLevel -> Bool -> TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar])
- tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType)
- tcSuperSkolTyVars :: [TyVar] -> (TCvSubst, [TcTyVar])
- tcInstSuperSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar])
- freshenTyVarBndrs :: [TyVar] -> TcM (TCvSubst, [TyVar])
- freshenCoVarBndrsX :: TCvSubst -> [CoVar] -> TcM (TCvSubst, [CoVar])
- zonkTidyTcType :: TidyEnv -> TcType -> TcM (TidyEnv, TcType)
- zonkTidyTcTypes :: TidyEnv -> [TcType] -> TcM (TidyEnv, [TcType])
- zonkTidyOrigin :: TidyEnv -> CtOrigin -> TcM (TidyEnv, CtOrigin)
- tidyEvVar :: TidyEnv -> EvVar -> EvVar
- tidyCt :: TidyEnv -> Ct -> Ct
- tidySkolemInfo :: TidyEnv -> SkolemInfo -> SkolemInfo
- zonkTcTyVar :: TcTyVar -> TcM TcType
- zonkTcTyVars :: [TcTyVar] -> TcM [TcType]
- zonkTcTyVarToTyVar :: HasDebugCallStack => TcTyVar -> TcM TcTyVar
- zonkTyVarTyVarPairs :: [(Name, TcTyVar)] -> TcM [(Name, TcTyVar)]
- zonkTyCoVarsAndFV :: TyCoVarSet -> TcM TyCoVarSet
- zonkTcTypeAndFV :: TcType -> TcM DTyCoVarSet
- zonkTyCoVarsAndFVList :: [TyCoVar] -> TcM [TyCoVar]
- candidateQTyVarsOfType :: TcType -> TcM CandidatesQTvs
- candidateQTyVarsOfKind :: TcKind -> TcM CandidatesQTvs
- candidateQTyVarsOfTypes :: [Type] -> TcM CandidatesQTvs
- candidateQTyVarsOfKinds :: [TcKind] -> TcM CandidatesQTvs
- data CandidatesQTvs = DV {
  - dv_kvs :: DTyVarSet
  - dv_tvs :: DTyVarSet
  - dv_cvs :: CoVarSet
  }
- delCandidates :: CandidatesQTvs -> [Var] -> CandidatesQTvs
- candidateKindVars :: CandidatesQTvs -> TyVarSet
- skolemiseQuantifiedTyVar :: TcTyVar -> TcM TcTyVar
- defaultTyVar :: Bool -> TcTyVar -> TcM Bool
- quantifyTyVars :: TcTyCoVarSet -> CandidatesQTvs -> TcM [TcTyVar]
- zonkTcTyCoVarBndr :: TcTyCoVar -> TcM TcTyCoVar
- zonkTyConBinders :: [TyConBinder] -> TcM [TyConBinder]
- zonkTcType :: TcType -> TcM TcType
- zonkTcTypes :: [TcType] -> TcM [TcType]
- zonkCo :: Coercion -> TcM Coercion
- zonkTyCoVarKind :: TyCoVar -> TcM TyCoVar
- zonkEvVar :: EvVar -> TcM EvVar
- zonkWC :: WantedConstraints -> TcM WantedConstraints
- zonkSimples :: Cts -> TcM Cts
- zonkId :: TcId -> TcM TcId
- zonkCoVar :: CoVar -> TcM CoVar
- zonkCt :: Ct -> TcM Ct
- zonkSkolemInfo :: SkolemInfo -> TcM SkolemInfo
- tcGetGlobalTyCoVars :: TcM TcTyVarSet
- ensureNotLevPoly :: Type -> SDoc -> TcM ()
- checkForLevPoly :: SDoc -> Type -> TcM ()
- checkForLevPolyX :: Monad m => (SDoc -> m ()) -> SDoc -> Type -> m ()
- formatLevPolyErr :: Type -> SDoc

# Documentation

type TcTyVar = Var Source #

Type variable that might be a metavariable

type TcKind = Kind Source #

type TcType = Type Source #

type TcTauType = TcType Source #

type TcThetaType = ThetaType Source #

type TcTyVarSet = TyVarSet Source #

newFlexiTyVar :: Kind -> TcM TcTyVar Source #

newFlexiTyVarTy :: Kind -> TcM TcType Source #

newFlexiTyVarTys :: Int -> Kind -> TcM [TcType] Source #

newOpenFlexiTyVarTy :: TcM TcType Source #

Create a tyvar that can be a lifted or unlifted type. Returns alpha :: TYPE kappa, where both alpha and kappa are fresh

newOpenTypeKind :: TcM TcKind Source #

newMetaKindVar :: TcM TcKind Source #

newMetaKindVars :: Int -> TcM [TcKind] Source #

newMetaTyVarTyAtLevel :: TcLevel -> TcKind -> TcM TcType Source #

cloneMetaTyVar :: TcTyVar -> TcM TcTyVar Source #

newFmvTyVar :: TcType -> TcM TcTyVar Source #

newFskTyVar :: TcType -> TcM TcTyVar Source #

readMetaTyVar :: TyVar -> TcM MetaDetails Source #

writeMetaTyVar :: TcTyVar -> TcType -> TcM () Source #

writeMetaTyVarRef :: TcTyVar -> TcRef MetaDetails -> TcType -> TcM () Source #

newMetaDetails :: MetaInfo -> TcM TcTyVarDetails Source #

isFilledMetaTyVar_maybe :: TcTyVar -> TcM (Maybe Type) Source #

isFilledMetaTyVar :: TyVar -> TcM Bool Source #

isUnfilledMetaTyVar :: TyVar -> TcM Bool Source #

data ExpType Source #

An expected type to check against during type-checking. See Note [ExpType] in TcMType, where you'll also find manipulators.

Constructors

Check TcType |
Infer !InferResult |

#### Instances

Instances details

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

type ExpSigmaType = ExpType Source #

type ExpRhoType = ExpType Source #

mkCheckExpType :: TcType -> ExpType Source #

Make an `ExpType` suitable for checking.

newInferExpType :: Bool -> TcM ExpType Source #

newInferExpTypeInst :: TcM ExpRhoType Source #

newInferExpTypeNoInst :: TcM ExpSigmaType Source #

Make an `ExpType` suitable for inferring a type of kind * or #.

readExpType :: ExpType -> TcM TcType Source #

Extract a type out of an ExpType. Otherwise, panics.

readExpType_maybe :: ExpType -> TcM (Maybe TcType) Source #

Extract a type out of an ExpType, if one exists. But one should always exist. Unless you're quite sure you know what you're doing.

expTypeToType :: ExpType -> TcM TcType Source #

Extracts the expected type if there is one, or generates a new TauTv if there isn't.

checkingExpType_maybe :: ExpType -> Maybe TcType Source #

Returns the expected type when in checking mode.

checkingExpType :: String -> ExpType -> TcType Source #

Returns the expected type when in checking mode. Panics if in inference mode.

tauifyExpType :: ExpType -> TcM ExpType Source #

Turn a (Infer hole) type into a (Check alpha), where alpha is a fresh unification variable

inferResultToType :: InferResult -> TcM Type Source #

newEvVar :: TcPredType -> TcRnIf gbl lcl EvVar Source #

newEvVars :: TcThetaType -> TcM [EvVar] Source #

newDict :: Class -> [TcType] -> TcM DictId Source #

newWanted :: CtOrigin -> Maybe TypeOrKind -> PredType -> TcM CtEvidence Source #

newWanteds :: CtOrigin -> ThetaType -> TcM [CtEvidence] Source #

newHoleCt :: Hole -> Id -> Type -> TcM Ct Source #

Create a new `CHoleCan` `Ct`.

cloneWanted :: Ct -> TcM Ct Source #

cloneWC :: WantedConstraints -> TcM WantedConstraints Source #

emitWanted :: CtOrigin -> TcPredType -> TcM EvTerm Source #

Emits a new Wanted. Deals with both equalities and non-equalities.

emitWantedEq :: CtOrigin -> TypeOrKind -> Role -> TcType -> TcType -> TcM Coercion Source #

Emits a new equality constraint

emitWantedEvVar :: CtOrigin -> TcPredType -> TcM EvVar Source #

Creates a new EvVar and immediately emits it as a Wanted. No equality predicates here.

emitWantedEvVars :: CtOrigin -> [TcPredType] -> TcM [EvVar] Source #

emitDerivedEqs :: CtOrigin -> [(TcType, TcType)] -> TcM () Source #

newTcEvBinds :: TcM EvBindsVar Source #

newNoTcEvBinds :: TcM EvBindsVar Source #

Creates an EvBindsVar incapable of holding any bindings. It still tracks covar usages (see comments on ebv_tcvs in TcEvidence), thus must be made monadically

addTcEvBind :: EvBindsVar -> EvBind -> TcM () Source #

newCoercionHole :: TcPredType -> TcM CoercionHole Source #

fillCoercionHole :: CoercionHole -> Coercion -> TcM () Source #

Put a value in a coercion hole

isFilledCoercionHole :: CoercionHole -> TcM Bool Source #

Is a coercion hole filled in?

unpackCoercionHole :: CoercionHole -> TcM Coercion Source #

Retrieve the contents of a coercion hole. Panics if the hole is unfilled

unpackCoercionHole_maybe :: CoercionHole -> TcM (Maybe Coercion) Source #

Retrieve the contents of a coercion hole, if it is filled

checkCoercionHole :: CoVar -> Coercion -> TcM Coercion Source #

Check that a coercion is appropriate for filling a hole. (The hole itself is needed only for printing. Always returns the checked coercion, but this return value is necessary so that the input coercion is forced only when the output is forced.

newMetaTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) Source #

newMetaTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) Source #

newMetaTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) Source #

newMetaTyVarTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) Source #

newMetaTyVarTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) Source #

newTyVarTyVar :: Name -> Kind -> TcM TcTyVar Source #

newTauTyVar :: Name -> Kind -> TcM TcTyVar Source #

newSkolemTyVar :: Name -> Kind -> TcM TcTyVar Source #

newWildCardX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) Source #

tcInstType Source #

Arguments

:: ([TyVar] -> TcM (TCvSubst, [TcTyVar])) | How to instantiate the type variables
-> Id | Type to instantiate
-> TcM ([(Name, TcTyVar)], TcThetaType, TcType) | Result (type vars, preds (incl equalities), rho)

tcInstSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) Source #

Given a list of `[`TyVar`]`, skolemize the type variables, returning a substitution mapping the original tyvars to the skolems, and the list of newly bound skolems.

tcInstSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) Source #

tcInstSkolTyVarsAt :: TcLevel -> Bool -> TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) Source #

tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType) Source #

tcSuperSkolTyVars :: [TyVar] -> (TCvSubst, [TcTyVar]) Source #

tcInstSuperSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) Source #

freshenTyVarBndrs :: [TyVar] -> TcM (TCvSubst, [TyVar]) Source #

Give fresh uniques to a bunch of TyVars, but they stay as TyVars, rather than becoming TcTyVars Used in FamInst.newFamInst, and Inst.newClsInst

freshenCoVarBndrsX :: TCvSubst -> [CoVar] -> TcM (TCvSubst, [CoVar]) Source #

Give fresh uniques to a bunch of CoVars Used in FamInst.newFamInst

zonkTidyTcType :: TidyEnv -> TcType -> TcM (TidyEnv, TcType) Source #

zonkTidyTcTypes :: TidyEnv -> [TcType] -> TcM (TidyEnv, [TcType]) Source #

zonkTidyOrigin :: TidyEnv -> CtOrigin -> TcM (TidyEnv, CtOrigin) Source #

tidyEvVar :: TidyEnv -> EvVar -> EvVar Source #

tidyCt :: TidyEnv -> Ct -> Ct Source #

tidySkolemInfo :: TidyEnv -> SkolemInfo -> SkolemInfo Source #

zonkTcTyVar :: TcTyVar -> TcM TcType Source #

zonkTcTyVars :: [TcTyVar] -> TcM [TcType] Source #

zonkTcTyVarToTyVar :: HasDebugCallStack => TcTyVar -> TcM TcTyVar Source #

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

zonkTyCoVarsAndFV :: TyCoVarSet -> TcM TyCoVarSet Source #

zonkTcTypeAndFV :: TcType -> TcM DTyCoVarSet Source #

zonkTyCoVarsAndFVList :: [TyCoVar] -> TcM [TyCoVar] Source #

candidateQTyVarsOfType :: TcType -> TcM CandidatesQTvs Source #

Gathers free variables to use as quantification candidates (in `quantifyTyVars`). This might output the same var in both sets, if it's used in both a type and a kind. The variables to quantify must have a TcLevel strictly greater than the ambient level. (See Wrinkle in Note [Naughty quantification candidates]) See Note [CandidatesQTvs determinism and order] See Note [Dependent type variables]

candidateQTyVarsOfKind :: TcKind -> TcM CandidatesQTvs Source #

Like `candidateQTyVarsOfType`, but consider every free variable to be dependent. This is appropriate when generalizing a *kind*, instead of a type. (That way, -XNoPolyKinds will default the variables to Type.)

candidateQTyVarsOfTypes :: [Type] -> TcM CandidatesQTvs Source #

Like `candidateQTyVarsOfType`, but over a list of types The variables to quantify must have a TcLevel strictly greater than the ambient level. (See Wrinkle in Note [Naughty quantification candidates])

candidateQTyVarsOfKinds :: [TcKind] -> TcM CandidatesQTvs Source #

data CandidatesQTvs Source #

Constructors

DV |
Fields dv_kvs :: DTyVarSet dv_tvs :: DTyVarSet dv_cvs :: CoVarSet

#### Instances

Instances details

Semigroup CandidatesQTvs # |
Instance details Defined in TcMType Methods (<>) :: CandidatesQTvs -> CandidatesQTvs -> CandidatesQTvs Source # sconcat :: NonEmpty CandidatesQTvs -> CandidatesQTvs Source # stimes :: Integral b => b -> CandidatesQTvs -> CandidatesQTvs Source #
Monoid CandidatesQTvs # |
Instance details Defined in TcMType Methods mempty :: CandidatesQTvs Source # mappend :: CandidatesQTvs -> CandidatesQTvs -> CandidatesQTvs Source # mconcat :: [CandidatesQTvs] -> CandidatesQTvs Source #
Outputable CandidatesQTvs # |
Instance details Defined in TcMType Methods ppr :: CandidatesQTvs -> SDoc Source # pprPrec :: Rational -> CandidatesQTvs -> SDoc Source #

delCandidates :: CandidatesQTvs -> [Var] -> CandidatesQTvs Source #

candidateKindVars :: CandidatesQTvs -> TyVarSet Source #

skolemiseQuantifiedTyVar :: TcTyVar -> TcM TcTyVar Source #

defaultTyVar :: Bool -> TcTyVar -> TcM Bool Source #

quantifyTyVars :: TcTyCoVarSet -> CandidatesQTvs -> TcM [TcTyVar] Source #

zonkTcTyCoVarBndr :: TcTyCoVar -> TcM TcTyCoVar Source #

zonkTyConBinders :: [TyConBinder] -> TcM [TyConBinder] Source #

zonkTcType :: TcType -> TcM TcType Source #

zonkTcTypes :: [TcType] -> TcM [TcType] Source #

zonkCo :: Coercion -> TcM Coercion Source #

Zonk a coercion -- really, just zonk any types in the coercion

zonkTyCoVarKind :: TyCoVar -> TcM TyCoVar Source #

zonkEvVar :: EvVar -> TcM EvVar Source #

zonkWC :: WantedConstraints -> TcM WantedConstraints Source #

zonkSimples :: Cts -> TcM Cts Source #

zonkId :: TcId -> TcM TcId Source #

zonkCoVar :: CoVar -> TcM CoVar Source #

zonkCt :: Ct -> TcM Ct Source #

zonkSkolemInfo :: SkolemInfo -> TcM SkolemInfo Source #

tcGetGlobalTyCoVars :: TcM TcTyVarSet Source #

`tcGetGlobalTyCoVars` returns a fully-zonked set of *scoped* tyvars free in the environment. To improve subsequent calls to the same function it writes the zonked set back into the environment. Note that this returns all variables free in anything (term-level or type-level) in scope. We thus don't have to worry about clashes with things that are not in scope, because if they are reachable, then they'll be returned here. NB: This is closed over kinds, so it can return unification variables mentioned in the kinds of in-scope tyvars.

ensureNotLevPoly :: Type -> SDoc -> TcM () Source #

According to the rules around representation polymorphism (see https://ghc.haskell.org/trac/ghc/wiki/NoSubKinds), no binder can have a representation-polymorphic type. This check ensures that we respect this rule. It is a bit regrettable that this error occurs in zonking, after which we should have reported all errors. But it's hard to see where else to do it, because this can be discovered only after all solving is done. And, perhaps most importantly, this isn't really a compositional property of a type system, so it's not a terrible surprise that the check has to go in an awkward spot.

checkForLevPoly :: SDoc -> Type -> TcM () Source #

checkForLevPolyX :: Monad m => (SDoc -> m ()) -> SDoc -> Type -> m () Source #

formatLevPolyErr :: Type -> SDoc Source #