On this page:
19.1 Conventional Formatting Procedures
format-symbol-for-display
indent-lines
join-lines
join-lines*
19.2 Message Formatting
message-formatter/  c
message-formatter
define-message-formatter
define+  provide-message-formatter
combine-message-formatters
default-message-formatter
current-message-formatter
format-message
8.0

19 Formatting

 (require xiden/format) package: xiden

xiden/format provides all bindings from racket/format, including the below bindings.

19.1 Conventional Formatting Procedures

procedure

(format-symbol-for-display sym)  string?

  sym : symbol?
Like symbol->string, except the resulting string wraps the symbol’s string content in conventional quotes for display in human-readable output.

procedure

(indent-lines lines)  (listof string?)

  lines : (listof string?)
Returns a new version of lines where each element has two leading spaces.

procedure

(join-lines lines)  string?

  lines : (listof string?)
Equivalent to (string-join lines "\n").

procedure

(join-lines* line ...)  string?

  line : string?
Equivalent to (join-lines (list line ...)).

19.2 Message Formatting

Messages are useful for exchanging information without formatting concerns, but program output must include human-readable strings. This section therefore defines a message formatter as a procedure that translates a message to a string. The bindings documented in this section pertain exclusively to message formatters.

A contract that matches a message formatter.

syntax

(message-formatter patts ...)

Expands to (λ (m) (match m patts ...)).

(define-message $foo (a b c))
 
; "1 2 3"
((message-formatter [($foo x y z) (format "~a ~a ~a" x y z)]) ($foo 1 2 3))

syntax

(define-message-formatter id patts ...)

Expands to (define id (message-formatter patts ...))

syntax

(define+provide-message-formatter id patts ...)

Expands to

(begin (provide (contract-out [id message-formatter/c]))
       (define-message-formatter id patts ...))

procedure

(combine-message-formatters formatter ...)  message-formatter/c

  formatter : message-formatter/c
Returns a message formatter that uses each formatter in the order passed.

A message formatter useful only for producing locale-independent fallback strings.

A parameter holding the message formatter for use with format-message.

procedure

(format-message m)  string?

  m : $message?
Equivalent to ((current-message-formatter) m).