[racket] Typed Racket: (Parameterof (HashTable ...))

From: Greg Hendershott (greghendershott at gmail.com)
Date: Sat Feb 15 14:31:51 EST 2014

>> This is an error:
>>
>>     (: ph (Parameterof (HashTable Symbol String)))
>>     (define ph (make-parameter (make-hash)))
>
> Here's one way to get this to typecheck:
>
>   (: ph (Parameterof (HashTable Symbol String)))
>   (define ph (make-parameter (ann (make-hash) (HashTable Symbol String))))

Thanks for the work-around!

> but it is annoying to have to put a seemingly redundant type annotation
> there.

Although it may be annoying, it's not a big deal. (Hash parameters are
not uncommon in untyped code, so this might make another good
tip/example for the TR intro -- which by the way is excellent.)

As a Typed Racket beginner (as in, ~ 48 hours into it), I'm still
learning when to use `ann` (or `#{}`) vs. `cast` vs. `assert`.

And as someone whose predominant static typing experience is C and
C++, I have the instinct that you don't cast unless you know exactly
what you're doing. So when I need to use `ann` or `cast` or `assert`,
I wince. But I'm still trying to learn the appropriate instinct, here.

Thanks again.

Posted on the users mailing list.