
Hi,
following code shows some problem I’m having with for/flvector
in typed racket:
#lang racket/base
;Welcome to DrRacket, version 8.6.0.2 [cs].
(module m1 typed/racket/base
(require racket/flonum)
(for/flvector ([i (in-list '(1 2 3))])
(exact->inexact i)))
; ERROR: Type Checker: Error in macro expansion -- insufficient type information to typecheck. please add more type annotations in: (for/flvector ((i (in-list (quote (1 2 3))))) (exact->inexact i))
(module m2 typed/racket/base
(require racket/flonum)
(for/flvector ([i (in-list '(1 2 3))])
(ann (exact->inexact i) Flonum)))
; ERROR: Type Checker: Error in macro expansion -- insufficient type information to typecheck. please add more type annotations in: (for/flvector ((i (in-list (quote (1 2 3))))) (ann (exact->inexact i) Flonum))
(module m3 typed/racket/base
(require racket/flonum)
(for/flvector : FlVector ([i (in-list '(1 2 3))])
(ann (exact->inexact i) Flonum)))
; ERROR: for/flvector: bad syntax in: (for/flvector : FlVector ((i (in-list (quote (1 2 3))))) (ann (exact->inexact i) Flonum))
(module m4 typed/racket/base
(require typed/racket/flonum)
(for/flvector ([i (in-list '(1 2 3))])
(exact->inexact i)))
What is the right way to use for/flvector
(as required from racket/flonum
)? Is there a reason why the version from racket/flonum
and typed/racket/flonum
are not in line? Probably the documentation will also need to be updated: <https://docs.racket-lang.org/reference/flonums.html#%28form._%28%28lib._racket%2Fflonum..rkt%29._for%2Fflvector%29%29|syntax (for/flvector maybe-length (for-clause …) body …)>

> (for/flvector type-ann-maybe (for-clause …) expr …+) I think you need to use type-ann-maybe
.

On the other hand - it’s obvious that the return type is flvector
so maybe it is something else.

Ai, it seems I didn’t read carefully enough. In racket/flonum
the annotation is the lenth (#:length 3
) not the type

but that is mentioned in the racket/flonum
documentation. The typed/racket/flonum
does say type-ann-maybe
…

And with (require racket/flonum)
it is required to know the length up front

That must be an oversight.

typed/racket just exports the one from flonum:

