Add the function TypeRep.pprTypeApp, and use it
[ghc-hetmet.git] / compiler / types / TypeRep.lhs
index 6a9c609..cc8e4be 100644 (file)
@@ -15,7 +15,8 @@ module TypeRep (
        funTyCon,
 
        -- Pretty-printing
-       pprType, pprParendType, pprTyThingCategory, 
+       pprType, pprParendType, pprTypeApp,
+       pprTyThingCategory, 
        pprPred, pprTheta, pprForAll, pprThetaArrow, pprClassPred,
 
        -- Kinds
@@ -432,6 +433,9 @@ pprType, pprParendType :: Type -> SDoc
 pprType       ty = ppr_type TopPrec   ty
 pprParendType ty = ppr_type TyConPrec ty
 
+pprTypeApp :: SDoc -> [Type] -> SDoc
+pprTypeApp pp tys = hang pp 2 (sep (map pprParendType tys))
+
 ------------------
 pprPred :: PredType -> SDoc
 pprPred (ClassP cls tys) = pprClassPred cls tys
@@ -439,8 +443,7 @@ pprPred (IParam ip ty)   = ppr ip <> dcolon <> pprType ty
 pprPred (EqPred ty1 ty2) = sep [ppr ty1, nest 2 (ptext SLIT("~")), ppr ty2]
 
 pprClassPred :: Class -> [Type] -> SDoc
-pprClassPred clas tys = parenSymOcc (getOccName clas) (ppr clas) 
-                       <+> sep (map pprParendType tys)
+pprClassPred clas tys = pprTypeApp (parenSymOcc (getOccName clas) (ppr clas)) tys
 
 pprTheta :: ThetaType -> SDoc
 pprTheta theta = parens (sep (punctuate comma (map pprPred theta)))
@@ -520,8 +523,7 @@ ppr_tc_app p tc tys
   | isTupleTyCon tc && tyConArity tc == length tys
   = tupleParens (tupleTyConBoxity tc) (sep (punctuate comma (map pprType tys)))
   | otherwise
-  = maybeParen p TyConPrec $
-    ppr_tc tc <+> sep (map (ppr_type TyConPrec) tys)
+  = maybeParen p TyConPrec (pprTypeApp (ppr_tc tc) tys)
 
 ppr_tc :: TyCon -> SDoc
 ppr_tc tc = parenSymOcc (getOccName tc) (pp_nt_debug <> ppr tc)