Copyright | (c) 2017 Michael Walker |
---|---|
License | MIT |
Maintainer | Michael Walker <mike@barrucadu.co.uk> |
Stability | experimental |
Portability | CPP, ExistentialQuantification, MultiParamTypeClasses, NoMonoLocalBinds, TypeFamilies |
Safe Haskell | None |
Language | Haskell2010 |
MonadSTM
testing implementation, internal types and definitions.
This module is NOT considered to form part of the public interface
of this library.
- newtype S n r a = S {}
- data STMAction n r
- newtype TVar r a = TVar (TVarId, r a)
- data Result a
- runTransaction :: MonadRef r n => S n r a -> IdSource -> n (Result a, IdSource, [TAction])
- doTransaction :: MonadRef r n => S n r a -> IdSource -> n (Result a, n (), IdSource, [TAction])
- stepTrans :: MonadRef r n => STMAction n r -> IdSource -> n (STMAction n r, n (), IdSource, [TVarId], [TVarId], TAction)
The S
monad
The underlying monad is based on continuations over primitive actions.
This is not Cont
because we want to give it a custom MonadFail
instance.
Primitive actions
STM transactions are represented as a sequence of primitive actions.
TVar
s
Output
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. |
Execution
runTransaction :: MonadRef r n => S n r a -> IdSource -> n (Result a, IdSource, [TAction]) Source #
Run a transaction, returning the result and new initial TVarId
.
If the transaction failed, any effects are undone.