(chibi show base)

The minimal base formatting combinators and show interface.The environment monad with some pre-defined fields for combinator formatting.

(fn vars expr ... fmt)

(show out [args ...])

Run the combinators args, accumulating the output to out, which is either an output port or a boolean, with #t indicating current-output-port and #f to collect the output as a string.

(with params x ... y)

Temporarily bind the parameters in the body x.

(nothing st)

The noop formatter. Generates no output and leaves the state unmodified.

(displayed x)

Formats a displayed version of x - if a string or char, outputs the raw characters (as with `display'), if x is already a formatter defers to that, otherwise outputs a written version of x.

(written x)

Formats a written version of x, as with `write'. The formatting can be updated with the 'writer field.

(each-in-list args)

Takes a single list of formatters, combined in sequence with each.

(each . args)

Combines each of the formatters in a sequence using displayed, so that strings and chars will be output directly and other objects will be written.

(output-default str)

Raw output - displays str to the formatter output port and updates row and col.

(call-with-output producer consumer)

Captures the output of producer and formats the result with consumer.

String utilities

(write-to-string x)

(escaped fmt [quot esc rename])

Outputs the string str, escaping any quote or escape characters. If esc-ch, which defaults to #

is

#f, escapes only the quote-ch, which defaults to #, by doubling it, as in SQL strings and CSV values. If renamer is provided, it should be a procedure of one character which maps that character to its escape value, e.g. #newline => #n, or #f if there is no escape value.

(maybe-escaped fmt pred [quot esc rename])

Only escape if there are special characters, in which case also wrap in quotes. For writing symbols in |...| escapes, or CSV fields, etc. The predicate indicates which characters cause slashification - this is in addition to automatic slashifying when either the quote or escape char is present.

(numeric n [rad prec sgn comma commasep decsep])

(numeric/si n [base separator])

(numeric/fitted width n . args)

(numeric/comma n . o)

(extract-shared-objects x cyclic-only?)

(call-with-shared-ref obj shares proc)

(call-with-shared-ref/cdr obj shares proc . o)

(write-with-shares obj shares)

(written-shared obj)

(written-simply obj)