- = do { result@(rep_tycon, rep_tys) <- tcLookupFamInst tycon tys
- ; let { tvs = map (Type.getTyVar
- "TcDeriv.tcLookupFamInstExact")
- rep_tys
- ; variable_only_subst = all Type.isTyVarTy rep_tys &&
- sizeVarSet (mkVarSet tvs) == length tvs
+ | not (isOpenTyCon tycon)
+ = return (tycon, tys)
+ | otherwise
+ = do { maybeFamInst <- tcLookupFamInst tycon tys
+ ; case maybeFamInst of
+ Nothing -> famInstNotFound tycon tys False
+ Just famInst@(_, rep_tys)
+ | not variable_only_subst -> famInstNotFound tycon tys True
+ | otherwise -> return famInst
+ where
+ tvs = map (Type.getTyVar
+ "TcDeriv.tcLookupFamInstExact")
+ rep_tys
+ variable_only_subst = all Type.isTyVarTy rep_tys &&
+ sizeVarSet (mkVarSet tvs) == length tvs