| Safe Haskell | Safe |
|---|---|
| Language | Haskell98 |
Data.MRef.Instances
Contents
Description
Documentation
An MVar (pronounced "em-var") is a synchronising variable, used
for communication between concurrent threads. It can be thought of
as a a box, which may be empty or full.
Instances
| Eq (MVar a) | Since: base-4.1.0.0 |
| MonadIO m => PutMRef (MVar a) m a # | |
Defined in Data.MRef.Instances Methods putMReference :: MVar a -> a -> m () # | |
| MonadIO m => TakeMRef (MVar a) m a # | |
Defined in Data.MRef.Instances Methods takeMReference :: MVar a -> m a # | |
| MonadIO m => NewMRef (MVar a) m a # | |
Defined in Data.MRef.Instances | |
| MonadIO m => NewRef (MVar a) m (Maybe a) # | |
Defined in Data.StateRef.Instances Methods newReference :: Maybe a -> m (MVar a) # | |
class Monad m => MonadIO (m :: * -> *) where #
Monads in which IO computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
Minimal complete definition
A monad supporting atomic memory transactions.
Instances
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
Shared memory locations that support atomic memory transactions.
Instances
atomically :: STM a -> IO a #
Perform a series of STM actions atomically.
Using atomically inside an unsafePerformIO or unsafeInterleaveIO
subverts some of guarantees that STM provides. It makes it possible to
run a transaction inside of another transaction, depending on when the
thunk is evaluated. If a nested transaction is attempted, an exception
is thrown by the runtime. It is possible to safely use atomically inside
unsafePerformIO or unsafeInterleaveIO, but the typechecker does not
rule out programs that may attempt nested transactions, meaning that
the programmer must take special care to prevent these.
However, there are functions for creating transactional variables that
can always be safely called in unsafePerformIO. See: newTVarIO,
newTChanIO, newBroadcastTChanIO, newTQueueIO, newTBQueueIO,
and newTMVarIO.
Using unsafePerformIO inside of atomically is also dangerous but for
different reasons. See unsafeIOToSTM for more on this.