#lang typed/racket(define h : (Immutable-HashTable Integer (-> String))(make-immutable-hash))(hash-ref h2(thunk "Hit and miss"))
#lang typed/racket(define h : (Immutable-HashTable Integer String)(make-immutable-hash))(hash-ref h2(thunk "Hit and miss"))
#lang typed/racket(define h : (Immutable-HashTable Integer String)(make-immutable-hash))(hash-ref h2"Hit and miss")
#lang typed/racket(require/typed racket[hash-ref ((Immutable-HashTable Symbol(U (-> String)String))Symbol(U String(-> String))->(U String(-> String)))])(let* ([h : (Immutable-HashTable Symbol(U (-> String)String))(make-immutable-hash)][h (hash-set h'function(thunk "Function value"))][h (hash-set h'string"String value")])(printf "Fixed string on error:\n")(for ([key (in-list '(function string missing))])(printf "key: ~a\tvalue: ~a\n"key(hash-ref hkey"Missed!")))(printf "\n")(printf "Thunk on error:\n")(for ([key (in-list '(function string missing))])(printf "key: ~a\tvalue: ~a\n"key(hash-ref hkey(thunk "Missed!")))))
>Fixed string on error:key: function value: #<procedure:...key: string value: String valuekey: missing value: Missed!Thunk on error:key: function value: #<procedure:...key: string value: String valuekey: missing value: Missed!
#lang typed/racket(require/typed racket[hash-ref (All (K V)(Immutable-HashTable K V)KV->V)])(let* ([h : (Immutable-HashTable Symbol(U (-> String)String))(make-immutable-hash)][h (hash-set h'function(thunk "Function value"))][h (hash-set h'string"String value")])(printf "Fixed string on error:\n")(for ([key (in-list '(function string missing))])(printf "key: ~a\tvalue: ~a\n"key(hash-ref hkey"Missed!")))(printf "\n")(printf "Thunk on error:\n")(for ([key (in-list '(function string missing))])(printf "key: ~a\tvalue: ~a\n"key(hash-ref hkey(thunk "Missed!")))))
>; hash/c: contract violation; expected: chaperone-contract?; given: K4