That particular pattern, with `(U String (-> String))`, will work, but
your generalized version would be wrong if it worked. Consider:
```
(: unsound : (Immutable-HashTable Symbol (-> String)) -> String)
(define (unsound h)
((hash-ref h (gensym) (lambda () "x"
(unsound (hash))
```
This pro
For the record, this seems to work fine:
#lang typed/racket
(require/typed racket
[hash-ref ((Immutable-HashTable Symbol
(U (-> String)
String))
Symbol
(U String
(-> String))
Wouldn’t that possibility then have to be part of the type for the values in
the hash? Maybe I don’t understand how types work for hashes.
In this code:
#lang typed/racket
(define h : (Immutable-HashTable Integer (-> String))
(make-immutable-hash))
(hash-ref h
2
(thunk "H
Unfortunately, that doesn't work -- the values in the hash could
include functions.
Sam
On Tue, Nov 24, 2020 at 7:25 AM Tim Jervis wrote:
>
> For the type of the third argument, rather than "any non-function", could
> Typed Racket use the type of the values in the hash?
>
> On Tuesday, 21 April
For the type of the third argument, rather than "any non-function", could
Typed Racket use the type of the values in the hash?
On Tuesday, 21 April 2020 at 15:51:00 UTC+1 Sam Tobin-Hochstadt wrote:
> The problem here is with the optional third argument to `hash-ref`.
> Typed Racket only allows `
On Tue, Apr 21, 2020 at 10:50:44AM -0400, Sam Tobin-Hochstadt wrote:
> The problem here is with the optional third argument to `hash-ref`.
> Typed Racket only allows `#f` or functions as the third argument.
> Plain Racket allows any non-function value as a default, or a function
> which is called t
The problem here is with the optional third argument to `hash-ref`.
Typed Racket only allows `#f` or functions as the third argument.
Plain Racket allows any non-function value as a default, or a function
which is called to produce the default. Since "any non-function" is
not expressible in Typed R
7 matches
Mail list logo