| Copyright | (c) The University of Glasgow 2017 | 
|---|---|
| License | see libraries/base/LICENSE | 
| Maintainer | libraries@haskell.org | 
| Stability | internal | 
| Portability | non-portable | 
| Safe Haskell | Trustworthy | 
| Language | Haskell2010 | 
GHC.Internal.IO.StdHandles
Description
This model abstracts away the platform specific handles that can be toggled through the RTS.
Synopsis
- stdin :: Handle
- stdout :: Handle
- stderr :: Handle
- openFile :: FilePath -> IOMode -> IO Handle
- openBinaryFile :: FilePath -> IOMode -> IO Handle
- openFileBlocking :: FilePath -> IOMode -> IO Handle
- withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r
- withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r
- withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r
Documentation
Arguments
| :: FilePath | The path to the file that should be opened | 
| -> IOMode | The mode in which the file should be opened | 
| -> IO Handle | 
The computation openFile path mode
The handle is open in text mode with localeEncoding.
 You can change the encoding with hSetEncoding.
Arguments
| :: FilePath | The path to the binary file that should be opened | 
| -> IOMode | The mode in which the binary file should be opened | 
| -> IO Handle | 
The computation openBinaryFile path mode
This is different from openFile as in that it does not use any file encoding.
Arguments
| :: FilePath | The path to the file that should be opened | 
| -> IOMode | The mode in which the file should be opened | 
| -> (Handle -> IO r) | The action to run with the obtained handle | 
| -> IO r | 
The computation withFile path mode actionaction
 with the obtained handle before closing the file.
Even when an exception is raised within the action, the file will still be closed.
 This is why withFile path mode act
openFilepath mode >>= (\hdl -> act hdl >>=hClosehdl)
See also: bracket
withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r Source #
The computation withBinaryFile path mode actionaction with the obtained handle before closing the binary file.
This is different from withFile as in that it does not use any file encoding.
Even when an exception is raised within the action, the file will still be closed.
 This is why withBinaryFile path mode act
openBinaryFilepath mode >>= (\hdl -> act hdl >>=hClosehdl)
See also: bracket