Module Prime_io
Helpers for standard library channels.
val with_file_in : (Stdlib.in_channel -> 'a) -> string -> 'a
with_file_in f fp
isf ic
whereic
is a channel opened for input from the file atfp
.ic
is closed whenf
returns or raises an exception.
val with_file_out : (Stdlib.out_channel -> 'a) -> string -> 'a
with_file_out f fp
callsf oc
whereoc
is a channel opened for output tofp
.oc
is closed whenf
returns or raises an exception. In the latter case the file is also removed.
val with1_file_in : (Stdlib.in_channel -> 'a -> 'b) -> string -> 'a -> 'b
with1_file_in f fp acc
isf ic acc
whereic
is a channel opened for reading fromfp
during the call. Due to the effect involved, this is not a special case ofwith_file_in
.
val with1_file_out : (Stdlib.out_channel -> 'a -> 'b) -> string -> 'a -> 'b
with1_file_out f fp acc
isf oc acc
whereoc
is a channel opened for writing tofp
during the call. Due to the effect involved, this is not a special case ofwith_file_out
.
val fold_input : ?close:bool -> (Stdlib.in_channel -> 'a -> 'a) -> Stdlib.in_channel -> 'a -> 'a
fold_input f ic
forms the composition of successive calls tof ic
untilEnd_of_file
is raised.- parameter close
If true, close
ic
before returning, including if an exception occurs while evaluatingf ic acc
for someacc
.