[project @ 2001-08-16 10:25:21 by simonmar]
[ghc-hetmet.git] / ghc / compiler / hsSyn / HsDecls.lhs
index 6d1befb..6f06cd8 100644 (file)
@@ -26,6 +26,7 @@ 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,
@@ -44,6 +45,8 @@ 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]