 -- |
 -- A device context
 --
-{# pointer *CUcontext as Context foreign newtype #}
-withContext :: Context -> (Ptr Context -> IO a) -> IO a
-
---
--- XXX: Probably want to add a finaliser to `destroy' the context before
--- releasing its reference. Not done as this may flag an error, which could be
--- picked up by later driver calls.
---
-newContext :: IO Context
-newContext = Context `fmap` mallocForeignPtrBytes (sizeOf (undefined :: Ptr ()))
+newtype Context = Context { useContext :: {# type CUcontext #}}
 
 
 -- |

-- System
import Foreign
import Foreign.C
import Foreign.ForeignPtr
import Control.Monad                    (liftM)



-- context must be floating (via `pop'), i.e. not attached to any thread.
--
push :: Context -> IO (Maybe String)
push ctx = nothingIfOk `fmap` cuCtxPushCurrent ctx

{# fun unsafe cuCtxPushCurrent
  { useContext `Context' } -> `Status' cToEnum #}


-- |
