#lang scheme/base
(require "base.ss"
scheme/string
"registry.ss"
scheme/function
)
(define default->string (curry format "~a"))
(define string-converter-table (make-cond-registry '()))
(define (string-converter-ref obj)
(registry-ref string-converter-table obj default->string))
(define (string-converter-set! type? converter)
(registry-set! string-converter-table type? converter))
(define (string-converter-del! type?)
(registry-del! string-converter-table type?))
(define (stringify* arg . args)
(stringify (cons arg args)))
(define (any->string v)
(cond ((string? v) v)
(else
((string-converter-ref v) v))))
(define (stringify args)
(string-join (map any->string args) ""))
(provide/contract
(stringify* (->* (any/c)
()
#:rest (listof any/c)
string?))
(stringify (-> (listof any/c) string?))
(string-converter-ref (-> any/c any))
(string-converter-set! (-> procedure? procedure? any))
(string-converter-del! (-> procedure? any))
(any->string (-> any/c string?))
(rename stringify* any*->string (->* (any/c)
()
#:rest (listof any/c)
string?))
(rename stringify any/list->string (-> (listof any/c) string?))
)
(provide (all-from-out scheme/string))