|
|
@ -45,7 +45,7 @@
|
|
|
|
(try (xexpr->string x)
|
|
|
|
(try (xexpr->string x)
|
|
|
|
(except [exn:fail? (make-coercion-error-handler 'html x)])))
|
|
|
|
(except [exn:fail? (make-coercion-error-handler 'html x)])))
|
|
|
|
|
|
|
|
|
|
|
|
; must get this right — no escaped chars
|
|
|
|
; todo: must get this right — no escaped chars
|
|
|
|
;(->html '(script ((type "text/javascript")) "3 > 2"))
|
|
|
|
;(->html '(script ((type "text/javascript")) "3 > 2"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -53,17 +53,21 @@
|
|
|
|
;; general way of coercing to symbol
|
|
|
|
;; general way of coercing to symbol
|
|
|
|
(define+provide/contract (->symbol x)
|
|
|
|
(define+provide/contract (->symbol x)
|
|
|
|
(any/c . -> . symbol?)
|
|
|
|
(any/c . -> . symbol?)
|
|
|
|
|
|
|
|
(if (symbol? x)
|
|
|
|
|
|
|
|
x
|
|
|
|
(try (string->symbol (->string x))
|
|
|
|
(try (string->symbol (->string x))
|
|
|
|
(except [exn:fail? (make-coercion-error-handler 'symbol x)])))
|
|
|
|
(except [exn:fail? (make-coercion-error-handler 'symbol x)]))))
|
|
|
|
|
|
|
|
|
|
|
|
;; general way of coercing to path
|
|
|
|
;; general way of coercing to path
|
|
|
|
(define+provide/contract (->path x)
|
|
|
|
(define+provide/contract (->path x)
|
|
|
|
(any/c . -> . path?)
|
|
|
|
(any/c . -> . path?)
|
|
|
|
|
|
|
|
(if (path? x)
|
|
|
|
|
|
|
|
x
|
|
|
|
(try
|
|
|
|
(try
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
[(url? x) (apply build-path (map path/param-path (url-path x)))]
|
|
|
|
[(url? x) (apply build-path (map path/param-path (url-path x)))]
|
|
|
|
[else (string->path (->string x))])
|
|
|
|
[else (string->path (->string x))])
|
|
|
|
(except [exn:fail? (make-coercion-error-handler 'path x)])))
|
|
|
|
(except [exn:fail? (make-coercion-error-handler 'path x)]))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; general way of coercing to url
|
|
|
|
;; general way of coercing to url
|
|
|
@ -81,23 +85,24 @@
|
|
|
|
;; general way of coercing to a list
|
|
|
|
;; general way of coercing to a list
|
|
|
|
(define+provide/contract (->list x)
|
|
|
|
(define+provide/contract (->list x)
|
|
|
|
(any/c . -> . list?)
|
|
|
|
(any/c . -> . list?)
|
|
|
|
|
|
|
|
(if (list? x)
|
|
|
|
|
|
|
|
x
|
|
|
|
(try
|
|
|
|
(try
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
[(list? x) x]
|
|
|
|
|
|
|
|
[(vector? x) (vector->list x)]
|
|
|
|
[(vector? x) (vector->list x)]
|
|
|
|
[(set? x) (set->list x)]
|
|
|
|
[(set? x) (set->list x)]
|
|
|
|
[else (list x)])
|
|
|
|
[else (list x)])
|
|
|
|
(except [exn:fail? (make-coercion-error-handler 'list x)])))
|
|
|
|
(except [exn:fail? (make-coercion-error-handler 'list x)]))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; general way of coercing to vector
|
|
|
|
;; general way of coercing to vector
|
|
|
|
(define+provide/contract (->vector x)
|
|
|
|
(define+provide/contract (->vector x)
|
|
|
|
(any/c . -> . vector?)
|
|
|
|
(any/c . -> . vector?)
|
|
|
|
|
|
|
|
(if (vector? x)
|
|
|
|
|
|
|
|
x
|
|
|
|
(try
|
|
|
|
(try
|
|
|
|
(cond
|
|
|
|
(list->vector (->list x))
|
|
|
|
[(vector? x) x]
|
|
|
|
(except [exn:fail? (make-coercion-error-handler 'vector x)]))))
|
|
|
|
[else (list->vector (->list x))])
|
|
|
|
|
|
|
|
(except [exn:fail? (make-coercion-error-handler 'vector x)])))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|