<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>You can use make-immutable-hash instead of hash, or you can use hash-set (functional update) to make a new hash based on an old one, and so you can still have (hash) as the base case for a for/fold or a foldr or something like that, which is at least one good use for a hash that takes zero arguments.  But I agree that I would like it to able to take 2, 4, 6, or 8 arguments.</div><div><br></div><div>And the type tooltips are useful for the documentation bit.</div><div><br></div><div><div>On Jan 24, 2015, at 1:43 AM, Matthew Butterick <<a href="mailto:mb@mbtype.com">mb@mbtype.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">I've been starting to learn Typed Racket. I discovered this thread when I ran into the same confusion about the behavior of TR's `hash`. FWIW, Sam's point that one can't expect every untyped program to work without modification is entirely fair. But Konrad's point is also fair: if a function like `append` or `hash` works differently in TR, then it is, for practical purposes, not the same function, even if it relies on the same code. If it would be superfluous to repeat every TR function in the documentation, it still could be valuable to document some of the major departures from Racket. I mean, I would read that, for sure ;)<div><br></div><div><div>PS. I remain curious what one can do with an immutable `hash` function that takes no arguments, but perhaps it is meant to be a TR koan.</div><div><br></div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 29, 2014 at 10:39 AM, Sam Tobin-Hochstadt <span dir="ltr"><<a href="mailto:samth@cs.indiana.edu" target="_blank">samth@cs.indiana.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Wed, Oct 29, 2014 at 12:32 PM, Konrad Hinsen<br>
<<a href="mailto:konrad.hinsen@fastmail.net">konrad.hinsen@fastmail.net</a>> wrote:<br>
<br>
> Of course, the Type Checker can't be wrong, so let's ask it what the type<br>
> of hash is:<br>
><br>
>   ≻ hash<br>
>   - : (All (a b) (-> (HashTable a b)))<br>
>   #<procedure:hash><br>
><br>
> Right, no arguments. So Typed Racket's hash is a restricted version of<br>
> plain Racket's hash. But there is no documentation whatsoever of this<br>
> restriction. Searching the Racket docs for hash yields only the one from<br>
> racket/base.<br>
<br>
</span>This isn't a different version of `hash` -- instead, it's the same<br>
version, with a type that doesn't accept every working untyped Racket<br>
program.<br>
<br>
This is true in other contexts as well:<br>
<br>
-> (append 5)<br>
5<br>
-> (require typed/racket)<br>
-> (append 5)<br>
; Type Checker: Polymorphic function `append' could not be<br>
;   applied to arguments:<br>
; Domain: (Listof a) *<br>
; Arguments: Positive-Byte<br>
;   in: (append 5)<br>
<br>
The type checker can't handle every possible working Racket program,<br>
and thus there are cases where you have to change your program to<br>
accommodate the type checker.<br>
<br>
The type of `hash` is one that comes up a bunch, and we should<br>
probably just add a few special cases that handle 2/4/6 arguments.<br>
Unfortunately, we don't yet have a mechanism for fully supporting the<br>
behavior of `hash`, and so there will be cases that work in untyped<br>
Racket but not in Typed Racket.<br>
<br>
As for documenting this, the types, which you can print at the REPL,<br>
are the best documentation. Just recently, Asumu added tooltips so<br>
you'll be able to see the type of `hash` online in DrRacket. I don't<br>
think repeating the types for every export of `racket` in the<br>
documentation would be helpful, especially in cases where they're<br>
quite complicated.<br>
<br>
Thanks for the useful feedback, and I hope you keep using Typed Racket,<br>
Sam<br>
<div class="HOEnZb"><div class="h5"><br>
____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br></div></div></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>