<div dir="ltr">Hello, Racket community.<div style>I'm a newbie and just started study Racket and Typed Racket and a little confused with generalization and inference.</div><div style>I found what inference works different for different containers type. For example:</div>
<div style><div><div style>Set:</div><div>> (set 0 195 196)</div><div>- : (Setof Byte)</div><div>(set 0 195 196)</div></div><div style>List:</div><div style><div>> '((195 . 1) (196 . 2))</div><div>- : (Listof (Pairof Positive-Byte Positive-Byte)) [generalized from (List (Pairof Positive-Byte One) (Pairof Positive-Byte Positive-Byte))]</div>
<div>'((195 . 1) (196 . 2))</div><div style>HashTable:</div><div style><div>> #hash((195 . 1) (196 . 2) (197 . 3)) </div><div>- : (HashTable Integer Integer)</div><div>'#hash((195 . 1) (197 . 3) (196 . 2))</div>
</div></div><div><br></div><div style>Actually i'm writing library for msgpack protocol and decide to implement it in Typed Racket. Here is my code which did't type check and broke all other program:</div><div style>
(define-type Atom (U False True Null))<br></div><div style><div>(: atoms (HashTable Byte Atom))</div><div>(define atoms #hash((#xc0 . ())</div><div> (#xc3 . #t)</div><div> (#xc2 . #f)))</div>
<div style>Error: Type Checker: Expected (HashTable Byte Atom), but got (HashTable Integer Atom) in: #hash((195 . #t) (194 . #f) (192 . ()))</div><div style><br></div><div style>Is it bug? Or feature?</div></div></div></div>