improve the way '() is treated as a constant
so it fits in with stronger and whatnot and the other list contracts
This commit is contained in:
parent
63f7cf1568
commit
c3e92093f6
|
@ -150,6 +150,8 @@
|
|||
(or/c (-> string?) (-> integer? integer?) integer?)
|
||||
(or/c (-> integer? integer?) integer?))
|
||||
|
||||
(ctest #t contract-stronger? (list/c) '())
|
||||
(ctest #t contract-stronger? (list/c) '())
|
||||
(ctest #t contract-stronger? (cons/c boolean? integer?) (cons/c boolean? integer?))
|
||||
(ctest #f contract-stronger? (cons/c boolean? integer?) (cons/c integer? boolean?))
|
||||
(ctest #t contract-stronger? (cons/c number? (listof number?)) (non-empty-listof number?))
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
contract-custom-write-property-proc
|
||||
(rename-out [contract-custom-write-property-proc custom-write-property-proc])
|
||||
|
||||
set-listof-any-and-cons/c-anyany!)
|
||||
set-some-basic-contracts!)
|
||||
|
||||
(define (contract-custom-write-property-proc stct port display?)
|
||||
(write-string "#<" port)
|
||||
|
@ -220,9 +220,11 @@
|
|||
;; bang it in here and use it only after it's been banged in.
|
||||
(define listof-any #f)
|
||||
(define consc-anyany #f)
|
||||
(define (set-listof-any-and-cons/c-anyany! l p)
|
||||
(define list/c-empty #f)
|
||||
(define (set-some-basic-contracts! l p mt)
|
||||
(set! listof-any l)
|
||||
(set! consc-anyany p))
|
||||
(set! consc-anyany p)
|
||||
(set! list/c-empty mt))
|
||||
|
||||
(define (coerce-contract/f x [name name-default])
|
||||
(define (coerce-simple-value x)
|
||||
|
@ -239,7 +241,8 @@
|
|||
x
|
||||
#f
|
||||
(memq x the-known-good-contracts))])]
|
||||
[(or (symbol? x) (boolean? x) (char? x) (null? x) (keyword? x))
|
||||
[(null? x) list/c-empty]
|
||||
[(or (symbol? x) (boolean? x) (char? x) (keyword? x))
|
||||
(make-eq-contract x
|
||||
(if (name-default? name)
|
||||
(if (or (null? x)
|
||||
|
|
|
@ -1135,8 +1135,11 @@
|
|||
(higher-order-list/c ctc-args)]))
|
||||
|
||||
(define (list/c-name-proc c)
|
||||
(apply build-compound-type-name
|
||||
'list/c (generic-list/c-args c)))
|
||||
(define args (generic-list/c-args c))
|
||||
(cond
|
||||
[(null? args) ''()]
|
||||
[else (apply build-compound-type-name 'list/c args)]))
|
||||
|
||||
(define ((list/c-first-order c) x)
|
||||
(and (list? x)
|
||||
(= (length x) (length (generic-list/c-args c)))
|
||||
|
@ -2108,5 +2111,8 @@
|
|||
[else "th"])))
|
||||
|
||||
;; this is a hack to work around cyclic linking issues;
|
||||
;; see definition of set-listof-any-and-cons/c-anyany!
|
||||
(set-listof-any-and-cons/c-anyany! (listof any/c) (cons/c any/c any/c))
|
||||
;; see definition of set-some-basic-contracts!
|
||||
(set-some-basic-contracts!
|
||||
(listof any/c)
|
||||
(cons/c any/c any/c)
|
||||
(list/c))
|
||||
|
|
Loading…
Reference in New Issue
Block a user