     f dptr     >>= return
 
 
+withArrayLen :: Storable a => [a] -> (Int -> DevicePtr a -> IO b) -> IO b
+withArrayLen vals fun =
+    let len   = length vals
+        bytes = fromIntegral len * fromIntegral (F.sizeOf (head vals))
+    in do
+        dptr <- forceEither `fmap` malloc bytes
+        pokeArray dptr vals
+        fun len dptr
+
+
 --------------------------------------------------------------------------------
 -- Copying
 --------------------------------------------------------------------------------

         -> Int64                       -- ^ The allocation pitch, as returned by 'malloc2D'
         -> Int                         -- ^ Value to set for each byte
         -> IO (Maybe String)
memset2D ptr (width,height) pitch symbol = nothingIfOk `fmap` cudaMemset2D ptr pitch symbol width height

{# fun unsafe cudaMemset2D
    { withDevicePtr* `DevicePtr a' ,

--    memset2D,
--    memset3D,

    -- ** Local allocation
    alloca,
    allocaBytes,

    -- ** Marshalling
    peek,
    poke,
