{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
module Control.Monad.Class.MonadSTM
( MonadSTM (..)
, MonadLabelledSTM (..)
, MonadInspectSTM (..)
, TraceValue (TraceValue, TraceDynamic, TraceString, DontTrace, traceDynamic, traceString)
, MonadTraceSTM (..)
, LazyTVar
, LazyTMVar
, TMVarDefault (..)
, labelTMVarDefault
, traceTMVarDefault
, newTMVarDefault
, newTMVarIODefault
, newEmptyTMVarDefault
, newEmptyTMVarIODefault
, takeTMVarDefault
, tryTakeTMVarDefault
, putTMVarDefault
, tryPutTMVarDefault
, readTMVarDefault
, tryReadTMVarDefault
, swapTMVarDefault
, isEmptyTMVarDefault
, TQueueDefault (..)
, labelTQueueDefault
, newTQueueDefault
, readTQueueDefault
, tryReadTQueueDefault
, peekTQueueDefault
, tryPeekTQueueDefault
, writeTQueueDefault
, isEmptyTQueueDefault
, TBQueueDefault (..)
, labelTBQueueDefault
, newTBQueueDefault
, readTBQueueDefault
, tryReadTBQueueDefault
, peekTBQueueDefault
, tryPeekTBQueueDefault
, writeTBQueueDefault
, isEmptyTBQueueDefault
, isFullTBQueueDefault
, lengthTBQueueDefault
, flushTBQueueDefault
, throwSTM
, catchSTM
, newTVarM
, newTMVarM
, newTMVarMDefault
, newEmptyTMVarM
, newEmptyTMVarMDefault
, WrappedSTM (..)
) where
import Prelude hiding (read)
import qualified Control.Concurrent.STM.TBQueue as STM
import qualified Control.Concurrent.STM.TMVar as STM
import qualified Control.Concurrent.STM.TQueue as STM
import qualified Control.Concurrent.STM.TVar as STM
import Control.Monad (MonadPlus (..))
import qualified Control.Monad.STM as STM
import Control.Monad.Cont (ContT (..))
import Control.Monad.Except (ExceptT (..))
import Control.Monad.RWS (RWST (..))
import Control.Monad.Reader (ReaderT (..))
import Control.Monad.State (StateT (..))
import Control.Monad.Trans (lift)
import Control.Monad.Writer (WriterT (..))
import qualified Control.Monad.Class.MonadThrow as MonadThrow
import Control.Applicative (Alternative (..))
import Control.Exception
import Data.Function (on)
import Data.Kind (Type)
import Data.Typeable (Typeable)
import GHC.Stack
import Numeric.Natural (Natural)
{-# DEPRECATED LazyTVar "Renamed back to 'TVar'" #-}
{-# DEPRECATED LazyTMVar "Renamed back to 'TMVar'" #-}
type LazyTVar m = TVar m
type LazyTMVar m = TMVar m
class ( Monad m
, Alternative (STM m)
, MonadPlus (STM m)
) => MonadSTM m where
type STM m = (stm :: Type -> Type) | stm -> m
atomically :: HasCallStack => STM m a -> m a
type TVar m :: Type -> Type
newTVar :: a -> STM m (TVar m a)
readTVar :: TVar m a -> STM m a
writeTVar :: TVar m a -> a -> STM m ()
retry :: STM m a
orElse :: STM m a -> STM m a -> STM m a
modifyTVar :: TVar m a -> (a -> a) -> STM m ()
modifyTVar TVar m a
v a -> a
f = TVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m a
v STM m a -> (a -> STM m ()) -> STM m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= TVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m a
v (a -> STM m ()) -> (a -> a) -> a -> STM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a
f
modifyTVar' :: TVar m a -> (a -> a) -> STM m ()
modifyTVar' TVar m a
v a -> a
f = TVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m a
v STM m a -> (a -> STM m ()) -> STM m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \a
x -> TVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m a
v (a -> STM m ()) -> a -> STM m ()
forall a b. (a -> b) -> a -> b
$! a -> a
f a
x
stateTVar :: TVar m s -> (s -> (a, s)) -> STM m a
stateTVar = TVar m s -> (s -> (a, s)) -> STM m a
forall (m :: * -> *) s a.
MonadSTM m =>
TVar m s -> (s -> (a, s)) -> STM m a
stateTVarDefault
swapTVar :: TVar m a -> a -> STM m a
swapTVar = TVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m a
swapTVarDefault
check :: Bool -> STM m ()
check Bool
True = () -> STM m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
check Bool
_ = STM m ()
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
type TMVar m :: Type -> Type
newTMVar :: a -> STM m (TMVar m a)
newEmptyTMVar :: STM m (TMVar m a)
takeTMVar :: TMVar m a -> STM m a
tryTakeTMVar :: TMVar m a -> STM m (Maybe a)
putTMVar :: TMVar m a -> a -> STM m ()
tryPutTMVar :: TMVar m a -> a -> STM m Bool
readTMVar :: TMVar m a -> STM m a
tryReadTMVar :: TMVar m a -> STM m (Maybe a)
swapTMVar :: TMVar m a -> a -> STM m a
isEmptyTMVar :: TMVar m a -> STM m Bool
type TQueue m :: Type -> Type
newTQueue :: STM m (TQueue m a)
readTQueue :: TQueue m a -> STM m a
tryReadTQueue :: TQueue m a -> STM m (Maybe a)
peekTQueue :: TQueue m a -> STM m a
tryPeekTQueue :: TQueue m a -> STM m (Maybe a)
writeTQueue :: TQueue m a -> a -> STM m ()
isEmptyTQueue :: TQueue m a -> STM m Bool
type TBQueue m :: Type -> Type
newTBQueue :: Natural -> STM m (TBQueue m a)
readTBQueue :: TBQueue m a -> STM m a
tryReadTBQueue :: TBQueue m a -> STM m (Maybe a)
peekTBQueue :: TBQueue m a -> STM m a
tryPeekTBQueue :: TBQueue m a -> STM m (Maybe a)
flushTBQueue :: TBQueue m a -> STM m [a]
writeTBQueue :: TBQueue m a -> a -> STM m ()
lengthTBQueue :: TBQueue m a -> STM m Natural
isEmptyTBQueue :: TBQueue m a -> STM m Bool
isFullTBQueue :: TBQueue m a -> STM m Bool
newTVarIO :: a -> m (TVar m a)
readTVarIO :: TVar m a -> m a
newTMVarIO :: a -> m (TMVar m a)
newEmptyTMVarIO :: m (TMVar m a)
newTQueueIO :: m (TQueue m a)
newTBQueueIO :: Natural -> m (TBQueue m a)
newTVarIO = STM m (TVar m a) -> m (TVar m a)
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m (TVar m a) -> m (TVar m a))
-> (a -> STM m (TVar m a)) -> a -> m (TVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar
readTVarIO = STM m a -> m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m a -> m a) -> (TVar m a -> STM m a) -> TVar m a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar
newTMVarIO = STM m (TMVar m a) -> m (TMVar m a)
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m (TMVar m a) -> m (TMVar m a))
-> (a -> STM m (TMVar m a)) -> a -> m (TMVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TMVar m a)
newTMVar
newEmptyTMVarIO = STM m (TMVar m a) -> m (TMVar m a)
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TMVar m a)
newEmptyTMVar
newTQueueIO = STM m (TQueue m a) -> m (TQueue m a)
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically STM m (TQueue m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TQueue m a)
newTQueue
newTBQueueIO = STM m (TBQueue m a) -> m (TBQueue m a)
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m (TBQueue m a) -> m (TBQueue m a))
-> (Natural -> STM m (TBQueue m a)) -> Natural -> m (TBQueue m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> STM m (TBQueue m a)
forall (m :: * -> *) a.
MonadSTM m =>
Natural -> STM m (TBQueue m a)
newTBQueue
stateTVarDefault :: MonadSTM m => TVar m s -> (s -> (a, s)) -> STM m a
stateTVarDefault :: TVar m s -> (s -> (a, s)) -> STM m a
stateTVarDefault TVar m s
var s -> (a, s)
f = do
s
s <- TVar m s -> STM m s
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m s
var
let (a
a, s
s') = s -> (a, s)
f s
s
TVar m s -> s -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m s
var s
s'
a -> STM m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
swapTVarDefault :: MonadSTM m => TVar m a -> a -> STM m a
swapTVarDefault :: TVar m a -> a -> STM m a
swapTVarDefault TVar m a
var a
new = do
a
old <- TVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m a
var
TVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m a
var a
new
a -> STM m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
old
newTVarM :: MonadSTM m => a -> m (TVar m a)
newTVarM :: a -> m (TVar m a)
newTVarM = a -> m (TVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> m (TVar m a)
newTVarIO
{-# DEPRECATED newTVarM "Use newTVarIO" #-}
newTMVarM :: MonadSTM m => a -> m (TMVar m a)
newTMVarM :: a -> m (TMVar m a)
newTMVarM = a -> m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> m (TMVar m a)
newTMVarIO
{-# DEPRECATED newTMVarM "Use newTMVarIO" #-}
newEmptyTMVarM :: MonadSTM m => m (TMVar m a)
newEmptyTMVarM :: m (TMVar m a)
newEmptyTMVarM = m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => m (TMVar m a)
newEmptyTMVarIO
{-# DEPRECATED newEmptyTMVarM "Use newEmptyTMVarIO" #-}
class MonadSTM m
=> MonadLabelledSTM m where
labelTVar :: TVar m a -> String -> STM m ()
labelTMVar :: TMVar m a -> String -> STM m ()
labelTQueue :: TQueue m a -> String -> STM m ()
labelTBQueue :: TBQueue m a -> String -> STM m ()
labelTVarIO :: TVar m a -> String -> m ()
labelTMVarIO :: TMVar m a -> String -> m ()
labelTQueueIO :: TQueue m a -> String -> m ()
labelTBQueueIO :: TBQueue m a -> String -> m ()
default labelTVarIO :: TVar m a -> String -> m ()
labelTVarIO = \TVar m a
v String
l -> STM m () -> m ()
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (TVar m a -> String -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TVar m a -> String -> STM m ()
labelTVar TVar m a
v String
l)
default labelTMVarIO :: TMVar m a -> String -> m ()
labelTMVarIO = \TMVar m a
v String
l -> STM m () -> m ()
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (TMVar m a -> String -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TMVar m a -> String -> STM m ()
labelTMVar TMVar m a
v String
l)
default labelTQueueIO :: TQueue m a -> String -> m ()
labelTQueueIO = \TQueue m a
v String
l -> STM m () -> m ()
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (TQueue m a -> String -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TQueue m a -> String -> STM m ()
labelTQueue TQueue m a
v String
l)
default labelTBQueueIO :: TBQueue m a -> String -> m ()
labelTBQueueIO = \TBQueue m a
v String
l -> STM m () -> m ()
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (TBQueue m a -> String -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TBQueue m a -> String -> STM m ()
labelTBQueue TBQueue m a
v String
l)
class ( MonadSTM m
, Monad (InspectMonad m)
)
=> MonadInspectSTM m where
type InspectMonad m :: Type -> Type
inspectTVar :: proxy m -> TVar m a -> InspectMonad m a
inspectTMVar :: proxy m -> TMVar m a -> InspectMonad m (Maybe a)
instance MonadInspectSTM IO where
type InspectMonad IO = IO
inspectTVar :: proxy IO -> TVar IO a -> InspectMonad IO a
inspectTVar proxy IO
_ = TVar IO a -> InspectMonad IO a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> m a
readTVarIO
inspectTMVar :: proxy IO -> TMVar IO a -> InspectMonad IO (Maybe a)
inspectTMVar proxy IO
_ = STM (Maybe a) -> IO (Maybe a)
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM (Maybe a) -> IO (Maybe a))
-> (TMVar a -> STM (Maybe a)) -> TMVar a -> IO (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar a -> STM (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryReadTMVar
data TraceValue where
TraceValue :: forall tr. Typeable tr
=> { ()
traceDynamic :: Maybe tr
, TraceValue -> Maybe String
traceString :: Maybe String
}
-> TraceValue
pattern TraceDynamic :: () => forall tr. Typeable tr => tr -> TraceValue
pattern $bTraceDynamic :: tr -> TraceValue
$mTraceDynamic :: forall r.
TraceValue
-> (forall tr. Typeable tr => tr -> r) -> (Void# -> r) -> r
TraceDynamic tr <- TraceValue { traceDynamic = Just tr }
where
TraceDynamic tr
tr = TraceValue :: forall tr. Typeable tr => Maybe tr -> Maybe String -> TraceValue
TraceValue { traceDynamic :: Maybe tr
traceDynamic = tr -> Maybe tr
forall a. a -> Maybe a
Just tr
tr, traceString :: Maybe String
traceString = Maybe String
forall a. Maybe a
Nothing }
pattern TraceString :: String -> TraceValue
pattern $bTraceString :: String -> TraceValue
$mTraceString :: forall r. TraceValue -> (String -> r) -> (Void# -> r) -> r
TraceString tr <- TraceValue { traceString = Just tr }
where
TraceString String
tr = TraceValue :: forall tr. Typeable tr => Maybe tr -> Maybe String -> TraceValue
TraceValue { traceDynamic :: Maybe ()
traceDynamic = (Maybe ()
forall a. Maybe a
Nothing :: Maybe ())
, traceString :: Maybe String
traceString = String -> Maybe String
forall a. a -> Maybe a
Just String
tr
}
pattern DontTrace :: TraceValue
pattern $bDontTrace :: TraceValue
$mDontTrace :: forall r. TraceValue -> (Void# -> r) -> (Void# -> r) -> r
DontTrace <- TraceValue Nothing Nothing
where
DontTrace = Maybe () -> Maybe String -> TraceValue
forall tr. Typeable tr => Maybe tr -> Maybe String -> TraceValue
TraceValue (Maybe ()
forall a. Maybe a
Nothing :: Maybe ()) Maybe String
forall a. Maybe a
Nothing
class MonadInspectSTM m
=> MonadTraceSTM m where
{-# MINIMAL traceTVar, traceTQueue, traceTBQueue #-}
traceTVar :: proxy m
-> TVar m a
-> (Maybe a -> a -> InspectMonad m TraceValue)
-> STM m ()
traceTMVar :: proxy m
-> TMVar m a
-> (Maybe (Maybe a) -> (Maybe a) -> InspectMonad m TraceValue)
-> STM m ()
traceTQueue :: proxy m
-> TQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
traceTBQueue :: proxy m
-> TBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
default traceTMVar :: ( TMVar m a ~ TMVarDefault m a
)
=> proxy m
-> TMVar m a
-> (Maybe (Maybe a) -> (Maybe a) -> InspectMonad m TraceValue)
-> STM m ()
traceTMVar = proxy m
-> TMVar m a
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
-> STM m ()
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadTraceSTM m =>
proxy m
-> TMVarDefault m a
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
-> STM m ()
traceTMVarDefault
traceTVarIO :: proxy m
-> TVar m a
-> (Maybe a -> a -> InspectMonad m TraceValue)
-> m ()
traceTMVarIO :: proxy m
-> TMVar m a
-> (Maybe (Maybe a) -> (Maybe a) -> InspectMonad m TraceValue)
-> m ()
traceTQueueIO :: proxy m
-> TQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> m ()
traceTBQueueIO :: proxy m
-> TBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> m ()
default traceTVarIO :: proxy m
-> TVar m a
-> (Maybe a -> a -> InspectMonad m TraceValue)
-> m ()
traceTVarIO = \proxy m
p TVar m a
v Maybe a -> a -> InspectMonad m TraceValue
f -> STM m () -> m ()
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (proxy m
-> TVar m a
-> (Maybe a -> a -> InspectMonad m TraceValue)
-> STM m ()
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadTraceSTM m =>
proxy m
-> TVar m a
-> (Maybe a -> a -> InspectMonad m TraceValue)
-> STM m ()
traceTVar proxy m
p TVar m a
v Maybe a -> a -> InspectMonad m TraceValue
f)
default traceTMVarIO :: proxy m
-> TMVar m a
-> (Maybe (Maybe a) -> (Maybe a) -> InspectMonad m TraceValue)
-> m ()
traceTMVarIO = \proxy m
p TMVar m a
v Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue
f -> STM m () -> m ()
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (proxy m
-> TMVar m a
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
-> STM m ()
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadTraceSTM m =>
proxy m
-> TMVar m a
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
-> STM m ()
traceTMVar proxy m
p TMVar m a
v Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue
f)
default traceTQueueIO :: proxy m
-> TQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> m ()
traceTQueueIO = \proxy m
p TQueue m a
v Maybe [a] -> [a] -> InspectMonad m TraceValue
f -> STM m () -> m ()
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (proxy m
-> TQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadTraceSTM m =>
proxy m
-> TQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
traceTQueue proxy m
p TQueue m a
v Maybe [a] -> [a] -> InspectMonad m TraceValue
f)
default traceTBQueueIO :: proxy m
-> TBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> m ()
traceTBQueueIO = \proxy m
p TBQueue m a
v Maybe [a] -> [a] -> InspectMonad m TraceValue
f -> STM m () -> m ()
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (proxy m
-> TBQueue 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 ()
traceTBQueue proxy m
p TBQueue m a
v Maybe [a] -> [a] -> InspectMonad m TraceValue
f)
instance MonadSTM IO where
type STM IO = STM.STM
atomically :: STM IO a -> IO a
atomically = IO a -> IO a
forall a. HasCallStack => IO a -> IO a
wrapBlockedIndefinitely (IO a -> IO a) -> (STM a -> IO a) -> STM a -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM a -> IO a
forall a. STM a -> IO a
STM.atomically
type TVar IO = STM.TVar
type TMVar IO = STM.TMVar
type TQueue IO = STM.TQueue
type TBQueue IO = STM.TBQueue
newTVar :: a -> STM IO (TVar IO a)
newTVar = a -> STM IO (TVar IO a)
forall a. a -> STM (TVar a)
STM.newTVar
readTVar :: TVar IO a -> STM IO a
readTVar = TVar IO a -> STM IO a
forall a. TVar a -> STM a
STM.readTVar
writeTVar :: TVar IO a -> a -> STM IO ()
writeTVar = TVar IO a -> a -> STM IO ()
forall a. TVar a -> a -> STM ()
STM.writeTVar
retry :: STM IO a
retry = STM IO a
forall a. STM a
STM.retry
orElse :: STM IO a -> STM IO a -> STM IO a
orElse = STM IO a -> STM IO a -> STM IO a
forall a. STM a -> STM a -> STM a
STM.orElse
modifyTVar :: TVar IO a -> (a -> a) -> STM IO ()
modifyTVar = TVar IO a -> (a -> a) -> STM IO ()
forall a. TVar a -> (a -> a) -> STM ()
STM.modifyTVar
modifyTVar' :: TVar IO a -> (a -> a) -> STM IO ()
modifyTVar' = TVar IO a -> (a -> a) -> STM IO ()
forall a. TVar a -> (a -> a) -> STM ()
STM.modifyTVar'
stateTVar :: TVar IO s -> (s -> (a, s)) -> STM IO a
stateTVar = TVar IO s -> (s -> (a, s)) -> STM IO a
forall s a. TVar s -> (s -> (a, s)) -> STM a
STM.stateTVar
swapTVar :: TVar IO a -> a -> STM IO a
swapTVar = TVar IO a -> a -> STM IO a
forall a. TVar a -> a -> STM a
STM.swapTVar
check :: Bool -> STM IO ()
check = Bool -> STM ()
Bool -> STM IO ()
STM.check
newTMVar :: a -> STM IO (TMVar IO a)
newTMVar = a -> STM IO (TMVar IO a)
forall a. a -> STM (TMVar a)
STM.newTMVar
newEmptyTMVar :: STM IO (TMVar IO a)
newEmptyTMVar = STM IO (TMVar IO a)
forall a. STM (TMVar a)
STM.newEmptyTMVar
takeTMVar :: TMVar IO a -> STM IO a
takeTMVar = TMVar IO a -> STM IO a
forall a. TMVar a -> STM a
STM.takeTMVar
tryTakeTMVar :: TMVar IO a -> STM IO (Maybe a)
tryTakeTMVar = TMVar IO a -> STM IO (Maybe a)
forall a. TMVar a -> STM (Maybe a)
STM.tryTakeTMVar
putTMVar :: TMVar IO a -> a -> STM IO ()
putTMVar = TMVar IO a -> a -> STM IO ()
forall a. TMVar a -> a -> STM ()
STM.putTMVar
tryPutTMVar :: TMVar IO a -> a -> STM IO Bool
tryPutTMVar = TMVar IO a -> a -> STM IO Bool
forall a. TMVar a -> a -> STM Bool
STM.tryPutTMVar
readTMVar :: TMVar IO a -> STM IO a
readTMVar = TMVar IO a -> STM IO a
forall a. TMVar a -> STM a
STM.readTMVar
tryReadTMVar :: TMVar IO a -> STM IO (Maybe a)
tryReadTMVar = TMVar IO a -> STM IO (Maybe a)
forall a. TMVar a -> STM (Maybe a)
STM.tryReadTMVar
swapTMVar :: TMVar IO a -> a -> STM IO a
swapTMVar = TMVar IO a -> a -> STM IO a
forall a. TMVar a -> a -> STM a
STM.swapTMVar
isEmptyTMVar :: TMVar IO a -> STM IO Bool
isEmptyTMVar = TMVar IO a -> STM IO Bool
forall a. TMVar a -> STM Bool
STM.isEmptyTMVar
newTQueue :: STM IO (TQueue IO a)
newTQueue = STM IO (TQueue IO a)
forall a. STM (TQueue a)
STM.newTQueue
readTQueue :: TQueue IO a -> STM IO a
readTQueue = TQueue IO a -> STM IO a
forall a. TQueue a -> STM a
STM.readTQueue
tryReadTQueue :: TQueue IO a -> STM IO (Maybe a)
tryReadTQueue = TQueue IO a -> STM IO (Maybe a)
forall a. TQueue a -> STM (Maybe a)
STM.tryReadTQueue
peekTQueue :: TQueue IO a -> STM IO a
peekTQueue = TQueue IO a -> STM IO a
forall a. TQueue a -> STM a
STM.peekTQueue
tryPeekTQueue :: TQueue IO a -> STM IO (Maybe a)
tryPeekTQueue = TQueue IO a -> STM IO (Maybe a)
forall a. TQueue a -> STM (Maybe a)
STM.tryPeekTQueue
flushTBQueue :: TBQueue IO a -> STM IO [a]
flushTBQueue = TBQueue IO a -> STM IO [a]
forall a. TBQueue a -> STM [a]
STM.flushTBQueue
writeTQueue :: TQueue IO a -> a -> STM IO ()
writeTQueue = TQueue IO a -> a -> STM IO ()
forall a. TQueue a -> a -> STM ()
STM.writeTQueue
isEmptyTQueue :: TQueue IO a -> STM IO Bool
isEmptyTQueue = TQueue IO a -> STM IO Bool
forall a. TQueue a -> STM Bool
STM.isEmptyTQueue
newTBQueue :: Natural -> STM IO (TBQueue IO a)
newTBQueue = Natural -> STM IO (TBQueue IO a)
forall a. Natural -> STM (TBQueue a)
STM.newTBQueue
readTBQueue :: TBQueue IO a -> STM IO a
readTBQueue = TBQueue IO a -> STM IO a
forall a. TBQueue a -> STM a
STM.readTBQueue
tryReadTBQueue :: TBQueue IO a -> STM IO (Maybe a)
tryReadTBQueue = TBQueue IO a -> STM IO (Maybe a)
forall a. TBQueue a -> STM (Maybe a)
STM.tryReadTBQueue
peekTBQueue :: TBQueue IO a -> STM IO a
peekTBQueue = TBQueue IO a -> STM IO a
forall a. TBQueue a -> STM a
STM.peekTBQueue
tryPeekTBQueue :: TBQueue IO a -> STM IO (Maybe a)
tryPeekTBQueue = TBQueue IO a -> STM IO (Maybe a)
forall a. TBQueue a -> STM (Maybe a)
STM.tryPeekTBQueue
writeTBQueue :: TBQueue IO a -> a -> STM IO ()
writeTBQueue = TBQueue IO a -> a -> STM IO ()
forall a. TBQueue a -> a -> STM ()
STM.writeTBQueue
lengthTBQueue :: TBQueue IO a -> STM IO Natural
lengthTBQueue = TBQueue IO a -> STM IO Natural
forall a. TBQueue a -> STM Natural
STM.lengthTBQueue
isEmptyTBQueue :: TBQueue IO a -> STM IO Bool
isEmptyTBQueue = TBQueue IO a -> STM IO Bool
forall a. TBQueue a -> STM Bool
STM.isEmptyTBQueue
isFullTBQueue :: TBQueue IO a -> STM IO Bool
isFullTBQueue = TBQueue IO a -> STM IO Bool
forall a. TBQueue a -> STM Bool
STM.isFullTBQueue
newTVarIO :: a -> IO (TVar IO a)
newTVarIO = a -> IO (TVar IO a)
forall a. a -> IO (TVar a)
STM.newTVarIO
readTVarIO :: TVar IO a -> IO a
readTVarIO = TVar IO a -> IO a
forall a. TVar a -> IO a
STM.readTVarIO
newTMVarIO :: a -> IO (TMVar IO a)
newTMVarIO = a -> IO (TMVar IO a)
forall a. a -> IO (TMVar a)
STM.newTMVarIO
newEmptyTMVarIO :: IO (TMVar IO a)
newEmptyTMVarIO = IO (TMVar IO a)
forall a. IO (TMVar a)
STM.newEmptyTMVarIO
newTQueueIO :: IO (TQueue IO a)
newTQueueIO = IO (TQueue IO a)
forall a. IO (TQueue a)
STM.newTQueueIO
newTBQueueIO :: Natural -> IO (TBQueue IO a)
newTBQueueIO = Natural -> IO (TBQueue IO a)
forall a. Natural -> IO (TBQueue a)
STM.newTBQueueIO
instance MonadLabelledSTM IO where
labelTVar :: TVar IO a -> String -> STM IO ()
labelTVar = \TVar IO a
_ String
_ -> () -> STM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
labelTMVar :: TMVar IO a -> String -> STM IO ()
labelTMVar = \TMVar IO a
_ String
_ -> () -> STM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
labelTQueue :: TQueue IO a -> String -> STM IO ()
labelTQueue = \TQueue IO a
_ String
_ -> () -> STM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
labelTBQueue :: TBQueue IO a -> String -> STM IO ()
labelTBQueue = \TBQueue IO a
_ String
_ -> () -> STM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
labelTVarIO :: TVar IO a -> String -> IO ()
labelTVarIO = \TVar IO a
_ String
_ -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
labelTMVarIO :: TMVar IO a -> String -> IO ()
labelTMVarIO = \TMVar IO a
_ String
_ -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
labelTQueueIO :: TQueue IO a -> String -> IO ()
labelTQueueIO = \TQueue IO a
_ String
_ -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
labelTBQueueIO :: TBQueue IO a -> String -> IO ()
labelTBQueueIO = \TBQueue IO a
_ String
_ -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
instance MonadTraceSTM IO where
traceTVar :: proxy IO
-> TVar IO a
-> (Maybe a -> a -> InspectMonad IO TraceValue)
-> STM IO ()
traceTVar = \proxy IO
_ TVar IO a
_ Maybe a -> a -> InspectMonad IO TraceValue
_ -> () -> STM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
traceTMVar :: proxy IO
-> TMVar IO a
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad IO TraceValue)
-> STM IO ()
traceTMVar = \proxy IO
_ TMVar IO a
_ Maybe (Maybe a) -> Maybe a -> InspectMonad IO TraceValue
_ -> () -> STM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
traceTQueue :: proxy IO
-> TQueue IO a
-> (Maybe [a] -> [a] -> InspectMonad IO TraceValue)
-> STM IO ()
traceTQueue = \proxy IO
_ TQueue IO a
_ Maybe [a] -> [a] -> InspectMonad IO TraceValue
_ -> () -> STM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
traceTBQueue :: proxy IO
-> TBQueue IO a
-> (Maybe [a] -> [a] -> InspectMonad IO TraceValue)
-> STM IO ()
traceTBQueue = \proxy IO
_ TBQueue IO a
_ Maybe [a] -> [a] -> InspectMonad IO TraceValue
_ -> () -> STM ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
traceTVarIO :: proxy IO
-> TVar IO a
-> (Maybe a -> a -> InspectMonad IO TraceValue)
-> IO ()
traceTVarIO = \proxy IO
_ TVar IO a
_ Maybe a -> a -> InspectMonad IO TraceValue
_ -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
traceTMVarIO :: proxy IO
-> TMVar IO a
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad IO TraceValue)
-> IO ()
traceTMVarIO = \proxy IO
_ TMVar IO a
_ Maybe (Maybe a) -> Maybe a -> InspectMonad IO TraceValue
_ -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
traceTQueueIO :: proxy IO
-> TQueue IO a
-> (Maybe [a] -> [a] -> InspectMonad IO TraceValue)
-> IO ()
traceTQueueIO = \proxy IO
_ TQueue IO a
_ Maybe [a] -> [a] -> InspectMonad IO TraceValue
_ -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
traceTBQueueIO :: proxy IO
-> TBQueue IO a
-> (Maybe [a] -> [a] -> InspectMonad IO TraceValue)
-> IO ()
traceTBQueueIO = \proxy IO
_ TBQueue IO a
_ Maybe [a] -> [a] -> InspectMonad IO TraceValue
_ -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
data BlockedIndefinitely = BlockedIndefinitely {
BlockedIndefinitely -> CallStack
blockedIndefinitelyCallStack :: CallStack
, BlockedIndefinitely -> BlockedIndefinitelyOnSTM
blockedIndefinitelyException :: BlockedIndefinitelyOnSTM
}
deriving Int -> BlockedIndefinitely -> ShowS
[BlockedIndefinitely] -> ShowS
BlockedIndefinitely -> String
(Int -> BlockedIndefinitely -> ShowS)
-> (BlockedIndefinitely -> String)
-> ([BlockedIndefinitely] -> ShowS)
-> Show BlockedIndefinitely
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BlockedIndefinitely] -> ShowS
$cshowList :: [BlockedIndefinitely] -> ShowS
show :: BlockedIndefinitely -> String
$cshow :: BlockedIndefinitely -> String
showsPrec :: Int -> BlockedIndefinitely -> ShowS
$cshowsPrec :: Int -> BlockedIndefinitely -> ShowS
Show
instance Exception BlockedIndefinitely where
displayException :: BlockedIndefinitely -> String
displayException (BlockedIndefinitely CallStack
cs BlockedIndefinitelyOnSTM
e) = [String] -> String
unlines [
BlockedIndefinitelyOnSTM -> String
forall e. Exception e => e -> String
displayException BlockedIndefinitelyOnSTM
e
, CallStack -> String
prettyCallStack CallStack
cs
]
wrapBlockedIndefinitely :: HasCallStack => IO a -> IO a
wrapBlockedIndefinitely :: IO a -> IO a
wrapBlockedIndefinitely = (BlockedIndefinitelyOnSTM -> IO a) -> IO a -> IO a
forall e a. Exception e => (e -> IO a) -> IO a -> IO a
handle (BlockedIndefinitely -> IO a
forall e a. Exception e => e -> IO a
throwIO (BlockedIndefinitely -> IO a)
-> (BlockedIndefinitelyOnSTM -> BlockedIndefinitely)
-> BlockedIndefinitelyOnSTM
-> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CallStack -> BlockedIndefinitelyOnSTM -> BlockedIndefinitely
BlockedIndefinitely CallStack
HasCallStack => CallStack
callStack)
newtype TMVarDefault m a = TMVar (TVar m (Maybe a))
labelTMVarDefault
:: MonadLabelledSTM m
=> TMVarDefault m a -> String -> STM m ()
labelTMVarDefault :: TMVarDefault m a -> String -> STM m ()
labelTMVarDefault (TMVar TVar m (Maybe a)
tvar) = TVar m (Maybe a) -> String -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TVar m a -> String -> STM m ()
labelTVar TVar m (Maybe a)
tvar
traceTMVarDefault
:: MonadTraceSTM m
=> proxy m
-> TMVarDefault m a
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
-> STM m ()
traceTMVarDefault :: proxy m
-> TMVarDefault m a
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
-> STM m ()
traceTMVarDefault proxy m
p (TMVar TVar m (Maybe a)
t) Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue
f = proxy m
-> TVar m (Maybe a)
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
-> STM m ()
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadTraceSTM m =>
proxy m
-> TVar m a
-> (Maybe a -> a -> InspectMonad m TraceValue)
-> STM m ()
traceTVar proxy m
p TVar m (Maybe a)
t Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue
f
newTMVarDefault :: MonadSTM m => a -> STM m (TMVarDefault m a)
newTMVarDefault :: a -> STM m (TMVarDefault m a)
newTMVarDefault a
a = do
TVar m (Maybe a)
t <- Maybe a -> STM m (TVar m (Maybe a))
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar (a -> Maybe a
forall a. a -> Maybe a
Just a
a)
TMVarDefault m a -> STM m (TMVarDefault m a)
forall (m :: * -> *) a. Monad m => a -> m a
return (TVar m (Maybe a) -> TMVarDefault m a
forall (m :: * -> *) a. TVar m (Maybe a) -> TMVarDefault m a
TMVar TVar m (Maybe a)
t)
newTMVarIODefault :: MonadSTM m => a -> m (TMVarDefault m a)
newTMVarIODefault :: a -> m (TMVarDefault m a)
newTMVarIODefault a
a = do
TVar m (Maybe a)
t <- Maybe a -> m (TVar m (Maybe a))
forall (m :: * -> *) a. MonadSTM m => a -> m (TVar m a)
newTVarM (a -> Maybe a
forall a. a -> Maybe a
Just a
a)
TMVarDefault m a -> m (TMVarDefault m a)
forall (m :: * -> *) a. Monad m => a -> m a
return (TVar m (Maybe a) -> TMVarDefault m a
forall (m :: * -> *) a. TVar m (Maybe a) -> TMVarDefault m a
TMVar TVar m (Maybe a)
t)
newTMVarMDefault :: MonadSTM m => a -> m (TMVarDefault m a)
newTMVarMDefault :: a -> m (TMVarDefault m a)
newTMVarMDefault = a -> m (TMVarDefault m a)
forall (m :: * -> *) a. MonadSTM m => a -> m (TMVarDefault m a)
newTMVarIODefault
{-# DEPRECATED newTMVarMDefault "Use newTMVarIODefault" #-}
newEmptyTMVarDefault :: MonadSTM m => STM m (TMVarDefault m a)
newEmptyTMVarDefault :: STM m (TMVarDefault m a)
newEmptyTMVarDefault = do
TVar m (Maybe a)
t <- Maybe a -> STM m (TVar m (Maybe a))
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar Maybe a
forall a. Maybe a
Nothing
TMVarDefault m a -> STM m (TMVarDefault m a)
forall (m :: * -> *) a. Monad m => a -> m a
return (TVar m (Maybe a) -> TMVarDefault m a
forall (m :: * -> *) a. TVar m (Maybe a) -> TMVarDefault m a
TMVar TVar m (Maybe a)
t)
newEmptyTMVarIODefault :: MonadSTM m => m (TMVarDefault m a)
newEmptyTMVarIODefault :: m (TMVarDefault m a)
newEmptyTMVarIODefault = do
TVar m (Maybe a)
t <- Maybe a -> m (TVar m (Maybe a))
forall (m :: * -> *) a. MonadSTM m => a -> m (TVar m a)
newTVarIO Maybe a
forall a. Maybe a
Nothing
TMVarDefault m a -> m (TMVarDefault m a)
forall (m :: * -> *) a. Monad m => a -> m a
return (TVar m (Maybe a) -> TMVarDefault m a
forall (m :: * -> *) a. TVar m (Maybe a) -> TMVarDefault m a
TMVar TVar m (Maybe a)
t)
newEmptyTMVarMDefault :: MonadSTM m => m (TMVarDefault m a)
newEmptyTMVarMDefault :: m (TMVarDefault m a)
newEmptyTMVarMDefault = m (TMVarDefault m a)
forall (m :: * -> *) a. MonadSTM m => m (TMVarDefault m a)
newEmptyTMVarIODefault
{-# DEPRECATED newEmptyTMVarMDefault "Use newEmptyTMVarIODefault" #-}
takeTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m a
takeTMVarDefault :: TMVarDefault m a -> STM m a
takeTMVarDefault (TMVar TVar m (Maybe a)
t) = do
Maybe a
m <- TVar m (Maybe a) -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m (Maybe a)
t
case Maybe a
m of
Maybe a
Nothing -> STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
Just a
a -> do TVar m (Maybe a) -> Maybe a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m (Maybe a)
t Maybe a
forall a. Maybe a
Nothing; a -> STM m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
tryTakeTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m (Maybe a)
tryTakeTMVarDefault :: TMVarDefault m a -> STM m (Maybe a)
tryTakeTMVarDefault (TMVar TVar m (Maybe a)
t) = do
Maybe a
m <- TVar m (Maybe a) -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m (Maybe a)
t
case Maybe a
m of
Maybe a
Nothing -> Maybe a -> STM m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
Just a
a -> do TVar m (Maybe a) -> Maybe a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m (Maybe a)
t Maybe a
forall a. Maybe a
Nothing; Maybe a -> STM m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Maybe a
forall a. a -> Maybe a
Just a
a)
putTMVarDefault :: MonadSTM m => TMVarDefault m a -> a -> STM m ()
putTMVarDefault :: TMVarDefault m a -> a -> STM m ()
putTMVarDefault (TMVar TVar m (Maybe a)
t) a
a = do
Maybe a
m <- TVar m (Maybe a) -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m (Maybe a)
t
case Maybe a
m of
Maybe a
Nothing -> do TVar m (Maybe a) -> Maybe a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m (Maybe a)
t (a -> Maybe a
forall a. a -> Maybe a
Just a
a); () -> STM m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just a
_ -> STM m ()
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
tryPutTMVarDefault :: MonadSTM m => TMVarDefault m a -> a -> STM m Bool
tryPutTMVarDefault :: TMVarDefault m a -> a -> STM m Bool
tryPutTMVarDefault (TMVar TVar m (Maybe a)
t) a
a = do
Maybe a
m <- TVar m (Maybe a) -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m (Maybe a)
t
case Maybe a
m of
Maybe a
Nothing -> do TVar m (Maybe a) -> Maybe a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m (Maybe a)
t (a -> Maybe a
forall a. a -> Maybe a
Just a
a); Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
Just a
_ -> Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
readTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m a
readTMVarDefault :: TMVarDefault m a -> STM m a
readTMVarDefault (TMVar TVar m (Maybe a)
t) = do
Maybe a
m <- TVar m (Maybe a) -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m (Maybe a)
t
case Maybe a
m of
Maybe a
Nothing -> STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
Just a
a -> a -> STM m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
tryReadTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m (Maybe a)
tryReadTMVarDefault :: TMVarDefault m a -> STM m (Maybe a)
tryReadTMVarDefault (TMVar TVar m (Maybe a)
t) = TVar m (Maybe a) -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m (Maybe a)
t
swapTMVarDefault :: MonadSTM m => TMVarDefault m a -> a -> STM m a
swapTMVarDefault :: TMVarDefault m a -> a -> STM m a
swapTMVarDefault (TMVar TVar m (Maybe a)
t) a
new = do
Maybe a
m <- TVar m (Maybe a) -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m (Maybe a)
t
case Maybe a
m of
Maybe a
Nothing -> STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
Just a
old -> do TVar m (Maybe a) -> Maybe a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m (Maybe a)
t (a -> Maybe a
forall a. a -> Maybe a
Just a
new); a -> STM m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
old
isEmptyTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m Bool
isEmptyTMVarDefault :: TMVarDefault m a -> STM m Bool
isEmptyTMVarDefault (TMVar TVar m (Maybe a)
t) = do
Maybe a
m <- TVar m (Maybe a) -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m (Maybe a)
t
case Maybe a
m of
Maybe a
Nothing -> Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
Just a
_ -> Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
data TQueueDefault m a = TQueue !(TVar m [a])
!(TVar m [a])
labelTQueueDefault
:: MonadLabelledSTM m
=> TQueueDefault m a -> String -> STM m ()
labelTQueueDefault :: TQueueDefault m a -> String -> STM m ()
labelTQueueDefault (TQueue TVar m [a]
read TVar m [a]
write) String
label = do
TVar m [a] -> String -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TVar m a -> String -> STM m ()
labelTVar TVar m [a]
read (String
label String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"-read")
TVar m [a] -> String -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TVar m a -> String -> STM m ()
labelTVar TVar m [a]
write (String
label String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"-write")
newTQueueDefault :: MonadSTM m => STM m (TQueueDefault m a)
newTQueueDefault :: STM m (TQueueDefault m a)
newTQueueDefault = do
TVar m [a]
read <- [a] -> STM m (TVar m [a])
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar []
TVar m [a]
write <- [a] -> STM m (TVar m [a])
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar []
TQueueDefault m a -> STM m (TQueueDefault m a)
forall (m :: * -> *) a. Monad m => a -> m a
return (TVar m [a] -> TVar m [a] -> TQueueDefault m a
forall (m :: * -> *) a.
TVar m [a] -> TVar m [a] -> TQueueDefault m a
TQueue TVar m [a]
read TVar m [a]
write)
writeTQueueDefault :: MonadSTM m => TQueueDefault m a -> a -> STM m ()
writeTQueueDefault :: TQueueDefault m a -> a -> STM m ()
writeTQueueDefault (TQueue TVar m [a]
_read TVar m [a]
write) a
a = do
[a]
listend <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
write
TVar m [a] -> [a] -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m [a]
write (a
aa -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
listend)
readTQueueDefault :: MonadSTM m => TQueueDefault m a -> STM m a
readTQueueDefault :: TQueueDefault m a -> STM m a
readTQueueDefault TQueueDefault m a
queue = STM m a -> (a -> STM m a) -> Maybe a -> STM m a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry a -> STM m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe a -> STM m a) -> STM m (Maybe a) -> STM m a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< TQueueDefault m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TQueueDefault m a -> STM m (Maybe a)
tryReadTQueueDefault TQueueDefault m a
queue
tryReadTQueueDefault :: MonadSTM m => TQueueDefault m a -> STM m (Maybe a)
tryReadTQueueDefault :: TQueueDefault m a -> STM m (Maybe a)
tryReadTQueueDefault (TQueue TVar m [a]
read TVar m [a]
write) = do
[a]
xs <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
read
case [a]
xs of
(a
x:[a]
xs') -> do
TVar m [a] -> [a] -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m [a]
read [a]
xs'
Maybe a -> STM m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Maybe a
forall a. a -> Maybe a
Just a
x)
[] -> do
[a]
ys <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
write
case [a] -> [a]
forall a. [a] -> [a]
reverse [a]
ys of
[] -> Maybe a -> STM m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
(a
z:[a]
zs) -> do
TVar m [a] -> [a] -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m [a]
write []
TVar m [a] -> [a] -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m [a]
read [a]
zs
Maybe a -> STM m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Maybe a
forall a. a -> Maybe a
Just a
z)
isEmptyTQueueDefault :: MonadSTM m => TQueueDefault m a -> STM m Bool
isEmptyTQueueDefault :: TQueueDefault m a -> STM m Bool
isEmptyTQueueDefault (TQueue TVar m [a]
read TVar m [a]
write) = do
[a]
xs <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
read
case [a]
xs of
(a
_:[a]
_) -> Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
[] -> do [a]
ys <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
write
case [a]
ys of
[] -> Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
[a]
_ -> Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
peekTQueueDefault :: MonadSTM m => TQueueDefault m a -> STM m a
peekTQueueDefault :: TQueueDefault m a -> STM m a
peekTQueueDefault (TQueue TVar m [a]
read TVar m [a]
_write) = do
[a]
xs <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
read
case [a]
xs of
(a
x:[a]
_) -> a -> STM m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x
[a]
_ -> STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
tryPeekTQueueDefault :: MonadSTM m => TQueueDefault m a -> STM m (Maybe a)
tryPeekTQueueDefault :: TQueueDefault m a -> STM m (Maybe a)
tryPeekTQueueDefault (TQueue TVar m [a]
read TVar m [a]
_write) = do
[a]
xs <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
read
case [a]
xs of
(a
x:[a]
_) -> Maybe a -> STM m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Maybe a
forall a. a -> Maybe a
Just a
x)
[a]
_ -> Maybe a -> STM m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
data TBQueueDefault m a = TBQueue
!(TVar m Natural)
!(TVar m [a])
!(TVar m Natural)
!(TVar m [a])
!Natural
labelTBQueueDefault
:: MonadLabelledSTM m
=> TBQueueDefault m a -> String -> STM m ()
labelTBQueueDefault :: TBQueueDefault m a -> String -> STM m ()
labelTBQueueDefault (TBQueue TVar m Natural
rsize TVar m [a]
read TVar m Natural
wsize TVar m [a]
write Natural
_size) String
label = do
TVar m Natural -> String -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TVar m a -> String -> STM m ()
labelTVar TVar m Natural
rsize (String
label String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"-rsize")
TVar m [a] -> String -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TVar m a -> String -> STM m ()
labelTVar TVar m [a]
read (String
label String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"-read")
TVar m Natural -> String -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TVar m a -> String -> STM m ()
labelTVar TVar m Natural
wsize (String
label String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"-wsize")
TVar m [a] -> String -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TVar m a -> String -> STM m ()
labelTVar TVar m [a]
write (String
label String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"-write")
newTBQueueDefault :: MonadSTM m => Natural -> STM m (TBQueueDefault m a)
newTBQueueDefault :: Natural -> STM m (TBQueueDefault m a)
newTBQueueDefault Natural
size = do
TVar m Natural
rsize <- Natural -> STM m (TVar m Natural)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar Natural
0
TVar m [a]
read <- [a] -> STM m (TVar m [a])
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar []
TVar m Natural
wsize <- Natural -> STM m (TVar m Natural)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar Natural
size
TVar m [a]
write <- [a] -> STM m (TVar m [a])
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar []
TBQueueDefault m a -> STM m (TBQueueDefault m a)
forall (m :: * -> *) a. Monad m => a -> m a
return (TVar m Natural
-> TVar m [a]
-> TVar m Natural
-> TVar m [a]
-> Natural
-> TBQueueDefault m a
forall (m :: * -> *) a.
TVar m Natural
-> TVar m [a]
-> TVar m Natural
-> TVar m [a]
-> Natural
-> TBQueueDefault m a
TBQueue TVar m Natural
rsize TVar m [a]
read TVar m Natural
wsize TVar m [a]
write Natural
size)
readTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m a
readTBQueueDefault :: TBQueueDefault m a -> STM m a
readTBQueueDefault TBQueueDefault m a
queue = STM m a -> (a -> STM m a) -> Maybe a -> STM m a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry a -> STM m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe a -> STM m a) -> STM m (Maybe a) -> STM m a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< TBQueueDefault m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueueDefault m a -> STM m (Maybe a)
tryReadTBQueueDefault TBQueueDefault m a
queue
tryReadTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m (Maybe a)
tryReadTBQueueDefault :: TBQueueDefault m a -> STM m (Maybe a)
tryReadTBQueueDefault (TBQueue TVar m Natural
rsize TVar m [a]
read TVar m Natural
_wsize TVar m [a]
write Natural
_size) = do
[a]
xs <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
read
Natural
r <- TVar m Natural -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m Natural
rsize
TVar m Natural -> Natural -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m Natural
rsize (Natural -> STM m ()) -> Natural -> STM m ()
forall a b. (a -> b) -> a -> b
$! Natural
r Natural -> Natural -> Natural
forall a. Num a => a -> a -> a
+ Natural
1
case [a]
xs of
(a
x:[a]
xs') -> do
TVar m [a] -> [a] -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m [a]
read [a]
xs'
Maybe a -> STM m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Maybe a
forall a. a -> Maybe a
Just a
x)
[] -> do
[a]
ys <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
write
case [a] -> [a]
forall a. [a] -> [a]
reverse [a]
ys of
[] -> Maybe a -> STM m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
(a
z:[a]
zs) -> do
TVar m [a] -> [a] -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m [a]
write []
TVar m [a] -> [a] -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m [a]
read [a]
zs
Maybe a -> STM m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Maybe a
forall a. a -> Maybe a
Just a
z)
peekTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m a
peekTBQueueDefault :: TBQueueDefault m a -> STM m a
peekTBQueueDefault (TBQueue TVar m Natural
_rsize TVar m [a]
read TVar m Natural
_wsize TVar m [a]
_write Natural
_size) = do
[a]
xs <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
read
case [a]
xs of
(a
x:[a]
_) -> a -> STM m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x
[a]
_ -> STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
tryPeekTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m (Maybe a)
tryPeekTBQueueDefault :: TBQueueDefault m a -> STM m (Maybe a)
tryPeekTBQueueDefault (TBQueue TVar m Natural
_rsize TVar m [a]
read TVar m Natural
_wsize TVar m [a]
_write Natural
_size) = do
[a]
xs <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
read
case [a]
xs of
(a
x:[a]
_) -> Maybe a -> STM m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Maybe a
forall a. a -> Maybe a
Just a
x)
[a]
_ -> Maybe a -> STM m (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
writeTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> a -> STM m ()
writeTBQueueDefault :: TBQueueDefault m a -> a -> STM m ()
writeTBQueueDefault (TBQueue TVar m Natural
rsize TVar m [a]
_read TVar m Natural
wsize TVar m [a]
write Natural
_size) a
a = do
Natural
w <- TVar m Natural -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m Natural
wsize
if (Natural
w Natural -> Natural -> Bool
forall a. Ord a => a -> a -> Bool
> Natural
0)
then do TVar m Natural -> Natural -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m Natural
wsize (Natural -> STM m ()) -> Natural -> STM m ()
forall a b. (a -> b) -> a -> b
$! Natural
w Natural -> Natural -> Natural
forall a. Num a => a -> a -> a
- Natural
1
else do
Natural
r <- TVar m Natural -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m Natural
rsize
if (Natural
r Natural -> Natural -> Bool
forall a. Ord a => a -> a -> Bool
> Natural
0)
then do TVar m Natural -> Natural -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m Natural
rsize Natural
0
TVar m Natural -> Natural -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m Natural
wsize (Natural -> STM m ()) -> Natural -> STM m ()
forall a b. (a -> b) -> a -> b
$! Natural
r Natural -> Natural -> Natural
forall a. Num a => a -> a -> a
- Natural
1
else STM m ()
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
[a]
listend <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
write
TVar m [a] -> [a] -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m [a]
write (a
aa -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
listend)
isEmptyTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m Bool
isEmptyTBQueueDefault :: TBQueueDefault m a -> STM m Bool
isEmptyTBQueueDefault (TBQueue TVar m Natural
_rsize TVar m [a]
read TVar m Natural
_wsize TVar m [a]
write Natural
_size) = do
[a]
xs <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
read
case [a]
xs of
(a
_:[a]
_) -> Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
[] -> do [a]
ys <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
write
case [a]
ys of
[] -> Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
[a]
_ -> Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
isFullTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m Bool
isFullTBQueueDefault :: TBQueueDefault m a -> STM m Bool
isFullTBQueueDefault (TBQueue TVar m Natural
rsize TVar m [a]
_read TVar m Natural
wsize TVar m [a]
_write Natural
_size) = do
Natural
w <- TVar m Natural -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m Natural
wsize
if (Natural
w Natural -> Natural -> Bool
forall a. Ord a => a -> a -> Bool
> Natural
0)
then Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else do
Natural
r <- TVar m Natural -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m Natural
rsize
if (Natural
r Natural -> Natural -> Bool
forall a. Ord a => a -> a -> Bool
> Natural
0)
then Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
else Bool -> STM m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
lengthTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m Natural
lengthTBQueueDefault :: TBQueueDefault m a -> STM m Natural
lengthTBQueueDefault (TBQueue TVar m Natural
rsize TVar m [a]
_read TVar m Natural
wsize TVar m [a]
_write Natural
size) = do
Natural
r <- TVar m Natural -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m Natural
rsize
Natural
w <- TVar m Natural -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m Natural
wsize
Natural -> STM m Natural
forall (m :: * -> *) a. Monad m => a -> m a
return (Natural -> STM m Natural) -> Natural -> STM m Natural
forall a b. (a -> b) -> a -> b
$! Natural
size Natural -> Natural -> Natural
forall a. Num a => a -> a -> a
- Natural
r Natural -> Natural -> Natural
forall a. Num a => a -> a -> a
- Natural
w
flushTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m [a]
flushTBQueueDefault :: TBQueueDefault m a -> STM m [a]
flushTBQueueDefault (TBQueue TVar m Natural
rsize TVar m [a]
read TVar m Natural
wsize TVar m [a]
write Natural
size) = do
[a]
xs <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
read
[a]
ys <- TVar m [a] -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar TVar m [a]
write
if [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
xs Bool -> Bool -> Bool
&& [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
ys
then [a] -> STM m [a]
forall (m :: * -> *) a. Monad m => a -> m a
return []
else do
TVar m [a] -> [a] -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m [a]
read []
TVar m [a] -> [a] -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m [a]
write []
TVar m Natural -> Natural -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m Natural
rsize Natural
0
TVar m Natural -> Natural -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar TVar m Natural
wsize Natural
size
[a] -> STM m [a]
forall (m :: * -> *) a. Monad m => a -> m a
return ([a]
xs [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a] -> [a]
forall a. [a] -> [a]
reverse [a]
ys)
throwSTM :: (MonadSTM m, MonadThrow.MonadThrow (STM m), Exception e)
=> e -> STM m a
throwSTM :: e -> STM m a
throwSTM = e -> STM m a
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
MonadThrow.throwIO
catchSTM :: (MonadSTM m, MonadThrow.MonadCatch (STM m), Exception e)
=> STM m a -> (e -> STM m a) -> STM m a
catchSTM :: STM m a -> (e -> STM m a) -> STM m a
catchSTM = STM m a -> (e -> STM m a) -> STM m a
forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> (e -> m a) -> m a
MonadThrow.catch
data Trans where
Cont :: Trans
Reader :: Trans
Writer :: Trans
State :: Trans
Except :: Trans
RWS :: Trans
newtype WrappedSTM (t :: Trans) r (m :: Type -> Type) a = WrappedSTM { WrappedSTM t r m a -> STM m a
runWrappedSTM :: STM m a }
deriving instance MonadSTM m => Functor (WrappedSTM t r m)
deriving instance MonadSTM m => Applicative (WrappedSTM t r m)
deriving instance MonadSTM m => Monad (WrappedSTM t r m)
deriving instance MonadSTM m => Alternative (WrappedSTM t r m)
deriving instance MonadSTM m => MonadPlus (WrappedSTM t r m)
instance ( MonadSTM m
, MonadThrow.MonadThrow (STM m)
, MonadThrow.MonadCatch (STM m)
) => MonadThrow.MonadThrow (WrappedSTM t r m) where
throwIO :: e -> WrappedSTM t r m a
throwIO = STM m a -> WrappedSTM t r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM t r m a)
-> (e -> STM m a) -> e -> WrappedSTM t r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> STM m a
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
MonadThrow.throwIO
instance ( MonadSTM m
, MonadThrow.MonadThrow (STM m)
, MonadThrow.MonadCatch (STM m)
) => MonadThrow.MonadCatch (WrappedSTM t r m) where
catch :: WrappedSTM t r m a
-> (e -> WrappedSTM t r m a) -> WrappedSTM t r m a
catch WrappedSTM t r m a
action e -> WrappedSTM t r m a
handler = STM m a -> WrappedSTM t r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM
(STM m a -> WrappedSTM t r m a) -> STM m a -> WrappedSTM t r m a
forall a b. (a -> b) -> a -> b
$ STM m a -> (e -> STM m a) -> STM m a
forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> (e -> m a) -> m a
MonadThrow.catch (WrappedSTM t r m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM WrappedSTM t r m a
action) (WrappedSTM t r m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM (WrappedSTM t r m a -> STM m a)
-> (e -> WrappedSTM t r m a) -> e -> STM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> WrappedSTM t r m a
handler)
generalBracket :: WrappedSTM t r m a
-> (a -> ExitCase b -> WrappedSTM t r m c)
-> (a -> WrappedSTM t r m b)
-> WrappedSTM t r m (b, c)
generalBracket WrappedSTM t r m a
acquire a -> ExitCase b -> WrappedSTM t r m c
release a -> WrappedSTM t r m b
use = STM m (b, c) -> WrappedSTM t r m (b, c)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (b, c) -> WrappedSTM t r m (b, c))
-> STM m (b, c) -> WrappedSTM t r m (b, c)
forall a b. (a -> b) -> a -> b
$
STM m a
-> (a -> ExitCase b -> STM m c) -> (a -> STM m b) -> STM m (b, c)
forall (m :: * -> *) a b c.
MonadCatch m =>
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
MonadThrow.generalBracket (WrappedSTM t r m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM WrappedSTM t r m a
acquire)
(WrappedSTM t r m c -> STM m c
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM (WrappedSTM t r m c -> STM m c)
-> (a -> ExitCase b -> WrappedSTM t r m c)
-> a
-> ExitCase b
-> STM m c
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: a -> ExitCase b -> WrappedSTM t r m c
release)
(WrappedSTM t r m b -> STM m b
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM (WrappedSTM t r m b -> STM m b)
-> (a -> WrappedSTM t r m b) -> a -> STM m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> WrappedSTM t r m b
use)
instance MonadSTM m => MonadSTM (ContT r m) where
type STM (ContT r m) = WrappedSTM Cont r m
atomically :: STM (ContT r m) a -> ContT r m a
atomically = m a -> ContT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ContT r m a)
-> (WrappedSTM 'Cont r m a -> m a)
-> WrappedSTM 'Cont r m a
-> ContT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m a -> m a)
-> (WrappedSTM 'Cont r m a -> STM m a)
-> WrappedSTM 'Cont r m a
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedSTM 'Cont r m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM
type TVar (ContT r m) = TVar m
newTVar :: a -> STM (ContT r m) (TVar (ContT r m) a)
newTVar = STM m (TVar m a) -> WrappedSTM 'Cont r m (TVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TVar m a) -> WrappedSTM 'Cont r m (TVar m a))
-> (a -> STM m (TVar m a)) -> a -> WrappedSTM 'Cont r m (TVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar
readTVar :: TVar (ContT r m) a -> STM (ContT r m) a
readTVar = TVar (ContT r m) a -> STM (ContT r m) a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar
writeTVar :: TVar (ContT r m) a -> a -> STM (ContT r m) ()
writeTVar = STM m () -> WrappedSTM 'Cont r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Cont r m ())
-> (TVar m a -> a -> STM m ())
-> TVar m a
-> a
-> WrappedSTM 'Cont r m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar
retry :: STM (ContT r m) a
retry = STM m a -> WrappedSTM 'Cont r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
orElse :: STM (ContT r m) a -> STM (ContT r m) a -> STM (ContT r m) a
orElse = STM m a -> WrappedSTM 'Cont r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Cont r m a)
-> (WrappedSTM 'Cont r m a -> WrappedSTM 'Cont r m a -> STM m a)
-> WrappedSTM 'Cont r m a
-> WrappedSTM 'Cont r m a
-> WrappedSTM 'Cont r m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: (STM m a -> STM m a -> STM m a)
-> (WrappedSTM 'Cont r m a -> STM m a)
-> WrappedSTM 'Cont r m a
-> WrappedSTM 'Cont r m a
-> STM m a
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on STM m a -> STM m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a -> STM m a -> STM m a
orElse WrappedSTM 'Cont r m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM
modifyTVar :: TVar (ContT r m) a -> (a -> a) -> STM (ContT r m) ()
modifyTVar = STM m () -> WrappedSTM 'Cont r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Cont r m ())
-> (TVar m a -> (a -> a) -> STM m ())
-> TVar m a
-> (a -> a)
-> WrappedSTM 'Cont r m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
modifyTVar
modifyTVar' :: TVar (ContT r m) a -> (a -> a) -> STM (ContT r m) ()
modifyTVar' = STM m () -> WrappedSTM 'Cont r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Cont r m ())
-> (TVar m a -> (a -> a) -> STM m ())
-> TVar m a
-> (a -> a)
-> WrappedSTM 'Cont r m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
modifyTVar'
stateTVar :: TVar (ContT r m) s -> (s -> (a, s)) -> STM (ContT r m) a
stateTVar = STM m a -> WrappedSTM 'Cont r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Cont r m a)
-> (TVar m s -> (s -> (a, s)) -> STM m a)
-> TVar m s
-> (s -> (a, s))
-> WrappedSTM 'Cont r m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m s -> (s -> (a, s)) -> STM m a
forall (m :: * -> *) s a.
MonadSTM m =>
TVar m s -> (s -> (a, s)) -> STM m a
stateTVar
swapTVar :: TVar (ContT r m) a -> a -> STM (ContT r m) a
swapTVar = STM m a -> WrappedSTM 'Cont r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Cont r m a)
-> (TVar m a -> a -> STM m a)
-> TVar m a
-> a
-> WrappedSTM 'Cont r m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m a
swapTVar
check :: Bool -> STM (ContT r m) ()
check = STM m () -> WrappedSTM 'Cont r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Cont r m ())
-> (Bool -> STM m ()) -> Bool -> WrappedSTM 'Cont r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> STM m ()
forall (m :: * -> *). MonadSTM m => Bool -> STM m ()
check
type TMVar (ContT r m) = TMVar m
newTMVar :: a -> STM (ContT r m) (TMVar (ContT r m) a)
newTMVar = STM m (TMVar m a) -> WrappedSTM 'Cont r m (TMVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TMVar m a) -> WrappedSTM 'Cont r m (TMVar m a))
-> (a -> STM m (TMVar m a))
-> a
-> WrappedSTM 'Cont r m (TMVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TMVar m a)
newTMVar
newEmptyTMVar :: STM (ContT r m) (TMVar (ContT r m) a)
newEmptyTMVar = STM m (TMVar m a) -> WrappedSTM 'Cont r m (TMVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TMVar m a)
newEmptyTMVar
takeTMVar :: TMVar (ContT r m) a -> STM (ContT r m) a
takeTMVar = STM m a -> WrappedSTM 'Cont r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Cont r m a)
-> (TMVar m a -> STM m a) -> TMVar m a -> WrappedSTM 'Cont r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
takeTMVar
tryTakeTMVar :: TMVar (ContT r m) a -> STM (ContT r m) (Maybe a)
tryTakeTMVar = STM m (Maybe a) -> WrappedSTM 'Cont r m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Cont r m (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> WrappedSTM 'Cont r m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryTakeTMVar
putTMVar :: TMVar (ContT r m) a -> a -> STM (ContT r m) ()
putTMVar = STM m () -> WrappedSTM 'Cont r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Cont r m ())
-> (TMVar m a -> a -> STM m ())
-> TMVar m a
-> a
-> WrappedSTM 'Cont r m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m ()
putTMVar
tryPutTMVar :: TMVar (ContT r m) a -> a -> STM (ContT r m) Bool
tryPutTMVar = STM m Bool -> WrappedSTM 'Cont r m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Cont r m Bool)
-> (TMVar m a -> a -> STM m Bool)
-> TMVar m a
-> a
-> WrappedSTM 'Cont r m Bool
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m Bool
tryPutTMVar
readTMVar :: TMVar (ContT r m) a -> STM (ContT r m) a
readTMVar = STM m a -> WrappedSTM 'Cont r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Cont r m a)
-> (TMVar m a -> STM m a) -> TMVar m a -> WrappedSTM 'Cont r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
readTMVar
tryReadTMVar :: TMVar (ContT r m) a -> STM (ContT r m) (Maybe a)
tryReadTMVar = STM m (Maybe a) -> WrappedSTM 'Cont r m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Cont r m (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> WrappedSTM 'Cont r m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryReadTMVar
swapTMVar :: TMVar (ContT r m) a -> a -> STM (ContT r m) a
swapTMVar = STM m a -> WrappedSTM 'Cont r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Cont r m a)
-> (TMVar m a -> a -> STM m a)
-> TMVar m a
-> a
-> WrappedSTM 'Cont r m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m a
swapTMVar
isEmptyTMVar :: TMVar (ContT r m) a -> STM (ContT r m) Bool
isEmptyTMVar = STM m Bool -> WrappedSTM 'Cont r m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Cont r m Bool)
-> (TMVar m a -> STM m Bool)
-> TMVar m a
-> WrappedSTM 'Cont r m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m Bool
isEmptyTMVar
type TQueue (ContT r m) = TQueue m
newTQueue :: STM (ContT r m) (TQueue (ContT r m) a)
newTQueue = STM m (TQueue m a) -> WrappedSTM 'Cont r m (TQueue m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m (TQueue m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TQueue m a)
newTQueue
readTQueue :: TQueue (ContT r m) a -> STM (ContT r m) a
readTQueue = STM m a -> WrappedSTM 'Cont r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Cont r m a)
-> (TQueue m a -> STM m a) -> TQueue m a -> WrappedSTM 'Cont r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
readTQueue
tryReadTQueue :: TQueue (ContT r m) a -> STM (ContT r m) (Maybe a)
tryReadTQueue = STM m (Maybe a) -> WrappedSTM 'Cont r m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Cont r m (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> WrappedSTM 'Cont r m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
tryReadTQueue
peekTQueue :: TQueue (ContT r m) a -> STM (ContT r m) a
peekTQueue = STM m a -> WrappedSTM 'Cont r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Cont r m a)
-> (TQueue m a -> STM m a) -> TQueue m a -> WrappedSTM 'Cont r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
peekTQueue
tryPeekTQueue :: TQueue (ContT r m) a -> STM (ContT r m) (Maybe a)
tryPeekTQueue = STM m (Maybe a) -> WrappedSTM 'Cont r m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Cont r m (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> WrappedSTM 'Cont r m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
tryPeekTQueue
writeTQueue :: TQueue (ContT r m) a -> a -> STM (ContT r m) ()
writeTQueue TQueue (ContT r m) a
v = STM m () -> WrappedSTM 'Cont r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Cont r m ())
-> (a -> STM m ()) -> a -> WrappedSTM 'Cont r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> a -> STM m ()
writeTQueue TQueue m a
TQueue (ContT r m) a
v
isEmptyTQueue :: TQueue (ContT r m) a -> STM (ContT r m) Bool
isEmptyTQueue = STM m Bool -> WrappedSTM 'Cont r m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Cont r m Bool)
-> (TQueue m a -> STM m Bool)
-> TQueue m a
-> WrappedSTM 'Cont r m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m Bool
isEmptyTQueue
type TBQueue (ContT r m) = TBQueue m
newTBQueue :: Natural -> STM (ContT r m) (TBQueue (ContT r m) a)
newTBQueue = STM m (TBQueue m a) -> WrappedSTM 'Cont r m (TBQueue m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TBQueue m a) -> WrappedSTM 'Cont r m (TBQueue m a))
-> (Natural -> STM m (TBQueue m a))
-> Natural
-> WrappedSTM 'Cont r m (TBQueue m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> STM m (TBQueue m a)
forall (m :: * -> *) a.
MonadSTM m =>
Natural -> STM m (TBQueue m a)
newTBQueue
readTBQueue :: TBQueue (ContT r m) a -> STM (ContT r m) a
readTBQueue = STM m a -> WrappedSTM 'Cont r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Cont r m a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> WrappedSTM 'Cont r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
readTBQueue
tryReadTBQueue :: TBQueue (ContT r m) a -> STM (ContT r m) (Maybe a)
tryReadTBQueue = STM m (Maybe a) -> WrappedSTM 'Cont r m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Cont r m (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> WrappedSTM 'Cont r m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
tryReadTBQueue
peekTBQueue :: TBQueue (ContT r m) a -> STM (ContT r m) a
peekTBQueue = STM m a -> WrappedSTM 'Cont r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Cont r m a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> WrappedSTM 'Cont r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
peekTBQueue
tryPeekTBQueue :: TBQueue (ContT r m) a -> STM (ContT r m) (Maybe a)
tryPeekTBQueue = STM m (Maybe a) -> WrappedSTM 'Cont r m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Cont r m (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> WrappedSTM 'Cont r m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
tryPeekTBQueue
flushTBQueue :: TBQueue (ContT r m) a -> STM (ContT r m) [a]
flushTBQueue = STM m [a] -> WrappedSTM 'Cont r m [a]
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m [a] -> WrappedSTM 'Cont r m [a])
-> (TBQueue m a -> STM m [a])
-> TBQueue m a
-> WrappedSTM 'Cont r m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m [a]
flushTBQueue
writeTBQueue :: TBQueue (ContT r m) a -> a -> STM (ContT r m) ()
writeTBQueue = STM m () -> WrappedSTM 'Cont r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Cont r m ())
-> (TBQueue m a -> a -> STM m ())
-> TBQueue m a
-> a
-> WrappedSTM 'Cont r m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TBQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> a -> STM m ()
writeTBQueue
lengthTBQueue :: TBQueue (ContT r m) a -> STM (ContT r m) Natural
lengthTBQueue = STM m Natural -> WrappedSTM 'Cont r m Natural
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Natural -> WrappedSTM 'Cont r m Natural)
-> (TBQueue m a -> STM m Natural)
-> TBQueue m a
-> WrappedSTM 'Cont r m Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Natural
lengthTBQueue
isEmptyTBQueue :: TBQueue (ContT r m) a -> STM (ContT r m) Bool
isEmptyTBQueue = STM m Bool -> WrappedSTM 'Cont r m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Cont r m Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> WrappedSTM 'Cont r m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
isEmptyTBQueue
isFullTBQueue :: TBQueue (ContT r m) a -> STM (ContT r m) Bool
isFullTBQueue = STM m Bool -> WrappedSTM 'Cont r m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Cont r m Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> WrappedSTM 'Cont r m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
isFullTBQueue
instance MonadSTM m => MonadSTM (ReaderT r m) where
type STM (ReaderT r m) = WrappedSTM Reader r m
atomically :: STM (ReaderT r m) a -> ReaderT r m a
atomically = m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ReaderT r m a)
-> (WrappedSTM 'Reader r m a -> m a)
-> WrappedSTM 'Reader r m a
-> ReaderT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m a -> m a)
-> (WrappedSTM 'Reader r m a -> STM m a)
-> WrappedSTM 'Reader r m a
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedSTM 'Reader r m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM
type TVar (ReaderT r m) = TVar m
newTVar :: a -> STM (ReaderT r m) (TVar (ReaderT r m) a)
newTVar = STM m (TVar m a) -> WrappedSTM 'Reader r m (TVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TVar m a) -> WrappedSTM 'Reader r m (TVar m a))
-> (a -> STM m (TVar m a))
-> a
-> WrappedSTM 'Reader r m (TVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar
readTVar :: TVar (ReaderT r m) a -> STM (ReaderT r m) a
readTVar = TVar (ReaderT r m) a -> STM (ReaderT r m) a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar
writeTVar :: TVar (ReaderT r m) a -> a -> STM (ReaderT r m) ()
writeTVar = STM m () -> WrappedSTM 'Reader r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Reader r m ())
-> (TVar m a -> a -> STM m ())
-> TVar m a
-> a
-> WrappedSTM 'Reader r m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar
retry :: STM (ReaderT r m) a
retry = STM m a -> WrappedSTM 'Reader r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
orElse :: STM (ReaderT r m) a -> STM (ReaderT r m) a -> STM (ReaderT r m) a
orElse = STM m a -> WrappedSTM 'Reader r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Reader r m a)
-> (WrappedSTM 'Reader r m a
-> WrappedSTM 'Reader r m a -> STM m a)
-> WrappedSTM 'Reader r m a
-> WrappedSTM 'Reader r m a
-> WrappedSTM 'Reader r m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: (STM m a -> STM m a -> STM m a)
-> (WrappedSTM 'Reader r m a -> STM m a)
-> WrappedSTM 'Reader r m a
-> WrappedSTM 'Reader r m a
-> STM m a
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on STM m a -> STM m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a -> STM m a -> STM m a
orElse WrappedSTM 'Reader r m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM
modifyTVar :: TVar (ReaderT r m) a -> (a -> a) -> STM (ReaderT r m) ()
modifyTVar = STM m () -> WrappedSTM 'Reader r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Reader r m ())
-> (TVar m a -> (a -> a) -> STM m ())
-> TVar m a
-> (a -> a)
-> WrappedSTM 'Reader r m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
modifyTVar
modifyTVar' :: TVar (ReaderT r m) a -> (a -> a) -> STM (ReaderT r m) ()
modifyTVar' = STM m () -> WrappedSTM 'Reader r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Reader r m ())
-> (TVar m a -> (a -> a) -> STM m ())
-> TVar m a
-> (a -> a)
-> WrappedSTM 'Reader r m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
modifyTVar'
stateTVar :: TVar (ReaderT r m) s -> (s -> (a, s)) -> STM (ReaderT r m) a
stateTVar = STM m a -> WrappedSTM 'Reader r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Reader r m a)
-> (TVar m s -> (s -> (a, s)) -> STM m a)
-> TVar m s
-> (s -> (a, s))
-> WrappedSTM 'Reader r m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m s -> (s -> (a, s)) -> STM m a
forall (m :: * -> *) s a.
MonadSTM m =>
TVar m s -> (s -> (a, s)) -> STM m a
stateTVar
swapTVar :: TVar (ReaderT r m) a -> a -> STM (ReaderT r m) a
swapTVar = STM m a -> WrappedSTM 'Reader r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Reader r m a)
-> (TVar m a -> a -> STM m a)
-> TVar m a
-> a
-> WrappedSTM 'Reader r m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m a
swapTVar
check :: Bool -> STM (ReaderT r m) ()
check = STM m () -> WrappedSTM 'Reader r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Reader r m ())
-> (Bool -> STM m ()) -> Bool -> WrappedSTM 'Reader r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> STM m ()
forall (m :: * -> *). MonadSTM m => Bool -> STM m ()
check
type TMVar (ReaderT r m) = TMVar m
newTMVar :: a -> STM (ReaderT r m) (TMVar (ReaderT r m) a)
newTMVar = STM m (TMVar m a) -> WrappedSTM 'Reader r m (TMVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TMVar m a) -> WrappedSTM 'Reader r m (TMVar m a))
-> (a -> STM m (TMVar m a))
-> a
-> WrappedSTM 'Reader r m (TMVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TMVar m a)
newTMVar
newEmptyTMVar :: STM (ReaderT r m) (TMVar (ReaderT r m) a)
newEmptyTMVar = STM m (TMVar m a) -> WrappedSTM 'Reader r m (TMVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TMVar m a)
newEmptyTMVar
takeTMVar :: TMVar (ReaderT r m) a -> STM (ReaderT r m) a
takeTMVar = STM m a -> WrappedSTM 'Reader r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Reader r m a)
-> (TMVar m a -> STM m a) -> TMVar m a -> WrappedSTM 'Reader r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
takeTMVar
tryTakeTMVar :: TMVar (ReaderT r m) a -> STM (ReaderT r m) (Maybe a)
tryTakeTMVar = STM m (Maybe a) -> WrappedSTM 'Reader r m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Reader r m (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> WrappedSTM 'Reader r m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryTakeTMVar
putTMVar :: TMVar (ReaderT r m) a -> a -> STM (ReaderT r m) ()
putTMVar = STM m () -> WrappedSTM 'Reader r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Reader r m ())
-> (TMVar m a -> a -> STM m ())
-> TMVar m a
-> a
-> WrappedSTM 'Reader r m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m ()
putTMVar
tryPutTMVar :: TMVar (ReaderT r m) a -> a -> STM (ReaderT r m) Bool
tryPutTMVar = STM m Bool -> WrappedSTM 'Reader r m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Reader r m Bool)
-> (TMVar m a -> a -> STM m Bool)
-> TMVar m a
-> a
-> WrappedSTM 'Reader r m Bool
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m Bool
tryPutTMVar
readTMVar :: TMVar (ReaderT r m) a -> STM (ReaderT r m) a
readTMVar = STM m a -> WrappedSTM 'Reader r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Reader r m a)
-> (TMVar m a -> STM m a) -> TMVar m a -> WrappedSTM 'Reader r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
readTMVar
tryReadTMVar :: TMVar (ReaderT r m) a -> STM (ReaderT r m) (Maybe a)
tryReadTMVar = STM m (Maybe a) -> WrappedSTM 'Reader r m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Reader r m (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> WrappedSTM 'Reader r m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryReadTMVar
swapTMVar :: TMVar (ReaderT r m) a -> a -> STM (ReaderT r m) a
swapTMVar = STM m a -> WrappedSTM 'Reader r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Reader r m a)
-> (TMVar m a -> a -> STM m a)
-> TMVar m a
-> a
-> WrappedSTM 'Reader r m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m a
swapTMVar
isEmptyTMVar :: TMVar (ReaderT r m) a -> STM (ReaderT r m) Bool
isEmptyTMVar = STM m Bool -> WrappedSTM 'Reader r m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Reader r m Bool)
-> (TMVar m a -> STM m Bool)
-> TMVar m a
-> WrappedSTM 'Reader r m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m Bool
isEmptyTMVar
type TQueue (ReaderT r m) = TQueue m
newTQueue :: STM (ReaderT r m) (TQueue (ReaderT r m) a)
newTQueue = STM m (TQueue m a) -> WrappedSTM 'Reader r m (TQueue m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m (TQueue m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TQueue m a)
newTQueue
readTQueue :: TQueue (ReaderT r m) a -> STM (ReaderT r m) a
readTQueue = STM m a -> WrappedSTM 'Reader r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Reader r m a)
-> (TQueue m a -> STM m a)
-> TQueue m a
-> WrappedSTM 'Reader r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
readTQueue
tryReadTQueue :: TQueue (ReaderT r m) a -> STM (ReaderT r m) (Maybe a)
tryReadTQueue = STM m (Maybe a) -> WrappedSTM 'Reader r m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Reader r m (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> WrappedSTM 'Reader r m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
tryReadTQueue
peekTQueue :: TQueue (ReaderT r m) a -> STM (ReaderT r m) a
peekTQueue = STM m a -> WrappedSTM 'Reader r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Reader r m a)
-> (TQueue m a -> STM m a)
-> TQueue m a
-> WrappedSTM 'Reader r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
peekTQueue
tryPeekTQueue :: TQueue (ReaderT r m) a -> STM (ReaderT r m) (Maybe a)
tryPeekTQueue = STM m (Maybe a) -> WrappedSTM 'Reader r m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Reader r m (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> WrappedSTM 'Reader r m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
tryPeekTQueue
writeTQueue :: TQueue (ReaderT r m) a -> a -> STM (ReaderT r m) ()
writeTQueue TQueue (ReaderT r m) a
v = STM m () -> WrappedSTM 'Reader r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Reader r m ())
-> (a -> STM m ()) -> a -> WrappedSTM 'Reader r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> a -> STM m ()
writeTQueue TQueue m a
TQueue (ReaderT r m) a
v
isEmptyTQueue :: TQueue (ReaderT r m) a -> STM (ReaderT r m) Bool
isEmptyTQueue = STM m Bool -> WrappedSTM 'Reader r m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Reader r m Bool)
-> (TQueue m a -> STM m Bool)
-> TQueue m a
-> WrappedSTM 'Reader r m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m Bool
isEmptyTQueue
type TBQueue (ReaderT r m) = TBQueue m
newTBQueue :: Natural -> STM (ReaderT r m) (TBQueue (ReaderT r m) a)
newTBQueue = STM m (TBQueue m a) -> WrappedSTM 'Reader r m (TBQueue m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TBQueue m a) -> WrappedSTM 'Reader r m (TBQueue m a))
-> (Natural -> STM m (TBQueue m a))
-> Natural
-> WrappedSTM 'Reader r m (TBQueue m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> STM m (TBQueue m a)
forall (m :: * -> *) a.
MonadSTM m =>
Natural -> STM m (TBQueue m a)
newTBQueue
readTBQueue :: TBQueue (ReaderT r m) a -> STM (ReaderT r m) a
readTBQueue = STM m a -> WrappedSTM 'Reader r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Reader r m a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> WrappedSTM 'Reader r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
readTBQueue
tryReadTBQueue :: TBQueue (ReaderT r m) a -> STM (ReaderT r m) (Maybe a)
tryReadTBQueue = STM m (Maybe a) -> WrappedSTM 'Reader r m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Reader r m (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> WrappedSTM 'Reader r m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
tryReadTBQueue
peekTBQueue :: TBQueue (ReaderT r m) a -> STM (ReaderT r m) a
peekTBQueue = STM m a -> WrappedSTM 'Reader r m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Reader r m a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> WrappedSTM 'Reader r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
peekTBQueue
tryPeekTBQueue :: TBQueue (ReaderT r m) a -> STM (ReaderT r m) (Maybe a)
tryPeekTBQueue = STM m (Maybe a) -> WrappedSTM 'Reader r m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Reader r m (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> WrappedSTM 'Reader r m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
tryPeekTBQueue
flushTBQueue :: TBQueue (ReaderT r m) a -> STM (ReaderT r m) [a]
flushTBQueue = STM m [a] -> WrappedSTM 'Reader r m [a]
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m [a] -> WrappedSTM 'Reader r m [a])
-> (TBQueue m a -> STM m [a])
-> TBQueue m a
-> WrappedSTM 'Reader r m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m [a]
flushTBQueue
writeTBQueue :: TBQueue (ReaderT r m) a -> a -> STM (ReaderT r m) ()
writeTBQueue = STM m () -> WrappedSTM 'Reader r m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Reader r m ())
-> (TBQueue m a -> a -> STM m ())
-> TBQueue m a
-> a
-> WrappedSTM 'Reader r m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TBQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> a -> STM m ()
writeTBQueue
lengthTBQueue :: TBQueue (ReaderT r m) a -> STM (ReaderT r m) Natural
lengthTBQueue = STM m Natural -> WrappedSTM 'Reader r m Natural
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Natural -> WrappedSTM 'Reader r m Natural)
-> (TBQueue m a -> STM m Natural)
-> TBQueue m a
-> WrappedSTM 'Reader r m Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Natural
lengthTBQueue
isEmptyTBQueue :: TBQueue (ReaderT r m) a -> STM (ReaderT r m) Bool
isEmptyTBQueue = STM m Bool -> WrappedSTM 'Reader r m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Reader r m Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> WrappedSTM 'Reader r m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
isEmptyTBQueue
isFullTBQueue :: TBQueue (ReaderT r m) a -> STM (ReaderT r m) Bool
isFullTBQueue = STM m Bool -> WrappedSTM 'Reader r m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Reader r m Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> WrappedSTM 'Reader r m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
isFullTBQueue
instance (Monoid w, MonadSTM m) => MonadSTM (WriterT w m) where
type STM (WriterT w m) = WrappedSTM Writer w m
atomically :: STM (WriterT w m) a -> WriterT w m a
atomically = m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> WriterT w m a)
-> (WrappedSTM 'Writer w m a -> m a)
-> WrappedSTM 'Writer w m a
-> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m a -> m a)
-> (WrappedSTM 'Writer w m a -> STM m a)
-> WrappedSTM 'Writer w m a
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedSTM 'Writer w m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM
type TVar (WriterT w m) = TVar m
newTVar :: a -> STM (WriterT w m) (TVar (WriterT w m) a)
newTVar = STM m (TVar m a) -> WrappedSTM 'Writer w m (TVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TVar m a) -> WrappedSTM 'Writer w m (TVar m a))
-> (a -> STM m (TVar m a))
-> a
-> WrappedSTM 'Writer w m (TVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar
readTVar :: TVar (WriterT w m) a -> STM (WriterT w m) a
readTVar = TVar (WriterT w m) a -> STM (WriterT w m) a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar
writeTVar :: TVar (WriterT w m) a -> a -> STM (WriterT w m) ()
writeTVar = STM m () -> WrappedSTM 'Writer w m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Writer w m ())
-> (TVar m a -> a -> STM m ())
-> TVar m a
-> a
-> WrappedSTM 'Writer w m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar
retry :: STM (WriterT w m) a
retry = STM m a -> WrappedSTM 'Writer w m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
orElse :: STM (WriterT w m) a -> STM (WriterT w m) a -> STM (WriterT w m) a
orElse = STM m a -> WrappedSTM 'Writer w m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Writer w m a)
-> (WrappedSTM 'Writer w m a
-> WrappedSTM 'Writer w m a -> STM m a)
-> WrappedSTM 'Writer w m a
-> WrappedSTM 'Writer w m a
-> WrappedSTM 'Writer w m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: (STM m a -> STM m a -> STM m a)
-> (WrappedSTM 'Writer w m a -> STM m a)
-> WrappedSTM 'Writer w m a
-> WrappedSTM 'Writer w m a
-> STM m a
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on STM m a -> STM m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a -> STM m a -> STM m a
orElse WrappedSTM 'Writer w m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM
modifyTVar :: TVar (WriterT w m) a -> (a -> a) -> STM (WriterT w m) ()
modifyTVar = STM m () -> WrappedSTM 'Writer w m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Writer w m ())
-> (TVar m a -> (a -> a) -> STM m ())
-> TVar m a
-> (a -> a)
-> WrappedSTM 'Writer w m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
modifyTVar
modifyTVar' :: TVar (WriterT w m) a -> (a -> a) -> STM (WriterT w m) ()
modifyTVar' = STM m () -> WrappedSTM 'Writer w m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Writer w m ())
-> (TVar m a -> (a -> a) -> STM m ())
-> TVar m a
-> (a -> a)
-> WrappedSTM 'Writer w m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
modifyTVar'
stateTVar :: TVar (WriterT w m) s -> (s -> (a, s)) -> STM (WriterT w m) a
stateTVar = STM m a -> WrappedSTM 'Writer w m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Writer w m a)
-> (TVar m s -> (s -> (a, s)) -> STM m a)
-> TVar m s
-> (s -> (a, s))
-> WrappedSTM 'Writer w m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m s -> (s -> (a, s)) -> STM m a
forall (m :: * -> *) s a.
MonadSTM m =>
TVar m s -> (s -> (a, s)) -> STM m a
stateTVar
swapTVar :: TVar (WriterT w m) a -> a -> STM (WriterT w m) a
swapTVar = STM m a -> WrappedSTM 'Writer w m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Writer w m a)
-> (TVar m a -> a -> STM m a)
-> TVar m a
-> a
-> WrappedSTM 'Writer w m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m a
swapTVar
check :: Bool -> STM (WriterT w m) ()
check = STM m () -> WrappedSTM 'Writer w m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Writer w m ())
-> (Bool -> STM m ()) -> Bool -> WrappedSTM 'Writer w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> STM m ()
forall (m :: * -> *). MonadSTM m => Bool -> STM m ()
check
type TMVar (WriterT w m) = TMVar m
newTMVar :: a -> STM (WriterT w m) (TMVar (WriterT w m) a)
newTMVar = STM m (TMVar m a) -> WrappedSTM 'Writer w m (TMVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TMVar m a) -> WrappedSTM 'Writer w m (TMVar m a))
-> (a -> STM m (TMVar m a))
-> a
-> WrappedSTM 'Writer w m (TMVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TMVar m a)
newTMVar
newEmptyTMVar :: STM (WriterT w m) (TMVar (WriterT w m) a)
newEmptyTMVar = STM m (TMVar m a) -> WrappedSTM 'Writer w m (TMVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TMVar m a)
newEmptyTMVar
takeTMVar :: TMVar (WriterT w m) a -> STM (WriterT w m) a
takeTMVar = STM m a -> WrappedSTM 'Writer w m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Writer w m a)
-> (TMVar m a -> STM m a) -> TMVar m a -> WrappedSTM 'Writer w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
takeTMVar
tryTakeTMVar :: TMVar (WriterT w m) a -> STM (WriterT w m) (Maybe a)
tryTakeTMVar = STM m (Maybe a) -> WrappedSTM 'Writer w m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Writer w m (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> WrappedSTM 'Writer w m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryTakeTMVar
putTMVar :: TMVar (WriterT w m) a -> a -> STM (WriterT w m) ()
putTMVar = STM m () -> WrappedSTM 'Writer w m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Writer w m ())
-> (TMVar m a -> a -> STM m ())
-> TMVar m a
-> a
-> WrappedSTM 'Writer w m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m ()
putTMVar
tryPutTMVar :: TMVar (WriterT w m) a -> a -> STM (WriterT w m) Bool
tryPutTMVar = STM m Bool -> WrappedSTM 'Writer w m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Writer w m Bool)
-> (TMVar m a -> a -> STM m Bool)
-> TMVar m a
-> a
-> WrappedSTM 'Writer w m Bool
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m Bool
tryPutTMVar
readTMVar :: TMVar (WriterT w m) a -> STM (WriterT w m) a
readTMVar = STM m a -> WrappedSTM 'Writer w m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Writer w m a)
-> (TMVar m a -> STM m a) -> TMVar m a -> WrappedSTM 'Writer w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
readTMVar
tryReadTMVar :: TMVar (WriterT w m) a -> STM (WriterT w m) (Maybe a)
tryReadTMVar = STM m (Maybe a) -> WrappedSTM 'Writer w m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Writer w m (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> WrappedSTM 'Writer w m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryReadTMVar
swapTMVar :: TMVar (WriterT w m) a -> a -> STM (WriterT w m) a
swapTMVar = STM m a -> WrappedSTM 'Writer w m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Writer w m a)
-> (TMVar m a -> a -> STM m a)
-> TMVar m a
-> a
-> WrappedSTM 'Writer w m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m a
swapTMVar
isEmptyTMVar :: TMVar (WriterT w m) a -> STM (WriterT w m) Bool
isEmptyTMVar = STM m Bool -> WrappedSTM 'Writer w m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Writer w m Bool)
-> (TMVar m a -> STM m Bool)
-> TMVar m a
-> WrappedSTM 'Writer w m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m Bool
isEmptyTMVar
type TQueue (WriterT w m) = TQueue m
newTQueue :: STM (WriterT w m) (TQueue (WriterT w m) a)
newTQueue = STM m (TQueue m a) -> WrappedSTM 'Writer w m (TQueue m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m (TQueue m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TQueue m a)
newTQueue
readTQueue :: TQueue (WriterT w m) a -> STM (WriterT w m) a
readTQueue = STM m a -> WrappedSTM 'Writer w m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Writer w m a)
-> (TQueue m a -> STM m a)
-> TQueue m a
-> WrappedSTM 'Writer w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
readTQueue
tryReadTQueue :: TQueue (WriterT w m) a -> STM (WriterT w m) (Maybe a)
tryReadTQueue = STM m (Maybe a) -> WrappedSTM 'Writer w m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Writer w m (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> WrappedSTM 'Writer w m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
tryReadTQueue
peekTQueue :: TQueue (WriterT w m) a -> STM (WriterT w m) a
peekTQueue = STM m a -> WrappedSTM 'Writer w m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Writer w m a)
-> (TQueue m a -> STM m a)
-> TQueue m a
-> WrappedSTM 'Writer w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
peekTQueue
tryPeekTQueue :: TQueue (WriterT w m) a -> STM (WriterT w m) (Maybe a)
tryPeekTQueue = STM m (Maybe a) -> WrappedSTM 'Writer w m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Writer w m (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> WrappedSTM 'Writer w m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
tryPeekTQueue
writeTQueue :: TQueue (WriterT w m) a -> a -> STM (WriterT w m) ()
writeTQueue TQueue (WriterT w m) a
v = STM m () -> WrappedSTM 'Writer w m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Writer w m ())
-> (a -> STM m ()) -> a -> WrappedSTM 'Writer w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> a -> STM m ()
writeTQueue TQueue m a
TQueue (WriterT w m) a
v
isEmptyTQueue :: TQueue (WriterT w m) a -> STM (WriterT w m) Bool
isEmptyTQueue = STM m Bool -> WrappedSTM 'Writer w m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Writer w m Bool)
-> (TQueue m a -> STM m Bool)
-> TQueue m a
-> WrappedSTM 'Writer w m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m Bool
isEmptyTQueue
type TBQueue (WriterT w m) = TBQueue m
newTBQueue :: Natural -> STM (WriterT w m) (TBQueue (WriterT w m) a)
newTBQueue = STM m (TBQueue m a) -> WrappedSTM 'Writer w m (TBQueue m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TBQueue m a) -> WrappedSTM 'Writer w m (TBQueue m a))
-> (Natural -> STM m (TBQueue m a))
-> Natural
-> WrappedSTM 'Writer w m (TBQueue m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> STM m (TBQueue m a)
forall (m :: * -> *) a.
MonadSTM m =>
Natural -> STM m (TBQueue m a)
newTBQueue
readTBQueue :: TBQueue (WriterT w m) a -> STM (WriterT w m) a
readTBQueue = STM m a -> WrappedSTM 'Writer w m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Writer w m a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> WrappedSTM 'Writer w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
readTBQueue
tryReadTBQueue :: TBQueue (WriterT w m) a -> STM (WriterT w m) (Maybe a)
tryReadTBQueue = STM m (Maybe a) -> WrappedSTM 'Writer w m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Writer w m (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> WrappedSTM 'Writer w m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
tryReadTBQueue
peekTBQueue :: TBQueue (WriterT w m) a -> STM (WriterT w m) a
peekTBQueue = STM m a -> WrappedSTM 'Writer w m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Writer w m a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> WrappedSTM 'Writer w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
peekTBQueue
tryPeekTBQueue :: TBQueue (WriterT w m) a -> STM (WriterT w m) (Maybe a)
tryPeekTBQueue = STM m (Maybe a) -> WrappedSTM 'Writer w m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Writer w m (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> WrappedSTM 'Writer w m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
tryPeekTBQueue
flushTBQueue :: TBQueue (WriterT w m) a -> STM (WriterT w m) [a]
flushTBQueue = STM m [a] -> WrappedSTM 'Writer w m [a]
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m [a] -> WrappedSTM 'Writer w m [a])
-> (TBQueue m a -> STM m [a])
-> TBQueue m a
-> WrappedSTM 'Writer w m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m [a]
flushTBQueue
writeTBQueue :: TBQueue (WriterT w m) a -> a -> STM (WriterT w m) ()
writeTBQueue = STM m () -> WrappedSTM 'Writer w m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Writer w m ())
-> (TBQueue m a -> a -> STM m ())
-> TBQueue m a
-> a
-> WrappedSTM 'Writer w m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TBQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> a -> STM m ()
writeTBQueue
lengthTBQueue :: TBQueue (WriterT w m) a -> STM (WriterT w m) Natural
lengthTBQueue = STM m Natural -> WrappedSTM 'Writer w m Natural
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Natural -> WrappedSTM 'Writer w m Natural)
-> (TBQueue m a -> STM m Natural)
-> TBQueue m a
-> WrappedSTM 'Writer w m Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Natural
lengthTBQueue
isEmptyTBQueue :: TBQueue (WriterT w m) a -> STM (WriterT w m) Bool
isEmptyTBQueue = STM m Bool -> WrappedSTM 'Writer w m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Writer w m Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> WrappedSTM 'Writer w m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
isEmptyTBQueue
isFullTBQueue :: TBQueue (WriterT w m) a -> STM (WriterT w m) Bool
isFullTBQueue = STM m Bool -> WrappedSTM 'Writer w m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Writer w m Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> WrappedSTM 'Writer w m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
isFullTBQueue
instance MonadSTM m => MonadSTM (StateT s m) where
type STM (StateT s m) = WrappedSTM State s m
atomically :: STM (StateT s m) a -> StateT s m a
atomically = m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> StateT s m a)
-> (WrappedSTM 'State s m a -> m a)
-> WrappedSTM 'State s m a
-> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m a -> m a)
-> (WrappedSTM 'State s m a -> STM m a)
-> WrappedSTM 'State s m a
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedSTM 'State s m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM
type TVar (StateT s m) = TVar m
newTVar :: a -> STM (StateT s m) (TVar (StateT s m) a)
newTVar = STM m (TVar m a) -> WrappedSTM 'State s m (TVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TVar m a) -> WrappedSTM 'State s m (TVar m a))
-> (a -> STM m (TVar m a)) -> a -> WrappedSTM 'State s m (TVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar
readTVar :: TVar (StateT s m) a -> STM (StateT s m) a
readTVar = TVar (StateT s m) a -> STM (StateT s m) a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar
writeTVar :: TVar (StateT s m) a -> a -> STM (StateT s m) ()
writeTVar = STM m () -> WrappedSTM 'State s m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'State s m ())
-> (TVar m a -> a -> STM m ())
-> TVar m a
-> a
-> WrappedSTM 'State s m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar
retry :: STM (StateT s m) a
retry = STM m a -> WrappedSTM 'State s m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
orElse :: STM (StateT s m) a -> STM (StateT s m) a -> STM (StateT s m) a
orElse = STM m a -> WrappedSTM 'State s m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'State s m a)
-> (WrappedSTM 'State s m a -> WrappedSTM 'State s m a -> STM m a)
-> WrappedSTM 'State s m a
-> WrappedSTM 'State s m a
-> WrappedSTM 'State s m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: (STM m a -> STM m a -> STM m a)
-> (WrappedSTM 'State s m a -> STM m a)
-> WrappedSTM 'State s m a
-> WrappedSTM 'State s m a
-> STM m a
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on STM m a -> STM m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a -> STM m a -> STM m a
orElse WrappedSTM 'State s m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM
modifyTVar :: TVar (StateT s m) a -> (a -> a) -> STM (StateT s m) ()
modifyTVar = STM m () -> WrappedSTM 'State s m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'State s m ())
-> (TVar m a -> (a -> a) -> STM m ())
-> TVar m a
-> (a -> a)
-> WrappedSTM 'State s m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
modifyTVar
modifyTVar' :: TVar (StateT s m) a -> (a -> a) -> STM (StateT s m) ()
modifyTVar' = STM m () -> WrappedSTM 'State s m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'State s m ())
-> (TVar m a -> (a -> a) -> STM m ())
-> TVar m a
-> (a -> a)
-> WrappedSTM 'State s m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
modifyTVar'
stateTVar :: TVar (StateT s m) s -> (s -> (a, s)) -> STM (StateT s m) a
stateTVar = STM m a -> WrappedSTM 'State s m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'State s m a)
-> (TVar m s -> (s -> (a, s)) -> STM m a)
-> TVar m s
-> (s -> (a, s))
-> WrappedSTM 'State s m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m s -> (s -> (a, s)) -> STM m a
forall (m :: * -> *) s a.
MonadSTM m =>
TVar m s -> (s -> (a, s)) -> STM m a
stateTVar
swapTVar :: TVar (StateT s m) a -> a -> STM (StateT s m) a
swapTVar = STM m a -> WrappedSTM 'State s m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'State s m a)
-> (TVar m a -> a -> STM m a)
-> TVar m a
-> a
-> WrappedSTM 'State s m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m a
swapTVar
check :: Bool -> STM (StateT s m) ()
check = STM m () -> WrappedSTM 'State s m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'State s m ())
-> (Bool -> STM m ()) -> Bool -> WrappedSTM 'State s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> STM m ()
forall (m :: * -> *). MonadSTM m => Bool -> STM m ()
check
type TMVar (StateT s m) = TMVar m
newTMVar :: a -> STM (StateT s m) (TMVar (StateT s m) a)
newTMVar = STM m (TMVar m a) -> WrappedSTM 'State s m (TMVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TMVar m a) -> WrappedSTM 'State s m (TMVar m a))
-> (a -> STM m (TMVar m a))
-> a
-> WrappedSTM 'State s m (TMVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TMVar m a)
newTMVar
newEmptyTMVar :: STM (StateT s m) (TMVar (StateT s m) a)
newEmptyTMVar = STM m (TMVar m a) -> WrappedSTM 'State s m (TMVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TMVar m a)
newEmptyTMVar
takeTMVar :: TMVar (StateT s m) a -> STM (StateT s m) a
takeTMVar = STM m a -> WrappedSTM 'State s m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'State s m a)
-> (TMVar m a -> STM m a) -> TMVar m a -> WrappedSTM 'State s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
takeTMVar
tryTakeTMVar :: TMVar (StateT s m) a -> STM (StateT s m) (Maybe a)
tryTakeTMVar = STM m (Maybe a) -> WrappedSTM 'State s m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'State s m (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> WrappedSTM 'State s m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryTakeTMVar
putTMVar :: TMVar (StateT s m) a -> a -> STM (StateT s m) ()
putTMVar = STM m () -> WrappedSTM 'State s m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'State s m ())
-> (TMVar m a -> a -> STM m ())
-> TMVar m a
-> a
-> WrappedSTM 'State s m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m ()
putTMVar
tryPutTMVar :: TMVar (StateT s m) a -> a -> STM (StateT s m) Bool
tryPutTMVar = STM m Bool -> WrappedSTM 'State s m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'State s m Bool)
-> (TMVar m a -> a -> STM m Bool)
-> TMVar m a
-> a
-> WrappedSTM 'State s m Bool
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m Bool
tryPutTMVar
readTMVar :: TMVar (StateT s m) a -> STM (StateT s m) a
readTMVar = STM m a -> WrappedSTM 'State s m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'State s m a)
-> (TMVar m a -> STM m a) -> TMVar m a -> WrappedSTM 'State s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
readTMVar
tryReadTMVar :: TMVar (StateT s m) a -> STM (StateT s m) (Maybe a)
tryReadTMVar = STM m (Maybe a) -> WrappedSTM 'State s m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'State s m (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> WrappedSTM 'State s m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryReadTMVar
swapTMVar :: TMVar (StateT s m) a -> a -> STM (StateT s m) a
swapTMVar = STM m a -> WrappedSTM 'State s m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'State s m a)
-> (TMVar m a -> a -> STM m a)
-> TMVar m a
-> a
-> WrappedSTM 'State s m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m a
swapTMVar
isEmptyTMVar :: TMVar (StateT s m) a -> STM (StateT s m) Bool
isEmptyTMVar = STM m Bool -> WrappedSTM 'State s m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'State s m Bool)
-> (TMVar m a -> STM m Bool)
-> TMVar m a
-> WrappedSTM 'State s m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m Bool
isEmptyTMVar
type TQueue (StateT s m) = TQueue m
newTQueue :: STM (StateT s m) (TQueue (StateT s m) a)
newTQueue = STM m (TQueue m a) -> WrappedSTM 'State s m (TQueue m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m (TQueue m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TQueue m a)
newTQueue
readTQueue :: TQueue (StateT s m) a -> STM (StateT s m) a
readTQueue = STM m a -> WrappedSTM 'State s m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'State s m a)
-> (TQueue m a -> STM m a) -> TQueue m a -> WrappedSTM 'State s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
readTQueue
tryReadTQueue :: TQueue (StateT s m) a -> STM (StateT s m) (Maybe a)
tryReadTQueue = STM m (Maybe a) -> WrappedSTM 'State s m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'State s m (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> WrappedSTM 'State s m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
tryReadTQueue
peekTQueue :: TQueue (StateT s m) a -> STM (StateT s m) a
peekTQueue = STM m a -> WrappedSTM 'State s m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'State s m a)
-> (TQueue m a -> STM m a) -> TQueue m a -> WrappedSTM 'State s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
peekTQueue
tryPeekTQueue :: TQueue (StateT s m) a -> STM (StateT s m) (Maybe a)
tryPeekTQueue = STM m (Maybe a) -> WrappedSTM 'State s m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'State s m (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> WrappedSTM 'State s m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
tryPeekTQueue
writeTQueue :: TQueue (StateT s m) a -> a -> STM (StateT s m) ()
writeTQueue TQueue (StateT s m) a
v = STM m () -> WrappedSTM 'State s m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'State s m ())
-> (a -> STM m ()) -> a -> WrappedSTM 'State s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> a -> STM m ()
writeTQueue TQueue m a
TQueue (StateT s m) a
v
isEmptyTQueue :: TQueue (StateT s m) a -> STM (StateT s m) Bool
isEmptyTQueue = STM m Bool -> WrappedSTM 'State s m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'State s m Bool)
-> (TQueue m a -> STM m Bool)
-> TQueue m a
-> WrappedSTM 'State s m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m Bool
isEmptyTQueue
type TBQueue (StateT s m) = TBQueue m
newTBQueue :: Natural -> STM (StateT s m) (TBQueue (StateT s m) a)
newTBQueue = STM m (TBQueue m a) -> WrappedSTM 'State s m (TBQueue m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TBQueue m a) -> WrappedSTM 'State s m (TBQueue m a))
-> (Natural -> STM m (TBQueue m a))
-> Natural
-> WrappedSTM 'State s m (TBQueue m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> STM m (TBQueue m a)
forall (m :: * -> *) a.
MonadSTM m =>
Natural -> STM m (TBQueue m a)
newTBQueue
readTBQueue :: TBQueue (StateT s m) a -> STM (StateT s m) a
readTBQueue = STM m a -> WrappedSTM 'State s m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'State s m a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> WrappedSTM 'State s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
readTBQueue
tryReadTBQueue :: TBQueue (StateT s m) a -> STM (StateT s m) (Maybe a)
tryReadTBQueue = STM m (Maybe a) -> WrappedSTM 'State s m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'State s m (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> WrappedSTM 'State s m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
tryReadTBQueue
peekTBQueue :: TBQueue (StateT s m) a -> STM (StateT s m) a
peekTBQueue = STM m a -> WrappedSTM 'State s m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'State s m a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> WrappedSTM 'State s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
peekTBQueue
tryPeekTBQueue :: TBQueue (StateT s m) a -> STM (StateT s m) (Maybe a)
tryPeekTBQueue = STM m (Maybe a) -> WrappedSTM 'State s m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'State s m (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> WrappedSTM 'State s m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
tryPeekTBQueue
flushTBQueue :: TBQueue (StateT s m) a -> STM (StateT s m) [a]
flushTBQueue = STM m [a] -> WrappedSTM 'State s m [a]
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m [a] -> WrappedSTM 'State s m [a])
-> (TBQueue m a -> STM m [a])
-> TBQueue m a
-> WrappedSTM 'State s m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m [a]
flushTBQueue
writeTBQueue :: TBQueue (StateT s m) a -> a -> STM (StateT s m) ()
writeTBQueue = STM m () -> WrappedSTM 'State s m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'State s m ())
-> (TBQueue m a -> a -> STM m ())
-> TBQueue m a
-> a
-> WrappedSTM 'State s m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TBQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> a -> STM m ()
writeTBQueue
lengthTBQueue :: TBQueue (StateT s m) a -> STM (StateT s m) Natural
lengthTBQueue = STM m Natural -> WrappedSTM 'State s m Natural
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Natural -> WrappedSTM 'State s m Natural)
-> (TBQueue m a -> STM m Natural)
-> TBQueue m a
-> WrappedSTM 'State s m Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Natural
lengthTBQueue
isEmptyTBQueue :: TBQueue (StateT s m) a -> STM (StateT s m) Bool
isEmptyTBQueue = STM m Bool -> WrappedSTM 'State s m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'State s m Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> WrappedSTM 'State s m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
isEmptyTBQueue
isFullTBQueue :: TBQueue (StateT s m) a -> STM (StateT s m) Bool
isFullTBQueue = STM m Bool -> WrappedSTM 'State s m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'State s m Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> WrappedSTM 'State s m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
isFullTBQueue
instance MonadSTM m => MonadSTM (ExceptT e m) where
type STM (ExceptT e m) = WrappedSTM Except e m
atomically :: STM (ExceptT e m) a -> ExceptT e m a
atomically = m a -> ExceptT e m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ExceptT e m a)
-> (WrappedSTM 'Except e m a -> m a)
-> WrappedSTM 'Except e m a
-> ExceptT e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m a -> m a)
-> (WrappedSTM 'Except e m a -> STM m a)
-> WrappedSTM 'Except e m a
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedSTM 'Except e m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM
type TVar (ExceptT e m) = TVar m
newTVar :: a -> STM (ExceptT e m) (TVar (ExceptT e m) a)
newTVar = STM m (TVar m a) -> WrappedSTM 'Except e m (TVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TVar m a) -> WrappedSTM 'Except e m (TVar m a))
-> (a -> STM m (TVar m a))
-> a
-> WrappedSTM 'Except e m (TVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar
readTVar :: TVar (ExceptT e m) a -> STM (ExceptT e m) a
readTVar = TVar (ExceptT e m) a -> STM (ExceptT e m) a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar
writeTVar :: TVar (ExceptT e m) a -> a -> STM (ExceptT e m) ()
writeTVar = STM m () -> WrappedSTM 'Except e m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Except e m ())
-> (TVar m a -> a -> STM m ())
-> TVar m a
-> a
-> WrappedSTM 'Except e m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar
retry :: STM (ExceptT e m) a
retry = STM m a -> WrappedSTM 'Except e m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
orElse :: STM (ExceptT e m) a -> STM (ExceptT e m) a -> STM (ExceptT e m) a
orElse = STM m a -> WrappedSTM 'Except e m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Except e m a)
-> (WrappedSTM 'Except e m a
-> WrappedSTM 'Except e m a -> STM m a)
-> WrappedSTM 'Except e m a
-> WrappedSTM 'Except e m a
-> WrappedSTM 'Except e m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: (STM m a -> STM m a -> STM m a)
-> (WrappedSTM 'Except e m a -> STM m a)
-> WrappedSTM 'Except e m a
-> WrappedSTM 'Except e m a
-> STM m a
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on STM m a -> STM m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a -> STM m a -> STM m a
orElse WrappedSTM 'Except e m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM
modifyTVar :: TVar (ExceptT e m) a -> (a -> a) -> STM (ExceptT e m) ()
modifyTVar = STM m () -> WrappedSTM 'Except e m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Except e m ())
-> (TVar m a -> (a -> a) -> STM m ())
-> TVar m a
-> (a -> a)
-> WrappedSTM 'Except e m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
modifyTVar
modifyTVar' :: TVar (ExceptT e m) a -> (a -> a) -> STM (ExceptT e m) ()
modifyTVar' = STM m () -> WrappedSTM 'Except e m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Except e m ())
-> (TVar m a -> (a -> a) -> STM m ())
-> TVar m a
-> (a -> a)
-> WrappedSTM 'Except e m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
modifyTVar'
stateTVar :: TVar (ExceptT e m) s -> (s -> (a, s)) -> STM (ExceptT e m) a
stateTVar = STM m a -> WrappedSTM 'Except e m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Except e m a)
-> (TVar m s -> (s -> (a, s)) -> STM m a)
-> TVar m s
-> (s -> (a, s))
-> WrappedSTM 'Except e m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m s -> (s -> (a, s)) -> STM m a
forall (m :: * -> *) s a.
MonadSTM m =>
TVar m s -> (s -> (a, s)) -> STM m a
stateTVar
swapTVar :: TVar (ExceptT e m) a -> a -> STM (ExceptT e m) a
swapTVar = STM m a -> WrappedSTM 'Except e m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Except e m a)
-> (TVar m a -> a -> STM m a)
-> TVar m a
-> a
-> WrappedSTM 'Except e m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m a
swapTVar
check :: Bool -> STM (ExceptT e m) ()
check = STM m () -> WrappedSTM 'Except e m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Except e m ())
-> (Bool -> STM m ()) -> Bool -> WrappedSTM 'Except e m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> STM m ()
forall (m :: * -> *). MonadSTM m => Bool -> STM m ()
check
type TMVar (ExceptT e m) = TMVar m
newTMVar :: a -> STM (ExceptT e m) (TMVar (ExceptT e m) a)
newTMVar = STM m (TMVar m a) -> WrappedSTM 'Except e m (TMVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TMVar m a) -> WrappedSTM 'Except e m (TMVar m a))
-> (a -> STM m (TMVar m a))
-> a
-> WrappedSTM 'Except e m (TMVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TMVar m a)
newTMVar
newEmptyTMVar :: STM (ExceptT e m) (TMVar (ExceptT e m) a)
newEmptyTMVar = STM m (TMVar m a) -> WrappedSTM 'Except e m (TMVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TMVar m a)
newEmptyTMVar
takeTMVar :: TMVar (ExceptT e m) a -> STM (ExceptT e m) a
takeTMVar = STM m a -> WrappedSTM 'Except e m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Except e m a)
-> (TMVar m a -> STM m a) -> TMVar m a -> WrappedSTM 'Except e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
takeTMVar
tryTakeTMVar :: TMVar (ExceptT e m) a -> STM (ExceptT e m) (Maybe a)
tryTakeTMVar = STM m (Maybe a) -> WrappedSTM 'Except e m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Except e m (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> WrappedSTM 'Except e m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryTakeTMVar
putTMVar :: TMVar (ExceptT e m) a -> a -> STM (ExceptT e m) ()
putTMVar = STM m () -> WrappedSTM 'Except e m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Except e m ())
-> (TMVar m a -> a -> STM m ())
-> TMVar m a
-> a
-> WrappedSTM 'Except e m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m ()
putTMVar
tryPutTMVar :: TMVar (ExceptT e m) a -> a -> STM (ExceptT e m) Bool
tryPutTMVar = STM m Bool -> WrappedSTM 'Except e m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Except e m Bool)
-> (TMVar m a -> a -> STM m Bool)
-> TMVar m a
-> a
-> WrappedSTM 'Except e m Bool
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m Bool
tryPutTMVar
readTMVar :: TMVar (ExceptT e m) a -> STM (ExceptT e m) a
readTMVar = STM m a -> WrappedSTM 'Except e m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Except e m a)
-> (TMVar m a -> STM m a) -> TMVar m a -> WrappedSTM 'Except e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
readTMVar
tryReadTMVar :: TMVar (ExceptT e m) a -> STM (ExceptT e m) (Maybe a)
tryReadTMVar = STM m (Maybe a) -> WrappedSTM 'Except e m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Except e m (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> WrappedSTM 'Except e m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryReadTMVar
swapTMVar :: TMVar (ExceptT e m) a -> a -> STM (ExceptT e m) a
swapTMVar = STM m a -> WrappedSTM 'Except e m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Except e m a)
-> (TMVar m a -> a -> STM m a)
-> TMVar m a
-> a
-> WrappedSTM 'Except e m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m a
swapTMVar
isEmptyTMVar :: TMVar (ExceptT e m) a -> STM (ExceptT e m) Bool
isEmptyTMVar = STM m Bool -> WrappedSTM 'Except e m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Except e m Bool)
-> (TMVar m a -> STM m Bool)
-> TMVar m a
-> WrappedSTM 'Except e m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m Bool
isEmptyTMVar
type TQueue (ExceptT e m) = TQueue m
newTQueue :: STM (ExceptT e m) (TQueue (ExceptT e m) a)
newTQueue = STM m (TQueue m a) -> WrappedSTM 'Except e m (TQueue m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m (TQueue m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TQueue m a)
newTQueue
readTQueue :: TQueue (ExceptT e m) a -> STM (ExceptT e m) a
readTQueue = STM m a -> WrappedSTM 'Except e m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Except e m a)
-> (TQueue m a -> STM m a)
-> TQueue m a
-> WrappedSTM 'Except e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
readTQueue
tryReadTQueue :: TQueue (ExceptT e m) a -> STM (ExceptT e m) (Maybe a)
tryReadTQueue = STM m (Maybe a) -> WrappedSTM 'Except e m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Except e m (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> WrappedSTM 'Except e m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
tryReadTQueue
peekTQueue :: TQueue (ExceptT e m) a -> STM (ExceptT e m) a
peekTQueue = STM m a -> WrappedSTM 'Except e m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Except e m a)
-> (TQueue m a -> STM m a)
-> TQueue m a
-> WrappedSTM 'Except e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
peekTQueue
tryPeekTQueue :: TQueue (ExceptT e m) a -> STM (ExceptT e m) (Maybe a)
tryPeekTQueue = STM m (Maybe a) -> WrappedSTM 'Except e m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Except e m (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> WrappedSTM 'Except e m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
tryPeekTQueue
writeTQueue :: TQueue (ExceptT e m) a -> a -> STM (ExceptT e m) ()
writeTQueue TQueue (ExceptT e m) a
v = STM m () -> WrappedSTM 'Except e m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Except e m ())
-> (a -> STM m ()) -> a -> WrappedSTM 'Except e m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> a -> STM m ()
writeTQueue TQueue m a
TQueue (ExceptT e m) a
v
isEmptyTQueue :: TQueue (ExceptT e m) a -> STM (ExceptT e m) Bool
isEmptyTQueue = STM m Bool -> WrappedSTM 'Except e m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Except e m Bool)
-> (TQueue m a -> STM m Bool)
-> TQueue m a
-> WrappedSTM 'Except e m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m Bool
isEmptyTQueue
type TBQueue (ExceptT e m) = TBQueue m
newTBQueue :: Natural -> STM (ExceptT e m) (TBQueue (ExceptT e m) a)
newTBQueue = STM m (TBQueue m a) -> WrappedSTM 'Except e m (TBQueue m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TBQueue m a) -> WrappedSTM 'Except e m (TBQueue m a))
-> (Natural -> STM m (TBQueue m a))
-> Natural
-> WrappedSTM 'Except e m (TBQueue m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> STM m (TBQueue m a)
forall (m :: * -> *) a.
MonadSTM m =>
Natural -> STM m (TBQueue m a)
newTBQueue
readTBQueue :: TBQueue (ExceptT e m) a -> STM (ExceptT e m) a
readTBQueue = STM m a -> WrappedSTM 'Except e m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Except e m a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> WrappedSTM 'Except e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
readTBQueue
tryReadTBQueue :: TBQueue (ExceptT e m) a -> STM (ExceptT e m) (Maybe a)
tryReadTBQueue = STM m (Maybe a) -> WrappedSTM 'Except e m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Except e m (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> WrappedSTM 'Except e m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
tryReadTBQueue
peekTBQueue :: TBQueue (ExceptT e m) a -> STM (ExceptT e m) a
peekTBQueue = STM m a -> WrappedSTM 'Except e m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'Except e m a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> WrappedSTM 'Except e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
peekTBQueue
tryPeekTBQueue :: TBQueue (ExceptT e m) a -> STM (ExceptT e m) (Maybe a)
tryPeekTBQueue = STM m (Maybe a) -> WrappedSTM 'Except e m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'Except e m (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> WrappedSTM 'Except e m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
tryPeekTBQueue
flushTBQueue :: TBQueue (ExceptT e m) a -> STM (ExceptT e m) [a]
flushTBQueue = STM m [a] -> WrappedSTM 'Except e m [a]
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m [a] -> WrappedSTM 'Except e m [a])
-> (TBQueue m a -> STM m [a])
-> TBQueue m a
-> WrappedSTM 'Except e m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m [a]
flushTBQueue
writeTBQueue :: TBQueue (ExceptT e m) a -> a -> STM (ExceptT e m) ()
writeTBQueue = STM m () -> WrappedSTM 'Except e m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'Except e m ())
-> (TBQueue m a -> a -> STM m ())
-> TBQueue m a
-> a
-> WrappedSTM 'Except e m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TBQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> a -> STM m ()
writeTBQueue
lengthTBQueue :: TBQueue (ExceptT e m) a -> STM (ExceptT e m) Natural
lengthTBQueue = STM m Natural -> WrappedSTM 'Except e m Natural
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Natural -> WrappedSTM 'Except e m Natural)
-> (TBQueue m a -> STM m Natural)
-> TBQueue m a
-> WrappedSTM 'Except e m Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Natural
lengthTBQueue
isEmptyTBQueue :: TBQueue (ExceptT e m) a -> STM (ExceptT e m) Bool
isEmptyTBQueue = STM m Bool -> WrappedSTM 'Except e m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Except e m Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> WrappedSTM 'Except e m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
isEmptyTBQueue
isFullTBQueue :: TBQueue (ExceptT e m) a -> STM (ExceptT e m) Bool
isFullTBQueue = STM m Bool -> WrappedSTM 'Except e m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'Except e m Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> WrappedSTM 'Except e m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
isFullTBQueue
instance (Monoid w, MonadSTM m) => MonadSTM (RWST r w s m) where
type STM (RWST r w s m) = WrappedSTM RWS (r, w, s) m
atomically :: STM (RWST r w s m) a -> RWST r w s m a
atomically = m a -> RWST r w s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RWST r w s m a)
-> (WrappedSTM 'RWS (r, w, s) m a -> m a)
-> WrappedSTM 'RWS (r, w, s) m a
-> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m a -> m a)
-> (WrappedSTM 'RWS (r, w, s) m a -> STM m a)
-> WrappedSTM 'RWS (r, w, s) m a
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedSTM 'RWS (r, w, s) m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM
type TVar (RWST r w s m) = TVar m
newTVar :: a -> STM (RWST r w s m) (TVar (RWST r w s m) a)
newTVar = STM m (TVar m a) -> WrappedSTM 'RWS (r, w, s) m (TVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TVar m a) -> WrappedSTM 'RWS (r, w, s) m (TVar m a))
-> (a -> STM m (TVar m a))
-> a
-> WrappedSTM 'RWS (r, w, s) m (TVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
newTVar
readTVar :: TVar (RWST r w s m) a -> STM (RWST r w s m) a
readTVar = TVar (RWST r w s m) a -> STM (RWST r w s m) a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
readTVar
writeTVar :: TVar (RWST r w s m) a -> a -> STM (RWST r w s m) ()
writeTVar = STM m () -> WrappedSTM 'RWS (r, w, s) m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'RWS (r, w, s) m ())
-> (TVar m a -> a -> STM m ())
-> TVar m a
-> a
-> WrappedSTM 'RWS (r, w, s) m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
writeTVar
retry :: STM (RWST r w s m) a
retry = STM m a -> WrappedSTM 'RWS (r, w, s) m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
orElse :: STM (RWST r w s m) a
-> STM (RWST r w s m) a -> STM (RWST r w s m) a
orElse = STM m a -> WrappedSTM 'RWS (r, w, s) m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'RWS (r, w, s) m a)
-> (WrappedSTM 'RWS (r, w, s) m a
-> WrappedSTM 'RWS (r, w, s) m a -> STM m a)
-> WrappedSTM 'RWS (r, w, s) m a
-> WrappedSTM 'RWS (r, w, s) m a
-> WrappedSTM 'RWS (r, w, s) m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: (STM m a -> STM m a -> STM m a)
-> (WrappedSTM 'RWS (r, w, s) m a -> STM m a)
-> WrappedSTM 'RWS (r, w, s) m a
-> WrappedSTM 'RWS (r, w, s) m a
-> STM m a
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on STM m a -> STM m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a -> STM m a -> STM m a
orElse WrappedSTM 'RWS (r, w, s) m a -> STM m a
forall (t :: Trans) r (m :: * -> *) a.
WrappedSTM t r m a -> STM m a
runWrappedSTM
modifyTVar :: TVar (RWST r w s m) a -> (a -> a) -> STM (RWST r w s m) ()
modifyTVar = STM m () -> WrappedSTM 'RWS (r, w, s) m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'RWS (r, w, s) m ())
-> (TVar m a -> (a -> a) -> STM m ())
-> TVar m a
-> (a -> a)
-> WrappedSTM 'RWS (r, w, s) m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
modifyTVar
modifyTVar' :: TVar (RWST r w s m) a -> (a -> a) -> STM (RWST r w s m) ()
modifyTVar' = STM m () -> WrappedSTM 'RWS (r, w, s) m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'RWS (r, w, s) m ())
-> (TVar m a -> (a -> a) -> STM m ())
-> TVar m a
-> (a -> a)
-> WrappedSTM 'RWS (r, w, s) m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
modifyTVar'
stateTVar :: TVar (RWST r w s m) s -> (s -> (a, s)) -> STM (RWST r w s m) a
stateTVar = STM m a -> WrappedSTM 'RWS (r, w, s) m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'RWS (r, w, s) m a)
-> (TVar m s -> (s -> (a, s)) -> STM m a)
-> TVar m s
-> (s -> (a, s))
-> WrappedSTM 'RWS (r, w, s) m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m s -> (s -> (a, s)) -> STM m a
forall (m :: * -> *) s a.
MonadSTM m =>
TVar m s -> (s -> (a, s)) -> STM m a
stateTVar
swapTVar :: TVar (RWST r w s m) a -> a -> STM (RWST r w s m) a
swapTVar = STM m a -> WrappedSTM 'RWS (r, w, s) m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'RWS (r, w, s) m a)
-> (TVar m a -> a -> STM m a)
-> TVar m a
-> a
-> WrappedSTM 'RWS (r, w, s) m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m a
swapTVar
check :: Bool -> STM (RWST r w s m) ()
check = STM m () -> WrappedSTM 'RWS (r, w, s) m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'RWS (r, w, s) m ())
-> (Bool -> STM m ()) -> Bool -> WrappedSTM 'RWS (r, w, s) m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> STM m ()
forall (m :: * -> *). MonadSTM m => Bool -> STM m ()
check
type TMVar (RWST r w s m) = TMVar m
newTMVar :: a -> STM (RWST r w s m) (TMVar (RWST r w s m) a)
newTMVar = STM m (TMVar m a) -> WrappedSTM 'RWS (r, w, s) m (TMVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TMVar m a) -> WrappedSTM 'RWS (r, w, s) m (TMVar m a))
-> (a -> STM m (TMVar m a))
-> a
-> WrappedSTM 'RWS (r, w, s) m (TMVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TMVar m a)
newTMVar
newEmptyTMVar :: STM (RWST r w s m) (TMVar (RWST r w s m) a)
newEmptyTMVar = STM m (TMVar m a) -> WrappedSTM 'RWS (r, w, s) m (TMVar m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TMVar m a)
newEmptyTMVar
takeTMVar :: TMVar (RWST r w s m) a -> STM (RWST r w s m) a
takeTMVar = STM m a -> WrappedSTM 'RWS (r, w, s) m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'RWS (r, w, s) m a)
-> (TMVar m a -> STM m a)
-> TMVar m a
-> WrappedSTM 'RWS (r, w, s) m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
takeTMVar
tryTakeTMVar :: TMVar (RWST r w s m) a -> STM (RWST r w s m) (Maybe a)
tryTakeTMVar = STM m (Maybe a) -> WrappedSTM 'RWS (r, w, s) m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'RWS (r, w, s) m (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> WrappedSTM 'RWS (r, w, s) m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryTakeTMVar
putTMVar :: TMVar (RWST r w s m) a -> a -> STM (RWST r w s m) ()
putTMVar = STM m () -> WrappedSTM 'RWS (r, w, s) m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'RWS (r, w, s) m ())
-> (TMVar m a -> a -> STM m ())
-> TMVar m a
-> a
-> WrappedSTM 'RWS (r, w, s) m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m ()
putTMVar
tryPutTMVar :: TMVar (RWST r w s m) a -> a -> STM (RWST r w s m) Bool
tryPutTMVar = STM m Bool -> WrappedSTM 'RWS (r, w, s) m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'RWS (r, w, s) m Bool)
-> (TMVar m a -> a -> STM m Bool)
-> TMVar m a
-> a
-> WrappedSTM 'RWS (r, w, s) m Bool
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m Bool
tryPutTMVar
readTMVar :: TMVar (RWST r w s m) a -> STM (RWST r w s m) a
readTMVar = STM m a -> WrappedSTM 'RWS (r, w, s) m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'RWS (r, w, s) m a)
-> (TMVar m a -> STM m a)
-> TMVar m a
-> WrappedSTM 'RWS (r, w, s) m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
readTMVar
tryReadTMVar :: TMVar (RWST r w s m) a -> STM (RWST r w s m) (Maybe a)
tryReadTMVar = STM m (Maybe a) -> WrappedSTM 'RWS (r, w, s) m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'RWS (r, w, s) m (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> WrappedSTM 'RWS (r, w, s) m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
tryReadTMVar
swapTMVar :: TMVar (RWST r w s m) a -> a -> STM (RWST r w s m) a
swapTMVar = STM m a -> WrappedSTM 'RWS (r, w, s) m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'RWS (r, w, s) m a)
-> (TMVar m a -> a -> STM m a)
-> TMVar m a
-> a
-> WrappedSTM 'RWS (r, w, s) m a
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TMVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m a
swapTMVar
isEmptyTMVar :: TMVar (RWST r w s m) a -> STM (RWST r w s m) Bool
isEmptyTMVar = STM m Bool -> WrappedSTM 'RWS (r, w, s) m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'RWS (r, w, s) m Bool)
-> (TMVar m a -> STM m Bool)
-> TMVar m a
-> WrappedSTM 'RWS (r, w, s) m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m Bool
isEmptyTMVar
type TQueue (RWST r w s m) = TQueue m
newTQueue :: STM (RWST r w s m) (TQueue (RWST r w s m) a)
newTQueue = STM m (TQueue m a) -> WrappedSTM 'RWS (r, w, s) m (TQueue m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM STM m (TQueue m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TQueue m a)
newTQueue
readTQueue :: TQueue (RWST r w s m) a -> STM (RWST r w s m) a
readTQueue = STM m a -> WrappedSTM 'RWS (r, w, s) m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'RWS (r, w, s) m a)
-> (TQueue m a -> STM m a)
-> TQueue m a
-> WrappedSTM 'RWS (r, w, s) m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
readTQueue
tryReadTQueue :: TQueue (RWST r w s m) a -> STM (RWST r w s m) (Maybe a)
tryReadTQueue = STM m (Maybe a) -> WrappedSTM 'RWS (r, w, s) m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'RWS (r, w, s) m (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> WrappedSTM 'RWS (r, w, s) m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
tryReadTQueue
peekTQueue :: TQueue (RWST r w s m) a -> STM (RWST r w s m) a
peekTQueue = STM m a -> WrappedSTM 'RWS (r, w, s) m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'RWS (r, w, s) m a)
-> (TQueue m a -> STM m a)
-> TQueue m a
-> WrappedSTM 'RWS (r, w, s) m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
peekTQueue
tryPeekTQueue :: TQueue (RWST r w s m) a -> STM (RWST r w s m) (Maybe a)
tryPeekTQueue = STM m (Maybe a) -> WrappedSTM 'RWS (r, w, s) m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'RWS (r, w, s) m (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> WrappedSTM 'RWS (r, w, s) m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
tryPeekTQueue
writeTQueue :: TQueue (RWST r w s m) a -> a -> STM (RWST r w s m) ()
writeTQueue TQueue (RWST r w s m) a
v = STM m () -> WrappedSTM 'RWS (r, w, s) m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'RWS (r, w, s) m ())
-> (a -> STM m ()) -> a -> WrappedSTM 'RWS (r, w, s) m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> a -> STM m ()
writeTQueue TQueue m a
TQueue (RWST r w s m) a
v
isEmptyTQueue :: TQueue (RWST r w s m) a -> STM (RWST r w s m) Bool
isEmptyTQueue = STM m Bool -> WrappedSTM 'RWS (r, w, s) m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'RWS (r, w, s) m Bool)
-> (TQueue m a -> STM m Bool)
-> TQueue m a
-> WrappedSTM 'RWS (r, w, s) m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m Bool
isEmptyTQueue
type TBQueue (RWST r w s m) = TBQueue m
newTBQueue :: Natural -> STM (RWST r w s m) (TBQueue (RWST r w s m) a)
newTBQueue = STM m (TBQueue m a) -> WrappedSTM 'RWS (r, w, s) m (TBQueue m a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (TBQueue m a) -> WrappedSTM 'RWS (r, w, s) m (TBQueue m a))
-> (Natural -> STM m (TBQueue m a))
-> Natural
-> WrappedSTM 'RWS (r, w, s) m (TBQueue m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> STM m (TBQueue m a)
forall (m :: * -> *) a.
MonadSTM m =>
Natural -> STM m (TBQueue m a)
newTBQueue
readTBQueue :: TBQueue (RWST r w s m) a -> STM (RWST r w s m) a
readTBQueue = STM m a -> WrappedSTM 'RWS (r, w, s) m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'RWS (r, w, s) m a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> WrappedSTM 'RWS (r, w, s) m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
readTBQueue
tryReadTBQueue :: TBQueue (RWST r w s m) a -> STM (RWST r w s m) (Maybe a)
tryReadTBQueue = STM m (Maybe a) -> WrappedSTM 'RWS (r, w, s) m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'RWS (r, w, s) m (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> WrappedSTM 'RWS (r, w, s) m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
tryReadTBQueue
peekTBQueue :: TBQueue (RWST r w s m) a -> STM (RWST r w s m) a
peekTBQueue = STM m a -> WrappedSTM 'RWS (r, w, s) m a
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m a -> WrappedSTM 'RWS (r, w, s) m a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> WrappedSTM 'RWS (r, w, s) m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
peekTBQueue
tryPeekTBQueue :: TBQueue (RWST r w s m) a -> STM (RWST r w s m) (Maybe a)
tryPeekTBQueue = STM m (Maybe a) -> WrappedSTM 'RWS (r, w, s) m (Maybe a)
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m (Maybe a) -> WrappedSTM 'RWS (r, w, s) m (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> WrappedSTM 'RWS (r, w, s) m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
tryPeekTBQueue
flushTBQueue :: TBQueue (RWST r w s m) a -> STM (RWST r w s m) [a]
flushTBQueue = STM m [a] -> WrappedSTM 'RWS (r, w, s) m [a]
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m [a] -> WrappedSTM 'RWS (r, w, s) m [a])
-> (TBQueue m a -> STM m [a])
-> TBQueue m a
-> WrappedSTM 'RWS (r, w, s) m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m [a]
flushTBQueue
writeTBQueue :: TBQueue (RWST r w s m) a -> a -> STM (RWST r w s m) ()
writeTBQueue = STM m () -> WrappedSTM 'RWS (r, w, s) m ()
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m () -> WrappedSTM 'RWS (r, w, s) m ())
-> (TBQueue m a -> a -> STM m ())
-> TBQueue m a
-> a
-> WrappedSTM 'RWS (r, w, s) m ()
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: TBQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> a -> STM m ()
writeTBQueue
lengthTBQueue :: TBQueue (RWST r w s m) a -> STM (RWST r w s m) Natural
lengthTBQueue = STM m Natural -> WrappedSTM 'RWS (r, w, s) m Natural
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Natural -> WrappedSTM 'RWS (r, w, s) m Natural)
-> (TBQueue m a -> STM m Natural)
-> TBQueue m a
-> WrappedSTM 'RWS (r, w, s) m Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Natural
lengthTBQueue
isEmptyTBQueue :: TBQueue (RWST r w s m) a -> STM (RWST r w s m) Bool
isEmptyTBQueue = STM m Bool -> WrappedSTM 'RWS (r, w, s) m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'RWS (r, w, s) m Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> WrappedSTM 'RWS (r, w, s) m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
isEmptyTBQueue
isFullTBQueue :: TBQueue (RWST r w s m) a -> STM (RWST r w s m) Bool
isFullTBQueue = STM m Bool -> WrappedSTM 'RWS (r, w, s) m Bool
forall (t :: Trans) r (m :: * -> *) a.
STM m a -> WrappedSTM t r m a
WrappedSTM (STM m Bool -> WrappedSTM 'RWS (r, w, s) m Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> WrappedSTM 'RWS (r, w, s) m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
isFullTBQueue
(.:) :: (c -> d) -> (a -> b -> c) -> (a -> b -> d)
(c -> d
f .: :: (c -> d) -> (a -> b -> c) -> a -> b -> d
.: a -> b -> c
g) a
x b
y = c -> d
f (a -> b -> c
g a
x b
y)