15 Aug 2012 05:52
Wrapping loops for TR isn't working, and the type annotations are for the wrong value
I like the idea of wrapping Racket's standard "for" loops with a few annotations and letting inference figure out the rest of the types. The problem is, it doesn't work very well. 1. Even though the loop's type is technically optional, it seems to always be required. 2. Many simple loops don't typecheck anyway. 3. It's a PITA to write new kinds of "for" loops in the same style. 4. A #:when clause can only be last. #4 is acknowledged in the TR reference. As an example of #1, the following is one of the simplest loops: ;; "Type Checker: ... add more type annotations" ;(for/list: ([i (in-range 5)]) i) ;; This works: (for/list: : (Listof Integer) ([i (in-range 5)]) i) Besides being annoying, it's obviously redundant. For examples of #2, these don't typecheck: (for/vector: : (Vectorof Integer) ([i (in-range 5)]) i)(Continue reading)
RSS Feed