ghc-8.0.2: The GHC API

Safe Haskell | None
Language | Haskell2010

FamInstEnv

Contents

- CoAxioms

Synopsis

- data FamInst = FamInst {
  - fi_axiom :: CoAxiom Unbranched
  - fi_flavor :: FamFlavor
  - fi_fam :: Name
  - fi_tcs :: [Maybe Name]
  - fi_tvs :: [TyVar]
  - fi_cvs :: [CoVar]
  - fi_tys :: [Type]
  - fi_rhs :: Type
  }
- data FamFlavor
  - = SynFamilyInst
  - | DataFamilyInst TyCon
- famInstAxiom :: FamInst -> CoAxiom Unbranched
- famInstTyCon :: FamInst -> TyCon
- famInstRHS :: FamInst -> Type
- famInstsRepTyCons :: [FamInst] -> [TyCon]
- famInstRepTyCon_maybe :: FamInst -> Maybe TyCon
- dataFamInstRepTyCon :: FamInst -> TyCon
- pprFamInst :: FamInst -> SDoc
- pprFamInsts :: [FamInst] -> SDoc
- mkImportedFamInst :: Name -> [Maybe Name] -> CoAxiom Unbranched -> FamInst
- type FamInstEnvs = (FamInstEnv, FamInstEnv)
- type FamInstEnv = UniqFM FamilyInstEnv
- emptyFamInstEnv :: FamInstEnv
- emptyFamInstEnvs :: (FamInstEnv, FamInstEnv)
- extendFamInstEnv :: FamInstEnv -> FamInst -> FamInstEnv
- deleteFromFamInstEnv :: FamInstEnv -> FamInst -> FamInstEnv
- extendFamInstEnvList :: FamInstEnv -> [FamInst] -> FamInstEnv
- identicalFamInstHead :: FamInst -> FamInst -> Bool
- famInstEnvElts :: FamInstEnv -> [FamInst]
- familyInstances :: (FamInstEnv, FamInstEnv) -> TyCon -> [FamInst]
- mkCoAxBranch :: [TyVar] -> [CoVar] -> [Type] -> Type -> [Role] -> SrcSpan -> CoAxBranch
- mkBranchedCoAxiom :: Name -> TyCon -> [CoAxBranch] -> CoAxiom Branched
- mkUnbranchedCoAxiom :: Name -> TyCon -> CoAxBranch -> CoAxiom Unbranched
- mkSingleCoAxiom :: Role -> Name -> [TyVar] -> [CoVar] -> TyCon -> [Type] -> Type -> CoAxiom Unbranched
- mkNewTypeCoAxiom :: Name -> TyCon -> [TyVar] -> [Role] -> Type -> CoAxiom Unbranched
- data FamInstMatch = FamInstMatch {
  - fim_instance :: FamInst
  - fim_tys :: [Type]
  - fim_cos :: [Coercion]
  }
- lookupFamInstEnv :: FamInstEnvs -> TyCon -> [Type] -> [FamInstMatch]
- lookupFamInstEnvConflicts :: FamInstEnvs -> FamInst -> [FamInstMatch]
- lookupFamInstEnvByTyCon :: FamInstEnvs -> TyCon -> [FamInst]
- isDominatedBy :: CoAxBranch -> [CoAxBranch] -> Bool
- apartnessCheck :: [Type] -> CoAxBranch -> Bool
- data InjectivityCheckResult
  - = InjectivityAccepted
  - | InjectivityUnified CoAxBranch CoAxBranch
- lookupFamInstEnvInjectivityConflicts :: [Bool] -> FamInstEnvs -> FamInst -> [CoAxBranch]
- injectiveBranches :: [Bool] -> CoAxBranch -> CoAxBranch -> InjectivityCheckResult
- topNormaliseType :: FamInstEnvs -> Type -> Type
- topNormaliseType_maybe :: FamInstEnvs -> Type -> Maybe (Coercion, Type)
- normaliseType :: FamInstEnvs -> Role -> Type -> (Coercion, Type)
- normaliseTcApp :: FamInstEnvs -> Role -> TyCon -> [Type] -> (Coercion, Type)
- reduceTyFamApp_maybe :: FamInstEnvs -> Role -> TyCon -> [Type] -> Maybe (Coercion, Type)
- flattenTys :: InScopeSet -> [Type] -> [Type]

# Documentation

data FamInst Source #

Constructors

FamInst |
Fields fi_axiom :: CoAxiom Unbranched fi_flavor :: FamFlavor fi_fam :: Name fi_tcs :: [Maybe Name] fi_tvs :: [TyVar] fi_cvs :: [CoVar] fi_tys :: [Type] fi_rhs :: Type

Instances

Outputable FamInst # |
Methods ppr :: FamInst -> SDoc Source # pprPrec :: Rational -> FamInst -> SDoc Source #
NamedThing FamInst # |
Methods getOccName :: FamInst -> OccName Source # getName :: FamInst -> Name Source #

data FamFlavor Source #

Constructors

SynFamilyInst |
DataFamilyInst TyCon |

famInstAxiom :: FamInst -> CoAxiom Unbranched Source #

famInstTyCon :: FamInst -> TyCon Source #

famInstRHS :: FamInst -> Type Source #

famInstsRepTyCons :: [FamInst] -> [TyCon] Source #

famInstRepTyCon_maybe :: FamInst -> Maybe TyCon Source #

dataFamInstRepTyCon :: FamInst -> TyCon Source #

pprFamInst :: FamInst -> SDoc Source #

pprFamInsts :: [FamInst] -> SDoc Source #

mkImportedFamInst :: Name -> [Maybe Name] -> CoAxiom Unbranched -> FamInst Source #

type FamInstEnvs = (FamInstEnv, FamInstEnv) Source #

type FamInstEnv = UniqFM FamilyInstEnv Source #

emptyFamInstEnv :: FamInstEnv Source #

emptyFamInstEnvs :: (FamInstEnv, FamInstEnv) Source #

extendFamInstEnv :: FamInstEnv -> FamInst -> FamInstEnv Source #

deleteFromFamInstEnv :: FamInstEnv -> FamInst -> FamInstEnv Source #

extendFamInstEnvList :: FamInstEnv -> [FamInst] -> FamInstEnv Source #

identicalFamInstHead :: FamInst -> FamInst -> Bool Source #

True when the LHSs are identical Used for overriding in GHCi

famInstEnvElts :: FamInstEnv -> [FamInst] Source #

familyInstances :: (FamInstEnv, FamInstEnv) -> TyCon -> [FamInst] Source #

# CoAxioms

mkCoAxBranch :: [TyVar] -> [CoVar] -> [Type] -> Type -> [Role] -> SrcSpan -> CoAxBranch Source #

mkBranchedCoAxiom :: Name -> TyCon -> [CoAxBranch] -> CoAxiom Branched Source #

mkUnbranchedCoAxiom :: Name -> TyCon -> CoAxBranch -> CoAxiom Unbranched Source #

mkSingleCoAxiom :: Role -> Name -> [TyVar] -> [CoVar] -> TyCon -> [Type] -> Type -> CoAxiom Unbranched Source #

mkNewTypeCoAxiom :: Name -> TyCon -> [TyVar] -> [Role] -> Type -> CoAxiom Unbranched Source #

Create a coercion constructor (axiom) suitable for the given newtype `TyCon`. The `Name` should be that of a new coercion `CoAxiom`, the `TyVar`s the arguments expected by the `newtype` and the type the appropriate right hand side of the `newtype`, with the free variables a subset of those `TyVar`s.

data FamInstMatch Source #

Constructors

FamInstMatch |
Fields fim_instance :: FamInst fim_tys :: [Type] fim_cos :: [Coercion]

Instances

Outputable FamInstMatch # |
Methods ppr :: FamInstMatch -> SDoc Source # pprPrec :: Rational -> FamInstMatch -> SDoc Source #

lookupFamInstEnv :: FamInstEnvs -> TyCon -> [Type] -> [FamInstMatch] Source #

lookupFamInstEnvConflicts :: FamInstEnvs -> FamInst -> [FamInstMatch] Source #

lookupFamInstEnvByTyCon :: FamInstEnvs -> TyCon -> [FamInst] Source #

isDominatedBy :: CoAxBranch -> [CoAxBranch] -> Bool Source #

apartnessCheck Source #

Arguments

:: [Type] | flattened target arguments. Make sure they're flattened! See Note [Flattening]. (NB: This "flat" is a different "flat" than is used in TcFlatten.)
-> CoAxBranch | the candidate equation we wish to use Precondition: this matches the target
-> Bool | True = equation can fire

Do an apartness check, as described in the "Closed Type Families" paper (POPL '14). This should be used when determining if an equation (`CoAxBranch`) of a closed type family can be used to reduce a certain target type family application.

data InjectivityCheckResult Source #

Result of testing two type family equations for injectiviy.

Constructors

InjectivityAccepted | Either RHSs are distinct or unification of RHSs leads to unification of LHSs
InjectivityUnified CoAxBranch CoAxBranch | RHSs unify but LHSs don't unify under that substitution. Relevant for closed type families where equation after unification might be overlpapped (in which case it is OK if they don't unify). Constructor stores axioms after unification.

lookupFamInstEnvInjectivityConflicts :: [Bool] -> FamInstEnvs -> FamInst -> [CoAxBranch] Source #

Check whether an open type family equation can be added to already existing instance environment without causing conflicts with supplied injectivity annotations. Returns list of conflicting axioms (type instance declarations).

injectiveBranches :: [Bool] -> CoAxBranch -> CoAxBranch -> InjectivityCheckResult Source #

Check whether two type family axioms don't violate injectivity annotation.

topNormaliseType :: FamInstEnvs -> Type -> Type Source #

topNormaliseType_maybe :: FamInstEnvs -> Type -> Maybe (Coercion, Type) Source #

Get rid of *outermost* (or toplevel) * type function redex * data family redex * newtypes returning an appropriate Representational coercion. Specifically, if topNormaliseType_maybe env ty = Maybe (co, ty') then (a) co :: ty ~R ty' (b) ty' is not a newtype, and is not a type-family or data-family redex

However, ty' can be something like (Maybe (F ty)), where (F ty) is a redex.

Its a bit like Type.repType, but handles type families too

normaliseType :: FamInstEnvs -> Role -> Type -> (Coercion, Type) Source #

normaliseTcApp :: FamInstEnvs -> Role -> TyCon -> [Type] -> (Coercion, Type) Source #

reduceTyFamApp_maybe :: FamInstEnvs -> Role -> TyCon -> [Type] -> Maybe (Coercion, Type) Source #

flattenTys :: InScopeSet -> [Type] -> [Type] Source #