Safe Haskell | None |
---|---|
Language | Haskell2010 |
GHC.Tc.Utils.TcType
Description
Types used in the typechecker
This module provides the Type interface for front-end parts of the compiler. These parts
- treat "source types" as opaque: newtypes, and predicates are meaningful.
- look through usage types
Synopsis
- type TcType = Type
- type TcSigmaType = TcType
- type TcRhoType = TcType
- type TcTauType = TcType
- type TcPredType = PredType
- type TcThetaType = ThetaType
- type TcTyVar = Var
- type TcTyVarSet = TyVarSet
- type TcDTyVarSet = DTyVarSet
- type TcTyCoVarSet = TyCoVarSet
- type TcDTyCoVarSet = DTyCoVarSet
- type TcKind = Kind
- type TcCoVar = CoVar
- type TcTyCoVar = Var
- type TcTyVarBinder = TyVarBinder
- type TcInvisTVBinder = InvisTVBinder
- type TcReqTVBinder = ReqTVBinder
- type TcTyCon = TyCon
- type KnotTied ty = ty
- data ExpType
- = Check TcType
- | Infer !InferResult
- data InferResult = IR {}
- type ExpSigmaType = ExpType
- type ExpRhoType = ExpType
- mkCheckExpType :: TcType -> ExpType
- data SyntaxOpType
- synKnownType :: TcType -> SyntaxOpType
- mkSynFunTys :: [SyntaxOpType] -> ExpType -> SyntaxOpType
- newtype TcLevel = TcLevel Int
- topTcLevel :: TcLevel
- pushTcLevel :: TcLevel -> TcLevel
- isTopTcLevel :: TcLevel -> Bool
- strictlyDeeperThan :: TcLevel -> TcLevel -> Bool
- sameDepthAs :: TcLevel -> TcLevel -> Bool
- tcTypeLevel :: TcType -> TcLevel
- tcTyVarLevel :: TcTyVar -> TcLevel
- maxTcLevel :: TcLevel -> TcLevel -> TcLevel
- promoteSkolem :: TcLevel -> TcTyVar -> TcTyVar
- promoteSkolemX :: TcLevel -> TCvSubst -> TcTyVar -> (TCvSubst, TcTyVar)
- promoteSkolemsX :: TcLevel -> TCvSubst -> [TcTyVar] -> (TCvSubst, [TcTyVar])
- data TcTyVarDetails
- pprTcTyVarDetails :: TcTyVarDetails -> SDoc
- vanillaSkolemTv :: TcTyVarDetails
- superSkolemTv :: TcTyVarDetails
- data MetaDetails
- data MetaInfo
- = TauTv
- | TyVarTv
- | FlatMetaTv
- | FlatSkolTv
- isImmutableTyVar :: TyVar -> Bool
- isSkolemTyVar :: TcTyVar -> Bool
- isMetaTyVar :: TcTyVar -> Bool
- isMetaTyVarTy :: TcType -> Bool
- isTyVarTy :: Type -> Bool
- tcIsTcTyVar :: TcTyVar -> Bool
- isTyVarTyVar :: Var -> Bool
- isOverlappableTyVar :: TcTyVar -> Bool
- isTyConableTyVar :: TcTyVar -> Bool
- isFskTyVar :: TcTyVar -> Bool
- isFmvTyVar :: TcTyVar -> Bool
- isFlattenTyVar :: TcTyVar -> Bool
- isAmbiguousTyVar :: TcTyVar -> Bool
- metaTyVarRef :: TyVar -> IORef MetaDetails
- metaTyVarInfo :: TcTyVar -> MetaInfo
- isFlexi :: MetaDetails -> Bool
- isIndirect :: MetaDetails -> Bool
- isRuntimeUnkSkol :: TyVar -> Bool
- metaTyVarTcLevel :: TcTyVar -> TcLevel
- setMetaTyVarTcLevel :: TcTyVar -> TcLevel -> TcTyVar
- metaTyVarTcLevel_maybe :: TcTyVar -> Maybe TcLevel
- isTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool
- isFloatedTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool
- findDupTyVarTvs :: [(Name, TcTyVar)] -> [(Name, Name)]
- mkTyVarNamePairs :: [TyVar] -> [(Name, TyVar)]
- mkPhiTy :: [PredType] -> Type -> Type
- mkInfSigmaTy :: [TyCoVar] -> [PredType] -> Type -> Type
- mkSpecSigmaTy :: [TyVar] -> [PredType] -> Type -> Type
- mkSigmaTy :: [TyCoVarBinder] -> [PredType] -> Type -> Type
- mkTcAppTy :: Type -> Type -> Type
- mkTcAppTys :: Type -> [Type] -> Type
- mkTcCastTy :: Type -> Coercion -> Type
- getTyVar :: String -> Type -> TyVar
- tcSplitForAllTy_maybe :: Type -> Maybe (TyVarBinder, Type)
- tcSplitForAllTys :: Type -> ([TyVar], Type)
- tcSplitForAllTysReq :: Type -> ([TcReqTVBinder], Type)
- tcSplitForAllTysInvis :: Type -> ([TcInvisTVBinder], Type)
- tcSplitPiTys :: Type -> ([TyBinder], Type)
- tcSplitPiTy_maybe :: Type -> Maybe (TyBinder, Type)
- tcSplitForAllVarBndrs :: Type -> ([TyVarBinder], Type)
- tcSplitPhiTy :: Type -> (ThetaType, Type)
- tcSplitPredFunTy_maybe :: Type -> Maybe (PredType, Type)
- tcSplitFunTy_maybe :: Type -> Maybe (Scaled Type, Type)
- tcSplitFunTys :: Type -> ([Scaled Type], Type)
- tcFunArgTy :: Type -> Scaled Type
- tcFunResultTy :: Type -> Type
- tcFunResultTyN :: HasDebugCallStack => Arity -> Type -> Type
- tcSplitFunTysN :: Arity -> TcRhoType -> Either Arity ([Scaled TcSigmaType], TcSigmaType)
- tcSplitTyConApp :: Type -> (TyCon, [Type])
- tcSplitTyConApp_maybe :: HasCallStack => Type -> Maybe (TyCon, [Type])
- tcTyConAppTyCon :: Type -> TyCon
- tcTyConAppTyCon_maybe :: Type -> Maybe TyCon
- tcTyConAppArgs :: Type -> [Type]
- tcSplitAppTy_maybe :: Type -> Maybe (Type, Type)
- tcSplitAppTy :: Type -> (Type, Type)
- tcSplitAppTys :: Type -> (Type, [Type])
- tcRepSplitAppTy_maybe :: Type -> Maybe (Type, Type)
- tcRepGetNumAppTys :: Type -> Arity
- tcGetCastedTyVar_maybe :: Type -> Maybe (TyVar, CoercionN)
- tcGetTyVar_maybe :: Type -> Maybe TyVar
- tcGetTyVar :: String -> Type -> TyVar
- tcSplitSigmaTy :: Type -> ([TyVar], ThetaType, Type)
- tcSplitNestedSigmaTys :: Type -> ([TyVar], ThetaType, Type)
- eqType :: Type -> Type -> Bool
- eqTypes :: [Type] -> [Type] -> Bool
- nonDetCmpType :: Type -> Type -> Ordering
- nonDetCmpTypes :: [Type] -> [Type] -> Ordering
- eqTypeX :: RnEnv2 -> Type -> Type -> Bool
- pickyEqType :: TcType -> TcType -> Bool
- tcEqType :: HasDebugCallStack => TcType -> TcType -> Bool
- tcEqKind :: HasDebugCallStack => TcKind -> TcKind -> Bool
- tcEqTypeNoKindCheck :: TcType -> TcType -> Bool
- tcEqTypeVis :: TcType -> TcType -> Bool
- isSigmaTy :: TcType -> Bool
- isRhoTy :: TcType -> Bool
- isRhoExpTy :: ExpType -> Bool
- isOverloadedTy :: Type -> Bool
- isFloatingTy :: Type -> Bool
- isDoubleTy :: Type -> Bool
- isFloatTy :: Type -> Bool
- isIntTy :: Type -> Bool
- isWordTy :: Type -> Bool
- isStringTy :: Type -> Bool
- isIntegerTy :: Type -> Bool
- isNaturalTy :: Type -> Bool
- isBoolTy :: Type -> Bool
- isUnitTy :: Type -> Bool
- isCharTy :: Type -> Bool
- isCallStackTy :: Type -> Bool
- isCallStackPred :: Class -> [Type] -> Maybe FastString
- isTauTy :: Type -> Bool
- isTauTyCon :: TyCon -> Bool
- tcIsTyVarTy :: Type -> Bool
- tcIsForAllTy :: Type -> Bool
- isPredTy :: HasDebugCallStack => Type -> Bool
- isTyVarClassPred :: PredType -> Bool
- isTyVarHead :: TcTyVar -> TcType -> Bool
- isInsolubleOccursCheck :: EqRel -> TcTyVar -> TcType -> Bool
- checkValidClsArgs :: Bool -> Class -> [KindOrType] -> Bool
- hasTyVarHead :: Type -> Bool
- isRigidTy :: TcType -> Bool
- isAlmostFunctionFree :: TcType -> Bool
- deNoteType :: Type -> Type
- orphNamesOfType :: Type -> NameSet
- orphNamesOfCo :: Coercion -> NameSet
- orphNamesOfTypes :: [Type] -> NameSet
- orphNamesOfCoCon :: CoAxiom br -> NameSet
- getDFunTyKey :: Type -> OccName
- evVarPred :: EvVar -> PredType
- mkMinimalBySCs :: forall a. (a -> PredType) -> [a] -> [a]
- transSuperClasses :: PredType -> [PredType]
- pickQuantifiablePreds :: TyVarSet -> TcThetaType -> TcThetaType
- pickCapturedPreds :: TyVarSet -> TcThetaType -> TcThetaType
- immSuperClasses :: Class -> [Type] -> [PredType]
- boxEqPred :: EqRel -> Type -> Type -> Maybe (Class, [Type])
- isImprovementPred :: PredType -> Bool
- tcTyFamInsts :: Type -> [(TyCon, [Type])]
- tcTyFamInstsAndVis :: Type -> [(Bool, TyCon, [Type])]
- tcTyConAppTyFamInstsAndVis :: TyCon -> [Type] -> [(Bool, TyCon, [Type])]
- isTyFamFree :: Type -> Bool
- exactTyCoVarsOfType :: Type -> TyCoVarSet
- exactTyCoVarsOfTypes :: [Type] -> TyCoVarSet
- anyRewritableTyVar :: Bool -> EqRel -> (EqRel -> TcTyVar -> Bool) -> TcType -> Bool
- isFFIArgumentTy :: DynFlags -> Safety -> Type -> Validity
- isFFIImportResultTy :: DynFlags -> Type -> Validity
- isFFIExportResultTy :: Type -> Validity
- isFFIExternalTy :: Type -> Validity
- isFFIDynTy :: Type -> Type -> Validity
- isFFIPrimArgumentTy :: DynFlags -> Type -> Validity
- isFFIPrimResultTy :: DynFlags -> Type -> Validity
- isFFILabelTy :: Type -> Validity
- isFFITy :: Type -> Bool
- isFunPtrTy :: Type -> Bool
- tcSplitIOType_maybe :: Type -> Maybe (TyCon, Type)
- type Kind = Type
- tcTypeKind :: HasDebugCallStack => Type -> Kind
- liftedTypeKind :: Kind
- constraintKind :: Kind
- isLiftedTypeKind :: Kind -> Bool
- isUnliftedTypeKind :: Kind -> Bool
- classifiesTypeWithValues :: Kind -> Bool
- data Type
- type PredType = Type
- type ThetaType = [PredType]
- data TyCoBinder
- data ArgFlag where
- data AnonArgFlag
- mkForAllTy :: TyCoVar -> ArgFlag -> Type -> Type
- mkForAllTys :: [TyCoVarBinder] -> Type -> Type
- mkInvisForAllTys :: [InvisTVBinder] -> Type -> Type
- mkTyCoInvForAllTys :: [TyCoVar] -> Type -> Type
- mkSpecForAllTys :: [TyVar] -> Type -> Type
- mkTyCoInvForAllTy :: TyCoVar -> Type -> Type
- mkInfForAllTy :: TyVar -> Type -> Type
- mkInfForAllTys :: [TyVar] -> Type -> Type
- mkVisFunTy :: Mult -> Type -> Type -> Type
- mkVisFunTys :: [Scaled Type] -> Type -> Type
- mkInvisFunTy :: Mult -> Type -> Type -> Type
- mkInvisFunTyMany :: Type -> Type -> Type
- mkVisFunTyMany :: Type -> Type -> Type
- mkVisFunTysMany :: [Type] -> Type -> Type
- mkInvisFunTysMany :: [Type] -> Type -> Type
- mkTyConApp :: TyCon -> [Type] -> Type
- mkAppTy :: Type -> Type -> Type
- mkAppTys :: Type -> [Type] -> Type
- mkTyConTy :: TyCon -> Type
- mkTyVarTy :: TyVar -> Type
- mkTyVarTys :: [TyVar] -> [Type]
- mkTyCoVarTy :: TyCoVar -> Type
- mkTyCoVarTys :: [TyCoVar] -> [Type]
- isClassPred :: PredType -> Bool
- isEqPrimPred :: PredType -> Bool
- isIPLikePred :: Type -> Bool
- isEqPred :: PredType -> Bool
- isEqPredClass :: Class -> Bool
- mkClassPred :: Class -> [Type] -> PredType
- tcSplitDFunTy :: Type -> ([TyVar], [Type], Class, [Type])
- tcSplitDFunHead :: Type -> (Class, [Type])
- tcSplitMethodTy :: Type -> ([TyVar], PredType, Type)
- isRuntimeRepVar :: TyVar -> Bool
- isKindLevPoly :: Kind -> Bool
- isVisibleBinder :: TyCoBinder -> Bool
- isInvisibleBinder :: TyCoBinder -> Bool
- data TCvSubst = TCvSubst InScopeSet TvSubstEnv CvSubstEnv
- type TvSubstEnv = TyVarEnv Type
- emptyTCvSubst :: TCvSubst
- mkEmptyTCvSubst :: InScopeSet -> TCvSubst
- zipTvSubst :: HasDebugCallStack => [TyVar] -> [Type] -> TCvSubst
- mkTvSubstPrs :: [(TyVar, Type)] -> TCvSubst
- notElemTCvSubst :: Var -> TCvSubst -> Bool
- unionTCvSubst :: TCvSubst -> TCvSubst -> TCvSubst
- getTvSubstEnv :: TCvSubst -> TvSubstEnv
- setTvSubstEnv :: TCvSubst -> TvSubstEnv -> TCvSubst
- getTCvInScope :: TCvSubst -> InScopeSet
- extendTCvInScope :: TCvSubst -> Var -> TCvSubst
- extendTCvInScopeList :: TCvSubst -> [Var] -> TCvSubst
- extendTCvInScopeSet :: TCvSubst -> VarSet -> TCvSubst
- extendTvSubstAndInScope :: TCvSubst -> TyVar -> Type -> TCvSubst
- lookupTyVar :: TCvSubst -> TyVar -> Maybe Type
- extendTCvSubst :: TCvSubst -> TyCoVar -> Type -> TCvSubst
- substTyVarBndr :: HasCallStack => TCvSubst -> TyVar -> (TCvSubst, TyVar)
- extendTvSubst :: TCvSubst -> TyVar -> Type -> TCvSubst
- isInScope :: Var -> TCvSubst -> Bool
- mkTCvSubst :: InScopeSet -> (TvSubstEnv, CvSubstEnv) -> TCvSubst
- mkTvSubst :: InScopeSet -> TvSubstEnv -> TCvSubst
- zipTyEnv :: HasDebugCallStack => [TyVar] -> [Type] -> TvSubstEnv
- zipCoEnv :: HasDebugCallStack => [CoVar] -> [Coercion] -> CvSubstEnv
- substTy :: HasCallStack => TCvSubst -> Type -> Type
- substTys :: HasCallStack => TCvSubst -> [Type] -> [Type]
- substScaledTys :: HasCallStack => TCvSubst -> [Scaled Type] -> [Scaled Type]
- substTyWith :: HasCallStack => [TyVar] -> [Type] -> Type -> Type
- substTyWithCoVars :: [CoVar] -> [Coercion] -> Type -> Type
- substTyAddInScope :: TCvSubst -> Type -> Type
- substTyUnchecked :: TCvSubst -> Type -> Type
- substTysUnchecked :: TCvSubst -> [Type] -> [Type]
- substScaledTyUnchecked :: HasCallStack => TCvSubst -> Scaled Type -> Scaled Type
- substThetaUnchecked :: TCvSubst -> ThetaType -> ThetaType
- substTyWithUnchecked :: [TyVar] -> [Type] -> Type -> Type
- substCoUnchecked :: TCvSubst -> Coercion -> Coercion
- substCoWithUnchecked :: [TyVar] -> [Type] -> Coercion -> Coercion
- substTheta :: HasCallStack => TCvSubst -> ThetaType -> ThetaType
- isUnliftedType :: HasDebugCallStack => Type -> Bool
- isUnboxedTupleType :: Type -> Bool
- isPrimitiveType :: Type -> Bool
- tcView :: Type -> Maybe Type
- coreView :: Type -> Maybe Type
- tyCoVarsOfType :: Type -> TyCoVarSet
- tyCoVarsOfTypes :: [Type] -> TyCoVarSet
- closeOverKinds :: TyCoVarSet -> TyCoVarSet
- tyCoFVsOfType :: Type -> FV
- tyCoFVsOfTypes :: [Type] -> FV
- tyCoVarsOfTypeDSet :: Type -> DTyCoVarSet
- tyCoVarsOfTypesDSet :: [Type] -> DTyCoVarSet
- closeOverKindsDSet :: DTyVarSet -> DTyVarSet
- tyCoVarsOfTypeList :: Type -> [TyCoVar]
- tyCoVarsOfTypesList :: [Type] -> [TyCoVar]
- noFreeVarsOfType :: Type -> Bool
- pprKind :: Kind -> SDoc
- pprParendKind :: Kind -> SDoc
- pprSigmaType :: Type -> SDoc
- pprType :: Type -> SDoc
- pprParendType :: Type -> SDoc
- pprTypeApp :: TyCon -> [Type] -> SDoc
- pprTyThingCategory :: TyThing -> SDoc
- tyThingCategory :: TyThing -> String
- pprTheta :: ThetaType -> SDoc
- pprParendTheta :: ThetaType -> SDoc
- pprThetaArrowTy :: ThetaType -> SDoc
- pprClassPred :: Class -> [Type] -> SDoc
- pprTCvBndr :: TyCoVarBinder -> SDoc
- pprTCvBndrs :: [TyCoVarBinder] -> SDoc
- type TypeSize = IntWithInf
- sizeType :: Type -> TypeSize
- sizeTypes :: [Type] -> TypeSize
- scopedSort :: [TyCoVar] -> [TyCoVar]
- tcTyConVisibilities :: TyCon -> [Bool]
- isNextTyConArgVisible :: TyCon -> [Type] -> Bool
- isNextArgVisible :: TcType -> Bool
Documentation
type TcSigmaType = TcType #
type TcPredType = PredType #
type TcThetaType = ThetaType #
type TcTyVarSet = TyVarSet #
type TcDTyVarSet = DTyVarSet #
type TcTyCoVarSet = TyCoVarSet #
type TcDTyCoVarSet = DTyCoVarSet #
type TcTyVarBinder = TyVarBinder #
type TcInvisTVBinder = InvisTVBinder #
type TcReqTVBinder = ReqTVBinder #
A type labeled KnotTied
might have knot-tied tycons in it. See
Note [Type checking recursive type and class declarations] in
GHC.Tc.TyCl
An expected type to check against during type-checking. See Note [ExpType] in GHC.Tc.Utils.TcMType, where you'll also find manipulators.
Constructors
Check TcType | |
Infer !InferResult |
data InferResult #
Instances
Outputable InferResult # | |
Defined in GHC.Tc.Utils.TcType |
type ExpSigmaType = ExpType #
type ExpRhoType = ExpType #
mkCheckExpType :: TcType -> ExpType #
Make an ExpType
suitable for checking.
data SyntaxOpType #
What to expect for an argument to a rebindable-syntax operator.
Quite like Type
, but allows for holes to be filled in by tcSyntaxOp.
The callback called from tcSyntaxOp gets a list of types; the meaning
of these types is determined by a left-to-right depth-first traversal
of the SyntaxOpType
tree. So if you pass in
SynAny `SynFun` (SynList `SynFun` SynType Int) `SynFun` SynAny
you'll get three types back: one for the first SynAny
, the element
type of the list, and one for the last SynAny
. You don't get anything
for the SynType
, because you've said positively that it should be an
Int, and so it shall be.
You'll also get three multiplicities back: one for each function arrow. See also Note [Linear types] in Multiplicity.
This is defined here to avoid defining it in GHC.Tc.Gen.Expr boot file.
Constructors
SynAny | Any type |
SynRho | A rho type, skolemised or instantiated as appropriate |
SynList | A list type. You get back the element type of the list |
SynFun SyntaxOpType SyntaxOpType infixr 0 | A function. |
SynType ExpType | A known type. |
synKnownType :: TcType -> SyntaxOpType #
Like SynType
but accepts a regular TcType
mkSynFunTys :: [SyntaxOpType] -> ExpType -> SyntaxOpType #
Like mkFunTys
but for SyntaxOpType
topTcLevel :: TcLevel #
pushTcLevel :: TcLevel -> TcLevel #
isTopTcLevel :: TcLevel -> Bool #
strictlyDeeperThan :: TcLevel -> TcLevel -> Bool #
sameDepthAs :: TcLevel -> TcLevel -> Bool #
tcTypeLevel :: TcType -> TcLevel #
tcTyVarLevel :: TcTyVar -> TcLevel #
maxTcLevel :: TcLevel -> TcLevel -> TcLevel #
promoteSkolem :: TcLevel -> TcTyVar -> TcTyVar #
promoteSkolemX :: TcLevel -> TCvSubst -> TcTyVar -> (TCvSubst, TcTyVar) #
Change the TcLevel in a skolem, extending a substitution
data TcTyVarDetails #
Constructors
SkolemTv TcLevel Bool | |
RuntimeUnk | |
MetaTv | |
Instances
Outputable TcTyVarDetails # | |
Defined in GHC.Tc.Utils.TcType |
pprTcTyVarDetails :: TcTyVarDetails -> SDoc #
data MetaDetails #
Instances
Outputable MetaDetails # | |
Defined in GHC.Tc.Utils.TcType |
Constructors
TauTv | |
TyVarTv | |
FlatMetaTv | |
FlatSkolTv |
isImmutableTyVar :: TyVar -> Bool #
isSkolemTyVar :: TcTyVar -> Bool #
isMetaTyVar :: TcTyVar -> Bool #
isMetaTyVarTy :: TcType -> Bool #
tcIsTcTyVar :: TcTyVar -> Bool #
isTyVarTyVar :: Var -> Bool #
isOverlappableTyVar :: TcTyVar -> Bool #
isTyConableTyVar :: TcTyVar -> Bool #
isFskTyVar :: TcTyVar -> Bool #
isFmvTyVar :: TcTyVar -> Bool #
isFlattenTyVar :: TcTyVar -> Bool #
True of both given and wanted flatten-skolems (fmv and fsk)
isAmbiguousTyVar :: TcTyVar -> Bool #
metaTyVarRef :: TyVar -> IORef MetaDetails #
metaTyVarInfo :: TcTyVar -> MetaInfo #
isFlexi :: MetaDetails -> Bool #
isIndirect :: MetaDetails -> Bool #
isRuntimeUnkSkol :: TyVar -> Bool #
metaTyVarTcLevel :: TcTyVar -> TcLevel #
setMetaTyVarTcLevel :: TcTyVar -> TcLevel -> TcTyVar #
isTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool #
isFloatedTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool #
mkTyVarNamePairs :: [TyVar] -> [(Name, TyVar)] #
mkInfSigmaTy :: [TyCoVar] -> [PredType] -> Type -> Type #
Make a sigma ty where all type variables are Inferred
. That is,
they cannot be used with visible type application.
mkSpecSigmaTy :: [TyVar] -> [PredType] -> Type -> Type #
Make a sigma ty where all type variables are "specified". That is, they can be used with visible type application
mkTcAppTys :: Type -> [Type] -> Type #
mkTcCastTy :: Type -> Coercion -> Type #
getTyVar :: String -> Type -> TyVar #
Attempts to obtain the type variable underlying a Type
, and panics with the
given message if this is not a type variable type. See also getTyVar_maybe
tcSplitForAllTy_maybe :: Type -> Maybe (TyVarBinder, Type) #
tcSplitForAllTys :: Type -> ([TyVar], Type) #
Like tcSplitPiTys
, but splits off only named binders,
returning just the tycovars.
tcSplitForAllTysReq :: Type -> ([TcReqTVBinder], Type) #
Like tcSplitForAllTys
, but only splits ForAllTy
s with Required
type
variable binders. All split tyvars are annotated with ()
.
tcSplitForAllTysInvis :: Type -> ([TcInvisTVBinder], Type) #
Like tcSplitForAllTys
, but only splits ForAllTy
s with Invisible
type
variable binders. All split tyvars are annotated with their Specificity
.
tcSplitPiTys :: Type -> ([TyBinder], Type) #
Splits a forall type into a list of TyBinder
s and the inner type.
Always succeeds, even if it returns an empty list.
tcSplitPiTy_maybe :: Type -> Maybe (TyBinder, Type) #
Splits a type into a TyBinder and a body, if possible. Panics otherwise
tcSplitForAllVarBndrs :: Type -> ([TyVarBinder], Type) #
Like tcSplitForAllTys
, but splits off only named binders.
tcSplitPhiTy :: Type -> (ThetaType, Type) #
tcFunArgTy :: Type -> Scaled Type #
tcFunResultTy :: Type -> Type #
tcFunResultTyN :: HasDebugCallStack => Arity -> Type -> Type #
Strips off n *visible* arguments and returns the resulting type
tcSplitFunTysN :: Arity -> TcRhoType -> Either Arity ([Scaled TcSigmaType], TcSigmaType) #
Split off exactly the specified number argument types
Returns
(Left m) if there are m
missing arrows in the type
(Right (tys,res)) if the type looks like t1 -> ... -> tn -> res
tcSplitTyConApp :: Type -> (TyCon, [Type]) #
tcSplitTyConApp_maybe :: HasCallStack => Type -> Maybe (TyCon, [Type]) #
Split a type constructor application into its type constructor and
applied types. Note that this may fail in the case of a FunTy
with an
argument of unknown kind FunTy
(e.g. FunTy (a :: k) Int
. since the kind
of a
isn't of the form TYPE rep
). Consequently, you may need to zonk your
type before using this function.
If you only need the TyCon
, consider using tcTyConAppTyCon_maybe
.
tcTyConAppTyCon :: Type -> TyCon #
tcTyConAppTyCon_maybe :: Type -> Maybe TyCon #
Like tcRepSplitTyConApp_maybe
, but only returns the TyCon
.
tcTyConAppArgs :: Type -> [Type] #
tcSplitAppTy :: Type -> (Type, Type) #
tcSplitAppTys :: Type -> (Type, [Type]) #
tcRepSplitAppTy_maybe :: Type -> Maybe (Type, Type) #
Does the AppTy split as in tcSplitAppTy_maybe
, but assumes that
any coreView stuff is already done. Refuses to look through (c => t)
tcRepGetNumAppTys :: Type -> Arity #
Returns the number of arguments in the given type, without looking through synonyms. This is used only for error reporting. We don't look through synonyms because of #11313.
tcGetCastedTyVar_maybe :: Type -> Maybe (TyVar, CoercionN) #
If the type is a tyvar, possibly under a cast, returns it, along with the coercion. Thus, the co is :: kind tv ~N kind type
tcGetTyVar_maybe :: Type -> Maybe TyVar #
tcGetTyVar :: String -> Type -> TyVar #
tcSplitNestedSigmaTys :: Type -> ([TyVar], ThetaType, Type) #
Split a sigma type into its parts, going underneath as many ForAllTy
s
as possible. For example, given this type synonym:
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t
if you called tcSplitSigmaTy
on this type:
forall s t a b. Each s t a b => Traversal s t a b
then it would return ([s,t,a,b], [Each s t a b], Traversal s t a b)
. But
if you instead called tcSplitNestedSigmaTys
on the type, it would return
([s,t,a,b,f], [Each s t a b, Applicative f], (a -> f b) -> s -> f t)
.
eqType :: Type -> Type -> Bool #
Type equality on source types. Does not look through newtypes
or
PredType
s, but it does look through type synonyms.
This first checks that the kinds of the types are equal and then
checks whether the types are equal, ignoring casts and coercions.
(The kind check is a recursive call, but since all kinds have type
Type
, there is no need to check the types of kinds.)
See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep.
eqTypes :: [Type] -> [Type] -> Bool #
Type equality on lists of types, looking through type synonyms but not newtypes.
nonDetCmpType :: Type -> Type -> Ordering #
nonDetCmpTypes :: [Type] -> [Type] -> Ordering #
eqTypeX :: RnEnv2 -> Type -> Type -> Bool #
Compare types with respect to a (presumably) non-empty RnEnv2
.
pickyEqType :: TcType -> TcType -> Bool #
Like pickyEqTypeVis
, but returns a Bool for convenience
tcEqTypeNoKindCheck :: TcType -> TcType -> Bool #
Just like tcEqType
, but will return True for types of different kinds
as long as their non-coercion structure is identical.
tcEqTypeVis :: TcType -> TcType -> Bool #
Like tcEqType
, but returns True if the visible part of the types
are equal, even if they are really unequal (in the invisible bits)
isOverloadedTy :: Type -> Bool #
isFloatingTy :: Type -> Bool #
Does a type represent a floating-point number?
isDoubleTy :: Type -> Bool #
isStringTy :: Type -> Bool #
Is a type String
?
isIntegerTy :: Type -> Bool #
isNaturalTy :: Type -> Bool #
isCallStackTy :: Type -> Bool #
Is a type a CallStack
?
isCallStackPred :: Class -> [Type] -> Maybe FastString #
Is a PredType
a CallStack
implicit parameter?
If so, return the name of the parameter.
isTauTyCon :: TyCon -> Bool #
tcIsTyVarTy :: Type -> Bool #
tcIsForAllTy :: Type -> Bool #
Is this a ForAllTy with a named binder?
isPredTy :: HasDebugCallStack => Type -> Bool #
isTyVarClassPred :: PredType -> Bool #
isTyVarHead :: TcTyVar -> TcType -> Bool #
Does the given tyvar appear at the head of a chain of applications (a t1 ... tn)
isInsolubleOccursCheck :: EqRel -> TcTyVar -> TcType -> Bool #
Is the equality a ~r ...a.... definitely insoluble or not? a ~r Maybe a -- Definitely insoluble a ~N ...(F a)... -- Not definitely insoluble -- Perhaps (F a) reduces to Int a ~R ...(N a)... -- Not definitely insoluble -- Perhaps newtype N a = MkN Int See Note [Occurs check error] in GHC.Tc.Solver.Canonical for the motivation for this function.
checkValidClsArgs :: Bool -> Class -> [KindOrType] -> Bool #
hasTyVarHead :: Type -> Bool #
isAlmostFunctionFree :: TcType -> Bool #
Is this type *almost function-free*? See Note [Almost function-free] in GHC.Tc.Types
deNoteType :: Type -> Type #
orphNamesOfType :: Type -> NameSet #
orphNamesOfCo :: Coercion -> NameSet #
orphNamesOfTypes :: [Type] -> NameSet #
orphNamesOfCoCon :: CoAxiom br -> NameSet #
getDFunTyKey :: Type -> OccName #
mkMinimalBySCs :: forall a. (a -> PredType) -> [a] -> [a] #
transSuperClasses :: PredType -> [PredType] #
pickQuantifiablePreds :: TyVarSet -> TcThetaType -> TcThetaType #
When inferring types, should we quantify over a given predicate? Generally true of classes; generally false of equality constraints. Equality constraints that mention quantified type variables and implicit variables complicate the story. See Notes [Inheriting implicit parameters] and [Quantifying over equality constraints]
pickCapturedPreds :: TyVarSet -> TcThetaType -> TcThetaType #
immSuperClasses :: Class -> [Type] -> [PredType] #
isImprovementPred :: PredType -> Bool #
Finding type instances
tcTyFamInsts :: Type -> [(TyCon, [Type])] #
Finds outermost type-family applications occurring in a type, after expanding synonyms. In the list (F, tys) that is returned we guarantee that tys matches F's arity. For example, given type family F a :: * -> * (arity 1) calling tcTyFamInsts on (Maybe (F Int Bool) will return (F, [Int]), not (F, [Int,Bool])
This is important for its use in deciding termination of type instances (see #11581). E.g. type instance G [Int] = ...(F Int <big type>)... we don't need to take <big type> into account when asking if the calls on the RHS are smaller than the LHS
tcTyFamInstsAndVis :: Type -> [(Bool, TyCon, [Type])] #
Like tcTyFamInsts
, except that the output records whether the
type family and its arguments occur as an invisible argument in
some type application. This information is useful because it helps GHC know
when to turn on -fprint-explicit-kinds
during error reporting so that
users can actually see the type family being mentioned.
As an example, consider:
class C a data T (a :: k) type family F a :: k instance C (T @(F Int) (F Bool))
There are two occurrences of the type family F
in that C
instance, so
will return:tcTyFamInstsAndVis
(C (T @(F Int) (F Bool)))
[ (True
, F, [Int]) , (False
, F, [Bool]) ]
F Int
is paired with True
since it appears as an invisible argument
to C
, whereas F Bool
is paired with False
since it appears an a
visible argument to C
.
See also Note [Kind arguments in error messages]
in GHC.Tc.Errors.
tcTyConAppTyFamInstsAndVis :: TyCon -> [Type] -> [(Bool, TyCon, [Type])] #
In an application of a TyCon
to some arguments, find the outermost
occurrences of type family applications within the arguments. This function
will not consider the TyCon
itself when checking for type family
applications.
See tcTyFamInstsAndVis
for more details on how this works (as this
function is called inside of tcTyFamInstsAndVis
).
isTyFamFree :: Type -> Bool #
Check that a type does not contain any type family applications.
Finding "exact" (non-dead) type variables
exactTyCoVarsOfType :: Type -> TyCoVarSet #
exactTyCoVarsOfTypes :: [Type] -> TyCoVarSet #
isFFIImportResultTy :: DynFlags -> Type -> Validity #
isFFIExportResultTy :: Type -> Validity #
isFFIExternalTy :: Type -> Validity #
isFFIDynTy :: Type -> Type -> Validity #
isFFIPrimArgumentTy :: DynFlags -> Type -> Validity #
isFFIPrimResultTy :: DynFlags -> Type -> Validity #
isFFILabelTy :: Type -> Validity #
isFunPtrTy :: Type -> Bool #
tcTypeKind :: HasDebugCallStack => Type -> Kind #
liftedTypeKind :: Kind #
constraintKind :: Kind #
isLiftedTypeKind :: Kind -> Bool #
This version considers Constraint to be the same as *. Returns True if the argument is equivalent to Type/Constraint and False otherwise. See Note [Kind Constraint and kind Type]
isUnliftedTypeKind :: Kind -> Bool #
Returns True if the kind classifies unlifted types and False otherwise. Note that this returns False for levity-polymorphic kinds, which may be specialized to a kind that classifies unlifted types.
classifiesTypeWithValues :: Kind -> Bool #
Does this classify a type allowed to have values? Responds True to things like *, #, TYPE Lifted, TYPE v, Constraint.
True of any sub-kind of OpenTypeKind
Instances
Data Type # | |
Defined in GHC.Core.TyCo.Rep Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Type -> c Type Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Type Source # toConstr :: Type -> Constr Source # dataTypeOf :: Type -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Type) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Type) Source # gmapT :: (forall b. Data b => b -> b) -> Type -> Type Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Type -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Type -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Type -> m Type Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type Source # | |
Outputable Type # | |
A type of the form p
of constraint kind represents a value whose type is
the Haskell predicate p
, where a predicate is what occurs before
the =>
in a Haskell type.
We use PredType
as documentation to mark those types that we guarantee to
have this kind.
It can be expanded into its representation, but:
- The type checker must treat it as opaque
- The rest of the compiler treats it as transparent
Consider these examples:
f :: (Eq a) => a -> Int g :: (?x :: Int -> Int) => a -> Int h :: (r\l) => {r} => {l::Int | r}
Here the Eq a
and ?x :: Int -> Int
and rl
are all called "predicates"
data TyCoBinder #
A TyCoBinder
represents an argument to a function. TyCoBinders can be
dependent (Named
) or nondependent (Anon
). They may also be visible or
not. See Note [TyCoBinders]
Instances
Data TyCoBinder # | |
Defined in GHC.Core.TyCo.Rep Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TyCoBinder -> c TyCoBinder Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TyCoBinder Source # toConstr :: TyCoBinder -> Constr Source # dataTypeOf :: TyCoBinder -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TyCoBinder) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyCoBinder) Source # gmapT :: (forall b. Data b => b -> b) -> TyCoBinder -> TyCoBinder Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TyCoBinder -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TyCoBinder -> r Source # gmapQ :: (forall d. Data d => d -> u) -> TyCoBinder -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> TyCoBinder -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TyCoBinder -> m TyCoBinder Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TyCoBinder -> m TyCoBinder Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TyCoBinder -> m TyCoBinder Source # | |
Outputable TyCoBinder # | |
Defined in GHC.Core.TyCo.Rep |
Argument Flag
Is something required to appear in source Haskell (Required
),
permitted by request (Specified
) (visible type application), or
prohibited entirely from appearing in source Haskell (Inferred
)?
See Note [VarBndrs, TyCoVarBinders, TyConBinders, and visibility] in GHC.Core.TyCo.Rep
Constructors
Invisible Specificity | |
Required |
Instances
Eq ArgFlag # | |
Data ArgFlag # | |
Defined in GHC.Types.Var Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ArgFlag -> c ArgFlag Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ArgFlag Source # toConstr :: ArgFlag -> Constr Source # dataTypeOf :: ArgFlag -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ArgFlag) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ArgFlag) Source # gmapT :: (forall b. Data b => b -> b) -> ArgFlag -> ArgFlag Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ArgFlag -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ArgFlag -> r Source # gmapQ :: (forall d. Data d => d -> u) -> ArgFlag -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> ArgFlag -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ArgFlag -> m ArgFlag Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ArgFlag -> m ArgFlag Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ArgFlag -> m ArgFlag Source # | |
Ord ArgFlag # | |
Outputable ArgFlag # | |
Binary ArgFlag # | |
Outputable tv => Outputable (VarBndr tv ArgFlag) # | |
data AnonArgFlag #
The non-dependent version of ArgFlag
.
See Note [AnonArgFlag]
Appears here partly so that it's together with its friends ArgFlag
and ForallVisFlag, but also because it is used in IfaceType, rather
early in the compilation chain
Constructors
VisArg | Used for |
InvisArg | Used for |
Instances
mkForAllTy :: TyCoVar -> ArgFlag -> Type -> Type #
Like mkTyCoForAllTy
, but does not check the occurrence of the binder
See Note [Unused coercion variable in ForAllTy]
mkForAllTys :: [TyCoVarBinder] -> Type -> Type #
Wraps foralls over the type using the provided TyCoVar
s from left to right
mkInvisForAllTys :: [InvisTVBinder] -> Type -> Type #
Wraps foralls over the type using the provided InvisTVBinder
s from left to right
mkTyCoInvForAllTys :: [TyCoVar] -> Type -> Type #
Like mkForAllTys
, but assumes all variables are dependent and
Inferred
, a common case
mkSpecForAllTys :: [TyVar] -> Type -> Type #
Like mkForAllTys
, but assumes all variables are dependent and
Specified
, a common case
mkInfForAllTy :: TyVar -> Type -> Type #
Like mkTyCoInvForAllTy
, but tv should be a tyvar
mkInfForAllTys :: [TyVar] -> Type -> Type #
Like mkTyCoInvForAllTys
, but tvs should be a list of tyvar
mkInvisFunTyMany :: Type -> Type -> Type infixr 3 #
mkVisFunTyMany :: Type -> Type -> Type infixr 3 #
Special, common, case: Arrow type with mult Many
mkVisFunTysMany :: [Type] -> Type -> Type #
mkInvisFunTysMany :: [Type] -> Type -> Type #
mkTyConApp :: TyCon -> [Type] -> Type #
Create the plain type constructor type which has been applied to no type arguments at all.
mkTyVarTys :: [TyVar] -> [Type] #
mkTyCoVarTy :: TyCoVar -> Type #
mkTyCoVarTys :: [TyCoVar] -> [Type] #
isClassPred :: PredType -> Bool #
isEqPrimPred :: PredType -> Bool #
isIPLikePred :: Type -> Bool #
isEqPredClass :: Class -> Bool #
mkClassPred :: Class -> [Type] -> PredType #
tcSplitDFunHead :: Type -> (Class, [Type]) #
isRuntimeRepVar :: TyVar -> Bool #
Is a tyvar of type RuntimeRep
?
isKindLevPoly :: Kind -> Bool #
Tests whether the given kind (which should look like TYPE x
)
is something other than a constructor tree (that is, constructors at every node).
E.g. True of TYPE k, TYPE (F Int)
False of TYPE 'LiftedRep
isVisibleBinder :: TyCoBinder -> Bool #
Does this binder bind a visible argument?
isInvisibleBinder :: TyCoBinder -> Bool #
Does this binder bind an invisible argument?
Type & coercion substitution
The following invariants must hold of a TCvSubst
:
- The in-scope set is needed only to guide the generation of fresh uniques
- In particular, the kind of the type variables in the in-scope set is not relevant
- The substitution is only applied ONCE! This is because in general such application will not reach a fixed point.
Constructors
TCvSubst InScopeSet TvSubstEnv CvSubstEnv |
mkEmptyTCvSubst :: InScopeSet -> TCvSubst #
zipTvSubst :: HasDebugCallStack => [TyVar] -> [Type] -> TCvSubst #
Generates the in-scope set for the TCvSubst
from the types in the incoming
environment. No CoVars, please!
mkTvSubstPrs :: [(TyVar, Type)] -> TCvSubst #
Generates the in-scope set for the TCvSubst
from the types in the
incoming environment. No CoVars, please!
notElemTCvSubst :: Var -> TCvSubst -> Bool #
unionTCvSubst :: TCvSubst -> TCvSubst -> TCvSubst #
getTvSubstEnv :: TCvSubst -> TvSubstEnv #
setTvSubstEnv :: TCvSubst -> TvSubstEnv -> TCvSubst #
getTCvInScope :: TCvSubst -> InScopeSet #
extendTCvInScope :: TCvSubst -> Var -> TCvSubst #
extendTCvInScopeList :: TCvSubst -> [Var] -> TCvSubst #
extendTCvInScopeSet :: TCvSubst -> VarSet -> TCvSubst #
substTyVarBndr :: HasCallStack => TCvSubst -> TyVar -> (TCvSubst, TyVar) #
mkTCvSubst :: InScopeSet -> (TvSubstEnv, CvSubstEnv) -> TCvSubst #
mkTvSubst :: InScopeSet -> TvSubstEnv -> TCvSubst #
Make a TCvSubst with specified tyvar subst and empty covar subst
zipTyEnv :: HasDebugCallStack => [TyVar] -> [Type] -> TvSubstEnv #
zipCoEnv :: HasDebugCallStack => [CoVar] -> [Coercion] -> CvSubstEnv #
substTy :: HasCallStack => TCvSubst -> Type -> Type #
Substitute within a Type
The substitution has to satisfy the invariants described in
Note [The substitution invariant].
substTys :: HasCallStack => TCvSubst -> [Type] -> [Type] #
Substitute within several Type
s
The substitution has to satisfy the invariants described in
Note [The substitution invariant].
substScaledTys :: HasCallStack => TCvSubst -> [Scaled Type] -> [Scaled Type] #
substTyWith :: HasCallStack => [TyVar] -> [Type] -> Type -> Type #
Type substitution, see zipTvSubst
substTyAddInScope :: TCvSubst -> Type -> Type #
Substitute within a Type
after adding the free variables of the type
to the in-scope set. This is useful for the case when the free variables
aren't already in the in-scope set or easily available.
See also Note [The substitution invariant].
substTyUnchecked :: TCvSubst -> Type -> Type #
Substitute within a Type
disabling the sanity checks.
The problems that the sanity checks in substTy catch are described in
Note [The substitution invariant].
The goal of #11371 is to migrate all the calls of substTyUnchecked to
substTy and remove this function. Please don't use in new code.
substTysUnchecked :: TCvSubst -> [Type] -> [Type] #
Substitute within several Type
s disabling the sanity checks.
The problems that the sanity checks in substTys catch are described in
Note [The substitution invariant].
The goal of #11371 is to migrate all the calls of substTysUnchecked to
substTys and remove this function. Please don't use in new code.
substScaledTyUnchecked :: HasCallStack => TCvSubst -> Scaled Type -> Scaled Type #
substThetaUnchecked :: TCvSubst -> ThetaType -> ThetaType #
Substitute within a ThetaType
disabling the sanity checks.
The problems that the sanity checks in substTys catch are described in
Note [The substitution invariant].
The goal of #11371 is to migrate all the calls of substThetaUnchecked to
substTheta and remove this function. Please don't use in new code.
substTyWithUnchecked :: [TyVar] -> [Type] -> Type -> Type #
Type substitution, see zipTvSubst
. Disables sanity checks.
The problems that the sanity checks in substTy catch are described in
Note [The substitution invariant].
The goal of #11371 is to migrate all the calls of substTyUnchecked to
substTy and remove this function. Please don't use in new code.
substCoUnchecked :: TCvSubst -> Coercion -> Coercion #
Substitute within a Coercion
disabling sanity checks.
The problems that the sanity checks in substCo catch are described in
Note [The substitution invariant].
The goal of #11371 is to migrate all the calls of substCoUnchecked to
substCo and remove this function. Please don't use in new code.
substCoWithUnchecked :: [TyVar] -> [Type] -> Coercion -> Coercion #
Coercion substitution, see zipTvSubst
. Disables sanity checks.
The problems that the sanity checks in substCo catch are described in
Note [The substitution invariant].
The goal of #11371 is to migrate all the calls of substCoUnchecked to
substCo and remove this function. Please don't use in new code.
substTheta :: HasCallStack => TCvSubst -> ThetaType -> ThetaType #
Substitute within a ThetaType
The substitution has to satisfy the invariants described in
Note [The substitution invariant].
isUnliftedType :: HasDebugCallStack => Type -> Bool #
See Type for what an unlifted type is.
Panics on levity polymorphic types; See mightBeUnliftedType
for
a more approximate predicate that behaves better in the presence of
levity polymorphism.
isUnboxedTupleType :: Type -> Bool #
isPrimitiveType :: Type -> Bool #
Returns true of types that are opaque to Haskell.
tcView :: Type -> Maybe Type #
Gives the typechecker view of a type. This unwraps synonyms but
leaves Constraint
alone. c.f. coreView, which turns Constraint into
TYPE LiftedRep. Returns Nothing if no unwrapping happens.
See also Note [coreView vs tcView]
coreView :: Type -> Maybe Type #
This function Strips off the top layer only of a type synonym
application (if any) its underlying representation type.
Returns Nothing if there is nothing to look through.
This function considers Constraint
to be a synonym of TYPE LiftedRep
.
By being non-recursive and inlined, this case analysis gets efficiently joined onto the case analysis that the caller is already doing
tyCoVarsOfType :: Type -> TyCoVarSet #
tyCoVarsOfTypes :: [Type] -> TyCoVarSet #
closeOverKinds :: TyCoVarSet -> TyCoVarSet #
tyCoFVsOfType :: Type -> FV #
The worker for tyCoFVsOfType
and tyCoFVsOfTypeList
.
The previous implementation used unionVarSet
which is O(n+m) and can
make the function quadratic.
It's exported, so that it can be composed with
other functions that compute free variables.
See Note [FV naming conventions] in GHC.Utils.FV.
Eta-expanded because that makes it run faster (apparently) See Note [FV eta expansion] in GHC.Utils.FV for explanation.
tyCoFVsOfTypes :: [Type] -> FV #
tyCoVarsOfTypeDSet :: Type -> DTyCoVarSet #
tyCoFVsOfType
that returns free variables of a type in a deterministic
set. For explanation of why using VarSet
is not deterministic see
Note [Deterministic FV] in GHC.Utils.FV.
tyCoVarsOfTypesDSet :: [Type] -> DTyCoVarSet #
Returns free variables of types, including kind variables as a deterministic set. For type synonyms it does not expand the synonym.
closeOverKindsDSet :: DTyVarSet -> DTyVarSet #
Add the kind variables free in the kinds of the tyvars in the given set. Returns a deterministic set.
tyCoVarsOfTypeList :: Type -> [TyCoVar] #
tyCoFVsOfType
that returns free variables of a type in deterministic
order. For explanation of why using VarSet
is not deterministic see
Note [Deterministic FV] in GHC.Utils.FV.
tyCoVarsOfTypesList :: [Type] -> [TyCoVar] #
Returns free variables of types, including kind variables as a deterministically ordered list. For type synonyms it does not expand the synonym.
noFreeVarsOfType :: Type -> Bool #
pprParendKind :: Kind -> SDoc #
pprSigmaType :: Type -> SDoc #
pprParendType :: Type -> SDoc #
pprTypeApp :: TyCon -> [Type] -> SDoc #
pprTyThingCategory :: TyThing -> SDoc #
tyThingCategory :: TyThing -> String #
pprParendTheta :: ThetaType -> SDoc #
pprThetaArrowTy :: ThetaType -> SDoc #
pprClassPred :: Class -> [Type] -> SDoc #
pprTCvBndr :: TyCoVarBinder -> SDoc #
pprTCvBndrs :: [TyCoVarBinder] -> SDoc #
type TypeSize = IntWithInf #
scopedSort :: [TyCoVar] -> [TyCoVar] #
Do a topological sort on a list of tyvars, so that binders occur before occurrences E.g. given [ a::k, k::*, b::k ] it'll return a well-scoped list [ k::*, a::k, b::k ]
This is a deterministic sorting operation (that is, doesn't depend on Uniques).
It is also meant to be stable: that is, variables should not be reordered unnecessarily. This is specified in Note [ScopedSort] See also Note [Ordering of implicit variables] in GHC.Rename.HsType
tcTyConVisibilities :: TyCon -> [Bool] #
For every arg a tycon can take, the returned list says True if the argument is taken visibly, and False otherwise. Ends with an infinite tail of Trues to allow for oversaturation.
isNextTyConArgVisible :: TyCon -> [Type] -> Bool #
If the tycon is applied to the types, is the next argument visible?
isNextArgVisible :: TcType -> Bool #
Should this type be applied to a visible argument?