std.io.write

Functions and types for working with Writers.

Types

#[implicit]
type Write a = { write_slice : a -> Array Byte -> Int -> Int -> IO Int, flush : a -> IO () }

Allows writing bytes to a sink. To ensure that all data has been written, writes have to be paired with a flush.

Values

let write_slice ?write : forall a . [Write a] -> a -> Array Byte -> Int -> Int -> IO Int

Write some bytes from a slice of an array into the writer. The bounds of the slice are given by start and end as a half open range [start, end).

The function returns the number of bytes that have been written. If the slice is not empty and the returned value is 0, the writer will likely not accept more data. It may accept more data in the future.

let write writer buf : forall a . [Write a] -> a -> Array Byte -> IO Int

Like write_slice, but tries to write all of buf.

let write_all writer buf : forall a . [Write a] -> a -> Array Byte -> IO ()

Writes the entire contents of buf into writer. The call will fail if writer does not accept all of the data.

let write_string writer str : forall a . [Write a] -> a -> String -> IO ()

Writes the entire string into writer. The call will fail if writer does not accept all of the data.

let flush ?write : forall a . [Write a] -> a -> IO ()

Flushes the buffers of the writer, ensuring that all data has been written.

let buffered writer : forall w . [Write w] -> w -> Buffered w

Wraps writer in a Buffered writer to provide buffering.

let buffered_with_capacity capacity writer : forall w . [Write w] -> Int -> w -> Buffered w

Wraps writer in a Buffered writer to provide buffering with the specified buffer capacity.

#[implicit]
let write_buffered : forall w . [Write w] -> Write (Buffered w)

Allows writing bytes to a sink. To ensure that all data has been written, writes have to be paired with a flush.

#[implicit]
let disposable_buffered : forall w . [Disposable w] -> [Write w] -> Disposable (Buffered w)

A resource that has to be released after use, for example a file handle or a database connection.