{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ExplicitNamespaces #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators #-}
module Control.Concurrent.Class.MonadSTM.Strict.TBQueue
(
StrictTBQueue
, LazyTBQueue
, toLazyTBQueue
, fromLazyTBQueue
, castStrictTBQueue
, newTBQueue
, newTBQueueIO
, readTBQueue
, tryReadTBQueue
, peekTBQueue
, tryPeekTBQueue
, flushTBQueue
, writeTBQueue
, lengthTBQueue
, isEmptyTBQueue
, isFullTBQueue
, unGetTBQueue
, labelTBQueue
, labelTBQueueIO
, traceTBQueue
, traceTBQueueIO
) where
import Control.Concurrent.Class.MonadSTM.TBQueue qualified as Lazy
import Control.Monad.Class.MonadSTM hiding (traceTBQueue, traceTBQueueIO)
import Numeric.Natural (Natural)
type LazyTBQueue m = Lazy.TBQueue m
newtype StrictTBQueue m a = StrictTBQueue { forall (m :: * -> *) a. StrictTBQueue m a -> LazyTBQueue m a
toLazyTBQueue :: LazyTBQueue m a }
fromLazyTBQueue :: LazyTBQueue m a -> StrictTBQueue m a
fromLazyTBQueue :: forall (m :: * -> *) a. LazyTBQueue m a -> StrictTBQueue m a
fromLazyTBQueue = LazyTBQueue m a -> StrictTBQueue m a
forall (m :: * -> *) a. LazyTBQueue m a -> StrictTBQueue m a
StrictTBQueue
castStrictTBQueue :: LazyTBQueue m ~ LazyTBQueue n
=> StrictTBQueue m a -> StrictTBQueue n a
castStrictTBQueue :: forall (m :: * -> *) (n :: * -> *) a.
(LazyTBQueue m ~ LazyTBQueue n) =>
StrictTBQueue m a -> StrictTBQueue n a
castStrictTBQueue (StrictTBQueue LazyTBQueue m a
var) = LazyTBQueue n a -> StrictTBQueue n a
forall (m :: * -> *) a. LazyTBQueue m a -> StrictTBQueue m a
StrictTBQueue LazyTBQueue m a
LazyTBQueue n a
var
labelTBQueue :: MonadLabelledSTM m => StrictTBQueue m a -> String -> STM m ()
labelTBQueue :: forall (m :: * -> *) a.
MonadLabelledSTM m =>
StrictTBQueue m a -> String -> STM m ()
labelTBQueue (StrictTBQueue LazyTBQueue m a
queue) = LazyTBQueue m a -> String -> STM m ()
forall a. TBQueue m a -> String -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TBQueue m a -> String -> STM m ()
Lazy.labelTBQueue LazyTBQueue m a
queue
labelTBQueueIO :: MonadLabelledSTM m => StrictTBQueue m a -> String -> m ()
labelTBQueueIO :: forall (m :: * -> *) a.
MonadLabelledSTM m =>
StrictTBQueue m a -> String -> m ()
labelTBQueueIO (StrictTBQueue LazyTBQueue m a
queue) = LazyTBQueue m a -> String -> m ()
forall a. TBQueue m a -> String -> m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TBQueue m a -> String -> m ()
Lazy.labelTBQueueIO LazyTBQueue m a
queue
traceTBQueue :: MonadTraceSTM m
=> proxy m
-> StrictTBQueue m a
-> ((Maybe [a]) -> [a] -> InspectMonad m TraceValue)
-> STM m ()
traceTBQueue :: forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadTraceSTM m =>
proxy m
-> StrictTBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
traceTBQueue proxy m
p (StrictTBQueue LazyTBQueue m a
queue) = proxy m
-> LazyTBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadTraceSTM m =>
proxy m
-> TBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
forall (proxy :: (* -> *) -> *) a.
proxy m
-> TBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
Lazy.traceTBQueue proxy m
p LazyTBQueue m a
queue
traceTBQueueIO :: MonadTraceSTM m
=> StrictTBQueue m a
-> ((Maybe [a]) -> [a] -> InspectMonad m TraceValue)
-> m ()
traceTBQueueIO :: forall (m :: * -> *) a.
MonadTraceSTM m =>
StrictTBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue) -> m ()
traceTBQueueIO (StrictTBQueue LazyTBQueue m a
queue) = LazyTBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue) -> m ()
forall a.
TBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue) -> m ()
forall (m :: * -> *) a.
MonadTraceSTM m =>
TBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue) -> m ()
Lazy.traceTBQueueIO LazyTBQueue m a
queue
newTBQueue :: MonadSTM m => Natural -> STM m (StrictTBQueue m a)
newTBQueue :: forall (m :: * -> *) a.
MonadSTM m =>
Natural -> STM m (StrictTBQueue m a)
newTBQueue Natural
n = LazyTBQueue m a -> StrictTBQueue m a
forall (m :: * -> *) a. LazyTBQueue m a -> StrictTBQueue m a
StrictTBQueue (LazyTBQueue m a -> StrictTBQueue m a)
-> STM m (LazyTBQueue m a) -> STM m (StrictTBQueue m a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Natural -> STM m (LazyTBQueue m a)
forall a. Natural -> STM m (TBQueue m a)
forall (m :: * -> *) a.
MonadSTM m =>
Natural -> STM m (TBQueue m a)
Lazy.newTBQueue Natural
n
newTBQueueIO :: MonadSTM m => Natural -> m (StrictTBQueue m a)
newTBQueueIO :: forall (m :: * -> *) a.
MonadSTM m =>
Natural -> m (StrictTBQueue m a)
newTBQueueIO = STM m (StrictTBQueue m a) -> m (StrictTBQueue m a)
forall a. HasCallStack => STM m a -> m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m (StrictTBQueue m a) -> m (StrictTBQueue m a))
-> (Natural -> STM m (StrictTBQueue m a))
-> Natural
-> m (StrictTBQueue m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> STM m (StrictTBQueue m a)
forall (m :: * -> *) a.
MonadSTM m =>
Natural -> STM m (StrictTBQueue m a)
newTBQueue
readTBQueue :: MonadSTM m => StrictTBQueue m a -> STM m a
readTBQueue :: forall (m :: * -> *) a. MonadSTM m => StrictTBQueue m a -> STM m a
readTBQueue = TBQueue m a -> STM m a
forall a. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
Lazy.readTBQueue (TBQueue m a -> STM m a)
-> (StrictTBQueue m a -> TBQueue m a)
-> StrictTBQueue m a
-> STM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StrictTBQueue m a -> TBQueue m a
forall (m :: * -> *) a. StrictTBQueue m a -> LazyTBQueue m a
toLazyTBQueue
tryReadTBQueue :: MonadSTM m => StrictTBQueue m a -> STM m (Maybe a)
tryReadTBQueue :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTBQueue m a -> STM m (Maybe a)
tryReadTBQueue = TBQueue m a -> STM m (Maybe a)
forall a. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
Lazy.tryReadTBQueue (TBQueue m a -> STM m (Maybe a))
-> (StrictTBQueue m a -> TBQueue m a)
-> StrictTBQueue m a
-> STM m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StrictTBQueue m a -> TBQueue m a
forall (m :: * -> *) a. StrictTBQueue m a -> LazyTBQueue m a
toLazyTBQueue
peekTBQueue :: MonadSTM m => StrictTBQueue m a -> STM m a
peekTBQueue :: forall (m :: * -> *) a. MonadSTM m => StrictTBQueue m a -> STM m a
peekTBQueue = TBQueue m a -> STM m a
forall a. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
Lazy.peekTBQueue (TBQueue m a -> STM m a)
-> (StrictTBQueue m a -> TBQueue m a)
-> StrictTBQueue m a
-> STM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StrictTBQueue m a -> TBQueue m a
forall (m :: * -> *) a. StrictTBQueue m a -> LazyTBQueue m a
toLazyTBQueue
tryPeekTBQueue :: MonadSTM m => StrictTBQueue m a -> STM m (Maybe a)
tryPeekTBQueue :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTBQueue m a -> STM m (Maybe a)
tryPeekTBQueue = TBQueue m a -> STM m (Maybe a)
forall a. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
Lazy.tryPeekTBQueue (TBQueue m a -> STM m (Maybe a))
-> (StrictTBQueue m a -> TBQueue m a)
-> StrictTBQueue m a
-> STM m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StrictTBQueue m a -> TBQueue m a
forall (m :: * -> *) a. StrictTBQueue m a -> LazyTBQueue m a
toLazyTBQueue
flushTBQueue :: MonadSTM m => StrictTBQueue m a -> STM m [a]
flushTBQueue :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTBQueue m a -> STM m [a]
flushTBQueue = TBQueue m a -> STM m [a]
forall a. TBQueue m a -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m [a]
Lazy.flushTBQueue (TBQueue m a -> STM m [a])
-> (StrictTBQueue m a -> TBQueue m a)
-> StrictTBQueue m a
-> STM m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StrictTBQueue m a -> TBQueue m a
forall (m :: * -> *) a. StrictTBQueue m a -> LazyTBQueue m a
toLazyTBQueue
writeTBQueue :: MonadSTM m => StrictTBQueue m a -> a -> STM m ()
writeTBQueue :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTBQueue m a -> a -> STM m ()
writeTBQueue (StrictTBQueue LazyTBQueue m a
tqueue) !a
a = LazyTBQueue m a -> a -> STM m ()
forall a. TBQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> a -> STM m ()
Lazy.writeTBQueue LazyTBQueue m a
tqueue a
a
lengthTBQueue :: MonadSTM m => StrictTBQueue m a -> STM m Natural
lengthTBQueue :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTBQueue m a -> STM m Natural
lengthTBQueue = TBQueue m a -> STM m Natural
forall a. TBQueue m a -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Natural
Lazy.lengthTBQueue (TBQueue m a -> STM m Natural)
-> (StrictTBQueue m a -> TBQueue m a)
-> StrictTBQueue m a
-> STM m Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StrictTBQueue m a -> TBQueue m a
forall (m :: * -> *) a. StrictTBQueue m a -> LazyTBQueue m a
toLazyTBQueue
isEmptyTBQueue :: MonadSTM m => StrictTBQueue m a -> STM m Bool
isEmptyTBQueue :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTBQueue m a -> STM m Bool
isEmptyTBQueue = TBQueue m a -> STM m Bool
forall a. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
Lazy.isEmptyTBQueue (TBQueue m a -> STM m Bool)
-> (StrictTBQueue m a -> TBQueue m a)
-> StrictTBQueue m a
-> STM m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StrictTBQueue m a -> TBQueue m a
forall (m :: * -> *) a. StrictTBQueue m a -> LazyTBQueue m a
toLazyTBQueue
isFullTBQueue :: MonadSTM m => StrictTBQueue m a -> STM m Bool
isFullTBQueue :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTBQueue m a -> STM m Bool
isFullTBQueue = TBQueue m a -> STM m Bool
forall a. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
Lazy.isFullTBQueue (TBQueue m a -> STM m Bool)
-> (StrictTBQueue m a -> TBQueue m a)
-> StrictTBQueue m a
-> STM m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StrictTBQueue m a -> TBQueue m a
forall (m :: * -> *) a. StrictTBQueue m a -> LazyTBQueue m a
toLazyTBQueue
unGetTBQueue :: MonadSTM m => StrictTBQueue m a -> a -> STM m ()
unGetTBQueue :: forall (m :: * -> *) a.
MonadSTM m =>
StrictTBQueue m a -> a -> STM m ()
unGetTBQueue (StrictTBQueue LazyTBQueue m a
queue) !a
a = LazyTBQueue m a -> a -> STM m ()
forall a. TBQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> a -> STM m ()
Lazy.unGetTBQueue LazyTBQueue m a
queue a
a