[racket] Little Schemer, lat?

From: Daniel Prager (daniel.a.prager at gmail.com)
Date: Thu Jan 8 18:18:25 EST 2015

I was surprised that *cdr* upsets the type-checker? How to fix?

#lang typed/racket

(: atom? (-> Any Boolean))
(define (atom? a)
  (or (symbol? a) (boolean? a) (number? a) (string? a)))

(: lat? (-> (List Any) Boolean))
(define (lat? l)
  (cond
    [(null? l) #t]
    [(atom? (car l)) (lat? (cdr l))]
    [else #f]))


Type Checker: Polymorphic function `cdr' could not be applied to arguments:
Types: (Pairof a b) -> (b : ((! False @ (cdr) (0 0)) | (False @ (cdr) (0
0))) : (cdr (0 0)))
       (Listof a) -> (Listof a)
Arguments: (List Any)
Expected result: (List Any)
 in: (cdr l)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20150109/355a5a9f/attachment.html>

Posted on the users mailing list.