On Jul 13, 2014, at 8:23 PM, Sam Tobin-Hochstadt <sa...@cs.indiana.edu> wrote:

> Probably, what's going on here is that `for/last` has a hidden loop
> variable that starts off as `#f` and Typed Racket infers that to have
> type `False`.

I thought that was the whole point of adding the : (U Index #f), right?  To 
provide a type for that loop variable?  

> 
> If that's the case, there's nothing you can really do other than
> rewrite this as `for/fold`.

Well, I tried to use for/fold, but it kept telling me to add more type 
annotations even when I had annotated every
little thing that I could.
Then I tried reversing the sequences and using for/first (which would work for 
what I’m doing but not in general),
but if I remember correctly that seemed to have the same problem.
Then I tried using the reversed sequences with for/or instead of for/first and 
that worked fine.  
But If there’s a hidden loop variable starting of as `#f`, then for/or should 
have the same problem, but for/or works fine.  

> 
> Sam
> 
> On Sun, Jul 13, 2014 at 7:57 PM, Alexander D. Knauth
> <alexan...@knauth.org> wrote:
>> For some reason this:
>> (for/last : (U Index #f)
>>    ([i : Index (ann (in-range 5) (Sequenceof Index))])
>>    i)
>> Is giving me this error:
>> . Type Checker: type mismatch
>>  expected: False
>>  given: Index in: (for/last : (U Index #f) ((i : Index (ann (in-range 5) 
>> (Sequenceof Index)))) i)
>> 
>> Why is it expecting False?
>> And is there some type annotation I can put somewhere to fix it or anything?
>> 
>> 
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users


____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to