TcType
- type TcType = Type
- type TcSigmaType = TcType
- type TcRhoType = TcType
- type TcTauType = TcType
- type TcPredType = PredType
- type TcThetaType = ThetaType
- type TcCoercion = Coercion
- type TcTyVar = TyVar
- type TcTyVarSet = TyVarSet
- type TcKind = Kind
- type TcCoVar = CoVar
- data UserTypeCtxt
- = FunSigCtxt Name
- | ExprSigCtxt
- | ConArgCtxt Name
- | TySynCtxt Name
- | GenPatCtxt
- | LamPatSigCtxt
- | BindPatSigCtxt
- | ResSigCtxt
- | ForSigCtxt Name
- | DefaultDeclCtxt
- | SpecInstCtxt
- | ThBrackCtxt
- | GenSigCtxt
- pprUserTypeCtxt :: UserTypeCtxt -> SDoc
- data TcTyVarDetails
- = SkolemTv Bool
- | RuntimeUnk
- | FlatSkol TcType
- | MetaTv MetaInfo (IORef MetaDetails)
- pprTcTyVarDetails :: TcTyVarDetails -> SDoc
- vanillaSkolemTv, superSkolemTv :: TcTyVarDetails
- data MetaDetails
- data MetaInfo
- isImmutableTyVar :: TyVar -> Bool
- isTyConableTyVar, isMetaTyVar, isOverlappableTyVar, isSkolemTyVar :: TcTyVar -> Bool
- isMetaTyVarTy :: TcType -> Bool
- isSigTyVar :: Var -> Bool
- metaTvRef :: TyVar -> IORef MetaDetails
- isFlexi, isIndirect :: MetaDetails -> Bool
- isRuntimeUnkSkol :: TyVar -> Bool
- mkPhiTy :: [PredType] -> Type -> Type
- mkSigmaTy :: [TyVar] -> [PredType] -> Type -> Type
- tcView :: Type -> Maybe Type
- tcSplitForAllTys :: Type -> ([TyVar], Type)
- tcSplitPhiTy :: Type -> (ThetaType, Type)
- tcSplitPredFunTy_maybe :: Type -> Maybe (PredType, Type)
- tcSplitFunTy_maybe :: Type -> Maybe (Type, Type)
- tcSplitFunTys :: Type -> ([Type], Type)
- tcFunArgTy :: Type -> Type
- tcFunResultTy :: Type -> Type
- tcSplitFunTysN :: TcRhoType -> Arity -> ([TcSigmaType], TcSigmaType)
- tcSplitTyConApp :: Type -> (TyCon, [Type])
- tcSplitTyConApp_maybe :: Type -> Maybe (TyCon, [Type])
- tcTyConAppTyCon :: Type -> TyCon
- tcTyConAppArgs :: Type -> [Type]
- tcSplitAppTy_maybe :: Type -> Maybe (Type, Type)
- tcSplitAppTy :: Type -> (Type, Type)
- tcSplitAppTys :: Type -> (Type, [Type])
- repSplitAppTy_maybe :: Type -> Maybe (Type, Type)
- tcInstHeadTyNotSynonym :: Type -> Bool
- tcInstHeadTyAppAllTyVars :: Type -> Bool
- tcGetTyVar_maybe :: Type -> Maybe TyVar
- tcGetTyVar :: String -> Type -> TyVar
- tcSplitSigmaTy :: Type -> ([TyVar], ThetaType, Type)
- tcDeepSplitSigmaTy_maybe :: TcSigmaType -> Maybe ([TcType], [TyVar], ThetaType, TcSigmaType)
- eqType :: Type -> Type -> Bool
- eqTypes :: [Type] -> [Type] -> Bool
- eqPred :: PredType -> PredType -> Bool
- cmpType :: Type -> Type -> Ordering
- cmpTypes :: [Type] -> [Type] -> Ordering
- cmpPred :: PredType -> PredType -> Ordering
- eqTypeX :: RnEnv2 -> Type -> Type -> Bool
- eqKind :: Kind -> Kind -> Bool
- isSigmaTy :: Type -> Bool
- isOverloadedTy :: Type -> Bool
- isFloatTy, isCharTy, isUnitTy, isBoolTy, isWordTy, isIntTy, isIntegerTy, isDoubleTy :: Type -> Bool
- isStringTy :: Type -> Bool
- isTauTy :: Type -> Bool
- isTauTyCon :: TyCon -> Bool
- tcIsTyVarTy :: Type -> Bool
- tcIsForAllTy :: Type -> Bool
- isSynFamilyTyConApp :: TcTauType -> Bool
- deNoteType :: Type -> Type
- orphNamesOfType :: Type -> NameSet
- orphNamesOfDFunHead :: Type -> NameSet
- orphNamesOfCo :: Coercion -> NameSet
- getDFunTyKey :: Type -> OccName
- mkMinimalBySCs :: [PredType] -> [PredType]
- transSuperClasses :: Class -> [Type] -> [PredType]
- immSuperClasses :: Class -> [Type] -> [PredType]
- tidyType :: TidyEnv -> Type -> Type
- tidyTypes :: TidyEnv -> [Type] -> [Type]
- tidyOpenType :: TidyEnv -> Type -> (TidyEnv, Type)
- tidyOpenTypes :: TidyEnv -> [Type] -> (TidyEnv, [Type])
- tidyTyVarBndr :: TidyEnv -> TyVar -> (TidyEnv, TyVar)
- tidyFreeTyVars :: TidyEnv -> TyVarSet -> TidyEnv
- tidyOpenTyVar :: TidyEnv -> TyVar -> (TidyEnv, TyVar)
- tidyOpenTyVars :: TidyEnv -> [TyVar] -> (TidyEnv, [TyVar])
- tidyTopType :: Type -> Type
- tidyPred :: TidyEnv -> PredType -> PredType
- tidyKind :: TidyEnv -> Kind -> (TidyEnv, Kind)
- tidyCo :: TidyEnv -> Coercion -> Coercion
- tidyCos :: TidyEnv -> [Coercion] -> [Coercion]
- isFFIArgumentTy :: DynFlags -> Safety -> Type -> Bool
- isFFIImportResultTy :: DynFlags -> Type -> Bool
- isFFIExportResultTy :: Type -> Bool
- isFFIExternalTy :: Type -> Bool
- isFFIDynArgumentTy :: Type -> Bool
- isFFIDynResultTy :: Type -> Bool
- isFFIPrimArgumentTy :: DynFlags -> Type -> Bool
- isFFIPrimResultTy :: DynFlags -> Type -> Bool
- isFFILabelTy :: Type -> Bool
- isFFIDotnetTy :: DynFlags -> Type -> Bool
- isFFIDotnetObjTy :: Type -> Bool
- isFFITy :: Type -> Bool
- isFunPtrTy :: Type -> Bool
- tcSplitIOType_maybe :: Type -> Maybe (TyCon, Type, Coercion)
- type Kind = Type
- typeKind :: Type -> Kind
- liftedTypeKind, argTypeKind, openTypeKind, unliftedTypeKind :: Kind
- mkArrowKind :: Kind -> Kind -> Kind
- mkArrowKinds :: [Kind] -> Kind -> Kind
- isLiftedTypeKind :: Kind -> Bool
- isUnliftedTypeKind :: Kind -> Bool
- isSubOpenTypeKind :: Kind -> Bool
- isSubArgTypeKind :: Kind -> Bool
- isSubKind :: Kind -> Kind -> Bool
- splitKindFunTys :: Kind -> ([Kind], Kind)
- defaultKind :: Kind -> Kind
- kindVarRef :: KindVar -> IORef MetaDetails
- mkKindVar :: Unique -> IORef MetaDetails -> KindVar
- data Type
- data Pred a
- type PredType = Pred Type
- type ThetaType = [PredType]
- mkForAllTy :: TyVar -> Type -> Type
- mkForAllTys :: [TyVar] -> Type -> Type
- mkFunTy :: Type -> Type -> Type
- mkFunTys :: [Type] -> Type -> Type
- zipFunTys :: Outputable a => [a] -> Type -> ([(a, Type)], Type)
- mkTyConApp :: TyCon -> [Type] -> Type
- mkAppTy :: Type -> Type -> Type
- mkAppTys :: Type -> [Type] -> Type
- applyTy :: Type -> Type -> Type
- applyTys :: Type -> [Type] -> Type
- mkTyVarTy :: TyVar -> Type
- mkTyVarTys :: [TyVar] -> [Type]
- mkTyConTy :: TyCon -> Type
- mkPredTy :: PredType -> Type
- mkPredTys :: ThetaType -> [Type]
- getClassPredTys_maybe :: PredType -> Maybe (Class, [Type])
- getClassPredTys :: PredType -> (Class, [Type])
- isClassPred :: Pred a -> Bool
- isTyVarClassPred :: PredType -> Bool
- isEqPred :: Pred a -> Bool
- mkClassPred :: Class -> [Type] -> PredType
- mkIPPred :: IPName Name -> Type -> PredType
- splitPredTy_maybe :: Type -> Maybe PredType
- mkDictTy :: Class -> [Type] -> Type
- isPredTy :: Type -> Bool
- isDictTy :: Type -> Bool
- isDictLikeTy :: Type -> Bool
- tcSplitDFunTy :: Type -> ([TyVar], Int, Class, [Type])
- tcSplitDFunHead :: Type -> (Class, [Type])
- isIPPred :: Pred a -> Bool
- mkEqPred :: (a, a) -> Pred a
- data TvSubst = TvSubst InScopeSet TvSubstEnv
- type TvSubstEnv = TyVarEnv Type
- emptyTvSubst :: TvSubst
- mkOpenTvSubst :: TvSubstEnv -> TvSubst
- zipOpenTvSubst :: [TyVar] -> [Type] -> TvSubst
- zipTopTvSubst :: [TyVar] -> [Type] -> TvSubst
- mkTopTvSubst :: [(TyVar, Type)] -> TvSubst
- notElemTvSubst :: TyCoVar -> TvSubst -> Bool
- unionTvSubst :: TvSubst -> TvSubst -> TvSubst
- getTvSubstEnv :: TvSubst -> TvSubstEnv
- setTvSubstEnv :: TvSubst -> TvSubstEnv -> TvSubst
- getTvInScope :: TvSubst -> InScopeSet
- extendTvInScope :: TvSubst -> Var -> TvSubst
- lookupTyVar :: TvSubst -> TyVar -> Maybe Type
- extendTvSubst :: TvSubst -> TyVar -> Type -> TvSubst
- substTyVarBndr :: TvSubst -> TyVar -> (TvSubst, TyVar)
- extendTvSubstList :: TvSubst -> [TyVar] -> [Type] -> TvSubst
- isInScope :: Var -> TvSubst -> Bool
- mkTvSubst :: InScopeSet -> TvSubstEnv -> TvSubst
- zipTyEnv :: [TyVar] -> [Type] -> TvSubstEnv
- substTy :: TvSubst -> Type -> Type
- substTys :: TvSubst -> [Type] -> [Type]
- substTyWith :: [TyVar] -> [Type] -> Type -> Type
- substTheta :: TvSubst -> ThetaType -> ThetaType
- substTyVar :: TvSubst -> TyVar -> Type
- substTyVars :: TvSubst -> [TyVar] -> [Type]
- isUnLiftedType :: Type -> Bool
- isUnboxedTupleType :: Type -> Bool
- isPrimitiveType :: Type -> Bool
- tyVarsOfType :: Type -> VarSet
- tyVarsOfTypes :: [Type] -> TyVarSet
- tyVarsOfPred :: PredType -> TyCoVarSet
- tyVarsOfTheta :: ThetaType -> TyCoVarSet
- tcTyVarsOfType :: Type -> TcTyVarSet
- tcTyVarsOfTypes :: [Type] -> TyVarSet
- tcTyVarsOfPred :: PredType -> TyVarSet
- exactTyVarsOfType :: Type -> TyVarSet
- exactTyVarsOfTypes :: [Type] -> TyVarSet
- pprKind, pprParendKind :: Kind -> SDoc
- pprType, pprParendType :: Type -> SDoc
- pprTypeApp :: NamedThing a => a -> [Type] -> SDoc
- pprTyThingCategory :: TyThing -> SDoc
- pprPred :: (Prec -> a -> SDoc) -> Pred a -> SDoc
- pprTheta :: ThetaType -> SDoc
- pprThetaArrow :: (Prec -> a -> SDoc) -> [Pred a] -> SDoc
- pprThetaArrowTy :: ThetaType -> SDoc
- pprClassPred :: Class -> [Type] -> SDoc
Documentation
type TcSigmaType = TcType
type TcPredType = PredType
type TcThetaType = ThetaType
type TcCoercion = Coercion
type TcTyVarSet = TyVarSet
data UserTypeCtxt
pprUserTypeCtxt :: UserTypeCtxt -> SDoc
data TcTyVarDetails
Constructors
SkolemTv Bool | |
RuntimeUnk | |
FlatSkol TcType | |
MetaTv MetaInfo (IORef MetaDetails) |
isImmutableTyVar :: TyVar -> Bool
isMetaTyVarTy :: TcType -> Bool
isSigTyVar :: Var -> Bool
metaTvRef :: TyVar -> IORef MetaDetails
isFlexi, isIndirect :: MetaDetails -> Bool
isRuntimeUnkSkol :: TyVar -> Bool
Similar to coreView
, but for the type checker, which just looks through synonyms
tcSplitForAllTys :: Type -> ([TyVar], Type)
tcSplitPhiTy :: Type -> (ThetaType, Type)
tcSplitPredFunTy_maybe :: Type -> Maybe (PredType, Type)
tcSplitFunTy_maybe :: Type -> Maybe (Type, Type)
tcSplitFunTys :: Type -> ([Type], Type)
tcFunArgTy :: Type -> Type
tcFunResultTy :: Type -> Type
tcSplitFunTysN :: TcRhoType -> Arity -> ([TcSigmaType], TcSigmaType)
tcSplitTyConApp :: Type -> (TyCon, [Type])
tcSplitTyConApp_maybe :: Type -> Maybe (TyCon, [Type])
tcTyConAppTyCon :: Type -> TyCon
tcTyConAppArgs :: Type -> [Type]
tcSplitAppTy_maybe :: Type -> Maybe (Type, Type)
tcSplitAppTy :: Type -> (Type, Type)
tcSplitAppTys :: Type -> (Type, [Type])
repSplitAppTy_maybe :: Type -> Maybe (Type, Type)
Does the AppTy split as in splitAppTy_maybe
, but assumes that
any Core view stuff is already done
tcInstHeadTyNotSynonym :: Type -> Bool
tcInstHeadTyAppAllTyVars :: Type -> Bool
tcGetTyVar_maybe :: Type -> Maybe TyVar
tcGetTyVar :: String -> Type -> TyVar
tcSplitSigmaTy :: Type -> ([TyVar], ThetaType, Type)
tcDeepSplitSigmaTy_maybe :: TcSigmaType -> Maybe ([TcType], [TyVar], ThetaType, TcSigmaType)
eqType :: Type -> Type -> Bool
Type equality on source types. Does not look through newtypes
or
PredType
s, but it does look through type synonyms.
isOverloadedTy :: Type -> Bool
isFloatTy, isCharTy, isUnitTy, isBoolTy, isWordTy, isIntTy, isIntegerTy, isDoubleTy :: Type -> Bool
isStringTy :: Type -> Bool
isTauTyCon :: TyCon -> Bool
tcIsTyVarTy :: Type -> Bool
tcIsForAllTy :: Type -> Bool
isSynFamilyTyConApp :: TcTauType -> Bool
deNoteType :: Type -> Type
orphNamesOfType :: Type -> NameSet
orphNamesOfDFunHead :: Type -> NameSet
orphNamesOfCo :: Coercion -> NameSet
getDFunTyKey :: Type -> OccName
mkMinimalBySCs :: [PredType] -> [PredType]
transSuperClasses :: Class -> [Type] -> [PredType]
immSuperClasses :: Class -> [Type] -> [PredType]
Tidying type related things up for printing
tidyOpenType :: TidyEnv -> Type -> (TidyEnv, Type)
Grabs the free type variables, tidies them
and then uses tidyType
to work over the type itself
tidyOpenTypes :: TidyEnv -> [Type] -> (TidyEnv, [Type])
tidyTyVarBndr :: TidyEnv -> TyVar -> (TidyEnv, TyVar)
This tidies up a type for printing in an error message, or in an interface file.
It doesn't change the uniques at all, just the print names.
tidyFreeTyVars :: TidyEnv -> TyVarSet -> TidyEnv
Add the free TyVar
s to the env in tidy form,
so that we can tidy the type they are free in
tidyOpenTyVar :: TidyEnv -> TyVar -> (TidyEnv, TyVar)
Treat a new TyVar
as a binder, and give it a fresh tidy name
using the environment if one has not already been allocated. See
also tidyTyVarBndr
tidyOpenTyVars :: TidyEnv -> [TyVar] -> (TidyEnv, [TyVar])
tidyTopType :: Type -> Type
Calls tidyType
on a top-level type (i.e. with an empty tidying environment)
isFFIArgumentTy :: DynFlags -> Safety -> Type -> Bool
isFFIImportResultTy :: DynFlags -> Type -> Bool
isFFIExportResultTy :: Type -> Bool
isFFIExternalTy :: Type -> Bool
isFFIDynArgumentTy :: Type -> Bool
isFFIDynResultTy :: Type -> Bool
isFFIPrimArgumentTy :: DynFlags -> Type -> Bool
isFFIPrimResultTy :: DynFlags -> Type -> Bool
isFFILabelTy :: Type -> Bool
isFFIDotnetTy :: DynFlags -> Type -> Bool
isFFIDotnetObjTy :: Type -> Bool
isFunPtrTy :: Type -> Bool
The key type representing kinds in the compiler. Invariant: a kind is always in one of these forms:
FunTy k1 k2 TyConApp PrimTyCon [...] TyVar kv -- (during inference only) ForAll ... -- (for top-level coercions)
mkArrowKind :: Kind -> Kind -> Kind
Given two kinds k1
and k2
, creates the Kind
k1 -> k2
mkArrowKinds :: [Kind] -> Kind -> Kind
Iterated application of mkArrowKind
isLiftedTypeKind :: Kind -> Bool
isUnliftedTypeKind :: Kind -> Bool
isSubOpenTypeKind :: Kind -> Bool
True of any sub-kind of OpenTypeKind (i.e. anything except arrow)
isSubArgTypeKind :: Kind -> Bool
True of any sub-kind of ArgTypeKind
splitKindFunTys :: Kind -> ([Kind], Kind)
Essentially splitFunTys
on kinds
defaultKind :: Kind -> Kind
Used when generalising: default kind ? and ?? to *. See Type for more information on what that means
kindVarRef :: KindVar -> IORef MetaDetails
mkKindVar :: Unique -> IORef MetaDetails -> KindVar
data Type
The key representation of types within the compiler
data Pred a
A type of the form PredTy p
represents a value whose type is
the Haskell predicate p
, where a predicate is what occurs before
the =>
in a Haskell type.
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"
mkForAllTy :: TyVar -> Type -> Type
mkForAllTys :: [TyVar] -> Type -> Type
Wraps foralls over the type using the provided TyVar
s from left to right
zipFunTys :: Outputable a => [a] -> Type -> ([(a, Type)], Type)
Splits off argument types from the given type and associating them with the things in the input list from left to right. The final result type is returned, along with the resulting pairs of objects and types, albeit with the list of pairs in reverse order. Panics if there are not enough argument types for the input list.
mkTyConApp :: TyCon -> [Type] -> Type
A key function: builds a TyConApp
or FunTy
as apppropriate to its arguments.
Applies its arguments to the constructor from left to right
applyTy :: Type -> Type -> Type
Instantiate a forall type with one or more type arguments. Used when we have a polymorphic function applied to type args:
f t1 t2
We use applyTys type-of-f [t1,t2]
to compute the type of the expression.
Panics if no application is possible.
applyTys :: Type -> [Type] -> Type
This function is interesting because:
- The function may have more for-alls than there are args
- Less obviously, it may have fewer for-alls
For case 2. think of:
applyTys (forall a.a) [forall b.b, Int]
This really can happen, via dressing up polymorphic types with newtype clothing. Here's an example:
newtype R = R (forall a. a->a) foo = case undefined :: R of R f -> f ()
mkTyVarTys :: [TyVar] -> [Type]
Create the plain type constructor type which has been applied to no type arguments at all.
getClassPredTys_maybe :: PredType -> Maybe (Class, [Type])
getClassPredTys :: PredType -> (Class, [Type])
isClassPred :: Pred a -> Bool
isTyVarClassPred :: PredType -> Bool
mkClassPred :: Class -> [Type] -> PredType
splitPredTy_maybe :: Type -> Maybe PredType
isDictLikeTy :: Type -> Bool
tcSplitDFunHead :: Type -> (Class, [Type])
data TvSubst
Type substitution
The following invariants must hold of a TvSubst
:
- 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 substition is only applied ONCE! This is because in general such application will not reached a fixed point.
Constructors
TvSubst InScopeSet TvSubstEnv |
Instances
type TvSubstEnv = TyVarEnv Type
mkOpenTvSubst :: TvSubstEnv -> TvSubst
zipOpenTvSubst :: [TyVar] -> [Type] -> TvSubst
zipTopTvSubst :: [TyVar] -> [Type] -> TvSubst
mkTopTvSubst :: [(TyVar, Type)] -> TvSubst
Called when doing top-level substitutions. Here we expect that the free vars of the range of the substitution will be empty.
notElemTvSubst :: TyCoVar -> TvSubst -> Bool
unionTvSubst :: TvSubst -> TvSubst -> TvSubst
getTvSubstEnv :: TvSubst -> TvSubstEnv
setTvSubstEnv :: TvSubst -> TvSubstEnv -> TvSubst
getTvInScope :: TvSubst -> InScopeSet
extendTvInScope :: TvSubst -> Var -> TvSubst
lookupTyVar :: TvSubst -> TyVar -> Maybe Type
extendTvSubst :: TvSubst -> TyVar -> Type -> TvSubst
substTyVarBndr :: TvSubst -> TyVar -> (TvSubst, TyVar)
extendTvSubstList :: TvSubst -> [TyVar] -> [Type] -> TvSubst
mkTvSubst :: InScopeSet -> TvSubstEnv -> TvSubst
zipTyEnv :: [TyVar] -> [Type] -> TvSubstEnv
substTyWith :: [TyVar] -> [Type] -> Type -> Type
Type substitution making use of an TvSubst
that
is assumed to be open, see zipOpenTvSubst
substTheta :: TvSubst -> ThetaType -> ThetaType
Substitute within a ThetaType
substTyVar :: TvSubst -> TyVar -> Type
substTyVars :: TvSubst -> [TyVar] -> [Type]
isUnLiftedType :: Type -> Bool
See Type for what an unlifted type is
isUnboxedTupleType :: Type -> Bool
isPrimitiveType :: Type -> Bool
Returns true of types that are opaque to Haskell. Most of these are unlifted, but now that we interact with .NET, we may have primtive (foreign-imported) types that are lifted
tyVarsOfType :: Type -> VarSet
NB: for type synonyms tyVarsOfType does not expand the synonym
tyVarsOfTypes :: [Type] -> TyVarSet
tyVarsOfPred :: PredType -> TyCoVarSet
tyVarsOfTheta :: ThetaType -> TyCoVarSet
tcTyVarsOfType :: Type -> TcTyVarSet
tcTyVarsOfTypes :: [Type] -> TyVarSet
tcTyVarsOfPred :: PredType -> TyVarSet
exactTyVarsOfType :: Type -> TyVarSet
exactTyVarsOfTypes :: [Type] -> TyVarSet
pprKind, pprParendKind :: Kind -> SDoc
pprType, pprParendType :: Type -> SDoc
pprTypeApp :: NamedThing a => a -> [Type] -> SDoc
pprTyThingCategory :: TyThing -> SDoc
pprThetaArrow :: (Prec -> a -> SDoc) -> [Pred a] -> SDoc
pprThetaArrowTy :: ThetaType -> SDoc
pprClassPred :: Class -> [Type] -> SDoc