{-# LANGUAGE BangPatterns       #-}
{-# LANGUAGE CPP                #-}
{-# LANGUAGE ExplicitNamespaces #-}
{-# LANGUAGE GADTs              #-}
{-# LANGUAGE NamedFieldPuns     #-}
{-# LANGUAGE TypeOperators      #-}

-- | This module corresponds to `Control.Concurrent.STM.TChan` in "stm" package
--
module Control.Concurrent.Class.MonadSTM.Strict.TChan
  ( StrictTChan
  , LazyTChan
  , toLazyTChan
  , fromLazyTChan
  , castStrictTChan
  , newTChan
  , newBroadcastTChan
  , writeTChan
  , readTChan
  , tryReadTChan
  , peekTChan
  , tryPeekTChan
  , dupTChan
  , unGetTChan
  , isEmptyTChan
  , cloneTChan
  ) where


import qualified Control.Concurrent.Class.MonadSTM.TChan as Lazy
import           Control.Monad.Class.MonadSTM


type LazyTChan   m = Lazy.TChan m

newtype StrictTChan m a = StrictTChan { forall (m :: * -> *) a. StrictTChan m a -> LazyTChan m a
toLazyTChan :: LazyTChan m a }

fromLazyTChan :: LazyTChan m a -> StrictTChan m a
fromLazyTChan :: forall (m :: * -> *) a. LazyTChan m a -> StrictTChan m a
fromLazyTChan = forall (m :: * -> *) a. LazyTChan m a -> StrictTChan m a
StrictTChan

castStrictTChan :: LazyTChan m ~ LazyTChan n
                => StrictTChan m a -> StrictTChan n a
castStrictTChan :: forall (m :: * -> *) (n :: * -> *) a.
(LazyTChan m ~ LazyTChan n) =>
StrictTChan m a -> StrictTChan n a
castStrictTChan (StrictTChan LazyTChan m a
var) = forall (m :: * -> *) a. LazyTChan m a -> StrictTChan m a
StrictTChan LazyTChan m a
var

newTChan :: MonadSTM m => STM m (StrictTChan m a)
newTChan :: forall (m :: * -> *) a. MonadSTM m => STM m (StrictTChan m a)
newTChan = forall (m :: * -> *) a. LazyTChan m a -> StrictTChan m a
StrictTChan forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. MonadSTM m => STM m (TChan m a)
Lazy.newTChan

newBroadcastTChan :: MonadSTM m => STM m (StrictTChan m a)
newBroadcastTChan :: forall (m :: * -> *) a. MonadSTM m => STM m (StrictTChan m a)
newBroadcastTChan = forall (m :: * -> *) a. LazyTChan m a -> StrictTChan m a
StrictTChan forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. MonadSTM m => STM m (TChan m a)
Lazy.newBroadcastTChan

writeTChan :: MonadSTM m => StrictTChan m a -> a -> STM m ()
writeTChan :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTChan m a -> a -> STM m ()
writeTChan (StrictTChan LazyTChan m a
chan) !a
a = forall (m :: * -> *) a. MonadSTM m => TChan m a -> a -> STM m ()
Lazy.writeTChan LazyTChan m a
chan a
a

readTChan :: MonadSTM m => StrictTChan m a -> STM m a
readTChan :: forall (m :: * -> *) a. MonadSTM m => StrictTChan m a -> STM m a
readTChan = forall (m :: * -> *) a. MonadSTM m => TChan m a -> STM m a
Lazy.readTChan forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. StrictTChan m a -> LazyTChan m a
toLazyTChan

tryReadTChan :: MonadSTM m => StrictTChan m a -> STM m (Maybe a)
tryReadTChan :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTChan m a -> STM m (Maybe a)
tryReadTChan = forall (m :: * -> *) a. MonadSTM m => TChan m a -> STM m (Maybe a)
Lazy.tryReadTChan forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. StrictTChan m a -> LazyTChan m a
toLazyTChan

peekTChan :: MonadSTM m => StrictTChan m a -> STM m a
peekTChan :: forall (m :: * -> *) a. MonadSTM m => StrictTChan m a -> STM m a
peekTChan = forall (m :: * -> *) a. MonadSTM m => TChan m a -> STM m a
Lazy.peekTChan forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. StrictTChan m a -> LazyTChan m a
toLazyTChan

tryPeekTChan :: MonadSTM m => StrictTChan m a -> STM m (Maybe a)
tryPeekTChan :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTChan m a -> STM m (Maybe a)
tryPeekTChan = forall (m :: * -> *) a. MonadSTM m => TChan m a -> STM m (Maybe a)
Lazy.tryPeekTChan forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. StrictTChan m a -> LazyTChan m a
toLazyTChan

dupTChan :: MonadSTM m => StrictTChan m a -> STM m (StrictTChan m a)
dupTChan :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTChan m a -> STM m (StrictTChan m a)
dupTChan = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (m :: * -> *) a. LazyTChan m a -> StrictTChan m a
fromLazyTChan forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a.
MonadSTM m =>
TChan m a -> STM m (TChan m a)
Lazy.dupTChan forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. StrictTChan m a -> LazyTChan m a
toLazyTChan

unGetTChan :: MonadSTM m => StrictTChan m a -> a -> STM m ()
unGetTChan :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTChan m a -> a -> STM m ()
unGetTChan (StrictTChan LazyTChan m a
chan) !a
a = forall (m :: * -> *) a. MonadSTM m => TChan m a -> a -> STM m ()
Lazy.unGetTChan LazyTChan m a
chan a
a

isEmptyTChan :: MonadSTM m => StrictTChan m a -> STM m Bool
isEmptyTChan :: forall (m :: * -> *) a. MonadSTM m => StrictTChan m a -> STM m Bool
isEmptyTChan = forall (m :: * -> *) a. MonadSTM m => TChan m a -> STM m Bool
Lazy.isEmptyTChan forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. StrictTChan m a -> LazyTChan m a
toLazyTChan

cloneTChan :: MonadSTM m => StrictTChan m a -> STM m (StrictTChan m a)
cloneTChan :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTChan m a -> STM m (StrictTChan m a)
cloneTChan = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (m :: * -> *) a. LazyTChan m a -> StrictTChan m a
fromLazyTChan forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a.
MonadSTM m =>
TChan m a -> STM m (TChan m a)
Lazy.cloneTChan forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. StrictTChan m a -> LazyTChan m a
toLazyTChan