[Haskell-cafe] vector, alignment and SIMD through FFI

Thomas DuBuisson thomas.dubuisson at gmail.com
Fri Jul 6 22:43:20 CEST 2012


On Fri, Jul 6, 2012 at 1:06 PM, Nicolas Trangez <nicolas at incubaid.com> wrote:
>     -- This fails:
>     -- Ambiguous type variable `a0' in the constraint:
>     --   (Storable a0) arising from a use of `sizeOf'

Here you can either tie a type knot using proxy types or you can use
the scoped type variable language extension.

Perhaps I'm missing something specific to your use, but for the
alignment issue you should be OK just calling allocBytes or one of its
variants.  I made some noise about this a bit ago and it resulted in
some extra words in the report under mallocBytes:

"""
The block of memory is sufficiently aligned for any of the basic
foreign types that fits into a memory block of the allocated size.
"""

Which I'm pretty sure GHC did, and still does, follow.

Cheers,
Thomas



More information about the Haskell-Cafe mailing list