X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FIO.hs;h=f60ecadeeef24f913b0b500d86e9a75627ad0671;hb=41e8fba828acbae1751628af50849f5352b27873;hp=0a65c73bb1cdeaf53667653c27501137b15cba0e;hpb=759ab7bf5f374ae394d495b38b237c81d91557c2;p=ghc-base.git diff --git a/System/IO.hs b/System/IO.hs index 0a65c73..f60ecad 100644 --- a/System/IO.hs +++ b/System/IO.hs @@ -1,4 +1,5 @@ -{-# OPTIONS_GHC -XNoImplicitPrelude #-} +{-# LANGUAGE CPP, NoImplicitPrelude #-} + ----------------------------------------------------------------------------- -- | -- Module : System.IO @@ -244,13 +245,12 @@ import System.Posix.Types #ifdef __GLASGOW_HASKELL__ import GHC.Base -import GHC.Real import GHC.IO hiding ( onException ) import GHC.IO.IOMode import GHC.IO.Handle.FD import qualified GHC.IO.FD as FD import GHC.IO.Handle -import GHC.IO.Handle.Text ( hGetBufSome ) +import GHC.IO.Handle.Text ( hGetBufSome, hPutStrLn ) import GHC.IORef import GHC.IO.Exception ( userError ) import GHC.IO.Encoding @@ -326,8 +326,7 @@ putStr s = hPutStr stdout s -- | The same as 'putStr', but adds a newline character. putStrLn :: String -> IO () -putStrLn s = do putStr s - putChar '\n' +putStrLn s = hPutStrLn stdout s -- | The 'print' function outputs a value of any printable type to the -- standard output device. @@ -425,13 +424,6 @@ readIO s = case (do { (x,t) <- reads s ; hReady :: Handle -> IO Bool hReady h = hWaitForInput h 0 --- | The same as 'hPutStr', but adds a newline character. - -hPutStrLn :: Handle -> String -> IO () -hPutStrLn hndl str = do - hPutStr hndl str - hPutChar hndl '\n' - -- | Computation 'hPrint' @hdl t@ writes the string representation of @t@ -- given by the 'shows' function to the file or channel managed by @hdl@ -- and appends a newline. @@ -449,7 +441,9 @@ hPrint hdl = hPutStrLn hdl . show -- | @'withFile' name mode act@ opens a file using 'openFile' and passes -- the resulting handle to the computation @act@. The handle will be -- closed on exit from 'withFile', whether by normal termination or by --- raising an exception. +-- raising an exception. If closing the handle raises an exception, then +-- this exception will be raised by 'withFile' rather than any exception +-- raised by 'act'. withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile name mode = bracket (openFile name mode) hClose @@ -573,7 +567,7 @@ openTempFile' loc tmp_dir template binary mode = do else ioError (errnoToIOError loc errno Nothing (Just tmp_dir)) else do - (fD,fd_type) <- FD.mkFD (fromIntegral fd) ReadWriteMode Nothing{-no stat-} + (fD,fd_type) <- FD.mkFD fd ReadWriteMode Nothing{-no stat-} False{-is_socket-} True{-is_nonblock-}