From: Ross Paterson Date: Thu, 4 May 2006 09:15:28 +0000 (+0000) Subject: use bracket in appendFile (like writeFile) X-Git-Tag: 2007-09-13~378 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=618e73291aa53c3531ad5912bd5e9f32741b040e;p=ghc-base.git use bracket in appendFile (like writeFile) --- diff --git a/System/IO.hs b/System/IO.hs index 201bb22..8982119 100644 --- a/System/IO.hs +++ b/System/IO.hs @@ -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'.