File

The File library provides functions for reading from and writing to files, built on the OutStream and InStream stream types from the Prelude. Bring it into scope with import File.

Table of contents

openWriteFile

openWriteFile : FilePath -> OutStream

Opens an OutStream channel endpoint to a file specified by a path, in write mode.

openAppendFile

openAppendFile : FilePath -> OutStream

Opens an OutStream channel endpoint to a file specified by a path, in append mode.

openReadFile

openReadFile : FilePath -> InStream

Opens an InStream channel endpoint to a file specified by a path, in read mode.

writeFile

writeFile : FilePath -> String -> ()

Writes a string to a file specified by a path. Does the same as openWriteFile fp |> hPutStr s |> hCloseOut.

appendFile

appendFile : FilePath -> String -> ()

Write a string to a file specified by a path. Does the same as openAppendFile fp |> hPutStr s |> hCloseOut.

readFile

readFile : FilePath -> String

Read the contents of a file specified by a path. Note that the string separates lines explicitely with the newline character \n.