[racket] require/typed to a struct type

From: Joe Gibbs Politz (joe at cs.brown.edu)
Date: Fri Feb 8 23:20:41 EST 2013

When using require/typed with a struct type in the signature, it seems
to matter if the require comes before or after the struct definition:

typed.rkt
=========
#lang typed/racket

(require/typed "untyped.rkt"
 [number-me (my-struct -> Number)])

(struct: my-struct ())

(number-me (my-struct))

untyped.rkt
=========
#lang racket/base

(provide number-me)
(define (number-me _) 52)


Running typed.rkt yields:

my-struct?: undefined;
 cannot reference an identifier before its definition

But, if I change typed.rkt to

typed2.rkt
=========
#lang typed/racket

(struct: my-struct ())

(require/typed "untyped.rkt"
 [number-me (my-struct -> Number)])

(number-me (my-struct))


There's no error and the call succeeds.

Any reason for the ordering dependency?  It's quite inconvenient to be
shuffling require statements around as soon as you want to put a
struct in their type, so I'm assuming this wasn't intended.

Posted on the users mailing list.