module Control.Concurrent.MonadIO (
MonadIO(..)
, C.MVar
, newEmptyMVar
, newMVar
, takeMVar
, putMVar
, readMVar
, swapMVar
, tryTakeMVar
, tryPutMVar
, isEmptyMVar
, C.Chan
, newChan
, writeChan
, readChan
, dupChan
, unGetChan
, isEmptyChan
, getChanContents
, writeList2Chan
, HasFork(..)
, C.ThreadId
, forkIO
, myThreadId
, killThread
, throwTo
, yield
, threadDelay
)
where
import Control.Monad.Trans(MonadIO(..))
import qualified Control.Concurrent as C
import qualified Control.Exception as E
newEmptyMVar :: MonadIO io => io (C.MVar a)
newEmptyMVar = liftIO $ C.newEmptyMVar
newMVar :: MonadIO io => a -> io (C.MVar a)
newMVar x = liftIO $ C.newMVar x
takeMVar :: MonadIO io => C.MVar a -> io a
takeMVar m = liftIO $ C.takeMVar m
putMVar :: MonadIO io => C.MVar a -> a -> io ()
putMVar m x = liftIO $ C.putMVar m x
readMVar :: MonadIO io => C.MVar a -> io a
readMVar m = liftIO $ C.readMVar m
swapMVar :: MonadIO io => C.MVar a -> a -> io a
swapMVar m x = liftIO $ C.swapMVar m x
tryTakeMVar :: MonadIO io => C.MVar a -> io (Maybe a)
tryTakeMVar m = liftIO $ C.tryTakeMVar m
tryPutMVar :: MonadIO io => C.MVar a -> a -> io Bool
tryPutMVar m x = liftIO $ C.tryPutMVar m x
isEmptyMVar :: MonadIO io => C.MVar a -> io Bool
isEmptyMVar m = liftIO $ C.isEmptyMVar m
newChan :: MonadIO io => io (C.Chan a)
newChan = liftIO $ C.newChan
writeChan :: MonadIO io => C.Chan a -> a -> io ()
writeChan c x = liftIO $ C.writeChan c x
readChan :: MonadIO io => C.Chan a -> io a
readChan c = liftIO $ C.readChan c
dupChan :: MonadIO io => C.Chan a -> io (C.Chan a)
dupChan c = liftIO $ C.dupChan c
unGetChan :: MonadIO io => C.Chan a -> a -> io ()
unGetChan c x = liftIO $ unGetChan c x
isEmptyChan :: MonadIO io => C.Chan a -> io Bool
isEmptyChan c = liftIO $ C.isEmptyChan c
getChanContents :: MonadIO io => C.Chan a -> io [a]
getChanContents c = liftIO $ C.getChanContents c
writeList2Chan :: MonadIO io => C.Chan a -> [a] -> io ()
writeList2Chan c xs = liftIO $ C.writeList2Chan c xs
class MonadIO io => HasFork io where
fork :: io () -> io C.ThreadId
instance HasFork IO where
fork m = C.forkIO m
forkIO :: IO () -> IO C.ThreadId
forkIO = C.forkIO
myThreadId :: HasFork io => io C.ThreadId
myThreadId = liftIO $ C.myThreadId
killThread :: HasFork io => C.ThreadId -> io ()
killThread i = liftIO $ C.killThread i
throwTo :: (E.Exception e, HasFork io) => C.ThreadId -> e -> io ()
throwTo i e = liftIO $ C.throwTo i e
yield :: HasFork io => io ()
yield = liftIO $ C.yield
threadDelay :: HasFork io => Int -> io ()
threadDelay n = liftIO $ C.threadDelay n