unlift-stm-0.1.0.0: (un)lifted classes and functions for the STM monad
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.STM.Unlift

Description

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 to MonadSTM. (Some functions necessarily require the more restrictive MonadUnliftSTM typeclass due to STM results appearing in negative positions of the function signature.)
  • This module also includes STM-related functions which return an IO result. These are abstracted to MonadIO or MonadUnliftIO and are re-exported directly from UnliftIO.STM.
Synopsis

Core

data STM a #

A monad supporting atomic memory transactions.

Instances

Instances details
Monad STM

Since: base-4.3.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

(>>=) :: STM a -> (a -> STM b) -> STM b #

(>>) :: STM a -> STM b -> STM b #

return :: a -> STM a #

Functor STM

Since: base-4.3.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

fmap :: (a -> b) -> STM a -> STM b #

(<$) :: a -> STM b -> STM a #

Applicative STM

Since: base-4.8.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

pure :: a -> STM a #

(<*>) :: STM (a -> b) -> STM a -> STM b #

liftA2 :: (a -> b -> c) -> STM a -> STM b -> STM c #

(*>) :: STM a -> STM b -> STM b #

(<*) :: STM a -> STM b -> STM a #

Alternative STM

Since: base-4.8.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

empty :: STM a #

(<|>) :: STM a -> STM a -> STM a #

some :: STM a -> STM [a] #

many :: STM a -> STM [a] #

MonadPlus STM

Since: base-4.3.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

mzero :: STM a #

mplus :: STM a -> STM a -> STM a #

MonadSTM STM Source # 
Instance details

Defined in Control.Monad.STM.Class

Methods

liftSTM :: STM a -> STM a Source #

MonadUnliftSTM STM Source # 
Instance details

Defined in Control.Monad.STM.Unlift

Methods

askUnliftSTM :: STM (UnliftSTM STM) Source #

withRunInSTM :: ((forall a. STM a -> STM a) -> STM b) -> STM b Source #

atomically :: MonadIO m => STM a -> m a #

Lifted version of atomically

Since: unliftio-0.2.1.0

retry :: MonadSTM m => m a Source #

Lifted version of retry

check :: MonadSTM m => Bool -> m () Source #

Lifted version of check

orElse :: MonadUnliftSTM m => m a -> m a -> m a Source #

Lifted version of orElse

throwSTM :: (Exception e, MonadSTM m) => e -> m a Source #

Lifted version of throwSTM

catchSTM :: (Exception e, MonadUnliftSTM m) => m a -> (e -> m a) -> m a Source #

Lifted version of catchSTM

TVar

data TVar a #

Shared memory locations that support atomic memory transactions.

Instances

Instances details
Eq (TVar a)

Since: base-4.8.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

(==) :: TVar a -> TVar a -> Bool #

(/=) :: TVar a -> TVar a -> Bool #

newTVarIO :: MonadIO m => a -> m (TVar a) #

Lifted version of newTVarIO

Since: unliftio-0.2.1.0

readTVarIO :: MonadIO m => TVar a -> m a #

Lifted version of readTVarIO

Since: unliftio-0.2.1.0

newTVar :: MonadSTM m => a -> m (TVar a) Source #

Lifted version of newTVar

readTVar :: MonadSTM m => TVar a -> m a Source #

Lifted version of readTVar

writeTVar :: MonadSTM m => TVar a -> a -> m () Source #

Lifted version of writeTVar

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'

swapTVar :: MonadSTM m => TVar a -> a -> m a Source #

Lifted version of swapTVar

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

data TMVar a #

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.

Instances

Instances details
Eq (TMVar a) 
Instance details

Defined in Control.Concurrent.STM.TMVar

Methods

(==) :: TMVar a -> TMVar a -> Bool #

(/=) :: TMVar a -> TMVar a -> Bool #

newTMVar :: MonadSTM m => a -> m (TMVar a) Source #

Lifted version of newTMVar

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

takeTMVar :: MonadSTM m => TMVar a -> m a Source #

Lifted version of takeTMVar

putTMVar :: MonadSTM m => TMVar a -> a -> m () Source #

Lifted version of putTMVar

readTMVar :: MonadSTM m => TMVar a -> m a Source #

Lifted version of readTMVar

tryReadTMVar :: MonadSTM m => TMVar a -> m (Maybe a) Source #

Lifted version of tryReadTMVar

swapTMVar :: MonadSTM m => TMVar a -> a -> m a Source #

Lifted version of swapTMVar

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

data TChan a #

TChan is an abstract type representing an unbounded FIFO channel.

Instances

Instances details
Eq (TChan a) 
Instance details

Defined in Control.Concurrent.STM.TChan

Methods

(==) :: TChan a -> TChan a -> Bool #

(/=) :: TChan a -> TChan a -> Bool #

newTChan :: MonadSTM m => m (TChan a) Source #

Lifted version of newTChan

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

dupTChan :: MonadSTM m => TChan a -> m (TChan a) Source #

Lifted version of dupTChan

cloneTChan :: MonadSTM m => TChan a -> m (TChan a) Source #

Lifted version of cloneTChan

readTChan :: MonadSTM m => TChan a -> m a Source #

Lifted version of readTChan

tryReadTChan :: MonadSTM m => TChan a -> m (Maybe a) Source #

Lifted version of tryReadTChan

peekTChan :: MonadSTM m => TChan a -> m a Source #

Lifted version of peekTChan

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

newTQueue :: MonadSTM m => m (TQueue a) Source #

Lifted version of newTQueue

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