make Control.Monad.Instances compilable by nhc98
[haskell-directory.git] / System / IO.hs
index 201bb22..6f0b017 100644 (file)
@@ -308,10 +308,8 @@ writeFile f txt = bracket (openFile f WriteMode) hClose
 -- > main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])
 
 appendFile      :: FilePath -> String -> IO ()
-appendFile name str = do
-    hdl <- openFile name AppendMode
-    hPutStr hdl str
-    hClose hdl
+appendFile f txt = bracket (openFile f AppendMode) hClose
+                          (\hdl -> hPutStr hdl txt)
 
 -- | The 'readLn' function combines 'getLine' and 'readIO'.
 
@@ -409,6 +407,7 @@ hSetBinaryMode _ _ = return ()
 -- -----------------------------------------------------------------------------
 -- Utils
 
+#ifdef __GLASGOW_HASKELL__
 -- Copied here to avoid recursive dependency with Control.Exception
 bracket 
        :: IO a         -- ^ computation to run first (\"acquire resource\")
@@ -424,3 +423,4 @@ bracket before after thing =
     after a
     return r
  )
+#endif