checkForInjectivityConflicts :: FamInstEnvs -> FamInst -> TcM ()
  -- see Note [Verifying injectivity annotation] in FamInstEnv, check 1B1.
checkForInjectivityConflicts instEnvs famInst
    | isTypeFamilyTyCon tycon   -- as opposed to data family tycon
    , Injective inj <- tyConInjectivityInfo tycon
    = let conflicts = lookupFamInstEnvInjectivityConflicts inj instEnvs famInst in
      reportConflictingInjectivityErrs tycon conflicts (coAxiomSingleBranch (fi_axiom famInst))

    | otherwise
    = return ()

    where tycon = famInstTyCon famInst

-- | Check whether a new open type family equation can be added without
-- violating injectivity annotation supplied by the user. Returns True when
-- this is possible and False if adding this equation would violate injectivity
-- annotation. This looks only at the one equation; it does not look for
-- interaction between equations. Use checkForInjectivityConflicts for that.
-- Does checks (2)-(4) of Note [Verifying injectivity annotation] in FamInstEnv.
checkForInjectivityConflicts :: FamInstEnvs -> FamInst -> TcM ()
checkForInjectivityConflicts instEnvs famInst
    | isTypeFamilyTyCon tycon   -- as opposed to data family tycon
    , Injective inj <- tyConInjectivityInfo tycon
    = let conflicts = lookupFamInstEnvInjectivityConflicts inj instEnvs famInst in
      reportConflictingInjectivityErrs tycon conflicts (coAxiomSingleBranch (fi_axiom famInst))

    | otherwise
    = return ()

    where tycon = famInstTyCon famInst

-- | Check whether a new open type family equation can be added without
-- violating injectivity annotation supplied by the user. Returns True when
-- this is possible and False if adding this equation would violate injectivity
-- annotation. This looks only at the one equation; it does not look for
-- interaction between equations. Use checkForInjectivityConflicts for that.
-- Does checks (2)-(4) of Note [Verifying injectivity annotation] in FamInstEnv.
checkForInjectivityConflicts instEnvs famInst
    | isTypeFamilyTyCon tycon   -- as opposed to data family tycon
    , Injective inj <- tyConInjectivityInfo tycon
    = let conflicts = lookupFamInstEnvInjectivityConflicts inj instEnvs famInst in
      reportConflictingInjectivityErrs tycon conflicts (coAxiomSingleBranch (fi_axiom famInst))

    | otherwise
    = return ()

    where tycon = famInstTyCon famInst

-- | Check whether a new open type family equation can be added without
-- violating injectivity annotation supplied by the user. Returns True when
-- this is possible and False if adding this equation would violate injectivity
-- annotation. This looks only at the one equation; it does not look for
-- interaction between equations. Use checkForInjectivityConflicts for that.
-- Does checks (2)-(4) of Note [Verifying injectivity annotation] in FamInstEnv.