[racket] A Typed Racket question

From: Сергей Самойленко (samsergey at yandex.ru)
Date: Fri May 3 04:29:42 EDT 2013

Hello!

Type checker returns an error while translating this piece of code:

(: permutations ((Listof Index) ->  (Listof (Listof Index))))
(define (permutations lst)
  (cond
    [(empty? lst) '(())]
    [else (for*/list: : (Listof (Listof Index)) 
            ([x : Index (in-list lst)]
             [y : (Listof Index) (in-list (permutations (remq x lst)))])
            (cons x y))]))

'Type Checker: Error in macro expansion -- insufficient type information to typecheck. please add more type annotations in: (for*/list: : (Listof (Listof Index)) ((x : Index (in-list lst)) (y : (Listof Index) (in-list (remq x lst)))) (cast (cons x y) (Listof Index)))'

Is it possible to give more type annotations in this case?

Sergey Samoylenko.

Posted on the users mailing list.