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

David Feuer david.feuer at gmail.com
Fri Oct 26 20:59:16 UTC 2018


I think you're looking at this wrong. An Addr doesn't need to point to
anything corresponding to a Haskell value at all. It's perfectly
acceptable for an FFI call to return an Addr pointing to some C
structure somewhere that Haskell never touches at all. Instead,
Haskell code may use it only as an argument to some other FFI call.
The only real reason to *have* Addr# rather than just using Int# or
Word# is that there's no inherent guarantee that a long in C is the
same size as a pointer.
On Fri, Oct 26, 2018 at 4:38 PM Sven Panne <svenpanne at gmail.com> wrote:
>
> Am Fr., 26. Okt. 2018 um 22:31 Uhr schrieb Andrew Martin <andrew.thaddeus at gmail.com>:
>>
>> The better alternative suggested in this thread is to use Addr instead. That way, you don't have to lie about the type of the serialized data that the pointer is pointing to.
>
>
> Even if I'm repeating myself: That is not lying, quite the opposite. If you e.g. use a C library with suboptimal typing (i.e. more often than not), you make the impedance matching explicit. How would you achieve that with Addr?
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


More information about the Libraries mailing list