[project @ 1996-05-16 09:42:08 by partain]
[ghc-hetmet.git] / ghc / compiler / hsSyn / HsExpr.lhs
index 93aa0e3..65fd71e 100644 (file)
@@ -19,7 +19,7 @@ import HsTypes                ( PolyType )
 
 -- others:
 import Id              ( DictVar(..), GenId, Id(..) )
-import Name            ( isSymLexeme, pprSym )
+import Name            ( pprNonSym, pprSym )
 import Outputable      ( interppSP, interpp'SP, ifnotPprForUser )
 import PprType         ( pprGenType, pprParendGenType, GenType{-instance-} )
 import Pretty
@@ -57,8 +57,11 @@ data HsExpr tyvar uvar id pat
                (HsExpr tyvar uvar id pat)      -- right operand
 
   -- We preserve prefix negation and parenthesis for the precedence parser.
+  -- They are eventually removed by the type checker.
 
   | NegApp     (HsExpr tyvar uvar id pat)      -- negated expr
+               id                              -- the negate id
+
   | HsPar      (HsExpr tyvar uvar id pat)      -- parenthesised expr
 
   | SectionL   (HsExpr tyvar uvar id pat)      -- operand
@@ -194,8 +197,7 @@ instance (NamedThing id, Outputable id, Outputable pat,
 \end{code}
 
 \begin{code}
-pprExpr sty (HsVar v)
-  = (if (isSymLexeme v) then ppParens else id) (ppr sty v)
+pprExpr sty (HsVar v) = pprNonSym sty v
 
 pprExpr sty (HsLit    lit)   = ppr sty lit
 pprExpr sty (HsLitOut lit _) = ppr sty lit
@@ -205,7 +207,7 @@ pprExpr sty (HsLam match)
 
 pprExpr sty expr@(HsApp e1 e2)
   = let (fun, args) = collect_args expr [] in
-    ppHang (pprParendExpr sty fun) 4 (ppSep (map (pprParendExpr sty) args))
+    ppHang (pprExpr sty fun) 4 (ppSep (map (pprExpr sty) args))
   where
     collect_args (HsApp fun arg) args = collect_args fun (arg:args)
     collect_args fun            args = (fun, args)
@@ -215,16 +217,16 @@ pprExpr sty (OpApp e1 op e2)
       HsVar v -> pp_infixly v
       _              -> pp_prefixly
   where
-    pp_e1 = pprParendExpr sty e1
-    pp_e2 = pprParendExpr sty e2
+    pp_e1 = pprExpr sty e1
+    pp_e2 = pprExpr sty e2
 
     pp_prefixly
-      = ppHang (pprParendExpr sty op) 4 (ppSep [pp_e1, pp_e2])
+      = ppHang (pprExpr sty op) 4 (ppSep [pp_e1, pp_e2])
 
     pp_infixly v
       = ppSep [pp_e1, ppCat [pprSym sty v, pp_e2]]
 
-pprExpr sty (NegApp e)
+pprExpr sty (NegApp e _)
   = ppBeside (ppChar '-') (pprParendExpr sty e)
 
 pprExpr sty (HsPar e)
@@ -401,8 +403,8 @@ pp_rbinds sty thing rbinds
   = ppHang thing 4
        (ppBesides [ppChar '{', ppInterleave ppComma (map (pp_rbind sty) rbinds), ppChar '}'])
   where
-    pp_rbind sty (v, _, True{-pun-}) = ppr sty v
-    pp_rbind sty (v, e, _) = ppCat [ppr sty v, ppStr "<-", ppr sty e]
+    pp_rbind PprForUser (v, _, True) = ppr PprForUser v
+    pp_rbind sty        (v, e, _)    = ppCat [ppr sty v, ppStr "=", ppr sty e]
 \end{code}
 
 %************************************************************************