| Copyright | (c) The University of Glasgow 2017 |
|---|---|
| License | see libraries/base/LICENSE |
| Maintainer | [email protected] |
| Stability | internal |
| Portability | non-portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
This model abstracts away the platform specific handles that can be toggled through the RTS.
stdin is a handle managing the programs standard input.
stdout is a handle managing the programs standard output.
stderr is a handle managing the programs standard error.
| :: 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 returns a file handle that can be used to interact with the file.
The handle is open in text mode with localeEncoding. You can change the encoding with hSetEncoding.
| :: 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 returns a file handle that can be used to interact with the binary file.
This is different from openFile as in that it does not use any file encoding.
openFileBlocking :: FilePath -> IOMode -> IO Handle Source
| :: 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 action opens the file and runs action 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 is preferable to
openFile path mode >>= (\hdl -> act hdl >>= hClose hdl)
See also: bracket
withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r Source
The computation withBinaryFile path mode action opens the binary file and runs action 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 is preferable to
openBinaryFile path mode >>= (\hdl -> act hdl >>= hClose hdl)
See also: bracket
withFileBlocking :: FilePath -> IOMode -> (Handle -> IO r) -> IO r Source
© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/9.12.1/docs/libraries/base-4.21.0.0-8e62/GHC-IO-StdHandles.html