 
 import Foreign.C
 import Foreign.Ptr
-import Foreign.ForeignPtr
+import Foreign.Concurrent
+import Foreign.ForeignPtr hiding (newForeignPtr, addForeignPtrFinalizer)
 import Foreign.Storable (Storable)
 
 import qualified Foreign.Storable as F

withDevicePtr' :: DevicePtr a -> (Ptr b -> IO c) -> IO c
withDevicePtr' =  withForeignPtr . castForeignPtr

newDevicePtr :: Ptr a -> IO (DevicePtr a)
newDevicePtr =  newForeignPtr_


--

-- |
-- Free previously allocated memory on the device
--

--free   :: DevicePtr a -> IO (Maybe String)
--free p =  nothingIfOk `fmap` (withDevicePtr p cudaFree)

free :: DevicePtr a -> IO ()
free =  finalizeForeignPtr

free_   :: Ptr a -> IO ()
free_ p =  cudaFree p >>= \rv ->
