GHC.Core.Type

ghc-9.10.0.20240413: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.Core.Type

Contents

- Main data types representing Types
  - Constructing and deconstructing types
  - Analyzing types
  - Binders
  - Predicates on types
- Space-saving construction
  - Levity and boxity
- Multiplicity
- Main data types representing Kinds
  - Finding the kind of a type
  - Common Kind
- Type free variables
  - Closing over kinds
- Well-scoped lists of variables
- Forcing evaluation of types
- Other views onto Types
- Main type substitution data types
  - Manipulating type substitutions
  - Performing substitution on types and kinds
- Tidying type related things up for printing
- Kinds

Description

Main functions for manipulating types and type-related things

Synopsis

- data Type
- data ForAllTyFlag where
  - Invisible !Specificity
  - Required
  - pattern Specified :: ForAllTyFlag
  - pattern Inferred :: ForAllTyFlag
- data FunTyFlag
  - = FTF_T_T
  - | FTF_T_C
  - | FTF_C_T
  - | FTF_C_C
- data Specificity
  - = InferredSpec
  - | SpecifiedSpec
- type KindOrType = Type
- type PredType = Type
- type ThetaType = [PredType]
- type FRRType = Type
- data Var
- type TyVar = Var
- isTyVar :: Var -> Bool
- type TyCoVar = Id
- data PiTyBinder
- type ForAllTyBinder = VarBndr TyCoVar ForAllTyFlag
- type TyVarBinder = VarBndr TyVar ForAllTyFlag
- type Mult = Type
- data Scaled a
- type KnotTied (ty :: k) = ty
- type RuntimeRepType = Type
- mkTyVarTy :: TyVar -> Type
- mkTyVarTys :: [TyVar] -> [Type]
- getTyVar :: HasDebugCallStack => 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 :: HasDebugCallStack => Type -> (Type, [Type])
- splitAppTysNoView :: HasDebugCallStack => Type -> (Type, [Type])
- splitAppTy_maybe :: Type -> Maybe (Type, Type)
- splitAppTyNoView_maybe :: HasDebugCallStack => Type -> Maybe (Type, Type)
- tcSplitAppTyNoView_maybe :: Type -> Maybe (Type, Type)
- mkFunTy :: HasDebugCallStack => FunTyFlag -> Mult -> Type -> Type -> Type
- mkVisFunTy :: HasDebugCallStack => Mult -> Type -> Type -> Type
- mkVisFunTyMany :: HasDebugCallStack => Type -> Type -> Type
- mkVisFunTysMany :: [Type] -> Type -> Type
- mkScaledFunTys :: HasDebugCallStack => [Scaled Type] -> Type -> Type
- mkInvisFunTy :: HasDebugCallStack => Type -> Type -> Type
- mkInvisFunTys :: HasDebugCallStack => [Type] -> Type -> Type
- tcMkVisFunTy :: Mult -> Type -> Type -> Type
- tcMkScaledFunTys :: [Scaled Type] -> Type -> Type
- tcMkInvisFunTy :: TypeOrConstraint -> Type -> Type -> Type
- splitFunTy :: Type -> (Mult, Type, Type)
- splitFunTy_maybe :: Type -> Maybe (FunTyFlag, Mult, Type, Type)
- splitFunTys :: Type -> ([Scaled Type], Type)
- funResultTy :: HasDebugCallStack => Type -> Type
- funArgTy :: HasDebugCallStack => Type -> Type
- funTyConAppTy_maybe :: FunTyFlag -> Type -> Type -> Type -> Maybe (TyCon, [Type])
- funTyFlagTyCon :: FunTyFlag -> TyCon
- tyConAppFunTy_maybe :: HasDebugCallStack => TyCon -> [Type] -> Maybe Type
- tyConAppFunCo_maybe :: HasDebugCallStack => Role -> TyCon -> [Coercion] -> Maybe Coercion
- mkFunctionType :: HasDebugCallStack => Mult -> Type -> Type -> Type
- mkScaledFunctionTys :: [Scaled Type] -> Type -> Type
- chooseFunTyFlag :: HasDebugCallStack => Type -> Type -> FunTyFlag
- mkTyConApp :: TyCon -> [Type] -> Type
- mkTyConTy :: TyCon -> Type
- tyConAppTyCon_maybe :: Type -> Maybe TyCon
- tyConAppTyConPicky_maybe :: Type -> Maybe TyCon
- tyConAppArgs_maybe :: Type -> Maybe [Type]
- tyConAppTyCon :: HasDebugCallStack => Type -> TyCon
- tyConAppArgs :: HasCallStack => Type -> [Type]
- splitTyConApp_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type])
- splitTyConAppNoView_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type])
- splitTyConApp :: Type -> (TyCon, [Type])
- tcSplitTyConApp :: Type -> (TyCon, [Type])
- tcSplitTyConApp_maybe :: HasCallStack => Type -> Maybe (TyCon, [Type])
- mkForAllTy :: ForAllTyBinder -> Type -> Type
- mkForAllTys :: [ForAllTyBinder] -> Type -> Type
- mkInvisForAllTys :: [InvisTVBinder] -> Type -> Type
- mkTyCoInvForAllTys :: [TyCoVar] -> Type -> Type
- mkSpecForAllTy :: TyVar -> Type -> Type
- mkSpecForAllTys :: [TyVar] -> Type -> Type
- mkVisForAllTys :: [TyVar] -> Type -> Type
- mkTyCoForAllTy :: TyCoVar -> ForAllTyFlag -> Type -> Type
- mkTyCoForAllTys :: [ForAllTyBinder] -> Type -> Type
- mkTyCoInvForAllTy :: TyCoVar -> Type -> Type
- mkInfForAllTy :: TyVar -> Type -> Type
- mkInfForAllTys :: [TyVar] -> Type -> Type
- splitForAllTyCoVars :: Type -> ([TyCoVar], Type)
- splitForAllTyVars :: Type -> ([TyVar], Type)
- splitForAllReqTyBinders :: Type -> ([ReqTyBinder], Type)
- splitForAllInvisTyBinders :: Type -> ([InvisTyBinder], Type)
- splitForAllForAllTyBinders :: Type -> ([ForAllTyBinder], Type)
- splitForAllForAllTyBinder_maybe :: Type -> Maybe (ForAllTyBinder, Type)
- splitForAllTyCoVar_maybe :: Type -> Maybe (TyCoVar, Type)
- splitForAllTyCoVar :: Type -> (TyCoVar, Type)
- splitForAllTyVar_maybe :: Type -> Maybe (TyVar, Type)
- splitForAllCoVar_maybe :: Type -> Maybe (CoVar, Type)
- splitPiTy_maybe :: Type -> Maybe (PiTyBinder, Type)
- splitPiTy :: Type -> (PiTyBinder, Type)
- splitPiTys :: Type -> ([PiTyBinder], Type)
- getRuntimeArgTys :: Type -> [(Scaled Type, FunTyFlag)]
- mkTyConBindersPreferAnon :: [TyVar] -> TyCoVarSet -> [TyConBinder]
- mkPiTy :: HasDebugCallStack => PiTyBinder -> Type -> Type
- mkPiTys :: HasDebugCallStack => [PiTyBinder] -> Type -> Type
- piResultTy :: HasDebugCallStack => Type -> Type -> Type
- piResultTys :: HasDebugCallStack => Type -> [Type] -> Type
- applyTysX :: HasDebugCallStack => [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 :: HasDebugCallStack => Type -> RuntimeRepType
- splitRuntimeRep_maybe :: RuntimeRepType -> Maybe (TyCon, [Type])
- kindRep_maybe :: HasDebugCallStack => Kind -> Maybe RuntimeRepType
- kindRep :: HasDebugCallStack => Kind -> RuntimeRepType
- getLevity :: HasDebugCallStack => Type -> Type
- levityType_maybe :: LevityType -> Maybe Levity
- mkCastTy :: Type -> Coercion -> Type
- mkCoercionTy :: Coercion -> Type
- splitCastTy_maybe :: Type -> Maybe (Type, Coercion)
- type ErrorMsgType = Type
- userTypeError_maybe :: Type -> Maybe ErrorMsgType
- deepUserTypeError_maybe :: Type -> Maybe ErrorMsgType
- pprUserTypeErrorTy :: ErrorMsgType -> SDoc
- coAxNthLHS :: forall (br :: BranchFlag). CoAxiom br -> Int -> Type
- stripCoercionTy :: Type -> Coercion
- splitInvisPiTys :: Type -> ([PiTyBinder], Type)
- splitInvisPiTysN :: Int -> Type -> ([PiTyBinder], Type)
- invisibleTyBndrCount :: Type -> Int
- filterOutInvisibleTypes :: TyCon -> [Type] -> [Type]
- filterOutInferredTypes :: TyCon -> [Type] -> [Type]
- partitionInvisibleTypes :: TyCon -> [Type] -> ([Type], [Type])
- partitionInvisibles :: [(a, ForAllTyFlag)] -> ([a], [a])
- tyConForAllTyFlags :: TyCon -> [Type] -> [ForAllTyFlag]
- appTyForAllTyFlags :: Type -> [Type] -> [ForAllTyFlag]
- data TyCoMapper env (m :: Type -> Type) = TyCoMapper {
  - tcm_tyvar :: env -> TyVar -> m Type
  - tcm_covar :: env -> CoVar -> m Coercion
  - tcm_hole :: env -> CoercionHole -> m Coercion
  - tcm_tycobinder :: forall r. env -> TyCoVar -> ForAllTyFlag -> (env -> TyCoVar -> m r) -> m r
  - tcm_tycon :: TyCon -> m TyCon
  }
- 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 {
  - tcf_view :: Type -> Maybe Type
  - tcf_tyvar :: env -> TyVar -> a
  - tcf_covar :: env -> CoVar -> a
  - tcf_hole :: env -> CoercionHole -> a
  - tcf_tycobinder :: env -> TyCoVar -> ForAllTyFlag -> env
  }
- foldTyCo :: Monoid a => TyCoFolder env a -> env -> (Type -> a, [Type] -> a, Coercion -> a, [Coercion] -> a)
- noView :: Type -> Maybe Type
- newTyConInstRhs :: TyCon -> [Type] -> Type
- mkForAllTyBinder :: vis -> TyCoVar -> VarBndr TyCoVar vis
- mkForAllTyBinders :: vis -> [TyCoVar] -> [VarBndr TyCoVar vis]
- mkTyVarBinder :: vis -> TyVar -> VarBndr TyVar vis
- mkTyVarBinders :: vis -> [TyVar] -> [VarBndr TyVar vis]
- tyVarSpecToBinders :: [VarBndr a Specificity] -> [VarBndr a ForAllTyFlag]
- isAnonPiTyBinder :: PiTyBinder -> Bool
- binderVar :: VarBndr tv argf -> tv
- binderVars :: [VarBndr tv argf] -> [tv]
- binderType :: VarBndr TyCoVar argf -> Type
- binderFlag :: VarBndr tv argf -> argf
- binderFlags :: [VarBndr tv argf] -> [argf]
- piTyBinderType :: PiTyBinder -> Type
- namedPiTyBinder_maybe :: PiTyBinder -> Maybe TyCoVar
- anonPiTyBinderType_maybe :: PiTyBinder -> Maybe Type
- isVisibleForAllTyFlag :: ForAllTyFlag -> Bool
- isInvisibleForAllTyFlag :: ForAllTyFlag -> Bool
- isVisiblePiTyBinder :: PiTyBinder -> Bool
- isInvisiblePiTyBinder :: PiTyBinder -> Bool
- isNamedPiTyBinder :: PiTyBinder -> Bool
- tyConBindersPiTyBinders :: [TyConBinder] -> [PiTyBinder]
- 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
- isForAllTy_invis_ty :: 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
- mkTYPEapp :: RuntimeRepType -> Type
- mkTYPEapp_maybe :: RuntimeRepType -> Maybe Type
- mkCONSTRAINTapp :: RuntimeRepType -> Type
- mkCONSTRAINTapp_maybe :: RuntimeRepType -> Maybe Type
- mkBoxedRepApp_maybe :: LevityType -> Maybe Type
- mkTupleRepApp_maybe :: Type -> Maybe Type
- typeOrConstraintKind :: TypeOrConstraint -> RuntimeRepType -> Kind
- sORTKind_maybe :: Kind -> Maybe (TypeOrConstraint, Type)
- typeTypeOrConstraint :: HasDebugCallStack => Type -> TypeOrConstraint
- typeLevity :: HasDebugCallStack => Type -> Levity
- typeLevity_maybe :: HasDebugCallStack => Type -> Maybe Levity
- tyConIsTYPEorCONSTRAINT :: TyCon -> Bool
- isLiftedTypeKind :: Kind -> Bool
- isUnliftedTypeKind :: Kind -> Bool
- pickyIsLiftedTypeKind :: Kind -> Bool
- isLiftedRuntimeRep :: RuntimeRepType -> Bool
- isUnliftedRuntimeRep :: RuntimeRepType -> Bool
- runtimeRepLevity_maybe :: RuntimeRepType -> Maybe Levity
- isBoxedRuntimeRep :: RuntimeRepType -> Bool
- isLiftedLevity :: Type -> Bool
- isUnliftedLevity :: Type -> Bool
- isUnliftedType :: HasDebugCallStack => Type -> Bool
- isBoxedType :: Type -> Bool
- isUnboxedTupleType :: Type -> Bool
- isUnboxedSumType :: Type -> Bool
- kindBoxedRepLevity_maybe :: Type -> Maybe Levity
- mightBeLiftedType :: Type -> Bool
- mightBeUnliftedType :: Type -> Bool
- definitelyLiftedType :: Type -> Bool
- definitelyUnliftedType :: Type -> Bool
- isAlgType :: Type -> Bool
- isDataFamilyAppType :: Type -> Bool
- isPrimitiveType :: Type -> Bool
- isStrictType :: HasDebugCallStack => Type -> Bool
- isTerminatingType :: HasDebugCallStack => Type -> Bool
- isLevityTy :: Type -> Bool
- isLevityVar :: TyVar -> Bool
- isRuntimeRepTy :: Type -> Bool
- isRuntimeRepVar :: TyVar -> Bool
- isRuntimeRepKindedTy :: Type -> Bool
- dropRuntimeRepArgs :: [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 OneTy :: Mult
- pattern ManyTy :: Mult
- isOneTy :: Mult -> Bool
- isManyTy :: Mult -> Bool
- isLinearType :: Type -> Bool
- type Kind = Type
- typeKind :: HasDebugCallStack => Type -> Kind
- typeHasFixedRuntimeRep :: HasDebugCallStack => Type -> Bool
- tcIsLiftedTypeKind :: Kind -> Bool
- isConstraintKind :: Kind -> Bool
- isConstraintLikeKind :: Kind -> Bool
- returnsConstraintKind :: Kind -> Bool
- tcIsBoxedTypeKind :: Kind -> Bool
- isTypeLikeKind :: Kind -> Bool
- liftedTypeKind :: Type
- unliftedTypeKind :: Type
- tyCoFVsOfType :: Type -> FV
- tyCoFVsBndr :: ForAllTyBinder -> 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
- 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]
- seqType :: Type -> ()
- seqTypes :: [Type] -> ()
- coreView :: Type -> Maybe Type
- coreFullView :: Type -> Type
- rewriterView :: Type -> Maybe Type
- tyConsOfType :: Type -> UniqSet TyCon
- type TvSubstEnv = TyVarEnv Type
- type IdSubstEnv = IdEnv CoreExpr
- data Subst = Subst InScopeSet IdSubstEnv TvSubstEnv CvSubstEnv
- emptyTvSubstEnv :: TvSubstEnv
- emptySubst :: Subst
- mkEmptySubst :: InScopeSet -> Subst
- mkTCvSubst :: InScopeSet -> TvSubstEnv -> CvSubstEnv -> Subst
- zipTvSubst :: HasDebugCallStack => [TyVar] -> [Type] -> Subst
- mkTvSubstPrs :: [(TyVar, Type)] -> Subst
- zipTCvSubst :: HasDebugCallStack => [TyCoVar] -> [Type] -> Subst
- notElemSubst :: Var -> Subst -> Bool
- getTvSubstEnv :: Subst -> TvSubstEnv
- zapSubst :: Subst -> Subst
- getSubstInScope :: Subst -> InScopeSet
- setInScope :: Subst -> InScopeSet -> Subst
- getSubstRangeTyCoFVs :: Subst -> VarSet
- extendSubstInScope :: Subst -> Var -> Subst
- extendSubstInScopeList :: Subst -> [Var] -> Subst
- extendSubstInScopeSet :: Subst -> VarSet -> Subst
- extendTCvSubst :: Subst -> TyCoVar -> Type -> Subst
- extendCvSubst :: Subst -> CoVar -> Coercion -> Subst
- extendTvSubst :: Subst -> TyVar -> Type -> Subst
- extendTvSubstBinderAndInScope :: Subst -> PiTyBinder -> Type -> Subst
- extendTvSubstList :: Subst -> [(TyVar, Type)] -> Subst
- extendTvSubstAndInScope :: Subst -> TyVar -> Type -> Subst
- extendTCvSubstList :: Subst -> [Var] -> [Type] -> Subst
- extendTvSubstWithClone :: Subst -> TyVar -> TyVar -> Subst
- extendTCvSubstWithClone :: Subst -> TyCoVar -> TyCoVar -> Subst
- isInScope :: Var -> Subst -> Bool
- composeTCvSubst :: Subst -> Subst -> Subst
- zipTyEnv :: HasDebugCallStack => [TyVar] -> [Type] -> TvSubstEnv
- zipCoEnv :: HasDebugCallStack => [CoVar] -> [Coercion] -> CvSubstEnv
- isEmptySubst :: Subst -> Bool
- unionSubst :: Subst -> Subst -> Subst
- isEmptyTCvSubst :: Subst -> Bool
- substTy :: HasDebugCallStack => Subst -> Type -> Type
- substTys :: HasDebugCallStack => Subst -> [Type] -> [Type]
- substScaledTy :: HasDebugCallStack => Subst -> Scaled Type -> Scaled Type
- substScaledTys :: HasDebugCallStack => Subst -> [Scaled Type] -> [Scaled Type]
- substTyWith :: HasDebugCallStack => [TyVar] -> [Type] -> Type -> Type
- substTysWith :: HasDebugCallStack => [TyVar] -> [Type] -> [Type] -> [Type]
- substTheta :: HasDebugCallStack => Subst -> ThetaType -> ThetaType
- substTyAddInScope :: HasDebugCallStack => Subst -> Type -> Type
- substTyUnchecked :: Subst -> Type -> Type
- substTysUnchecked :: Subst -> [Type] -> [Type]
- substScaledTyUnchecked :: HasDebugCallStack => Subst -> Scaled Type -> Scaled Type
- substScaledTysUnchecked :: Subst -> [Scaled Type] -> [Scaled Type]
- substThetaUnchecked :: Subst -> ThetaType -> ThetaType
- substTyWithUnchecked :: [TyVar] -> [Type] -> Type -> Type
- substCo :: HasDebugCallStack => Subst -> Coercion -> Coercion
- substCoUnchecked :: Subst -> Coercion -> Coercion
- substCoWithUnchecked :: [TyVar] -> [Type] -> Coercion -> Coercion
- substTyVarBndr :: HasDebugCallStack => Subst -> TyVar -> (Subst, TyVar)
- substTyVarBndrs :: HasDebugCallStack => Subst -> [TyVar] -> (Subst, [TyVar])
- substTyVar :: Subst -> TyVar -> Type
- substTyVars :: Subst -> [TyVar] -> [Type]
- substVarBndr :: HasDebugCallStack => Subst -> TyCoVar -> (Subst, TyCoVar)
- substVarBndrs :: HasDebugCallStack => Subst -> [TyCoVar] -> (Subst, [TyCoVar])
- substTyCoBndr :: Subst -> PiTyBinder -> (Subst, PiTyBinder)
- substTyVarToTyVar :: HasDebugCallStack => Subst -> TyVar -> TyVar
- cloneTyVarBndr :: Subst -> TyVar -> Unique -> (Subst, TyVar)
- cloneTyVarBndrs :: Subst -> [TyVar] -> UniqSupply -> (Subst, [TyVar])
- lookupTyVar :: Subst -> TyVar -> Maybe Type
- tidyType :: TidyEnv -> Type -> Type
- tidyTypes :: TidyEnv -> [Type] -> [Type]
- tidyOpenType :: TidyEnv -> Type -> (TidyEnv, Type)
- tidyOpenTypes :: TidyEnv -> [Type] -> (TidyEnv, [Type])
- 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
- tidyForAllTyBinder :: TidyEnv -> VarBndr TyCoVar vis -> (TidyEnv, VarBndr TyCoVar vis)
- tidyForAllTyBinders :: TidyEnv -> [VarBndr TyCoVar vis] -> (TidyEnv, [VarBndr TyCoVar vis])
- isTYPEorCONSTRAINT :: Kind -> Bool
- isConcreteType :: Type -> Bool
- isFixedRuntimeRepKind :: HasDebugCallStack => 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 byte-represented 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` or `newtype`. 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 built-in type that can't be expressed in Haskell.
Unlifted
  Anything that isn't lifted is considered unlifted.

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 low-level representation as far as Core-to-Core 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.

data Type Source #

#### Instances

Instances details

Outputable Type Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods ppr :: Type -> SDoc Source #
Data Type Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Type -> c Type # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Type # toConstr :: Type -> Constr # dataTypeOf :: Type -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Type) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Type) # gmapT :: (forall b. Data b => b -> b) -> Type -> Type # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r # gmapQ :: (forall d. Data d => d -> u) -> Type -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Type -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Type -> m Type # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type #
Eq (DeBruijn Type) Source # |
Instance details Defined in GHC.Core.Map.Type Methods (==) :: DeBruijn Type -> DeBruijn Type -> Bool # (/=) :: DeBruijn Type -> DeBruijn Type -> Bool #

data ForAllTyFlag Source #

ForAllTyFlag

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, ForAllTyBinders, TyConBinders, and visibility] in GHC.Core.TyCo.Rep

Constructors

Invisible !Specificity |
Required |

Bundled Patterns

pattern Specified :: ForAllTyFlag |
pattern Inferred :: ForAllTyFlag |

#### Instances

Instances details

NFData ForAllTyFlag Source # |
Instance details Defined in GHC.Types.Var Methods rnf :: ForAllTyFlag -> () Source #
Binary ForAllTyFlag Source # |
Instance details Defined in GHC.Types.Var Methods put_ :: BinHandle -> ForAllTyFlag -> IO () Source # put :: BinHandle -> ForAllTyFlag -> IO (Bin ForAllTyFlag) Source # get :: BinHandle -> IO ForAllTyFlag Source #
Outputable ForAllTyFlag Source # |
Instance details Defined in GHC.Types.Var Methods ppr :: ForAllTyFlag -> SDoc Source #
Data ForAllTyFlag Source # |
Instance details Defined in GHC.Types.Var Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ForAllTyFlag -> c ForAllTyFlag # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ForAllTyFlag # toConstr :: ForAllTyFlag -> Constr # dataTypeOf :: ForAllTyFlag -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ForAllTyFlag) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ForAllTyFlag) # gmapT :: (forall b. Data b => b -> b) -> ForAllTyFlag -> ForAllTyFlag # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ForAllTyFlag -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ForAllTyFlag -> r # gmapQ :: (forall d. Data d => d -> u) -> ForAllTyFlag -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ForAllTyFlag -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ForAllTyFlag -> m ForAllTyFlag # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ForAllTyFlag -> m ForAllTyFlag # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ForAllTyFlag -> m ForAllTyFlag #
Eq ForAllTyFlag Source # |
Instance details Defined in GHC.Types.Var Methods (==) :: ForAllTyFlag -> ForAllTyFlag -> Bool # (/=) :: ForAllTyFlag -> ForAllTyFlag -> Bool #
Ord ForAllTyFlag Source # |
Instance details Defined in GHC.Types.Var Methods compare :: ForAllTyFlag -> ForAllTyFlag -> Ordering # (<) :: ForAllTyFlag -> ForAllTyFlag -> Bool # (<=) :: ForAllTyFlag -> ForAllTyFlag -> Bool # (>) :: ForAllTyFlag -> ForAllTyFlag -> Bool # (>=) :: ForAllTyFlag -> ForAllTyFlag -> Bool # max :: ForAllTyFlag -> ForAllTyFlag -> ForAllTyFlag # min :: ForAllTyFlag -> ForAllTyFlag -> ForAllTyFlag #
Outputable tv => Outputable (VarBndr tv ForAllTyFlag) Source # |
Instance details Defined in GHC.Types.Var Methods ppr :: VarBndr tv ForAllTyFlag -> SDoc Source #

data FunTyFlag Source #

The non-dependent version of `ForAllTyFlag`. See Note [FunTyFlag] Appears here partly so that it's together with its friends ForAllTyFlag and ForallVisFlag, but also because it is used in IfaceType, rather early in the compilation chain

Constructors

FTF_T_T |
FTF_T_C |
FTF_C_T |
FTF_C_C |

#### Instances

Instances details

Binary FunTyFlag Source # |
Instance details Defined in GHC.Types.Var Methods put_ :: BinHandle -> FunTyFlag -> IO () Source # put :: BinHandle -> FunTyFlag -> IO (Bin FunTyFlag) Source # get :: BinHandle -> IO FunTyFlag Source #
Outputable FunTyFlag Source # |
Instance details Defined in GHC.Types.Var Methods ppr :: FunTyFlag -> SDoc Source #
Data FunTyFlag Source # |
Instance details Defined in GHC.Types.Var Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FunTyFlag -> c FunTyFlag # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c FunTyFlag # toConstr :: FunTyFlag -> Constr # dataTypeOf :: FunTyFlag -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c FunTyFlag) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FunTyFlag) # gmapT :: (forall b. Data b => b -> b) -> FunTyFlag -> FunTyFlag # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FunTyFlag -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FunTyFlag -> r # gmapQ :: (forall d. Data d => d -> u) -> FunTyFlag -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> FunTyFlag -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag #
Eq FunTyFlag Source # |
Instance details Defined in GHC.Types.Var Methods (==) :: FunTyFlag -> FunTyFlag -> Bool # (/=) :: FunTyFlag -> FunTyFlag -> Bool #
Ord FunTyFlag Source # |
Instance details Defined in GHC.Types.Var Methods compare :: FunTyFlag -> FunTyFlag -> Ordering # (<) :: FunTyFlag -> FunTyFlag -> Bool # (<=) :: FunTyFlag -> FunTyFlag -> Bool # (>) :: FunTyFlag -> FunTyFlag -> Bool # (>=) :: FunTyFlag -> FunTyFlag -> Bool # max :: FunTyFlag -> FunTyFlag -> FunTyFlag # min :: FunTyFlag -> FunTyFlag -> FunTyFlag #

data Specificity Source #

Whether an `Invisible` argument may appear in source Haskell.

Constructors

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

Instances details

NFData Specificity Source # |
Instance details Defined in GHC.Types.Var Methods rnf :: Specificity -> () Source #
Binary Specificity Source # |
Instance details Defined in GHC.Types.Var Methods put_ :: BinHandle -> Specificity -> IO () Source # put :: BinHandle -> Specificity -> IO (Bin Specificity) Source # get :: BinHandle -> IO Specificity Source #
Data Specificity Source # |
Instance details Defined in GHC.Types.Var Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Specificity -> c Specificity # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Specificity # toConstr :: Specificity -> Constr # dataTypeOf :: Specificity -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Specificity) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Specificity) # gmapT :: (forall b. Data b => b -> b) -> Specificity -> Specificity # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Specificity -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Specificity -> r # gmapQ :: (forall d. Data d => d -> u) -> Specificity -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Specificity -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Specificity -> m Specificity # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Specificity -> m Specificity # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Specificity -> m Specificity #
Eq Specificity Source # |
Instance details Defined in GHC.Types.Var Methods (==) :: Specificity -> Specificity -> Bool # (/=) :: Specificity -> Specificity -> Bool #
Ord Specificity Source # |
Instance details Defined in GHC.Types.Var Methods compare :: Specificity -> Specificity -> Ordering # (<) :: Specificity -> Specificity -> Bool # (<=) :: Specificity -> Specificity -> Bool # (>) :: Specificity -> Specificity -> Bool # (>=) :: Specificity -> Specificity -> Bool # max :: Specificity -> Specificity -> Specificity # min :: Specificity -> Specificity -> Specificity #
OutputableBndrFlag Specificity p Source # |
Instance details Defined in GHC.Hs.Type Methods pprTyVarBndr :: HsTyVarBndr Specificity (GhcPass p) -> SDoc
Outputable tv => Outputable (VarBndr tv Specificity) Source # |
Instance details Defined in GHC.Types.Var Methods ppr :: VarBndr tv Specificity -> SDoc Source #

type KindOrType = Type Source #

The key representation of types within the compiler

type PredType = Type Source #

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"

type ThetaType = [PredType] Source #

A collection of `PredType`s

type FRRType = Type Source #

data Var Source #

Variable

Essentially a typed `Name`, that may also contain some additional information about the `Var` and its use sites.

#### Instances

Instances details

NamedThing Var Source # |
Instance details Defined in GHC.Types.Var Methods getOccName :: Var -> OccName Source # getName :: Var -> Name Source #
HasOccName Var Source # |
Instance details Defined in GHC.Types.Var Methods occName :: Var -> OccName Source #
Uniquable Var Source # |
Instance details Defined in GHC.Types.Var Methods getUnique :: Var -> Unique Source #
Outputable Var Source # |
Instance details Defined in GHC.Types.Var Methods ppr :: Var -> SDoc Source #
OutputableBndr Var Source # |
Instance details Defined in GHC.Core.Ppr Methods pprBndr :: BindingSite -> Var -> SDoc Source # pprPrefixOcc :: Var -> SDoc Source # pprInfixOcc :: Var -> SDoc Source # bndrIsJoin_maybe :: Var -> JoinPointHood Source #
Data Var Source # |
Instance details Defined in GHC.Types.Var Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Var -> c Var # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Var # toConstr :: Var -> Constr # dataTypeOf :: Var -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Var) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Var) # gmapT :: (forall b. Data b => b -> b) -> Var -> Var # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Var -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Var -> r # gmapQ :: (forall d. Data d => d -> u) -> Var -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Var -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Var -> m Var # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Var -> m Var # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Var -> m Var #
Eq Var Source # |
Instance details Defined in GHC.Types.Var Methods (==) :: Var -> Var -> Bool # (/=) :: Var -> Var -> Bool #
Ord Var Source # |
Instance details Defined in GHC.Types.Var Methods compare :: Var -> Var -> Ordering # (<) :: Var -> Var -> Bool # (<=) :: Var -> Var -> Bool # (>) :: Var -> Var -> Bool # (>=) :: Var -> Var -> Bool # max :: Var -> Var -> Var # min :: Var -> Var -> Var #
Eq (DeBruijn CoreAlt) Source # |
Instance details Defined in GHC.Core.Map.Expr Methods (==) :: DeBruijn CoreAlt -> DeBruijn CoreAlt -> Bool # (/=) :: DeBruijn CoreAlt -> DeBruijn CoreAlt -> Bool #
Eq (DeBruijn CoreExpr) Source # |
Instance details Defined in GHC.Core.Map.Expr Methods (==) :: DeBruijn CoreExpr -> DeBruijn CoreExpr -> Bool # (/=) :: DeBruijn CoreExpr -> DeBruijn CoreExpr -> Bool #
Eq (DeBruijn Var) Source # |
Instance details Defined in GHC.Core.Map.Type Methods (==) :: DeBruijn Var -> DeBruijn Var -> Bool # (/=) :: DeBruijn Var -> DeBruijn Var -> Bool #
OutputableBndr (Id, TagSig) Source # |
Instance details Defined in GHC.Stg.InferTags.TagSig Methods pprBndr :: BindingSite -> (Id, TagSig) -> SDoc Source # pprPrefixOcc :: (Id, TagSig) -> SDoc Source # pprInfixOcc :: (Id, TagSig) -> SDoc Source # bndrIsJoin_maybe :: (Id, TagSig) -> JoinPointHood Source #
type Anno Id Source # |
Instance details Defined in GHC.Hs.Extension type Anno Id = SrcSpanAnnN

type TyVar = Var Source #

Type or kind Variable

isTyVar :: Var -> Bool Source #

Is this a type-level (i.e., computationally irrelevant, thus erasable) variable? Satisfies `isTyVar = not . isId`.

type TyCoVar = Id Source #

Type or Coercion Variable

data PiTyBinder Source #

A `PiTyBinder` represents an argument to a function. PiTyBinders can be dependent (`Named`) or nondependent (`Anon`). They may also be visible or not. See Note [PiTyBinders]

#### Instances

Instances details

Outputable PiTyBinder Source # |
Instance details Defined in GHC.Types.Var Methods ppr :: PiTyBinder -> SDoc Source #
Data PiTyBinder Source # |
Instance details Defined in GHC.Types.Var Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PiTyBinder -> c PiTyBinder # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PiTyBinder # toConstr :: PiTyBinder -> Constr # dataTypeOf :: PiTyBinder -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PiTyBinder) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PiTyBinder) # gmapT :: (forall b. Data b => b -> b) -> PiTyBinder -> PiTyBinder # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PiTyBinder -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PiTyBinder -> r # gmapQ :: (forall d. Data d => d -> u) -> PiTyBinder -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> PiTyBinder -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder #

type ForAllTyBinder = VarBndr TyCoVar ForAllTyFlag Source #

Variable Binder

A `ForAllTyBinder` 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.hs-boot

A `TyVarBinder` is a binder with only TyVar

type TyVarBinder = VarBndr TyVar ForAllTyFlag Source #

type Mult = Type Source #

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.

data Scaled a Source #

A shorthand for data with an attached `Mult` element (the multiplicity).

#### Instances

Instances details

Outputable a => Outputable (Scaled a) Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods ppr :: Scaled a -> SDoc Source #
Data a => Data (Scaled a) Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Scaled a -> c (Scaled a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Scaled a) # toConstr :: Scaled a -> Constr # dataTypeOf :: Scaled a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Scaled a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Scaled a)) # gmapT :: (forall b. Data b => b -> b) -> Scaled a -> Scaled a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Scaled a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Scaled a -> r # gmapQ :: (forall d. Data d => d -> u) -> Scaled a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Scaled a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Scaled a -> m (Scaled a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Scaled a -> m (Scaled a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Scaled a -> m (Scaled a) #

type KnotTied (ty :: k) = ty Source #

A type labeled `KnotTied` might have knot-tied tycons in it. See Note [Type checking recursive type and class declarations] in GHC.Tc.TyCl

type RuntimeRepType = Type Source #

Type synonym used for types of kind RuntimeRep.

## Constructing and deconstructing types

mkTyVarTy :: TyVar -> Type Source #

mkTyVarTys :: [TyVar] -> [Type] Source #

getTyVar :: HasDebugCallStack => 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

tyVarKind :: TyVar -> Kind Source #

varType :: Var -> Kind Source #

The type or kind of the `Var` in question

mkAppTy :: Type -> Type -> Type Source #

Applies a type to another, as in e.g. `k a`

mkAppTys :: Type -> [Type] -> Type Source #

splitAppTy :: Type -> (Type, Type) Source #

Attempts to take a type application apart, as in `splitAppTy_maybe`, and panics if this is not possible

splitAppTys :: HasDebugCallStack => 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.

splitAppTysNoView :: 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!

splitAppTyNoView_maybe :: HasDebugCallStack => Type -> Maybe (Type, Type) Source #

Does the AppTy split as in `splitAppTy_maybe`, but assumes that any coreView stuff is already done

tcSplitAppTyNoView_maybe :: Type -> Maybe (Type, Type) Source #

Just like splitAppTyNoView_maybe, but does not split (c => t) See Note [Decomposing fat arrow c=>t]

mkFunTy :: HasDebugCallStack => FunTyFlag -> Mult -> Type -> Type -> Type infixr 3 Source #

mkVisFunTy :: HasDebugCallStack => Mult -> Type -> Type -> Type Source #

mkVisFunTyMany :: HasDebugCallStack => Type -> Type -> Type infixr 3 Source #

Make nested arrow types | Special, common, case: Arrow type with mult Many

mkVisFunTysMany :: [Type] -> Type -> Type Source #

mkScaledFunTys :: HasDebugCallStack => [Scaled Type] -> Type -> Type Source #

mkInvisFunTy :: HasDebugCallStack => Type -> Type -> Type infixr 3 Source #

mkInvisFunTys :: HasDebugCallStack => [Type] -> Type -> Type Source #

tcMkVisFunTy :: Mult -> Type -> Type -> Type Source #

tcMkScaledFunTys :: [Scaled Type] -> Type -> Type Source #

tcMkInvisFunTy :: TypeOrConstraint -> Type -> Type -> Type Source #

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 (FunTyFlag, Mult, Type, Type) Source #

Attempts to extract the multiplicity, argument and result types from a type

splitFunTys :: Type -> ([Scaled Type], Type) Source #

funResultTy :: HasDebugCallStack => Type -> Type Source #

Extract the function result type and panic if that is not possible

funArgTy :: HasDebugCallStack => Type -> Type Source #

Extract the function argument type and panic if that is not possible

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"

funTyConAppTy_maybe :: FunTyFlag -> Type -> Type -> Type -> Maybe (TyCon, [Type]) Source #

Given the components of a FunTy figure out the corresponding TyConApp.

funTyFlagTyCon :: FunTyFlag -> TyCon Source #

tyConAppFunTy_maybe :: HasDebugCallStack => TyCon -> [Type] -> Maybe Type Source #

Return Just if this TyConApp should be represented as a FunTy

tyConAppFunCo_maybe :: HasDebugCallStack => Role -> TyCon -> [Coercion] -> Maybe Coercion Source #

Return Just if this TyConAppCo should be represented as a FunCo

mkFunctionType :: HasDebugCallStack => Mult -> Type -> Type -> Type Source #

This one works out the FunTyFlag from the argument type See GHC.Types.Var Note [FunTyFlag]

mkScaledFunctionTys :: [Scaled Type] -> Type -> Type Source #

Like mkFunctionType, compute the FunTyFlag from the arguments

chooseFunTyFlag :: HasDebugCallStack => Type -> Type -> FunTyFlag Source #

See GHC.Types.Var Note [FunTyFlag]

mkTyConApp :: TyCon -> [Type] -> Type Source #

A key function: builds a `TyConApp` or `FunTy` as appropriate to its arguments. Applies its arguments to the constructor from left to right.

mkTyConTy :: TyCon -> Type Source #

(mkTyConTy tc) returns (TyConApp tc []) but arranges to share that TyConApp among all calls See Note [Sharing nullary TyConApps] So it's just an alias for tyConNullaryTy!

tyConAppTyCon_maybe :: Type -> Maybe TyCon Source #

The same as `fst . splitTyConApp` We can short-cut the FunTy case

tyConAppTyConPicky_maybe :: Type -> Maybe TyCon Source #

Retrieve the tycon heading this type, if there is one. Does not look through synonyms.

tyConAppArgs_maybe :: Type -> Maybe [Type] Source #

The same as `snd . splitTyConApp`

tyConAppTyCon :: HasDebugCallStack => Type -> TyCon Source #

tyConAppArgs :: HasCallStack => 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

splitTyConAppNoView_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type]) Source #

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 :: Type -> (TyCon, [Type]) Source #

tcSplitTyConApp_maybe :: HasCallStack => Type -> Maybe (TyCon, [Type]) Source #

tcSplitTyConApp_maybe splits a type constructor application into its type constructor and applied types.

Differs from splitTyConApp_maybe in that it does *not* split types headed with (=>), as that's not a TyCon in the type-checker.

Note that this may fail (in funTyConAppTy_maybe) 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`. This isn't usually a problem but may be temporarily the case during canonicalization: see Note [Decomposing FunTy] in GHC.Tc.Solver.Equality and Note [The Purely Kinded Type Invariant (PKTI)] in GHC.Tc.Gen.HsType, Wrinkle around FunTy

Consequently, you may need to zonk your type before using this function.

mkForAllTy :: ForAllTyBinder -> Type -> Type Source #

Like `mkTyCoForAllTy`, but does not check the occurrence of the binder See Note [Unused coercion variable in ForAllTy]

mkForAllTys :: [ForAllTyBinder] -> 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

mkTyCoForAllTy :: TyCoVar -> ForAllTyFlag -> Type -> Type Source #

Make a dependent forall over a TyCoVar

mkTyCoForAllTys :: [ForAllTyBinder] -> Type -> Type Source #

Make a dependent forall over a TyCoVar

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.

splitForAllTyVars :: Type -> ([TyVar], Type) Source #

Like `splitForAllTyCoVars`, but split only for tyvars. 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.

splitForAllReqTyBinders :: Type -> ([ReqTyBinder], Type) Source #

Like `splitForAllTyCoVars`, but only splits `ForAllTy`s with `Required` type variable binders. Furthermore, each returned tyvar is annotated with `()`.

splitForAllInvisTyBinders :: Type -> ([InvisTyBinder], Type) Source #

Like `splitForAllTyCoVars`, but only splits `ForAllTy`s with `Invisible` type variable binders. Furthermore, each returned tyvar is annotated with its `Specificity`.

splitForAllForAllTyBinders :: Type -> ([ForAllTyBinder], Type) Source #

Take a ForAllTy apart, returning the binders and result type

splitForAllForAllTyBinder_maybe :: Type -> Maybe (ForAllTyBinder, Type) Source #

Attempts to take a ForAllTy apart, returning the full ForAllTyBinder

splitForAllTyCoVar_maybe :: Type -> Maybe (TyCoVar, Type) Source #

Attempts to take a ForAllTy apart, returning the Var

splitForAllTyCoVar :: Type -> (TyCoVar, Type) Source #

Take a forall type apart, or panics if that is not possible.

splitForAllTyVar_maybe :: Type -> Maybe (TyVar, Type) Source #

Attempts to take a ForAllTy apart, but only if the binder is a TyVar

splitForAllCoVar_maybe :: Type -> Maybe (CoVar, Type) Source #

Like `splitForAllTyCoVar_maybe`, but only returns Just if it is a covar binder.

splitPiTy_maybe :: Type -> Maybe (PiTyBinder, Type) Source #

Attempts to take a forall type apart; works with proper foralls and functions

splitPiTy :: Type -> (PiTyBinder, Type) Source #

Takes a forall type apart, or panics

splitPiTys :: Type -> ([PiTyBinder], Type) Source #

Split off all PiTyBinders to a type, splitting both proper foralls and functions

getRuntimeArgTys :: Type -> [(Scaled Type, FunTyFlag)] Source #

Extracts a list of run-time arguments from a function type, looking through newtypes to the right of arrows.

Examples:

       newtype Identity a = I a

       getRuntimeArgTys (Int -> Bool -> Double) == [(Int, FTF_T_T), (Bool, FTF_T_T)]
       getRuntimeArgTys (Identity Int -> Bool -> Double) == [(Identity Int, FTF_T_T), (Bool, FTF_T_T)]
       getRuntimeArgTys (Int -> Identity (Bool -> Identity Double)) == [(Int, FTF_T_T), (Bool, FTF_T_T)]
       getRuntimeArgTys (forall a. Show a => Identity a -> a -> Int -> Bool)
                == [(Show a, FTF_C_T), (Identity a, FTF_T_T),(a, FTF_T_T),(Int, FTF_T_T)]

Note that, in the last case, the returned types might mention an out-of-scope type variable. This function is used only when we really care about the kinds of the returned types, so this is OK.

- *Warning**: this function can return an infinite list. For example:

      newtype N a = MkN (a -> N a)
      getRuntimeArgTys (N a) == repeat (a, FTF_T_T)

mkTyConBindersPreferAnon Source #

Arguments

:: [TyVar] | binders
-> TyCoVarSet | free variables of result
-> [TyConBinder] |

Given a list of type-level vars and the free vars of a result kind, makes PiTyBinders, 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 non-coercion binders are visible.

mkPiTy :: HasDebugCallStack => PiTyBinder -> Type -> Type Source #

mkPiTys :: HasDebugCallStack => [PiTyBinder] -> Type -> Type Source #

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 for-alls than there are args 2. Less obviously, it may have fewer for-alls 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.

applyTysX :: HasDebugCallStack => [TyVar] -> Type -> [Type] -> Type Source #

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)

buildSynTyCon Source #

Arguments

:: Name |
-> [KnotTied TyConBinder] |
-> Kind | result kind
-> [Role] |
-> KnotTied Type |
-> TyCon |

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.

isLitTy :: Type -> Maybe TyLit Source #

Is this a type literal (symbol, numeric, or char)?

isPredTy :: HasDebugCallStack => Type -> Bool Source #

getRuntimeRep :: HasDebugCallStack => Type -> RuntimeRepType Source #

Extract the RuntimeRep classifier of a type. For instance, `getRuntimeRep_maybe Int = LiftedRep`. Panics if this is not possible.

splitRuntimeRep_maybe :: RuntimeRepType -> Maybe (TyCon, [Type]) Source #

(splitRuntimeRep_maybe rr) takes a Type rr :: RuntimeRep, and returns the (TyCon,[Type]) for the RuntimeRep, if possible, where the TyCon is one of the promoted DataCons of RuntimeRep. Remember: the unique on TyCon that is a a promoted DataCon is the same as the unique on the DataCon See Note [Promoted data constructors] in GHC.Core.TyCon May not be possible if `rr` is a type variable or type family application

kindRep_maybe :: HasDebugCallStack => Kind -> Maybe RuntimeRepType Source #

Given a kind (TYPE rr) or (CONSTRAINT rr), extract its RuntimeRep classifier rr. For example, `kindRep_maybe * = Just LiftedRep` Returns `Nothing` if the kind is not of form (TYPE rr)

kindRep :: HasDebugCallStack => Kind -> RuntimeRepType 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

getLevity :: HasDebugCallStack => Type -> Type Source #

Extract the `Levity` of a type. For example, `getLevity Int = Lifted`, or `getLevity (Array# Int) = Unlifted`.

Panics if this is not possible. Does not look through type family applications.

levityType_maybe :: LevityType -> Maybe Levity Source #

`levityType_maybe` takes a Type of kind Levity, and returns its levity May not be possible for a type variable or type family application

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 #

splitCastTy_maybe :: Type -> Maybe (Type, Coercion) Source #

type ErrorMsgType = Type Source #

A type of kind `ErrorMessage` (from the `TypeError` module).

userTypeError_maybe :: Type -> Maybe ErrorMsgType Source #

Is this type a custom user error? If so, give us the error message.

deepUserTypeError_maybe :: Type -> Maybe ErrorMsgType Source #

pprUserTypeErrorTy :: ErrorMsgType -> SDoc Source #

Render a type corresponding to a user type error into a SDoc.

coAxNthLHS :: forall (br :: BranchFlag). 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 -> ([PiTyBinder], Type) Source #

Like `splitPiTys`, but returns only *invisible* binders, including constraints. Stops at the first visible binder.

splitInvisPiTysN :: Int -> Type -> ([PiTyBinder], Type) Source #

Same as `splitInvisPiTys`, but stop when - you have found `n` `PiTyBinder`s, - or you run out of invisible binders

invisibleTyBndrCount :: Type -> Int Source #

filterOutInvisibleTypes :: TyCon -> [Type] -> [Type] Source #

Given a `TyCon` and a list of argument types, filter out any invisible (i.e., `Inferred` or `Specified`) arguments.

filterOutInferredTypes :: TyCon -> [Type] -> [Type] Source #

Given a `TyCon` and a list of argument types, filter out any `Inferred` arguments.

partitionInvisibleTypes :: TyCon -> [Type] -> ([Type], [Type]) Source #

Given a `TyCon` and a list of argument types, partition the arguments into:

1. `Inferred` or `Specified` (i.e., invisible) arguments and
2. `Required` (i.e., visible) arguments

partitionInvisibles :: [(a, ForAllTyFlag)] -> ([a], [a]) Source #

Given a list of things paired with their visibilities, partition the things into (invisible things, visible things).

tyConForAllTyFlags :: TyCon -> [Type] -> [ForAllTyFlag] 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
    tyConForAllTyFlags 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.

appTyForAllTyFlags :: Type -> [Type] -> [ForAllTyFlag] 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 higher-rank situation in which `appTyForAllTyFlags` comes in handy, since `f Type Bool` would be represented in Core using `AppTy`s. (See also #15792).

## Analyzing types

data TyCoMapper env (m :: Type -> Type) Source #

This describes how a "map" operation over a type/coercion should behave

Constructors

TyCoMapper |
Fields tcm_tyvar :: env -> TyVar -> m Type tcm_covar :: env -> CoVar -> m Coercion tcm_hole :: env -> CoercionHole -> m Coercion What to do with coercion holes. See Note [Coercion holes] in GHC.Core.TyCo.Rep. tcm_tycobinder :: forall r. env -> TyCoVar -> ForAllTyFlag -> (env -> TyCoVar -> m r) -> m r The returned env is used in the extended scope tcm_tycon :: TyCon -> m TyCon This is used only for TcTyCons a) To zonk TcTyCons b) To turn TcTyCons into TyCons. See Note [Type checking recursive type and class declarations] in GHC.Tc.TyCl

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 #

Constructors

TyCoFolder |
Fields tcf_view :: Type -> Maybe Type tcf_tyvar :: env -> TyVar -> a tcf_covar :: env -> CoVar -> a tcf_hole :: env -> CoercionHole -> a What to do with coercion holes. See Note [Coercion holes] in GHC.Core.TyCo.Rep. tcf_tycobinder :: env -> TyCoVar -> ForAllTyFlag -> env The returned env is used in the extended scope

foldTyCo :: Monoid a => TyCoFolder env a -> env -> (Type -> a, [Type] -> a, Coercion -> a, [Coercion] -> a) Source #

noView :: Type -> Maybe Type Source #

A view function that looks through nothing.

newTyConInstRhs :: TyCon -> [Type] -> Type Source #

Unwrap one `layer` of newtype on a type constructor and its arguments, using an eta-reduced version of the `newtype` if possible. This requires tys to have at least `newTyConInstArity tycon` elements.

## Binders

mkForAllTyBinder :: vis -> TyCoVar -> VarBndr TyCoVar vis Source #

Make a named binder

mkForAllTyBinders :: vis -> [TyCoVar] -> [VarBndr TyCoVar vis] Source #

Make many named 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 ForAllTyFlag] Source #

isAnonPiTyBinder :: PiTyBinder -> Bool Source #

Does this binder bind a variable that is not erased? Returns `True` for anonymous binders.

binderVar :: VarBndr tv argf -> tv Source #

binderVars :: [VarBndr tv argf] -> [tv] Source #

binderType :: VarBndr TyCoVar argf -> Type Source #

binderFlag :: VarBndr tv argf -> argf Source #

binderFlags :: [VarBndr tv argf] -> [argf] Source #

piTyBinderType :: PiTyBinder -> Type Source #

namedPiTyBinder_maybe :: PiTyBinder -> Maybe TyCoVar Source #

anonPiTyBinderType_maybe :: PiTyBinder -> Maybe Type Source #

Extract a relevant type, if there is one.

isVisibleForAllTyFlag :: ForAllTyFlag -> Bool Source #

Does this `ForAllTyFlag` classify an argument that is written in Haskell?

isInvisibleForAllTyFlag :: ForAllTyFlag -> Bool Source #

Does this `ForAllTyFlag` classify an argument that is not written in Haskell?

isVisiblePiTyBinder :: PiTyBinder -> Bool Source #

Does this binder bind a visible argument?

isInvisiblePiTyBinder :: PiTyBinder -> Bool Source #

Does this binder bind an invisible argument?

isNamedPiTyBinder :: PiTyBinder -> Bool Source #

tyConBindersPiTyBinders :: [TyConBinder] -> [PiTyBinder] Source #

## Predicates on types

isTyVarTy :: Type -> Bool Source #

isFunTy :: Type -> Bool Source #

Is this a function?

isCoercionTy :: Type -> Bool Source #

isCoercionTy_maybe :: Type -> Maybe Coercion 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

isForAllTy_invis_ty :: Type -> Bool Source #

Like `isForAllTy`, but returns True only if it is an inferred tyvar binder

isPiTy :: Type -> Bool Source #

Is this a function or forall?

isTauTy :: Type -> Bool Source #

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]

tyConAppNeedsKindSig Source #

Arguments

:: 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 `TyCon` is applied to.
-> Bool | Does `T t_1 ... t_n` need a kind signature? (Where `n` is the number of arguments)

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 source-syntax type? (See `Note [When does a tycon application need an explicit kind signature?]` for a full explanation of what this function checks for.)

# Space-saving construction

mkTYPEapp :: RuntimeRepType -> Type Source #

mkTYPEapp_maybe :: RuntimeRepType -> Maybe Type Source #

Given a `RuntimeRep`, applies `TYPE` to it. On the fly it rewrites TYPE LiftedRep --> liftedTypeKind (a synonym) TYPE UnliftedRep --> unliftedTypeKind (ditto) TYPE ZeroBitRep --> zeroBitTypeKind (ditto) NB: no need to check for TYPE (BoxedRep Lifted), TYPE (BoxedRep Unlifted) because those inner types should already have been rewritten to LiftedRep and UnliftedRep respectively, by mkTyConApp

see Note [TYPE and CONSTRAINT] in GHC.Builtin.Types.Prim. See Note [Using synonyms to compress types] in GHC.Core.Type

mkCONSTRAINTapp :: RuntimeRepType -> Type Source #

Just like mkTYPEapp

mkCONSTRAINTapp_maybe :: RuntimeRepType -> Maybe Type Source #

Just like mkTYPEapp_maybe

mkBoxedRepApp_maybe :: LevityType -> Maybe Type Source #

Given a `Levity`, apply `BoxedRep` to it On the fly, rewrite BoxedRep Lifted --> liftedRepTy (a synonym) BoxedRep Unlifted --> unliftedRepTy (ditto) See Note [TYPE and CONSTRAINT] in GHC.Builtin.Types.Prim. See Note [Using synonyms to compress types] in GHC.Core.Type

mkTupleRepApp_maybe :: Type -> Maybe Type Source #

Given a `[RuntimeRep]`, apply `TupleRep` to it On the fly, rewrite TupleRep [] -> zeroBitRepTy (a synonym) See Note [TYPE and CONSTRAINT] in GHC.Builtin.Types.Prim. See Note [Using synonyms to compress types] in GHC.Core.Type

typeOrConstraintKind :: TypeOrConstraint -> RuntimeRepType -> Kind Source #

### Levity and boxity

sORTKind_maybe :: Kind -> Maybe (TypeOrConstraint, Type) Source #

typeTypeOrConstraint :: HasDebugCallStack => Type -> TypeOrConstraint Source #

typeLevity :: HasDebugCallStack => Type -> Levity Source #

typeLevity_maybe :: HasDebugCallStack => Type -> Maybe Levity Source #

Tries to compute the `Levity` of the given type. Returns either a definite `Levity`, or `Nothing` if we aren't sure (e.g. the type is representation-polymorphic).

Panics if the kind does not have the shape `TYPE r`.

tyConIsTYPEorCONSTRAINT :: TyCon -> Bool Source #

isLiftedTypeKind :: Kind -> Bool Source #

Returns True if the argument is (lifted) Type or Constraint See Note [TYPE and CONSTRAINT] in GHC.Builtin.Types.Prim

isUnliftedTypeKind :: Kind -> Bool Source #

Returns True if the kind classifies unlifted types (like 'Int#') and False otherwise. Note that this returns False for representation-polymorphic kinds, which may be specialized to a kind that classifies unlifted types.

pickyIsLiftedTypeKind :: Kind -> Bool Source #

isLiftedRuntimeRep :: RuntimeRepType -> Bool Source #

Check whether a type of kind `RuntimeRep` is lifted.

`isLiftedRuntimeRep` is:

- True of `LiftedRep :: RuntimeRep`
- False of type variables, type family applications, and of other reps such as `IntRep :: RuntimeRep`.

isUnliftedRuntimeRep :: RuntimeRepType -> Bool Source #

Check whether a type of kind `RuntimeRep` is unlifted.

- True of definitely unlifted `RuntimeRep`s such as `UnliftedRep`, `IntRep`, `FloatRep`, ...
- False of `LiftedRep`,
- False for type variables and type family applications.

runtimeRepLevity_maybe :: RuntimeRepType -> Maybe Levity Source #

Check whether a type (usually of kind `RuntimeRep`) is lifted, unlifted, or unknown. Returns Nothing if the type isn't of kind `RuntimeRep`.

`runtimeRepLevity_maybe rr` returns:

- `Just Lifted` if `rr` is `LiftedRep :: RuntimeRep`
- `Just Unlifted` if `rr` is definitely unlifted, e.g. `IntRep`
- `Nothing` if not known (e.g. it's a type variable or a type family application).

isBoxedRuntimeRep :: RuntimeRepType -> Bool Source #

See `isBoxedRuntimeRep_maybe`.

isLiftedLevity :: Type -> Bool Source #

isUnliftedLevity :: Type -> Bool Source #

isUnliftedType :: HasDebugCallStack => Type -> Bool Source #

Is the given type definitely unlifted? See Type for what an unlifted type is.

Panics on representation-polymorphic types; See `mightBeUnliftedType` for a more approximate predicate that behaves better in the presence of representation polymorphism.

isBoxedType :: Type -> Bool Source #

See Type for what a boxed type is. Panics on representation-polymorphic types; See `mightBeUnliftedType` for a more approximate predicate that behaves better in the presence of representation polymorphism.

isUnboxedTupleType :: Type -> Bool Source #

isUnboxedSumType :: Type -> Bool Source #

kindBoxedRepLevity_maybe :: Type -> Maybe Levity Source #

Check whether a kind is of the form `TYPE (BoxedRep Lifted)` or `TYPE (BoxedRep Unlifted)`.

Returns:

- `Just Lifted` for `TYPE (BoxedRep Lifted)` and `Type`,
- `Just Unlifted` for `TYPE (BoxedRep Unlifted)` and `UnliftedType`,
- `Nothing` for anything else, e.g. `TYPE IntRep`, `TYPE (BoxedRep l)`, etc.

mightBeLiftedType :: Type -> Bool Source #

Returns:

- `False` if the type is guaranteed unlifted or
- `True` if it lifted, OR we aren't sure (e.g. in a representation-polymorphic case)

mightBeUnliftedType :: Type -> Bool Source #

Returns:

- `False` if the type is guaranteed lifted or
- `True` if it is unlifted, OR we aren't sure (e.g. in a representation-polymorphic case)

definitelyLiftedType :: Type -> Bool Source #

definitelyUnliftedType :: 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 representation-polymorphic types.

isTerminatingType :: HasDebugCallStack => Type -> Bool Source #

True = a term of this type cannot be bottom This identifies the types described by Note [NON-BOTTOM-DICTS invariant] in GHC.Core NB: unlifted types are not terminating types! e.g. you can write a term (loop 1)::Int# that diverges.

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#]

# 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

linear :: a -> Scaled a Source #

Scale a payload by One

tymult :: a -> Scaled a Source #

Scale a payload by Many; used for type arguments in core

mkScaled :: Mult -> a -> Scaled a Source #

irrelevantMult :: Scaled a -> a Source #

scaledSet :: Scaled a -> b -> Scaled b Source #

pattern OneTy :: Mult Source #

pattern ManyTy :: Mult Source #

isOneTy :: Mult -> Bool Source #

isManyTy :: Mult -> Bool Source #

isLinearType :: Type -> Bool Source #

`isLinear t` returns `True` of a if `t` is a type of (curried) function where at least one argument is linear (or otherwise non-unrestricted). We use this function to check whether it is safe to eta reduce an Id in CorePrep. It is always safe to return `True`, because `True` deactivates the optimisation.

# Main data types representing Kinds

type Kind = Type Source #

The key type representing kinds in the compiler.

## Finding the kind of a type

typeKind :: HasDebugCallStack => Type -> Kind Source #

typeHasFixedRuntimeRep :: HasDebugCallStack => Type -> Bool Source #

Returns True if a type has a syntactically fixed runtime rep, as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete.

This function is equivalent to `isFixedRuntimeRepKind . typeKind` but much faster.

Precondition: The type has kind `(`TYPE` blah)`

tcIsLiftedTypeKind :: Kind -> Bool Source #

Is this kind equivalent to `Type` i.e. TYPE LiftedRep?

isConstraintKind :: Kind -> Bool Source #

isConstraintLikeKind :: Kind -> Bool Source #

returnsConstraintKind :: Kind -> Bool Source #

tcIsBoxedTypeKind :: Kind -> Bool Source #

Is this kind equivalent to `TYPE (BoxedRep l)` for some `l :: Levity`?

isTypeLikeKind :: Kind -> Bool Source #

Is this kind equivalent to `TYPE r` (for some unknown r)?

This considers `Constraint` to be distinct from `*`.

## Common Kind

liftedTypeKind :: Type Source #

unliftedTypeKind :: Type Source #

# 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.

Eta-expanded because that makes it run faster (apparently) See Note [FV eta expansion] in GHC.Utils.FV for explanation.

tyCoFVsBndr :: ForAllTyBinder -> FV -> FV Source #

tyCoFVsVarBndr :: Var -> FV -> FV Source #

tyCoFVsVarBndrs :: [Var] -> 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 #

anyFreeVarsOfType :: (TyCoVar -> Bool) -> Type -> Bool Source #

anyFreeVarsOfTypes :: (TyCoVar -> Bool) -> [Type] -> Bool Source #

noFreeVarsOfType :: Type -> Bool 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`

typeSize :: Type -> Int Source #

occCheckExpand :: [Var] -> Type -> Maybe Type Source #

## 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.

closeOverKinds :: TyCoVarSet -> TyCoVarSet Source #

# Well-scoped 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 well-scoped list [ k::*, a::k, b::k ]

This is a deterministic sorting operation (that is, doesn't depend on Uniques).

It is also meant to be stable: that is, variables should not be reordered unnecessarily. This is specified in Note [ScopedSort] See also Note [Ordering of implicit variables] in GHC.Rename.HsType

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

# Forcing evaluation of types

seqType :: Type -> () Source #

seqTypes :: [Type] -> () Source #

# 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 does not look through type family applications.

By being non-recursive and inlined, this case analysis gets efficiently joined onto the case analysis that the caller is already doing

coreFullView :: Type -> Type Source #

Iterates `coreView` until there is no more to synonym to expand. NB: coreFullView is non-recursive and can be inlined; core_full_view is the recursive one See Note [Inlining coreView].

rewriterView :: Type -> Maybe Type Source #

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 TvSubstEnv = TyVarEnv Type Source #

A substitution of `Type`s for `TyVar`s and `Kind`s for `KindVar`s

type IdSubstEnv = IdEnv CoreExpr Source #

A substitution of `Expr`s for non-coercion `Id`s

data Subst Source #

Type & coercion & id substitution

The Subst data type defined in this module contains substitution for tyvar, covar and id. However, operations on IdSubstEnv (mapping from Id to CoreExpr) that require the definition of the Expr data type are defined in GHC.Core.Subst to avoid circular module dependency.

Constructors

Subst InScopeSet IdSubstEnv TvSubstEnv CvSubstEnv |

#### Instances

Instances details

Outputable Subst Source # |
Instance details Defined in GHC.Core.TyCo.Subst Methods ppr :: Subst -> SDoc Source #

## Manipulating type substitutions

emptyTvSubstEnv :: TvSubstEnv Source #

emptySubst :: Subst Source #

mkEmptySubst :: InScopeSet -> Subst Source #

mkTCvSubst :: InScopeSet -> TvSubstEnv -> CvSubstEnv -> Subst Source #

zipTvSubst :: HasDebugCallStack => [TyVar] -> [Type] -> Subst Source #

Generates the in-scope set for the `Subst` from the types in the incoming environment. No CoVars or Ids, please!

mkTvSubstPrs :: [(TyVar, Type)] -> Subst Source #

Generates the in-scope set for the `TCvSubst` from the types in the incoming environment. No CoVars, please! The InScopeSet is just a thunk so with a bit of luck it'll never be evaluated

zipTCvSubst :: HasDebugCallStack => [TyCoVar] -> [Type] -> Subst Source #

notElemSubst :: Var -> Subst -> Bool Source #

getTvSubstEnv :: Subst -> TvSubstEnv Source #

zapSubst :: Subst -> Subst Source #

Remove all substitutions that might have been built up while preserving the in-scope set originally called zapSubstEnv

getSubstInScope :: Subst -> InScopeSet Source #

Find the in-scope set: see Note [The substitution invariant]

setInScope :: Subst -> InScopeSet -> Subst Source #

getSubstRangeTyCoFVs :: Subst -> VarSet Source #

Returns the free variables of the types in the range of a substitution as a non-deterministic set.

extendSubstInScope :: Subst -> Var -> Subst Source #

Add the `Var` to the in-scope set

extendSubstInScopeList :: Subst -> [Var] -> Subst Source #

Add the `Var`s to the in-scope set: see also `extendInScope`

extendSubstInScopeSet :: Subst -> VarSet -> Subst Source #

Add the `Var`s to the in-scope set: see also `extendInScope`

extendTCvSubst :: Subst -> TyCoVar -> Type -> Subst Source #

extendCvSubst :: Subst -> CoVar -> Coercion -> Subst Source #

Add a substitution from a `CoVar` to a `Coercion` to the `Subst`: you must ensure that the in-scope set satisfies Note [The substitution invariant] after extending the substitution like this

extendTvSubst :: Subst -> TyVar -> Type -> Subst Source #

Add a substitution for a `TyVar` to the `Subst` The `TyVar` *must* be a real TyVar, and not a CoVar You must ensure that the in-scope set is such that Note [The substitution invariant] holds after extending the substitution like this.

extendTvSubstBinderAndInScope :: Subst -> PiTyBinder -> Type -> Subst Source #

extendTvSubstList :: Subst -> [(TyVar, Type)] -> Subst Source #

Adds multiple `TyVar` substitutions to the `Subst`: see also `extendTvSubst`

extendTvSubstAndInScope :: Subst -> TyVar -> Type -> Subst Source #

extendTCvSubstList :: Subst -> [Var] -> [Type] -> Subst Source #

extendTvSubstWithClone :: Subst -> TyVar -> TyVar -> Subst Source #

extendTCvSubstWithClone :: Subst -> TyCoVar -> TyCoVar -> Subst Source #

isInScope :: Var -> Subst -> Bool Source #

composeTCvSubst :: Subst -> Subst -> Subst Source #

Composes two substitutions, applying the second one provided first, like in function composition. This function leaves IdSubstEnv untouched because IdSubstEnv is not used during substitution for types.

zipTyEnv :: HasDebugCallStack => [TyVar] -> [Type] -> TvSubstEnv Source #

The InScopeSet is just a thunk so with a bit of luck it'll never be evaluated

zipCoEnv :: HasDebugCallStack => [CoVar] -> [Coercion] -> CvSubstEnv Source #

isEmptySubst :: Subst -> Bool Source #

unionSubst :: Subst -> Subst -> Subst Source #

isEmptyTCvSubst :: Subst -> Bool Source #

Checks whether the tyvar and covar environments are empty. This function should be used over `isEmptySubst` when substituting for types, because types currently do not contain expressions; we can safely disregard the expression environment when deciding whether to skip a substitution. Using `isEmptyTCvSubst` gives us a non-trivial performance boost (up to 70% less allocation for T18223)

## Performing substitution on types and kinds

substTy :: HasDebugCallStack => Subst -> Type -> Type Source #

Substitute within a `Type` The substitution has to satisfy the invariants described in Note [The substitution invariant].

substTys :: HasDebugCallStack => Subst -> [Type] -> [Type] Source #

Substitute within several `Type`s The substitution has to satisfy the invariants described in Note [The substitution invariant].

substScaledTy :: HasDebugCallStack => Subst -> Scaled Type -> Scaled Type Source #

substScaledTys :: HasDebugCallStack => Subst -> [Scaled Type] -> [Scaled Type] Source #

substTyWith :: HasDebugCallStack => [TyVar] -> [Type] -> Type -> Type Source #

Type substitution, see `zipTvSubst`

substTysWith :: HasDebugCallStack => [TyVar] -> [Type] -> [Type] -> [Type] Source #

Type substitution, see `zipTvSubst`

substTheta :: HasDebugCallStack => Subst -> ThetaType -> ThetaType Source #

Substitute within a `ThetaType` The substitution has to satisfy the invariants described in Note [The substitution invariant].

substTyAddInScope :: HasDebugCallStack => Subst -> Type -> Type Source #

Substitute within a `Type` after adding the free variables of the type to the in-scope set. This is useful for the case when the free variables aren't already in the in-scope set or easily available. See also Note [The substitution invariant].

substTyUnchecked :: Subst -> 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 :: Subst -> [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 :: HasDebugCallStack => Subst -> Scaled Type -> Scaled Type Source #

substScaledTysUnchecked :: Subst -> [Scaled Type] -> [Scaled Type] Source #

substThetaUnchecked :: Subst -> 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.

substCo :: HasDebugCallStack => Subst -> Coercion -> Coercion Source #

Substitute within a `Coercion` The substitution has to satisfy the invariants described in Note [The substitution invariant].

substCoUnchecked :: Subst -> 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 :: HasDebugCallStack => Subst -> TyVar -> (Subst, TyVar) Source #

substTyVarBndrs :: HasDebugCallStack => Subst -> [TyVar] -> (Subst, [TyVar]) Source #

substTyVar :: Subst -> TyVar -> Type Source #

substTyVars :: Subst -> [TyVar] -> [Type] Source #

substVarBndr :: HasDebugCallStack => Subst -> TyCoVar -> (Subst, TyCoVar) Source #

substVarBndrs :: HasDebugCallStack => Subst -> [TyCoVar] -> (Subst, [TyCoVar]) Source #

substTyCoBndr :: Subst -> PiTyBinder -> (Subst, PiTyBinder) Source #

substTyVarToTyVar :: HasDebugCallStack => Subst -> TyVar -> TyVar Source #

cloneTyVarBndr :: Subst -> TyVar -> Unique -> (Subst, TyVar) Source #

cloneTyVarBndrs :: Subst -> [TyVar] -> UniqSupply -> (Subst, [TyVar]) Source #

lookupTyVar :: Subst -> TyVar -> Maybe Type 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]

tidyOpenType :: TidyEnv -> Type -> (TidyEnv, Type) Source #

tidyOpenTypes :: TidyEnv -> [Type] -> (TidyEnv, [Type]) Source #

Grabs the free type variables, tidies them and then uses `tidyType` to work over the type itself

tidyVarBndr :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar) Source #

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`

tidyOpenTyCoVars :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar]) Source #

tidyTyCoVarOcc :: TidyEnv -> TyCoVar -> TyCoVar Source #

tidyTopType :: Type -> Type Source #

Calls `tidyType` on a top-level type (i.e. with an empty tidying environment)

tidyForAllTyBinder :: TidyEnv -> VarBndr TyCoVar vis -> (TidyEnv, VarBndr TyCoVar vis) Source #

tidyForAllTyBinders :: TidyEnv -> [VarBndr TyCoVar vis] -> (TidyEnv, [VarBndr TyCoVar vis]) Source #

# Kinds

isTYPEorCONSTRAINT :: Kind -> Bool Source #

Does this classify a type allowed to have values? Responds True to things like *, TYPE Lifted, TYPE IntRep, TYPE v, Constraint.

True of a kind `TYPE _` or `CONSTRAINT _`

isConcreteType :: Type -> Bool Source #

Tests whether the given type is concrete, i.e. it whether it consists only of concrete type constructors, concrete type variables, and applications.

See Note [Concrete types] in GHC.Tc.Utils.Concrete.

isFixedRuntimeRepKind :: HasDebugCallStack => Kind -> Bool Source #

Checks that a kind of the form `Type`, `Constraint` or `'TYPE r` is concrete. See `isConcreteType`.

Precondition: The type has kind `TYPE blah` or `CONSTRAINT blah`