[racket] Typed Racket: Parametricity foils equality checking?

From: Ray Racine (ray.racine at gmail.com)
Date: Thu Nov 1 17:08:53 EDT 2012

Interestingly

(require/typed racket
               [remove-duplicates ((Listof Any) -> (Listof Any)))])

works.


On Thu, Nov 1, 2012 at 4:56 PM, John Clements <clements at brinckerhoff.org>wrote:

> I can't tell whether this is a bug.  In the program below,
> remove-duplicates doesn't remove duplicates. This looks like an attempt to
> preserve parametricity a la theorems for free, but I don't think that TR
> actually tries to guarantee parametricity in this sense.  I'm guessing that
> the values in the list are being wrapped in contracts that prevent
> 'eq?'-checking; I thought that chaperones were supposed to... no, I
> shouldn't even finish that sentence.
>
> Anyhow, I'm just writing to make sure that this isn't a bug. It's
> certainly not the behavior that I would naively expect. I can certainly
> work around the bug by substituting a more specific type for
> remove-duplicates, as in the commented-out version.
>
> John
>
> #lang typed/racket
>
> (require/typed racket
>                [remove-duplicates (All (T) (Listof T) -> (Listof T))]
>                #;[remove-duplicates ((Listof Symbol) -> (Listof Symbol))])
>
> (remove-duplicates '(a b c a d)) ;; => produces '(a b c a d)--that is, a
> list with duplicates
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121101/9712bc85/attachment.html>

Posted on the users mailing list.