[plt-scheme] Problem writing SML style enumerate vector constructor/initializer in typed-scheme
To paraphrase Sarah Silverman's comedy special, "Vectors are Magic."
While cons cells can be allocated and initialized and chained together
one at a time, vector memory must be (or should be) allocated as a block
and then initialized in a nice tight loop.  This creates some problems for
typed code.
Case in point, I'm trying to implement SML's style enumerate array
constructor in typed-scheme.
The code is a little messy as I've been trying different things,
but I think the essential errors  are apparent.
*(define: (x) (enumerate [size : Integer] [init : (Integer -> x)]) : 
(Vectorof x)
  (let: ([v : (Vectorof x) (make-vector size)]) ; <<< big problem
    (for ([k (in-range size)])                    <<< problem #2 I can't 
seem to grok
           (vector-set! v k (init k)))))*
So the first obvious problem is that make-vector has no obvious
default value of the type variable x.
The second error is a little more obscure to me and relates to the for
expression.
Here is DrScheme's error message:
*typecheck: untyped identifier in-range imported from module <for.ss> 
in: in-range
typecheck: Expected (Vectorof x), but got Void in: fold-var*
Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091024/02d8885a/attachment.html>