CoAxiom

ghc-7.10.3: The GHC API

Safe Haskell | None
Language | Haskell2010

CoAxiom

Description

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

Synopsis

- data Branched
- data Unbranched
- type BranchIndex = Int
- data BranchList a br where
  - FirstBranch :: a -> BranchList a br
  - NextBranch :: a -> BranchList a br -> BranchList a Branched
- toBranchList :: [a] -> BranchList a Branched
- fromBranchList :: BranchList a br -> [a]
- toBranchedList :: BranchList a br -> BranchList a Branched
- toUnbranchedList :: BranchList a br -> BranchList a Unbranched
- brListLength :: BranchList a br -> Int
- brListNth :: BranchList a br -> BranchIndex -> a
- brListMap :: (a -> b) -> BranchList a br -> [b]
- brListFoldr :: (a -> b -> b) -> b -> BranchList a br -> b
- brListMapM :: Monad m => (a -> m b) -> BranchList a br -> m [b]
- brListFoldlM_ :: forall a b m br. Monad m => (a -> b -> m a) -> a -> BranchList b br -> m ()
- brListZipWith :: (a -> b -> c) -> BranchList a br1 -> BranchList b br2 -> [c]
- data CoAxiom br = CoAxiom {
  - co_ax_unique :: Unique
  - co_ax_name :: Name
  - co_ax_role :: Role
  - co_ax_tc :: TyCon
  - co_ax_branches :: BranchList CoAxBranch br
  - co_ax_implicit :: Bool
  }
- data CoAxBranch = CoAxBranch {
  - cab_loc :: SrcSpan
  - cab_tvs :: [TyVar]
  - cab_roles :: [Role]
  - cab_lhs :: [Type]
  - cab_rhs :: Type
  - cab_incomps :: [CoAxBranch]
  }
- toBranchedAxiom :: CoAxiom br -> CoAxiom Branched
- toUnbranchedAxiom :: CoAxiom br -> CoAxiom Unbranched
- coAxiomName :: CoAxiom br -> Name
- coAxiomArity :: CoAxiom br -> BranchIndex -> Arity
- coAxiomBranches :: CoAxiom br -> BranchList CoAxBranch br
- coAxiomTyCon :: CoAxiom br -> TyCon
- isImplicitCoAxiom :: CoAxiom br -> Bool
- coAxiomNumPats :: CoAxiom br -> Int
- coAxiomNthBranch :: CoAxiom br -> BranchIndex -> CoAxBranch
- coAxiomSingleBranch_maybe :: CoAxiom br -> Maybe CoAxBranch
- coAxiomRole :: CoAxiom br -> Role
- coAxiomSingleBranch :: CoAxiom Unbranched -> CoAxBranch
- coAxBranchTyVars :: CoAxBranch -> [TyVar]
- 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 = CoAxiomRule {
  - coaxrName :: FastString
  - coaxrTypeArity :: Int
  - coaxrAsmpRoles :: [Role]
  - coaxrRole :: Role
  - coaxrProves :: [Type] -> [Eqn] -> Maybe Eqn
  }
- type Eqn = Pair Type
- data BuiltInSynFamily = BuiltInSynFamily {
  - sfMatchFam :: [Type] -> Maybe (CoAxiomRule, [Type], Type)
  - sfInteractTop :: [Type] -> Type -> [Eqn]
  - sfInteractInert :: [Type] -> Type -> [Type] -> Type -> [Eqn]
  }
- trivialBuiltInFamily :: BuiltInSynFamily

# Documentation

data Branched

data Unbranched

type BranchIndex = Int

data BranchList a br where

Constructors

FirstBranch :: a -> BranchList a br |
NextBranch :: a -> BranchList a br -> BranchList a Branched |

Instances

Outputable a => Outputable (BranchList a br) |

toBranchList :: [a] -> BranchList a Branched

fromBranchList :: BranchList a br -> [a]

toBranchedList :: BranchList a br -> BranchList a Branched

toUnbranchedList :: BranchList a br -> BranchList a Unbranched

brListLength :: BranchList a br -> Int

brListNth :: BranchList a br -> BranchIndex -> a

brListMap :: (a -> b) -> BranchList a br -> [b]

brListFoldr :: (a -> b -> b) -> b -> BranchList a br -> b

brListMapM :: Monad m => (a -> m b) -> BranchList a br -> m [b]

brListFoldlM_ :: forall a b m br. Monad m => (a -> b -> m a) -> a -> BranchList b br -> m ()

brListZipWith :: (a -> b -> c) -> BranchList a br1 -> BranchList b br2 -> [c]

data CoAxiom br

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 :: BranchList CoAxBranch br co_ax_implicit :: Bool

Instances

Eq (CoAxiom br) |
Typeable * br => Data (CoAxiom br) |
Ord (CoAxiom br) |
Outputable (CoAxiom br) |
Uniquable (CoAxiom br) |
NamedThing (CoAxiom br) |

data CoAxBranch

Constructors

CoAxBranch |
Fields cab_loc :: SrcSpan cab_tvs :: [TyVar] cab_roles :: [Role] cab_lhs :: [Type] cab_rhs :: Type cab_incomps :: [CoAxBranch]

toBranchedAxiom :: CoAxiom br -> CoAxiom Branched

toUnbranchedAxiom :: CoAxiom br -> CoAxiom Unbranched

coAxiomName :: CoAxiom br -> Name

coAxiomArity :: CoAxiom br -> BranchIndex -> Arity

coAxiomBranches :: CoAxiom br -> BranchList CoAxBranch br

coAxiomTyCon :: CoAxiom br -> TyCon

isImplicitCoAxiom :: CoAxiom br -> Bool

coAxiomNumPats :: CoAxiom br -> Int

coAxiomNthBranch :: CoAxiom br -> BranchIndex -> CoAxBranch

coAxiomSingleBranch_maybe :: CoAxiom br -> Maybe CoAxBranch

coAxiomRole :: CoAxiom br -> Role

coAxiomSingleBranch :: CoAxiom Unbranched -> CoAxBranch

coAxBranchTyVars :: CoAxBranch -> [TyVar]

coAxBranchRoles :: CoAxBranch -> [Role]

coAxBranchLHS :: CoAxBranch -> [Type]

coAxBranchRHS :: CoAxBranch -> Type

coAxBranchSpan :: CoAxBranch -> SrcSpan

coAxBranchIncomps :: CoAxBranch -> [CoAxBranch]

placeHolderIncomps :: [CoAxBranch]

data Role

Constructors

Nominal |
Representational |
Phantom |

Instances

Eq Role |
Data Role |
Outputable Role |
Binary Role |

fsFromRole :: Role -> FastString

data CoAxiomRule

For now, we work only with nominal equality.

Constructors

CoAxiomRule |
Fields coaxrName :: FastString coaxrTypeArity :: Int coaxrAsmpRoles :: [Role] coaxrRole :: Role coaxrProves :: [Type] -> [Eqn] -> Maybe Eqn coaxrProves returns `Nothing` when it doesn't like the supplied arguments. When this happens in a coercion that means that the coercion is ill-formed, and Core Lint checks for that.

Instances

Eq CoAxiomRule |
Data CoAxiomRule |
Ord CoAxiomRule |
Outputable CoAxiomRule |
Uniquable CoAxiomRule |

type Eqn = Pair Type

A more explicit representation for `t1 ~ t2`.

data BuiltInSynFamily

Constructors

BuiltInSynFamily |
Fields sfMatchFam :: [Type] -> Maybe (CoAxiomRule, [Type], Type) sfInteractTop :: [Type] -> Type -> [Eqn] sfInteractInert :: [Type] -> Type -> [Type] -> Type -> [Eqn]

trivialBuiltInFamily :: BuiltInSynFamily