-instance (NamedThing name, Outputable name) => Outputable (ConDecl name) where
-
- ppr sty (ConDecl con tys _)
- = ppCat [ppr sty (getOccName con), ppInterleave ppNil (map (ppr_bang sty) tys)]
-
- -- We print ConOpDecls in prefix form in interface files
- ppr PprInterface (ConOpDecl ty1 op ty2 _)
- = ppCat [ppr PprInterface (getOccName op), ppr_bang PprInterface ty1, ppr_bang PprInterface ty2]
- ppr sty (ConOpDecl ty1 op ty2 _)
- = ppCat [ppr_bang sty ty1, ppr sty (getOccName op), ppr_bang sty ty2]
-
- ppr sty (NewConDecl con ty _)
- = ppCat [ppr sty (getOccName con), pprParendHsType sty ty]
- ppr sty (RecConDecl con fields _)
- = ppCat [ppr sty (getOccName con),
- ppCurlies (ppInterleave pp'SP (map pp_field fields))
- ]
- where
- pp_field (n, ty) = ppCat [ppr sty n, ppPStr SLIT("::"), ppr_bang sty ty]
-
-ppr_bang sty (Banged ty) = ppBeside (ppChar '!') (pprParendHsType sty ty)
-ppr_bang sty (Unbanged ty) = pprParendHsType sty ty
-\end{code}
-
-%************************************************************************
-%* *
-\subsection[ClassDecl]{A class declaration}
-%* *
-%************************************************************************
-
-\begin{code}
-data ClassDecl tyvar uvar name pat
- = ClassDecl (Context name) -- context...
- name -- name of the class
- (HsTyVar name) -- the class type variable
- [Sig name] -- methods' signatures
- (MonoBinds tyvar uvar name pat) -- default methods
- (ClassPragmas name)
- SrcLoc
+instance (Outputable name) => Outputable (ConDecl name) where
+ ppr (ConDecl con tvs cxt con_details loc)
+ = sep [pprForAll tvs, pprContext cxt, ppr_con_details con con_details]
+
+ppr_con_details con (InfixCon ty1 ty2)
+ = hsep [ppr_bang ty1, ppr con, ppr_bang ty2]
+
+ppr_con_details con (VanillaCon tys)
+ = ppr con <+> hsep (map (ppr_bang) tys)
+
+ppr_con_details con (NewCon ty Nothing)
+ = ppr con <+> pprParendHsType ty
+
+ppr_con_details con (NewCon ty (Just x))
+ = ppr con <+> braces pp_field
+ where
+ pp_field = ppr x <+> dcolon <+> pprParendHsType ty
+
+ppr_con_details con (RecCon fields)
+ = ppr con <+> braces (hsep (punctuate comma (map ppr_field fields)))
+ where
+ ppr_field (ns, ty) = hsep (map (ppr) ns) <+>
+ dcolon <+>
+ ppr_bang ty
+
+ppr_bang (Banged ty) = ptext SLIT("!") <> pprParendHsType ty
+ppr_bang (Unbanged ty) = pprParendHsType ty
+ppr_bang (Unpacked ty) = ptext SLIT("! !") <> pprParendHsType ty