[plt-scheme] named function contracts?

From: Richard C. Cobbe (cobbe at ccs.neu.edu)
Date: Sat Apr 10 22:24:47 EDT 2004

Is there any way to create a named function contract?

Here's the situation.  I've got the following definition, as the
contract in question keeps coming up.

  (define predicate-contract (any? . -> . boolean?))

Unfortunately, this makes for really confusing error messages in the
following case:

(module a mzscheme
  ...
  (provide/contract ...
                    (foo? predicate-contract)))

(module b mzscheme
  (require "a.ss")
  (provide/contract ...
                    (bar? (-> number? (-> foo? boolean?)))))

Then, if I invoke ((bar? 3) 'x), where (foo? 'x) = #f, the error message
tells me that I've violated bar?'s contract, and that it expects a
<predicate-contract> value.

Obviously, I can choose a different name for predicate-contract to make
the error message clearer, but that's an imperfect solution at best.  Is
there a way to attach an arbitrary name to a function contract, similar
to flat-named-contract?

Thanks,

Richard


Posted on the users mailing list.