HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

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.

  • 5 values

File conversions

5 declarations
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.