[racket] Typed racket and hash table

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Fri Jun 27 16:11:27 EDT 2014

I think you should follow Alexander's advice here about using
`hash-ref` and not `hash-ref!`.

Also, your whole function can also be written as:

    (hash-update! my-hash size (λ ([v : (Listof String)]) (cons s v))
(λ () null))

Sam

On Fri, Jun 27, 2014 at 3:55 PM, Manfred Lotz <manfred.lotz at arcor.de> wrote:
> On Fri, 27 Jun 2014 15:49:14 -0400
> Sam Tobin-Hochstadt <samth at cs.indiana.edu>
> wrote:
>
>> On Fri, Jun 27, 2014 at 3:32 PM, Manfred Lotz
>> <manfred.lotz at arcor.de> wrote:
>> >
>> > Argument 3:
>> >   Expected: (-> b)
>> >   Given:    False
>>
>>
>> This is the key part of the error message: you have to provide a
>> function as the third argument, and you provided `#f`. I'd just change
>> that to (lambda () #f).
>>
>> Sam
>
> Ok, I did this but still not enough.
>
> test.rkt:10:14: Type Checker: Polymorphic function `hash-ref!' could
> not be applied to arguments: Argument 1:
>   Expected: (HashTable a b)
>   Given:    (HashTable Nonnegative-Integer (Listof String))
> Argument 2:
>   Expected: a
>   Given:    Nonnegative-Integer
> Argument 3:
>   Expected: (-> b)
>   Given:    (-> False)
>
>   in: (hash-ref! my-hash size (lambda () #f))
>   context...:
>    /home/manfred/racket/share/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:249:0:
>   type-check /home/manfred/racket/share/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:40:0:
>   tc-setup /home/manfred/racket/share/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:25:4
>    standard-module-name-resolver
>
>
> Thanks, Manfred
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users


Posted on the users mailing list.