bedeke
2022-8-1 11:07:35

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-&gt;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-&gt;inexact i)) (module m2 typed/racket/base (require racket/flonum) (for/flvector ([i (in-list '(1 2 3))]) (ann (exact-&gt;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-&gt;inexact i) Flonum)) (module m3 typed/racket/base (require racket/flonum) (for/flvector : FlVector ([i (in-list '(1 2 3))]) (ann (exact-&gt;inexact i) Flonum))) ; ERROR: for/flvector: bad syntax in: (for/flvector : FlVector ((i (in-list (quote (1 2 3))))) (ann (exact-&gt;inexact i) Flonum)) (module m4 typed/racket/base (require typed/racket/flonum) (for/flvector ([i (in-list '(1 2 3))]) (exact-&gt;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 …)>


soegaard2
2022-8-1 11:08:47

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


soegaard2
2022-8-1 11:10:20

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


bedeke
2022-8-1 11:11:16

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


bedeke
2022-8-1 11:15:04

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


bedeke
2022-8-1 11:20:49

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


soegaard2
2022-8-1 12:29:25

That must be an oversight.


soegaard2
2022-8-1 12:48:57

typed/racket just exports the one from flonum: