Storable laws

David Feuer david.feuer at
Sat Dec 16 05:33:36 UTC 2017

The documentation for pokeByteOff indicates that the following equality

  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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list