ghc-9.4.3: The GHC API
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Tc.Utils.TcType

Description

Types used in the typechecker

This module provides the Type interface for front-end parts of the compiler. These parts

  • treat "source types" as opaque: newtypes, and predicates are meaningful.
  • look through usage types
Synopsis

Documentation

type TcTypeFRR = TcType Source #

A type which has a syntactically fixed RuntimeRep as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete.

type TcSigmaTypeFRR = TcSigmaType Source #

A TcSigmaTypeFRR is a TcSigmaType which has a syntactically fixed RuntimeRep in the sense of Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete.

In particular, this means that:

This property is important in functions such as matchExpectedFunTys, where we want to provide argument types which have a known runtime representation. See Note [Return arguments with a fixed RuntimeRep.

type TcTyVar = Var Source #

Type variable that might be a metavariable

type KnotTied ty = 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

data ExpType Source #

An expected type to check against during type-checking. See Note [ExpType] in GHC.Tc.Utils.TcMType, where you'll also find manipulators.

Constructors

Check TcType 
Infer !InferResult 

Instances

Instances details
Outputable ExpType Source # 
Instance details

Defined in GHC.Tc.Utils.TcType

Methods

ppr :: ExpType -> SDoc Source #

data InferResult Source #

Constructors

IR 

Fields

  • ir_uniq :: Unique

    This Unique is for debugging only

  • ir_lvl :: TcLevel

    See Note [TcLevel of ExpType] in GHC.Tc.Utils.TcMType

  • ir_frr :: Maybe FixedRuntimeRepContext

    See Note [FixedRuntimeRep context in ExpType] in GHC.Tc.Utils.TcMType

  • ir_ref :: IORef (Maybe TcType)

    The type that fills in this hole should be a Type, that is, its kind should be TYPE rr for some rr :: RuntimeRep.

    Additionally, if the ir_frr field is Just frr_orig then rr must be concrete, in the sense of Note [Concrete types] in GHC.Tc.Utils.Concrete.

Instances

Instances details
Outputable InferResult Source # 
Instance details

Defined in GHC.Tc.Utils.TcType

Methods

ppr :: InferResult -> SDoc Source #

type ExpTypeFRR = ExpType Source #

An ExpType which has a fixed RuntimeRep.

For a Check ExpType, the stored TcType must have a fixed RuntimeRep. For an Infer ExpType, the ir_frr field must be of the form Just frr_orig.

type ExpSigmaTypeFRR = ExpTypeFRR Source #

Like TcSigmaTypeFRR, but for an expected type.

See ExpTypeFRR.

mkCheckExpType :: TcType -> ExpType Source #

Make an ExpType suitable for checking.

data SyntaxOpType Source #

What to expect for an argument to a rebindable-syntax operator. Quite like Type, but allows for holes to be filled in by tcSyntaxOp. The callback called from tcSyntaxOp gets a list of types; the meaning of these types is determined by a left-to-right depth-first traversal of the SyntaxOpType tree. So if you pass in

SynAny `SynFun` (SynList `SynFun` SynType Int) `SynFun` SynAny

you'll get three types back: one for the first SynAny, the element type of the list, and one for the last SynAny. You don't get anything for the SynType, because you've said positively that it should be an Int, and so it shall be.

You'll also get three multiplicities back: one for each function arrow. See also Note [Linear types] in Multiplicity.

This is defined here to avoid defining it in GHC.Tc.Gen.Expr boot file.

Constructors

SynAny

Any type

SynRho

A rho type, skolemised or instantiated as appropriate

SynList

A list type. You get back the element type of the list

SynFun SyntaxOpType SyntaxOpType infixr 0

A function.

SynType ExpType

A known type.

synKnownType :: TcType -> SyntaxOpType Source #

Like SynType but accepts a regular TcType

newtype TcLevel Source #

Constructors

TcLevel Int 

Instances

Instances details
Outputable TcLevel Source # 
Instance details

Defined in GHC.Tc.Utils.TcType

Methods

ppr :: TcLevel -> SDoc Source #

Eq TcLevel Source # 
Instance details

Defined in GHC.Tc.Utils.TcType

Methods

(==) :: TcLevel -> TcLevel -> Bool #

(/=) :: TcLevel -> TcLevel -> Bool #

Ord TcLevel Source # 
Instance details

Defined in GHC.Tc.Utils.TcType

data MetaDetails Source #

Constructors

Flexi 
Indirect TcType 

Instances

Instances details
Outputable MetaDetails Source # 
Instance details

Defined in GHC.Tc.Utils.TcType

Methods

ppr :: MetaDetails -> SDoc Source #

data MetaInfo Source #

What restrictions are on this metavariable around unification? These are checked in GHC.Tc.Utils.Unify.startSolvingByUnification.

Constructors

TauTv

This MetaTv is an ordinary unification variable A TauTv is always filled in with a tau-type, which never contains any ForAlls.

TyVarTv

A variant of TauTv, except that it should not be unified with a type, only with a type variable See Note [TyVarTv] in GHC.Tc.Utils.TcMType

RuntimeUnkTv

A unification variable used in the GHCi debugger. It is allowed to unify with a polytype, unlike TauTv

CycleBreakerTv 
ConcreteTv ConcreteTvOrigin

A unification variable that can only be unified with a concrete type, in the sense of Note [Concrete types] in GHC.Tc.Utils.Concrete. See Note [ConcreteTv] in GHC.Tc.Utils.Concrete. See also Note [The Concrete mechanism] in GHC.Tc.Utils.Concrete for an overview of how this works in context.

Instances

Instances details
Outputable MetaInfo Source # 
Instance details

Defined in GHC.Tc.Utils.TcType

Methods

ppr :: MetaInfo -> SDoc Source #

data ConcreteTvOrigin Source #

What caused us to create a ConcreteTv metavariable? See Note [ConcreteTv] in GHC.Tc.Utils.Concrete.

Constructors

ConcreteFRR FixedRuntimeRepOrigin

A ConcreteTv used to enforce the representation-polymorphism invariants.

See FixedRuntimeRepOrigin for more information.

isConcreteTyVar_maybe :: TcTyVar -> Maybe ConcreteTvOrigin Source #

Is this type variable a concrete type variable, i.e. it is a metavariable with ConcreteTv MetaInfo?

Returns the ConcreteTvOrigin stored in the type variable if so, or Nothing otherwise.

isConcreteTyVar :: TcTyVar -> Bool Source #

Is this type variable a concrete type variable, i.e. it is a metavariable with ConcreteTv MetaInfo?

isConcreteTyVarTy :: TcType -> Bool Source #

Is this type concrete type variable, i.e. a metavariable with ConcreteTv MetaInfo?

isConcreteTyVarTy_maybe :: TcType -> Maybe (TcTyVar, ConcreteTvOrigin) Source #

Is this type a concrete type variable? If so, return the associated TcTyVar and ConcreteTvOrigin.

mkInfSigmaTy :: [TyCoVar] -> [PredType] -> Type -> Type Source #

Make a sigma ty where all type variables are Inferred. That is, they cannot be used with visible type application.

mkSpecSigmaTy :: [TyVar] -> [PredType] -> Type -> Type Source #

Make a sigma ty where all type variables are "specified". That is, they can be used with visible type application

getTyVar :: String -> Type -> TyVar Source #

Attempts to obtain the type variable underlying a Type, and panics with the given message if this is not a type variable type. See also getTyVar_maybe

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

Like tcSplitPiTys, but splits off only named binders, returning just the tyvars.

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

Like tcSplitForAllTyVars, but only splits ForAllTys with Invisible type variable binders.

tcSplitSomeForAllTyVars :: (ArgFlag -> Bool) -> Type -> ([TyVar], Type) Source #

Like tcSplitForAllTyVars, but only splits a ForAllTy if argf_pred argf is True, where argf is the visibility of the ForAllTy's binder and argf_pred is a predicate over visibilities provided as an argument to this function.

tcSplitForAllReqTVBinders :: Type -> ([TcReqTVBinder], Type) Source #

Like tcSplitForAllTyVars, but only splits ForAllTys with Required type variable binders. All split tyvars are annotated with ().

tcSplitForAllInvisTVBinders :: Type -> ([TcInvisTVBinder], Type) Source #

Like tcSplitForAllTyVars, but only splits ForAllTys with Invisible type variable binders. All split tyvars are annotated with their Specificity.

tcSplitPiTys :: Type -> ([TyBinder], Type) Source #

Splits a forall type into a list of TyBinders and the inner type. Always succeeds, even if it returns an empty list.

tcSplitPiTy_maybe :: Type -> Maybe (TyBinder, Type) Source #

Splits a type into a TyBinder and a body, if possible. Panics otherwise

tcSplitForAllTyVarBinders :: Type -> ([TyVarBinder], Type) Source #

Like tcSplitForAllTyVars, but splits off only named binders.

tcFunResultTyN :: HasDebugCallStack => Arity -> Type -> Type Source #

Strips off n *visible* arguments and returns the resulting type

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

Split off exactly the specified number argument types Returns (Left m) if there are m missing arrows in the type (Right (tys,res)) if the type looks like t1 -> ... -> tn -> res

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

Split a type constructor application into its type constructor and applied types. Note that this may fail in the case of a FunTy with an argument of unknown kind FunTy (e.g. FunTy (a :: k) Int. since the kind of a isn't of the form TYPE rep). Consequently, you may need to zonk your type before using this function.

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

If you only need the TyCon, consider using tcTyConAppTyCon_maybe.

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

Does the AppTy split as in tcSplitAppTy_maybe, but assumes that any coreView stuff is already done. Refuses to look through (c => t)

tcRepGetNumAppTys :: Type -> Arity Source #

Returns the number of arguments in the given type, without looking through synonyms. This is used only for error reporting. We don't look through synonyms because of #11313.

tcGetCastedTyVar_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 type

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

Split a sigma type into its parts. This only splits invisible type variable binders, as these are the only forms of binder that the typechecker will implicitly instantiate.

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

Split a sigma type into its parts, going underneath as many arrows and foralls as possible. See Note [tcSplitNestedSigmaTys]

eqType :: Type -> Type -> Bool Source #

Type equality on source types. Does not look through newtypes, PredTypes or type families, but it does look through type synonyms. This first checks that the kinds of the types are equal and then checks whether the types are equal, ignoring casts and coercions. (The kind check is a recursive call, but since all kinds have type Type, there is no need to check the types of kinds.) See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep.

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

Type equality on lists of types, looking through type synonyms but not newtypes.

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

Compare types with respect to a (presumably) non-empty RnEnv2.

pickyEqType :: TcType -> TcType -> Bool Source #

Like pickyEqTypeVis, but returns a Bool for convenience

tcEqType :: HasDebugCallStack => TcType -> TcType -> Bool Source #

tcEqType implements typechecker equality, as described in Note [Typechecker equality vs definitional equality].

tcEqTypeNoKindCheck :: TcType -> TcType -> Bool Source #

Just like tcEqType, but will return True for types of different kinds as long as their non-coercion structure is identical.

tcEqTypeVis :: TcType -> TcType -> Bool Source #

Like tcEqType, but returns True if the visible part of the types are equal, even if they are really unequal (in the invisible bits)

tcEqTyConApps :: TyCon -> [Type] -> TyCon -> [Type] -> Bool Source #

Check whether two TyConApps are the same; if the number of arguments are different, just checks the common prefix of arguments.

isRhoExpTy :: ExpType -> Bool Source #

Like isRhoTy, but also says True for Infer types

isFloatingPrimTy :: Type -> Bool Source #

Is the type inhabited by machine floating-point numbers?

Used to check that we don't use floating-point literal patterns in Core.

See #9238 and Note [Rules for floating-point comparisons] in GHC.Core.Opt.ConstantFold.

isStringTy :: Type -> Bool Source #

Is a type String?

tcIsForAllTy :: Type -> Bool Source #

Is this a ForAllTy with a named binder?

ambigTkvsOfTy :: TcType -> ([Var], [Var]) Source #

Returns the (kind, type) variables in a type that are as-yet-unknown: metavariables and RuntimeUnks

mkMinimalBySCs :: forall a. (a -> PredType) -> [a] -> [a] Source #

Finding type instances

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

Finds outermost type-family applications occurring in a type, after expanding synonyms. In the list (F, tys) that is returned we guarantee that tys matches F's arity. For example, given type family F a :: * -> * (arity 1) calling tcTyFamInsts on (Maybe (F Int Bool) will return (F, [Int]), not (F, [Int,Bool])

This is important for its use in deciding termination of type instances (see #11581). E.g. type instance G [Int] = ...(F Int <big type>)... we don't need to take <big type> into account when asking if the calls on the RHS are smaller than the LHS

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

Like tcTyFamInsts, except that the output records whether the type family and its arguments occur as an invisible argument in some type application. This information is useful because it helps GHC know when to turn on -fprint-explicit-kinds during error reporting so that users can actually see the type family being mentioned.

As an example, consider:

class C a
data T (a :: k)
type family F a :: k
instance C (T @(F Int) (F Bool))

There are two occurrences of the type family F in that C instance, so tcTyFamInstsAndVis (C (T @(F Int) (F Bool))) will return:

[ (True,  F, [Int])
, (False, F, [Bool]) ]

F Int is paired with True since it appears as an invisible argument to C, whereas F Bool is paired with False since it appears an a visible argument to C.

See also Note [Kind arguments in error messages] in GHC.Tc.Errors.

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

In an application of a TyCon to some arguments, find the outermost occurrences of type family applications within the arguments. This function will not consider the TyCon itself when checking for type family applications.

See tcTyFamInstsAndVis for more details on how this works (as this function is called inside of tcTyFamInstsAndVis).

isTyFamFree :: Type -> Bool Source #

Check that a type does not contain any type family applications.

Finding "exact" (non-dead) type variables

type Kind = Type Source #

The key type representing kinds in the compiler.

isLiftedTypeKind :: Kind -> Bool Source #

This version considers Constraint to be the same as *. Returns True if the argument is equivalent to Type/Constraint and False otherwise. See Note [Kind Constraint and kind Type]

isUnliftedTypeKind :: Kind -> Bool Source #

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

classifiesTypeWithValues :: 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 any sub-kind of OpenTypeKind

data Type Source #

Instances

Instances details
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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Type Source #

toConstr :: Type -> Constr Source #

dataTypeOf :: Type -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Type) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Type) Source #

gmapT :: (forall b. Data b => b -> b) -> Type -> Type Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Type -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Type -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Type -> m Type Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type Source #

Outputable Type Source # 
Instance details

Defined in GHC.Core.TyCo.Rep

Methods

ppr :: Type -> SDoc Source #

Eq (DeBruijn Type) Source # 
Instance details

Defined in GHC.Core.Map.Type

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 PredTypes

data TyCoBinder Source #

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

Instances

Instances details
Data TyCoBinder 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) -> TyCoBinder -> c TyCoBinder Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TyCoBinder Source #

toConstr :: TyCoBinder -> Constr Source #

dataTypeOf :: TyCoBinder -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TyCoBinder) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TyCoBinder) Source #

gmapT :: (forall b. Data b => b -> b) -> TyCoBinder -> TyCoBinder Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TyCoBinder -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TyCoBinder -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TyCoBinder -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TyCoBinder -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TyCoBinder -> m TyCoBinder Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TyCoBinder -> m TyCoBinder Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TyCoBinder -> m TyCoBinder Source #

Outputable TyCoBinder Source # 
Instance details

Defined in GHC.Core.TyCo.Rep

Methods

ppr :: TyCoBinder -> SDoc Source #

data ArgFlag Source #

Argument Flag

Is something required to appear in source Haskell (Required), permitted by request (Specified) (visible type application), or prohibited entirely from appearing in source Haskell (Inferred)? See Note [VarBndrs, TyCoVarBinders, TyConBinders, and visibility] in GHC.Core.TyCo.Rep

Bundled Patterns

pattern Specified :: ArgFlag 
pattern Inferred :: ArgFlag 

Instances

Instances details
Data ArgFlag 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) -> ArgFlag -> c ArgFlag Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ArgFlag Source #

toConstr :: ArgFlag -> Constr Source #

dataTypeOf :: ArgFlag -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ArgFlag) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ArgFlag) Source #

gmapT :: (forall b. Data b => b -> b) -> ArgFlag -> ArgFlag Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ArgFlag -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ArgFlag -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> ArgFlag -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ArgFlag -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ArgFlag -> m ArgFlag Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ArgFlag -> m ArgFlag Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ArgFlag -> m ArgFlag Source #

Binary ArgFlag Source # 
Instance details

Defined in GHC.Types.Var

Outputable ArgFlag Source # 
Instance details

Defined in GHC.Types.Var

Methods

ppr :: ArgFlag -> SDoc Source #

Eq ArgFlag Source # 
Instance details

Defined in GHC.Types.Var

Methods

(==) :: ArgFlag -> ArgFlag -> Bool #

(/=) :: ArgFlag -> ArgFlag -> Bool #

Ord ArgFlag Source # 
Instance details

Defined in GHC.Types.Var

Outputable tv => Outputable (VarBndr tv ArgFlag) Source # 
Instance details

Defined in GHC.Types.Var

Methods

ppr :: VarBndr tv ArgFlag -> SDoc Source #

data AnonArgFlag Source #

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

Constructors

VisArg

Used for (->): an ordinary non-dependent arrow. The argument is visible in source code.

InvisArg

Used for (=>): a non-dependent predicate arrow. The argument is invisible in source code.

Instances

Instances details
Data AnonArgFlag 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) -> AnonArgFlag -> c AnonArgFlag Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AnonArgFlag Source #

toConstr :: AnonArgFlag -> Constr Source #

dataTypeOf :: AnonArgFlag -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AnonArgFlag) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AnonArgFlag) Source #

gmapT :: (forall b. Data b => b -> b) -> AnonArgFlag -> AnonArgFlag Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AnonArgFlag -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AnonArgFlag -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> AnonArgFlag -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AnonArgFlag -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AnonArgFlag -> m AnonArgFlag Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AnonArgFlag -> m AnonArgFlag Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AnonArgFlag -> m AnonArgFlag Source #

Binary AnonArgFlag Source # 
Instance details

Defined in GHC.Types.Var

Outputable AnonArgFlag Source # 
Instance details

Defined in GHC.Types.Var

Methods

ppr :: AnonArgFlag -> SDoc Source #

Eq AnonArgFlag Source # 
Instance details

Defined in GHC.Types.Var

Ord AnonArgFlag Source # 
Instance details

Defined in GHC.Types.Var

mkForAllTy :: TyCoVar -> ArgFlag -> Type -> Type Source #

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

mkForAllTys :: [TyCoVarBinder] -> Type -> Type Source #

Wraps foralls over the type using the provided TyCoVars from left to right

mkInvisForAllTys :: [InvisTVBinder] -> Type -> Type Source #

Wraps foralls over the type using the provided InvisTVBinders from left to right

mkTyCoInvForAllTys :: [TyCoVar] -> Type -> Type Source #

Like mkForAllTys, but assumes all variables are dependent and Inferred, a common case

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

Like mkForAllTys, but assumes all variables are dependent and Specified, a common case

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

mkVisFunTy :: Mult -> Type -> Type -> Type infixr 3 Source #

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

Make nested arrow types

mkInvisFunTy :: Mult -> Type -> Type -> Type infixr 3 Source #

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

Special, common, case: Arrow type with mult Many

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

mkTyConTy :: TyCon -> Type Source #

(mkTyConTy tc) returns (TyConApp tc []) but arranges to share that TyConApp among all calls See Note [Sharing nullary TyConApps] in GHC.Core.TyCon

isRuntimeRepVar :: TyVar -> Bool Source #

Is a tyvar of type RuntimeRep?

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

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

Precondition: The type has kind (TYPE blah).

isVisibleBinder :: TyCoBinder -> Bool Source #

Does this binder bind a visible argument?

isInvisibleBinder :: TyCoBinder -> Bool Source #

Does this binder bind an invisible argument?

data TCvSubst Source #

Type & coercion substitution

The following invariants must hold of a TCvSubst:

  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 reach a fixed point.

Instances

Instances details
Outputable TCvSubst Source # 
Instance details

Defined in GHC.Core.TyCo.Subst

Methods

ppr :: TCvSubst -> SDoc Source #

type TvSubstEnv = TyVarEnv Type Source #

A substitution of Types for TyVars and Kinds for KindVars

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

Generates the in-scope set for the TCvSubst from the types in the incoming environment. No CoVars, please!

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

Generates the in-scope set for the TCvSubst from the types in the incoming environment. No CoVars, please!

mkTvSubst :: InScopeSet -> TvSubstEnv -> TCvSubst Source #

Make a TCvSubst with specified tyvar subst and empty covar subst

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

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

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

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

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

Type substitution, see zipTvSubst

substTyWithCoVars :: [CoVar] -> [Coercion] -> Type -> Type Source #

Substitute covars within a type

substTyAddInScope :: TCvSubst -> 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 :: TCvSubst -> Type -> Type Source #

Substitute within a Type disabling the sanity checks. The problems that the sanity checks in substTy catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substTyUnchecked to substTy and remove this function. Please don't use in new code.

substTysUnchecked :: TCvSubst -> [Type] -> [Type] Source #

Substitute within several Types 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.

substThetaUnchecked :: TCvSubst -> ThetaType -> ThetaType Source #

Substitute within a ThetaType disabling the sanity checks. The problems that the sanity checks in substTys catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substThetaUnchecked to substTheta and remove this function. Please don't use in new code.

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

Type substitution, see zipTvSubst. Disables sanity checks. The problems that the sanity checks in substTy catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substTyUnchecked to substTy and remove this function. Please don't use in new code.

substCoUnchecked :: TCvSubst -> Coercion -> Coercion Source #

Substitute within a Coercion disabling sanity checks. The problems that the sanity checks in substCo catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substCoUnchecked to substCo and remove this function. Please don't use in new code.

substCoWithUnchecked :: [TyVar] -> [Type] -> Coercion -> Coercion Source #

Coercion substitution, see zipTvSubst. Disables sanity checks. The problems that the sanity checks in substCo catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substCoUnchecked to substCo and remove this function. Please don't use in new code.

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

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

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.

isPrimitiveType :: Type -> Bool Source #

Returns true of types that are opaque to Haskell.

tcView :: Type -> Maybe Type Source #

Gives the typechecker view of a type. This unwraps synonyms but leaves Constraint alone. c.f. coreView, which turns Constraint into Type. Returns Nothing if no unwrapping happens. See also Note [coreView vs tcView]

coreView :: Type -> Maybe Type Source #

This function strips off the top layer only of a type synonym application (if any) its underlying representation type. Returns Nothing if there is nothing to look through. This function considers Constraint to be a synonym of Type.

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

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.

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.

tyCoVarsOfTypesDSet :: [Type] -> DTyCoVarSet Source #

Returns free variables of types, including kind variables as a deterministic set. For type synonyms it does not expand the synonym.

closeOverKindsDSet :: DTyVarSet -> DTyVarSet Source #

Add the kind variables free in the kinds of the tyvars in the given set. Returns a deterministic set.

tyCoVarsOfTypeList :: Type -> [TyCoVar] Source #

tyCoFVsOfType that returns free variables of a type in deterministic order. For explanation of why using VarSet is not deterministic see Note [Deterministic FV] in GHC.Utils.FV.

tyCoVarsOfTypesList :: [Type] -> [TyCoVar] Source #

Returns free variables of types, including kind variables as a deterministically ordered list. For type synonyms it does not expand the synonym.

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

tcTyConVisibilities :: TyCon -> [Bool] Source #

For every arg a tycon can take, the returned list says True if the argument is taken visibly, and False otherwise. Ends with an infinite tail of Trues to allow for oversaturation.

isNextTyConArgVisible :: TyCon -> [Type] -> Bool Source #

If the tycon is applied to the types, is the next argument visible?

isNextArgVisible :: TcType -> Bool Source #

Should this type be applied to a visible argument?