Safe Haskell | None |
---|
- Finding type instances
- Finding exact (non-dead) type variables
- Tidying type related things up for printing
- type TcType = Type
- type TcSigmaType = TcType
- type TcRhoType = TcType
- type TcTauType = TcType
- type TcPredType = PredType
- type TcThetaType = ThetaType
- type TcTyVar = TyVar
- type TcTyVarSet = TyVarSet
- type TcKind = Kind
- type TcCoVar = CoVar
- data UserTypeCtxt
- = FunSigCtxt Name
- | InfSigCtxt Name
- | ExprSigCtxt
- | ConArgCtxt Name
- | TySynCtxt Name
- | LamPatSigCtxt
- | BindPatSigCtxt
- | ResSigCtxt
- | ForSigCtxt Name
- | DefaultDeclCtxt
- | InstDeclCtxt
- | SpecInstCtxt
- | ThBrackCtxt
- | GenSigCtxt
- | GhciCtxt
- | ClassSCCtxt Name
- | SigmaCtxt
- | DataTyCtxt Name
- pprUserTypeCtxt :: UserTypeCtxt -> SDoc
- data TcTyVarDetails
- = SkolemTv Bool
- | RuntimeUnk
- | FlatSkol TcType
- | MetaTv MetaInfo (IORef MetaDetails)
- pprTcTyVarDetails :: TcTyVarDetails -> SDoc
- vanillaSkolemTv :: TcTyVarDetails
- superSkolemTv :: TcTyVarDetails
- data MetaDetails
- data MetaInfo
- isImmutableTyVar :: TyVar -> Bool
- isSkolemTyVar :: TcTyVar -> Bool
- isMetaTyVar :: TcTyVar -> Bool
- isMetaTyVarTy :: TcType -> Bool
- isTyVarTy :: Type -> Bool
- isSigTyVar :: Var -> Bool
- isOverlappableTyVar :: TcTyVar -> Bool
- isTyConableTyVar :: TcTyVar -> Bool
- isAmbiguousTyVar :: TcTyVar -> Bool
- metaTvRef :: TyVar -> IORef MetaDetails
- isFlexi :: MetaDetails -> Bool
- 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
- isDoubleTy :: Type -> Bool
- isFloatTy :: Type -> Bool
- isIntTy :: Type -> Bool
- isWordTy :: Type -> Bool
- isStringTy :: Type -> Bool
- isIntegerTy :: Type -> Bool
- isBoolTy :: Type -> Bool
- isUnitTy :: Type -> Bool
- isCharTy :: Type -> Bool
- isTauTy :: Type -> Bool
- isTauTyCon :: TyCon -> Bool
- tcIsTyVarTy :: Type -> Bool
- tcIsForAllTy :: Type -> Bool
- isSynFamilyTyConApp :: TcTauType -> Bool
- isPredTy :: Type -> Bool
- isTyVarClassPred :: PredType -> Bool
- shallowPredTypePredTree :: PredType -> PredTree
- deNoteType :: Type -> Type
- orphNamesOfType :: Type -> NameSet
- orphNamesOfDFunHead :: Type -> NameSet
- orphNamesOfCo :: Coercion -> NameSet
- getDFunTyKey :: Type -> OccName
- evVarPred_maybe :: EvVar -> Maybe PredType
- evVarPred :: EvVar -> PredType
- mkMinimalBySCs :: [PredType] -> [PredType]
- transSuperClasses :: Class -> [Type] -> [PredType]
- immSuperClasses :: Class -> [Type] -> [PredType]
- tcTyFamInsts :: Type -> [(TyCon, [Type])]
- exactTyVarsOfType :: Type -> TyVarSet
- exactTyVarsOfTypes :: [Type] -> TyVarSet
- tidyType :: TidyEnv -> Type -> Type
- tidyTypes :: TidyEnv -> [Type] -> [Type]
- tidyOpenType :: TidyEnv -> Type -> (TidyEnv, Type)
- tidyOpenTypes :: TidyEnv -> [Type] -> (TidyEnv, [Type])
- tidyOpenKind :: TidyEnv -> Kind -> (TidyEnv, Kind)
- tidyTyVarBndr :: TidyEnv -> TyVar -> (TidyEnv, TyVar)
- tidyFreeTyVars :: TidyEnv -> TyVarSet -> TidyEnv
- tidyOpenTyVar :: TidyEnv -> TyVar -> (TidyEnv, TyVar)
- tidyOpenTyVars :: TidyEnv -> [TyVar] -> (TidyEnv, [TyVar])
- tidyTopType :: Type -> Type
- tidyKind :: TidyEnv -> Kind -> 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)
- type Kind = Type
- typeKind :: Type -> Kind
- unliftedTypeKind :: Kind
- liftedTypeKind :: Kind
- argTypeKind :: Kind
- openTypeKind :: Kind
- constraintKind :: 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
- mkMetaKindVar :: Unique -> IORef MetaDetails -> MetaKindVar
- data Type
- type PredType = 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 -> KindOrType -> Type
- applyTys :: Type -> [KindOrType] -> Type
- mkTyVarTy :: TyVar -> Type
- mkTyVarTys :: [TyVar] -> [Type]
- mkTyConTy :: TyCon -> Type
- isClassPred :: PredType -> Bool
- isEqPred :: PredType -> Bool
- isIPPred :: PredType -> Bool
- mkClassPred :: Class -> [Type] -> PredType
- mkIPPred :: IPName Name -> Type -> PredType
- isDictLikeTy :: Type -> Bool
- tcSplitDFunTy :: Type -> ([TyVar], Int, Class, [Type])
- tcSplitDFunHead :: Type -> (Class, [Type])
- mkEqPred :: (Type, Type) -> PredType
- 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 :: CoVar -> 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
- tcTyVarsOfType :: Type -> TcTyVarSet
- tcTyVarsOfTypes :: [Type] -> TyVarSet
- pprKind :: Kind -> SDoc
- pprParendKind :: Kind -> SDoc
- pprType :: Type -> SDoc
- pprParendType :: Type -> SDoc
- pprTypeApp :: NamedThing a => a -> [Type] -> SDoc
- pprTyThingCategory :: TyThing -> SDoc
- pprTheta :: ThetaType -> SDoc
- pprThetaArrowTy :: ThetaType -> SDoc
- pprClassPred :: Class -> [Type] -> SDoc
Documentation
type TcSigmaType = TcTypeSource
type TcPredType = PredTypeSource
type TcThetaType = ThetaTypeSource
type TcTyVarSet = TyVarSetSource
data UserTypeCtxt Source
data TcTyVarDetails Source
isImmutableTyVar :: TyVar -> BoolSource
isSkolemTyVar :: TcTyVar -> BoolSource
isMetaTyVar :: TcTyVar -> BoolSource
isMetaTyVarTy :: TcType -> BoolSource
isSigTyVar :: Var -> BoolSource
metaTvRef :: TyVar -> IORef MetaDetailsSource
isFlexi :: MetaDetails -> BoolSource
isIndirect :: MetaDetails -> BoolSource
isRuntimeUnkSkol :: TyVar -> BoolSource
tcView :: Type -> Maybe TypeSource
Similar to coreView
, but for the type checker, which just looks through synonyms
tcSplitForAllTys :: Type -> ([TyVar], Type)Source
tcSplitPhiTy :: Type -> (ThetaType, Type)Source
tcSplitFunTys :: Type -> ([Type], Type)Source
tcFunArgTy :: Type -> TypeSource
tcFunResultTy :: Type -> TypeSource
tcSplitFunTysN :: TcRhoType -> Arity -> ([TcSigmaType], TcSigmaType)Source
tcSplitTyConApp :: Type -> (TyCon, [Type])Source
tcTyConAppTyCon :: Type -> TyConSource
tcTyConAppArgs :: Type -> [Type]Source
tcSplitAppTy :: Type -> (Type, Type)Source
tcSplitAppTys :: Type -> (Type, [Type])Source
repSplitAppTy_maybe :: Type -> Maybe (Type, Type)Source
Does the AppTy split as in splitAppTy_maybe
, but assumes that
any Core view stuff is already done
tcGetTyVar_maybe :: Type -> Maybe TyVarSource
tcGetTyVar :: String -> Type -> TyVarSource
tcDeepSplitSigmaTy_maybe :: TcSigmaType -> Maybe ([TcType], [TyVar], ThetaType, TcSigmaType)Source
eqType :: Type -> Type -> BoolSource
Type equality on source types. Does not look through newtypes
or
PredType
s, but it does look through type synonyms.
isOverloadedTy :: Type -> BoolSource
isDoubleTy :: Type -> BoolSource
isStringTy :: Type -> BoolSource
isIntegerTy :: Type -> BoolSource
isTauTyCon :: TyCon -> BoolSource
tcIsTyVarTy :: Type -> BoolSource
tcIsForAllTy :: Type -> BoolSource
shallowPredTypePredTree :: PredType -> PredTreeSource
Like classifyPredType
but doesn't look through type synonyms.
Used to check that programs only use simple contexts without any
synonyms in them.
deNoteType :: Type -> TypeSource
orphNamesOfType :: Type -> NameSetSource
getDFunTyKey :: Type -> OccNameSource
mkMinimalBySCs :: [PredType] -> [PredType]Source
transSuperClasses :: Class -> [Type] -> [PredType]Source
immSuperClasses :: Class -> [Type] -> [PredType]Source
Finding type instances
tcTyFamInsts :: Type -> [(TyCon, [Type])]Source
Finds type family instances occuring in a type after expanding synonyms.
Finding exact (non-dead) type variables
exactTyVarsOfTypes :: [Type] -> TyVarSetSource
Tidying type related things up for printing
tidyOpenType :: TidyEnv -> Type -> (TidyEnv, Type)Source
Grabs the free type variables, tidies them
and then uses tidyType
to work over the type itself
tidyTyVarBndr :: TidyEnv -> TyVar -> (TidyEnv, TyVar)Source
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 -> TidyEnvSource
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)Source
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
tidyTopType :: Type -> TypeSource
Calls tidyType
on a top-level type (i.e. with an empty tidying environment)
isFFIImportResultTy :: DynFlags -> Type -> BoolSource
isFFIExternalTy :: Type -> BoolSource
isFFIDynArgumentTy :: Type -> BoolSource
isFFIDynResultTy :: Type -> BoolSource
isFFIPrimArgumentTy :: DynFlags -> Type -> BoolSource
isFFIPrimResultTy :: DynFlags -> Type -> BoolSource
isFFILabelTy :: Type -> BoolSource
isFFIDotnetTy :: DynFlags -> Type -> BoolSource
isFFIDotnetObjTy :: Type -> BoolSource
isFunPtrTy :: Type -> BoolSource
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)
mkArrowKinds :: [Kind] -> Kind -> KindSource
Iterated application of mkArrowKind
isLiftedTypeKind :: Kind -> BoolSource
isSubOpenTypeKind :: Kind -> BoolSource
True of any sub-kind of OpenTypeKind
True of any sub-kind of OpenTypeKind
isSubArgTypeKind :: Kind -> BoolSource
True of any sub-kind of ArgTypeKind
splitKindFunTys :: Kind -> ([Kind], Kind)Source
Essentially splitFunTys
on kinds
defaultKind :: Kind -> KindSource
Used when generalising: default OpenKind and ArgKind to *. See Type for more information on what that means
mkMetaKindVar :: Unique -> IORef MetaDetails -> MetaKindVarSource
The key representation of types within the compiler
A type of the form p
of kind Constraint
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"
mkForAllTy :: TyVar -> Type -> TypeSource
mkForAllTys :: [TyVar] -> Type -> TypeSource
Wraps foralls over the type using the provided TyVar
s from left to right
mkFunTy :: Type -> Type -> TypeSource
Creates a function type from the given argument and result type
zipFunTys :: Outputable a => [a] -> Type -> ([(a, Type)], Type)Source
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] -> TypeSource
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 -> KindOrType -> TypeSource
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 -> [KindOrType] -> TypeSource
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, but only (I think) in situations involving
undefined. For example:
undefined :: forall a. a
Term: undefined (forall b. b->b)
Int
This term should have type (Int -> Int), but notice that
there are more type args than foralls in undefined
s type.
mkTyVarTys :: [TyVar] -> [Type]Source
mkTyConTy :: TyCon -> TypeSource
Create the plain type constructor type which has been applied to no type arguments at all.
isClassPred :: PredType -> BoolSource
mkClassPred :: Class -> [Type] -> PredTypeSource
isDictLikeTy :: Type -> BoolSource
tcSplitDFunHead :: Type -> (Class, [Type])Source
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.
zipOpenTvSubst :: [TyVar] -> [Type] -> TvSubstSource
zipTopTvSubst :: [TyVar] -> [Type] -> TvSubstSource
mkTopTvSubst :: [(TyVar, Type)] -> TvSubstSource
Called when doing top-level substitutions. Here we expect that the free vars of the range of the substitution will be empty.
notElemTvSubst :: CoVar -> TvSubst -> BoolSource
unionTvSubst :: TvSubst -> TvSubst -> TvSubstSource
setTvSubstEnv :: TvSubst -> TvSubstEnv -> TvSubstSource
extendTvInScope :: TvSubst -> Var -> TvSubstSource
mkTvSubst :: InScopeSet -> TvSubstEnv -> TvSubstSource
zipTyEnv :: [TyVar] -> [Type] -> TvSubstEnvSource
substTyWith :: [TyVar] -> [Type] -> Type -> TypeSource
Type substitution making use of an TvSubst
that
is assumed to be open, see zipOpenTvSubst
substTyVar :: TvSubst -> TyVar -> TypeSource
substTyVars :: TvSubst -> [TyVar] -> [Type]Source
isUnLiftedType :: Type -> BoolSource
See Type for what an unlifted type is
isUnboxedTupleType :: Type -> BoolSource
isPrimitiveType :: Type -> BoolSource
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 -> VarSetSource
NB: for type synonyms tyVarsOfType does not expand the synonym tyVarsOfType returns only the free *type* variables of a type For example, tyVarsOfType (a::k) returns {a}, not including the kind variable {k}
tyVarsOfTypes :: [Type] -> TyVarSetSource
tcTyVarsOfTypes :: [Type] -> TyVarSetSource
pprParendKind :: Kind -> SDocSource
pprParendType :: Type -> SDocSource
pprTypeApp :: NamedThing a => a -> [Type] -> SDocSource
pprClassPred :: Class -> [Type] -> SDocSource