comments on unstable libraries

This commit is contained in:
Ryan Culpepper 2010-09-06 22:15:03 -06:00
parent 0bdb302409
commit ef778baeb0
6 changed files with 28 additions and 11 deletions

View File

@ -21,6 +21,8 @@
;; "read with bytes". Regardless, I see little point in composing two
;; functions where the two names are clear enough -- you might consider
;; looking at the version in CL.
;; Ryan: I agree. More useful would be a version that checked that the
;; bytes contains only one S-expr and errors otherwise.
(define (write/bytes v)
(define by (open-output-bytes))

View File

@ -9,13 +9,6 @@
(define port-number? (between/c 1 65535))
(define tcp-listen-port? (between/c 0 65535))
(define non-empty-string/c
(and/c string?
(lambda (s) (not (zero? (string-length s))))))
;; Eli: If this gets in, there should also be versions for bytes, lists, and
;; vectors.
;; Ryan: How about just making these predicates? Predicates are more broadly applicable,
;; and when used as a contract we get the descriptive name for free.
(define (non-empty-string? x)
(and (string? x) (not (zero? (string-length x)))))
(define (non-empty-bytes? x)

View File

@ -9,10 +9,11 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (dict-empty? dict)
(= (dict-count dict) 0))
(not (dict-iterate-first dict)))
;; Eli: This encourages ignoring the actual representation, and the fact
;; that `dict-count' can in some cases be an O(N) operation. (And to
;; make things worse, it's not even mentioned in the docs.)
;; Ryan: Fixed complexity.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
@ -135,6 +136,10 @@
;; union of two alists, etc. Alternatively, just write a function for
;; merging two hash tables (and call it `hash-union', of course).
;; Ryan: I prefer the names dict-add-all and dict-add-all!---no connotations
;; of symmetry, and it makes it clear that the first argument determines the
;; representation (and key constraints, etc).
(define (dict-union
#:combine [combine #f]
#:combine/key [combine/key

View File

@ -14,3 +14,7 @@
(define pretty-format/write (pretty-format/pretty pretty-write))
(define pretty-format/display (pretty-format/pretty pretty-display))
(define pretty-format/print (pretty-format/pretty pretty-print))
;; Ryan: There doesn't seem to be any 'format' going on. Perhaps call
;; them pretty-write-to-string, etc?
;; Bleh, just saw pretty-format in racket/pretty :(

View File

@ -7,8 +7,21 @@
@unstable-header[]
@defthing[non-empty-string/c contract?]{
Contract for non-empty strings.
@deftogether[[
@defproc[(non-empty-string? [x any/c]) boolean?]
@defproc[(non-empty-list? [x any/c]) boolean?]
@defproc[(non-empty-bytes? [x any/c]) boolean?]
@defproc[(non-empty-vector? [x any/c]) boolean?]]]{
Returns @racket[#t] if @racket[x] is of the appropriate data type
(string, list, bytes, or vector, respectively) and is not empty;
returns @racket[#f] otherwise.
}
@defproc[(singleton-list? [x any/c]) boolean?]{
Returns @racket[#t] if @racket[x] is a list of one element; returns
@racket[#f] otherwise.
}
@defthing[port-number? contract?]{

View File

@ -25,7 +25,7 @@
(provide/contract
[redirect-to
(->* (non-empty-string/c) (redirection-status? #:headers (listof header?))
(->* (non-empty-string?) (redirection-status? #:headers (listof header?))
response/full?)]
[redirection-status? (any/c . -> . boolean?)]
[permanently redirection-status?]