Stability | experimental |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Lifted versions of functions from Control.Concurrent.STM:
- This is meant to be a drop-in replacement for Control.Concurrent.STM and
UnliftIO.STM, for more streamlined use of
STM
functions when using mtl-style monad transformer stacks. - Functions that normally return a
STM
result are abstracted toMonadSTM
. (Some functions necessarily require the more restrictiveMonadUnliftSTM
typeclass due toSTM
results appearing in negative positions of the function signature.) - This module also includes STM-related functions which return an
IO
result. These are abstracted toMonadIO
orMonadUnliftIO
and are re-exported directly from UnliftIO.STM.
Synopsis
- data STM a
- atomically :: MonadIO m => STM a -> m a
- retry :: MonadSTM m => m a
- check :: MonadSTM m => Bool -> m ()
- orElse :: MonadUnliftSTM m => m a -> m a -> m a
- throwSTM :: (Exception e, MonadSTM m) => e -> m a
- catchSTM :: (Exception e, MonadUnliftSTM m) => m a -> (e -> m a) -> m a
- data TVar a
- newTVarIO :: MonadIO m => a -> m (TVar a)
- readTVarIO :: MonadIO m => TVar a -> m a
- newTVar :: MonadSTM m => a -> m (TVar a)
- readTVar :: MonadSTM m => TVar a -> m a
- writeTVar :: MonadSTM m => TVar a -> a -> m ()
- modifyTVar :: MonadSTM m => TVar a -> (a -> a) -> m ()
- modifyTVar' :: MonadSTM m => TVar a -> (a -> a) -> m ()
- modifyTVarM :: MonadSTM m => TVar a -> (a -> m a) -> m ()
- modifyTVarM' :: MonadSTM m => TVar a -> (a -> m a) -> m ()
- swapTVar :: MonadSTM m => TVar a -> a -> m a
- registerDelay :: MonadIO m => Int -> m (TVar Bool)
- mkWeakTVar :: MonadUnliftIO m => TVar a -> m () -> m (Weak (TVar a))
- data TMVar a
- newTMVar :: MonadSTM m => a -> m (TMVar a)
- newEmptyTMVar :: MonadSTM m => m (TMVar a)
- newTMVarIO :: MonadIO m => a -> m (TMVar a)
- newEmptyTMVarIO :: MonadIO m => m (TMVar a)
- takeTMVar :: MonadSTM m => TMVar a -> m a
- putTMVar :: MonadSTM m => TMVar a -> a -> m ()
- readTMVar :: MonadSTM m => TMVar a -> m a
- tryReadTMVar :: MonadSTM m => TMVar a -> m (Maybe a)
- swapTMVar :: MonadSTM m => TMVar a -> a -> m a
- tryTakeTMVar :: MonadSTM m => TMVar a -> m (Maybe a)
- tryPutTMVar :: MonadSTM m => TMVar a -> a -> m Bool
- isEmptyTMVar :: MonadSTM m => TMVar a -> m Bool
- mkWeakTMVar :: MonadUnliftIO m => TMVar a -> m () -> m (Weak (TMVar a))
- data TChan a
- newTChan :: MonadSTM m => m (TChan a)
- newTChanIO :: MonadIO m => m (TChan a)
- newBroadcastTChan :: MonadSTM m => m (TChan a)
- newBroadcastTChanIO :: MonadIO m => m (TChan a)
- dupTChan :: MonadSTM m => TChan a -> m (TChan a)
- cloneTChan :: MonadSTM m => TChan a -> m (TChan a)
- readTChan :: MonadSTM m => TChan a -> m a
- tryReadTChan :: MonadSTM m => TChan a -> m (Maybe a)
- peekTChan :: MonadSTM m => TChan a -> m a
- tryPeekTChan :: MonadSTM m => TChan a -> m (Maybe a)
- writeTChan :: MonadSTM m => TChan a -> a -> m ()
- unGetTChan :: MonadSTM m => TChan a -> a -> m ()
- isEmptyTChan :: MonadSTM m => TChan a -> m Bool
- newTQueue :: MonadSTM m => m (TQueue a)
- newTQueueIO :: MonadIO m => m (TQueue a)
- readTQueue :: MonadSTM m => TQueue a -> m a
- tryReadTQueue :: MonadSTM m => TQueue a -> m (Maybe a)
- peekTQueue :: MonadSTM m => TQueue a -> m a
- tryPeekTQueue :: MonadSTM m => TQueue a -> m (Maybe a)
- writeTQueue :: MonadSTM m => TQueue a -> a -> m ()
- unGetTQueue :: MonadSTM m => TQueue a -> a -> m ()
- isEmptyTQueue :: MonadSTM m => TQueue a -> m Bool
- newTBQueue :: MonadSTM m => Natural -> m (TBQueue a)
- newTBQueueIO :: MonadIO m => Natural -> m (TBQueue a)
- readTBQueue :: MonadSTM m => TBQueue a -> m a
- tryReadTBQueue :: MonadSTM m => TBQueue a -> m (Maybe a)
- peekTBQueue :: MonadSTM m => TBQueue a -> m a
- tryPeekTBQueue :: MonadSTM m => TBQueue a -> m (Maybe a)
- writeTBQueue :: MonadSTM m => TBQueue a -> a -> m ()
- unGetTBQueue :: MonadSTM m => TBQueue a -> a -> m ()
- isEmptyTBQueue :: MonadSTM m => TBQueue a -> m Bool
- isFullTBQueue :: MonadSTM m => TBQueue a -> m Bool
- threadWaitReadSTM :: (MonadIO io, MonadSTM stm) => Fd -> io (stm (), io ())
- threadWaitWriteSTM :: (MonadIO io, MonadSTM stm) => Fd -> io (stm (), io ())
- module Control.Monad.STM.Class
- module Control.Monad.STM.Unlift
- module Control.Monad.IO.Class
- module Control.Monad.IO.Unlift
Core
A monad supporting atomic memory transactions.
Instances
Monad STM | Since: base-4.3.0.0 |
Functor STM | Since: base-4.3.0.0 |
Applicative STM | Since: base-4.8.0.0 |
Alternative STM | Since: base-4.8.0.0 |
MonadPlus STM | Since: base-4.3.0.0 |
MonadSTM STM Source # | |
MonadUnliftSTM STM Source # | |
Defined in Control.Monad.STM.Unlift |
atomically :: MonadIO m => STM a -> m a #
Lifted version of atomically
Since: unliftio-0.2.1.0
orElse :: MonadUnliftSTM m => m a -> m a -> m a Source #
Lifted version of orElse
catchSTM :: (Exception e, MonadUnliftSTM m) => m a -> (e -> m a) -> m a Source #
Lifted version of catchSTM
TVar
Shared memory locations that support atomic memory transactions.
readTVarIO :: MonadIO m => TVar a -> m a #
Lifted version of readTVarIO
Since: unliftio-0.2.1.0
modifyTVar :: MonadSTM m => TVar a -> (a -> a) -> m () Source #
Lifted version of modifyTVar
modifyTVar' :: MonadSTM m => TVar a -> (a -> a) -> m () Source #
Lifted version of modifyTVar'
modifyTVarM :: MonadSTM m => TVar a -> (a -> m a) -> m () Source #
A monadic version of modifyTVar
modifyTVarM' :: MonadSTM m => TVar a -> (a -> m a) -> m () Source #
A monadic version of modifyTVar'
registerDelay :: MonadIO m => Int -> m (TVar Bool) #
Lifted version of registerDelay
Since: unliftio-0.2.1.0
mkWeakTVar :: MonadUnliftIO m => TVar a -> m () -> m (Weak (TVar a)) #
Lifted version of mkWeakTVar
Since: unliftio-0.2.1.0
TMVar
A TMVar
is a synchronising variable, used
for communication between concurrent threads. It can be thought of
as a box, which may be empty or full.
newEmptyTMVar :: MonadSTM m => m (TMVar a) Source #
Lifted version of newEmptyTMVar
newTMVarIO :: MonadIO m => a -> m (TMVar a) #
Lifted version of newTMVarIO
Since: unliftio-0.2.1.0
newEmptyTMVarIO :: MonadIO m => m (TMVar a) #
Lifted version of newEmptyTMVarIO
Since: unliftio-0.2.1.0
tryReadTMVar :: MonadSTM m => TMVar a -> m (Maybe a) Source #
Lifted version of tryReadTMVar
tryTakeTMVar :: MonadSTM m => TMVar a -> m (Maybe a) Source #
Lifted version of tryTakeTMVar
tryPutTMVar :: MonadSTM m => TMVar a -> a -> m Bool Source #
Lifted version of tryPutTMVar
isEmptyTMVar :: MonadSTM m => TMVar a -> m Bool Source #
Lifted version of isEmptyTMVar
mkWeakTMVar :: MonadUnliftIO m => TMVar a -> m () -> m (Weak (TMVar a)) #
Lifted version of mkWeakTMVar
Since: unliftio-0.2.1.0
TChan
TChan
is an abstract type representing an unbounded FIFO channel.
newTChanIO :: MonadIO m => m (TChan a) #
Lifted version of newTChanIO
Since: unliftio-0.2.1.0
newBroadcastTChan :: MonadSTM m => m (TChan a) Source #
Lifted version of newBroadcastTChan
newBroadcastTChanIO :: MonadIO m => m (TChan a) #
Lifted version of newBroadcastTChanIO
Since: unliftio-0.2.1.0
cloneTChan :: MonadSTM m => TChan a -> m (TChan a) Source #
Lifted version of cloneTChan
tryReadTChan :: MonadSTM m => TChan a -> m (Maybe a) Source #
Lifted version of tryReadTChan
tryPeekTChan :: MonadSTM m => TChan a -> m (Maybe a) Source #
Lifted version of tryPeekTChan
writeTChan :: MonadSTM m => TChan a -> a -> m () Source #
Lifted version of writeTChan
unGetTChan :: MonadSTM m => TChan a -> a -> m () Source #
Lifted version of unGetTChan
isEmptyTChan :: MonadSTM m => TChan a -> m Bool Source #
Lifted version of isEmptyTChan
TQueue
newTQueueIO :: MonadIO m => m (TQueue a) #
Lifted version of newTQueueIO
Since: unliftio-0.2.1.0
readTQueue :: MonadSTM m => TQueue a -> m a Source #
Lifted version of readTQueue
tryReadTQueue :: MonadSTM m => TQueue a -> m (Maybe a) Source #
Lifted version of tryReadTQueue
peekTQueue :: MonadSTM m => TQueue a -> m a Source #
Lifted version of peekTQueue
tryPeekTQueue :: MonadSTM m => TQueue a -> m (Maybe a) Source #
Lifted version of tryPeekTQueue
writeTQueue :: MonadSTM m => TQueue a -> a -> m () Source #
Lifted version of writeTQueue
unGetTQueue :: MonadSTM m => TQueue a -> a -> m () Source #
Lifted version of unGetTQueue
isEmptyTQueue :: MonadSTM m => TQueue a -> m Bool Source #
Lifted version of isEmptyTQueue
TBQueue
newTBQueue :: MonadSTM m => Natural -> m (TBQueue a) Source #
Lifted version of newTBQueue
newTBQueueIO :: MonadIO m => Natural -> m (TBQueue a) #
Lifted version of newTBQueueIO
Since: unliftio-0.2.1.0
readTBQueue :: MonadSTM m => TBQueue a -> m a Source #
Lifted version of readTBQueue
tryReadTBQueue :: MonadSTM m => TBQueue a -> m (Maybe a) Source #
Lifted version of tryReadTBQueue
peekTBQueue :: MonadSTM m => TBQueue a -> m a Source #
Lifted version of peekTBQueue
tryPeekTBQueue :: MonadSTM m => TBQueue a -> m (Maybe a) Source #
Lifted version of tryPeekTBQueue
writeTBQueue :: MonadSTM m => TBQueue a -> a -> m () Source #
Lifted version of writeTBQueue
unGetTBQueue :: MonadSTM m => TBQueue a -> a -> m () Source #
Lifted version of unGetTBQueue
isEmptyTBQueue :: MonadSTM m => TBQueue a -> m Bool Source #
Lifted version of isEmptyTBQueue
isFullTBQueue :: MonadSTM m => TBQueue a -> m Bool Source #
Lifted version of isFullTBQueue
Low-level functions on file descriptors
threadWaitReadSTM :: (MonadIO io, MonadSTM stm) => Fd -> io (stm (), io ()) Source #
Lifted version of threadWaitReadSTM
threadWaitWriteSTM :: (MonadIO io, MonadSTM stm) => Fd -> io (stm (), io ()) Source #
Lifted version of threadWaitWriteSTM
Re-exported modules
module Control.Monad.STM.Class
module Control.Monad.STM.Unlift
module Control.Monad.IO.Class
module Control.Monad.IO.Unlift