 
 {# fun unsafe cuMemcpyHtoDAsync
   { useDevicePtr `DevicePtr a'
-  , castPtr      `Ptr a'
+  , useHP        `HostPtr a'
   ,              `Int'
   , useStream    `Stream'  } -> `Status' cToEnum #}
+  where
+    useHP = castPtr . useHostPtr
+
+
+-- |
+-- Write a list of storable elements into a device array. The device array must
+-- be sufficiently large to hold the entire list. This requires two marshalling
+-- operations.
+--
+pokeListArray :: Storable a => [a] -> DevicePtr a -> IO ()
+pokeListArray xs dptr = F.withArrayLen xs $ \len p -> pokeArray len p dptr
+
+
+--------------------------------------------------------------------------------
+-- Combined Allocation and Marshalling
+--------------------------------------------------------------------------------
+
+-- |
+-- Write a list of storable elements into a newly allocated device array. Note
+-- that this requires two memory copies: firstly from a Haskell list to a heap
+-- allocated array, and from there onto the graphics device. The memory should
+-- be 'free'd when no longer required.
+--
+newListArray :: Storable a => [a] -> IO (DevicePtr a)
+newListArray xs =
+  F.withArrayLen xs                     $ \len p ->
+  bracketOnError (mallocArray len) free $ \d_xs  -> do
+    pokeArray len p d_xs
+    return d_xs
+
+
+-- |
+-- Temporarily store a list of elements into a newly allocated device array. An
+-- IO action is applied to to the array, the result of which is returned.
+-- Similar to 'newListArray', this requires copying the data twice.
+--
+-- As with 'allocaArray', the memory is freed once the action completes, so you
+-- should not return the pointer from the action, and be wary of asynchronous
+-- kernel execution.
+--
+withListArray :: Storable a => [a] -> (DevicePtr a -> IO b) -> IO b
+withListArray xs = bracket (newListArray xs) free
 
 
 --------------------------------------------------------------------------------

import Foreign.CUDA.Driver.Stream               (Stream(..))

-- System
import Foreign                           hiding (peekArray, pokeArray, malloc, free)
import Foreign.C
import Control.Monad                            (liftM)
import Unsafe.Coerce

#c
typedef enum CUmemhostalloc_option_enum {



--------------------------------------------------------------------------------
-- Marshalling
--------------------------------------------------------------------------------

-- |
