Description
We have PrimStorable
to derive Storable
instances from Prim
instances. It would be very nice to be able to offer a StorablePrim
to go the other way. Unfortunately, I don't think it's quite possible to do this.
The tricky parts are the ByteArray#
and MutableByteArray#
operations. We can almost use byteArrayContents# :: ByteArray# -> Addr#
, but that only works reliably if the ByteArray#
is pinned. The trouble is that the garbage collector could run between the time we get the address of the start of the array and the time the appropriate Storable
method uses it. I'm pretty sure the only entirely reliable way to implement these operations would be to copy the entire array, which is just awful.
On the other hand, we can offer adapter functions for all the other Prim
methods, so I think we should add them.