|
Foreign.Marshal.Array | Portability | portable | Stability | provisional | Maintainer | ffi@haskell.org |
|
|
|
|
|
Description |
Marshalling support: routines allocating, storing, and retrieving Haskell
lists that are represented as arrays in the foreign language
|
|
Synopsis |
|
|
|
|
Marshalling arrays |
|
Allocation |
|
mallocArray :: Storable a => Int -> IO (Ptr a) |
Allocate storage for the given number of elements of a storable type.
|
|
mallocArray0 :: Storable a => Int -> IO (Ptr a) |
Like mallocArray, but add an extra element to signal the end of the array
|
|
allocaArray :: Storable a => Int -> (Ptr a -> IO b) -> IO b |
Temporarily allocate space for the given number of elements.
- see alloca for the storage lifetime constraints
|
|
allocaArray0 :: Storable a => Int -> (Ptr a -> IO b) -> IO b |
Like allocaArray, but add an extra element to signal the end of the array
|
|
reallocArray :: Storable a => Ptr a -> Int -> IO (Ptr a) |
Adjust the size of an array
|
|
reallocArray0 :: Storable a => Ptr a -> Int -> IO (Ptr a) |
Adjust the size of an array while adding an element for the end marker
|
|
Marshalling |
|
peekArray :: Storable a => Int -> Ptr a -> IO [a] |
Convert an array of given length into a Haskell list. This version
traverses the array backwards using an accumulating parameter,
which uses constant stack space. The previous version using mapM
needed linear stack space.
|
|
peekArray0 :: (Storable a, Eq a) => a -> Ptr a -> IO [a] |
Convert an array terminated by the given end marker into a Haskell list
|
|
pokeArray :: Storable a => Ptr a -> [a] -> IO () |
Write the list elements consecutive into memory
|
|
pokeArray0 :: Storable a => a -> Ptr a -> [a] -> IO () |
Write the list elements consecutive into memory and terminate them with the
given marker element
|
|
Combined allocation and marshalling |
|
newArray :: Storable a => [a] -> IO (Ptr a) |
Write a list of storable elements into a newly allocated, consecutive
sequence of storable values
|
|
newArray0 :: Storable a => a -> [a] -> IO (Ptr a) |
Write a list of storable elements into a newly allocated, consecutive
sequence of storable values, where the end is fixed by the given end marker
|
|
withArray :: Storable a => [a] -> (Ptr a -> IO b) -> IO b |
Temporarily store a list of storable values in memory
|
|
withArray0 :: Storable a => a -> [a] -> (Ptr a -> IO b) -> IO b |
Like withArray, but a terminator indicates where the array ends
|
|
Copying |
|
(argument order: destination, source) |
|
copyArray :: Storable a => Ptr a -> Ptr a -> Int -> IO () |
Copy the given number of elements from the second array (source) into the
first array (destination); the copied areas may not overlap
|
|
moveArray :: Storable a => Ptr a -> Ptr a -> Int -> IO () |
Copy the given number of elements from the second array (source) into the
first array (destination); the copied areas may overlap
|
|
Finding the length |
|
lengthArray0 :: (Storable a, Eq a) => a -> Ptr a -> IO Int |
Return the number of elements in an array, excluding the terminator
|
|
Indexing |
|
advancePtr :: Storable a => Ptr a -> Int -> Ptr a |
Advance a pointer into an array by the given number of elements
|
|
Produced by Haddock version 0.6 |