How to Require Macros from Untyped Racket in Typed Racket with Dependencies on Typed Imports?
I'm facing an issue when trying to require a macro defined in an untyped Racket
module into a Typed Racket module. The macro depends on a function from the same
untyped module. Here's an example:
Welcome to Racket v8.15 [cs].
> (module m racket
(provide (all-defined-out))
(define (g y) y)
(define-syntax (f stx)
(syntax-case stx ()
[(_ x)
#'(g x)])))
> (require 'm)
> (f 0)
string:7:10: Type Checker: missing type for identifier;
consider using `require/typed' to import it
identifier: g
from module: (quote m)
in: g
[,bt for context]
> (require/typed 'm [g (-> Number Number)])
> (g 0)
- : Number
0
> (f 0)
string:7:10: Type Checker: missing type for identifier;
consider using `require/typed' to import it
identifier: g
from module: (quote m)
in: g
[,bt for context]
Unfortunately, even though g
is typed, f
still doesn't recognize the type of
g
. However, when f
uses built-in functions like add1
, it works without any
issues:
Welcome to Racket v8.15 [cs].
> (module m racket
(provide (all-defined-out))
(define-syntax (f stx)
(syntax-case stx ()
[(_ x)
#'(add1 x)])))
> (require 'm)
> (f 0)
- : Integer [more precisely: One]
1
Why doesn't the require/typed
type information for g
propagate to f
, and
how can I properly use macros from an untyped Racket module that depend on typed
imports?