TyCoRep

ghc-8.8.2: The GHC API

Safe Haskell | None
Language | Haskell2010

TyCoRep

Contents

- Types
- Coercions
- Functions over types
- Functions over binders
- Functions over coercions
- Pretty-printing
- Free variables
- Substitutions
- Tidying type related things up for printing
- Sizes

Synopsis

- data TyThing
  - = AnId Id
  - | AConLike ConLike
  - | ATyCon TyCon
  - | ACoAxiom (CoAxiom Branched)
- tyThingCategory :: TyThing -> String
- pprTyThingCategory :: TyThing -> SDoc
- pprShortTyThing :: TyThing -> SDoc
- data Type
  - = TyVarTy Var
  - | AppTy Type Type
  - | TyConApp TyCon [KindOrType]
  - | ForAllTy !TyCoVarBinder Type
  - | FunTy Type Type
  - | LitTy TyLit
  - | CastTy Type KindCoercion
  - | CoercionTy Coercion
- data TyLit
  - = NumTyLit Integer
  - | StrTyLit FastString
- type KindOrType = Type
- type Kind = Type
- type KnotTied ty = ty
- type PredType = Type
- type ThetaType = [PredType]
- data ArgFlag
  - = Inferred
  - | Specified
  - | Required
- data Coercion
  - = Refl Type
  - | GRefl Role Type MCoercionN
  - | TyConAppCo Role TyCon [Coercion]
  - | AppCo Coercion CoercionN
  - | ForAllCo TyCoVar KindCoercion Coercion
  - | FunCo Role Coercion Coercion
  - | CoVarCo CoVar
  - | AxiomInstCo (CoAxiom Branched) BranchIndex [Coercion]
  - | AxiomRuleCo CoAxiomRule [Coercion]
  - | UnivCo UnivCoProvenance Role Type Type
  - | SymCo Coercion
  - | TransCo Coercion Coercion
  - | NthCo Role Int Coercion
  - | LRCo LeftOrRight CoercionN
  - | InstCo Coercion CoercionN
  - | KindCo Coercion
  - | SubCo CoercionN
  - | HoleCo CoercionHole
- data UnivCoProvenance
  - = UnsafeCoerceProv
  - | PhantomProv KindCoercion
  - | ProofIrrelProv KindCoercion
  - | PluginProv String
- data CoercionHole = CoercionHole {
  - ch_co_var :: CoVar
  - ch_ref :: IORef (Maybe Coercion)
  }
- coHoleCoVar :: CoercionHole -> CoVar
- setCoHoleCoVar :: CoercionHole -> CoVar -> CoercionHole
- type CoercionN = Coercion
- type CoercionR = Coercion
- type CoercionP = Coercion
- type KindCoercion = CoercionN
- data MCoercion
  - = MRefl
  - | MCo Coercion
- type MCoercionR = MCoercion
- type MCoercionN = MCoercion
- mkTyConTy :: TyCon -> Type
- mkTyVarTy :: TyVar -> Type
- mkTyVarTys :: [TyVar] -> [Type]
- mkTyCoVarTy :: TyCoVar -> Type
- mkTyCoVarTys :: [TyCoVar] -> [Type]
- mkFunTy :: Type -> Type -> Type
- mkFunTys :: [Type] -> Type -> Type
- mkTyCoForAllTy :: TyCoVar -> ArgFlag -> Type -> Type
- mkForAllTys :: [TyCoVarBinder] -> Type -> Type
- mkForAllTy :: TyCoVar -> ArgFlag -> Type -> Type
- mkTyCoPiTy :: TyCoBinder -> Type -> Type
- mkTyCoPiTys :: [TyCoBinder] -> Type -> Type
- mkPiTys :: [TyCoBinder] -> Type -> Type
- kindRep_maybe :: HasDebugCallStack => Kind -> Maybe Type
- kindRep :: HasDebugCallStack => Kind -> Type
- isLiftedTypeKind :: Kind -> Bool
- isUnliftedTypeKind :: Kind -> Bool
- isLiftedRuntimeRep :: Type -> Bool
- isUnliftedRuntimeRep :: Type -> Bool
- isRuntimeRepTy :: Type -> Bool
- isRuntimeRepVar :: TyVar -> Bool
- sameVis :: ArgFlag -> ArgFlag -> Bool
- data TyCoBinder
  - = Named TyCoVarBinder
  - | Anon Type
- type TyCoVarBinder = VarBndr TyCoVar ArgFlag
- type TyBinder = TyCoBinder
- binderVar :: VarBndr tv argf -> tv
- binderVars :: [VarBndr tv argf] -> [tv]
- binderType :: VarBndr TyCoVar argf -> Type
- binderArgFlag :: VarBndr tv argf -> argf
- delBinderVar :: VarSet -> TyCoVarBinder -> VarSet
- isInvisibleArgFlag :: ArgFlag -> Bool
- isVisibleArgFlag :: ArgFlag -> Bool
- isInvisibleBinder :: TyCoBinder -> Bool
- isVisibleBinder :: TyCoBinder -> Bool
- isTyBinder :: TyCoBinder -> Bool
- isNamedBinder :: TyCoBinder -> Bool
- tyCoBinderArgFlag :: TyCoBinder -> ArgFlag
- pickLR :: LeftOrRight -> (a, a) -> a
- pprType :: Type -> SDoc
- pprParendType :: Type -> SDoc
- pprPrecType :: PprPrec -> Type -> SDoc
- pprPrecTypeX :: TidyEnv -> PprPrec -> Type -> SDoc
- pprTypeApp :: TyCon -> [Type] -> SDoc
- pprTCvBndr :: TyCoVarBinder -> SDoc
- pprTCvBndrs :: [TyCoVarBinder] -> SDoc
- pprSigmaType :: Type -> SDoc
- pprTheta :: ThetaType -> SDoc
- pprParendTheta :: ThetaType -> SDoc
- pprForAll :: [TyCoVarBinder] -> SDoc
- pprUserForAll :: [TyCoVarBinder] -> SDoc
- pprTyVar :: TyVar -> SDoc
- pprTyVars :: [TyVar] -> SDoc
- pprThetaArrowTy :: ThetaType -> SDoc
- pprClassPred :: Class -> [Type] -> SDoc
- pprKind :: Kind -> SDoc
- pprParendKind :: Kind -> SDoc
- pprTyLit :: TyLit -> SDoc
- newtype PprPrec = PprPrec Int
- topPrec :: PprPrec
- sigPrec :: PprPrec
- opPrec :: PprPrec
- funPrec :: PprPrec
- appPrec :: PprPrec
- maybeParen :: PprPrec -> PprPrec -> SDoc -> SDoc
- pprDataCons :: TyCon -> SDoc
- pprWithExplicitKindsWhen :: Bool -> SDoc -> SDoc
- pprCo :: Coercion -> SDoc
- pprParendCo :: Coercion -> SDoc
- debugPprType :: Type -> SDoc
- tyCoVarsOfType :: Type -> TyCoVarSet
- tyCoVarsOfTypeDSet :: Type -> DTyCoVarSet
- tyCoVarsOfTypes :: [Type] -> TyCoVarSet
- tyCoVarsOfTypesDSet :: [Type] -> DTyCoVarSet
- tyCoFVsBndr :: TyCoVarBinder -> FV -> FV
- tyCoFVsVarBndr :: Var -> FV -> FV
- tyCoFVsVarBndrs :: [Var] -> FV -> FV
- tyCoFVsOfType :: Type -> FV
- tyCoVarsOfTypeList :: Type -> [TyCoVar]
- tyCoFVsOfTypes :: [Type] -> FV
- tyCoVarsOfTypesList :: [Type] -> [TyCoVar]
- 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 :: Type -> FV
- tyConAppNeedsKindSig :: Bool -> TyCon -> Int -> Bool
- noFreeVarsOfType :: Type -> Bool
- noFreeVarsOfCo :: Coercion -> Bool
- data TCvSubst = TCvSubst InScopeSet TvSubstEnv CvSubstEnv
- type TvSubstEnv = TyVarEnv Type
- type CvSubstEnv = CoVarEnv Coercion
- emptyTvSubstEnv :: TvSubstEnv
- emptyCvSubstEnv :: CvSubstEnv
- composeTCvSubstEnv :: InScopeSet -> (TvSubstEnv, CvSubstEnv) -> (TvSubstEnv, CvSubstEnv) -> (TvSubstEnv, CvSubstEnv)
- composeTCvSubst :: TCvSubst -> TCvSubst -> TCvSubst
- emptyTCvSubst :: TCvSubst
- mkEmptyTCvSubst :: InScopeSet -> TCvSubst
- isEmptyTCvSubst :: TCvSubst -> Bool
- mkTCvSubst :: InScopeSet -> (TvSubstEnv, CvSubstEnv) -> TCvSubst
- mkTvSubst :: InScopeSet -> TvSubstEnv -> TCvSubst
- mkCvSubst :: InScopeSet -> CvSubstEnv -> TCvSubst
- getTvSubstEnv :: TCvSubst -> TvSubstEnv
- getCvSubstEnv :: TCvSubst -> CvSubstEnv
- getTCvInScope :: TCvSubst -> InScopeSet
- getTCvSubstRangeFVs :: TCvSubst -> VarSet
- isInScope :: Var -> TCvSubst -> Bool
- notElemTCvSubst :: Var -> TCvSubst -> Bool
- setTvSubstEnv :: TCvSubst -> TvSubstEnv -> TCvSubst
- setCvSubstEnv :: TCvSubst -> CvSubstEnv -> TCvSubst
- zapTCvSubst :: TCvSubst -> TCvSubst
- extendTCvInScope :: TCvSubst -> Var -> TCvSubst
- extendTCvInScopeList :: TCvSubst -> [Var] -> TCvSubst
- extendTCvInScopeSet :: TCvSubst -> VarSet -> TCvSubst
- extendTCvSubst :: TCvSubst -> TyCoVar -> Type -> TCvSubst
- extendTCvSubstWithClone :: TCvSubst -> TyCoVar -> TyCoVar -> TCvSubst
- extendCvSubst :: TCvSubst -> CoVar -> Coercion -> TCvSubst
- extendCvSubstWithClone :: TCvSubst -> CoVar -> CoVar -> TCvSubst
- extendTvSubst :: TCvSubst -> TyVar -> Type -> TCvSubst
- extendTvSubstBinderAndInScope :: TCvSubst -> TyCoBinder -> Type -> TCvSubst
- extendTvSubstWithClone :: TCvSubst -> TyVar -> TyVar -> TCvSubst
- extendTvSubstList :: TCvSubst -> [Var] -> [Type] -> TCvSubst
- extendTvSubstAndInScope :: TCvSubst -> TyVar -> Type -> TCvSubst
- extendTCvSubstList :: TCvSubst -> [Var] -> [Type] -> TCvSubst
- unionTCvSubst :: TCvSubst -> TCvSubst -> TCvSubst
- zipTyEnv :: HasDebugCallStack => [TyVar] -> [Type] -> TvSubstEnv
- zipCoEnv :: HasDebugCallStack => [CoVar] -> [Coercion] -> CvSubstEnv
- mkTyCoInScopeSet :: [Type] -> [Coercion] -> InScopeSet
- zipTvSubst :: HasDebugCallStack => [TyVar] -> [Type] -> TCvSubst
- zipCvSubst :: HasDebugCallStack => [CoVar] -> [Coercion] -> TCvSubst
- zipTCvSubst :: HasDebugCallStack => [TyCoVar] -> [Type] -> TCvSubst
- mkTvSubstPrs :: [(TyVar, Type)] -> TCvSubst
- substTyWith :: HasCallStack => [TyVar] -> [Type] -> Type -> Type
- substTyWithCoVars :: [CoVar] -> [Coercion] -> Type -> Type
- substTysWith :: [TyVar] -> [Type] -> [Type] -> [Type]
- substTysWithCoVars :: [CoVar] -> [Coercion] -> [Type] -> [Type]
- substCoWith :: HasCallStack => [TyVar] -> [Type] -> Coercion -> Coercion
- substTy :: HasCallStack => TCvSubst -> Type -> Type
- substTyAddInScope :: TCvSubst -> Type -> Type
- substTyUnchecked :: TCvSubst -> Type -> Type
- substTysUnchecked :: TCvSubst -> [Type] -> [Type]
- substThetaUnchecked :: TCvSubst -> ThetaType -> ThetaType
- substTyWithUnchecked :: [TyVar] -> [Type] -> Type -> Type
- substCoUnchecked :: TCvSubst -> Coercion -> Coercion
- substCoWithUnchecked :: [TyVar] -> [Type] -> Coercion -> Coercion
- substTyWithInScope :: InScopeSet -> [TyVar] -> [Type] -> Type -> Type
- substTys :: HasCallStack => TCvSubst -> [Type] -> [Type]
- substTheta :: HasCallStack => TCvSubst -> ThetaType -> ThetaType
- lookupTyVar :: TCvSubst -> TyVar -> Maybe Type
- substCo :: HasCallStack => TCvSubst -> Coercion -> Coercion
- substCos :: HasCallStack => TCvSubst -> [Coercion] -> [Coercion]
- substCoVar :: TCvSubst -> CoVar -> Coercion
- substCoVars :: TCvSubst -> [CoVar] -> [Coercion]
- lookupCoVar :: TCvSubst -> Var -> Maybe Coercion
- cloneTyVarBndr :: TCvSubst -> TyVar -> Unique -> (TCvSubst, TyVar)
- cloneTyVarBndrs :: TCvSubst -> [TyVar] -> UniqSupply -> (TCvSubst, [TyVar])
- substVarBndr :: HasCallStack => TCvSubst -> TyCoVar -> (TCvSubst, TyCoVar)
- substVarBndrs :: HasCallStack => TCvSubst -> [TyCoVar] -> (TCvSubst, [TyCoVar])
- substTyVarBndr :: HasCallStack => TCvSubst -> TyVar -> (TCvSubst, TyVar)
- substTyVarBndrs :: HasCallStack => TCvSubst -> [TyVar] -> (TCvSubst, [TyVar])
- substCoVarBndr :: HasCallStack => TCvSubst -> CoVar -> (TCvSubst, CoVar)
- substTyVar :: TCvSubst -> TyVar -> Type
- substTyVars :: TCvSubst -> [TyVar] -> [Type]
- substTyCoVars :: TCvSubst -> [TyCoVar] -> [Type]
- substForAllCoBndr :: TCvSubst -> TyCoVar -> KindCoercion -> (TCvSubst, TyCoVar, Coercion)
- substVarBndrUsing :: (TCvSubst -> Type -> Type) -> TCvSubst -> TyCoVar -> (TCvSubst, TyCoVar)
- substForAllCoBndrUsing :: Bool -> (Coercion -> Coercion) -> TCvSubst -> TyCoVar -> KindCoercion -> (TCvSubst, TyCoVar, KindCoercion)
- checkValidSubst :: HasCallStack => TCvSubst -> [Type] -> [Coercion] -> a -> a
- isValidTCvSubst :: TCvSubst -> Bool
- tidyType :: TidyEnv -> Type -> Type
- tidyTypes :: TidyEnv -> [Type] -> [Type]
- tidyOpenType :: TidyEnv -> Type -> (TidyEnv, Type)
- tidyOpenTypes :: TidyEnv -> [Type] -> (TidyEnv, [Type])
- tidyOpenKind :: TidyEnv -> Kind -> (TidyEnv, Kind)
- tidyVarBndr :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar)
- tidyVarBndrs :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar])
- tidyFreeTyCoVars :: TidyEnv -> [TyCoVar] -> TidyEnv
- avoidNameClashes :: [TyCoVar] -> TidyEnv -> TidyEnv
- tidyOpenTyCoVar :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar)
- tidyOpenTyCoVars :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar])
- tidyTyCoVarOcc :: TidyEnv -> TyCoVar -> TyCoVar
- tidyTopType :: Type -> Type
- tidyKind :: TidyEnv -> Kind -> Kind
- tidyCo :: TidyEnv -> Coercion -> Coercion
- tidyCos :: TidyEnv -> [Coercion] -> [Coercion]
- tidyTyCoVarBinder :: TidyEnv -> VarBndr TyCoVar vis -> (TidyEnv, VarBndr TyCoVar vis)
- tidyTyCoVarBinders :: TidyEnv -> [VarBndr TyCoVar vis] -> (TidyEnv, [VarBndr TyCoVar vis])
- typeSize :: Type -> Int
- coercionSize :: Coercion -> Int
- provSize :: UnivCoProvenance -> Int

# Documentation

data TyThing Source #

A global typecheckable-thing, essentially anything that has a name. Not to be confused with a `TcTyThing`, which is also a typecheckable thing but in the *local* context. See `TcEnv` for how to retrieve a `TyThing` given a `Name`.

Constructors

AnId Id |
AConLike ConLike |
ATyCon TyCon |
ACoAxiom (CoAxiom Branched) |

#### Instances

Instances details

Outputable TyThing # |
Instance details Defined in TyCoRep Methods ppr :: TyThing -> SDoc Source # pprPrec :: Rational -> TyThing -> SDoc Source #
NamedThing TyThing # |
Instance details Defined in TyCoRep Methods getOccName :: TyThing -> OccName Source # getName :: TyThing -> Name Source #

tyThingCategory :: TyThing -> String Source #

pprTyThingCategory :: TyThing -> SDoc Source #

pprShortTyThing :: TyThing -> SDoc Source #

# Types

data Type Source #

Constructors

TyVarTy Var | Vanilla type or kind variable (*never* a coercion variable)
AppTy Type Type | Type application to something other than a `TyCon`. Parameters: 1) Function: must not be a `TyConApp` or `CastTy`, must be another `AppTy`, or `TyVarTy` See Note Respecting definitional equality about the no `CastTy` requirement 2) Argument type
TyConApp TyCon [KindOrType] | Application of a `TyCon`, including newtypes and synonyms. Invariant: saturated applications of `FunTyCon` must use `FunTy` and saturated synonyms must use their own constructors. However, unsaturated `FunTyCon`s do appear as `TyConApp`s. Parameters: 1) Type constructor being applied to. 2) Type arguments. Might not have enough type arguments here to saturate the constructor. Even type synonyms are not necessarily saturated; for example unsaturated type synonyms can appear as the right hand side of a type synonym.
ForAllTy !TyCoVarBinder Type | A Π type.
FunTy Type Type | t1 -> t2 Very common, so an important special case
LitTy TyLit | Type literals are similar to type constructors.
CastTy Type KindCoercion | A kind cast. The coercion is always nominal. INVARIANT: The cast is never refl. INVARIANT: The Type is not a CastTy (use TransCo instead) See Note Respecting definitional equality and (EQ3)
CoercionTy Coercion | Injection of a Coercion into a type This should only ever be used in the RHS of an AppTy, in the list of a TyConApp, when applying a promoted GADT data constructor

#### Instances

Instances details

Data Type # |
Instance details Defined in TyCoRep 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 # |
Instance details Defined in TyCoRep Methods ppr :: Type -> SDoc Source # pprPrec :: Rational -> Type -> SDoc Source #

data TyLit Source #

Constructors

NumTyLit Integer |
StrTyLit FastString |

#### Instances

Instances details

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

type KindOrType = Type Source #

The key representation of types within the compiler

type Kind = Type Source #

The key type representing kinds in the compiler.

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 TcTyClsDecls

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

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 TyCoRep

Constructors

Inferred |
Specified |
Required |

#### Instances

Instances details

Eq ArgFlag # |
Instance details Defined in Var Methods (==) :: ArgFlag -> ArgFlag -> Bool # (/=) :: ArgFlag -> ArgFlag -> Bool #
Data ArgFlag # |
Instance details Defined in 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 #
Ord ArgFlag # |
Instance details Defined in Var Methods compare :: ArgFlag -> ArgFlag -> Ordering # (<) :: ArgFlag -> ArgFlag -> Bool # (<=) :: ArgFlag -> ArgFlag -> Bool # (>) :: ArgFlag -> ArgFlag -> Bool # (>=) :: ArgFlag -> ArgFlag -> Bool # max :: ArgFlag -> ArgFlag -> ArgFlag # min :: ArgFlag -> ArgFlag -> ArgFlag #
Outputable ArgFlag # |
Instance details Defined in Var Methods ppr :: ArgFlag -> SDoc Source # pprPrec :: Rational -> ArgFlag -> SDoc Source #
Binary ArgFlag # |
Instance details Defined in Var Methods put_ :: BinHandle -> ArgFlag -> IO () Source # put :: BinHandle -> ArgFlag -> IO (Bin ArgFlag) Source # get :: BinHandle -> IO ArgFlag Source #
Outputable tv => Outputable (VarBndr tv ArgFlag) # |
Instance details Defined in Var Methods ppr :: VarBndr tv ArgFlag -> SDoc Source # pprPrec :: Rational -> VarBndr tv ArgFlag -> SDoc Source #

# Coercions

data Coercion Source #

A `Coercion` is concrete evidence of the equality/convertibility of two types.

Constructors

Refl Type |
GRefl Role Type MCoercionN |
TyConAppCo Role TyCon [Coercion] |
AppCo Coercion CoercionN |
ForAllCo TyCoVar KindCoercion Coercion |
FunCo Role Coercion Coercion |
CoVarCo CoVar |
AxiomInstCo (CoAxiom Branched) BranchIndex [Coercion] |
AxiomRuleCo CoAxiomRule [Coercion] |
UnivCo UnivCoProvenance Role Type Type |
SymCo Coercion |
TransCo Coercion Coercion |
NthCo Role Int Coercion |
LRCo LeftOrRight CoercionN |
InstCo Coercion CoercionN |
KindCo Coercion |
SubCo CoercionN |
HoleCo CoercionHole | See Note [Coercion holes] Only present during typechecking

#### Instances

Instances details

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

data UnivCoProvenance Source #

For simplicity, we have just one UnivCo that represents a coercion from some type to some other type, with (in general) no restrictions on the type. The UnivCoProvenance specifies more exactly what the coercion really is and why a program should (or shouldn't!) trust the coercion. It is reasonable to consider each constructor of `UnivCoProvenance` as a totally independent coercion form; their only commonality is that they don't tell you what types they coercion between. (That info is in the `UnivCo` constructor of `Coercion`.

Constructors

UnsafeCoerceProv | From `unsafeCoerce#`. These are unsound.
PhantomProv KindCoercion | See Note [Phantom coercions]. Only in Phantom roled coercions
ProofIrrelProv KindCoercion | From the fact that any two coercions are considered equivalent. See Note [ProofIrrelProv]. Can be used in Nominal or Representational coercions
PluginProv String | From a plugin, which asserts that this coercion is sound. The string is for the use of the plugin.

#### Instances

Instances details

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

data CoercionHole Source #

A coercion to be filled in by the type-checker. See Note [Coercion holes]

Constructors

CoercionHole |
Fields ch_co_var :: CoVar ch_ref :: IORef (Maybe Coercion)

#### Instances

Instances details

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

coHoleCoVar :: CoercionHole -> CoVar Source #

setCoHoleCoVar :: CoercionHole -> CoVar -> CoercionHole Source #

type CoercionN = Coercion Source #

type CoercionR = Coercion Source #

type CoercionP = Coercion Source #

type KindCoercion = CoercionN Source #

data MCoercion Source #

A semantically more meaningful type to represent what may or may not be a useful `Coercion`.

Constructors

MRefl |
MCo Coercion |

#### Instances

Instances details

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

type MCoercionR = MCoercion Source #

type MCoercionN = MCoercion Source #

# Functions over types

mkTyConTy :: TyCon -> Type Source #

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

mkTyVarTy :: TyVar -> Type Source #

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

mkTyCoVarTy :: TyCoVar -> Type Source #

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

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

Make an arrow type

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

Make nested arrow types

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

If tv is a coercion variable and it is not used in the body, returns a FunTy, otherwise makes a forall type. See Note [Unused coercion variable in ForAllTy]

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

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

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

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

mkTyCoPiTy :: TyCoBinder -> Type -> Type Source #

mkTyCoPiTys :: [TyCoBinder] -> Type -> Type Source #

mkPiTys :: [TyCoBinder] -> Type -> Type Source #

Like `mkTyCoPiTys`, but does not check the occurrence of the binder

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

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

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

Extract the RuntimeRep classifier of a type from its kind. For example, `kindRep * = LiftedRep`; Panics if this is not possible. Treats * and Constraint as the same

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 and False otherwise. Note that this returns False for levity-polymorphic kinds, which may be specialized to a kind that classifies unlifted types.

isLiftedRuntimeRep :: Type -> Bool Source #

isUnliftedRuntimeRep :: Type -> Bool Source #

isRuntimeRepTy :: Type -> Bool Source #

Is this the type `RuntimeRep`?

isRuntimeRepVar :: TyVar -> Bool Source #

Is a tyvar of type `RuntimeRep`?

sameVis :: ArgFlag -> ArgFlag -> Bool Source #

Do these denote the same level of visibility? `Required` arguments are visible, others are not. So this function equates `Specified` and `Inferred`. Used for printing.

# Functions over binders

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]

Constructors

Named TyCoVarBinder |
Anon Type |

#### Instances

Instances details

Data TyCoBinder # |
Instance details Defined in TyCoRep 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 # |
Instance details Defined in TyCoRep Methods ppr :: TyCoBinder -> SDoc Source # pprPrec :: Rational -> TyCoBinder -> SDoc Source #

type TyCoVarBinder = VarBndr TyCoVar ArgFlag Source #

Variable Binder

A `TyCoVarBinder` is the binder of a ForAllTy It's convenient to define this synonym here rather its natural home in TyCoRep, because it's used in DataCon.hs-boot

A `TyVarBinder` is a binder with only TyVar

type TyBinder = TyCoBinder Source #

`TyBinder` is like `TyCoBinder`, but there can only be `TyVarBinder` in the `Named` field.

binderVar :: VarBndr tv argf -> tv Source #

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

binderType :: VarBndr TyCoVar argf -> Type Source #

binderArgFlag :: VarBndr tv argf -> argf Source #

delBinderVar :: VarSet -> TyCoVarBinder -> VarSet Source #

Remove the binder's variable from the set, if the binder has a variable.

isInvisibleArgFlag :: ArgFlag -> Bool Source #

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

isVisibleArgFlag :: ArgFlag -> Bool Source #

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

isInvisibleBinder :: TyCoBinder -> Bool Source #

Does this binder bind an invisible argument?

isVisibleBinder :: TyCoBinder -> Bool Source #

Does this binder bind a visible argument?

isTyBinder :: TyCoBinder -> Bool Source #

If its a named binder, is the binder a tyvar? Returns True for nondependent binder.

isNamedBinder :: TyCoBinder -> Bool Source #

tyCoBinderArgFlag :: TyCoBinder -> ArgFlag Source #

# Functions over coercions

pickLR :: LeftOrRight -> (a, a) -> a Source #

# Pretty-printing

pprType :: Type -> SDoc Source #

pprParendType :: Type -> SDoc Source #

pprPrecType :: PprPrec -> Type -> SDoc Source #

pprPrecTypeX :: TidyEnv -> PprPrec -> Type -> SDoc Source #

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

pprTCvBndr :: TyCoVarBinder -> SDoc Source #

pprTCvBndrs :: [TyCoVarBinder] -> SDoc Source #

pprSigmaType :: Type -> SDoc Source #

pprTheta :: ThetaType -> SDoc Source #

pprParendTheta :: ThetaType -> SDoc Source #

pprForAll :: [TyCoVarBinder] -> SDoc Source #

pprUserForAll :: [TyCoVarBinder] -> SDoc Source #

Print a user-level forall; see Note [When to print foralls]

pprTyVar :: TyVar -> SDoc Source #

pprTyVars :: [TyVar] -> SDoc Source #

pprThetaArrowTy :: ThetaType -> SDoc Source #

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

pprKind :: Kind -> SDoc Source #

pprParendKind :: Kind -> SDoc Source #

pprTyLit :: TyLit -> SDoc Source #

newtype PprPrec Source #

A general-purpose pretty-printing precedence type.

Constructors

PprPrec Int |

#### Instances

Instances details

Eq PprPrec # |
Instance details Defined in BasicTypes Methods (==) :: PprPrec -> PprPrec -> Bool # (/=) :: PprPrec -> PprPrec -> Bool #
Ord PprPrec # |
Instance details Defined in BasicTypes Methods compare :: PprPrec -> PprPrec -> Ordering # (<) :: PprPrec -> PprPrec -> Bool # (<=) :: PprPrec -> PprPrec -> Bool # (>) :: PprPrec -> PprPrec -> Bool # (>=) :: PprPrec -> PprPrec -> Bool # max :: PprPrec -> PprPrec -> PprPrec # min :: PprPrec -> PprPrec -> PprPrec #
Show PprPrec # |
Instance details Defined in BasicTypes Methods showsPrec :: Int -> PprPrec -> ShowS Source # show :: PprPrec -> String Source # showList :: [PprPrec] -> ShowS Source #

topPrec :: PprPrec Source #

sigPrec :: PprPrec Source #

opPrec :: PprPrec Source #

funPrec :: PprPrec Source #

appPrec :: PprPrec Source #

maybeParen :: PprPrec -> PprPrec -> SDoc -> SDoc Source #

pprDataCons :: TyCon -> SDoc Source #

pprWithExplicitKindsWhen :: Bool -> SDoc -> SDoc Source #

Display all kind information (with `-fprint-explicit-kinds`) when the provided `Bool` argument is `True`. See `Note [Kind arguments in error messages]` in TcErrors.

pprCo :: Coercion -> SDoc Source #

pprParendCo :: Coercion -> SDoc Source #

debugPprType :: Type -> SDoc Source #

debugPprType is a simple pretty printer that prints a type without going through IfaceType. It does not format as prettily as the normal route, but it's much more direct, and that can be useful for debugging. E.g. with -dppr-debug it prints the kind on type-variable occurrences which the normal route fundamentally cannot do.

# Free variables

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.

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

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

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

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 #

tyCoVarsOfProv :: UnivCoProvenance -> TyCoVarSet 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

injectiveVarsOfType :: Type -> FV Source #

Returns the free variables of a `Type` that are in injective positions. For example, if `F` is a non-injective type family, then:

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

If ``injectiveVarsOfType` ty = itvs`, then knowing `ty` fixes `itvs`. More formally, if `a` is in ``injectiveVarsOfType` ty` and `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?]`.

tyConAppNeedsKindSig Source #

Arguments

:: Bool | Should specified binders count towards injective positions in the kind of the TyCon?
-> 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.)

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.

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.

# Substitutions

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.

Constructors

TCvSubst InScopeSet TvSubstEnv CvSubstEnv |

#### Instances

Instances details

Outputable TCvSubst # |
Instance details Defined in TyCoRep Methods ppr :: TCvSubst -> SDoc Source # pprPrec :: Rational -> TCvSubst -> SDoc Source #

type TvSubstEnv = TyVarEnv Type Source #

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

type CvSubstEnv = CoVarEnv Coercion Source #

A substitution of `Coercion`s for `CoVar`s

emptyTvSubstEnv :: TvSubstEnv Source #

emptyCvSubstEnv :: CvSubstEnv Source #

composeTCvSubstEnv :: InScopeSet -> (TvSubstEnv, CvSubstEnv) -> (TvSubstEnv, CvSubstEnv) -> (TvSubstEnv, CvSubstEnv) Source #

`(compose env1 env2)(x)` is `env1(env2(x))`; i.e. apply `env2` then `env1`. It assumes that both are idempotent. Typically, `env1` is the refinement to a base substitution `env2`

composeTCvSubst :: TCvSubst -> TCvSubst -> TCvSubst Source #

Composes two substitutions, applying the second one provided first, like in function composition.

emptyTCvSubst :: TCvSubst Source #

mkEmptyTCvSubst :: InScopeSet -> TCvSubst Source #

isEmptyTCvSubst :: TCvSubst -> Bool Source #

mkTCvSubst :: InScopeSet -> (TvSubstEnv, CvSubstEnv) -> TCvSubst Source #

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

Make a TCvSubst with specified tyvar subst and empty covar subst

mkCvSubst :: InScopeSet -> CvSubstEnv -> TCvSubst Source #

Make a TCvSubst with specified covar subst and empty tyvar subst

getTvSubstEnv :: TCvSubst -> TvSubstEnv Source #

getCvSubstEnv :: TCvSubst -> CvSubstEnv Source #

getTCvInScope :: TCvSubst -> InScopeSet Source #

getTCvSubstRangeFVs :: TCvSubst -> VarSet Source #

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

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

notElemTCvSubst :: Var -> TCvSubst -> Bool Source #

setTvSubstEnv :: TCvSubst -> TvSubstEnv -> TCvSubst Source #

setCvSubstEnv :: TCvSubst -> CvSubstEnv -> TCvSubst Source #

zapTCvSubst :: TCvSubst -> TCvSubst Source #

extendTCvInScope :: TCvSubst -> Var -> TCvSubst Source #

extendTCvInScopeList :: TCvSubst -> [Var] -> TCvSubst Source #

extendTCvInScopeSet :: TCvSubst -> VarSet -> TCvSubst Source #

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

extendTCvSubstWithClone :: TCvSubst -> TyCoVar -> TyCoVar -> TCvSubst Source #

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

extendCvSubstWithClone :: TCvSubst -> CoVar -> CoVar -> TCvSubst Source #

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

extendTvSubstBinderAndInScope :: TCvSubst -> TyCoBinder -> Type -> TCvSubst Source #

extendTvSubstWithClone :: TCvSubst -> TyVar -> TyVar -> TCvSubst Source #

extendTvSubstList :: TCvSubst -> [Var] -> [Type] -> TCvSubst Source #

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

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

unionTCvSubst :: TCvSubst -> TCvSubst -> TCvSubst Source #

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

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

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

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

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

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

zipCvSubst :: HasDebugCallStack => [CoVar] -> [Coercion] -> TCvSubst Source #

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

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

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

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

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

Type substitution, see `zipTvSubst`

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

Substitute covars within a type

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

Type substitution, see `zipTvSubst`

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

Type substitution, see `zipTvSubst`

substCoWith :: HasCallStack => [TyVar] -> [Type] -> Coercion -> Coercion Source #

Coercion substitution, see `zipTvSubst`

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

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

substTyAddInScope :: TCvSubst -> Type -> Type Source #

Substitute within a `Type` after adding the free variables of the type to the 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 `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.

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.

substTyWithInScope :: InScopeSet -> [TyVar] -> [Type] -> Type -> Type Source #

Substitute tyvars within a type using a known `InScopeSet`. Pre-condition: the `in_scope` set should satisfy Note [The substitution invariant]; specifically it should include the free vars of `tys`, and of `ty` minus the domain of the subst.

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

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

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

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

lookupTyVar :: TCvSubst -> TyVar -> Maybe Type Source #

substCo :: HasCallStack => TCvSubst -> Coercion -> Coercion Source #

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

substCos :: HasCallStack => TCvSubst -> [Coercion] -> [Coercion] Source #

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

substCoVar :: TCvSubst -> CoVar -> Coercion Source #

substCoVars :: TCvSubst -> [CoVar] -> [Coercion] Source #

lookupCoVar :: TCvSubst -> Var -> Maybe Coercion Source #

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

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

substVarBndr :: HasCallStack => TCvSubst -> TyCoVar -> (TCvSubst, TyCoVar) Source #

substVarBndrs :: HasCallStack => TCvSubst -> [TyCoVar] -> (TCvSubst, [TyCoVar]) Source #

substTyVarBndr :: HasCallStack => TCvSubst -> TyVar -> (TCvSubst, TyVar) Source #

substTyVarBndrs :: HasCallStack => TCvSubst -> [TyVar] -> (TCvSubst, [TyVar]) Source #

substCoVarBndr :: HasCallStack => TCvSubst -> CoVar -> (TCvSubst, CoVar) Source #

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

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

substTyCoVars :: TCvSubst -> [TyCoVar] -> [Type] Source #

substForAllCoBndr :: TCvSubst -> TyCoVar -> KindCoercion -> (TCvSubst, TyCoVar, Coercion) Source #

substVarBndrUsing :: (TCvSubst -> Type -> Type) -> TCvSubst -> TyCoVar -> (TCvSubst, TyCoVar) Source #

substForAllCoBndrUsing :: Bool -> (Coercion -> Coercion) -> TCvSubst -> TyCoVar -> KindCoercion -> (TCvSubst, TyCoVar, KindCoercion) Source #

checkValidSubst :: HasCallStack => TCvSubst -> [Type] -> [Coercion] -> a -> a Source #

This checks if the substitution satisfies the invariant from Note [The substitution invariant].

isValidTCvSubst :: TCvSubst -> Bool Source #

When calling `substTy` it should be the case that the in-scope set in the substitution is a superset of the free vars of the range of the substitution. See also Note [The substitution invariant].

# Tidying type related things up for printing

tidyType :: TidyEnv -> Type -> Type Source #

tidyTypes :: TidyEnv -> [Type] -> [Type] Source #

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

tidyOpenKind :: TidyEnv -> Kind -> (TidyEnv, Kind) Source #

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

avoidNameClashes :: [TyCoVar] -> TidyEnv -> TidyEnv Source #

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)

tidyKind :: TidyEnv -> Kind -> Kind Source #

tidyCo :: TidyEnv -> Coercion -> Coercion Source #

tidyCos :: TidyEnv -> [Coercion] -> [Coercion] Source #

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

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

# Sizes

typeSize :: Type -> Int Source #

coercionSize :: Coercion -> Int Source #

provSize :: UnivCoProvenance -> Int Source #