[racket] Typed Racket error (exporting a struct containing a hash table)

From: Jeremiah Willcock (jewillco at osl.iu.edu)
Date: Sat Dec 10 19:35:05 EST 2011

On Sat, 10 Dec 2011, Sam Tobin-Hochstadt wrote:

> On Sat, Dec 10, 2011 at 5:54 PM, Jeremiah Willcock <jewillco at osl.iu.edu> wrote:
>> When I run the following program:
>>
>> #lang typed/racket
>> (struct: A ((f : (HashTable Any Any))))
>> (provide (all-defined-out))
>>
>> I get the error message:
>>
>> racket-Linux-install/lib/racket/collects/racket/contract/private/hash.rkt:57:0:
>> hash/c: expected either a flat or chaperone contract for the domain, got Any
>>
>> "Check Syntax" does not produce any errors, and highlights the program
>> correctly.  My "About DrRacket..." version string is "Welcome to DrRacket,
>> version 5.2.0.5--2011-06-21(-/f), english" (from the Git repository as of
>> Dec. 6, 2011).  The "provide" form is necessary for the program to fail. I
>> would appreciate any help you might be able to give.
>
> The problem is in the `Any' contract.  The implementation of `Any'
> can't be used as the contract for hashtable keys.
>
> I'll fix this so that it works for this program, but you won't be able
> to, in general, define a `HashTable' with key type `Any' in Typed
> Racket and insert higher-order values as keys.
>
> To work around this for the moment, use a more specific contract than
> `Any' on the keys.

I've tried more specific key types as well, and got similar errors for 
those as well (at least for something define-typed as (U (Vectorof Any) 
Symbol)).

-- Jeremiah Willcock

Posted on the users mailing list.