[racket] [Typed Racket] mapping car

From: Eric Tanter (etanter at dcc.uchile.cl)
Date: Wed Apr 4 16:17:29 EDT 2012

Hi,

Is there a way to get this to typecheck?

(: cars : (All (A) (Listof (Listof A)) -> (Listof A)))
(define (cars ls)
  (map car (filter cons? ls)))

By looking at the error, it seems the problem is that it is impossible to map car on a list of lists:
> (map car '((1)))
Type Checker: Polymorphic function map could not be applied to arguments...


Thanks,

-- Éric


Posted on the users mailing list.