On 01/04/2013 01:27 PM, Jens Axel Søgaard wrote:
2013/1/3 Neil Toronto <neil.toro...@gmail.com>:
I solved it by not using `for/sum' and writing this ridiculous function for
the recursive base case and the initial values in `x':

   (: zero-of (case-> (Real -> Real)
                      (Number -> Number)))
   (define (zero-of x) 0)

Fortunately, it should get inlined. I also renamed `U' to `V', because it
was overshadowing the type name.

Thanks for the solution.

I am very fond of for and friends in Racket code, and
it annoys me to port these constructs to Typed Racket.
I know the goal is for Typed Racket to use the
output of the macro expansion of for and friends,
but maybe it is worth the effort to implement Typed
Racket versions of the most used for-variants?

The general goal of using untyped macros in TR code without a hitch is difficult because macros tend to introduce indirection (e.g. renaming) that throws off local type inference.

FWIW, Vincent and Sam aren't against specialized TR macros. For example, the `for/vector:' and `for*/vector:' exported by `typed/racket' are written from scratch instead of being wrappers for `for/vector' and `for*/vector'.

I gave `for/sum:' a little thought recently, though, and I couldn't think of how to make it work without annotations. Maybe you'll have more success. I'm less motivated to fix `for/sum:' than you are. :D

Neil ⊥

_________________________
 Racket Developers list:
 http://lists.racket-lang.org/dev

Reply via email to