TcType

ghc-7.10.2: The GHC API

Safe Haskell | None
Language | Haskell2010

TcType

Contents

- Finding type instances
- Finding "exact" (non-dead) type variables

Synopsis

- type TcType = Type
- type TcSigmaType = TcType
- type TcRhoType = TcType
- type TcTauType = TcType
- type TcPredType = PredType
- type TcThetaType = ThetaType
- type TcTyVar = TyVar
- type TcTyVarSet = TyVarSet
- type TcKind = Kind
- type TcCoVar = CoVar
- newtype TcLevel = TcLevel Int
- topTcLevel :: TcLevel
- pushTcLevel :: TcLevel -> TcLevel
- strictlyDeeperThan :: TcLevel -> TcLevel -> Bool
- sameDepthAs :: TcLevel -> TcLevel -> Bool
- fskTcLevel :: TcLevel
- data UserTypeCtxt
  - = FunSigCtxt Name
  - | InfSigCtxt Name
  - | ExprSigCtxt
  - | ConArgCtxt Name
  - | TySynCtxt Name
  - | PatSigCtxt
  - | RuleSigCtxt Name
  - | ResSigCtxt
  - | ForSigCtxt Name
  - | DefaultDeclCtxt
  - | InstDeclCtxt
  - | SpecInstCtxt
  - | ThBrackCtxt
  - | GenSigCtxt
  - | GhciCtxt
  - | ClassSCCtxt Name
  - | SigmaCtxt
  - | DataTyCtxt Name
- pprUserTypeCtxt :: UserTypeCtxt -> SDoc
- pprSigCtxt :: UserTypeCtxt -> SDoc -> SDoc -> SDoc
- data TcTyVarDetails
  - = SkolemTv Bool
  - | FlatSkol TcType
  - | RuntimeUnk
  - | MetaTv {
    - mtv_info :: MetaInfo
    - mtv_ref :: IORef MetaDetails
    - mtv_tclvl :: TcLevel
    }
- pprTcTyVarDetails :: TcTyVarDetails -> SDoc
- vanillaSkolemTv :: TcTyVarDetails
- superSkolemTv :: TcTyVarDetails
- data MetaDetails
  - = Flexi
  - | Indirect TcType
- data MetaInfo
  - = TauTv Bool
  - | ReturnTv
  - | SigTv
  - | FlatMetaTv
- isImmutableTyVar :: TyVar -> Bool
- isSkolemTyVar :: TcTyVar -> Bool
- isMetaTyVar :: TcTyVar -> Bool
- isMetaTyVarTy :: TcType -> Bool
- isTyVarTy :: Type -> Bool
- isSigTyVar :: Var -> Bool
- isOverlappableTyVar :: TcTyVar -> Bool
- isTyConableTyVar :: TcTyVar -> Bool
- isFskTyVar :: TcTyVar -> Bool
- isFmvTyVar :: TcTyVar -> Bool
- isFlattenTyVar :: TcTyVar -> Bool
- isReturnTyVar :: TcTyVar -> Bool
- isAmbiguousTyVar :: TcTyVar -> Bool
- metaTvRef :: TyVar -> IORef MetaDetails
- metaTyVarInfo :: TcTyVar -> MetaInfo
- isFlexi :: MetaDetails -> Bool
- isIndirect :: MetaDetails -> Bool
- isRuntimeUnkSkol :: TyVar -> Bool
- isTypeVar :: Var -> Bool
- isKindVar :: Var -> Bool
- metaTyVarTcLevel :: TcTyVar -> TcLevel
- setMetaTyVarTcLevel :: TcTyVar -> TcLevel -> TcTyVar
- metaTyVarTcLevel_maybe :: TcTyVar -> Maybe TcLevel
- isTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool
- isTouchableOrFmv :: TcLevel -> TcTyVar -> Bool
- isFloatedTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool
- canUnifyWithPolyType :: DynFlags -> TcTyVarDetails -> TcKind -> Bool
- mkPhiTy :: [PredType] -> Type -> Type
- mkSigmaTy :: [TyVar] -> [PredType] -> Type -> Type
- mkTcEqPred :: TcType -> TcType -> Type
- mkTcReprEqPred :: TcType -> TcType -> Type
- mkTcEqPredRole :: Role -> TcType -> TcType -> Type
- tcView :: Type -> Maybe Type
- tcSplitForAllTys :: Type -> ([TyVar], Type)
- tcSplitPhiTy :: Type -> (ThetaType, Type)
- tcSplitPredFunTy_maybe :: Type -> Maybe (PredType, Type)
- tcSplitFunTy_maybe :: Type -> Maybe (Type, Type)
- tcSplitFunTys :: Type -> ([Type], Type)
- tcFunArgTy :: Type -> Type
- tcFunResultTy :: Type -> Type
- tcSplitFunTysN :: TcRhoType -> Arity -> ([TcSigmaType], TcSigmaType)
- tcSplitTyConApp :: Type -> (TyCon, [Type])
- tcSplitTyConApp_maybe :: Type -> Maybe (TyCon, [Type])
- tcTyConAppTyCon :: Type -> TyCon
- tcTyConAppArgs :: Type -> [Type]
- tcSplitAppTy_maybe :: Type -> Maybe (Type, Type)
- tcSplitAppTy :: Type -> (Type, Type)
- tcSplitAppTys :: Type -> (Type, [Type])
- repSplitAppTy_maybe :: Type -> Maybe (Type, Type)
- tcInstHeadTyNotSynonym :: Type -> Bool
- tcInstHeadTyAppAllTyVars :: Type -> Bool
- tcGetTyVar_maybe :: Type -> Maybe TyVar
- tcGetTyVar :: String -> Type -> TyVar
- nextRole :: Type -> Role
- tcSplitSigmaTy :: Type -> ([TyVar], ThetaType, Type)
- tcDeepSplitSigmaTy_maybe :: TcSigmaType -> Maybe ([TcType], [TyVar], ThetaType, TcSigmaType)
- eqType :: Type -> Type -> Bool
- eqTypes :: [Type] -> [Type] -> Bool
- eqPred :: PredType -> PredType -> Bool
- cmpType :: Type -> Type -> Ordering
- cmpTypes :: [Type] -> [Type] -> Ordering
- cmpPred :: PredType -> PredType -> Ordering
- eqTypeX :: RnEnv2 -> Type -> Type -> Bool
- pickyEqType :: TcType -> TcType -> Bool
- tcEqType :: TcType -> TcType -> Bool
- tcEqKind :: TcKind -> TcKind -> Bool
- isSigmaTy :: TcType -> Bool
- isRhoTy :: TcType -> Bool
- isOverloadedTy :: Type -> Bool
- isDoubleTy :: Type -> Bool
- isFloatTy :: Type -> Bool
- isIntTy :: Type -> Bool
- isWordTy :: Type -> Bool
- isStringTy :: Type -> Bool
- isIntegerTy :: Type -> Bool
- isBoolTy :: Type -> Bool
- isUnitTy :: Type -> Bool
- isCharTy :: Type -> Bool
- isTauTy :: Type -> Bool
- isTauTyCon :: TyCon -> Bool
- tcIsTyVarTy :: Type -> Bool
- tcIsForAllTy :: Type -> Bool
- isPredTy :: Type -> Bool
- isTyVarClassPred :: PredType -> Bool
- isTyVarExposed :: TcTyVar -> TcType -> Bool
- deNoteType :: Type -> Type
- occurCheckExpand :: DynFlags -> TcTyVar -> Type -> OccCheckResult Type
- data OccCheckResult a
  - = OC_OK a
  - | OC_Forall
  - | OC_NonTyVar
  - | OC_Occurs
- orphNamesOfType :: Type -> NameSet
- orphNamesOfDFunHead :: Type -> NameSet
- orphNamesOfCo :: Coercion -> NameSet
- orphNamesOfTypes :: [Type] -> NameSet
- orphNamesOfCoCon :: CoAxiom br -> NameSet
- getDFunTyKey :: Type -> OccName
- evVarPred_maybe :: EvVar -> Maybe PredType
- evVarPred :: EvVar -> PredType
- mkMinimalBySCs :: [PredType] -> [PredType]
- transSuperClasses :: Class -> [Type] -> [PredType]
- immSuperClasses :: Class -> [Type] -> [PredType]
- tcTyFamInsts :: Type -> [(TyCon, [Type])]
- exactTyVarsOfType :: Type -> TyVarSet
- exactTyVarsOfTypes :: [Type] -> TyVarSet
- isFFIArgumentTy :: DynFlags -> Safety -> Type -> Validity
- isFFIImportResultTy :: DynFlags -> Type -> Validity
- isFFIExportResultTy :: Type -> Validity
- isFFIExternalTy :: Type -> Validity
- isFFIDynTy :: Type -> Type -> Validity
- isFFIPrimArgumentTy :: DynFlags -> Type -> Validity
- isFFIPrimResultTy :: DynFlags -> Type -> Validity
- isFFILabelTy :: Type -> Validity
- isFFITy :: Type -> Bool
- isFunPtrTy :: Type -> Bool
- tcSplitIOType_maybe :: Type -> Maybe (TyCon, Type)
- type Kind = Type
- typeKind :: Type -> Kind
- unliftedTypeKind :: Kind
- liftedTypeKind :: Kind
- openTypeKind :: Kind
- constraintKind :: Kind
- mkArrowKind :: Kind -> Kind -> Kind
- mkArrowKinds :: [Kind] -> Kind -> Kind
- isLiftedTypeKind :: Kind -> Bool
- isUnliftedTypeKind :: Kind -> Bool
- isSubOpenTypeKind :: Kind -> Bool
- tcIsSubKind :: Kind -> Kind -> Bool
- splitKindFunTys :: Kind -> ([Kind], Kind)
- defaultKind :: Kind -> Kind
- data Type
- type PredType = Type
- type ThetaType = [PredType]
- mkForAllTy :: TyVar -> Type -> Type
- mkForAllTys :: [TyVar] -> Type -> Type
- mkFunTy :: Type -> Type -> Type
- mkFunTys :: [Type] -> Type -> Type
- zipFunTys :: Outputable a => [a] -> Type -> ([(a, Type)], Type)
- mkTyConApp :: TyCon -> [Type] -> Type
- mkAppTy :: Type -> Type -> Type
- mkAppTys :: Type -> [Type] -> Type
- applyTy :: Type -> KindOrType -> Type
- applyTys :: Type -> [KindOrType] -> Type
- mkTyVarTy :: TyVar -> Type
- mkTyVarTys :: [TyVar] -> [Type]
- mkTyConTy :: TyCon -> Type
- isClassPred :: PredType -> Bool
- isEqPred :: PredType -> Bool
- isIPPred :: PredType -> Bool
- mkClassPred :: Class -> [Type] -> PredType
- isDictLikeTy :: Type -> Bool
- tcSplitDFunTy :: Type -> ([TyVar], [Type], Class, [Type])
- tcSplitDFunHead :: Type -> (Class, [Type])
- mkEqPred :: Type -> Type -> PredType
- data TvSubst = TvSubst InScopeSet TvSubstEnv
- type TvSubstEnv = TyVarEnv Type
- emptyTvSubst :: TvSubst
- mkOpenTvSubst :: TvSubstEnv -> TvSubst
- zipOpenTvSubst :: [TyVar] -> [Type] -> TvSubst
- zipTopTvSubst :: [TyVar] -> [Type] -> TvSubst
- mkTopTvSubst :: [(TyVar, Type)] -> TvSubst
- notElemTvSubst :: CoVar -> TvSubst -> Bool
- unionTvSubst :: TvSubst -> TvSubst -> TvSubst
- getTvSubstEnv :: TvSubst -> TvSubstEnv
- setTvSubstEnv :: TvSubst -> TvSubstEnv -> TvSubst
- getTvInScope :: TvSubst -> InScopeSet
- extendTvInScope :: TvSubst -> Var -> TvSubst
- lookupTyVar :: TvSubst -> TyVar -> Maybe Type
- extendTvSubst :: TvSubst -> TyVar -> Type -> TvSubst
- substTyVarBndr :: TvSubst -> TyVar -> (TvSubst, TyVar)
- extendTvSubstList :: TvSubst -> [TyVar] -> [Type] -> TvSubst
- isInScope :: Var -> TvSubst -> Bool
- mkTvSubst :: InScopeSet -> TvSubstEnv -> TvSubst
- zipTyEnv :: [TyVar] -> [Type] -> TvSubstEnv
- substTy :: TvSubst -> Type -> Type
- substTys :: TvSubst -> [Type] -> [Type]
- substTyWith :: [TyVar] -> [Type] -> Type -> Type
- substTheta :: TvSubst -> ThetaType -> ThetaType
- substTyVar :: TvSubst -> TyVar -> Type
- substTyVars :: TvSubst -> [TyVar] -> [Type]
- isUnLiftedType :: Type -> Bool
- isUnboxedTupleType :: Type -> Bool
- isPrimitiveType :: Type -> Bool
- tyVarsOfType :: Type -> VarSet
- tyVarsOfTypes :: [Type] -> TyVarSet
- closeOverKinds :: TyVarSet -> TyVarSet
- tcTyVarsOfType :: Type -> TcTyVarSet
- tcTyVarsOfTypes :: [Type] -> TyVarSet
- pprKind :: Kind -> SDoc
- pprParendKind :: Kind -> SDoc
- pprSigmaType :: Type -> SDoc
- pprType :: Type -> SDoc
- pprParendType :: Type -> SDoc
- pprTypeApp :: TyCon -> [Type] -> SDoc
- pprTyThingCategory :: TyThing -> SDoc
- pprTheta :: ThetaType -> SDoc
- pprThetaArrowTy :: ThetaType -> SDoc
- pprClassPred :: Class -> [Type] -> SDoc

# Documentation

type TcType = Type Source

type TcSigmaType = TcType Source

type TcRhoType = TcType Source

type TcTauType = TcType Source

type TcPredType = PredType Source

type TcThetaType = ThetaType Source

type TcTyVar = TyVar Source

type TcTyVarSet = TyVarSet Source

type TcKind = Kind Source

type TcCoVar = CoVar Source

newtype TcLevel Source

Constructors

TcLevel Int |

Instances

Eq TcLevel |
Outputable TcLevel |

topTcLevel :: TcLevel Source

pushTcLevel :: TcLevel -> TcLevel Source

strictlyDeeperThan :: TcLevel -> TcLevel -> Bool Source

sameDepthAs :: TcLevel -> TcLevel -> Bool Source

fskTcLevel :: TcLevel Source

data UserTypeCtxt Source

Constructors

FunSigCtxt Name |
InfSigCtxt Name |
ExprSigCtxt |
ConArgCtxt Name |
TySynCtxt Name |
PatSigCtxt |
RuleSigCtxt Name |
ResSigCtxt |
ForSigCtxt Name |
DefaultDeclCtxt |
InstDeclCtxt |
SpecInstCtxt |
ThBrackCtxt |
GenSigCtxt |
GhciCtxt |
ClassSCCtxt Name |
SigmaCtxt |
DataTyCtxt Name |

pprUserTypeCtxt :: UserTypeCtxt -> SDoc Source

pprSigCtxt :: UserTypeCtxt -> SDoc -> SDoc -> SDoc Source

data TcTyVarDetails Source

Constructors

SkolemTv Bool |
FlatSkol TcType |
RuntimeUnk |
MetaTv |
Fields mtv_info :: MetaInfo mtv_ref :: IORef MetaDetails mtv_tclvl :: TcLevel

pprTcTyVarDetails :: TcTyVarDetails -> SDoc Source

vanillaSkolemTv :: TcTyVarDetails Source

superSkolemTv :: TcTyVarDetails Source

data MetaDetails Source

Constructors

Flexi |
Indirect TcType |

Instances

Outputable MetaDetails |

data MetaInfo Source

Constructors

TauTv Bool |
ReturnTv |
SigTv |
FlatMetaTv |

isImmutableTyVar :: TyVar -> Bool Source

isSkolemTyVar :: TcTyVar -> Bool Source

isMetaTyVar :: TcTyVar -> Bool Source

isMetaTyVarTy :: TcType -> Bool Source

isTyVarTy :: Type -> Bool Source

isSigTyVar :: Var -> Bool Source

isOverlappableTyVar :: TcTyVar -> Bool Source

isTyConableTyVar :: TcTyVar -> Bool Source

isFskTyVar :: TcTyVar -> Bool Source

True of FlatSkol skolems only

isFmvTyVar :: TcTyVar -> Bool Source

isFlattenTyVar :: TcTyVar -> Bool Source

True of both given and wanted flatten-skolems (fak and usk)

isReturnTyVar :: TcTyVar -> Bool Source

isAmbiguousTyVar :: TcTyVar -> Bool Source

metaTvRef :: TyVar -> IORef MetaDetails Source

metaTyVarInfo :: TcTyVar -> MetaInfo Source

isFlexi :: MetaDetails -> Bool Source

isIndirect :: MetaDetails -> Bool Source

isRuntimeUnkSkol :: TyVar -> Bool Source

isTypeVar :: Var -> Bool Source

isKindVar :: Var -> Bool Source

metaTyVarTcLevel :: TcTyVar -> TcLevel Source

setMetaTyVarTcLevel :: TcTyVar -> TcLevel -> TcTyVar Source

metaTyVarTcLevel_maybe :: TcTyVar -> Maybe TcLevel Source

isTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool Source

isTouchableOrFmv :: TcLevel -> TcTyVar -> Bool Source

isFloatedTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool Source

canUnifyWithPolyType :: DynFlags -> TcTyVarDetails -> TcKind -> Bool Source

mkPhiTy :: [PredType] -> Type -> Type Source

mkSigmaTy :: [TyVar] -> [PredType] -> Type -> Type Source

mkTcEqPred :: TcType -> TcType -> Type Source

mkTcReprEqPred :: TcType -> TcType -> Type Source

Make a representational equality predicate

mkTcEqPredRole :: Role -> TcType -> TcType -> Type Source

Make an equality predicate at a given role. The role must not be Phantom.

tcView :: Type -> Maybe Type Source

Similar to `coreView`, but for the type checker, which just looks through synonyms

tcSplitForAllTys :: Type -> ([TyVar], Type) Source

tcSplitPhiTy :: Type -> (ThetaType, Type) Source

tcSplitPredFunTy_maybe :: Type -> Maybe (PredType, Type) Source

tcSplitFunTy_maybe :: Type -> Maybe (Type, Type) Source

tcSplitFunTys :: Type -> ([Type], Type) Source

tcFunArgTy :: Type -> Type Source

tcFunResultTy :: Type -> Type Source

tcSplitFunTysN :: TcRhoType -> Arity -> ([TcSigmaType], TcSigmaType) Source

tcSplitTyConApp :: Type -> (TyCon, [Type]) Source

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

tcTyConAppTyCon :: Type -> TyCon Source

tcTyConAppArgs :: Type -> [Type] Source

tcSplitAppTy_maybe :: Type -> Maybe (Type, Type) Source

tcSplitAppTy :: Type -> (Type, Type) Source

tcSplitAppTys :: Type -> (Type, [Type]) Source

repSplitAppTy_maybe :: Type -> Maybe (Type, Type) Source

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

tcInstHeadTyNotSynonym :: Type -> Bool Source

tcInstHeadTyAppAllTyVars :: Type -> Bool Source

tcGetTyVar_maybe :: Type -> Maybe TyVar Source

tcGetTyVar :: String -> Type -> TyVar Source

nextRole :: Type -> Role Source

What is the role assigned to the next parameter of this type? Usually, this will be `Nominal`, but if the type is a `TyConApp`, we may be able to do better. The type does *not* have to be well-kinded when applied for this to work!

tcSplitSigmaTy :: Type -> ([TyVar], ThetaType, Type) Source

tcDeepSplitSigmaTy_maybe :: TcSigmaType -> Maybe ([TcType], [TyVar], ThetaType, TcSigmaType) Source

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. Watch out for horrible hack: See Note [Comparison with OpenTypeKind]

eqTypes :: [Type] -> [Type] -> Bool Source

eqPred :: PredType -> PredType -> Bool Source

cmpType :: Type -> Type -> Ordering Source

cmpTypes :: [Type] -> [Type] -> Ordering Source

cmpPred :: PredType -> PredType -> Ordering Source

eqTypeX :: RnEnv2 -> Type -> Type -> Bool Source

pickyEqType :: TcType -> TcType -> Bool Source

tcEqType :: TcType -> TcType -> Bool Source

tcEqKind :: TcKind -> TcKind -> Bool Source

isSigmaTy :: TcType -> Bool Source

isRhoTy :: TcType -> Bool Source

isOverloadedTy :: Type -> Bool Source

isDoubleTy :: Type -> Bool Source

isFloatTy :: Type -> Bool Source

isIntTy :: Type -> Bool Source

isWordTy :: Type -> Bool Source

isStringTy :: Type -> Bool Source

isIntegerTy :: Type -> Bool Source

isBoolTy :: Type -> Bool Source

isUnitTy :: Type -> Bool Source

isCharTy :: Type -> Bool Source

isTauTy :: Type -> Bool Source

isTauTyCon :: TyCon -> Bool Source

tcIsTyVarTy :: Type -> Bool Source

tcIsForAllTy :: Type -> Bool Source

isPredTy :: Type -> Bool Source

isTyVarClassPred :: PredType -> Bool Source

isTyVarExposed :: TcTyVar -> TcType -> Bool Source

Does the given tyvar appear in the given type outside of any non-newtypes? Assume we're looking for `a`. Says "yes" for `a`, `N a`, `b a`, `a b`, `b (N a)`. Says "no" for `[a]`, `Maybe a`, `T a`, where `N` is a newtype and `T` is a datatype.

deNoteType :: Type -> Type Source

occurCheckExpand :: DynFlags -> TcTyVar -> Type -> OccCheckResult Type Source

data OccCheckResult a Source

Constructors

OC_OK a |
OC_Forall |
OC_NonTyVar |
OC_Occurs |

Instances

Monad OccCheckResult |
Functor OccCheckResult |
Applicative OccCheckResult |

orphNamesOfType :: Type -> NameSet Source

orphNamesOfDFunHead :: Type -> NameSet Source

orphNamesOfCo :: Coercion -> NameSet Source

orphNamesOfTypes :: [Type] -> NameSet Source

orphNamesOfCoCon :: CoAxiom br -> NameSet Source

getDFunTyKey :: Type -> OccName Source

evVarPred_maybe :: EvVar -> Maybe PredType Source

evVarPred :: EvVar -> PredType Source

mkMinimalBySCs :: [PredType] -> [PredType] Source

transSuperClasses :: Class -> [Type] -> [PredType] Source

immSuperClasses :: Class -> [Type] -> [PredType] Source

# Finding type instances

tcTyFamInsts :: Type -> [(TyCon, [Type])] Source

Finds outermost type-family applications occuring in a type, after expanding synonyms.

# Finding "exact" (non-dead) type variables

exactTyVarsOfType :: Type -> TyVarSet Source

exactTyVarsOfTypes :: [Type] -> TyVarSet Source

isFFIArgumentTy :: DynFlags -> Safety -> Type -> Validity Source

isFFIImportResultTy :: DynFlags -> Type -> Validity Source

isFFIExportResultTy :: Type -> Validity Source

isFFIExternalTy :: Type -> Validity Source

isFFIDynTy :: Type -> Type -> Validity Source

isFFIPrimArgumentTy :: DynFlags -> Type -> Validity Source

isFFIPrimResultTy :: DynFlags -> Type -> Validity Source

isFFILabelTy :: Type -> Validity Source

isFFITy :: Type -> Bool Source

isFunPtrTy :: Type -> Bool Source

tcSplitIOType_maybe :: Type -> Maybe (TyCon, Type) Source

type Kind = Type Source

The key type representing kinds in the compiler. Invariant: a kind is always in one of these forms:

    FunTy k1 k2
    TyConApp PrimTyCon [...]
    TyVar kv   -- (during inference only)
    ForAll ... -- (for top-level coercions)

typeKind :: Type -> Kind Source

unliftedTypeKind :: Kind Source

See Type for details of the distinction between these `Kind`s

liftedTypeKind :: Kind Source

See Type for details of the distinction between these `Kind`s

openTypeKind :: Kind Source

See Type for details of the distinction between these `Kind`s

constraintKind :: Kind Source

See Type for details of the distinction between these `Kind`s

mkArrowKind :: Kind -> Kind -> Kind Source

Given two kinds `k1` and `k2`, creates the `Kind` `k1 -> k2`

mkArrowKinds :: [Kind] -> Kind -> Kind Source

Iterated application of `mkArrowKind`

isLiftedTypeKind :: Kind -> Bool Source

isUnliftedTypeKind :: Kind -> Bool Source

See Type for details of the distinction between these `Kind`s

isSubOpenTypeKind :: Kind -> Bool Source

True of any sub-kind of OpenTypeKind

tcIsSubKind :: Kind -> Kind -> Bool Source

splitKindFunTys :: Kind -> ([Kind], Kind) Source

Essentially `splitFunTys` on kinds

defaultKind :: Kind -> Kind Source

data Type Source

The key representation of types within the compiler

Instances

Data Type |
Outputable Type |

type PredType = Type Source

A type of the form `p` of kind `Constraint` represents a value whose type is the Haskell predicate `p`, where a predicate is what occurs before the `=>` in a Haskell type.

We use `PredType` as documentation to mark those types that we guarantee to have this kind.

It can be expanded into its representation, but:

- The type checker must treat it as opaque
- The rest of the compiler treats it as transparent

Consider these examples:

    f :: (Eq a) => a -> Int
    g :: (?x :: Int -> Int) => a -> Int
    h :: (r\l) => {r} => {l::Int | r}

Here the `Eq a` and `?x :: Int -> Int` and `rl` are all called "predicates"

type ThetaType = [PredType] Source

A collection of `PredType`s

mkForAllTy :: TyVar -> Type -> Type Source

mkForAllTys :: [TyVar] -> Type -> Type Source

Wraps foralls over the type using the provided `TyVar`s from left to right

mkFunTy :: Type -> Type -> Type infixr 3 Source

Creates a function type from the given argument and result type

mkFunTys :: [Type] -> Type -> Type Source

zipFunTys :: Outputable a => [a] -> Type -> ([(a, Type)], Type) Source

Splits off argument types from the given type and associating them with the things in the input list from left to right. The final result type is returned, along with the resulting pairs of objects and types, albeit with the list of pairs in reverse order. Panics if there are not enough argument types for the input list.

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

mkAppTy :: Type -> Type -> Type Source

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

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

applyTy :: Type -> KindOrType -> Type Source

Instantiate a forall type with one or more type arguments. Used when we have a polymorphic function applied to type args:

    f t1 t2

We use `applyTys type-of-f [t1,t2]` to compute the type of the expression. Panics if no application is possible.

applyTys :: Type -> [KindOrType] -> Type Source

This function is interesting because:

1. The function may have more for-alls than there are args
2. Less obviously, it may have fewer for-alls

For case 2. think of:

    applyTys (forall a.a) [forall b.b, Int]

This really can happen, but only (I think) in situations involving undefined. For example: undefined :: forall a. a Term: undefined `(forall b. b->b)` Int This term should have type (Int -> Int), but notice that there are more type args than foralls in `undefined`s type.

mkTyVarTy :: TyVar -> Type Source

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

mkTyConTy :: TyCon -> Type Source

Create the plain type constructor type which has been applied to no type arguments at all.

isClassPred :: PredType -> Bool Source

isEqPred :: PredType -> Bool Source

isIPPred :: PredType -> Bool Source

mkClassPred :: Class -> [Type] -> PredType Source

isDictLikeTy :: Type -> Bool Source

tcSplitDFunTy :: Type -> ([TyVar], [Type], Class, [Type]) Source

tcSplitDFunHead :: Type -> (Class, [Type]) Source

mkEqPred :: Type -> Type -> PredType Source

Creates a type equality predicate

data TvSubst Source

Type substitution

The following invariants must hold of a `TvSubst`:

1. The in-scope set is needed only to guide the generation of fresh uniques
2. In particular, the kind of the type variables in the in-scope set is not relevant
3. The substitution is only applied ONCE! This is because in general such application will not reached a fixed point.

Constructors

TvSubst InScopeSet TvSubstEnv |

type TvSubstEnv = TyVarEnv Type Source

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

emptyTvSubst :: TvSubst Source

mkOpenTvSubst :: TvSubstEnv -> TvSubst Source

Generates the in-scope set for the `TvSubst` from the types in the incoming environment, hence "open"

zipOpenTvSubst :: [TyVar] -> [Type] -> TvSubst Source

Generates the in-scope set for the `TvSubst` from the types in the incoming environment, hence "open"

zipTopTvSubst :: [TyVar] -> [Type] -> TvSubst Source

mkTopTvSubst :: [(TyVar, Type)] -> TvSubst Source

Called when doing top-level substitutions. Here we expect that the free vars of the range of the substitution will be empty.

notElemTvSubst :: CoVar -> TvSubst -> Bool Source

unionTvSubst :: TvSubst -> TvSubst -> TvSubst Source

getTvSubstEnv :: TvSubst -> TvSubstEnv Source

setTvSubstEnv :: TvSubst -> TvSubstEnv -> TvSubst Source

getTvInScope :: TvSubst -> InScopeSet Source

extendTvInScope :: TvSubst -> Var -> TvSubst Source

lookupTyVar :: TvSubst -> TyVar -> Maybe Type Source

extendTvSubst :: TvSubst -> TyVar -> Type -> TvSubst Source

substTyVarBndr :: TvSubst -> TyVar -> (TvSubst, TyVar) Source

extendTvSubstList :: TvSubst -> [TyVar] -> [Type] -> TvSubst Source

isInScope :: Var -> TvSubst -> Bool Source

mkTvSubst :: InScopeSet -> TvSubstEnv -> TvSubst Source

zipTyEnv :: [TyVar] -> [Type] -> TvSubstEnv Source

substTy :: TvSubst -> Type -> Type Source

Substitute within a `Type`

substTys :: TvSubst -> [Type] -> [Type] Source

Substitute within several `Type`s

substTyWith :: [TyVar] -> [Type] -> Type -> Type Source

Type substitution making use of an `TvSubst` that is assumed to be open, see `zipOpenTvSubst`

substTheta :: TvSubst -> ThetaType -> ThetaType Source

Substitute within a `ThetaType`

substTyVar :: TvSubst -> TyVar -> Type Source

substTyVars :: TvSubst -> [TyVar] -> [Type] Source

isUnLiftedType :: Type -> Bool Source

See Type for what an unlifted type is

isUnboxedTupleType :: Type -> Bool Source

isPrimitiveType :: Type -> Bool Source

Returns true of types that are opaque to Haskell.

tyVarsOfType :: Type -> VarSet Source

NB: for type synonyms tyVarsOfType does not expand the synonym tyVarsOfType returns only the free variables of a type For example, tyVarsOfType (a::k) returns {a}, not including the kind variable {k}

tyVarsOfTypes :: [Type] -> TyVarSet Source

closeOverKinds :: TyVarSet -> TyVarSet Source

tcTyVarsOfType :: Type -> TcTyVarSet Source

tcTyVarsOfTypes :: [Type] -> TyVarSet Source

pprKind :: Kind -> SDoc Source

pprParendKind :: Kind -> SDoc Source

pprSigmaType :: Type -> SDoc Source

pprType :: Type -> SDoc Source

pprParendType :: Type -> SDoc Source

pprTypeApp :: TyCon -> [Type] -> SDoc Source

pprTyThingCategory :: TyThing -> SDoc Source

pprTheta :: ThetaType -> SDoc Source

pprThetaArrowTy :: ThetaType -> SDoc Source

pprClassPred :: Class -> [Type] -> SDoc Source