X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypes%2FType.lhs;h=fd817956d23356001bbb09a08291ae30696a8a14;hb=ff5ae6ab8ed907dcf6adc810791b756bab827ab3;hp=cdc54a1b7afc90ab144842d570600fccaffd9086;hpb=380512de6eef0cbb17431d9e64007a9320914e23;p=ghc-hetmet.git diff --git a/compiler/types/Type.lhs b/compiler/types/Type.lhs index cdc54a1..fd81795 100644 --- a/compiler/types/Type.lhs +++ b/compiler/types/Type.lhs @@ -55,7 +55,7 @@ module Type ( -- Source types predTypeRep, mkPredTy, mkPredTys, - tyConOrigHead, + tyConOrigHead, pprSourceTyCon, -- Newtypes splitRecNewType_maybe, newTyConInstRhs, @@ -92,10 +92,10 @@ 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, + pprType, pprParendType, pprTypeApp, pprTyThingCategory, pprForAll, pprPred, pprTheta, pprThetaArrow, pprClassPred, pprKind, pprParendKind ) where @@ -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,16 @@ 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. For example +-- e.g. data T [a] = ... +-- In that case we want to print `T [a]', where T is the family TyCon +pprSourceTyCon tycon + | Just (repTyCon, tys) <- tyConFamInst_maybe tycon + = ppr $ repTyCon `TyConApp` tys -- can't be FunTyCon + | otherwise + = ppr tycon \end{code} @@ -1313,6 +1322,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