<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">This is because Racket’s for loops special-case on <font face="Courier" class="">in-range</font>, <font face="Courier" class="">in-list</font>, <font face="Courier" class="">in-vector</font>, etc. They do this for performance reasons—no need to check the type at runtime. This is probably redundant in a typed context, anyway, though, since the typechecker should be able to (ideally) make those optimizations itself.</div><div class=""><br class=""></div><div class="">Anyway, it looks like the TR expansion of for loops doesn’t account for the (rather large) type of <font face="Courier" class="">in-range</font>. I think Asumu’s rewriting the loops in TR, though—perhaps this will be fixed then?</div><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 5, 2015, at 19:07, Alexander D. Knauth <<a href="mailto:alexander@knauth.org" class="">alexander@knauth.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">This program:<br class="">#lang typed/racket<br class="">(define n : Real 5)<br class="">(for/list ([i : Natural (in-range n)]) : (Listof Natural)<br class=""> i)<br class="">And this program:<br class="">#lang typed/racket<br class="">(define n : Real 5)<br class="">(for/list ([i : Natural (identity (in-range n))]) : (Listof Natural)<br class=""> i)<br class="">The first one produces an error:<br class="">. Type Checker: type mismatch<br class=""> expected: Nonnegative-Integer<br class=""> given: Integer in: (for/list ((i : Natural (in-range n))) : (Listof Natural) i)<br class="">The second one works fine:<br class="">'(0 1 2 3 4)<br class="">But why does the first one produce integer, but wrapping it in identity make it produce Nonnegative-Integer (Natural) ?<br class=""><br class=""><br class=""><br class="">____________________<br class=""> Racket Users list:<br class=""> <a href="http://lists.racket-lang.org/users" class="">http://lists.racket-lang.org/users</a><br class=""></div></blockquote></div><br class=""></body></html>