<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Since hash-tables can be mutable as far as TR knows, (HashTable Symbol String) is not a subtype of (HashTable Symbol JSExpr).</div><div>To work around this, you can do this:</div><div><div>#lang typed/racket/base</div><div>(require typed/json)</div><div>(: jsx JSExpr) ; <-- jsx is what I ultimately want.</div><div>(define jsx (ann #hasheq((a . "val1") (b . "val2") (c . "val3")) (HashTable Symbol JSExpr)))</div></div><div><br></div><div>Or this would work too:</div><div><div>#lang typed/racket/base</div><div>(require typed/json)</div><div>(: jsx (HashTable Symbol JSExpr)) ; <-- jsx is what I ultimately want.</div><div>(define jsx #hasheq((a . "val1") (b . "val2") (c . "val3")))</div></div><div><br></div><div>Or you could use (inst make-immutable-hasheq Symbol JSExpr) instead of using #hasheq, and it would do the same thing.</div><div><br></div><br><div><div>On Jan 19, 2015, at 1:28 AM, Jordan Johnson <<a href="mailto:jmj@fellowhuman.com">jmj@fellowhuman.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi all,<div class=""><br class=""></div><div class="">I’ve been trying to create JSExprs, as defined in the typed/json library. This is one of those instances where it seems like I must be making things harder than they should be, but I’m still feeling like a duck on rollerskates in TR, so I want to make sure I’m not missing an easier way to do it.</div><div class=""><br class=""></div><div class="">Would you please confirm if this is indeed a smallest-possible solution?</div><div class=""><br class=""></div><div class=""><b class="">;;;; begin</b></div><div class=""><div class="">#lang typed/racket/base</div><div class=""><br class=""></div><div class="">(require typed/json)</div><div class=""><br class=""></div><div class="">(: jsx JSExpr) ; <b class=""><-- jsx is what I ultimately want.</b></div><div class=""><br class=""></div><div class="">;; Attempt #1:</div><div class="">#;</div><div class="">(define jsx #hasheq((a . "val1") (b . "val2") (c . "val3")))</div><div class=""><br class=""></div><div class="">#| Resulting error:</div><div class="">Type Checker: type mismatch</div><div class=""> expected: JSExpr</div><div class=""> given: (HashTable Symbol String)</div><div class=""><br class=""></div><div class=""><b class="">[This seems weird, since it seems like (HashTable Symbol String) should be</b></div><div class=""><b class=""> a subtype of JSExpr. </b><b class="">Is the problem that the typechecker can’t recognize</b></div><div class=""><b class=""> the Strings as JSExprs?]</b></div><div class="">|#</div><div class=""><br class=""></div><div class="">;; Attempt #N (<b class="">shortest </b><b class="">successful version I’ve found</b>):</div></div><div class="">(define jsx</div><div class=""><div class=""> (for/hasheq : (HashTable Symbol JSExpr) ([k '(a b c)]</div><div class=""> [v '("val1" "val2" "val3")])</div><div class=""> (values k v)))</div></div><div class=""><b class="">;;;; end</b></div><div class=""><br class=""></div><div class="">Regards,</div><div class="">Jordan</div><div class=""><br class=""></div></div>____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br></body></html>