-pprId exts id
- = hang (ppr_bndr id <+> dcolon) 2
- (pprType exts (GHC.idType id))
-
-pprType True ty = ppr ty
-pprType False ty = ppr (GHC.dropForAlls ty)
+pprId :: PrintExplicitForalls -> Var -> SDoc
+pprId pefas ident
+ = hang (ppr_bndr ident <+> dcolon)
+ 2 (pprTypeForUser pefas (GHC.idType ident))
+
+pprTypeForUser :: PrintExplicitForalls -> GHC.Type -> SDoc
+-- We do two things here.
+-- a) We tidy the type, regardless
+-- b) If PrintExplicitForAlls is True, we discard the foralls
+-- but we do so `deeply'
+-- Prime example: a class op might have type
+-- forall a. C a => forall b. Ord b => stuff
+-- Then we want to display
+-- (C a, Ord b) => stuff
+pprTypeForUser print_foralls ty
+ | print_foralls = ppr tidy_ty
+ | otherwise = ppr (mkPhiTy [p | (_tvs, ps) <- ctxt, p <- ps] ty')
+ where
+ tidy_ty = tidyTopType ty
+ (ctxt, ty') = tcMultiSplitSigmaTy tidy_ty