[project @ 1997-07-05 03:02:04 by sof]
[ghc-hetmet.git] / ghc / compiler / hsSyn / HsBinds.lhs
index 0c167d6..e39e494 100644 (file)
@@ -17,9 +17,6 @@ IMP_Ubiq()
 IMPORT_DELOOPER(HsLoop)        ( pprMatches, pprGRHSsAndBinds,
                          Match, GRHSsAndBinds,
                          pprExpr, HsExpr )
-#else
-import {-# SOURCE #-} HsMatches ( pprMatches, Match, pprGRHSsAndBinds, GRHSsAndBinds )
-import {-# SOURCE #-} HsExpr    ( pprExpr, HsExpr )
 #endif
 
 import HsPragmas       ( GenPragmas, ClassOpPragmas )
@@ -39,6 +36,12 @@ import Bag
 import SrcLoc          ( SrcLoc{-instances-} )
 import TyVar           ( GenTyVar{-instances-} )
 import Unique          ( Unique {- instance Eq -} )
+
+#if __GLASGOW_HASKELL__ >= 202
+import {-# SOURCE #-} HsExpr    ( pprExpr, HsExpr )
+import {-# SOURCE #-} HsMatches ( pprMatches, Match, pprGRHSsAndBinds, GRHSsAndBinds )
+#endif
+
 \end{code}
 
 %************************************************************************
@@ -193,17 +196,17 @@ ppr_monobind sty (AndMonoBinds binds1 binds2)
       = ($$) (ppr_monobind sty binds1) (ppr_monobind sty binds2)
 
 ppr_monobind sty (PatMonoBind pat grhss_n_binds locn)
-      = hang (ppr sty pat) 4 (pprGRHSsAndBinds sty False grhss_n_binds)
+      = sep [ppr sty pat, nest 4 (pprGRHSsAndBinds sty False grhss_n_binds)]
 
 ppr_monobind sty (FunMonoBind fun inf matches locn)
       = pprMatches sty (False, ppr sty fun) matches
       -- ToDo: print infix if appropriate
 
 ppr_monobind sty (VarMonoBind name expr)
-      = hang (hsep [ppr sty name, equals]) 4 (pprExpr sty expr)
+      = sep [ppr sty name <+> equals, nest 4 (pprExpr sty expr)]
 
 ppr_monobind sty (CoreMonoBind name expr)
-      = hang (hsep [ppr sty name, equals]) 4 (ppr sty expr)
+      = sep [ppr sty name <+> equals, nest 4 (ppr sty expr)]
 
 ppr_monobind sty (AbsBinds tyvars dictvars exports val_binds)
      = ($$) (sep [ptext SLIT("AbsBinds"),
@@ -231,7 +234,7 @@ data Sig name
                SrcLoc
 
   | ClassOpSig name                    -- Selector name
-               name                    -- Default-method name
+               (Maybe name)            -- Default-method name (if any)
                (HsType name)
                SrcLoc
 
@@ -258,27 +261,25 @@ instance (NamedThing name, Outputable name) => Outputable (Sig name) where
 
 
 ppr_sig sty (Sig var ty _)
-      = hang (hsep [ppr sty var, ptext SLIT("::")])
-            4 (ppr sty ty)
+      = sep [ppr sty var <+> ptext SLIT("::"),
+            nest 4 (ppr sty ty)]
 
 ppr_sig sty (ClassOpSig var _ ty _)
-      = hang (hsep [ppr sty (getOccName var), ptext SLIT("::")])
-            4 (ppr sty ty)
+      = sep [ppr sty (getOccName var) <+> ptext SLIT("::"),
+            nest 4 (ppr sty ty)]
 
 ppr_sig sty (DeforestSig var _)
-      = hang (hsep [text "{-# DEFOREST", ppr sty var])
-                  4 (text "#-")
+      = hsep [text "{-# DEFOREST", ppr sty var, text "#-}"]
 
 ppr_sig sty (SpecSig var ty using _)
-      = hang (hsep [text "{-# SPECIALIZE", ppr sty var, ptext SLIT("::")])
-            4 (hsep [ppr sty ty, pp_using using, text "#-}"])
-
+      = sep [ hsep [text "{-# SPECIALIZE", ppr sty var, ptext SLIT("::")],
+             nest 4 (hsep [ppr sty ty, pp_using using, text "#-}"])
+       ]
       where
        pp_using Nothing   = empty
        pp_using (Just me) = hsep [char '=', ppr sty me]
 
 ppr_sig sty (InlineSig var _)
-
         = hsep [text "{-# INLINE", ppr sty var, text "#-}"]
 
 ppr_sig sty (MagicUnfoldingSig var str _)