
16 Dec
2017
16 Dec
'17
5:33 a.m.
The documentation for pokeByteOff indicates that the following equality holds: pokeElemOff addr idx x = poke (addr `plusPtr` (idx * sizeOf x)) x Notably, this ignores alignment. It thus seems to imply that sizeOf must always be a multiple of alignment; otherwise, non-zero indices could access non-aligned addresses. Was this intentional? If so, I believe sizeOf and alignment should document the law. If not, then I believe the {poke,peek}ElemOff laws need to change to something like pokeElemOff addr idx x = poke (addr `plusPtr` (idx * lcm (sizeOf x) (alignment x))) x