 moduleErr :: String -> String -> a
 moduleErr fun msg =  error ("Foreign.CUDA." ++ fun ++ ':':' ':msg)
 
-moduleForceEither :: Either String a -> a
-moduleForceEither (Left  s) = moduleErr "Marshal" s
-moduleForceEither (Right r) = r
-

memset :: DevicePtr a                   -- ^ The device memory
       -> Int64                         -- ^ Number of bytes
       -> Int                           -- ^ Value to set for each byte
       -> IO (Maybe String)
memset ptr bytes symbol =
    nothingIfOk `fmap` cudaMemset ptr symbol bytes

{# fun unsafe cudaMemset
    { withDevPtrCast* `DevicePtr a' ,
                      `Int'         ,
      cIntConv        `Int64'       } -> `Status' cToEnum #}
    where
      withDevPtrCast = withDevicePtr . castDevicePtr


-- |

         -> (Int64, Int64)              -- ^ The (width,height) of the matrix in bytes
         -> Int64                       -- ^ The allocation pitch, as returned by 'malloc2D'
         -> Int                         -- ^ Value to set for each byte
         -> IO ()
memset2D ptr (width,height) pitch symbol =
  nothingIfOk =<< cudaMemset2D ptr pitch symbol width height

{# fun unsafe cudaMemset2D
  { withDevPtrCast* `DevicePtr a'
  , cIntConv        `Int64'
  ,                 `Int'
  , cIntConv        `Int64'
  , cIntConv        `Int64'       } -> `Status' cToEnum #}
  where
    withDevPtrCast = withDevicePtr . castDevicePtr


-- |
