[project @ 2001-06-11 12:24:51 by simonpj]
[ghc-hetmet.git] / ghc / compiler / hsSyn / HsBinds.lhs
index 0d91edf..4050a2e 100644 (file)
@@ -10,8 +10,9 @@ module HsBinds where
 
 #include "HsVersions.h"
 
-import {-# SOURCE #-} HsExpr    ( pprExpr, HsExpr )
-import {-# SOURCE #-} HsMatches ( pprMatches, Match, pprGRHSs, GRHSs )
+import {-# SOURCE #-} HsExpr ( HsExpr, pprExpr,
+                              Match,  pprFunBind,
+                              GRHSs,  pprPatBind )
 
 -- friends:
 import HsTypes         ( HsType )
@@ -74,16 +75,18 @@ instance (Outputable pat, Outputable id) =>
 
 ppr_binds EmptyBinds = empty
 ppr_binds (ThenBinds binds1 binds2)
-     = ($$) (ppr_binds binds1) (ppr_binds binds2)
+    = ppr_binds binds1 $$ ppr_binds binds2
 ppr_binds (MonoBind bind sigs is_rec)
-     = vcat [ifNotPprForUser (ptext rec_str),
+     = vcat [ppr_isrec,
             vcat (map ppr sigs),
             ppr bind
        ]
      where
-       rec_str = case is_rec of
-                  Recursive    -> SLIT("{- rec -}")
-                  NonRecursive -> SLIT("{- nonrec -}")
+       ppr_isrec = getPprStyle $ \ sty -> 
+                  if userStyle sty then empty else
+                  case is_rec of
+                       Recursive    -> ptext SLIT("{- rec -}")
+                       NonRecursive -> ptext SLIT("{- nonrec -}")
 \end{code}
 
 %************************************************************************
@@ -198,11 +201,8 @@ ppr_monobind EmptyMonoBinds = empty
 ppr_monobind (AndMonoBinds binds1 binds2)
       = ppr_monobind binds1 $$ ppr_monobind binds2
 
-ppr_monobind (PatMonoBind pat grhss locn)
-      = sep [ppr pat, nest 4 (pprGRHSs False grhss)]
-
-ppr_monobind (FunMonoBind fun inf matches locn)
-      = pprMatches (False, ppr fun) matches
+ppr_monobind (PatMonoBind pat grhss locn)      = pprPatBind pat grhss
+ppr_monobind (FunMonoBind fun inf matches locn) = pprFunBind fun matches
       -- ToDo: print infix if appropriate
 
 ppr_monobind (VarMonoBind name expr)
@@ -238,9 +238,9 @@ data Sig name
                (HsType name)
                SrcLoc
 
-  | ClassOpSig name                    -- Selector name
-                (Maybe (DefMeth name)) -- Nothing for source-file class signatures
-                                       -- Gives DefMeth info for interface files sigs
+  | ClassOpSig name            -- Selector name
+                (DefMeth name) -- Default-method info
+                               -- See "THE NAMING STORY" in HsDecls
                (HsType name)
                SrcLoc
 
@@ -338,15 +338,9 @@ ppr_sig (ClassOpSig var dm ty _)
       = sep [ppr var <+> pp_dm <+> dcolon, nest 4 (ppr ty)]
       where
        pp_dm = case dm of 
-                 Just (DefMeth _) -> equals    -- Default method indicator
-                 Just GenDefMeth  -> semi      -- Generic method indicator
-                 Just NoDefMeth   -> empty     -- No Method at all
-                 -- Not convinced this is right...
-                 -- Not used in interface file output hopefully
-                 -- but needed for ddump-rn ??
-                 other            -> dot
-                                  -- empty     -- No method at all
-
+                 DefMeth _  -> equals  -- Default method indicator
+                 GenDefMeth -> semi    -- Generic method indicator
+                 NoDefMeth  -> empty   -- No Method at all
 
 ppr_sig (SpecSig var ty _)
       = sep [ hsep [text "{-# SPECIALIZE", ppr var, dcolon],
@@ -383,10 +377,10 @@ eqHsSig (InlineSig n1 _ _)   (InlineSig n2 _ _)   = n1 == n2
 eqHsSig (NoInlineSig n1 _ _) (NoInlineSig n2 _ _) = n1 == n2
 
 eqHsSig (SpecInstSig ty1 _)  (SpecInstSig ty2 _)  = ty1 == ty2
-eqHsSig (SpecSig n1 ty1 _)   (SpecSig n2 ty2 _) 
-  = -- may have many specialisations for one value;
+eqHsSig (SpecSig n1 ty1 _)   (SpecSig n2 ty2 _)   =
+    -- may have many specialisations for one value;
     -- but not ones that are exactly the same...
     (n1 == n2) && (ty1 == ty2)
 
-eqHsSig other_1 other_2 = False
+eqHsSig _other1 _other2 = False
 \end{code}