carray-0.1.1: A C-compatible array library.





This module provides both the mutable IOCArray which uses pinned memory on the GC'd heap. Elements are stored according to the class Storable. You can obtain a pointer to the array contents to manipulate elements from languages like C.

IOCArray is 16-byte aligned by default. If you create a IOCArray with unsafeForeignPtrToIOCArray then it may not be aligned. This will be an issue if you intend to use SIMD instructions.

IOCArray is equivalent to Data.Array.Storable.StorableArray and similar to Data.Array.IO.IOUArray but slower. IOCArray has O(1) versions of unsafeFreeze and unsafeThaw when converting to/from CArray.


IOCArray type

data IOCArray i e Source

Absolutely equivalent representation, but used for the mutable interface.


Foreign support

withIOCArray :: IOCArray i e -> (Ptr e -> IO a) -> IO aSource

touchIOCArray :: IOCArray i e -> IO ()Source

If you want to use it afterwards, ensure that you touchCArray after the last use of the pointer, so the array is not freed too early.

The overloaded mutable array interface