[plt-scheme] Contracts for polymorphic functions

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Fri Sep 30 15:16:28 EDT 2005

On 9/30/05, Robby Findler <robby at cs.uchicago.edu> wrote:
> FWIW, another way to write the (a?) contract for map is to write:
>
>   (define (map-c x y) (-> (listof x) (-> x y) (listof y)))
>
> and then apply that at various use sites. Of course, this isn't very
> nice, because you have to both find the places where you want to apply
> this function and you have to actually come up with arguments at those
> places.

Well, the real problem with that is that you won't get blame unless
you export map at each separate set of contracts from some module. 
The anaphoric-contracts solution, whatever else can be said for it,
makes it clear how the initial exporting module restricts the use of
map.

> > My remaining questions are - was this an intended
> > use of anaphoric-contracts, if so why is there no existing function
> > contract constructor that facilitates creating new anaphoric contracts
> > at function invocation, and is there anything else interesting about
> > this I've left out?
>
> I'm not sure anaphoric-contracts is really ready for the prime-time. It
> only really seems to be the right thing for first-order values that
> pass thru. Overall, it somehow just doesn't seem to be quite right, but
> I don't know why (I'm only saying this because I cooked it up ... :)

What do you mean by "first-order values that pass thru"?  And as for
"quite right", I'm not sure what you mean - what was the intended use
for, or initial purpose of, anaphoric-contracts?

--Carl


Posted on the users mailing list.