<div dir="ltr">Its the same reason that this program gives an error.<div><br></div><div><div>#lang racket</div><div><br></div><div>(define/contract (f x)</div><div>  (my-struct? . -&gt; . number?)</div><div>  1)  </div><div>
<br></div><div>(struct my-struct ()) </div><div><br></div><div>(f (my-struct))</div></div><div><br></div><div style>Do you expect this to work?</div><div><br></div><div style>We could replace uses of my-struct? with (lambda (x) (my-struct? x)) but I wonder if the optimizer will see through that or not (Given that it actually is delaying the resolution of the variable). Also that doesn&#39;t return true to struct-predicate-procedure? and something might depend on that for optimizations.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Feb 8, 2013 at 8:20 PM, Joe Gibbs Politz <span dir="ltr">&lt;<a href="mailto:joe@cs.brown.edu" target="_blank">joe@cs.brown.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When using require/typed with a struct type in the signature, it seems<br>
to matter if the require comes before or after the struct definition:<br>
<br>
typed.rkt<br>
=========<br>
#lang typed/racket<br>
<br>
(require/typed &quot;untyped.rkt&quot;<br>
 [number-me (my-struct -&gt; Number)])<br>
<br>
(struct: my-struct ())<br>
<br>
(number-me (my-struct))<br>
<br>
untyped.rkt<br>
=========<br>
#lang racket/base<br>
<br>
(provide number-me)<br>
(define (number-me _) 52)<br>
<br>
<br>
Running typed.rkt yields:<br>
<br>
my-struct?: undefined;<br>
 cannot reference an identifier before its definition<br>
<br>
But, if I change typed.rkt to<br>
<br>
typed2.rkt<br>
=========<br>
#lang typed/racket<br>
<br>
(struct: my-struct ())<br>
<br>
(require/typed &quot;untyped.rkt&quot;<br>
 [number-me (my-struct -&gt; Number)])<br>
<br>
(number-me (my-struct))<br>
<br>
<br>
There&#39;s no error and the call succeeds.<br>
<br>
Any reason for the ordering dependency?  It&#39;s quite inconvenient to be<br>
shuffling require statements around as soon as you want to put a<br>
struct in their type, so I&#39;m assuming this wasn&#39;t intended.<br>
____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div><br></div>