Discussion: Storable instances for tuples

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Discussion: Storable instances for tuples

David Feuer
It seems surprising that there are no Storable instances for tuple types. I would expect any tuple of Storable types to be Storable. To provide a sensible FFI experience, the order of the fields should be preserved. Since Storable generally aligns values, I believe elements should be aligned within tuples as well, in the default fashion used for C structs. We could offer a Packed newtype to override this behavior.

Why store tuples like this, and not the way Data.Vector.Unboxed does? A moment's reflection will show that it simply can't. A Ptr is a single pointer and must remain one; there's no room in it to deal with multiple arrays or extra offset info.

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Discussion: Storable instances for tuples

Henning Thielemann

On Fri, 15 Dec 2017, David Feuer wrote:

> It seems surprising that there are no Storable instances for tuple types. I would expect any tuple of Storable
> types to be Storable. To provide a sensible FFI experience, the order of the fields should be preserved. Since
> Storable generally aligns values, I believe elements should be aligned within tuples as well, in the default
> fashion used for C structs. We could offer a Packed newtype to override this behavior.

I had the same suggestion when we discussed instance Storable (). Sven
Panne answered:
    http://mail.haskell.org/pipermail/libraries/2015-June/025903.html
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries