GHC.Core.Coercion.Axiom

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

Safe Haskell | Ignore
Language | GHC2021

GHC.Core.Coercion.Axiom

Contents

- Orphan instances

Description

Module for coercion axioms, used to represent type family instances and newtypes

Synopsis

- data BranchFlag
- type Branched = 'Branched
- type Unbranched = 'Unbranched
- type BranchIndex = Int
- newtype Branches (br :: BranchFlag) = MkBranches {
  - unMkBranches :: Array BranchIndex CoAxBranch
  }
- manyBranches :: [CoAxBranch] -> Branches Branched
- unbranched :: CoAxBranch -> Branches Unbranched
- fromBranches :: forall (br :: BranchFlag). Branches br -> [CoAxBranch]
- numBranches :: forall (br :: BranchFlag). Branches br -> Int
- mapAccumBranches :: forall (br :: BranchFlag). ([CoAxBranch] -> CoAxBranch -> CoAxBranch) -> Branches br -> Branches br
- data CoAxiom (br :: BranchFlag) = CoAxiom {
  - co_ax_unique :: Unique
  - co_ax_name :: Name
  - co_ax_role :: Role
  - co_ax_tc :: TyCon
  - co_ax_branches :: Branches br
  - co_ax_implicit :: Bool
  }
- data CoAxBranch = CoAxBranch {
  - cab_loc :: SrcSpan
  - cab_tvs :: [TyVar]
  - cab_eta_tvs :: [TyVar]
  - cab_cvs :: [CoVar]
  - cab_roles :: [Role]
  - cab_lhs :: [Type]
  - cab_rhs :: Type
  - cab_incomps :: [CoAxBranch]
  }
- toBranchedAxiom :: forall (br :: BranchFlag). CoAxiom br -> CoAxiom Branched
- toUnbranchedAxiom :: forall (br :: BranchFlag). CoAxiom br -> CoAxiom Unbranched
- coAxiomName :: forall (br :: BranchFlag). CoAxiom br -> Name
- coAxiomArity :: forall (br :: BranchFlag). CoAxiom br -> BranchIndex -> Arity
- coAxiomBranches :: forall (br :: BranchFlag). CoAxiom br -> Branches br
- coAxiomTyCon :: forall (br :: BranchFlag). CoAxiom br -> TyCon
- isImplicitCoAxiom :: forall (br :: BranchFlag). CoAxiom br -> Bool
- coAxiomNumPats :: forall (br :: BranchFlag). CoAxiom br -> Int
- coAxiomNthBranch :: forall (br :: BranchFlag). CoAxiom br -> BranchIndex -> CoAxBranch
- coAxiomSingleBranch_maybe :: forall (br :: BranchFlag). CoAxiom br -> Maybe CoAxBranch
- coAxiomRole :: forall (br :: BranchFlag). CoAxiom br -> Role
- coAxiomSingleBranch :: CoAxiom Unbranched -> CoAxBranch
- coAxBranchTyVars :: CoAxBranch -> [TyVar]
- coAxBranchCoVars :: CoAxBranch -> [CoVar]
- coAxBranchRoles :: CoAxBranch -> [Role]
- coAxBranchLHS :: CoAxBranch -> [Type]
- coAxBranchRHS :: CoAxBranch -> Type
- coAxBranchSpan :: CoAxBranch -> SrcSpan
- coAxBranchIncomps :: CoAxBranch -> [CoAxBranch]
- placeHolderIncomps :: [CoAxBranch]
- data Role
  - = Nominal
  - | Representational
  - | Phantom
- fsFromRole :: Role -> FastString
- data CoAxiomRule
  - = BuiltInFamRew BuiltInFamRewrite
  - | BuiltInFamInj BuiltInFamInjectivity
  - | BranchedAxiom (CoAxiom Branched) BranchIndex
  - | UnbranchedAxiom (CoAxiom Unbranched)
- data BuiltInFamRewrite = BIF_Rewrite {
  - bifrw_name :: FastString
  - bifrw_axr :: CoAxiomRule
  - bifrw_fam_tc :: TyCon
  - bifrw_arity :: Arity
  - bifrw_match :: [Type] -> Maybe ([Type], Type)
  - bifrw_proves :: [TypeEqn] -> Maybe TypeEqn
  }
- data BuiltInFamInjectivity = BIF_Interact {
  - bifinj_name :: FastString
  - bifinj_axr :: CoAxiomRule
  - bifinj_proves :: TypeEqn -> Maybe TypeEqn
  }
- type TypeEqn = Pair Type
- coAxiomRuleArgRoles :: CoAxiomRule -> [Role]
- coAxiomRuleRole :: CoAxiomRule -> Role
- coAxiomRuleBranch_maybe :: CoAxiomRule -> Maybe (TyCon, Role, CoAxBranch)
- isNewtypeAxiomRule_maybe :: CoAxiomRule -> Maybe (TyCon, CoAxBranch)
- data BuiltInSynFamily = BuiltInSynFamily {
  - sfMatchFam :: [BuiltInFamRewrite]
  - sfInteract :: [BuiltInFamInjectivity]
  }
- trivialBuiltInFamily :: BuiltInSynFamily

# Documentation

data BranchFlag #

type Branched = 'Branched #

type Unbranched = 'Unbranched #

type BranchIndex = Int #

newtype Branches (br :: BranchFlag) #

Constructors

MkBranches |
Fields unMkBranches :: Array BranchIndex CoAxBranch

manyBranches :: [CoAxBranch] -> Branches Branched #

unbranched :: CoAxBranch -> Branches Unbranched #

fromBranches :: forall (br :: BranchFlag). Branches br -> [CoAxBranch] #

numBranches :: forall (br :: BranchFlag). Branches br -> Int #

mapAccumBranches :: forall (br :: BranchFlag). ([CoAxBranch] -> CoAxBranch -> CoAxBranch) -> Branches br -> Branches br #

The `[CoAxBranch]` passed into the mapping function is a list of all previous branches, reversed

data CoAxiom (br :: BranchFlag) #

A `CoAxiom` is a "coercion constructor", i.e. a named equality axiom.

Constructors

CoAxiom |
Fields co_ax_unique :: Unique co_ax_name :: Name co_ax_role :: Role co_ax_tc :: TyCon co_ax_branches :: Branches br co_ax_implicit :: Bool

#### Instances

Instances details

Typeable br => Data (CoAxiom br) # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CoAxiom br -> c (CoAxiom br) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (CoAxiom br) # toConstr :: CoAxiom br -> Constr # dataTypeOf :: CoAxiom br -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (CoAxiom br)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (CoAxiom br)) # gmapT :: (forall b. Data b => b -> b) -> CoAxiom br -> CoAxiom br # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CoAxiom br -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CoAxiom br -> r # gmapQ :: (forall d. Data d => d -> u) -> CoAxiom br -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CoAxiom br -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CoAxiom br -> m (CoAxiom br) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CoAxiom br -> m (CoAxiom br) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CoAxiom br -> m (CoAxiom br) #
NamedThing (CoAxiom br) # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods getOccName :: CoAxiom br -> OccName # getName :: CoAxiom br -> Name #
Uniquable (CoAxiom br) # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods getUnique :: CoAxiom br -> Unique #
Outputable (CoAxiom br) # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods ppr :: CoAxiom br -> SDoc #
Eq (CoAxiom br) # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods (==) :: CoAxiom br -> CoAxiom br -> Bool # (/=) :: CoAxiom br -> CoAxiom br -> Bool #

data CoAxBranch #

A branch of a coercion axiom, which provides the evidence for unwrapping a newtype or a type-family reduction step using a single equation.

Constructors

CoAxBranch |
Fields cab_loc :: SrcSpan Location of the defining equation See Note [CoAxiom locations] cab_tvs :: [TyVar] Bound type variables; not necessarily fresh See Note [CoAxBranch type variables] cab_eta_tvs :: [TyVar] Eta-reduced tyvars cab_tvs and cab_lhs may be eta-reduced; see Note [Eta reduction for data families] cab_cvs :: [CoVar] Bound coercion variables Always empty, for now. See Note [Constraints in patterns] in GHC.Tc.TyCl cab_roles :: [Role] See Note [CoAxBranch roles] cab_lhs :: [Type] Type patterns to match against cab_rhs :: Type Right-hand side of the equality See Note [CoAxioms are homogeneous] cab_incomps :: [CoAxBranch] The previous incompatible branches See Note [Storing compatibility]

#### Instances

Instances details

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

toBranchedAxiom :: forall (br :: BranchFlag). CoAxiom br -> CoAxiom Branched #

toUnbranchedAxiom :: forall (br :: BranchFlag). CoAxiom br -> CoAxiom Unbranched #

coAxiomName :: forall (br :: BranchFlag). CoAxiom br -> Name #

coAxiomArity :: forall (br :: BranchFlag). CoAxiom br -> BranchIndex -> Arity #

coAxiomBranches :: forall (br :: BranchFlag). CoAxiom br -> Branches br #

coAxiomTyCon :: forall (br :: BranchFlag). CoAxiom br -> TyCon #

isImplicitCoAxiom :: forall (br :: BranchFlag). CoAxiom br -> Bool #

coAxiomNumPats :: forall (br :: BranchFlag). CoAxiom br -> Int #

coAxiomNthBranch :: forall (br :: BranchFlag). CoAxiom br -> BranchIndex -> CoAxBranch #

coAxiomSingleBranch_maybe :: forall (br :: BranchFlag). CoAxiom br -> Maybe CoAxBranch #

coAxiomRole :: forall (br :: BranchFlag). CoAxiom br -> Role #

coAxiomSingleBranch :: CoAxiom Unbranched -> CoAxBranch #

coAxBranchTyVars :: CoAxBranch -> [TyVar] #

coAxBranchCoVars :: CoAxBranch -> [CoVar] #

coAxBranchRoles :: CoAxBranch -> [Role] #

coAxBranchLHS :: CoAxBranch -> [Type] #

coAxBranchRHS :: CoAxBranch -> Type #

coAxBranchSpan :: CoAxBranch -> SrcSpan #

coAxBranchIncomps :: CoAxBranch -> [CoAxBranch] #

placeHolderIncomps :: [CoAxBranch] #

data Role #

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

NFData Role # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods rnf :: Role -> () #
Data Role # |
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 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Role # toConstr :: Role -> Constr # dataTypeOf :: Role -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Role) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Role) # gmapT :: (forall b. Data b => b -> b) -> Role -> Role # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Role -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Role -> r # gmapQ :: (forall d. Data d => d -> u) -> Role -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Role -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Role -> m Role # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Role -> m Role # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Role -> m Role #
Binary Role # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods put_ :: WriteBinHandle -> Role -> IO () # put :: WriteBinHandle -> Role -> IO (Bin Role) # get :: ReadBinHandle -> IO Role #
Outputable Role # |
Instance details Defined in GHC.Core.Coercion.Axiom Methods ppr :: Role -> SDoc #
Eq Role # |
Instance details Defined in Language.Haskell.Syntax.Basic Methods (==) :: Role -> Role -> Bool # (/=) :: Role -> Role -> Bool #
Ord Role # |
Instance details Defined in Language.Haskell.Syntax.Basic Methods compare :: Role -> Role -> Ordering # (<) :: Role -> Role -> Bool # (<=) :: Role -> Role -> Bool # (>) :: Role -> Role -> Bool # (>=) :: Role -> Role -> Bool # max :: Role -> Role -> Role # min :: Role -> Role -> Role #
type Anno (Maybe Role) # |
Instance details Defined in GHC.Hs.Decls type Anno (Maybe Role) = EpAnnCO

fsFromRole :: Role -> FastString #

data CoAxiomRule #

CoAxiomRule describes a built-in axiom, one that we assume to be true See Note [CoAxiomRule]

Constructors

BuiltInFamRew BuiltInFamRewrite |
BuiltInFamInj BuiltInFamInjectivity |
BranchedAxiom (CoAxiom Branched) BranchIndex |
UnbranchedAxiom (CoAxiom Unbranched) |

#### Instances

Instances details

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

data BuiltInFamRewrite #

Constructors

BIF_Rewrite |
Fields bifrw_name :: FastString bifrw_axr :: CoAxiomRule bifrw_fam_tc :: TyCon bifrw_arity :: Arity bifrw_match :: [Type] -> Maybe ([Type], Type) bifrw_proves :: [TypeEqn] -> Maybe TypeEqn

data BuiltInFamInjectivity #

Constructors

BIF_Interact |
Fields bifinj_name :: FastString bifinj_axr :: CoAxiomRule bifinj_proves :: TypeEqn -> Maybe TypeEqn Always unary: just one TypeEqn argument Returns `Nothing` when it doesn't like the supplied argument. When this happens in a coercion that means that the coercion is ill-formed, and Core Lint checks for that.

type TypeEqn = Pair Type #

A more explicit representation for `t1 ~ t2`.

coAxiomRuleArgRoles :: CoAxiomRule -> [Role] #

coAxiomRuleRole :: CoAxiomRule -> Role #

coAxiomRuleBranch_maybe :: CoAxiomRule -> Maybe (TyCon, Role, CoAxBranch) #

isNewtypeAxiomRule_maybe :: CoAxiomRule -> Maybe (TyCon, CoAxBranch) #

data BuiltInSynFamily #

Constructors

BuiltInSynFamily |
Fields sfMatchFam :: [BuiltInFamRewrite] sfInteract :: [BuiltInFamInjectivity]

trivialBuiltInFamily :: BuiltInSynFamily #

# Orphan instances

NFData Role # |
Instance details Methods rnf :: Role -> () #
Binary Role # |
Instance details Methods put_ :: WriteBinHandle -> Role -> IO () # put :: WriteBinHandle -> Role -> IO (Bin Role) # get :: ReadBinHandle -> IO Role #
Outputable Role # |
Instance details Methods ppr :: Role -> SDoc #