Fix some "warn-unused-do-bind" warnings where we want to ignore the value
[ghc-base.git] / GHC / IO / Handle.hs
index f436f15..1531b4a 100644 (file)
@@ -23,7 +23,7 @@ module GHC.IO.Handle (
  
    hFileSize, hSetFileSize, hIsEOF, hLookAhead,
    hSetBuffering, hSetBinaryMode, hSetEncoding,
-   hFlush, hDuplicate, hDuplicateTo,
+   hFlush, hFlushAll, hDuplicate, hDuplicateTo,
  
    hClose, hClose_help,
  
@@ -147,7 +147,7 @@ hSetFileSize handle size =
 hIsEOF :: Handle -> IO Bool
 hIsEOF handle =
   catch
-     (do hLookAhead handle; return False)
+     (hLookAhead handle >> return False)
      (\e -> if isEOFError e then return True else ioError e)
 
 -- ---------------------------------------------------------------------------
@@ -282,6 +282,26 @@ hSetEncoding hdl encoding = do
 hFlush :: Handle -> IO () 
 hFlush handle = wantWritableHandle "hFlush" handle flushWriteBuffer
 
+-- | The action 'hFlushAll' @hdl@ flushes all buffered data in @hdl@,
+-- including any buffered read data.  Buffered read data is flushed
+-- by seeking the file position back to the point before the bufferred
+-- data was read, and hence only works if @hdl@ is seekable (see
+-- 'hIsSeekable').
+--
+-- This operation may fail with:
+--
+--  * 'isFullError' if the device is full;
+--
+--  * 'isPermissionError' if a system resource limit would be exceeded.
+--    It is unspecified whether the characters in the buffer are discarded
+--    or retained under these circumstances;
+--
+--  * 'isIllegalOperation' if @hdl@ has buffered read data, and is not
+--    seekable.
+
+hFlushAll :: Handle -> IO () 
+hFlushAll handle = withHandle_ "hFlushAll" handle flushBuffer
+
 -- -----------------------------------------------------------------------------
 -- Repositioning Handles
 
@@ -648,7 +668,7 @@ dupHandleTo filepath h other_side
   case cast devTo of
     Nothing   -> ioe_dupHandlesNotCompatible h
     Just dev' -> do 
-      IODevice.dup2 dev dev'
+      _ <- IODevice.dup2 dev dev'
       FileHandle _ m <- dupHandle_ dev' filepath other_side h_ mb_finalizer
       takeMVar m