[plt-scheme] Dependent Contracts for Structures?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Apr 9 08:31:24 EDT 2009

The only other alternative is to write the contracts for the fields manually.

Robby

On Tuesday, April 7, 2009, Will M Farr <farr at mit.edu> wrote:
> Hello all,
>
> Is it possible to create "dependent" contracts (in the spirit of '->d) for structs in a provide/contract form?  I'm thinking something like
>
> (struct matrix
>   ((rows natural-number/c)
>    (cols natural-number/c)
>    (elts (vector-of-length/c (* rows cols)))))
>
> When I try this now, I get that 'rows and 'cols are not bound in the (vector-of-length/c ...) contract. I don't see anything about this in the documentation for the (struct ...) form in (provide/contract ...).
>
> It's not really strictly necessary, but it would be nice to have....
>
> Thanks!
> Will
>


Posted on the users mailing list.