I tried using
for/first in Typed Racket in many different ways, in particular like this:
(for/first : Integer ([i : Integer '(1 2 3)]) (ann i Integer))
As you can see, I put in all type annotations I could think of, but I still get:
Type Checker: Error in macro expansion -- insufficient type information to typecheck. please add more type annotations
Then, I accidentally saw in the Typed Racket reference that
for*/and are not supported: 2 Special Form Reference.
I was somewhat surprised, given that the same chapter of the reference says that
for/last is supported for example. So I tried
(for/last ([i '(1 2 3)]) i)
which gave me
; /gnu/store/nhcp7rxxlkvxc4gw20v87gs65isi3xzq-racket-vm-cs-8.5/opt/racket-vm/collects/racket/private/for.rkt:2095:6: Type Checker: type mismatch ; expected: False ; given: Integer ; in: result
Oh. The following works by the way:
(for/last ([i '(1 2 3)]) #f)
but it is obviously kind of useless.
Is there a deep reason for these family of macros to be broken/unsupported? I haven't yet checked their Typed Racket definitions, but I would be happy to help fixing them is somebody is available to provide guidance.
FWIW, I can get the behavior of
for/first with the following slightly more verbose
for/fold, which typechecks fine:
(for/fold ([res : (U False Integer) #f]) ([i '(1 2 3)]) #:break (not (eq? res #f)) i)