[racket] Typed Racket: Parametricity foils equality checking?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Nov 1 18:45:47 EDT 2012

Thank you, thank you, thank you. 

[This validates that my objection to our parametricity is real.]



On Nov 1, 2012, at 4:56 PM, John Clements 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 --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20121101/65bc99e9/attachment.p7s>

Posted on the users mailing list.