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

Safe HaskellSafe
LanguageHaskell98

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).

Instances
Functor STMS Source # 
Instance details

Defined in Test.IOSpec.STM

Methods

fmap :: (a -> b) -> STMS a -> STMS b #

(<$) :: a -> STMS b -> STMS a #

Executable STMS Source # 
Instance details

Defined in Test.IOSpec.STM

Methods

step :: STMS a -> VM (Step a) Source #

Atomically

atomically :: STMS :<: f => STM a -> IOSpec f a Source #

The atomically function atomically executes an STM action.

The STM monad

data STM a Source #

Instances
Monad STM Source # 
Instance details

Defined in Test.IOSpec.STM

Methods

(>>=) :: STM a -> (a -> STM b) -> STM b #

(>>) :: STM a -> STM b -> STM b #

return :: a -> STM a #

fail :: String -> STM a #

Functor STM Source # 
Instance details

Defined in Test.IOSpec.STM

Methods

fmap :: (a -> b) -> STM a -> STM b #

(<$) :: a -> STM b -> STM a #

Applicative STM Source # 
Instance details

Defined in Test.IOSpec.STM

Methods

pure :: a -> STM a #

(<*>) :: STM (a -> b) -> STM a -> STM b #

liftA2 :: (a -> b -> c) -> STM a -> STM b -> STM c #

(*>) :: STM a -> STM b -> STM b #

(<*) :: STM a -> STM b -> STM a #

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 a Source #

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 a Source #

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

orElse :: STM a -> STM a -> STM a Source #

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.