Proposal: Move primitive-Data.Primitive.Addr API into base

Henning Thielemann lemming at henning-thielemann.de
Fri Oct 26 09:15:02 UTC 2018


On Thu, 25 Oct 2018, David Feuer wrote:

> Ptr Word8 is not (just) a pointer to byte-addressable memory. It's 
> specifically a pointer to something representing an 8-bit unsigned 
> integer. If you use a Ptr Word8 for the address of a floating point 
> value, then you are *wrong* (or doing something very weird, anyway). To 
> quote the documentation,
> 
> A value of type Ptr a represents a pointer to an object, or an array of 
> objects, which may be marshalled to or from Haskell values of type a.

Interesting observations.

There are the Storable methods

peekByteOff :: Ptr b -> Int -> IO a
pokeByteOff :: Ptr b -> Int -> a -> IO ()

They ignore the target types of their pointers. Should be Addr, then, too?

And if we are touching Storable class, how about passing Proxy's to sizeOf 
and alignment instead of undefined values? Maybe we should add new methods 
to Storable class with default implementations that redirect to the old 
methods.


More information about the Libraries mailing list