22 Formatting
(require denxi/format) | package: denxi |
denxi/format provides all bindings from racket/format, including the below bindings.
22.1 Conventional Formatting Procedures
procedure
(format-symbol-for-display sym) → string?
sym : symbol?
procedure
(indent-lines lines) → (listof string?)
lines : (listof string?)
procedure
(join-lines [ #:trailing? trailing?] #:suffix suffix lines) → string? trailing? : any/c = #f suffix : (or/c char? string? #f) lines : (listof string?)
If suffix is #f, then join-lines will use a platform-specific suffix.
If trailing? is #t, then the last line will also end in the suffix.
procedure
(join-lines* [ #:trailing? trailing?] #:suffix suffix line ...) → string? trailing? : any/c = #f suffix : (or/c char? string? #f) line : string?
22.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.
syntax
(message-formatter 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 ...)
syntax
(define+provide-message-formatter id patts ...)
(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
procedure
(format-message m) → string?
m : $message?