package lwt
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=94272fac89c5bf21a89c102b8a8f35a5
sha512=8951b94555e930634375816d71815b9d85daad6ffb7dab24864661504d11be26575ab0b237196c54693efa372a9b69cdc1d5068a20a250dc0bbb4a3c03c5fda1
doc/lwt.unix/Lwt_fmt/index.html
Module Lwt_fmt
Format API for Lwt-powered IOs
This module bridges the gap between Format and Lwt. Although it is not required, it is recommended to use this module with the Fmt library.
Compared to regular formatting function, the main difference is that printing statements will now return promises instead of blocking.
val printf : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'aReturns a promise that prints on the standard output. Similar to Format.printf.
val eprintf : ('a, Format.formatter, unit, unit Lwt.t) format4 -> 'aReturns a promise that prints on the standard error. Similar to Format.eprintf.
Formatters
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 oc creates a formatter that writes to the channel oc.
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:Format.formatter ->
unit ->
formattermake_formatter ~commit ~fmt creates a new lwt formatter based on the Format.formatter fmt. The commit function will be called by the printing functions to update the underlying channel.
val get_formatter : formatter -> Format.formatterget_formatter fmt returns the underlying Format.formatter. To access the underlying formatter during printing, it isvrecommended to use %t and %a.
Printing
val fprintf :
formatter ->
('a, Format.formatter, unit, unit Lwt.t) format4 ->
'aval kfprintf :
(formatter -> unit Lwt.t -> 'a) ->
formatter ->
('b, Format.formatter, unit, 'a) format4 ->
'bval ifprintf :
formatter ->
('a, Format.formatter, unit, unit Lwt.t) format4 ->
'aval ikfprintf :
(formatter -> unit Lwt.t -> 'a) ->
formatter ->
('b, Format.formatter, unit, 'a) format4 ->
'bflush fmt flushes the formatter (as with Format.pp_print_flush) and executes all the printing action on the underlying channel.
Low level functions
val write_order : Lwt_io.output_channel -> order -> unit Lwt.twrite_order oc o applies the order o on the channel oc.