Safe Haskell  SafeInferred 

Language  Haskell2010 
Main functions for manipulating types and typerelated things
Synopsis
 data Type
 data ArgFlag where
 data AnonArgFlag
 data Specificity
 type KindOrType = Type
 type PredType = Type
 type ThetaType = [PredType]
 data Var
 type TyVar = Var
 isTyVar :: Var > Bool
 type TyCoVar = Id
 data TyCoBinder
 type TyCoVarBinder = VarBndr TyCoVar ArgFlag
 type TyVarBinder = VarBndr TyVar ArgFlag
 type Mult = Type
 data Scaled a
 type KnotTied ty = ty
 mkTyVarTy :: TyVar > Type
 mkTyVarTys :: [TyVar] > [Type]
 getTyVar :: String > Type > TyVar
 getTyVar_maybe :: Type > Maybe TyVar
 repGetTyVar_maybe :: Type > Maybe TyVar
 getCastedTyVar_maybe :: Type > Maybe (TyVar, CoercionN)
 tyVarKind :: TyVar > Kind
 varType :: Var > Kind
 mkAppTy :: Type > Type > Type
 mkAppTys :: Type > [Type] > Type
 splitAppTy :: Type > (Type, Type)
 splitAppTys :: Type > (Type, [Type])
 repSplitAppTys :: HasDebugCallStack => Type > (Type, [Type])
 splitAppTy_maybe :: Type > Maybe (Type, Type)
 repSplitAppTy_maybe :: HasDebugCallStack => Type > Maybe (Type, Type)
 tcRepSplitAppTy_maybe :: Type > Maybe (Type, Type)
 mkFunTy :: AnonArgFlag > Mult > Type > Type > Type
 mkVisFunTy :: Mult > Type > Type > Type
 mkInvisFunTy :: Mult > Type > Type > Type
 mkVisFunTys :: [Scaled Type] > Type > Type
 mkVisFunTyMany :: Type > Type > Type
 mkInvisFunTyMany :: Type > Type > Type
 mkVisFunTysMany :: [Type] > Type > Type
 mkInvisFunTysMany :: [Type] > Type > Type
 splitFunTy :: Type > (Mult, Type, Type)
 splitFunTy_maybe :: Type > Maybe (Mult, Type, Type)
 splitFunTys :: Type > ([Scaled Type], Type)
 funResultTy :: Type > Type
 funArgTy :: Type > Type
 mkTyConApp :: TyCon > [Type] > Type
 mkTyConTy :: TyCon > Type
 tYPE :: Type > Type
 tyConAppTyCon_maybe :: Type > Maybe TyCon
 tyConAppTyConPicky_maybe :: Type > Maybe TyCon
 tyConAppArgs_maybe :: Type > Maybe [Type]
 tyConAppTyCon :: Type > TyCon
 tyConAppArgs :: Type > [Type]
 splitTyConApp_maybe :: HasDebugCallStack => Type > Maybe (TyCon, [Type])
 splitTyConApp :: Type > (TyCon, [Type])
 tyConAppArgN :: Int > Type > Type
 tcSplitTyConApp_maybe :: HasCallStack => Type > Maybe (TyCon, [Type])
 splitListTyConApp_maybe :: Type > Maybe Type
 repSplitTyConApp_maybe :: HasDebugCallStack => Type > Maybe (TyCon, [Type])
 mkForAllTy :: TyCoVar > ArgFlag > Type > Type
 mkForAllTys :: [TyCoVarBinder] > Type > Type
 mkInvisForAllTys :: [InvisTVBinder] > Type > Type
 mkTyCoInvForAllTys :: [TyCoVar] > Type > Type
 mkSpecForAllTy :: TyVar > Type > Type
 mkSpecForAllTys :: [TyVar] > Type > Type
 mkVisForAllTys :: [TyVar] > Type > Type
 mkTyCoInvForAllTy :: TyCoVar > Type > Type
 mkInfForAllTy :: TyVar > Type > Type
 mkInfForAllTys :: [TyVar] > Type > Type
 splitForAllTyCoVars :: Type > ([TyCoVar], Type)
 splitForAllReqTVBinders :: Type > ([ReqTVBinder], Type)
 splitForAllInvisTVBinders :: Type > ([InvisTVBinder], Type)
 splitForAllTyCoVarBinders :: Type > ([TyCoVarBinder], Type)
 splitForAllTyCoVar_maybe :: Type > Maybe (TyCoVar, Type)
 splitForAllTyCoVar :: Type > (TyCoVar, Type)
 splitForAllTyVar_maybe :: Type > Maybe (TyCoVar, Type)
 splitForAllCoVar_maybe :: Type > Maybe (TyCoVar, Type)
 splitPiTy_maybe :: Type > Maybe (TyCoBinder, Type)
 splitPiTy :: Type > (TyCoBinder, Type)
 splitPiTys :: Type > ([TyCoBinder], Type)
 mkTyConBindersPreferAnon :: [TyVar] > TyCoVarSet > [TyConBinder]
 mkPiTy :: TyCoBinder > Type > Type
 mkPiTys :: [TyCoBinder] > Type > Type
 piResultTy :: HasDebugCallStack => Type > Type > Type
 piResultTys :: HasDebugCallStack => Type > [Type] > Type
 applyTysX :: [TyVar] > Type > [Type] > Type
 dropForAlls :: Type > Type
 mkFamilyTyConApp :: TyCon > [Type] > Type
 buildSynTyCon :: Name > [KnotTied TyConBinder] > Kind > [Role] > KnotTied Type > TyCon
 mkNumLitTy :: Integer > Type
 isNumLitTy :: Type > Maybe Integer
 mkStrLitTy :: FastString > Type
 isStrLitTy :: Type > Maybe FastString
 mkCharLitTy :: Char > Type
 isCharLitTy :: Type > Maybe Char
 isLitTy :: Type > Maybe TyLit
 isPredTy :: HasDebugCallStack => Type > Bool
 getRuntimeRep_maybe :: HasDebugCallStack => Type > Maybe Type
 kindRep_maybe :: HasDebugCallStack => Kind > Maybe Type
 kindRep :: HasDebugCallStack => Kind > Type
 mkCastTy :: Type > Coercion > Type
 mkCoercionTy :: Coercion > Type
 splitCastTy_maybe :: Type > Maybe (Type, Coercion)
 userTypeError_maybe :: Type > Maybe Type
 pprUserTypeErrorTy :: Type > SDoc
 coAxNthLHS :: CoAxiom br > Int > Type
 stripCoercionTy :: Type > Coercion
 splitInvisPiTys :: Type > ([TyCoBinder], Type)
 splitInvisPiTysN :: Int > Type > ([TyCoBinder], Type)
 invisibleTyBndrCount :: Type > Int
 filterOutInvisibleTypes :: TyCon > [Type] > [Type]
 filterOutInferredTypes :: TyCon > [Type] > [Type]
 partitionInvisibleTypes :: TyCon > [Type] > ([Type], [Type])
 partitionInvisibles :: [(a, ArgFlag)] > ([a], [a])
 tyConArgFlags :: TyCon > [Type] > [ArgFlag]
 appTyArgFlags :: Type > [Type] > [ArgFlag]
 data TyCoMapper env m = TyCoMapper {}
 mapTyCo :: Monad m => TyCoMapper () m > (Type > m Type, [Type] > m [Type], Coercion > m Coercion, [Coercion] > m [Coercion])
 mapTyCoX :: Monad m => TyCoMapper env m > (env > Type > m Type, env > [Type] > m [Type], env > Coercion > m Coercion, env > [Coercion] > m [Coercion])
 data TyCoFolder env a = TyCoFolder {}
 foldTyCo :: Monoid a => TyCoFolder env a > env > (Type > a, [Type] > a, Coercion > a, [Coercion] > a)
 newTyConInstRhs :: TyCon > [Type] > Type
 sameVis :: ArgFlag > ArgFlag > Bool
 mkTyCoVarBinder :: vis > TyCoVar > VarBndr TyCoVar vis
 mkTyCoVarBinders :: vis > [TyCoVar] > [VarBndr TyCoVar vis]
 mkTyVarBinder :: vis > TyVar > VarBndr TyVar vis
 mkTyVarBinders :: vis > [TyVar] > [VarBndr TyVar vis]
 tyVarSpecToBinders :: [VarBndr a Specificity] > [VarBndr a ArgFlag]
 mkAnonBinder :: AnonArgFlag > Scaled Type > TyCoBinder
 isAnonTyCoBinder :: TyCoBinder > Bool
 binderVar :: VarBndr tv argf > tv
 binderVars :: [VarBndr tv argf] > [tv]
 binderType :: VarBndr TyCoVar argf > Type
 binderArgFlag :: VarBndr tv argf > argf
 tyCoBinderType :: TyCoBinder > Type
 tyCoBinderVar_maybe :: TyCoBinder > Maybe TyCoVar
 tyBinderType :: TyBinder > Type
 binderRelevantType_maybe :: TyCoBinder > Maybe Type
 isVisibleArgFlag :: ArgFlag > Bool
 isInvisibleArgFlag :: ArgFlag > Bool
 isVisibleBinder :: TyCoBinder > Bool
 isInvisibleBinder :: TyCoBinder > Bool
 isNamedBinder :: TyCoBinder > Bool
 tyConBindersTyCoBinders :: [TyConBinder] > [TyCoBinder]
 funTyCon :: TyCon
 unrestrictedFunTyCon :: TyCon
 isTyVarTy :: Type > Bool
 isFunTy :: Type > Bool
 isCoercionTy :: Type > Bool
 isCoercionTy_maybe :: Type > Maybe Coercion
 isForAllTy :: Type > Bool
 isForAllTy_ty :: Type > Bool
 isForAllTy_co :: Type > Bool
 isPiTy :: Type > Bool
 isTauTy :: Type > Bool
 isFamFreeTy :: Type > Bool
 isCoVarType :: Type > Bool
 isAtomicTy :: Type > Bool
 isValidJoinPointType :: JoinArity > Type > Bool
 tyConAppNeedsKindSig :: Bool > TyCon > Int > Bool
 isLiftedType_maybe :: HasDebugCallStack => Type > Maybe Bool
 isLiftedTypeKind :: Kind > Bool
 isUnliftedTypeKind :: Kind > Bool
 isBoxedTypeKind :: Kind > Bool
 pickyIsLiftedTypeKind :: Kind > Bool
 isLiftedRuntimeRep :: Type > Bool
 isUnliftedRuntimeRep :: Type > Bool
 isBoxedRuntimeRep :: Type > Bool
 isLiftedLevity :: Type > Bool
 isUnliftedLevity :: Type > Bool
 isUnliftedType :: HasDebugCallStack => Type > Bool
 isBoxedType :: Type > Bool
 mightBeUnliftedType :: Type > Bool
 isUnboxedTupleType :: Type > Bool
 isUnboxedSumType :: Type > Bool
 isAlgType :: Type > Bool
 isDataFamilyAppType :: Type > Bool
 isPrimitiveType :: Type > Bool
 isStrictType :: HasDebugCallStack => Type > Bool
 isLevityTy :: Type > Bool
 isLevityVar :: TyVar > Bool
 isRuntimeRepTy :: Type > Bool
 isRuntimeRepVar :: TyVar > Bool
 isRuntimeRepKindedTy :: Type > Bool
 dropRuntimeRepArgs :: [Type] > [Type]
 getRuntimeRep :: HasDebugCallStack => Type > Type
 isMultiplicityTy :: Type > Bool
 isMultiplicityVar :: TyVar > Bool
 unrestricted :: a > Scaled a
 linear :: a > Scaled a
 tymult :: a > Scaled a
 mkScaled :: Mult > a > Scaled a
 irrelevantMult :: Scaled a > a
 scaledSet :: Scaled a > b > Scaled b
 pattern One :: Mult
 pattern Many :: Mult
 isOneDataConTy :: Mult > Bool
 isManyDataConTy :: Mult > Bool
 isLinearType :: Type > Bool
 type Kind = Type
 typeKind :: HasDebugCallStack => Type > Kind
 tcTypeKind :: HasDebugCallStack => Type > Kind
 isTypeLevPoly :: Type > Bool
 resultIsLevPoly :: Type > Bool
 tcIsLiftedTypeKind :: Kind > Bool
 tcIsConstraintKind :: Kind > Bool
 tcReturnsConstraintKind :: Kind > Bool
 tcIsBoxedTypeKind :: Kind > Bool
 tcIsRuntimeTypeKind :: Kind > Bool
 liftedTypeKind :: Kind
 unliftedTypeKind :: Kind
 tyCoFVsOfType :: Type > FV
 tyCoFVsBndr :: TyCoVarBinder > FV > FV
 tyCoFVsVarBndr :: Var > FV > FV
 tyCoFVsVarBndrs :: [Var] > FV > FV
 tyCoVarsOfType :: Type > TyCoVarSet
 tyCoVarsOfTypes :: [Type] > TyCoVarSet
 tyCoVarsOfTypeDSet :: Type > DTyCoVarSet
 coVarsOfType :: Type > CoVarSet
 coVarsOfTypes :: [Type] > CoVarSet
 anyFreeVarsOfType :: (TyCoVar > Bool) > Type > Bool
 anyFreeVarsOfTypes :: (TyCoVar > Bool) > [Type] > Bool
 noFreeVarsOfType :: Type > Bool
 splitVisVarsOfType :: Type > Pair TyCoVarSet
 splitVisVarsOfTypes :: [Type] > Pair TyCoVarSet
 expandTypeSynonyms :: Type > Type
 typeSize :: Type > Int
 occCheckExpand :: [Var] > Type > Maybe Type
 closeOverKindsDSet :: DTyVarSet > DTyVarSet
 closeOverKindsList :: [TyVar] > [TyVar]
 closeOverKinds :: TyCoVarSet > TyCoVarSet
 scopedSort :: [TyCoVar] > [TyCoVar]
 tyCoVarsOfTypeWellScoped :: Type > [TyVar]
 tyCoVarsOfTypesWellScoped :: [Type] > [TyVar]
 eqType :: Type > Type > Bool
 eqTypeX :: RnEnv2 > Type > Type > Bool
 eqTypes :: [Type] > [Type] > Bool
 nonDetCmpType :: Type > Type > Ordering
 nonDetCmpTypes :: [Type] > [Type] > Ordering
 nonDetCmpTypeX :: RnEnv2 > Type > Type > Ordering
 nonDetCmpTypesX :: RnEnv2 > [Type] > [Type] > Ordering
 nonDetCmpTc :: TyCon > TyCon > Ordering
 eqVarBndrs :: RnEnv2 > [Var] > [Var] > Maybe RnEnv2
 seqType :: Type > ()
 seqTypes :: [Type] > ()
 coreView :: Type > Maybe Type
 tcView :: Type > Maybe Type
 tyConsOfType :: Type > UniqSet TyCon
 type TvSubstEnv = TyVarEnv Type
 data TCvSubst = TCvSubst InScopeSet TvSubstEnv CvSubstEnv
 emptyTvSubstEnv :: TvSubstEnv
 emptyTCvSubst :: TCvSubst
 mkEmptyTCvSubst :: InScopeSet > TCvSubst
 mkTCvSubst :: InScopeSet > (TvSubstEnv, CvSubstEnv) > TCvSubst
 zipTvSubst :: HasDebugCallStack => [TyVar] > [Type] > TCvSubst
 mkTvSubstPrs :: [(TyVar, Type)] > TCvSubst
 zipTCvSubst :: HasDebugCallStack => [TyCoVar] > [Type] > TCvSubst
 notElemTCvSubst :: Var > TCvSubst > Bool
 getTvSubstEnv :: TCvSubst > TvSubstEnv
 setTvSubstEnv :: TCvSubst > TvSubstEnv > TCvSubst
 zapTCvSubst :: TCvSubst > TCvSubst
 getTCvInScope :: TCvSubst > InScopeSet
 getTCvSubstRangeFVs :: TCvSubst > VarSet
 extendTCvInScope :: TCvSubst > Var > TCvSubst
 extendTCvInScopeList :: TCvSubst > [Var] > TCvSubst
 extendTCvInScopeSet :: TCvSubst > VarSet > TCvSubst
 extendTCvSubst :: TCvSubst > TyCoVar > Type > TCvSubst
 extendCvSubst :: TCvSubst > CoVar > Coercion > TCvSubst
 extendTvSubst :: TCvSubst > TyVar > Type > TCvSubst
 extendTvSubstBinderAndInScope :: TCvSubst > TyCoBinder > Type > TCvSubst
 extendTvSubstList :: TCvSubst > [Var] > [Type] > TCvSubst
 extendTvSubstAndInScope :: TCvSubst > TyVar > Type > TCvSubst
 extendTCvSubstList :: TCvSubst > [Var] > [Type] > TCvSubst
 extendTvSubstWithClone :: TCvSubst > TyVar > TyVar > TCvSubst
 extendTCvSubstWithClone :: TCvSubst > TyCoVar > TyCoVar > TCvSubst
 isInScope :: Var > TCvSubst > Bool
 composeTCvSubstEnv :: InScopeSet > (TvSubstEnv, CvSubstEnv) > (TvSubstEnv, CvSubstEnv) > (TvSubstEnv, CvSubstEnv)
 composeTCvSubst :: TCvSubst > TCvSubst > TCvSubst
 zipTyEnv :: HasDebugCallStack => [TyVar] > [Type] > TvSubstEnv
 zipCoEnv :: HasDebugCallStack => [CoVar] > [Coercion] > CvSubstEnv
 isEmptyTCvSubst :: TCvSubst > Bool
 unionTCvSubst :: TCvSubst > TCvSubst > TCvSubst
 substTy :: HasCallStack => TCvSubst > Type > Type
 substTys :: HasCallStack => TCvSubst > [Type] > [Type]
 substScaledTy :: HasCallStack => TCvSubst > Scaled Type > Scaled Type
 substScaledTys :: HasCallStack => TCvSubst > [Scaled Type] > [Scaled Type]
 substTyWith :: HasCallStack => [TyVar] > [Type] > Type > Type
 substTysWith :: [TyVar] > [Type] > [Type] > [Type]
 substTheta :: HasCallStack => TCvSubst > ThetaType > ThetaType
 substTyAddInScope :: TCvSubst > Type > Type
 substTyUnchecked :: TCvSubst > Type > Type
 substTysUnchecked :: TCvSubst > [Type] > [Type]
 substScaledTyUnchecked :: HasCallStack => TCvSubst > Scaled Type > Scaled Type
 substScaledTysUnchecked :: TCvSubst > [Scaled Type] > [Scaled Type]
 substThetaUnchecked :: TCvSubst > ThetaType > ThetaType
 substTyWithUnchecked :: [TyVar] > [Type] > Type > Type
 substCoUnchecked :: TCvSubst > Coercion > Coercion
 substCoWithUnchecked :: [TyVar] > [Type] > Coercion > Coercion
 substTyVarBndr :: HasCallStack => TCvSubst > TyVar > (TCvSubst, TyVar)
 substTyVarBndrs :: HasCallStack => TCvSubst > [TyVar] > (TCvSubst, [TyVar])
 substTyVar :: TCvSubst > TyVar > Type
 substTyVars :: TCvSubst > [TyVar] > [Type]
 substVarBndr :: HasCallStack => TCvSubst > TyCoVar > (TCvSubst, TyCoVar)
 substVarBndrs :: HasCallStack => TCvSubst > [TyCoVar] > (TCvSubst, [TyCoVar])
 substTyCoBndr :: TCvSubst > TyCoBinder > (TCvSubst, TyCoBinder)
 cloneTyVarBndr :: TCvSubst > TyVar > Unique > (TCvSubst, TyVar)
 cloneTyVarBndrs :: TCvSubst > [TyVar] > UniqSupply > (TCvSubst, [TyVar])
 lookupTyVar :: TCvSubst > TyVar > Maybe Type
 tidyType :: TidyEnv > Type > Type
 tidyTypes :: TidyEnv > [Type] > [Type]
 tidyOpenType :: TidyEnv > Type > (TidyEnv, Type)
 tidyOpenTypes :: TidyEnv > [Type] > (TidyEnv, [Type])
 tidyOpenKind :: TidyEnv > Kind > (TidyEnv, Kind)
 tidyVarBndr :: TidyEnv > TyCoVar > (TidyEnv, TyCoVar)
 tidyVarBndrs :: TidyEnv > [TyCoVar] > (TidyEnv, [TyCoVar])
 tidyFreeTyCoVars :: TidyEnv > [TyCoVar] > TidyEnv
 tidyOpenTyCoVar :: TidyEnv > TyCoVar > (TidyEnv, TyCoVar)
 tidyOpenTyCoVars :: TidyEnv > [TyCoVar] > (TidyEnv, [TyCoVar])
 tidyTyCoVarOcc :: TidyEnv > TyCoVar > TyCoVar
 tidyTopType :: Type > Type
 tidyKind :: TidyEnv > Kind > Kind
 tidyTyCoVarBinder :: TidyEnv > VarBndr TyCoVar vis > (TidyEnv, VarBndr TyCoVar vis)
 tidyTyCoVarBinders :: TidyEnv > [VarBndr TyCoVar vis] > (TidyEnv, [VarBndr TyCoVar vis])
 isConstraintKindCon :: TyCon > Bool
 classifiesTypeWithValues :: Kind > Bool
 isKindLevPoly :: Kind > Bool
Main data types representing Types
Types are any, but at least one, of:
 Boxed
 Iff its representation is a pointer to an object on the GC'd heap. Operationally, heap objects can be entered as a means of evaluation.
 Lifted
 Iff it has bottom as an element: An instance of a lifted type might diverge when evaluated. GHC Haskell's unboxed types are unlifted. An unboxed, but lifted type is not very useful. (Example: A byterepresented type, where evaluating 0xff computes the 12345678th collatz number modulo 0xff.) Only lifted types may be unified with a type variable.
 Algebraic
 Iff it is a type with one or more constructors, whether
declared with
data
ornewtype
. An algebraic type is one that can be deconstructed with a case expression. There are algebraic types that are not lifted types, like unlifted data types or unboxed tuples.  Data
 Iff it is a type declared with
data
, or a boxed tuple. There are also unlifted data types.  Primitive
 Iff it is a builtin type that can't be expressed in Haskell.
Currently, all primitive types are unlifted, but that's not necessarily
the case: for example, Int
could be primitive.
Some primitive types are unboxed, such as Int#
, whereas some are boxed
but unlifted (such as ByteArray#
). The only primitive types that we
classify as algebraic are the unboxed tuples.
Some examples of type classifications that may make this a bit clearer are:
Type primitive boxed lifted algebraic  Int# Yes No No No ByteArray# Yes Yes No No (# a, b #) Yes No No Yes (# a  b #) Yes No No Yes ( a, b ) No Yes Yes Yes [a] No Yes Yes Yes
A source type is a type that is a separate type as far as the type checker is concerned, but which has a more lowlevel representation as far as CoretoCore passes and the rest of the back end is concerned.
You don't normally have to worry about this, as the utility functions in this module will automatically convert a source into a representation type if they are spotted, to the best of its abilities. If you don't want this to happen, use the equivalent functions from the TcType module.
Instances
Data Type Source #  
Defined in GHC.Core.TyCo.Rep 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 Source #  
Eq (DeBruijn Type) Source #  
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
Instances
Data ArgFlag Source #  
Defined in GHC.Types.Var 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 #  
Binary ArgFlag Source #  
Outputable ArgFlag Source #  
Eq ArgFlag Source #  
Ord ArgFlag Source #  
Outputable tv => Outputable (VarBndr tv ArgFlag) Source #  
data AnonArgFlag Source #
The nondependent 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
VisArg  Used for 
InvisArg  Used for 
Instances
data Specificity Source #
Whether an Invisible
argument may appear in source Haskell.
InferredSpec  the argument may not appear in source Haskell, it is only inferred. 
SpecifiedSpec  the argument may appear in source Haskell, but isn't required. 
Instances
type KindOrType = Type Source #
The key representation of types within the compiler
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"
Variable
Essentially a typed Name
, that may also contain some additional information
about the Var
and its use sites.
Instances
Data Var Source #  
Defined in GHC.Types.Var gfoldl :: (forall d b. Data d => c (d > b) > d > c b) > (forall g. g > c g) > Var > c Var Source # gunfold :: (forall b r. Data b => c (b > r) > c r) > (forall r. r > c r) > Constr > c Var Source # toConstr :: Var > Constr Source # dataTypeOf :: Var > DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) > Maybe (c Var) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) > Maybe (c Var) Source # gmapT :: (forall b. Data b => b > b) > Var > Var Source # gmapQl :: (r > r' > r) > r > (forall d. Data d => d > r') > Var > r Source # gmapQr :: forall r r'. (r' > r > r) > r > (forall d. Data d => d > r') > Var > r Source # gmapQ :: (forall d. Data d => d > u) > Var > [u] Source # gmapQi :: Int > (forall d. Data d => d > u) > Var > u Source # gmapM :: Monad m => (forall d. Data d => d > m d) > Var > m Var Source # gmapMp :: MonadPlus m => (forall d. Data d => d > m d) > Var > m Var Source # gmapMo :: MonadPlus m => (forall d. Data d => d > m d) > Var > m Var Source #  
NamedThing Var Source #  
HasOccName Var Source #  
Uniquable Var Source #  
Outputable Var Source #  
OutputableBndr Var Source #  
Defined in GHC.Core.Ppr  
Eq Var Source #  
Ord Var Source #  
Eq (DeBruijn CoreAlt) Source #  
Eq (DeBruijn CoreExpr) Source #  
type Anno Id Source #  
Defined in GHC.Hs.Extension  
type Anno (LocatedN Id) Source #  
Defined in GHC.Hs.Binds  
type Anno [LocatedN Id] Source #  
Defined in GHC.Hs.Binds 
isTyVar :: Var > Bool Source #
Is this a typelevel (i.e., computationally irrelevant, thus erasable)
variable? Satisfies isTyVar = not . isId
.
data TyCoBinder Source #
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 Source #  
Defined in GHC.Core.TyCo.Rep 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 Source #  
Defined in GHC.Core.TyCo.Rep ppr :: TyCoBinder > SDoc Source # 
type TyCoVarBinder = VarBndr TyCoVar ArgFlag Source #
Variable Binder
A TyCoVarBinder
is the binder of a ForAllTy
It's convenient to define this synonym here rather its natural
home in GHC.Core.TyCo.Rep, because it's used in GHC.Core.DataCon.hsboot
A TyVarBinder
is a binder with only TyVar
Mult is a type alias for Type.
Mult must contain Type because multiplicity variables are mere type variables (of kind Multiplicity) in Haskell. So the simplest implementation is to make Mult be Type.
Multiplicities can be formed with:  One: GHC.Types.One (= oneDataCon)  Many: GHC.Types.Many (= manyDataCon)  Multiplication: GHC.Types.MultMul (= multMulTyCon)
So that Mult feels a bit more structured, we provide pattern synonyms and smart constructors for these.
A shorthand for data with an attached Mult
element (the multiplicity).
Instances
Data a => Data (Scaled a) Source #  
Defined in GHC.Core.TyCo.Rep gfoldl :: (forall d b. Data d => c (d > b) > d > c b) > (forall g. g > c g) > Scaled a > c (Scaled a) Source # gunfold :: (forall b r. Data b => c (b > r) > c r) > (forall r. r > c r) > Constr > c (Scaled a) Source # toConstr :: Scaled a > Constr Source # dataTypeOf :: Scaled a > DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) > Maybe (c (Scaled a)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) > Maybe (c (Scaled a)) Source # gmapT :: (forall b. Data b => b > b) > Scaled a > Scaled a Source # gmapQl :: (r > r' > r) > r > (forall d. Data d => d > r') > Scaled a > r Source # gmapQr :: forall r r'. (r' > r > r) > r > (forall d. Data d => d > r') > Scaled a > r Source # gmapQ :: (forall d. Data d => d > u) > Scaled a > [u] Source # gmapQi :: Int > (forall d. Data d => d > u) > Scaled a > u Source # gmapM :: Monad m => (forall d. Data d => d > m d) > Scaled a > m (Scaled a) Source # gmapMp :: MonadPlus m => (forall d. Data d => d > m d) > Scaled a > m (Scaled a) Source # gmapMo :: MonadPlus m => (forall d. Data d => d > m d) > Scaled a > m (Scaled a) Source #  
Outputable a => Outputable (Scaled a) Source #  
type KnotTied ty = ty Source #
A type labeled KnotTied
might have knottied tycons in it. See
Note [Type checking recursive type and class declarations] in
GHC.Tc.TyCl
Constructing and deconstructing types
mkTyVarTys :: [TyVar] > [Type] Source #
getTyVar :: String > Type > TyVar Source #
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
getTyVar_maybe :: Type > Maybe TyVar Source #
Attempts to obtain the type variable underlying a Type
repGetTyVar_maybe :: Type > Maybe TyVar Source #
Attempts to obtain the type variable underlying a Type
, without
any expansion
getCastedTyVar_maybe :: Type > Maybe (TyVar, CoercionN) Source #
If the type is a tyvar, possibly under a cast, returns it, along with the coercion. Thus, the co is :: kind tv ~N kind ty
splitAppTy :: Type > (Type, Type) Source #
Attempts to take a type application apart, as in splitAppTy_maybe
,
and panics if this is not possible
splitAppTys :: Type > (Type, [Type]) Source #
Recursively splits a type as far as is possible, leaving a residual type being applied to and the type arguments applied to it. Never fails, even if that means returning an empty list of type applications.
repSplitAppTys :: HasDebugCallStack => Type > (Type, [Type]) Source #
Like splitAppTys
, but doesn't look through type synonyms
splitAppTy_maybe :: Type > Maybe (Type, Type) Source #
Attempt to take a type application apart, whether it is a function, type constructor, or plain type application. Note that type family applications are NEVER unsaturated by this!
repSplitAppTy_maybe :: HasDebugCallStack => Type > Maybe (Type, Type) Source #
Does the AppTy split as in splitAppTy_maybe
, but assumes that
any Core view stuff is already done
tcRepSplitAppTy_maybe :: Type > Maybe (Type, Type) Source #
Does the AppTy split as in tcSplitAppTy_maybe
, but assumes that
any coreView stuff is already done. Refuses to look through (c => t)
mkVisFunTyMany :: Type > Type > Type infixr 3 Source #
Special, common, case: Arrow type with mult Many
splitFunTy :: Type > (Mult, Type, Type) Source #
Attempts to extract the multiplicity, argument and result types from a type,
and panics if that is not possible. See also splitFunTy_maybe
splitFunTy_maybe :: Type > Maybe (Mult, Type, Type) Source #
Attempts to extract the multiplicity, argument and result types from a type
funResultTy :: Type > Type Source #
Extract the function result type and panic if that is not possible
funArgTy :: Type > Type Source #
Just like piResultTys
but for a single argument
Try not to iterate piResultTy
, because it's inefficient to substitute
one variable at a time; instead use 'piResultTys"
Extract the function argument type and panic if that is not possible
mkTyConTy :: TyCon > Type Source #
Create the plain type constructor type which has been applied to no type arguments at all.
Given a RuntimeRep
, applies TYPE
to it.
See Note [TYPE and RuntimeRep] in GHC.Builtin.Types.Prim.
tyConAppTyConPicky_maybe :: Type > Maybe TyCon Source #
Retrieve the tycon heading this type, if there is one. Does not look through synonyms.
tyConAppTyCon :: Type > TyCon Source #
tyConAppArgs :: Type > [Type] Source #
splitTyConApp_maybe :: HasDebugCallStack => Type > Maybe (TyCon, [Type]) Source #
Attempts to tease a type apart into a type constructor and the application of a number of arguments to that constructor
splitTyConApp :: Type > (TyCon, [Type]) Source #
Attempts to tease a type apart into a type constructor and the application
of a number of arguments to that constructor. Panics if that is not possible.
See also splitTyConApp_maybe
tcSplitTyConApp_maybe :: HasCallStack => Type > Maybe (TyCon, [Type]) Source #
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.
This does *not* split types headed with (=>), as that's not a TyCon in the typechecker.
If you only need the TyCon
, consider using tcTyConAppTyCon_maybe
.
splitListTyConApp_maybe :: Type > Maybe Type Source #
Attempts to tease a list type apart and gives the type of the elements if successful (looks through type synonyms)
repSplitTyConApp_maybe :: HasDebugCallStack => Type > Maybe (TyCon, [Type]) Source #
Like splitTyConApp_maybe
, but doesn't look through synonyms. This
assumes the synonyms have already been dealt with.
Moreover, for a FunTy, it only succeeds if the argument types have enough info to extract the runtimerep arguments that the funTyCon requires. This will usually be true; but may be temporarily false during canonicalization: see Note [Decomposing FunTy] in GHC.Tc.Solver.Canonical
mkForAllTy :: TyCoVar > ArgFlag > Type > Type Source #
Like mkTyCoForAllTy
, but does not check the occurrence of the binder
See Note [Unused coercion variable in ForAllTy]
mkForAllTys :: [TyCoVarBinder] > Type > Type Source #
Wraps foralls over the type using the provided TyCoVar
s from left to right
mkInvisForAllTys :: [InvisTVBinder] > Type > Type Source #
Wraps foralls over the type using the provided InvisTVBinder
s from left to right
mkTyCoInvForAllTys :: [TyCoVar] > Type > Type Source #
Like mkForAllTys
, but assumes all variables are dependent and
Inferred
, a common case
mkSpecForAllTy :: TyVar > Type > Type Source #
Like mkForAllTy
, but assumes the variable is dependent and Specified
,
a common case
mkSpecForAllTys :: [TyVar] > Type > Type Source #
Like mkForAllTys
, but assumes all variables are dependent and
Specified
, a common case
mkVisForAllTys :: [TyVar] > Type > Type Source #
Like mkForAllTys, but assumes all variables are dependent and visible
mkTyCoInvForAllTy :: TyCoVar > Type > Type Source #
Make a dependent forall over an Inferred
variable
mkInfForAllTy :: TyVar > Type > Type Source #
Like mkTyCoInvForAllTy
, but tv should be a tyvar
mkInfForAllTys :: [TyVar] > Type > Type Source #
Like mkTyCoInvForAllTys
, but tvs should be a list of tyvar
splitForAllTyCoVars :: Type > ([TyCoVar], Type) Source #
Take a ForAllTy apart, returning the list of tycovars and the result type. This always succeeds, even if it returns only an empty list. Note that the result type returned may have free variables that were bound by a forall.
splitForAllReqTVBinders :: Type > ([ReqTVBinder], Type) Source #
Like splitForAllTyCoVars
, but only splits ForAllTy
s with Required
type
variable binders. Furthermore, each returned tyvar is annotated with ()
.
splitForAllInvisTVBinders :: Type > ([InvisTVBinder], Type) Source #
Like splitForAllTyCoVars
, but only splits ForAllTy
s with Invisible
type
variable binders. Furthermore, each returned tyvar is annotated with its
Specificity
.
splitForAllTyCoVarBinders :: Type > ([TyCoVarBinder], Type) Source #
Like splitPiTys
but split off only named binders
and returns TyCoVarBinder
s rather than TyCoBinder
s
splitForAllTyCoVar_maybe :: Type > Maybe (TyCoVar, Type) Source #
Attempts to take a forall type apart, but only if it's a proper forall, with a named binder
splitForAllTyCoVar :: Type > (TyCoVar, Type) Source #
Take a forall type apart, or panics if that is not possible.
splitForAllTyVar_maybe :: Type > Maybe (TyCoVar, Type) Source #
Like splitForAllTyCoVar_maybe
, but only returns Just if it is a tyvar binder.
splitForAllCoVar_maybe :: Type > Maybe (TyCoVar, Type) Source #
Like splitForAllTyCoVar_maybe
, but only returns Just if it is a covar binder.
splitPiTy_maybe :: Type > Maybe (TyCoBinder, Type) Source #
Attempts to take a forall type apart; works with proper foralls and functions
splitPiTys :: Type > ([TyCoBinder], Type) Source #
Split off all TyCoBinders to a type, splitting both proper foralls and functions
mkTyConBindersPreferAnon Source #
:: [TyVar]  binders 
> TyCoVarSet  free variables of result 
> [TyConBinder] 
Given a list of typelevel vars and the free vars of a result kind, makes TyCoBinders, preferring anonymous binders if the variable is, in fact, not dependent. e.g. mkTyConBindersPreferAnon (k:*),(b:k),(c:k) We want (k:*) Named, (b:k) Anon, (c:k) Anon
All noncoercion binders are visible.
piResultTy :: HasDebugCallStack => Type > Type > Type Source #
piResultTys :: HasDebugCallStack => Type > [Type] > Type Source #
(piResultTys f_ty [ty1, .., tyn]) gives the type of (f ty1 .. tyn)
where f :: f_ty
piResultTys
is interesting because:
1. f_ty
may have more foralls than there are args
2. Less obviously, it may have fewer foralls
For case 2. think of:
piResultTys (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.
dropForAlls :: Type > Type Source #
Drops all ForAllTys
mkFamilyTyConApp :: TyCon > [Type] > Type Source #
Given a family instance TyCon and its arg types, return the corresponding family type. E.g:
data family T a data instance T (Maybe b) = MkT b
Where the instance tycon is :RTL, so:
mkFamilyTyConApp :RTL Int = T (Maybe Int)
mkNumLitTy :: Integer > Type Source #
isNumLitTy :: Type > Maybe Integer Source #
Is this a numeric literal. We also look through type synonyms.
mkStrLitTy :: FastString > Type Source #
isStrLitTy :: Type > Maybe FastString Source #
Is this a symbol literal. We also look through type synonyms.
mkCharLitTy :: Char > Type Source #
isCharLitTy :: Type > Maybe Char Source #
Is this a char literal? We also look through type synonyms.
getRuntimeRep_maybe :: HasDebugCallStack => Type > Maybe Type Source #
Extract the RuntimeRep classifier of a type. For instance,
getRuntimeRep_maybe Int = LiftedRep
. Returns Nothing
if this is not
possible.
kindRep_maybe :: HasDebugCallStack => Kind > Maybe Type Source #
Given a kind (TYPE rr), extract its RuntimeRep classifier rr.
For example, kindRep_maybe * = Just LiftedRep
Returns Nothing
if the kind is not of form (TYPE rr)
Treats * and Constraint as the same
kindRep :: HasDebugCallStack => Kind > Type Source #
Extract the RuntimeRep classifier of a type from its kind. For example,
kindRep * = LiftedRep
; Panics if this is not possible.
Treats * and Constraint as the same
mkCastTy :: Type > Coercion > Type Source #
Make a CastTy
. The Coercion must be nominal. Checks the
Coercion for reflexivity, dropping it if it's reflexive.
See Note [Respecting definitional equality] in GHC.Core.TyCo.Rep
mkCoercionTy :: Coercion > Type Source #
userTypeError_maybe :: Type > Maybe Type Source #
Is this type a custom user error? If so, give us the kind and the error message.
pprUserTypeErrorTy :: Type > SDoc Source #
Render a type corresponding to a user type error into a SDoc.
coAxNthLHS :: CoAxiom br > Int > Type Source #
Get the type on the LHS of a coercion induced by a type/data family instance.
stripCoercionTy :: Type > Coercion Source #
splitInvisPiTys :: Type > ([TyCoBinder], Type) Source #
Like splitPiTys
, but returns only *invisible* binders, including constraints.
Stops at the first visible binder.
splitInvisPiTysN :: Int > Type > ([TyCoBinder], Type) Source #
Same as splitInvisPiTys
, but stop when
 you have found n
TyCoBinder
s,
 or you run out of invisible binders
invisibleTyBndrCount :: Type > Int Source #
partitionInvisibles :: [(a, ArgFlag)] > ([a], [a]) Source #
Given a list of things paired with their visibilities, partition the things into (invisible things, visible things).
tyConArgFlags :: TyCon > [Type] > [ArgFlag] Source #
Given a TyCon
and a list of argument types to which the TyCon
is
applied, determine each argument's visibility
(Inferred
, Specified
, or Required
).
Wrinkle: consider the following scenario:
T :: forall k. k > k tyConArgFlags T [forall m. m > m > m, S, R, Q]
After substituting, we get
T (forall m. m > m > m) :: (forall m. m > m > m) > forall n. n > n > n
Thus, the first argument is invisible, S
is visible, R
is invisible again,
and Q
is visible.
appTyArgFlags :: Type > [Type] > [ArgFlag] Source #
Given a Type
and a list of argument types to which the Type
is
applied, determine each argument's visibility
(Inferred
, Specified
, or Required
).
Most of the time, the arguments will be Required
, but not always. Consider
f :: forall a. a > Type
. In f Type Bool
, the first argument (Type
) is
Specified
and the second argument (Bool
) is Required
. It is precisely
this sort of higherrank situation in which appTyArgFlags
comes in handy,
since f Type Bool
would be represented in Core using AppTy
s.
(See also #15792).
Analyzing types
data TyCoMapper env m Source #
This describes how a "map" operation over a type/coercion should behave
TyCoMapper  

mapTyCo :: Monad m => TyCoMapper () m > (Type > m Type, [Type] > m [Type], Coercion > m Coercion, [Coercion] > m [Coercion]) Source #
mapTyCoX :: Monad m => TyCoMapper env m > (env > Type > m Type, env > [Type] > m [Type], env > Coercion > m Coercion, env > [Coercion] > m [Coercion]) Source #
data TyCoFolder env a Source #
TyCoFolder  

foldTyCo :: Monoid a => TyCoFolder env a > env > (Type > a, [Type] > a, Coercion > a, [Coercion] > a) Source #
newTyConInstRhs :: TyCon > [Type] > Type Source #
Unwrap one layer
of newtype on a type constructor and its
arguments, using an etareduced version of the newtype
if possible.
This requires tys to have at least newTyConInstArity tycon
elements.
Binders
mkTyVarBinder :: vis > TyVar > VarBndr TyVar vis Source #
Make a named binder
var
should be a type variable
mkTyVarBinders :: vis > [TyVar] > [VarBndr TyVar vis] Source #
Make many named binders Input vars should be type variables
tyVarSpecToBinders :: [VarBndr a Specificity] > [VarBndr a ArgFlag] Source #
mkAnonBinder :: AnonArgFlag > Scaled Type > TyCoBinder Source #
Make an anonymous binder
isAnonTyCoBinder :: TyCoBinder > Bool Source #
Does this binder bind a variable that is not erased? Returns
True
for anonymous binders.
binderVars :: [VarBndr tv argf] > [tv] Source #
binderArgFlag :: VarBndr tv argf > argf Source #
tyCoBinderType :: TyCoBinder > Type Source #
tyBinderType :: TyBinder > Type Source #
binderRelevantType_maybe :: TyCoBinder > Maybe Type Source #
Extract a relevant type, if there is one.
isVisibleArgFlag :: ArgFlag > Bool Source #
Does this ArgFlag
classify an argument that is written in Haskell?
isInvisibleArgFlag :: ArgFlag > Bool Source #
Does this ArgFlag
classify an argument that is not written in Haskell?
isVisibleBinder :: TyCoBinder > Bool Source #
Does this binder bind a visible argument?
isInvisibleBinder :: TyCoBinder > Bool Source #
Does this binder bind an invisible argument?
isNamedBinder :: TyCoBinder > Bool Source #
tyConBindersTyCoBinders :: [TyConBinder] > [TyCoBinder] Source #
Common type constructors
The FUN
type constructor.
FUN :: forall (m :: Multiplicity) > forall {rep1 :: RuntimeRep} {rep2 :: RuntimeRep}. TYPE rep1 > TYPE rep2 > *
The runtime representations quantification is left inferred. This
means they cannot be specified with XTypeApplications
.
This is a deliberate choice to allow future extensions to the function arrow. To allow visible application a type synonym can be defined:
type Arr :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep). TYPE rep1 > TYPE rep2 > Type type Arr = FUN 'Many
Predicates on types
isCoercionTy :: Type > Bool Source #
isForAllTy :: Type > Bool Source #
Checks whether this is a proper forall (with a named binder)
isForAllTy_ty :: Type > Bool Source #
Like isForAllTy
, but returns True only if it is a tyvar binder
isForAllTy_co :: Type > Bool Source #
Like isForAllTy
, but returns True only if it is a covar binder
isFamFreeTy :: Type > Bool Source #
isCoVarType :: Type > Bool Source #
Does this type classify a core (unlifted) Coercion? At either role nominal or representational (t1 ~# t2) or (t1 ~R# t2) See Note [Types for coercions, predicates, and evidence] in GHC.Core.TyCo.Rep
isAtomicTy :: Type > Bool Source #
isValidJoinPointType :: JoinArity > Type > Bool Source #
Determine whether a type could be the type of a join point of given total
arity, according to the polymorphism rule. A join point cannot be polymorphic
in its return type, since given
join j a
b x y z = e1 in e2,
the types of e1 and e2 must be the same, and a and b are not in scope for e2.
(See Note [The polymorphism rule of join points] in GHC.Core.) Returns False
also if the type simply doesn't have enough arguments.
Note that we need to know how many arguments (type *and* value) the putative join point takes; for instance, if j :: forall a. a > Int then j could be a binary join point returning an Int, but it could *not* be a unary join point returning a > Int.
TODO: See Note [Excess polymorphism and join points]
:: Bool  Should specified binders count towards injective positions in the kind of the TyCon? (If you're using visible kind applications, then you want True here. 
> TyCon  
> Int  The number of args the 
> Bool  Does 
Does a TyCon
(that is applied to some number of arguments) need to be
ascribed with an explicit kind signature to resolve ambiguity if rendered as
a sourcesyntax type?
(See Note [When does a tycon application need an explicit kind signature?]
for a full explanation of what this function checks for.)
Levity and boxity
isLiftedType_maybe :: HasDebugCallStack => Type > Maybe Bool Source #
Returns Just True if this type is surely lifted, Just False if it is surely unlifted, Nothing if we can't be sure (i.e., it is levity polymorphic), and panics if the kind does not have the shape TYPE r.
isLiftedTypeKind :: Kind > Bool Source #
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 Source #
Returns True if the kind classifies unlifted types (like 'Int#') and False otherwise. Note that this returns False for levitypolymorphic kinds, which may be specialized to a kind that classifies unlifted types.
isBoxedTypeKind :: Kind > Bool Source #
Returns True if the kind classifies types which are allocated on the GC'd heap and False otherwise. Note that this returns False for levitypolymorphic kinds, which may be specialized to a kind that classifies AddrRep or even unboxed kinds.
pickyIsLiftedTypeKind :: Kind > Bool Source #
isLiftedRuntimeRep :: Type > Bool Source #
isUnliftedRuntimeRep :: Type > Bool Source #
isBoxedRuntimeRep :: Type > Bool Source #
See isBoxedRuntimeRep_maybe
.
isLiftedLevity :: Type > Bool Source #
isUnliftedLevity :: Type > Bool Source #
isUnliftedType :: HasDebugCallStack => Type > Bool Source #
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.
isBoxedType :: Type > Bool Source #
See Type for what a boxed type is.
Panics on levity polymorphic types; See mightBeUnliftedType
for
a more approximate predicate that behaves better in the presence of
levity polymorphism.
mightBeUnliftedType :: Type > Bool Source #
isUnboxedTupleType :: Type > Bool Source #
isUnboxedSumType :: Type > Bool Source #
isAlgType :: Type > Bool Source #
See Type for what an algebraic type is. Should only be applied to types, as opposed to e.g. partially saturated type constructors
isDataFamilyAppType :: Type > Bool Source #
Check whether a type is a data family type
isPrimitiveType :: Type > Bool Source #
Returns true of types that are opaque to Haskell.
isStrictType :: HasDebugCallStack => Type > Bool Source #
Computes whether an argument (or let right hand side) should
be computed strictly or lazily, based only on its type.
Currently, it's just isUnliftedType
. Panics on levitypolymorphic types.
isLevityTy :: Type > Bool Source #
Is this the type Levity
?
isLevityVar :: TyVar > Bool Source #
Is a tyvar of type Levity
?
isRuntimeRepTy :: Type > Bool Source #
Is this the type RuntimeRep
?
isRuntimeRepVar :: TyVar > Bool Source #
Is a tyvar of type RuntimeRep
?
isRuntimeRepKindedTy :: Type > Bool Source #
Is this a type of kind RuntimeRep? (e.g. LiftedRep)
dropRuntimeRepArgs :: [Type] > [Type] Source #
Drops prefix of RuntimeRep constructors in TyConApp
s. Useful for e.g.
dropping 'LiftedRep arguments of unboxed tuple TyCon applications:
dropRuntimeRepArgs [ 'LiftedRep, 'IntRep , String, Int# ] == [String, Int#]
getRuntimeRep :: HasDebugCallStack => Type > Type Source #
Extract the RuntimeRep classifier of a type. For instance,
getRuntimeRep_maybe Int = LiftedRep
. Panics if this is not possible.
Multiplicity
isMultiplicityTy :: Type > Bool Source #
Is this the type Multiplicity
?
isMultiplicityVar :: TyVar > Bool Source #
Is a tyvar of type Multiplicity
?
unrestricted :: a > Scaled a Source #
Scale a payload by Many
irrelevantMult :: Scaled a > a Source #
isOneDataConTy :: Mult > Bool Source #
isManyDataConTy :: Mult > Bool Source #
isLinearType :: Type > Bool Source #
Main data types representing Kinds
Finding the kind of a type
tcTypeKind :: HasDebugCallStack => Type > Kind Source #
isTypeLevPoly :: Type > Bool Source #
Returns True if a type is levity polymorphic. Should be the same as (isKindLevPoly . typeKind) but much faster. Precondition: The type has kind (TYPE blah)
resultIsLevPoly :: Type > Bool Source #
Looking past all pitypes, is the end result potentially levity polymorphic? Example: True for (forall r (a :: TYPE r). String > a) Example: False for (forall r1 r2 (a :: TYPE r1) (b :: TYPE r2). a > b > Type)
tcIsLiftedTypeKind :: Kind > Bool Source #
Is this kind equivalent to Type
?
This considers Constraint
to be distinct from Type
. For a version that
treats them as the same type, see isLiftedTypeKind
.
tcIsConstraintKind :: Kind > Bool Source #
tcReturnsConstraintKind :: Kind > Bool Source #
tcIsBoxedTypeKind :: Kind > Bool Source #
Is this kind equivalent to TYPE (BoxedRep l)
for some l :: Levity
?
This considers Constraint
to be distinct from Type
. For a version that
treats them as the same type, see isLiftedTypeKind
.
tcIsRuntimeTypeKind :: Kind > Bool Source #
Is this kind equivalent to TYPE r
(for some unknown r)?
This considers Constraint
to be distinct from *
.
Common Kind
Type free variables
tyCoFVsOfType :: Type > FV Source #
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.
Etaexpanded because that makes it run faster (apparently) See Note [FV eta expansion] in GHC.Utils.FV for explanation.
tyCoFVsBndr :: TyCoVarBinder > FV > FV Source #
tyCoVarsOfType :: Type > TyCoVarSet Source #
tyCoVarsOfTypes :: [Type] > TyCoVarSet Source #
tyCoVarsOfTypeDSet :: Type > DTyCoVarSet Source #
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.
coVarsOfType :: Type > CoVarSet Source #
coVarsOfTypes :: [Type] > CoVarSet Source #
noFreeVarsOfType :: Type > Bool Source #
splitVisVarsOfType :: Type > Pair TyCoVarSet Source #
Retrieve the free variables in this type, splitting them based on whether they are used visibly or invisibly. Invisible ones come first.
splitVisVarsOfTypes :: [Type] > Pair TyCoVarSet Source #
expandTypeSynonyms :: Type > Type Source #
Expand out all type synonyms. Actually, it'd suffice to expand out just the ones that discard type variables (e.g. type Funny a = Int) But we don't know which those are currently, so we just expand all.
expandTypeSynonyms
only expands out type synonyms mentioned in the type,
not in the kinds of any TyCon or TyVar mentioned in the type.
Keep this synchronized with synonymTyConsOfType
Closing over kinds
closeOverKindsDSet :: DTyVarSet > DTyVarSet Source #
Add the kind variables free in the kinds of the tyvars in the given set. Returns a deterministic set.
closeOverKindsList :: [TyVar] > [TyVar] Source #
Add the kind variables free in the kinds of the tyvars in the given set. Returns a deterministically ordered list.
Wellscoped lists of variables
scopedSort :: [TyCoVar] > [TyCoVar] Source #
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 wellscoped 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
tyCoVarsOfTypeWellScoped :: Type > [TyVar] Source #
Get the free vars of a type in scoped order
tyCoVarsOfTypesWellScoped :: [Type] > [TyVar] Source #
Get the free vars of types in scoped order
Type comparison
eqType :: Type > Type > Bool Source #
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 [Nontrivial definitional equality] in GHC.Core.TyCo.Rep.
eqTypeX :: RnEnv2 > Type > Type > Bool Source #
Compare types with respect to a (presumably) nonempty RnEnv2
.
eqTypes :: [Type] > [Type] > Bool Source #
Type equality on lists of types, looking through type synonyms but not newtypes.
nonDetCmpTc :: TyCon > TyCon > Ordering Source #
Compare two TyCon
s. NB: This should never see Constraint
(as
recognized by Kind.isConstraintKindCon) which is considered a synonym for
Type
in Core.
See Note [Kind Constraint and kind Type] in GHC.Core.Type.
See Note [nonDetCmpType nondeterminism]
Forcing evaluation of types
Other views onto Types
coreView :: Type > Maybe Type Source #
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
.
By being nonrecursive and inlined, this case analysis gets efficiently joined onto the case analysis that the caller is already doing
tyConsOfType :: Type > UniqSet TyCon Source #
All type constructors occurring in the type; looking through type synonyms, but not newtypes. When it finds a Class, it returns the class TyCon.
Main type substitution data types
Type & coercion substitution
The following invariants must hold of a TCvSubst
:
 The inscope set is needed only to guide the generation of fresh uniques
 In particular, the kind of the type variables in the inscope set is not relevant
 The substitution is only applied ONCE! This is because in general such application will not reach a fixed point.
Instances
Manipulating type substitutions
mkEmptyTCvSubst :: InScopeSet > TCvSubst Source #
mkTCvSubst :: InScopeSet > (TvSubstEnv, CvSubstEnv) > TCvSubst Source #
zipTvSubst :: HasDebugCallStack => [TyVar] > [Type] > TCvSubst Source #
Generates the inscope set for the TCvSubst
from the types in the incoming
environment. No CoVars, please!
mkTvSubstPrs :: [(TyVar, Type)] > TCvSubst Source #
Generates the inscope set for the TCvSubst
from the types in the
incoming environment. No CoVars, please!
zipTCvSubst :: HasDebugCallStack => [TyCoVar] > [Type] > TCvSubst Source #
getTvSubstEnv :: TCvSubst > TvSubstEnv Source #
setTvSubstEnv :: TCvSubst > TvSubstEnv > TCvSubst Source #
zapTCvSubst :: TCvSubst > TCvSubst Source #
getTCvInScope :: TCvSubst > InScopeSet Source #
getTCvSubstRangeFVs :: TCvSubst > VarSet Source #
Returns the free variables of the types in the range of a substitution as a nondeterministic set.
extendTvSubstBinderAndInScope :: TCvSubst > TyCoBinder > Type > TCvSubst Source #
composeTCvSubstEnv :: InScopeSet > (TvSubstEnv, CvSubstEnv) > (TvSubstEnv, CvSubstEnv) > (TvSubstEnv, CvSubstEnv) Source #
(compose env1 env2)(x)
is env1(env2(x))
; i.e. apply env2
then env1
.
It assumes that both are idempotent.
Typically, env1
is the refinement to a base substitution env2
composeTCvSubst :: TCvSubst > TCvSubst > TCvSubst Source #
Composes two substitutions, applying the second one provided first, like in function composition.
zipTyEnv :: HasDebugCallStack => [TyVar] > [Type] > TvSubstEnv Source #
zipCoEnv :: HasDebugCallStack => [CoVar] > [Coercion] > CvSubstEnv Source #
isEmptyTCvSubst :: TCvSubst > Bool Source #
Performing substitution on types and kinds
substTy :: HasCallStack => TCvSubst > Type > Type Source #
Substitute within a Type
The substitution has to satisfy the invariants described in
Note [The substitution invariant].
substTys :: HasCallStack => TCvSubst > [Type] > [Type] Source #
Substitute within several Type
s
The substitution has to satisfy the invariants described in
Note [The substitution invariant].
substScaledTy :: HasCallStack => TCvSubst > Scaled Type > Scaled Type Source #
substScaledTys :: HasCallStack => TCvSubst > [Scaled Type] > [Scaled Type] Source #
substTyWith :: HasCallStack => [TyVar] > [Type] > Type > Type Source #
Type substitution, see zipTvSubst
substTysWith :: [TyVar] > [Type] > [Type] > [Type] Source #
Type substitution, see zipTvSubst
substTheta :: HasCallStack => TCvSubst > ThetaType > ThetaType Source #
Substitute within a ThetaType
The substitution has to satisfy the invariants described in
Note [The substitution invariant].
substTyAddInScope :: TCvSubst > Type > Type Source #
Substitute within a Type
after adding the free variables of the type
to the inscope set. This is useful for the case when the free variables
aren't already in the inscope set or easily available.
See also Note [The substitution invariant].
substTyUnchecked :: TCvSubst > Type > Type Source #
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] Source #
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 Source #
substThetaUnchecked :: TCvSubst > ThetaType > ThetaType Source #
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 Source #
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 Source #
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 Source #
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.
substTyVarBndr :: HasCallStack => TCvSubst > TyVar > (TCvSubst, TyVar) Source #
substTyVarBndrs :: HasCallStack => TCvSubst > [TyVar] > (TCvSubst, [TyVar]) Source #
substVarBndr :: HasCallStack => TCvSubst > TyCoVar > (TCvSubst, TyCoVar) Source #
substVarBndrs :: HasCallStack => TCvSubst > [TyCoVar] > (TCvSubst, [TyCoVar]) Source #
substTyCoBndr :: TCvSubst > TyCoBinder > (TCvSubst, TyCoBinder) Source #
cloneTyVarBndrs :: TCvSubst > [TyVar] > UniqSupply > (TCvSubst, [TyVar]) Source #
Tidying type related things up for printing
tidyType :: TidyEnv > Type > Type Source #
Tidy a Type
See Note [Strictness in tidyType and friends]
tidyTypes :: TidyEnv > [Type] > [Type] Source #
Tidy a list of Types
See Note [Strictness in tidyType and friends]
tidyOpenTypes :: TidyEnv > [Type] > (TidyEnv, [Type]) Source #
Grabs the free type variables, tidies them
and then uses tidyType
to work over the type itself
tidyVarBndrs :: TidyEnv > [TyCoVar] > (TidyEnv, [TyCoVar]) 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.
tidyFreeTyCoVars :: TidyEnv > [TyCoVar] > TidyEnv Source #
Add the free TyVar
s to the env in tidy form,
so that we can tidy the type they are free in
tidyOpenTyCoVar :: TidyEnv > TyCoVar > (TidyEnv, TyCoVar) Source #
Treat a new TyCoVar
as a binder, and give it a fresh tidy name
using the environment if one has not already been allocated. See
also tidyVarBndr
tidyTopType :: Type > Type Source #
Calls tidyType
on a toplevel type (i.e. with an empty tidying environment)
Kinds
classifiesTypeWithValues :: Kind > Bool Source #
Does this classify a type allowed to have values? Responds True to things like *, #, TYPE Lifted, TYPE v, Constraint.
True of any subkind of OpenTypeKind
isKindLevPoly :: Kind > Bool Source #
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