ghc-lib-parser-9.12.2.20250421: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Core.Coercion

Contents

- Main data type
  - Functions over coercions
  - Constructing coercions
  - Decomposition
  - Coercion variables
  - Free variables
  - Substitution
  - Lifting
  - Comparison
  - Forcing evaluation of coercions
- Pretty-printing
- Tidying
- Other

Description

Module for (a) type kinds and (b) type coercions, as used in System FC. See `Expr` for more on System FC and how coercions fit into it.

Synopsis

- data Coercion
- type CoercionN = Coercion
- type CoercionR = Coercion
- type CoercionP = Coercion
- data MCoercion
  - = MRefl
  - | MCo Coercion
- type MCoercionN = MCoercion
- type MCoercionR = MCoercion
- data CoSel
  - = SelTyCon Int Role
  - | SelFun FunSel
  - | SelForAll
- data FunSel
  - = SelMult
  - | SelArg
  - | SelRes
- data UnivCoProvenance
- data CoercionHole = CoercionHole {
  - ch_co_var :: CoVar
  - ch_ref :: IORef (Maybe Coercion)
  - ch_hetero_kind :: Bool
  }
- coHoleCoVar :: CoercionHole -> CoVar
- setCoHoleCoVar :: CoercionHole -> CoVar -> CoercionHole
- data LeftOrRight
  - = CLeft
  - | CRight
- data Var
- type CoVar = Id
- type TyCoVar = Id
- data Role
  - = Nominal
  - | Representational
  - | Phantom
- ltRole :: Role -> Role -> Bool
- coVarRType :: HasDebugCallStack => CoVar -> Type
- coVarLType :: HasDebugCallStack => CoVar -> Type
- coVarTypes :: HasDebugCallStack => CoVar -> Pair Type
- coVarKind :: CoVar -> Type
- coVarTypesRole :: HasDebugCallStack => CoVar -> (Type, Type, Role)
- coVarRole :: CoVar -> Role
- coercionType :: Coercion -> Type
- mkCoercionType :: Role -> Type -> Type -> Type
- coercionKind :: HasDebugCallStack => Coercion -> Pair Type
- coercionLKind :: HasDebugCallStack => Coercion -> Type
- coercionRKind :: HasDebugCallStack => Coercion -> Type
- coercionKinds :: [Coercion] -> Pair [Type]
- coercionRole :: Coercion -> Role
- coercionKindRole :: Coercion -> (Pair Type, Role)
- mkGReflCo :: Role -> Type -> MCoercionN -> Coercion
- mkGReflMCo :: HasDebugCallStack => Role -> Type -> CoercionN -> Coercion
- mkReflCo :: Role -> Type -> Coercion
- mkRepReflCo :: Type -> Coercion
- mkNomReflCo :: Type -> Coercion
- mkCoVarCo :: CoVar -> Coercion
- mkCoVarCos :: [CoVar] -> [Coercion]
- mkAxInstCo :: Role -> CoAxiomRule -> [Type] -> [Coercion] -> Coercion
- mkUnbranchedAxInstCo :: Role -> CoAxiom Unbranched -> [Type] -> [Coercion] -> Coercion
- mkAxInstRHS :: forall (br :: BranchFlag). CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Type
- mkUnbranchedAxInstRHS :: CoAxiom Unbranched -> [Type] -> [Coercion] -> Type
- mkAxInstLHS :: forall (br :: BranchFlag). CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Type
- mkUnbranchedAxInstLHS :: CoAxiom Unbranched -> [Type] -> [Coercion] -> Type
- mkPiCo :: Role -> Var -> Coercion -> Coercion
- mkPiCos :: Role -> [Var] -> Coercion -> Coercion
- mkCoCast :: Coercion -> CoercionR -> Coercion
- mkSymCo :: Coercion -> Coercion
- mkTransCo :: HasDebugCallStack => Coercion -> Coercion -> Coercion
- mkSelCo :: HasDebugCallStack => CoSel -> Coercion -> Coercion
- mkSelCoResRole :: CoSel -> Role -> Role
- getNthFun :: FunSel -> a -> a -> a -> a
- selectFromType :: HasDebugCallStack => CoSel -> Type -> Type
- mkLRCo :: LeftOrRight -> Coercion -> Coercion
- mkInstCo :: Coercion -> CoercionN -> Coercion
- mkAppCo :: Coercion -> Coercion -> Coercion
- mkAppCos :: Coercion -> [Coercion] -> Coercion
- mkTyConAppCo :: HasDebugCallStack => Role -> TyCon -> [Coercion] -> Coercion
- mkFunCo :: Role -> FunTyFlag -> CoercionN -> Coercion -> Coercion -> Coercion
- mkFunCo2 :: Role -> FunTyFlag -> FunTyFlag -> CoercionN -> Coercion -> Coercion -> Coercion
- mkFunCoNoFTF :: HasDebugCallStack => Role -> CoercionN -> Coercion -> Coercion -> Coercion
- mkFunResCo :: Role -> Id -> Coercion -> Coercion
- mkNakedFunCo :: Role -> FunTyFlag -> CoercionN -> Coercion -> Coercion -> Coercion
- mkNakedForAllCo :: TyVar -> ForAllTyFlag -> ForAllTyFlag -> CoercionN -> Coercion -> Coercion
- mkForAllCo :: HasDebugCallStack => TyCoVar -> ForAllTyFlag -> ForAllTyFlag -> CoercionN -> Coercion -> Coercion
- mkHomoForAllCos :: [ForAllTyBinder] -> Coercion -> Coercion
- mkPhantomCo :: Coercion -> Type -> Type -> Coercion
- mkHoleCo :: CoercionHole -> Coercion
- mkUnivCo :: UnivCoProvenance -> [Coercion] -> Role -> Type -> Type -> Coercion
- mkSubCo :: HasDebugCallStack => Coercion -> Coercion
- mkProofIrrelCo :: Role -> CoercionN -> Coercion -> Coercion -> Coercion
- downgradeRole :: Role -> Role -> Coercion -> Coercion
- mkAxiomCo :: CoAxiomRule -> [Coercion] -> Coercion
- mkGReflRightCo :: Role -> Type -> CoercionN -> Coercion
- mkGReflLeftCo :: Role -> Type -> CoercionN -> Coercion
- mkCoherenceLeftCo :: Role -> Type -> CoercionN -> Coercion -> Coercion
- mkCoherenceRightCo :: HasDebugCallStack => Role -> Type -> CoercionN -> Coercion -> Coercion
- mkKindCo :: Coercion -> Coercion
- castCoercionKind :: Coercion -> CoercionN -> CoercionN -> Coercion
- castCoercionKind1 :: Coercion -> Role -> Type -> Type -> CoercionN -> Coercion
- castCoercionKind2 :: Coercion -> Role -> Type -> Type -> CoercionN -> CoercionN -> Coercion
- mkPrimEqPred :: Type -> Type -> Type
- mkReprPrimEqPred :: Type -> Type -> Type
- mkPrimEqPredRole :: Role -> Type -> Type -> PredType
- mkNomPrimEqPred :: Kind -> Type -> Type -> Type
- instNewTyCon_maybe :: TyCon -> [Type] -> Maybe (Type, Coercion)
- type NormaliseStepper ev = RecTcChecker -> TyCon -> [Type] -> NormaliseStepResult ev
- data NormaliseStepResult ev
  - = NS_Done
  - | NS_Abort
  - | NS_Step RecTcChecker Type ev
- composeSteppers :: NormaliseStepper ev -> NormaliseStepper ev -> NormaliseStepper ev
- unwrapNewTypeStepper :: NormaliseStepper Coercion
- topNormaliseNewType_maybe :: Type -> Maybe (Coercion, Type)
- topNormaliseTypeX :: NormaliseStepper ev -> (ev -> ev -> ev) -> Type -> Maybe (ev, Type)
- decomposeCo :: Arity -> Coercion -> Infinite Role -> [Coercion]
- decomposeFunCo :: HasDebugCallStack => Coercion -> (CoercionN, Coercion, Coercion)
- decomposePiCos :: HasDebugCallStack => CoercionN -> Pair Type -> [Type] -> ([CoercionN], CoercionN)
- getCoVar_maybe :: Coercion -> Maybe CoVar
- splitAppCo_maybe :: Coercion -> Maybe (Coercion, Coercion)
- splitFunCo_maybe :: Coercion -> Maybe (Coercion, Coercion)
- splitForAllCo_maybe :: Coercion -> Maybe (TyCoVar, ForAllTyFlag, ForAllTyFlag, Coercion, Coercion)
- splitForAllCo_ty_maybe :: Coercion -> Maybe (TyVar, ForAllTyFlag, ForAllTyFlag, Coercion, Coercion)
- splitForAllCo_co_maybe :: Coercion -> Maybe (CoVar, ForAllTyFlag, ForAllTyFlag, Coercion, Coercion)
- tyConRole :: Role -> TyCon -> Int -> Role
- tyConRolesX :: Role -> TyCon -> Infinite Role
- tyConRolesRepresentational :: TyCon -> Infinite Role
- setNominalRole_maybe :: Role -> Coercion -> Maybe CoercionN
- tyConRoleListX :: Role -> TyCon -> [Role]
- tyConRoleListRepresentational :: TyCon -> [Role]
- funRole :: Role -> FunSel -> Role
- pickLR :: LeftOrRight -> (a, a) -> a
- isGReflCo :: Coercion -> Bool
- isReflCo :: Coercion -> Bool
- isReflCo_maybe :: Coercion -> Maybe (Type, Role)
- isGReflCo_maybe :: Coercion -> Maybe (Type, Role)
- isReflexiveCo :: Coercion -> Bool
- isReflexiveCo_maybe :: Coercion -> Maybe (Type, Role)
- isReflCoVar_maybe :: Var -> Maybe Coercion
- isGReflMCo :: MCoercion -> Bool
- mkGReflLeftMCo :: Role -> Type -> MCoercionN -> Coercion
- mkGReflRightMCo :: Role -> Type -> MCoercionN -> Coercion
- mkCoherenceRightMCo :: Role -> Type -> MCoercionN -> Coercion -> Coercion
- coToMCo :: Coercion -> MCoercion
- mkTransMCo :: MCoercion -> MCoercion -> MCoercion
- mkTransMCoL :: MCoercion -> Coercion -> MCoercion
- mkTransMCoR :: Coercion -> MCoercion -> MCoercion
- mkCastTyMCo :: Type -> MCoercion -> Type
- mkSymMCo :: MCoercion -> MCoercion
- mkFunResMCo :: Id -> MCoercionR -> MCoercionR
- mkPiMCos :: [Var] -> MCoercion -> MCoercion
- isReflMCo :: MCoercion -> Bool
- checkReflexiveMCo :: MCoercion -> MCoercion
- mkCoVar :: Name -> Type -> CoVar
- isCoVar :: Var -> Bool
- coVarName :: CoVar -> Name
- setCoVarName :: CoVar -> Name -> CoVar
- setCoVarUnique :: CoVar -> Unique -> CoVar
- tyCoVarsOfCo :: Coercion -> TyCoVarSet
- tyCoVarsOfCos :: [Coercion] -> TyCoVarSet
- coVarsOfCo :: Coercion -> CoVarSet
- tyCoFVsOfCo :: Coercion -> FV
- tyCoFVsOfCos :: [Coercion] -> FV
- tyCoVarsOfCoDSet :: Coercion -> DTyCoVarSet
- coercionSize :: Coercion -> Int
- anyFreeVarsOfCo :: (TyCoVar -> Bool) -> Coercion -> Bool
- type CvSubstEnv = CoVarEnv Coercion
- emptyCvSubstEnv :: CvSubstEnv
- lookupCoVar :: Subst -> Var -> Maybe Coercion
- substCo :: HasDebugCallStack => Subst -> Coercion -> Coercion
- substCos :: HasDebugCallStack => Subst -> [Coercion] -> [Coercion]
- substCoVar :: Subst -> CoVar -> Coercion
- substCoVars :: Subst -> [CoVar] -> [Coercion]
- substCoWith :: HasDebugCallStack => [TyVar] -> [Type] -> Coercion -> Coercion
- substCoVarBndr :: HasDebugCallStack => Subst -> CoVar -> (Subst, CoVar)
- extendTvSubstAndInScope :: Subst -> TyVar -> Type -> Subst
- getCvSubstEnv :: Subst -> CvSubstEnv
- liftCoSubst :: HasDebugCallStack => Role -> LiftingContext -> Type -> Coercion
- liftCoSubstTyVar :: LiftingContext -> Role -> TyVar -> Maybe Coercion
- liftCoSubstWith :: Role -> [TyCoVar] -> [Coercion] -> Type -> Coercion
- liftCoSubstWithEx :: Role -> [TyVar] -> [Coercion] -> [TyCoVar] -> [Type] -> (Type -> Coercion, [Type])
- emptyLiftingContext :: InScopeSet -> LiftingContext
- extendLiftingContext :: LiftingContext -> TyCoVar -> Coercion -> LiftingContext
- extendLiftingContextAndInScope :: LiftingContext -> TyCoVar -> Coercion -> LiftingContext
- liftCoSubstVarBndrUsing :: (r -> CoercionN) -> (LiftingContext -> Type -> r) -> LiftingContext -> TyCoVar -> (LiftingContext, TyCoVar, r)
- isMappedByLC :: TyCoVar -> LiftingContext -> Bool
- extendLiftingContextCvSubst :: LiftingContext -> CoVar -> Coercion -> LiftingContext
- mkSubstLiftingContext :: Subst -> LiftingContext
- liftingContextSubst :: LiftingContext -> Subst
- zapLiftingContext :: LiftingContext -> LiftingContext
- substForAllCoBndrUsingLC :: SwapFlag -> (Coercion -> Coercion) -> LiftingContext -> TyCoVar -> Coercion -> (LiftingContext, TyCoVar, Coercion)
- lcLookupCoVar :: LiftingContext -> CoVar -> Maybe Coercion
- lcInScopeSet :: LiftingContext -> InScopeSet
- type LiftCoEnv = VarEnv Coercion
- data LiftingContext = LC Subst LiftCoEnv
- liftEnvSubstLeft :: Subst -> LiftCoEnv -> Subst
- liftEnvSubstRight :: Subst -> LiftCoEnv -> Subst
- substRightCo :: LiftingContext -> Coercion -> Coercion
- substLeftCo :: LiftingContext -> Coercion -> Coercion
- swapLiftCoEnv :: LiftCoEnv -> LiftCoEnv
- lcSubstLeft :: LiftingContext -> Subst
- lcSubstRight :: LiftingContext -> Subst
- eqCoercion :: Coercion -> Coercion -> Bool
- eqCoercionX :: RnEnv2 -> Coercion -> Coercion -> Bool
- seqCo :: Coercion -> ()
- pprCo :: Coercion -> SDoc
- pprParendCo :: Coercion -> SDoc
- pprCoAxiom :: forall (br :: BranchFlag). CoAxiom br -> SDoc
- pprCoAxBranch :: TyCon -> CoAxBranch -> SDoc
- pprCoAxBranchLHS :: TyCon -> CoAxBranch -> SDoc
- pprCoAxBranchUser :: TyCon -> CoAxBranch -> SDoc
- tidyCoAxBndrsForUser :: TidyEnv -> [Var] -> (TidyEnv, [Var])
- etaExpandCoAxBranch :: CoAxBranch -> ([TyVar], [Type], Type)
- tidyCo :: TidyEnv -> Coercion -> Coercion
- tidyCos :: TidyEnv -> [Coercion] -> [Coercion]
- promoteCoercion :: HasDebugCallStack => Coercion -> CoercionN
- buildCoercion :: HasDebugCallStack => Type -> Type -> CoercionN
- multToCo :: Mult -> Coercion
- mkRuntimeRepCo :: HasDebugCallStack => Coercion -> Coercion
- hasCoercionHoleTy :: Type -> Bool
- hasCoercionHoleCo :: Coercion -> Bool
- hasThisCoercionHoleTy :: Type -> CoercionHole -> Bool
- setCoHoleType :: CoercionHole -> Type -> CoercionHole

# Main data type

data Coercion Source #

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

#### Instances

Instances details

Data Coercion 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) -> 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 Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods ppr :: Coercion -> SDoc Source #
Eq (DeBruijn Coercion) Source # |
Instance details Defined in GHC.Core.Map.Type Methods (==) :: DeBruijn Coercion -> DeBruijn Coercion -> Bool Source # (/=) :: DeBruijn Coercion -> DeBruijn Coercion -> Bool Source #

type CoercionN = Coercion Source #

type CoercionR = Coercion Source #

type CoercionP = Coercion 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 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) -> 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 Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods ppr :: MCoercion -> SDoc Source #

type MCoercionN = MCoercion Source #

type MCoercionR = MCoercion Source #

data CoSel Source #

Constructors

SelTyCon Int Role |
SelFun FunSel |
SelForAll |

#### Instances

Instances details

NFData CoSel Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods rnf :: CoSel -> () Source #
Data CoSel 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) -> CoSel -> c CoSel Source #

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

toConstr :: CoSel -> Constr Source #

dataTypeOf :: CoSel -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Binary CoSel Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods put_ :: WriteBinHandle -> CoSel -> IO () Source # put :: WriteBinHandle -> CoSel -> IO (Bin CoSel) Source # get :: ReadBinHandle -> IO CoSel Source #
Outputable CoSel Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods ppr :: CoSel -> SDoc Source #
Eq CoSel Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods (==) :: CoSel -> CoSel -> Bool Source # (/=) :: CoSel -> CoSel -> Bool Source #
Ord CoSel Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods compare :: CoSel -> CoSel -> Ordering Source # (<) :: CoSel -> CoSel -> Bool Source # (<=) :: CoSel -> CoSel -> Bool Source # (>) :: CoSel -> CoSel -> Bool Source # (>=) :: CoSel -> CoSel -> Bool Source # max :: CoSel -> CoSel -> CoSel Source # min :: CoSel -> CoSel -> CoSel Source #

data FunSel Source #

Constructors

SelMult |
SelArg |
SelRes |

#### Instances

Instances details

Data FunSel 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) -> FunSel -> c FunSel Source #

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

toConstr :: FunSel -> Constr Source #

dataTypeOf :: FunSel -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Outputable FunSel Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods ppr :: FunSel -> SDoc Source #
Eq FunSel Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods (==) :: FunSel -> FunSel -> Bool Source # (/=) :: FunSel -> FunSel -> Bool Source #
Ord FunSel Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods compare :: FunSel -> FunSel -> Ordering Source # (<) :: FunSel -> FunSel -> Bool Source # (<=) :: FunSel -> FunSel -> Bool Source # (>) :: FunSel -> FunSel -> Bool Source # (>=) :: FunSel -> FunSel -> Bool Source # max :: FunSel -> FunSel -> FunSel Source # min :: FunSel -> FunSel -> FunSel 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`.

#### Instances

Instances details

NFData UnivCoProvenance Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods rnf :: UnivCoProvenance -> () Source #
Data UnivCoProvenance 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) -> 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 #

Binary UnivCoProvenance Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods put_ :: WriteBinHandle -> UnivCoProvenance -> IO () Source # put :: WriteBinHandle -> UnivCoProvenance -> IO (Bin UnivCoProvenance) Source # get :: ReadBinHandle -> IO UnivCoProvenance Source #
Outputable UnivCoProvenance Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods ppr :: UnivCoProvenance -> SDoc Source #
Eq UnivCoProvenance Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods (==) :: UnivCoProvenance -> UnivCoProvenance -> Bool Source # (/=) :: UnivCoProvenance -> UnivCoProvenance -> Bool Source #
Ord UnivCoProvenance Source # |

Instance details

Defined in GHC.Core.TyCo.Rep

Methods

compare :: UnivCoProvenance -> UnivCoProvenance -> Ordering Source #

(<) :: UnivCoProvenance -> UnivCoProvenance -> Bool Source #

(<=) :: UnivCoProvenance -> UnivCoProvenance -> Bool Source #

(>) :: UnivCoProvenance -> UnivCoProvenance -> Bool Source #

(>=) :: UnivCoProvenance -> UnivCoProvenance -> Bool Source #

max :: UnivCoProvenance -> UnivCoProvenance -> UnivCoProvenance Source #

min :: UnivCoProvenance -> UnivCoProvenance -> UnivCoProvenance 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)
- ch_hetero_kind :: Bool

#### Instances

Instances details

Data CoercionHole 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) -> 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 #

Uniquable CoercionHole Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods getUnique :: CoercionHole -> Unique Source #
Outputable CoercionHole Source # |
Instance details Defined in GHC.Core.TyCo.Rep Methods ppr :: CoercionHole -> SDoc Source #

coHoleCoVar :: CoercionHole -> CoVar Source #

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

data LeftOrRight Source #

Constructors

CLeft |
CRight |

#### Instances

Instances details

Data LeftOrRight Source # |

Instance details

Defined in GHC.Types.Basic

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LeftOrRight -> c LeftOrRight Source #

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

toConstr :: LeftOrRight -> Constr Source #

dataTypeOf :: LeftOrRight -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Binary LeftOrRight Source # |
Instance details Defined in GHC.Types.Basic Methods put_ :: WriteBinHandle -> LeftOrRight -> IO () Source # put :: WriteBinHandle -> LeftOrRight -> IO (Bin LeftOrRight) Source # get :: ReadBinHandle -> IO LeftOrRight Source #
Outputable LeftOrRight Source # |
Instance details Defined in GHC.Types.Basic Methods ppr :: LeftOrRight -> SDoc Source #
Eq LeftOrRight Source # |
Instance details Defined in GHC.Types.Basic Methods (==) :: LeftOrRight -> LeftOrRight -> Bool Source # (/=) :: LeftOrRight -> LeftOrRight -> Bool Source #
Ord LeftOrRight Source # |

Instance details

Defined in GHC.Types.Basic

Methods

compare :: LeftOrRight -> LeftOrRight -> Ordering Source #

(<) :: LeftOrRight -> LeftOrRight -> Bool Source #

(<=) :: LeftOrRight -> LeftOrRight -> Bool Source #

(>) :: LeftOrRight -> LeftOrRight -> Bool Source #

(>=) :: LeftOrRight -> LeftOrRight -> Bool Source #

max :: LeftOrRight -> LeftOrRight -> LeftOrRight Source #

min :: LeftOrRight -> LeftOrRight -> LeftOrRight Source #

data Var Source #

Variable

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

#### Instances

Instances details

Data Var Source # |

Instance details

Defined in GHC.Types.Var

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Var -> c Var Source #

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

toConstr :: Var -> Constr Source #

dataTypeOf :: Var -> DataType Source #

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

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

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

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

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

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

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

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

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

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

NamedThing Var Source # |
Instance details Defined in GHC.Types.Var Methods getOccName :: Var -> OccName Source # getName :: Var -> Name Source #
HasOccName Var Source # |
Instance details Defined in GHC.Types.Var Methods occName :: Var -> OccName Source #
Uniquable Var Source # |
Instance details Defined in GHC.Types.Var Methods getUnique :: Var -> Unique Source #
Outputable Var Source # |
Instance details Defined in GHC.Types.Var Methods ppr :: Var -> SDoc Source #
OutputableBndr Var Source # |
Instance details Defined in GHC.Core.Ppr Methods pprBndr :: BindingSite -> Var -> SDoc Source # pprPrefixOcc :: Var -> SDoc Source # pprInfixOcc :: Var -> SDoc Source # bndrIsJoin_maybe :: Var -> JoinPointHood Source #
Eq Var Source # |
Instance details Defined in GHC.Types.Var Methods (==) :: Var -> Var -> Bool Source # (/=) :: Var -> Var -> Bool Source #
Ord Var Source # |
Instance details Defined in GHC.Types.Var Methods compare :: Var -> Var -> Ordering Source # (<) :: Var -> Var -> Bool Source # (<=) :: Var -> Var -> Bool Source # (>) :: Var -> Var -> Bool Source # (>=) :: Var -> Var -> Bool Source # max :: Var -> Var -> Var Source # min :: Var -> Var -> Var Source #
Eq (DeBruijn CoreAlt) Source # |
Instance details Defined in GHC.Core.Map.Expr Methods (==) :: DeBruijn CoreAlt -> DeBruijn CoreAlt -> Bool Source # (/=) :: DeBruijn CoreAlt -> DeBruijn CoreAlt -> Bool Source #
Eq (DeBruijn CoreExpr) Source # |
Instance details Defined in GHC.Core.Map.Expr Methods (==) :: DeBruijn CoreExpr -> DeBruijn CoreExpr -> Bool Source # (/=) :: DeBruijn CoreExpr -> DeBruijn CoreExpr -> Bool Source #
Eq (DeBruijn Var) Source # |
Instance details Defined in GHC.Core.Map.Type Methods (==) :: DeBruijn Var -> DeBruijn Var -> Bool Source # (/=) :: DeBruijn Var -> DeBruijn Var -> Bool Source #
OutputableBndr (Id, TagSig) Source # |
Instance details Defined in GHC.Stg.InferTags.TagSig Methods pprBndr :: BindingSite -> (Id, TagSig) -> SDoc Source # pprPrefixOcc :: (Id, TagSig) -> SDoc Source # pprInfixOcc :: (Id, TagSig) -> SDoc Source # bndrIsJoin_maybe :: (Id, TagSig) -> JoinPointHood Source #
type Anno Id Source # |
Instance details Defined in GHC.Hs.Extension type Anno Id = SrcSpanAnnN

type CoVar = Id Source #

Coercion Variable

type TyCoVar = Id Source #

Type or Coercion Variable

data Role Source #

See Note [Roles] in GHC.Core.Coercion

Order of constructors matters: the Ord instance coincides with the *super*typing relation on roles.

Constructors

Nominal |
Representational |
Phantom |

#### Instances

Instances details

Data Role Source # |

Instance details

Defined in Language.Haskell.Syntax.Basic

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Role -> c Role Source #

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

toConstr :: Role -> Constr Source #

dataTypeOf :: Role -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Binary Role Source # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods put_ :: WriteBinHandle -> Role -> IO () Source # put :: WriteBinHandle -> Role -> IO (Bin Role) Source # get :: ReadBinHandle -> IO Role Source #
Outputable Role Source # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods ppr :: Role -> SDoc Source #
Eq Role Source # |
Instance details Defined in Language.Haskell.Syntax.Basic Methods (==) :: Role -> Role -> Bool Source # (/=) :: Role -> Role -> Bool Source #
Ord Role Source # |
Instance details Defined in Language.Haskell.Syntax.Basic Methods compare :: Role -> Role -> Ordering Source # (<) :: Role -> Role -> Bool Source # (<=) :: Role -> Role -> Bool Source # (>) :: Role -> Role -> Bool Source # (>=) :: Role -> Role -> Bool Source # max :: Role -> Role -> Role Source # min :: Role -> Role -> Role Source #
type Anno (Maybe Role) Source # |
Instance details Defined in GHC.Hs.Decls type Anno (Maybe Role) = EpAnnCO

ltRole :: Role -> Role -> Bool Source #

## Functions over coercions

coVarRType :: HasDebugCallStack => CoVar -> Type Source #

coVarLType :: HasDebugCallStack => CoVar -> Type Source #

coVarTypes :: HasDebugCallStack => CoVar -> Pair Type Source #

coVarKind :: CoVar -> Type Source #

coVarTypesRole :: HasDebugCallStack => CoVar -> (Type, Type, Role) Source #

coVarRole :: CoVar -> Role Source #

coercionType :: Coercion -> Type Source #

mkCoercionType :: Role -> Type -> Type -> Type Source #

Makes a coercion type from two types: the types whose equality is proven by the relevant `Coercion`

coercionKind :: HasDebugCallStack => Coercion -> Pair Type Source #

If it is the case that

    c :: (t1 ~ t2)

i.e. the kind of `c` relates `t1` and `t2`, then `coercionKind c = Pair t1 t2`.

coercionLKind :: HasDebugCallStack => Coercion -> Type Source #

coercionRKind :: HasDebugCallStack => Coercion -> Type Source #

coercionKinds :: [Coercion] -> Pair [Type] Source #

Apply `coercionKind` to multiple `Coercion`s

coercionRole :: Coercion -> Role Source #

Retrieve the role from a coercion.

coercionKindRole :: Coercion -> (Pair Type, Role) Source #

Get a coercion's kind and role.

## Constructing coercions

mkGReflCo :: Role -> Type -> MCoercionN -> Coercion Source #

Make a generalized reflexive coercion

mkGReflMCo :: HasDebugCallStack => Role -> Type -> CoercionN -> Coercion Source #

mkReflCo :: Role -> Type -> Coercion Source #

Make a reflexive coercion

mkRepReflCo :: Type -> Coercion Source #

Make a representational reflexive coercion

mkNomReflCo :: Type -> Coercion Source #

Make a nominal reflexive coercion

mkCoVarCo :: CoVar -> Coercion Source #

mkCoVarCos :: [CoVar] -> [Coercion] Source #

mkAxInstCo :: Role -> CoAxiomRule -> [Type] -> [Coercion] -> Coercion Source #

mkUnbranchedAxInstCo :: Role -> CoAxiom Unbranched -> [Type] -> [Coercion] -> Coercion Source #

mkAxInstRHS :: forall (br :: BranchFlag). CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Type Source #

mkUnbranchedAxInstRHS :: CoAxiom Unbranched -> [Type] -> [Coercion] -> Type Source #

mkAxInstLHS :: forall (br :: BranchFlag). CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Type Source #

Return the left-hand type of the axiom, when the axiom is instantiated at the types given.

mkUnbranchedAxInstLHS :: CoAxiom Unbranched -> [Type] -> [Coercion] -> Type Source #

Instantiate the left-hand side of an unbranched axiom

mkPiCo :: Role -> Var -> Coercion -> Coercion Source #

Make a forall `Coercion`, where both types related by the coercion are quantified over the same variable.

mkPiCos :: Role -> [Var] -> Coercion -> Coercion Source #

mkCoCast :: Coercion -> CoercionR -> Coercion Source #

mkSymCo :: Coercion -> Coercion Source #

Create a symmetric version of the given `Coercion` that asserts equality between the same types but in the other "direction", so a kind of `t1 ~ t2` becomes the kind `t2 ~ t1`.

mkTransCo :: HasDebugCallStack => Coercion -> Coercion -> Coercion Source #

mkTransCo creates a new `Coercion` by composing the two given `Coercion`s transitively: (co1 ; co2)

mkSelCo :: HasDebugCallStack => CoSel -> Coercion -> Coercion Source #

mkSelCoResRole :: CoSel -> Role -> Role Source #

getNthFun Source #

Arguments

:: FunSel |
-> a | multiplicity
-> a | argument
-> a | result
-> a | One of the above three

Extract the nth field of a FunCo

selectFromType :: HasDebugCallStack => CoSel -> Type -> Type Source #

mkLRCo :: LeftOrRight -> Coercion -> Coercion Source #

mkInstCo :: Coercion -> CoercionN -> Coercion Source #

Instantiates a `Coercion`. Works for both tyvar and covar

mkAppCo Source #

Arguments

:: Coercion | :: t1 ~r t2
-> Coercion | :: s1 ~N s2, where s1 :: k1, s2 :: k2
-> Coercion | :: t1 s1 ~r t2 s2

Apply a `Coercion` to another `Coercion`. The second coercion must be Nominal, unless the first is Phantom. If the first is Phantom, then the second can be either Phantom or Nominal.

mkAppCos :: Coercion -> [Coercion] -> Coercion Source #

Applies multiple `Coercion`s to another `Coercion`, from left to right. See also `mkAppCo`.

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

Apply a type constructor to a list of coercions. It is the caller's responsibility to get the roles correct on argument coercions.

mkFunCo :: Role -> FunTyFlag -> CoercionN -> Coercion -> Coercion -> Coercion Source #

Build a function `Coercion` from two other `Coercion`s. That is, given `co1 :: a ~ b` and `co2 :: x ~ y` produce `co :: (a -> x) ~ (b -> y)` or `(a => x) ~ (b => y)`, depending on the kind of `a`/`b`. This (most common) version takes a single FunTyFlag, which is used for both fco_afl and ftf_afr of the FunCo

mkFunCo2 :: Role -> FunTyFlag -> FunTyFlag -> CoercionN -> Coercion -> Coercion -> Coercion Source #

mkFunCoNoFTF :: HasDebugCallStack => Role -> CoercionN -> Coercion -> Coercion -> Coercion Source #

mkFunResCo :: Role -> Id -> Coercion -> Coercion Source #

mkNakedFunCo :: Role -> FunTyFlag -> CoercionN -> Coercion -> Coercion -> Coercion Source #

mkNakedForAllCo :: TyVar -> ForAllTyFlag -> ForAllTyFlag -> CoercionN -> Coercion -> Coercion Source #

mkForAllCo :: HasDebugCallStack => TyCoVar -> ForAllTyFlag -> ForAllTyFlag -> CoercionN -> Coercion -> Coercion Source #

Make a Coercion from a tycovar, a kind coercion, and a body coercion.

mkHomoForAllCos :: [ForAllTyBinder] -> Coercion -> Coercion Source #

Make a Coercion quantified over a type/coercion variable; the variable has the same kind and visibility in both sides of the coercion

mkPhantomCo :: Coercion -> Type -> Type -> Coercion Source #

Make a phantom coercion between two types. The coercion passed in must be a nominal coercion between the kinds of the types.

mkHoleCo :: CoercionHole -> Coercion Source #

Make a coercion from a coercion hole

mkUnivCo Source #

Arguments

:: UnivCoProvenance |
-> [Coercion] | Coercions on which this depends
-> Role | role of the built coercion, "r"
-> Type | t1 :: k1
-> Type | t2 :: k2
-> Coercion | :: t1 ~r t2

Make a universal coercion between two arbitrary types.

mkSubCo :: HasDebugCallStack => Coercion -> Coercion Source #

mkProofIrrelCo Source #

Arguments

:: Role | role of the created coercion, "r"
-> CoercionN | :: phi1 ~N phi2
-> Coercion | g1 :: phi1
-> Coercion | g2 :: phi2
-> Coercion | :: g1 ~r g2

Make a "coercion between coercions".

downgradeRole :: Role -> Role -> Coercion -> Coercion Source #

Like `downgradeRole_maybe`, but panics if the change isn't a downgrade. See Note [Role twiddling functions]

mkAxiomCo :: CoAxiomRule -> [Coercion] -> Coercion Source #

mkGReflRightCo :: Role -> Type -> CoercionN -> Coercion Source #

Given `ty :: k1`, `co :: k1 ~ k2`, produces `co' :: ty ~r (ty |> co)`

mkGReflLeftCo :: Role -> Type -> CoercionN -> Coercion Source #

Given `r`, `ty :: k1`, and `co :: k1 ~N k2`, produces `co' :: (ty |> co) ~r ty`

mkCoherenceLeftCo :: Role -> Type -> CoercionN -> Coercion -> Coercion Source #

Given `ty :: k1`, `co :: k1 ~ k2`, `co2:: ty ~r ty'`, produces @co' :: (ty |> co) ~r ty' It is not only a utility function, but it saves allocation when co is a GRefl coercion.

mkCoherenceRightCo :: HasDebugCallStack => Role -> Type -> CoercionN -> Coercion -> Coercion Source #

Given `ty :: k1`, `co :: k1 ~ k2`, `co2:: ty' ~r ty`, produces @co' :: ty' ~r (ty |> co) It is not only a utility function, but it saves allocation when co is a GRefl coercion.

mkKindCo :: Coercion -> Coercion Source #

Given `co :: (a :: k) ~ (b :: k')` produce `co' :: k ~ k'`.

castCoercionKind :: Coercion -> CoercionN -> CoercionN -> Coercion Source #

Creates a new coercion with both of its types casted by different casts `castCoercionKind g h1 h2`, where `g :: t1 ~r t2`, has type `(t1 |> h1) ~r (t2 |> h2)`. `h1` and `h2` must be nominal. It calls `coercionKindRole`, so it's quite inefficient (which `I` stands for) Use `castCoercionKind2` instead if `t1`, `t2`, and `r` are known beforehand.

castCoercionKind1 :: Coercion -> Role -> Type -> Type -> CoercionN -> Coercion Source #

`castCoercionKind1 g r t1 t2 h` = `coercionKind g r t1 t2 h h` That is, it's a specialised form of castCoercionKind, where the two kind coercions are identical `castCoercionKind1 g r t1 t2 h`, where `g :: t1 ~r t2`, has type `(t1 |> h) ~r (t2 |> h)`. `h` must be nominal. See Note [castCoercionKind1]

castCoercionKind2 :: Coercion -> Role -> Type -> Type -> CoercionN -> CoercionN -> Coercion Source #

Creates a new coercion with both of its types casted by different casts `castCoercionKind2 g r t1 t2 h1 h2`, where `g :: t1 ~r t2`, has type `(t1 |> h1) ~r (t2 |> h2)`. `h1` and `h2` must be nominal.

mkPrimEqPred :: Type -> Type -> Type Source #

Creates a primitive nominal type equality predicate. t1 ~# t2 Invariant: the types are not Coercions

mkReprPrimEqPred :: Type -> Type -> Type Source #

Creates a primitive representational type equality predicate. t1 ~R# t2 Invariant: the types are not Coercions

mkPrimEqPredRole :: Role -> Type -> Type -> PredType Source #

Makes a lifted equality predicate at the given role

mkNomPrimEqPred :: Kind -> Type -> Type -> Type Source #

Creates a primitive nominal type equality predicate with an explicit (but homogeneous) kind: (~#) k k ty1 ty2

## Decomposition

instNewTyCon_maybe :: TyCon -> [Type] -> Maybe (Type, Coercion) Source #

If `instNewTyCon_maybe T ts = Just (rep_ty, co)` then `co :: T ts ~R# rep_ty`

Checks for a newtype, and for being saturated

type NormaliseStepper ev = RecTcChecker -> TyCon -> [Type] -> NormaliseStepResult ev Source #

A function to check if we can reduce a type by one step. Used with `topNormaliseTypeX`.

data NormaliseStepResult ev Source #

The result of stepping in a normalisation function. See `topNormaliseTypeX`.

Constructors

NS_Done | Nothing more to do
NS_Abort | Utter failure. The outer function should fail too.
NS_Step RecTcChecker Type ev | We stepped, yielding new bits; ^ ev is evidence; Usually a co :: old type ~ new type

#### Instances

Instances details

Functor NormaliseStepResult Source # |
Instance details Defined in GHC.Core.Coercion Methods fmap :: (a -> b) -> NormaliseStepResult a -> NormaliseStepResult b Source # (<$) :: a -> NormaliseStepResult b -> NormaliseStepResult a Source #
Outputable ev => Outputable (NormaliseStepResult ev) Source # |
Instance details Defined in GHC.Core.Coercion Methods ppr :: NormaliseStepResult ev -> SDoc Source #

composeSteppers :: NormaliseStepper ev -> NormaliseStepper ev -> NormaliseStepper ev Source #

Try one stepper and then try the next, if the first doesn't make progress. So if it returns NS_Done, it means that both steppers are satisfied

unwrapNewTypeStepper :: NormaliseStepper Coercion Source #

A `NormaliseStepper` that unwraps newtypes, careful not to fall into a loop. If it would fall into a loop, it produces `NS_Abort`.

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

Sometimes we want to look through a `newtype` and get its associated coercion. This function strips off `newtype` layers enough to reveal something that isn't a `newtype`. Specifically, here's the invariant:

    topNormaliseNewType_maybe rec_nts ty = Just (co, ty')

then (a) `co : ty ~R ty'`. (b) ty' is not a newtype.

The function returns `Nothing` for non-`newtypes`, or unsaturated applications

This function does *not* look through type families, because it has no access to the type family environment. If you do have that at hand, consider to use topNormaliseType_maybe, which should be a drop-in replacement for topNormaliseNewType_maybe If topNormliseNewType_maybe ty = Just (co, ty'), then co : ty ~R ty'

topNormaliseTypeX :: NormaliseStepper ev -> (ev -> ev -> ev) -> Type -> Maybe (ev, Type) Source #

A general function for normalising the top-level of a type. It continues to use the provided `NormaliseStepper` until that function fails, and then this function returns. The roles of the coercions produced by the `NormaliseStepper` must all be the same, which is the role returned from the call to `topNormaliseTypeX`.

Typically ev is Coercion.

If topNormaliseTypeX step plus ty = Just (ev, ty') then ty ~ev1~ t1 ~ev2~ t2 ... ~evn~ ty' and ev = ev1 `plus` ev2 `plus` ... `plus` evn If it returns Nothing then no newtype unwrapping could happen

decomposeCo :: Arity -> Coercion -> Infinite Role -> [Coercion] Source #

This breaks a `Coercion` with type `T A B C ~ T D E F` into a list of `Coercion`s of kinds `A ~ D`, `B ~ E` and `E ~ F`. Hence:

    decomposeCo 3 c [r1, r2, r3] = [nth r1 0 c, nth r2 1 c, nth r3 2 c]

decomposeFunCo :: HasDebugCallStack => Coercion -> (CoercionN, Coercion, Coercion) Source #

decomposePiCos :: HasDebugCallStack => CoercionN -> Pair Type -> [Type] -> ([CoercionN], CoercionN) Source #

getCoVar_maybe :: Coercion -> Maybe CoVar Source #

Extract a covar, if possible. This check is dirty. Be ashamed of yourself. (It's dirty because it cares about the structure of a coercion, which is morally reprehensible.)

splitAppCo_maybe :: Coercion -> Maybe (Coercion, Coercion) Source #

Attempt to take a coercion application apart.

splitFunCo_maybe :: Coercion -> Maybe (Coercion, Coercion) Source #

splitForAllCo_maybe :: Coercion -> Maybe (TyCoVar, ForAllTyFlag, ForAllTyFlag, Coercion, Coercion) Source #

splitForAllCo_ty_maybe :: Coercion -> Maybe (TyVar, ForAllTyFlag, ForAllTyFlag, Coercion, Coercion) Source #

Like `splitForAllCo_maybe`, but only returns Just for tyvar binder

splitForAllCo_co_maybe :: Coercion -> Maybe (CoVar, ForAllTyFlag, ForAllTyFlag, Coercion, Coercion) Source #

Like `splitForAllCo_maybe`, but only returns Just for covar binder

tyConRole :: Role -> TyCon -> Int -> Role Source #

tyConRolesX :: Role -> TyCon -> Infinite Role Source #

tyConRolesRepresentational :: TyCon -> Infinite Role Source #

setNominalRole_maybe :: Role -> Coercion -> Maybe CoercionN Source #

Converts a coercion to be nominal, if possible. See Note [Role twiddling functions]

tyConRoleListX :: Role -> TyCon -> [Role] Source #

tyConRoleListRepresentational :: TyCon -> [Role] Source #

funRole :: Role -> FunSel -> Role Source #

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

isGReflCo :: Coercion -> Bool Source #

Tests if this coercion is obviously a generalized reflexive coercion. Guaranteed to work very quickly.

isReflCo :: Coercion -> Bool Source #

Tests if this coercion is obviously reflexive. Guaranteed to work very quickly. Sometimes a coercion can be reflexive, but not obviously so. c.f. `isReflexiveCo`

isReflCo_maybe :: Coercion -> Maybe (Type, Role) Source #

Returns the type coerced if this coercion is reflexive. Guaranteed to work very quickly. Sometimes a coercion can be reflexive, but not obviously so. c.f. `isReflexiveCo_maybe`

isGReflCo_maybe :: Coercion -> Maybe (Type, Role) Source #

Returns the type coerced if this coercion is a generalized reflexive coercion. Guaranteed to work very quickly.

isReflexiveCo :: Coercion -> Bool Source #

Slowly checks if the coercion is reflexive. Don't call this in a loop, as it walks over the entire coercion.

isReflexiveCo_maybe :: Coercion -> Maybe (Type, Role) Source #

Extracts the coerced type from a reflexive coercion. This potentially walks over the entire coercion, so avoid doing this in a loop.

isReflCoVar_maybe :: Var -> Maybe Coercion Source #

isGReflMCo :: MCoercion -> Bool Source #

Tests if this MCoercion is obviously generalized reflexive Guaranteed to work very quickly.

mkGReflLeftMCo :: Role -> Type -> MCoercionN -> Coercion Source #

mkGReflRightMCo :: Role -> Type -> MCoercionN -> Coercion Source #

mkCoherenceRightMCo :: Role -> Type -> MCoercionN -> Coercion -> Coercion Source #

Like `mkCoherenceRightCo`, but with an `MCoercion`

coToMCo :: Coercion -> MCoercion Source #

mkTransMCo :: MCoercion -> MCoercion -> MCoercion Source #

Compose two MCoercions via transitivity

mkTransMCoL :: MCoercion -> Coercion -> MCoercion Source #

mkTransMCoR :: Coercion -> MCoercion -> MCoercion Source #

mkCastTyMCo :: Type -> MCoercion -> Type Source #

Cast a type by an `MCoercion`

mkSymMCo :: MCoercion -> MCoercion Source #

Get the reverse of an `MCoercion`

mkFunResMCo :: Id -> MCoercionR -> MCoercionR Source #

mkPiMCos :: [Var] -> MCoercion -> MCoercion Source #

isReflMCo :: MCoercion -> Bool Source #

checkReflexiveMCo :: MCoercion -> MCoercion Source #

## Coercion variables

mkCoVar :: Name -> Type -> CoVar Source #

isCoVar :: Var -> Bool Source #

Is this a coercion variable? Satisfies ``isId` v ==> `isCoVar` v == not (`isNonCoVarId` v)`.

coVarName :: CoVar -> Name Source #

setCoVarName :: CoVar -> Name -> CoVar Source #

setCoVarUnique :: CoVar -> Unique -> CoVar Source #

## Free variables

tyCoVarsOfCo :: Coercion -> TyCoVarSet Source #

tyCoVarsOfCos :: [Coercion] -> TyCoVarSet Source #

coVarsOfCo :: Coercion -> CoVarSet Source #

tyCoFVsOfCo :: Coercion -> FV Source #

tyCoFVsOfCos :: [Coercion] -> FV Source #

tyCoVarsOfCoDSet :: Coercion -> DTyCoVarSet Source #

Get a deterministic set of the vars free in a coercion

coercionSize :: Coercion -> Int Source #

anyFreeVarsOfCo :: (TyCoVar -> Bool) -> Coercion -> Bool Source #

## Substitution

type CvSubstEnv = CoVarEnv Coercion Source #

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

emptyCvSubstEnv :: CvSubstEnv Source #

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

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

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

substCos :: HasDebugCallStack => Subst -> [Coercion] -> [Coercion] Source #

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

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

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

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

Coercion substitution, see `zipTvSubst`

substCoVarBndr :: HasDebugCallStack => Subst -> CoVar -> (Subst, CoVar) Source #

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

getCvSubstEnv :: Subst -> CvSubstEnv Source #

## Lifting

liftCoSubst :: HasDebugCallStack => Role -> LiftingContext -> Type -> Coercion Source #

`liftCoSubst role lc ty` produces a coercion (at role `role`) that coerces between `lc_left(ty)` and `lc_right(ty)`, where `lc_left` is a substitution mapping type variables to the left-hand types of the mapped coercions in `lc`, and similar for `lc_right`.

liftCoSubstTyVar :: LiftingContext -> Role -> TyVar -> Maybe Coercion Source #

liftCoSubstWith :: Role -> [TyCoVar] -> [Coercion] -> Type -> Coercion Source #

liftCoSubstWithEx :: Role -> [TyVar] -> [Coercion] -> [TyCoVar] -> [Type] -> (Type -> Coercion, [Type]) Source #

emptyLiftingContext :: InScopeSet -> LiftingContext Source #

extendLiftingContext Source #

Arguments

:: LiftingContext | original LC
-> TyCoVar | new variable to map...
-> Coercion | ...to this lifted version
-> LiftingContext |

Extend a lifting context with a new mapping.

extendLiftingContextAndInScope Source #

Arguments

:: LiftingContext | Original LC
-> TyCoVar | new variable to map...
-> Coercion | to this coercion
-> LiftingContext |

Extend a lifting context with a new mapping, and extend the in-scope set

liftCoSubstVarBndrUsing Source #

Arguments

:: (r -> CoercionN) | coercion getter
-> (LiftingContext -> Type -> r) | callback
-> LiftingContext |
-> TyCoVar |
-> (LiftingContext, TyCoVar, r) |

isMappedByLC :: TyCoVar -> LiftingContext -> Bool Source #

Is a var in the domain of a lifting context?

extendLiftingContextCvSubst :: LiftingContext -> CoVar -> Coercion -> LiftingContext Source #

Extend the substitution component of a lifting context with a new binding for a coercion variable. Used during coercion optimisation.

mkSubstLiftingContext :: Subst -> LiftingContext Source #

liftingContextSubst :: LiftingContext -> Subst Source #

zapLiftingContext :: LiftingContext -> LiftingContext Source #

Erase the environments in a lifting context

substForAllCoBndrUsingLC :: SwapFlag -> (Coercion -> Coercion) -> LiftingContext -> TyCoVar -> Coercion -> (LiftingContext, TyCoVar, Coercion) Source #

Like `substForAllCoBndr`, but works on a lifting context

lcLookupCoVar :: LiftingContext -> CoVar -> Maybe Coercion Source #

Lookup a `CoVar` in the substitution in a `LiftingContext`

lcInScopeSet :: LiftingContext -> InScopeSet Source #

Get the `InScopeSet` from a `LiftingContext`

type LiftCoEnv = VarEnv Coercion Source #

data LiftingContext Source #

Constructors

LC Subst LiftCoEnv |

#### Instances

Instances details

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

liftEnvSubstLeft :: Subst -> LiftCoEnv -> Subst Source #

liftEnvSubstRight :: Subst -> LiftCoEnv -> Subst Source #

substRightCo :: LiftingContext -> Coercion -> Coercion Source #

substLeftCo :: LiftingContext -> Coercion -> Coercion Source #

swapLiftCoEnv :: LiftCoEnv -> LiftCoEnv Source #

Apply "sym" to all coercions in a `LiftCoEnv`

lcSubstLeft :: LiftingContext -> Subst Source #

lcSubstRight :: LiftingContext -> Subst Source #

## Comparison

eqCoercion :: Coercion -> Coercion -> Bool Source #

Syntactic equality of coercions

eqCoercionX :: RnEnv2 -> Coercion -> Coercion -> Bool Source #

Compare two `Coercion`s, with respect to an RnEnv2

## Forcing evaluation of coercions

seqCo :: Coercion -> () Source #

# Pretty-printing

pprCo :: Coercion -> SDoc Source #

pprParendCo :: Coercion -> SDoc Source #

pprCoAxiom :: forall (br :: BranchFlag). CoAxiom br -> SDoc Source #

pprCoAxBranch :: TyCon -> CoAxBranch -> SDoc Source #

pprCoAxBranchLHS :: TyCon -> CoAxBranch -> SDoc Source #

pprCoAxBranchUser :: TyCon -> CoAxBranch -> SDoc Source #

tidyCoAxBndrsForUser :: TidyEnv -> [Var] -> (TidyEnv, [Var]) Source #

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

# Tidying

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

Tidy a Coercion

See Note [Strictness in tidyType and friends]

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

# Other

promoteCoercion :: HasDebugCallStack => Coercion -> CoercionN Source #

like mkKindCo, but aggressively & recursively optimizes to avoid using a KindCo constructor. The output role is nominal.

buildCoercion :: HasDebugCallStack => Type -> Type -> CoercionN Source #

Assuming that two types are the same, ignoring coercions, find a nominal coercion between the types. This is useful when optimizing transitivity over coercion applications, where splitting two AppCos might yield different kinds. See Note [EtaAppCo] in GHC.Core.Coercion.Opt.

multToCo :: Mult -> Coercion Source #

mkRuntimeRepCo :: HasDebugCallStack => Coercion -> Coercion Source #

Given a coercion `co :: (t1 :: TYPE r1) ~ (t2 :: TYPE r2)` produce a coercion `rep_co :: r1 ~ r2` But actually it is possible that co :: (t1 :: CONSTRAINT r1) ~ (t2 :: CONSTRAINT r2) or co :: (t1 :: TYPE r1) ~ (t2 :: CONSTRAINT r2) or co :: (t1 :: CONSTRAINT r1) ~ (t2 :: TYPE r2) See Note [mkRuntimeRepCo]

hasCoercionHoleTy :: Type -> Bool Source #

Is there a hetero-kind coercion hole in this type? (That is, a coercion hole with ch_hetero_kind=True.) See wrinkle (EIK2) of Note [Equalities with incompatible kinds] in GHC.Tc.Solver.Equality

hasCoercionHoleCo :: Coercion -> Bool Source #

Is there a hetero-kind coercion hole in this coercion?

hasThisCoercionHoleTy :: Type -> CoercionHole -> Bool Source #

setCoHoleType :: CoercionHole -> Type -> CoercionHole Source #

Set the type of a `CoercionHole`