pruned unstable/string (moved some code back to web-server)
This commit is contained in:
parent
52aefa6e35
commit
7ef56fbfc5
|
@ -3,7 +3,6 @@
|
|||
scribble/manual
|
||||
"utils.rkt"
|
||||
(for-label unstable/string
|
||||
racket/serialize
|
||||
racket/contract
|
||||
racket/base))
|
||||
|
||||
|
@ -13,22 +12,6 @@
|
|||
|
||||
@unstable-header[]
|
||||
|
||||
@defproc[(lowercase-symbol! [sb (or/c string? bytes?)])
|
||||
symbol?]{
|
||||
Returns @racket[sb] as a lowercase symbol.
|
||||
}
|
||||
|
||||
@defproc[(read/string [s string?])
|
||||
serializable?]{
|
||||
@racket[read]s a value from @racket[s] and returns it.
|
||||
}
|
||||
|
||||
@defproc[(write/string [v serializable?])
|
||||
string?]{
|
||||
@racket[write]s @racket[v] to a string and returns it.
|
||||
}
|
||||
|
||||
|
||||
@addition{Vincent St-Amour}
|
||||
|
||||
@defproc[(regexp-filter [pattern (or/c string? bytes? regexp? byte-regexp?)]
|
||||
|
|
|
@ -1,39 +1,5 @@
|
|||
#lang racket/base
|
||||
(require racket/contract/base
|
||||
racket/serialize)
|
||||
|
||||
(define (read/string str)
|
||||
(define r (read (open-input-string str)))
|
||||
(cond [(eof-object? r) (raise-type-error 'read/string "nonempty string" str)]
|
||||
[else r]))
|
||||
|
||||
;; Eli: Same comments as `read/bytes'.
|
||||
|
||||
(define (write/string v)
|
||||
(define str (open-output-string))
|
||||
(write v str)
|
||||
(get-output-string str))
|
||||
;; Eli: Same comments as `write/string', and worse -- this is the same as
|
||||
;; (format "~s" v)
|
||||
|
||||
; lowercase-symbol! : (or/c string bytes) -> symbol
|
||||
(define (lowercase-symbol! s)
|
||||
(string->symbol
|
||||
(string-downcase
|
||||
(if (bytes? s)
|
||||
(bytes->string/utf-8 s)
|
||||
s))))
|
||||
;; Eli: This doesn't make any sense at all. Why is the `!' in the name? Why
|
||||
;; does it accept bytes? Why does a function in a "string" library accept
|
||||
;; bytes? How can I guess that this creates a new symbol from that name?
|
||||
;; (Which makes me think that this is (compose string->symbol string-downcase
|
||||
;; symbol->string))
|
||||
|
||||
(provide/contract
|
||||
[lowercase-symbol! ((or/c string? bytes?) . -> . symbol?)]
|
||||
[read/string (string? . -> . serializable?)]
|
||||
[write/string (serializable? . -> . string?)])
|
||||
|
||||
(require racket/contract/base)
|
||||
|
||||
;; added by stamourv
|
||||
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
#lang racket/base
|
||||
(require racket/contract/base
|
||||
unstable/list
|
||||
unstable/contract)
|
||||
unstable/contract
|
||||
racket/serialize)
|
||||
(require unstable/bytes
|
||||
unstable/contract
|
||||
unstable/list
|
||||
unstable/string
|
||||
unstable/net/url)
|
||||
(provide
|
||||
(all-from-out
|
||||
unstable/bytes
|
||||
unstable/contract
|
||||
unstable/list
|
||||
unstable/string
|
||||
unstable/net/url))
|
||||
|
||||
;; --
|
||||
|
@ -111,3 +110,37 @@
|
|||
[strip-prefix-ups ((listof path-piece?) . -> . (listof path-piece?))]
|
||||
[directory-part (path-string? . -> . path?)]
|
||||
[build-path-unless-absolute (path-string? path-string? . -> . path?)])
|
||||
|
||||
;; --
|
||||
|
||||
(define (read/string str)
|
||||
(define r (read (open-input-string str)))
|
||||
(cond [(eof-object? r) (raise-type-error 'read/string "nonempty string" str)]
|
||||
[else r]))
|
||||
|
||||
;; Eli: Same comments as `read/bytes'.
|
||||
|
||||
(define (write/string v)
|
||||
(define str (open-output-string))
|
||||
(write v str)
|
||||
(get-output-string str))
|
||||
;; Eli: Same comments as `write/string', and worse -- this is the same as
|
||||
;; (format "~s" v)
|
||||
|
||||
; lowercase-symbol! : (or/c string bytes) -> symbol
|
||||
(define (lowercase-symbol! s)
|
||||
(string->symbol
|
||||
(string-downcase
|
||||
(if (bytes? s)
|
||||
(bytes->string/utf-8 s)
|
||||
s))))
|
||||
;; Eli: This doesn't make any sense at all. Why is the `!' in the name? Why
|
||||
;; does it accept bytes? Why does a function in a "string" library accept
|
||||
;; bytes? How can I guess that this creates a new symbol from that name?
|
||||
;; (Which makes me think that this is (compose string->symbol string-downcase
|
||||
;; symbol->string))
|
||||
|
||||
(provide/contract
|
||||
[lowercase-symbol! ((or/c string? bytes?) . -> . symbol?)]
|
||||
[read/string (string? . -> . serializable?)]
|
||||
[write/string (serializable? . -> . string?)])
|
||||
|
|
Loading…
Reference in New Issue
Block a user