- ppr sty (UserTyVar name) = ppr_hs_tyname sty name
- ppr sty (IfaceTyVar name kind) = ppCat [ppr_hs_tyname sty name, ppPStr SLIT("::"), ppr sty kind]
-
-
--- Here comes a rather gross hack.
--- We want to print data and class decls in interface files, from the original source
--- When we do, we want the type variables to come out with their original names, not
--- some new unique (or else interfaces wobble too much). So when we come to one of
--- these type variables we sneakily change the style to PprForUser!
-ppr_hs_tyname PprInterface tv_name = ppr PprForUser tv_name
-ppr_hs_tyname other_sty tv_name = ppr other_sty tv_name
-
-ppr_forall sty ctxt_prec [] [] ty
- = ppr_mono_ty sty ctxt_prec ty
-ppr_forall sty ctxt_prec tvs ctxt ty
- = ppSep [ppPStr SLIT("_forall_"), ppBracket (interppSP sty tvs),
- pprContext sty ctxt, ppPStr SLIT("=>"),
- pprHsType sty ty]
-
-pprContext :: (Outputable name) => PprStyle -> (Context name) -> Pretty
-pprContext sty [] = ppNil
-pprContext sty context
- = ppCat [ppCurlies (ppIntersperse pp'SP (map ppr_assert context))]
- where
- ppr_assert (clas, ty) = ppCat [ppr sty clas, ppr sty ty]
+ ppr (UserTyVar name) = ppr name
+ ppr (IfaceTyVar name kind) = hsep [ppr name, ptext SLIT("::"), ppr kind]
+
+pprForAll [] = empty
+pprForAll tvs = ptext SLIT("forall") <+> interppSP tvs <> ptext SLIT(".")
+
+pprContext :: (Outputable name) => Context name -> SDoc
+pprContext [] = empty
+pprContext context = parens (hsep (punctuate comma (map pprClassAssertion context))) <+> ptext SLIT("=>")
+
+pprClassAssertion :: (Outputable name) => ClassAssertion name -> SDoc
+pprClassAssertion (clas, tys)
+ = ppr clas <+> hsep (map ppr tys)