From 2d542e890d733da50e4c6bda1bcc0504e6814d84 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sat, 18 Apr 2015 08:42:52 -0700 Subject: [PATCH] make ->string work with URLs --- sugar/test/main.rkt | 2 +- typed/sugar/coerce.rkt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sugar/test/main.rkt b/sugar/test/main.rkt index 2b795b2..f820a4d 100644 --- a/sugar/test/main.rkt +++ b/sugar/test/main.rkt @@ -42,7 +42,7 @@ (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") + (check-equal? (->string (string->url "foo/bar.html")) "foo/bar.html") (define file-name-as-text "foo.txt") (check-equal? (->string (string->path file-name-as-text)) file-name-as-text) (check-equal? (->string #\¶) "¶") diff --git a/typed/sugar/coerce.rkt b/typed/sugar/coerce.rkt index a288f83..9346354 100644 --- a/typed/sugar/coerce.rkt +++ b/typed/sugar/coerce.rkt @@ -23,7 +23,7 @@ (provide Stringish) -(define-type Stringish (U String Symbol Number Path Char Null Void)) +(define-type Stringish (U String Symbol Number Path Char Null Void SugarURL)) (define/typed+provide (->string x) @@ -37,6 +37,7 @@ [(number? x) (number->string x)] [(path? x) (path->string x)] [(char? x) (format "~a" x)] + [(url? x) (url->string x)] [else (error 'bad-type)]))))