-- | Lifted "Control.Concurrent.Chan".
--
-- @since 0.1.0.0
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

-- | Lifted 'C.newChan'.
--
-- @since 0.1.0.0
newChan :: MonadIO m => m (Chan a)
newChan :: forall (m :: * -> *) a. MonadIO m => m (Chan a)
newChan = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a. IO (Chan a)
C.newChan

-- | Lifted 'C.writeChan'.
--
-- @since 0.1.0.0
writeChan :: MonadIO m => Chan a -> a -> m ()
writeChan :: forall (m :: * -> *) a. MonadIO m => Chan a -> a -> m ()
writeChan Chan a
c = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Chan a -> a -> IO ()
C.writeChan Chan a
c

-- | Lifted 'C.readChan'.
--
-- @since 0.1.0.0
readChan :: MonadIO m => Chan a -> m a
readChan :: forall (m :: * -> *) a. MonadIO m => Chan a -> m a
readChan = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Chan a -> IO a
C.readChan

-- | Lifted 'C.dupChan'.
--
-- @since 0.1.0.0
dupChan :: MonadIO m => Chan a -> m (Chan a)
dupChan :: forall (m :: * -> *) a. MonadIO m => Chan a -> m (Chan a)
dupChan = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Chan a -> IO (Chan a)
C.dupChan

-- | Lifted 'C.getChanContents'.
--
-- @since 0.1.0.0
getChanContents :: MonadIO m => Chan a -> m [a]
getChanContents :: forall (m :: * -> *) a. MonadIO m => Chan a -> m [a]
getChanContents = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Chan a -> IO [a]
C.getChanContents

-- | Lifted 'C.writeList2Chan'.
--
-- @since 0.1.0.0
writeList2Chan :: MonadIO m => Chan a -> [a] -> m ()
writeList2Chan :: forall (m :: * -> *) a. MonadIO m => Chan a -> [a] -> m ()
writeList2Chan Chan a
c = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Chan a -> [a] -> IO ()
C.writeList2Chan Chan a
c