[project @ 2001-08-16 10:25:21 by simonmar]
[ghc-hetmet.git] / ghc / compiler / hsSyn / HsDecls.lhs
index ebf82a7..6f06cd8 100644 (file)
@@ -26,14 +26,14 @@ module HsDecls (
 -- friends:
 import HsBinds         ( HsBinds, MonoBinds, Sig(..), FixitySig(..) )
 import HsExpr          ( HsExpr )
+import HsImpExp                ( ppr_var )
 import HsTypes
 import PprCore         ( pprCoreRule )
 import HsCore          ( UfExpr, UfBinder, HsIdInfo, pprHsIdInfo,
                          eq_ufBinders, eq_ufExpr, pprUfExpr 
                        )
 import CoreSyn         ( CoreRule(..) )
-import BasicTypes      ( NewOrData(..) )
-import Demand          ( StrictnessMark(..) )
+import BasicTypes      ( NewOrData(..), StrictnessMark(..) )
 import ForeignCall     ( CExportSpec, CCallSpec, DNCallSpec, CCallConv )
 
 -- others:
@@ -42,8 +42,11 @@ import FunDeps               ( pprFundeps )
 import Class           ( FunDep, DefMeth(..) )
 import CStrings                ( CLabelString )
 import Outputable      
+import Util            ( eqListBy )
 import SrcLoc          ( SrcLoc )
 import FastString
+
+import Maybe           ( isNothing, fromJust ) 
 \end{code}
 
 
@@ -454,7 +457,10 @@ instance (NamedThing name, Outputable name, Outputable pat)
              => Outputable (TyClDecl name pat) where
 
     ppr (IfaceSig {tcdName = var, tcdType = ty, tcdIdInfo = info})
-       = hsep [ppr var, dcolon, ppr ty, pprHsIdInfo info]
+       = getPprStyle $ \ sty ->
+          hsep [ if ifaceStyle sty then ppr var else ppr_var var,
+                 dcolon, ppr ty, pprHsIdInfo info
+               ]
 
     ppr (ForeignType {tcdName = tycon})
        = hsep [ptext SLIT("foreign import type dotnet"), ppr tycon]
@@ -485,8 +491,11 @@ instance (NamedThing name, Outputable name, Outputable pat)
       where
         top_matter  = ptext SLIT("class") <+> pp_decl_head context clas tyvars <+> pprFundeps fds
        ppr_sig sig = ppr sig <> semi
+
        pp_methods = getPprStyle $ \ sty ->
-                    if ifaceStyle sty then empty else ppr methods
+                    if ifaceStyle sty || isNothing methods
+                       then empty
+                       else ppr (fromJust methods)
         
 pp_decl_head :: Outputable name => HsContext name -> name -> [HsTyVarBndr name] -> SDoc
 pp_decl_head context thing tyvars = hsep [pprHsContext context, ppr thing, interppSP tyvars]
@@ -606,7 +615,7 @@ ppr_con_details con (VanillaCon tys)
   = ppr con <+> hsep (map (ppr_bang) tys)
 
 ppr_con_details con (RecCon fields)
-  = ppr con <+> braces (hsep (punctuate comma (map ppr_field fields)))
+  = ppr con <+> braces (sep (punctuate comma (map ppr_field fields)))
   where
     ppr_field (ns, ty) = hsep (map (ppr) ns) <+> 
                         dcolon <+>