[plt-scheme] Contracts for polymorphic functions

From: Robby Findler (robby at cs.uchicago.edu)
Date: Fri Sep 30 15:11:36 EDT 2005

At Fri, 30 Sep 2005 14:52:30 -0400, Carl Eastlund wrote:
> In some sense, this expresses the polymorphic nature of map - the
> relationship between its input/output lists and the domain/range of
> the given function.  

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

> 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 ... :)


Posted on the users mailing list.