| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Effects.Concurrent.STM
Description
Provides classes for STM.
Since: 0.1
Synopsis
- data STM a
- class Monad m => MonadSTM (m :: Type -> Type) where
- atomically :: HasCallStack => STM a -> m a
- data TVar a
- newTVarA :: (HasCallStack, MonadSTM m) => a -> m (TVar a)
- readTVarA :: (HasCallStack, MonadSTM m) => TVar a -> m a
- writeTVarA :: (HasCallStack, MonadSTM m) => TVar a -> a -> m ()
- modifyTVarA' :: (HasCallStack, MonadSTM m) => TVar a -> (a -> a) -> m ()
- data TBQueue a
- newTBQueueA :: (HasCallStack, MonadSTM m) => Natural -> m (TBQueue a)
- readTBQueueA :: (HasCallStack, MonadSTM m) => TBQueue a -> m a
- tryReadTBQueueA :: (HasCallStack, MonadSTM m) => TBQueue a -> m (Maybe a)
- writeTBQueueA :: (HasCallStack, MonadSTM m) => TBQueue a -> a -> m ()
- flushTBQueueA :: (HasCallStack, MonadSTM m) => TBQueue a -> m [a]
- data Natural
Effect
A monad supporting atomic memory transactions.
Instances
| Alternative STM # | Takes the first non- Since: base-4.8.0.0 |
| Applicative STM # | Since: base-4.8.0.0 |
| Functor STM # | Since: base-4.3.0.0 |
| Monad STM # | Since: base-4.3.0.0 |
| MonadPlus STM # | Takes the first non- Since: base-4.3.0.0 |
| MArray TArray e STM # | |
Defined in Control.Concurrent.STM.TArray Methods getBounds :: Ix i => TArray i e -> STM (i, i) # getNumElements :: Ix i => TArray i e -> STM Int # newArray :: Ix i => (i, i) -> e -> STM (TArray i e) # newArray_ :: Ix i => (i, i) -> STM (TArray i e) # unsafeNewArray_ :: Ix i => (i, i) -> STM (TArray i e) # | |
| Monoid a => Monoid (STM a) # | Since: base-4.17.0.0 |
| Semigroup a => Semigroup (STM a) # | Since: base-4.17.0.0 |
class Monad m => MonadSTM (m :: Type -> Type) where Source #
STM effect. Note that this class is for monads that can lift entire
STM transactions (i.e. atomically). It is not intended for "STM-like"
monads -- hence has no STM instance -- as the semantics for "STM-like" and
"can lift STM atomically" are different.
Since: 0.1
Instances
| MonadSTM IO Source # | Since: 0.1 |
Defined in Effects.Concurrent.STM Methods atomically :: HasCallStack => STM a -> IO a Source # | |
| MonadSTM m => MonadSTM (ReaderT e m) Source # | Since: 0.1 |
Defined in Effects.Concurrent.STM Methods atomically :: HasCallStack => STM a -> ReaderT e m a Source # | |
TVar
Shared memory locations that support atomic memory transactions.
newTVarA :: (HasCallStack, MonadSTM m) => a -> m (TVar a) Source #
Create a new TVar holding a value supplied and lifts the result via
atomically.
Since: 0.1
readTVarA :: (HasCallStack, MonadSTM m) => TVar a -> m a Source #
Return the current value stored in a TVar and lifts the result via
atomically.
Since: 0.1
writeTVarA :: (HasCallStack, MonadSTM m) => TVar a -> a -> m () Source #
Write the supplied value into a TVar and lifts the action via
atomically.
Since: 0.1
modifyTVarA' :: (HasCallStack, MonadSTM m) => TVar a -> (a -> a) -> m () Source #
Strict version of modifyTVar, lifting the action via
atomically.
Since: 0.1
TBQueue
TBQueue is an abstract type representing a bounded FIFO channel.
Since: stm-2.4
Arguments
| :: (HasCallStack, MonadSTM m) | |
| => Natural | maximum number of elements the queue can hold |
| -> m (TBQueue a) |
Builds and returns a new instance of TBQueue, lifting via atomically.
Since: 0.1
readTBQueueA :: (HasCallStack, MonadSTM m) => TBQueue a -> m a Source #
Read the next value from the TBQueue, lifting via atomically.
Since: 0.1
tryReadTBQueueA :: (HasCallStack, MonadSTM m) => TBQueue a -> m (Maybe a) Source #
A version of readTBQueue which does not retry. Instead it
returns Nothing if no value is available. Lifts via atomically.
Since: 0.1
writeTBQueueA :: (HasCallStack, MonadSTM m) => TBQueue a -> a -> m () Source #
Write a value to a TBQueue; blocks if the queue is full. Lifts via
atomically.
Since: 0.1
flushTBQueueA :: (HasCallStack, MonadSTM m) => TBQueue a -> m [a] Source #
Efficiently read the entire contents of a TBQueue into a list. This
function never retries. Lifts via atomically.
Since: 0.1
Reexports
Natural number
Invariant: numbers <= 0xffffffffffffffff use the NS constructor
Instances
| PrintfArg Natural # | Since: base-4.8.0.0 |
Defined in Text.Printf | |
| Num Natural # | Note that Since: base-4.8.0.0 |
| Eq Natural # | |
| Ord Natural # | |
| KnownNat n => HasResolution (n :: Nat) # | For example, |
Defined in Data.Fixed Methods resolution :: p n -> Integer # | |