ghc-8.2.2: The GHC API

Safe HaskellNone
LanguageHaskell2010

FamInst

Contents

Synopsis

Documentation

checkFamInstConsistency :: [Module] -> [Module] -> TcM TcGblEnv Source #

Check family instance consistency, given:

  1. The list of all modules transitively imported by us which define a family instance (these are the ones we have to check for consistency), and
  2. The list of modules which we directly imported (these specify the sets of family instance defining modules which are already known to be consistent).

See Note [Checking family instance consistency] for more details, and Note [The type family instance consistency story] for the big picture.

This function doesn't check ALL instances for consistency, only ones that aren't involved in recursive knot-tying loops; see Note [Don't check hs-boot type family instances too early]. It returns a modified TcGblEnv that has saved the instances that need to be checked later; use checkRecFamInstConsistency to check those.

tcLookupDataFamInst :: FamInstEnvs -> TyCon -> [TcType] -> (TyCon, [TcType], Coercion) Source #

Like tcLookupDataFamInst_maybe, but returns the arguments back if there is no data family to unwrap. Returns a Representational coercion

tcLookupDataFamInst_maybe :: FamInstEnvs -> TyCon -> [TcType] -> Maybe (TyCon, [TcType], Coercion) Source #

Converts a data family type (eg F [a]) to its representation type (eg FList a) and returns a coercion between the two: co :: F [a] ~R FList a.

tcInstNewTyCon_maybe :: TyCon -> [TcType] -> Maybe (TcType, TcCoercion) Source #

If co :: T ts ~ rep_ty then:

instNewTyCon_maybe T ts = Just (rep_ty, co)

Checks for a newtype, and for being saturated Just like Coercion.instNewTyCon_maybe, but returns a TcCoercion

tcTopNormaliseNewTypeTF_maybe :: FamInstEnvs -> GlobalRdrEnv -> Type -> Maybe ((Bag GlobalRdrElt, TcCoercion), Type) Source #

tcTopNormaliseNewTypeTF_maybe gets rid of top-level newtypes, potentially looking through newtype instances.

It is only used by the type inference engine (specifically, when solving representational equality), and hence it is careful to unwrap only if the relevant data constructor is in scope. That's why it get a GlobalRdrEnv argument.

It is careful not to unwrap data/newtype instances if it can't continue unwrapping. Such care is necessary for proper error messages.

It does not look through type families. It does not normalise arguments to a tycon.

If the result is Just (rep_ty, (co, gres), rep_ty), then co : ty ~R rep_ty gres are the GREs for the data constructors that had to be in scope

checkRecFamInstConsistency :: TyCon -> TcM () Source #

Given a TyCon that has been incorporated into the type environment (the knot is tied), if it is a type family, check that all deferred instances for it are consistent. See Note [Don't check hs-boot type family instances too early]

Injectivity

makeInjectivityErrors Source #

Arguments

:: CoAxiom br

Type family for which we generate errors

-> CoAxBranch

Currently checked equation (represented by axiom)

-> [Bool]

Injectivity annotation

-> [CoAxBranch]

List of injectivity conflicts

-> [(SDoc, SrcSpan)] 

Build a list of injectivity errors together with their source locations.