[racket] Typed Racket and require/typed for polymorphic structs

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Wed Aug 7 11:42:53 EDT 2013

What is (posn X Y)? If you mean the obvious (struct/c posn X Y) you
will run into issues with the fact that posn is immutable and
therefore the contracts on its fields need to be flat or chaperone
contracts, and parametric contracts are not.


On Wed, Aug 7, 2013 at 8:32 AM, Asumu Takikawa <asumu at ccs.neu.edu> wrote:
> On 2013-08-07 08:18:41 -0700, Eric Dobson wrote:
>> Ok, now I'm not so sure it is possible. Can you give what you think
>> the contracts should be for your posn example? The issue that I see is
>> that the parametricity is shared across different functions and I
>> don't know how that is represented with racket contracts.
>
> The contracts should be something like
>   make-posn  -->  (-> X Y (posn X Y))
>   posn-x     -->  (-> (posn X Y) X)
>   posn-y     -->  (-> (posn X Y) Y)
>
>   where X = (new-∀/c 'X)
>         Y = (new-∀/c 'Y)
>
> This is similar to how `contract-out` works with the #:exists and
> #:forall keywords.
>
> Cheers,
> Asumu


Posted on the users mailing list.