[racket] Typed Racket Confusing Error Message / Type Check Error
This looks like something that should work -- I'm not sure why TR
thinks that `Nothing` is the right type to infer for the second
parameter to the `Collection` type. However, changing the last line
to:
(((inst Collection-append D C) coll) elem))
makes it typecheck.
On Wed, Aug 1, 2012 at 12:17 PM, Ray Racine <ray.racine at gmail.com> wrote:
> 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))
>
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
>
--
sam th
samth at ccs.neu.edu