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

Henning Thielemann lemming at henning-thielemann.de
Sat Nov 3 06:56:17 UTC 2018


On Fri, 26 Oct 2018, Henning Thielemann wrote:

> 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?

Thinking about it ... these functions are intended for access of record 
fields. Then the following type signatures would have been better:

peekField :: Ptr b -> Offset b a -> IO a
pokeField :: Ptr b -> Offset b a -> a -> IO ()

newtype Offset b a = Offset Int

This way we had more type safety and no need for Addr or lying Ptr's.


More information about the Libraries mailing list