[racket] Typed Racket Confusing Error Message / Type Check Error

From: Ray Racine (ray.racine at gmail.com)
Date: Wed Aug 1 12:17:59 EDT 2012

The following gives an error of "Expected Nothing, but got D in elem."
Type checking error?

#lang typed/racket/base

(struct: (D C) Collection ([append   : (D -> Void)]
                           [build    : (-> C)]))

(: List-Builder (All (D) -> (Collection D (Listof D))))
(define (List-Builder)

  (: lst (Listof D))
  (define lst '())

  (Collection (λ: ((datum : D))
                (set! lst (cons datum lst)))
              (λ () lst)))

(: build-Collection (All (D C) (Collection D C)-> C))
(define (build-Collection collection)
  ((Collection-build collection)))

(: append-Collection (All (D C) (Collection D C) D -> Void))
(define (append-Collection coll elem)
  ((Collection-append coll) elem))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120801/de35c263/attachment.html>

Posted on the users mailing list.