[racket] TR: typechecking for*/and

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Mon Feb 9 10:25:17 EST 2015

The `for*` loops' expansion is not typechecker-friendly at all, so there
are a lot of cases where they won't work in TR.

In this particular case, there is no more type information you could
add, which makes the error message really misleading. Inference is not
currently able to distinguish these "hopeless" cases from more routine
ones, which is part of the problem.

Using `for*/fold` instead of `for*/and` works in this case. It's not as
nice as the original, I agree, but it's a workaround.

The good news is, Asumu is reimplementing the TR `for` loops to play
more nicely with the typechecker. This should hopefully solve this
problem, and more. I don't know what the timeframe for that work
landing is, though.

Vincent



At Fri, 6 Feb 2015 18:04:56 -0800,
Matthew Butterick wrote:
> 
> The first three loops typecheck as expected, but the fourth, using for*/and with two bindings, does not. What is missing?
> 
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 
> #lang typed/racket
> 
> (for*/sum : Integer
>   ([i : Integer (in-range 10)])
>   1)
> 
> ;; 10
> 
> (for*/and : Boolean
>   ([i : Integer (in-range 10)])
>   #t)
> 
> ;; #t
> 
> (for*/sum : Integer
>   ([i : Integer (in-range 10)]
>    [j : Integer (in-range 10)])
>   1)
> 
> ;; 100
> 
> (for*/and : Boolean
>   ([i : Integer (in-range 10)]
>    [j : Integer (in-range 10)])
>   #t)
> 
> ;; Error in macro expansion -- insufficient type information to typecheck
> 
> 
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 
> 
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.