From 618e73291aa53c3531ad5912bd5e9f32741b040e Mon Sep 17 00:00:00 2001 From: Ross Paterson Date: Thu, 4 May 2006 09:15:28 +0000 Subject: [PATCH] use bracket in appendFile (like writeFile) --- System/IO.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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'. -- 1.7.10.4