projects
/
haskell-directory.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9856777
)
use bracket in appendFile (like writeFile)
author
Ross Paterson
<ross@soi.city.ac.uk>
Thu, 4 May 2006 09:15:28 +0000
(09:15 +0000)
committer
Ross Paterson
<ross@soi.city.ac.uk>
Thu, 4 May 2006 09:15:28 +0000
(09:15 +0000)
System/IO.hs
patch
|
blob
|
history
diff --git
a/System/IO.hs
b/System/IO.hs
index
201bb22
..
8982119
100644
(file)
--- 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'.