The Typed Racket reference indicates that it's possible to use with-type
to created “typed regions” within untyped code.
The
with-type
form allows for localized Typed Racket regions in otherwise untyped code.
It’s a little unclear how to actually use this, though. Obviously, using such a feature needs to take place within an untyped module using #lang racket
or something similar. How should the with-type
binding be imported?
A naïve attempt is just to require
Typed Racket, but this causes failures with how TR overwrites existing syntactic forms.
(require typed/racket)
(struct point (x y)) ; complains about missing type annotations
Trying to use only-in
to simply require with-type
and nothing else sort of works, but then none of the required type bindings (such as Number
or ->
) exist.
It seems like the only way to do this would be to manually use only-in
to import only the things that I need, but this feels laborious. I could also use prefix-in
, but then of course everything would be scattered with prefixes.
Is there a recommended way of doing this, or is this feature somewhat deprecated?