Print infix function definitions correctly in HsSyn
[ghc-hetmet.git] / compiler / hsSyn / HsBinds.lhs
index 41bbea9..c0f01a8 100644 (file)
@@ -17,7 +17,7 @@ import {-# SOURCE #-} HsExpr ( HsExpr, pprExpr, LHsExpr,
 import {-# SOURCE #-} HsPat  ( LPat )
 
 import HsTypes
-import PprCore
+import PprCore ()
 import Coercion
 import Type
 import Name
@@ -95,7 +95,7 @@ data HsBind id
                                -- Before renaming, and after typechecking, 
                                -- the field is unused; it's just an error thunk
 
-        fun_tick :: Maybe Int   -- This is the (optional) module-local tick number. 
+        fun_tick :: Maybe (Int,[id])   -- This is the (optional) module-local tick number. 
     }
 
   | PatBind {  -- The pattern is never a simple variable;
@@ -165,7 +165,7 @@ instance OutputableBndr id => Outputable (HsValBinds id) where
 pprValBindsForUser :: (OutputableBndr id1, OutputableBndr id2)
                   => LHsBinds id1 -> [LSig id2] -> SDoc
 pprValBindsForUser binds sigs
-  = vcat (map snd (sort_by_loc decls))
+  = pprDeeperList vcat (map snd (sort_by_loc decls))
   where
 
     decls :: [(SrcSpan, SDoc)]
@@ -177,7 +177,7 @@ pprValBindsForUser binds sigs
 pprLHsBinds :: OutputableBndr id => LHsBinds id -> SDoc
 pprLHsBinds binds 
   | isEmptyLHsBinds binds = empty
-  | otherwise = lbrace <+> vcat (map ppr (bagToList binds)) <+> rbrace
+  | otherwise = lbrace <+> pprDeeperList vcat (map ppr (bagToList binds)) <+> rbrace
 
 ------------
 emptyLocalBinds :: HsLocalBinds a
@@ -242,14 +242,13 @@ ppr_monobind :: OutputableBndr id => HsBind id -> SDoc
 
 ppr_monobind (PatBind { pat_lhs = pat, pat_rhs = grhss })      = pprPatBind pat grhss
 ppr_monobind (VarBind { var_id = var, var_rhs = rhs })         = ppr var <+> equals <+> pprExpr (unLoc rhs)
-ppr_monobind (FunBind { fun_id = fun, 
+ppr_monobind (FunBind { fun_id = fun, fun_infix = inf,
                        fun_matches = matches,
                        fun_tick = tick }) = 
                           (case tick of 
                              Nothing -> empty
                              Just t  -> text "-- tick id = " <> ppr t
-                          ) $$ pprFunBind (unLoc fun) matches
-      -- ToDo: print infix if appropriate
+                          ) $$ pprFunBind (unLoc fun) inf matches
 
 ppr_monobind (AbsBinds { abs_tvs = tyvars, abs_dicts = dictvars, 
                         abs_exports = exports, abs_binds = val_binds })
@@ -292,7 +291,7 @@ data IPBind id
        (LHsExpr id)
 
 instance (OutputableBndr id) => Outputable (HsIPBinds id) where
-  ppr (IPBinds bs ds) = vcat (map ppr bs) 
+  ppr (IPBinds bs ds) = pprDeeperList vcat (map ppr bs) 
                        $$ pprLHsBinds ds
 
 instance (OutputableBndr id) => Outputable (IPBind id) where
@@ -319,10 +318,10 @@ data HsWrapper
   | WpCo Coercion              -- A cast:  [] `cast` co
                                -- Guaranteedn not the identity coercion
 
-  | WpApp Var                  -- [] x; the xi are dicts or coercions
-  | WpTyApp Type               -- [] t
-  | WpLam Id                   -- \x. []; the xi are dicts or coercions
-  | WpTyLam TyVar              -- \a. []
+  | WpApp Var                  -- [] d         the 'd' is a type-class dictionary
+  | WpTyApp Type               -- [] t         the 't' is a type or corecion
+  | WpLam Id                   -- \d. []       the 'd' is a type-class dictionary
+  | WpTyLam TyVar              -- \a. []       the 'a' is a type or coercion variable
 
        -- Non-empty bindings, so that the identity coercion
        -- is always exactly WpHole
@@ -546,3 +545,4 @@ pprPrag :: Outputable id => id -> LPrag -> SDoc
 pprPrag var (L _ (InlinePrag inl))         = ppr inl <+> ppr var
 pprPrag var (L _ (SpecPrag expr ty _ inl)) = pprSpec var ty inl
 \end{code}
+