projects
/
ghc-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
43b264a
)
redefine writeFile and appendFile using withFile
author
Ross Paterson
<ross@soi.city.ac.uk>
Tue, 7 Nov 2006 14:03:59 +0000
(14:03 +0000)
committer
Ross Paterson
<ross@soi.city.ac.uk>
Tue, 7 Nov 2006 14:03:59 +0000
(14:03 +0000)
System/IO.hs
patch
|
blob
|
history
diff --git
a/System/IO.hs
b/System/IO.hs
index
a7552f5
..
f45e51d
100644
(file)
--- a/
System/IO.hs
+++ b/
System/IO.hs
@@
-299,8
+299,7
@@
readFile name = openFile name ReadMode >>= hGetContents
-- | The computation 'writeFile' @file str@ function writes the string @str@,
-- to the file @file@.
writeFile :: FilePath -> String -> IO ()
-- | The computation 'writeFile' @file str@ function writes the string @str@,
-- to the file @file@.
writeFile :: FilePath -> String -> IO ()
-writeFile f txt = bracket (openFile f WriteMode) hClose
- (\hdl -> hPutStr hdl txt)
+writeFile f txt = withFile f WriteMode (\ hdl -> hPutStr hdl txt)
-- | The computation 'appendFile' @file str@ function appends the string @str@,
-- to the file @file@.
-- | The computation 'appendFile' @file str@ function appends the string @str@,
-- to the file @file@.
@@
-312,8
+311,7
@@
writeFile f txt = bracket (openFile f WriteMode) hClose
-- > main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])
appendFile :: FilePath -> String -> IO ()
-- > main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])
appendFile :: FilePath -> String -> IO ()
-appendFile f txt = bracket (openFile f AppendMode) hClose
- (\hdl -> hPutStr hdl txt)
+appendFile f txt = withFile f AppendMode (\ hdl -> hPutStr hdl txt)
-- | The 'readLn' function combines 'getLine' and 'readIO'.
-- | The 'readLn' function combines 'getLine' and 'readIO'.