[plt-scheme] named function contracts?
You seem to want a name for a flat contract, not a name for a ho
contract. foo? is a flat contract (altho it's implementation as a
predicate is wrapped as a ho contract, but this is a separate thing).
This program:
(module a mzscheme
(require (lib "contract.ss"))
(define predicate-contract (any? . -> . boolean?))
(define (foo? x) (not (eq? 'x x)))
(provide/contract (foo? predicate-contract)))
(module b mzscheme
(require (lib "contract.ss"))
(require a)
(define (bar? n) (lambda (f) #t))
(provide/contract (bar? (-> number? (-> (flat-named-contract "foo" foo?) boolean?)))))
(require b)
((bar? 3) 'x)
produces this output:
15.2: b: top-level broke bar?'s contract: (-> number? (-> foo boolean?)): expected <foo>, given: x
One source of additional confusion here: the names of functions that
have contracts on them (like the function "foo?" in this case) come
from the name of the contract (predicate-contract) rather than their
defined name (foo?). I've wished I could do something about this, but I
don't see how this can be improved. It's either no names or those
names, from what I can tell.
Robby