<div dir="ltr">This has a non-chaperone contract being used in a struct/c, I think?<div><br></div><div>(FST (LST 1 2 3)) => struct/dc: expected chaperone contracts, but field a has #<barrier-contract></div><div><br>
</div><div style>Robby</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jan 6, 2013 at 2:40 PM, Sam Tobin-Hochstadt <span dir="ltr"><<a href="mailto:samth@ccs.neu.edu" target="_blank">samth@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Sun, Jan 6, 2013 at 3:23 PM, Robby Findler<br>
<<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>> wrote:<br>
> On Sun, Jan 6, 2013 at 2:18 PM, Sam Tobin-Hochstadt <<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a>><br>
> wrote:<br>
>><br>
>> > The boundaries have the information; that's how the contracts got<br>
>> > inserted<br>
>> > in the first place.<br>
>><br>
>> No, the contracts are parametric contracts using `parametric->/c`, and<br>
>> thus don't have any information about the types used at all.<br>
><br>
><br>
> I don't see why you can't tag them when something at a boundary and then<br>
> check that something at another boundary instead of doing some deep check.<br>
<br>
</div></div>The problem is that I don't know what to tag them *with*.<br>
<br>
Consider the following program:<br>
<br>
#lang racket<br>
<br>
(struct kons (a d))<br>
(struct mt ())<br>
(define MT (mt))<br>
(define (FST v)<br>
(when (eq? MT v) (error 'empty))<br>
(kons-a v))<br>
(define (RST v)<br>
(when (eq? MT v) (error 'empty))<br>
(kons-d v))<br>
(define (LST . x)<br>
(if (empty? x)<br>
MT<br>
(kons (first x) (apply LST (rest x)))))<br>
(define (LST/C elem/c)<br>
(define C (recursive-contract<br>
(or/c (λ (v) (eq? v MT))<br>
(struct/c kons elem/c C))))<br>
C)<br>
(provide/contract<br>
[LST (parametric->/c (A) (->* () #:rest A (LST/C A)))]<br>
[FST (parametric->/c (A) (-> (LST/C A) A))]<br>
[RST (parametric->/c (A) (-> (LST/C A) (LST/C A)))])<br>
<br>
This is the essence of Neil's polymorphic list program, as implemented<br>
by Typed Racket. I don't know how to change those contracts to not be<br>
really expensive, because I can't pick the instantiation of A at<br>
runtime to tag the structure instances with.<br>
<span class="HOEnZb"><font color="#888888"><br>
Sam<br>
</font></span></blockquote></div><br></div>