Interruptible FFI calls with pthread_kill and CancelSynchronousIO. v4
[ghc-hetmet.git] / compiler / hsSyn / HsDecls.lhs
index dc4bac7..fd6d3bb 100644 (file)
@@ -221,16 +221,26 @@ instance OutputableBndr name => Outputable (HsGroup name) where
                   hs_fords  = foreign_decls,
                   hs_defds  = default_decls,
                   hs_ruleds = rule_decls })
-       = vcat [ppr_ds fix_decls, ppr_ds default_decls, 
-               ppr_ds deprec_decls, ppr_ds ann_decls,
-               ppr_ds rule_decls,
-               ppr val_decls,
-               ppr_ds tycl_decls, ppr_ds inst_decls,
-                ppr_ds deriv_decls,
-               ppr_ds foreign_decls]
+       = vcat_mb empty 
+            [ppr_ds fix_decls, ppr_ds default_decls, 
+            ppr_ds deprec_decls, ppr_ds ann_decls,
+            ppr_ds rule_decls,
+            if isEmptyValBinds val_decls 
+                then Nothing 
+                else Just (ppr val_decls),
+            ppr_ds tycl_decls, ppr_ds inst_decls,
+             ppr_ds deriv_decls,
+            ppr_ds foreign_decls]
        where
-         ppr_ds [] = empty
-         ppr_ds ds = blankLine $$ vcat (map ppr ds)
+          ppr_ds :: Outputable a => [a] -> Maybe SDoc
+         ppr_ds [] = Nothing
+         ppr_ds ds = Just (vcat (map ppr ds))
+
+          vcat_mb :: SDoc -> [Maybe SDoc] -> SDoc
+         -- Concatenate vertically with white-space between non-blanks
+          vcat_mb _    []             = empty
+          vcat_mb gap (Nothing : ds) = vcat_mb gap ds
+          vcat_mb gap (Just d  : ds) = gap $$ d $$ vcat_mb blankLine ds
 
 data SpliceDecl id 
   = SpliceDecl                 -- Top level splice
@@ -627,6 +637,7 @@ instance OutputableBndr name
         top_matter    =     ptext (sLit "class") 
                        <+> pp_decl_head (unLoc context) lclas tyvars Nothing
                        <+> pprFundeps (map unLoc fds)
+        ppr_semi :: Outputable a => a -> SDoc
        ppr_semi decl = ppr decl <> semi
 
 pp_decl_head :: OutputableBndr name
@@ -886,7 +897,7 @@ data ForeignImport = -- import of a C entity
                     --  * `Safety' is irrelevant for `CLabel' and `CWrapper'
                     --
                     CImport  CCallConv       -- ccall or stdcall
-                             Safety          -- safe or unsafe
+                             Safety          -- interruptible, safe or unsafe
                              FastString      -- name of C header
                              CImportSpec     -- details of the C entity
   deriving (Data, Typeable)