<div dir="ltr"><div>Hi all,</div><div><br></div><div>I've just noticed that all `WordX` (and `IntX`) data types are</div><div>actually implemented as wrappers around `Word#` (and `Int#`). This</div><div>probably doesn't matter much if it's stored on the heap (due to</div><div>pointer indirection and heap alignment), but it also means that:</div><div>```</div><div>data Foo = Foo {-# UNPACK #-} !Word8 {-# UNPACK #-} !Int8</div><div>```</div><div>will actually take *a lot* of space: on 64 bit we'd need 8 bytes for</div><div>header, 8 bytes for `Word8`, 8 bytes for `Int8`.</div><div><br></div><div>Is there any reason for this? The only thing I can see is that this</div><div>avoids having to add things like `Word8#` primitives into the</div><div>compiler. (also the codegen would need to emit zero-extend moves when</div><div>loading from memory, like `movzb{l,q}`)</div><div><br></div><div>If we had things like `Word8#` we could also consider changing `Bool`</div><div>to just wrap it (with the obvious encoding). Which would allow to both</div><div>UNPACK `Bool` *and* save the size within the struct. (alternatively</div><div>one could imagine a `Bool#` that would be just a byte)</div><div><br></div><div>I couldn't find any discussion about this, so any pointers would be</div><div>welcome. :)</div><div><br></div><div>Thanks,</div><div>Michal</div><div><br></div><div>PS.  I've had a look at it after reading about the recent</div><div>implementation of struct field reordering optimization in rustc:</div><div><a href="http://camlorn.net/posts/April%202017/rust-struct-field-reordering.html">http://camlorn.net/posts/April%202017/rust-struct-field-reordering.html</a></div><div><br></div></div>