id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,difficulty,testcase,blockedby,blocking,related
5091,Proposal: Retrieving the System Event Manager,basvandijk,,"When you want to use the system event manager (the one started by the
RTS) you currently have to do something like this:

{{{
{-# LANGUAGE ForeignFunctionInterface #-}

import System.Event (EventManager)
import GHC.Conc.Sync (sharedCAF)
import Foreign.Ptr (Ptr)
import Data.IORef (IORef, newIORef, readIORef)
import System.IO.Unsafe (unsafePerformIO)

main = do
  Just mgr <- readIORef eventManager
  ...

eventManager :: IORef (Maybe EventManager)
eventManager = unsafePerformIO $ do
    em <- newIORef Nothing
    sharedCAF em getOrSetSystemEventThreadEventManagerStore
{-# NOINLINE eventManager #-}

foreign import ccall unsafe ""getOrSetSystemEventThreadEventManagerStore""
    getOrSetSystemEventThreadEventManagerStore :: Ptr a -> IO (Ptr a)
}}}

I propose to abstract this ugliness in a function:

{{{
getSystemEventManager :: IO (Maybe EventManager)
getSystemEventManager = readIORef eventManager
}}}

and export it from `GHC.Event`.

I don't think this needs to go through the library submission process since the module is GHC specific.

See the [http://thread.gmane.org/gmane.comp.lang.haskell.libraries/15458/ thread on the libraries list].
",task,closed,normal,,libraries/base,7.0.3,fixed,,,Unknown/Multiple,Unknown/Multiple,None/Unknown,,,,,
