[racket] Type info lost for required function used in Racket REPL... but DrRacket REPL is OK?

From: Greg Hendershott (greghendershott at gmail.com)
Date: Sat Apr 19 22:32:04 EDT 2014

I often like to evaluate Racket source files, then do a little
interactive exploring in the REPL. Sometimes this doesn't work with
Typed Racket, using command-line Racket -- but works just fine in
DrRacket.

For example, given these two files:

;; tr0.rkt
#lang typed/racket/base
(: f (Number -> Number))
(define (f n)
  n)
(provide f)

;; tr1.rkt
#lang typed/racket/base
(require "tr0.rkt")
(f 1)

Then:

$ racket
Welcome to Racket v6.0.1.4.
-> (require xrepl)  ;maybe already in .racketrc
-> ,en tr0.rkt
"tr0.rkt"> (f 1)
- : Number
1
"tr0.rkt"> ,en tr1.rkt
1
"tr1.rkt"> (f 1)
; readline-input:4:0: Type Checker: missing type for identifier;
;  consider using `require/typed' to import it
;   identifier: idY6
;   from module: tr0.rkt
;   in: (f 1)
; [,bt for context]
"tr1.rkt">

In other words:

On `enter!` to tr0.rkt, where `f` is defined:
- `f` evaluates fine in the REPL.

On `enter!` to tr1.rkt, where `f` is required:
- `f` evaluates fine in the tr1.rkt source file
- `f` seems to lack type information, in the REPL.
  (Same problem in my Emacs racket-mode REPL.)

HOWEVER, in the DrRacket REPL ("interactions" pane), `f` evaluates just fine!

What is the DrRacket REPL doing differently?

Whatever it is, I would like to do it in racket-mode REPL.
(And, if possible, submit a PR to do it in Racket REPL.)

Posted on the users mailing list.