IOSpec-0.2.2: A pure specification of the IO monad.

Test.IOSpec.STM

Contents

Synopsis

The specification of STM

data STMS a Source

An expression of type IOSpec STMS a corresponds to an IO computation that may use atomically and returns a value of type a.

By itself, STMS is not terribly useful. You will probably want to use IOSpec (ForkS :+: STMS).

Atomically

atomically :: STMS :<: f => STM a -> IOSpec f aSource

The atomically function atomically executes an STM action.

The STM monad

data STM a Source

Instances

data TVar a Source

A TVar is a shared, mutable variable used by STM.

newTVar :: Typeable a => a -> STM (TVar a)Source

The newTVar function creates a new transactional variable.

readTVar :: Typeable a => TVar a -> STM aSource

The readTVar function reads the value stored in a transactional variable.

writeTVar :: Typeable a => TVar a -> a -> STM ()Source

The writeTVar function overwrites the value stored in a transactional variable.

retry :: STM aSource

The retry function abandons a transaction and retries at some later time.

orElse :: STM a -> STM a -> STM aSource

The orElse function takes two STM actions stm1 and stm2 and performs stm1. If stm1 calls retry it performs stm2. If stm1 succeeds, on the other hand, stm2 is not executed.

check :: Bool -> STM ()Source

The check function checks if its boolean argument holds. If the boolean is true, it returns (); otherwise it calls retry.