-- > 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'.
-- -----------------------------------------------------------------------------
-- Utils
+#ifdef __GLASGOW_HASKELL__
-- Copied here to avoid recursive dependency with Control.Exception
bracket
:: IO a -- ^ computation to run first (\"acquire resource\")
after a
return r
)
+#endif