[project @ 2005-12-19 09:48:14 by simonpj]
[ghc-hetmet.git] / ghc / compiler / hsSyn / HsExpr.lhs
index 7327436..86c4190 100644 (file)
@@ -14,7 +14,7 @@ import HsPat          ( LPat )
 import HsLit           ( HsLit(..), HsOverLit )
 import HsTypes         ( LHsType, PostTcType )
 import HsImpExp                ( isOperator, pprHsVar )
-import HsBinds         ( HsBindGroup, DictBinds )
+import HsBinds         ( HsLocalBinds, DictBinds, isEmptyLocalBinds )
 
 -- others:
 import Type            ( Type, pprParendType )
@@ -104,9 +104,6 @@ data HsExpr id
                Fixity          -- Renamer adds fixity; bottom until then
                (LHsExpr id)    -- right operand
 
-  -- We preserve prefix negation and parenthesis for the precedence parser.
-  -- They are eventually removed by the type checker.
-
   | NegApp     (LHsExpr id)    -- negated expr
                (SyntaxExpr id) -- Name of 'negate'
 
@@ -124,7 +121,7 @@ data HsExpr id
                (LHsExpr id)    --  then part
                (LHsExpr id)    --  else part
 
-  | HsLet      [HsBindGroup id] -- let(rec)
+  | HsLet      (HsLocalBinds id) -- let(rec)
                (LHsExpr  id)
 
   | HsDo       (HsStmtContext Name)    -- The parameterisation is unimportant
@@ -153,7 +150,7 @@ data HsExpr id
 
        -- Record construction
   | RecordCon  (Located id)            -- The constructor.  After type checking
-                                       -- it's the *worker* Id of the constructor
+                                       -- it's the dataConWrapId of the constructor
                PostTcExpr              -- Data con Id applied to type args
                (HsRecordBinds id)
 
@@ -277,8 +274,8 @@ pprExpr :: OutputableBndr id => HsExpr id -> SDoc
 
 pprExpr  e = pprDeeper (ppr_expr e)
 
-pprBinds :: OutputableBndr id => [HsBindGroup id] -> SDoc
-pprBinds b = pprDeeper (vcat (map ppr b))
+pprBinds :: OutputableBndr id => HsLocalBinds id -> SDoc
+pprBinds b = pprDeeper (ppr b)
 
 ppr_lexpr :: OutputableBndr id => LHsExpr id -> SDoc
 ppr_lexpr e = ppr_expr (unLoc e)
@@ -322,7 +319,7 @@ ppr_expr (SectionL expr op)
 
     pp_prefixly = hang (hsep [text " \\ x_ ->", ppr op])
                       4 (hsep [pp_expr, ptext SLIT("x_ )")])
-    pp_infixly v = parens (sep [pp_expr, ppr v])
+    pp_infixly v = parens (sep [pp_expr, pprInfix v])
 
 ppr_expr (SectionR op expr)
   = case unLoc op of
@@ -334,7 +331,7 @@ ppr_expr (SectionR op expr)
     pp_prefixly = hang (hsep [text "( \\ x_ ->", ppr op, ptext SLIT("x_")])
                       4 ((<>) pp_expr rparen)
     pp_infixly v
-      = parens (sep [ppr v, pp_expr])
+      = parens (sep [pprInfix v, pp_expr])
 
 ppr_expr (HsLam matches) 
   = pprMatches LambdaExpr matches
@@ -531,7 +528,7 @@ The legal constructors for commands are:
                (HsCmd id)      --  else part
                SrcLoc
 
-  | HsLet      (HsBinds id)    -- let(rec)
+  | HsLet      (HsLocalBinds id)       -- let(rec)
                (HsCmd  id)
 
   | HsDo       (HsStmtContext Name)    -- The parameterisation is unimportant
@@ -622,7 +619,7 @@ hsLMatchPats (L _ (Match pats _ _)) = pats
 -- GRHSs are used both for pattern bindings and for Matches
 data GRHSs id  
   = GRHSs [LGRHS id]           -- Guarded RHSs
-         [HsBindGroup id]      -- The where clause
+         (HsLocalBinds id)     -- The where clause
 
 type LGRHS id = Located (GRHS id)
 
@@ -666,7 +663,7 @@ pprGRHSs :: OutputableBndr id => HsMatchContext id -> GRHSs id -> SDoc
 pprGRHSs ctxt (GRHSs grhss binds)
   = vcat (map (pprGRHS ctxt . unLoc) grhss)
     $$
-    (if null binds then empty
+    (if isEmptyLocalBinds binds then empty
      else text "where" $$ nest 4 (pprBinds binds))
 
 pprGRHS :: OutputableBndr id => HsMatchContext id -> GRHS id -> SDoc
@@ -703,10 +700,10 @@ data Stmt id
                (SyntaxExpr id)         -- The (>>) operator
                PostTcType              -- Element type of the RHS (used for arrows)
 
-  | LetStmt    [HsBindGroup id]
+  | LetStmt    (HsLocalBinds id)       
 
        -- ParStmts only occur in a list comprehension
-  | ParStmt    [([LStmt id], [id])]    -- After remaing, the ids are the binders
+  | ParStmt    [([LStmt id], [id])]    -- After renaming, the ids are the binders
                                        -- bound by the stmts and used subsequently
 
        -- Recursive statement (see Note [RecStmt] below)