diff --git a/coerce.rkt b/coerce.rkt index ccdf755..5649cae 100644 --- a/coerce.rkt +++ b/coerce.rkt @@ -1,10 +1,8 @@ #lang racket/base (require (for-syntax racket/base racket/syntax)) -(require net/url xml racket/set racket/contract racket/sequence racket/stream racket/dict) +(require net/url racket/set racket/contract racket/sequence racket/stream racket/dict) (require "len.rkt" "define.rkt") - - (define (make-coercion-error-handler target-format x) (λ(e) (error (format "Can’t convert ~a to ~a" x target-format)))) @@ -26,7 +24,7 @@ x ; fast exit for strings (with-handlers ([exn:fail? (make-coercion-error-handler 'string (format "~a (result of ~a" x 'x))]) (cond - [(equal? '() x) ""] + [(or (equal? '() x) (void? x)) ""] [(symbol? x) (symbol->string x)] [(number? x) (number->string x)] [(path? x) (path->string x)] @@ -38,7 +36,7 @@ x ; fast exit for strings (with-handlers ([exn:fail? (make-coercion-error-handler 'string x)]) (cond - [(equal? '() x) ""] + [(or (equal? '() x) (void? x)) ""] [(symbol? x) (symbol->string x)] [(number? x) (number->string x)] [(path? x) (path->string x)] diff --git a/tests.rkt b/tests.rkt index d8feffa..ab1602d 100644 --- a/tests.rkt +++ b/tests.rkt @@ -5,6 +5,7 @@ (check-equal? (->string "foo") "foo") (check-equal? (->string '()) "") +(check-equal? (->string (void)) "") (check-equal? (->string 'foo) "foo") (check-equal? (->string 123) "123") ;(check-equal? (->string (string->url "foo/bar.html")) "foo/bar.html")