base-4.18.1.0: Basic libraries

Copyright | (c) The University of Glasgow 1994-2001
License | see libraries/base/LICENSE
Maintainer | libraries@haskell.org
Stability | internal
Portability | non-portable
Safe Haskell | Trustworthy
Language | Haskell2010

GHC.IO.Handle.Internals

Description

This module defines the basic operations on I/O "handles". All of the operations defined here are independent of the underlying device.

Synopsis

- withHandle :: String -> Handle -> (Handle__ -> IO (Handle__, a)) -> IO a
- withHandle' :: String -> Handle -> MVar Handle__ -> (Handle__ -> IO (Handle__, a)) -> IO a
- withHandle_ :: String -> Handle -> (Handle__ -> IO a) -> IO a
- withHandle__' :: String -> Handle -> MVar Handle__ -> (Handle__ -> IO Handle__) -> IO ()
- withHandle_' :: String -> Handle -> MVar Handle__ -> (Handle__ -> IO a) -> IO a
- withAllHandles__ :: String -> Handle -> (Handle__ -> IO Handle__) -> IO ()
- wantWritableHandle :: String -> Handle -> (Handle__ -> IO a) -> IO a
- wantReadableHandle :: String -> Handle -> (Handle__ -> IO (Handle__, a)) -> IO a
- wantReadableHandle_ :: String -> Handle -> (Handle__ -> IO a) -> IO a
- wantSeekableHandle :: String -> Handle -> (Handle__ -> IO a) -> IO a
- mkHandle :: (RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) => dev -> FilePath -> HandleType -> Bool -> Maybe TextEncoding -> NewlineMode -> Maybe HandleFinalizer -> Maybe (MVar Handle__) -> IO Handle
- mkFileHandle :: (RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) => dev -> FilePath -> IOMode -> Maybe TextEncoding -> NewlineMode -> IO Handle
- mkFileHandleNoFinalizer :: (RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) => dev -> FilePath -> IOMode -> Maybe TextEncoding -> NewlineMode -> IO Handle
- mkDuplexHandle :: (RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) => dev -> FilePath -> Maybe TextEncoding -> NewlineMode -> IO Handle
- mkDuplexHandleNoFinalizer :: (RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) => dev -> FilePath -> Maybe TextEncoding -> NewlineMode -> IO Handle
- addHandleFinalizer :: Handle -> HandleFinalizer -> IO ()
- openTextEncoding :: Maybe TextEncoding -> HandleType -> (forall es ds. Maybe (TextEncoder es) -> Maybe (TextDecoder ds) -> IO a) -> IO a
- closeTextCodecs :: Handle__ -> IO ()
- initBufferState :: HandleType -> BufferState
- dEFAULT_CHAR_BUFFER_SIZE :: Int
- flushBuffer :: Handle__ -> IO ()
- flushWriteBuffer :: Handle__ -> IO ()
- flushCharReadBuffer :: Handle__ -> IO ()
- flushCharBuffer :: Handle__ -> IO ()
- flushByteReadBuffer :: Handle__ -> IO ()
- flushByteWriteBuffer :: Handle__ -> IO ()
- readTextDevice :: Handle__ -> CharBuffer -> IO CharBuffer
- writeCharBuffer :: Handle__ -> CharBuffer -> IO ()
- readTextDeviceNonBlocking :: Handle__ -> CharBuffer -> IO CharBuffer
- decodeByteBuf :: Handle__ -> CharBuffer -> IO CharBuffer
- augmentIOError :: IOException -> String -> Handle -> IOException
- ioe_closedHandle :: IO a
- ioe_semiclosedHandle :: IO a
- ioe_EOF :: IO a
- ioe_notReadable :: IO a
- ioe_notWritable :: IO a
- ioe_finalizedHandle :: FilePath -> Handle__
- ioe_bufsiz :: Int -> IO a
- hClose_impl :: Handle -> IO ()
- hClose_help :: Handle__ -> IO (Handle__, Maybe SomeException)
- hLookAhead_ :: Handle__ -> IO Char
- type HandleFinalizer = FilePath -> MVar Handle__ -> IO ()
- handleFinalizer :: FilePath -> MVar Handle__ -> IO ()
- debugIO :: String -> IO ()
- traceIO :: String -> IO ()

# Documentation

withHandle :: String -> Handle -> (Handle__ -> IO (Handle__, a)) -> IO a Source #

withHandle' :: String -> Handle -> MVar Handle__ -> (Handle__ -> IO (Handle__, a)) -> IO a Source #

withHandle_ :: String -> Handle -> (Handle__ -> IO a) -> IO a Source #

withHandle__' :: String -> Handle -> MVar Handle__ -> (Handle__ -> IO Handle__) -> IO () Source #

withHandle_' :: String -> Handle -> MVar Handle__ -> (Handle__ -> IO a) -> IO a Source #

withAllHandles__ :: String -> Handle -> (Handle__ -> IO Handle__) -> IO () Source #

wantWritableHandle :: String -> Handle -> (Handle__ -> IO a) -> IO a Source #

wantReadableHandle :: String -> Handle -> (Handle__ -> IO (Handle__, a)) -> IO a Source #

wantReadableHandle_ :: String -> Handle -> (Handle__ -> IO a) -> IO a Source #

wantSeekableHandle :: String -> Handle -> (Handle__ -> IO a) -> IO a Source #

mkHandle :: (RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) => dev -> FilePath -> HandleType -> Bool -> Maybe TextEncoding -> NewlineMode -> Maybe HandleFinalizer -> Maybe (MVar Handle__) -> IO Handle Source #

mkFileHandle Source #

Arguments

:: (RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) |
=> dev | the underlying IO device, which must support `IODevice`, `BufferedIO` and `Typeable`
-> FilePath | a string describing the `Handle`, e.g. the file path for a file. Used in error messages.
-> IOMode |
-> Maybe TextEncoding |
-> NewlineMode |
-> IO Handle |

makes a new `Handle`

mkFileHandleNoFinalizer Source #

Arguments

:: (RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) |
=> dev | the underlying IO device, which must support `IODevice`, `BufferedIO` and `Typeable`
-> FilePath | a string describing the `Handle`, e.g. the file path for a file. Used in error messages.
-> IOMode |
-> Maybe TextEncoding |
-> NewlineMode |
-> IO Handle |

makes a new `Handle` without a finalizer.

mkDuplexHandle :: (RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) => dev -> FilePath -> Maybe TextEncoding -> NewlineMode -> IO Handle Source #

like `mkFileHandle`, except that a `Handle` is created with two independent buffers, one for reading and one for writing. Used for full-duplex streams, such as network sockets.

mkDuplexHandleNoFinalizer :: (RawIO dev, IODevice dev, BufferedIO dev, Typeable dev) => dev -> FilePath -> Maybe TextEncoding -> NewlineMode -> IO Handle Source #

like `mkFileHandle`, except that a `Handle` is created with two independent buffers, one for reading and one for writing. Used for full-duplex streams, such as network sockets.

addHandleFinalizer :: Handle -> HandleFinalizer -> IO () Source #

Add a finalizer to a `Handle`. Specifically, the finalizer will be added to the `MVar` of a file handle or the write-side `MVar` of a duplex handle. See Handle Finalizers for details.

openTextEncoding :: Maybe TextEncoding -> HandleType -> (forall es ds. Maybe (TextEncoder es) -> Maybe (TextDecoder ds) -> IO a) -> IO a Source #

closeTextCodecs :: Handle__ -> IO () Source #

initBufferState :: HandleType -> BufferState Source #

dEFAULT_CHAR_BUFFER_SIZE :: Int Source #

flushBuffer :: Handle__ -> IO () Source #

syncs the file with the buffer, including moving the file pointer backwards in the case of a read buffer. This can fail on a non-seekable read Handle.

flushWriteBuffer :: Handle__ -> IO () Source #

flushCharReadBuffer :: Handle__ -> IO () Source #

flushCharBuffer :: Handle__ -> IO () Source #

flushes the Char buffer only. Works on all Handles.

flushByteReadBuffer :: Handle__ -> IO () Source #

flushByteWriteBuffer :: Handle__ -> IO () Source #

readTextDevice :: Handle__ -> CharBuffer -> IO CharBuffer Source #

writeCharBuffer :: Handle__ -> CharBuffer -> IO () Source #

readTextDeviceNonBlocking :: Handle__ -> CharBuffer -> IO CharBuffer Source #

decodeByteBuf :: Handle__ -> CharBuffer -> IO CharBuffer Source #

augmentIOError :: IOException -> String -> Handle -> IOException Source #

ioe_closedHandle :: IO a Source #

ioe_semiclosedHandle :: IO a Source #

ioe_EOF :: IO a Source #

ioe_notReadable :: IO a Source #

ioe_notWritable :: IO a Source #

ioe_finalizedHandle :: FilePath -> Handle__ Source #

ioe_bufsiz :: Int -> IO a Source #

hClose_impl :: Handle -> IO () Source #

This function exists temporarily to avoid an unused import warning in `bytestring`.

hClose_help :: Handle__ -> IO (Handle__, Maybe SomeException) Source #

hLookAhead_ :: Handle__ -> IO Char Source #

type HandleFinalizer = FilePath -> MVar Handle__ -> IO () Source #

handleFinalizer :: FilePath -> MVar Handle__ -> IO () Source #

debugIO :: String -> IO () Source #

traceIO :: String -> IO () Source #