[racket] for*/list and Typed Racket
Hi All,
I've tried again with Racket 5.2.1 and 5.1.3, and in both it fails to
compile, so I assume there is some non-trivial issue with for*/list in
Typed Racket.
Does anyone have any suggestions on how to make this work?
Thanks.
2012/6/24 Adolfo Pérez Álvarez <adolfo.pa at gmail.com>:
> Hi everyone,
>
> I've been trying to convert the following code to Typed Racket without success:
>
> (define-type Region Number)
> (define-type Color Number)
>
> (define-type Map (Listof (Pair Region (Listof Region))))
>
> (: empty-solution (Listof (Pair Region Color)))
> (define empty-solution '(()))
>
> (: colorize : Map (Listof Color) -> (Listof (Pair Region Color)))
> (define (colorize map colors)
> (for/fold ([solutions empty-solution]) ([entry map])
> (match-let ([(cons region neighbours) entry])
> (for*/list ([s solutions]
> [c colors]
> #:unless (findf (λ (rc)
> (and (memv (car rc) neighbours)
> (eqv? (cdr rc) c)))
> s))
> (cons (cons region c) s)))))
>
> It fails to compile, complaining about the lack of type information
> inside for*/list. The thing is, I added type signatures to every
> single binding inside colorize (I'm quite desperate ;-) ) using the
> #{var : type} syntax, but it didn't work, it gave me exactly the same
> error message:
>
> Type Checker: Error in macro expansion -- insufficient type
> information to typecheck. please add more type annotations in:
> (for*/list ((s solutions) (c colors) #:unless (findf (λ (rc) (and
> (memv (car rc) neighbours) (eqv? (cdr rc) c))) s)) (cons (cons region
> c) s))
>
> I'm using the bleeding edge version (master branch at Github; updated
> today 24th June); DrRacket claims to be at version:
> 5.3.0.11--2012-06-24(c1152749/d). I'll try to test this with the
> latest stable release as soon as possible.
>
> Thanks.