Safe Haskell | None |
---|---|
Language | Haskell2010 |
The STMLike
Monad
MonadIO ConcIO | |
MonadBase IO ConcIO | |
Monad (STMLike n r) Source | |
Functor (STMLike n r) Source | |
Applicative (STMLike n r) Source | |
MonadThrow (STMLike n r) Source | |
MonadCatch (STMLike n r) Source | |
Monad n => MonadSTM (STMLike n r) Source | |
Monad n => MonadConc (Conc n r (STMLike n r)) Source | |
type TVar (STMLike n r) = TVar r Source | |
type STM (Conc n r (STMLike n r)) = STMLike n r Source | |
type MVar (Conc n r (STMLike n r)) = MVar r Source | |
type CRef (Conc n r (STMLike n r)) = CRef r Source | |
type Ticket (Conc n r (STMLike n r)) = Ticket Source | |
type ThreadId (Conc n r (STMLike n r)) = ThreadId Source |
type STMST t = STMLike (ST t) (STRef t) Source
A MonadSTM
implementation using ST
, it encapsulates a single
atomic transaction. The environment, that is, the collection of
defined TVar
s is implicit, there is no list of them, they exist
purely as references. This makes the types simpler, but means you
can't really get an aggregate of them (if you ever wanted to for
some reason).
type STMIO = STMLike IO IORef Source
A MonadSTM
implementation using ST
, it encapsulates a single
atomic transaction. The environment, that is, the collection of
defined TVar
s is implicit, there is no list of them, they exist
purely as references. This makes the types simpler, but means you
can't really get an aggregate of them (if you ever wanted to for
some reason).
Executing Transactions
The result of an STM transaction, along with which TVar
s it
touched whilst executing.
Success [TVarId] [TVarId] a | The transaction completed successfully, reading the first list
|
Retry [TVarId] | The transaction aborted by calling |
Exception SomeException | The transaction aborted by throwing an exception. |
type TTrace = [TAction] Source
A trace of an STM transaction is just a list of actions that occurred, as there are no scheduling decisions to make.
All the actions that an STM transaction can perform.
TNew | Create a new |
TRead TVarId | Read from a |
TWrite TVarId | Write to a |
TRetry | Abort and discard effects. |
TOrElse TTrace (Maybe TTrace) | Execute a transaction until it succeeds ( |
TThrow | Throw an exception, abort, and discard effects. |
TCatch TTrace (Maybe TTrace) | Execute a transaction until it succeeds ( |
TStop | Terminate successfully and commit effects. |
TLift | Lifts an action from the underlying monad. Note that the
penultimate action in a trace will always be a |
Every TVar
has a unique identifier.