Module Lwt_fmt
Format API for Lwt-powered IOs
- since
- 4.1.0
val printf : ('a, Stdlib.Format.formatter, unit, unit Lwt.t) Stdlib.format4 -> 'aReturns a promise that prints on the standard output. Similar to
Format.printf.
val eprintf : ('a, Stdlib.Format.formatter, unit, unit Lwt.t) Stdlib.format4 -> 'aReturns a promise that prints on the standard error. Similar to
Format.eprintf.
Formatters
type order=|String of string * int * intString (s, off, len)indicate the output ofsat offsetoffand lengthlen.|FlushFlush operation
val make_stream : unit -> order Lwt_stream.t * formattermake_stream ()returns a formatter and a stream of all the writing order given on that stream.
val of_channel : Lwt_io.output_channel -> formatterof_channel occreates a formatter that writes to the channeloc.
val stdout : formatterFormatter printing on
Lwt_io.stdout.
val stderr : formatterFormatter printing on
Lwt_io.stdout.
val make_formatter : commit:(unit -> unit Lwt.t) -> fmt:Stdlib.Format.formatter -> unit -> formattermake_formatter ~commit ~fmtcreates a new lwt formatter based on theFormat.formatterfmt. Thecommitfunction will be called by the printing functions to update the underlying channel.
val get_formatter : formatter -> Stdlib.Format.formatterget_formatter fmtreturns the underlyingFormat.formatter. To access the underlying formatter during printing, it isvrecommended to use%tand%a.
Printing
val fprintf : formatter -> ('a, Stdlib.Format.formatter, unit, unit Lwt.t) Stdlib.format4 -> 'aval kfprintf : (formatter -> unit Lwt.t -> 'a) -> formatter -> ('b, Stdlib.Format.formatter, unit, 'a) Stdlib.format4 -> 'bval ifprintf : formatter -> ('a, Stdlib.Format.formatter, unit, unit Lwt.t) Stdlib.format4 -> 'aval ikfprintf : (formatter -> unit Lwt.t -> 'a) -> formatter -> ('b, Stdlib.Format.formatter, unit, 'a) Stdlib.format4 -> 'bval flush : formatter -> unit Lwt.tflush fmtflushes the formatter (as withFormat.pp_print_flush) and executes all the printing action on the underlying channel.
val write_order : Lwt_io.output_channel -> order -> unit Lwt.twrite_order oc oapplies the orderoon the channeloc.