5.1. The IO Module
The io
module provides I/O functionality, such as opening files and printing to the terminal.
Standard module containing types and functions for (file) input/output.
This module's most trivial functionality, such as printing to the terminal, is included in the prelude.
Types
IOMode
type IOMode of
read,
write,
append,
read_write
The different modes for opening a file.
File
type File of
path: Str,
descr: Int,
mode: IOMode
A handle to a file.
Values
stdin
ext stdin : File
A read-only file handle to the standard input, "stdin".
stdout
ext stdout : File
An append-only file handle to the standard output, "stdout".
stderr
ext stderr : File
An append-only file handle to the standard error output, "stderr".
openf
ext openf path mode : Str -> IOMode -> !File
Opens the file with the given path
and IOMode
.
closef
ext closef file : File -> !Nll
Closes the given file.
putsf
ext putsf file str : File -> Str -> !Nll
Writes string str
to the given File, if it has been opened with mode write
, read_write
or append
.
puts
let puts str : Str -> !Nll
Prints the given string to stdout
.
Imports
Publicly imported symbols:
from std::str use Str
View the source code here.