[racket-dev] [plt] Push #24227: master branch updated
On 02/01/2012 10:10 AM, Ryan Culpepper wrote:
> On 02/01/2012 09:55 AM, ntoronto at racket-lang.org wrote:
>> collects/unstable/contract.rkt
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> --- OLD/collects/unstable/contract.rkt
>> +++ NEW/collects/unstable/contract.rkt
>> @@ -171,6 +171,14 @@
>> (lambda (idx . elems) #t)))))))
>> sequence?)))
>>
>> +;; Added by ntoronto
>> +
>> +(define contract/c (or/c contract? (any/c . -> . any/c)))
>> +
>> +(define (treeof elem-contract)
>> + (or/c elem-contract
>> + (listof (recursive-contract (treeof elem-contract) #:flat))))
>
> 'contract/c' is not useful: 'contract?' already recognizes predicates,
> and due to the way 'or/c' handles mixed flat and higher-order contracts,
> the arrow contract's checks *never apply*.
>
> > (contract? even?)
> #t
>
> > (define/contract ev (or/c contract? (-> any/c any/c)) even?)
> > (ev 5 6 7) ;; You might think this would be a contract error... nope!
> even?: expects 1 argument, given 3: 5 6 7
>
> > (define/contract vv (or/c contract? (-> any/c any/c)) vector->values)
> > (vv '#(1 2 3)) ;; Likewise... but not a contract error.
> 1
> 2
> 3
Fascinating!
Thanks for checking over my stuff. I'll get rid of it shortly.
Neil T