Module Show


module Show: sig .. end
Interface for creating show functions in a standardised way.

type 'a show 
Type of showers, which contains functions for showing values of type 'a.
val to_formatter : 'a show -> Format.formatter -> 'a -> unit
Get a formatter from a shower. The returned formatter prints into the current box, it does not open a new box.
val to_formatter' : 'a show -> Format.formatter -> 'a -> unit
Get a formatter from a shower. The returned formatter opens a new box to print into.
val to_string : 'a show -> 'a -> string
Get from a shower a function that converts a value to a string.
val append_to : 'a show -> 'a -> Buffer.t -> unit
Use a shower to append the string representation of a value to a buffer.
val print : 'a show -> 'a -> unit
Use a shower to print a value to stdout.
val print_line : 'a show -> 'a -> unit
Use a shower to print a value followed by a newline to stdout.
val shower_from_formatter : ?size_hint:int -> (Format.formatter -> 'a -> unit) -> 'a show
Create a shower from a function which converts a value to a string. The formatter should print into the current box, although it may open new boxes for sub-parts.
val shower_from_to_string : ?size_hint:int -> ('a -> string) -> 'a show
Create a shower from a function which converts a value to a string.

Create a shower from a function which appends a value to a buffer.

Useful showers


val any_shower : 'a show
shower for any value, shows "<unknown>"
val func_shower : ('a -> 'b) show
shower for any function value, shows "<function>"
val int_shower : int show
shower for ints
val float_shower : float show
shower for floats
val bool_shower : bool show
shower for bools
val char_shower : char show
shower for chars
val char_shower' : char show
shower for chars, shows without quotes
val string_shower : string show
shower for strings
val string_shower' : string show
shower for strings, shows without quotes and escaping
val unit_shower : unit show
shower for unit
val option_shower : 'a show -> 'a option show
shower for options
val list_shower : 'a show -> 'a list show
shower for lists
val assoc_list_shower : 'a show -> 'b show -> ('a * 'b) list show
shower for association lists
val listlike_shower : string -> string -> string -> 'a show -> 'a list show
shower for listlike things
val assoc_shower : 'a show -> 'b show -> ('a * 'b) show
shower for associations

Showers for tuples
val tuple_shower2 : 'a show -> 'b show -> ('a * 'b) show
val tuple_shower3 : 'a show -> 'b show -> 'c show -> ('a * 'b * 'c) show
val tuple_shower4 : 'a show ->
'b show -> 'c show -> 'd show -> ('a * 'b * 'c * 'd) show
val tuple_shower5 : 'a show ->
'b show ->
'c show ->
'd show -> 'e show -> ('a * 'b * 'c * 'd * 'e) show
val tuple_shower6 : 'a show ->
'b show ->
'c show ->
'd show ->
'e show -> 'f show -> ('a * 'b * 'c * 'd * 'e * 'f) show
val field_shower : string -> ('a -> 'b) -> 'b show -> 'a show
field_shower name f s

Create a shower for field called name, which is extracted from a record of type 'a, and displayed with shower s.

val record_shower : 'a show list -> 'a show
Create a shower for a record, from a list of field showers.