[racket] Typed Racket: Parametricity foils equality checking?

From: John Clements (clements at brinckerhoff.org)
Date: Thu Nov 1 16:56:48 EDT 2012

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4370 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20121101/1c5116b2/attachment-0001.p7s>

Posted on the users mailing list.