checkTauTvUpdate: take synonym families into account
[ghc-hetmet.git] / compiler / types / Type.lhs
index cdc54a1..147f546 100644 (file)
@@ -55,7 +55,7 @@ module Type (
 
        -- Source types
        predTypeRep, mkPredTy, mkPredTys,
-       tyConOrigHead,
+       tyConOrigHead, pprSourceTyCon,
 
        -- Newtypes
        splitRecNewType_maybe, newTyConInstRhs,
@@ -92,7 +92,7 @@ module Type (
 
        -- Performing substitution on types
        substTy, substTys, substTyWith, substTheta, 
-       substPred, substTyVar, substTyVarBndr, deShadowTy, lookupTyVar,
+       substPred, substTyVar, substTyVars, substTyVarBndr, deShadowTy, lookupTyVar,
 
        -- Pretty-printing
        pprType, pprParendType, pprTyThingCategory, pprForAll,
@@ -411,7 +411,6 @@ splitNewTyConApp_maybe other              = Nothing
 newTyConInstRhs :: TyCon -> [Type] -> Type
 newTyConInstRhs tycon tys =
     let (tvs, ty) = newTyConRhs tycon in substTyWith tvs tys ty
-
 \end{code}
 
 
@@ -610,6 +609,13 @@ tyConOrigHead :: TyCon -> (TyCon, [Type])
 tyConOrigHead tycon = case tyConFamInst_maybe tycon of
                        Nothing      -> (tycon, mkTyVarTys (tyConTyVars tycon))
                        Just famInst -> famInst
+
+-- Pretty prints a tycon, using the family instance in case of a
+-- representation tycon.
+pprSourceTyCon tycon | Just (repTyCon, tys) <- tyConFamInst_maybe tycon =
+  ppr $ repTyCon `TyConApp` tys               -- can't be FunTyCon
+                     | otherwise                                        =
+  ppr tycon
 \end{code}
 
 
@@ -1313,6 +1319,9 @@ substTyVar subst@(TvSubst in_scope env) tv
                Just ty -> ty   -- See Note [Apply Once]
     } 
 
+substTyVars :: TvSubst -> [TyVar] -> [Type]
+substTyVars subst tvs = map (substTyVar subst) tvs
+
 lookupTyVar :: TvSubst -> TyVar  -> Maybe Type
        -- See Note [Extending the TvSubst]
 lookupTyVar (TvSubst in_scope env) tv = lookupVarEnv env tv