Safe Haskell | None |
---|---|

Language | Haskell2010 |

## Synopsis

- tyCoVarsOfType :: Type -> TyCoVarSet
- tyCoVarsOfTypeDSet :: Type -> DTyCoVarSet
- tyCoVarsOfTypes :: [Type] -> TyCoVarSet
- tyCoVarsOfTypesDSet :: [Type] -> DTyCoVarSet
- exactTyCoVarsOfType :: Type -> TyCoVarSet
- exactTyCoVarsOfTypes :: [Type] -> TyVarSet
- tyCoFVsBndr :: TyCoVarBinder -> FV -> FV
- tyCoFVsVarBndr :: Var -> FV -> FV
- tyCoFVsVarBndrs :: [Var] -> FV -> FV
- tyCoFVsOfType :: Type -> FV
- tyCoVarsOfTypeList :: Type -> [TyCoVar]
- tyCoFVsOfTypes :: [Type] -> FV
- tyCoVarsOfTypesList :: [Type] -> [TyCoVar]
- tyCoVarsOfTypesSet :: TyVarEnv Type -> TyCoVarSet
- tyCoVarsOfCosSet :: CoVarEnv Coercion -> TyCoVarSet
- coVarsOfType :: Type -> CoVarSet
- coVarsOfTypes :: [Type] -> TyCoVarSet
- coVarsOfCo :: Coercion -> CoVarSet
- coVarsOfCos :: [Coercion] -> CoVarSet
- tyCoVarsOfCo :: Coercion -> TyCoVarSet
- tyCoVarsOfCos :: [Coercion] -> TyCoVarSet
- tyCoVarsOfCoDSet :: Coercion -> DTyCoVarSet
- tyCoFVsOfCo :: Coercion -> FV
- tyCoFVsOfCos :: [Coercion] -> FV
- tyCoVarsOfCoList :: Coercion -> [TyCoVar]
- tyCoVarsOfProv :: UnivCoProvenance -> TyCoVarSet
- almostDevoidCoVarOfCo :: CoVar -> Coercion -> Bool
- injectiveVarsOfType :: Bool -> Type -> FV
- injectiveVarsOfTypes :: Bool -> [Type] -> FV
- invisibleVarsOfType :: Type -> FV
- invisibleVarsOfTypes :: [Type] -> FV
- noFreeVarsOfType :: Type -> Bool
- noFreeVarsOfTypes :: [Type] -> Bool
- noFreeVarsOfCo :: Coercion -> Bool
- mkTyCoInScopeSet :: [Type] -> [Coercion] -> InScopeSet
- scopedSort :: [TyCoVar] -> [TyCoVar]
- tyCoVarsOfTypeWellScoped :: Type -> [TyVar]
- tyCoVarsOfTypesWellScoped :: [Type] -> [TyVar]

# Documentation

tyCoVarsOfType :: 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 FV.

tyCoVarsOfTypes :: [Type] -> TyCoVarSet Source #

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.

exactTyCoVarsOfType :: Type -> TyCoVarSet Source #

exactTyCoVarsOfTypes :: [Type] -> TyVarSet Source #

tyCoFVsBndr :: TyCoVarBinder -> FV -> FV Source #

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

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

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

tyCoFVsOfTypes :: [Type] -> FV Source #

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.

tyCoVarsOfTypesSet :: TyVarEnv Type -> TyCoVarSet Source #

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

coVarsOfType :: Type -> CoVarSet Source #

coVarsOfTypes :: [Type] -> TyCoVarSet Source #

coVarsOfCo :: Coercion -> CoVarSet Source #

coVarsOfCos :: [Coercion] -> CoVarSet Source #

tyCoVarsOfCo :: Coercion -> TyCoVarSet Source #

tyCoVarsOfCos :: [Coercion] -> TyCoVarSet Source #

tyCoVarsOfCoDSet :: Coercion -> DTyCoVarSet Source #

Get a deterministic set of the vars free in a coercion

tyCoFVsOfCo :: Coercion -> FV Source #

tyCoFVsOfCos :: [Coercion] -> FV Source #

tyCoVarsOfCoList :: Coercion -> [TyCoVar] Source #

almostDevoidCoVarOfCo :: CoVar -> Coercion -> Bool Source #

Given a covar and a coercion, returns True if covar is almost devoid in the coercion. That is, covar can only appear in Refl and GRefl. See last wrinkle in Note [Unused coercion variable in ForAllCo] in Coercion

:: Bool | Should we look under injective type families? See Note [Coverage condition for injective type families] in FamInst. |

-> Type | |

-> FV |

Returns the free variables of a `Type`

that are in injective positions.
Specifically, it finds the free variables while:

- Expanding type synonyms
- Ignoring the coercion in
`(ty |> co)`

- Ignoring the non-injective fields of a
`TyConApp`

For example, if `F`

is a non-injective type family, then:

injectiveTyVarsOf( Either c (Maybe (a, F b c)) ) = {a,c}

If

, then knowing `injectiveVarsOfType`

ty = itvs`ty`

fixes `itvs`

.
More formally, if
`a`

is in

and `injectiveVarsOfType`

ty`S1(ty) ~ S2(ty)`

,
then `S1(a) ~ S2(a)`

,
where `S1`

and `S2`

are arbitrary substitutions.

See `Note [When does a tycon application need an explicit kind signature?]`

.

invisibleVarsOfType :: Type -> FV Source #

Returns the set of variables that are used invisibly anywhere within the given type. A variable will be included even if it is used both visibly and invisibly. An invisible use site includes: * In the kind of a variable * In the kind of a bound variable in a forall * In a coercion * In a Specified or Inferred argument to a function See Note [VarBndrs, TyCoVarBinders, TyConBinders, and visibility] in TyCoRep

invisibleVarsOfTypes :: [Type] -> FV Source #

Like `invisibleVarsOfType`

, but for many types.

noFreeVarsOfType :: Type -> Bool Source #

Returns True if this type has no free variables. Should be the same as isEmptyVarSet . tyCoVarsOfType, but faster in the non-forall case.

noFreeVarsOfTypes :: [Type] -> Bool Source #

noFreeVarsOfCo :: Coercion -> Bool Source #

Returns True if this coercion has no free variables. Should be the same as isEmptyVarSet . tyCoVarsOfCo, but faster in the non-forall case.

mkTyCoInScopeSet :: [Type] -> [Coercion] -> InScopeSet Source #

Generates an in-scope set from the free variables in a list of types and a list of coercions

# Welll-scoped free 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 RnTypes

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