HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduleio-streams-1.5.2.2Haskell2010

System.IO.Streams.File

Input and output streams for files.

The functions in this file use "with*" or "bracket" semantics, i.e. they open the supplied FilePath, run a user computation, and then close the file handle. If you need more control over the lifecycle of the underlying file descriptor resources, you are encouraged to use the functions from System.IO.Streams.Handle instead.

Contents
  1. File conversions
Synopsis

File conversions

valuewithFileAsInput
  1. :: FilePath

    file to open

  2. -> (InputStream ByteString -> IO a)

    function to run

  3. -> IO a

withFileAsInput name act opens the specified file in "read mode" and passes the resulting InputStream to the computation act. The file will be closed on exit from withFileAsInput, whether by normal termination or by raising an exception.

If closing the file raises an exception, then that exception will be raised by withFileAsInput rather than any exception raised by act.