{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleContexts #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Safe #-}
#endif
module Control.Concurrent.Chan.Lifted
( Chan
, newChan
, writeChan
, readChan
, dupChan
, getChanContents
, writeList2Chan
) where
import Control.Concurrent.Chan ( Chan )
import qualified Control.Concurrent.Chan as Chan
import System.IO ( IO )
import Prelude ( (.) )
import Control.Monad.Base ( MonadBase, liftBase )
#include "inlinable.h"
newChan :: MonadBase IO m => m (Chan a)
newChan :: forall (m :: * -> *) a. MonadBase IO m => m (Chan a)
newChan = IO (Chan a) -> m (Chan a)
forall α. IO α -> m α
forall (b :: * -> *) (m :: * -> *) α. MonadBase b m => b α -> m α
liftBase IO (Chan a)
forall a. IO (Chan a)
Chan.newChan
{-# INLINABLE newChan #-}
writeChan :: MonadBase IO m => Chan a -> a -> m ()
writeChan :: forall (m :: * -> *) a. MonadBase IO m => Chan a -> a -> m ()
writeChan Chan a
chan = IO () -> m ()
forall α. IO α -> m α
forall (b :: * -> *) (m :: * -> *) α. MonadBase b m => b α -> m α
liftBase (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 ()
Chan.writeChan Chan a
chan
{-# INLINABLE writeChan #-}
readChan :: MonadBase IO m => Chan a -> m a
readChan :: forall (m :: * -> *) a. MonadBase IO m => Chan a -> m a
readChan = IO a -> m a
forall α. IO α -> m α
forall (b :: * -> *) (m :: * -> *) α. MonadBase b m => b α -> m α
liftBase (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
Chan.readChan
{-# INLINABLE readChan #-}
dupChan :: MonadBase IO m => Chan a -> m (Chan a)
dupChan :: forall (m :: * -> *) a. MonadBase IO m => Chan a -> m (Chan a)
dupChan = IO (Chan a) -> m (Chan a)
forall α. IO α -> m α
forall (b :: * -> *) (m :: * -> *) α. MonadBase b m => b α -> m α
liftBase (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)
Chan.dupChan
{-# INLINABLE dupChan #-}
getChanContents :: MonadBase IO m => Chan a -> m [a]
getChanContents :: forall (m :: * -> *) a. MonadBase IO m => Chan a -> m [a]
getChanContents = IO [a] -> m [a]
forall α. IO α -> m α
forall (b :: * -> *) (m :: * -> *) α. MonadBase b m => b α -> m α
liftBase (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]
Chan.getChanContents
{-# INLINABLE getChanContents #-}
writeList2Chan :: MonadBase IO m => Chan a -> [a] -> m ()
writeList2Chan :: forall (m :: * -> *) a. MonadBase IO m => Chan a -> [a] -> m ()
writeList2Chan Chan a
chan = IO () -> m ()
forall α. IO α -> m α
forall (b :: * -> *) (m :: * -> *) α. MonadBase b m => b α -> m α
liftBase (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 ()
Chan.writeList2Chan Chan a
chan
{-# INLINABLE writeList2Chan #-}