Module Odoc_utils.Io_utilsSource

with_open_* are resource safe wrappers around opening and closing channels. They are equivalent to the same functions in OCaml 4.14's In_channel and Out_channel.

Sourceval _with_resource : 'a -> close:('a -> unit) -> ('a -> 'b) -> 'b
Sourceval with_open_in : string -> (in_channel -> 'a) -> 'a
Sourceval with_open_in_bin : string -> (in_channel -> 'a) -> 'a
Sourceval fold_lines : string -> (string -> 'a -> 'a) -> 'a -> 'a

Read a file line-by-line by folding f.

Sourceval read_lines : string -> string list

Read a file as a list of lines.

Sourceval with_open_out : string -> (out_channel -> 'a) -> 'a
Sourceval with_open_out_bin : string -> (out_channel -> 'a) -> 'a
Sourceval with_formatter_out : string -> (Format.formatter -> 'a) -> 'a

Like with_open_out but operate on a Format buffer.

Sourceval marshal : string -> 'a -> unit

Shortcuts for composing with_open_* functions and Marshal.

Sourceval unmarshal : string -> 'a