<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 26, 2014 at 11:56 AM, Andreas Abel <span dir="ltr"><<a href="mailto:andreas.abel@ifi.lmu.de" target="_blank">andreas.abel@ifi.lmu.de</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Machine integers have the size of the addressable main memory, so they should be used (exclusively?) for quantities that are limited by the size of the memory, like the mentioned indices into data structures like vectors or arrays.<br>


<br>
With Word I can address as many objects as my machine can hold bytes. However, the objects are usually not bytes, but words themselves.  Thus, Int, which is only one bit short of Word, is as good as Word as an index type.  Further, Int supports subtraction.<br>

</blockquote><div><br></div><div>"Usually" is not always. You address bytes and Int is not large enough to do so. In fact, this proposal was partly triggered by GHC doing the wrong thing with really large array indices, as the primops have a Int# argument which caused a wraparound. This in turn led to bad Cmm being generated and finally a segfault in the overflow1 test in the GHC test suite.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I do not know what Word would be good for to the amount that it deserves a place in Prelude.<br></blockquote>

<div><br></div><div>Bit twiddling of all kinds. We use it for e.g. bitmasks in unordered-containers. Hashing, etc.</div><div><br></div></div></div></div>