module UnliftIO.Chan
( Chan
, newChan
, writeChan
, readChan
, dupChan
, getChanContents
, writeList2Chan
) where
import Control.Monad.IO.Unlift
import Control.Concurrent.Chan (Chan)
import qualified Control.Concurrent.Chan as C
newChan :: MonadIO m => m (Chan a)
newChan :: m (Chan a)
newChan = IO (Chan a) -> m (Chan a)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO (Chan a)
forall a. IO (Chan a)
C.newChan
writeChan :: MonadIO m => Chan a -> a -> m ()
writeChan :: Chan a -> a -> m ()
writeChan Chan a
c = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (a -> IO ()) -> a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Chan a -> a -> IO ()
forall a. Chan a -> a -> IO ()
C.writeChan Chan a
c
readChan :: MonadIO m => Chan a -> m a
readChan :: Chan a -> m a
readChan = IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> m a) -> (Chan a -> IO a) -> Chan a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Chan a -> IO a
forall a. Chan a -> IO a
C.readChan
dupChan :: MonadIO m => Chan a -> m (Chan a)
dupChan :: Chan a -> m (Chan a)
dupChan = IO (Chan a) -> m (Chan a)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Chan a) -> m (Chan a))
-> (Chan a -> IO (Chan a)) -> Chan a -> m (Chan a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Chan a -> IO (Chan a)
forall a. Chan a -> IO (Chan a)
C.dupChan
getChanContents :: MonadIO m => Chan a -> m [a]
getChanContents :: Chan a -> m [a]
getChanContents = IO [a] -> m [a]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [a] -> m [a]) -> (Chan a -> IO [a]) -> Chan a -> m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Chan a -> IO [a]
forall a. Chan a -> IO [a]
C.getChanContents
writeList2Chan :: MonadIO m => Chan a -> [a] -> m ()
writeList2Chan :: Chan a -> [a] -> m ()
writeList2Chan Chan a
c = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> ([a] -> IO ()) -> [a] -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Chan a -> [a] -> IO ()
forall a. Chan a -> [a] -> IO ()
C.writeList2Chan Chan a
c