dejafu-0.7.1.3: Systematic testing for Haskell concurrency.

Copyright(c) 2016 Michael Walker
LicenseMIT
MaintainerMichael Walker <mike@barrucadu.co.uk>
Stabilityexperimental
PortabilityCPP, ExistentialQuantification, MultiParamTypeClasses, RankNTypes
Safe HaskellSafe
LanguageHaskell2010

Test.DejaFu.STM.Internal

Contents

Description

MonadSTM testing implementation, internal types and definitions. This module is NOT considered to form part of the public interface of this library.

Synopsis

Documentation

newtype M n r a Source #

The underlying monad is based on continuations over primitive actions.

This is not Cont because we want to give it a custom MonadFail instance.

Constructors

M 

Fields

Instances

Monad (M n r) Source # 

Methods

(>>=) :: M n r a -> (a -> M n r b) -> M n r b #

(>>) :: M n r a -> M n r b -> M n r b #

return :: a -> M n r a #

fail :: String -> M n r a #

Functor (M n r) Source # 

Methods

fmap :: (a -> b) -> M n r a -> M n r b #

(<$) :: a -> M n r b -> M n r a #

MonadFail (M n r) Source #

Since: 0.7.1.2

Methods

fail :: String -> M n r a #

Applicative (M n r) Source # 

Methods

pure :: a -> M n r a #

(<*>) :: M n r (a -> b) -> M n r a -> M n r b #

(*>) :: M n r a -> M n r b -> M n r b #

(<*) :: M n r a -> M n r b -> M n r a #

cont :: ((a -> STMAction n r) -> STMAction n r) -> M n r a Source #

Construct a continuation-passing operation from a function.

runCont :: M n r a -> (a -> STMAction n r) -> STMAction n r Source #

Run a CPS computation with the given final computation.

Primitive actions

data STMAction n r Source #

STM transactions are represented as a sequence of primitive actions.

Constructors

Exception e => SCatch (e -> M n r a) (M n r a) (a -> STMAction n r) 
SRead (TVar r a) (a -> STMAction n r) 
SWrite (TVar r a) a (STMAction n r) 
SOrElse (M n r a) (M n r a) (a -> STMAction n r) 
SNew String a (TVar r a -> STMAction n r) 
Exception e => SThrow e 
SRetry 
SStop (n ()) 

TVars

newtype TVar r a Source #

A TVar is a tuple of a unique ID and the value contained. The ID is so that blocked transactions can be re-run when a TVar they depend on has changed.

Constructors

TVar (TVarId, r a) 

Output

data Result a Source #

The result of an STM transaction, along with which TVars it touched whilst executing.

Since: 0.1.0.0

Constructors

Success [TVarId] [TVarId] a

The transaction completed successfully, reading the first list TVars and writing to the second.

Retry [TVarId]

The transaction aborted by calling retry, and read the returned TVars. It should be retried when at least one of the TVars has been mutated.

Exception SomeException

The transaction aborted by throwing an exception.

Instances

Functor Result Source # 

Methods

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

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

Foldable Result Source # 

Methods

fold :: Monoid m => Result m -> m #

foldMap :: Monoid m => (a -> m) -> Result a -> m #

foldr :: (a -> b -> b) -> b -> Result a -> b #

foldr' :: (a -> b -> b) -> b -> Result a -> b #

foldl :: (b -> a -> b) -> b -> Result a -> b #

foldl' :: (b -> a -> b) -> b -> Result a -> b #

foldr1 :: (a -> a -> a) -> Result a -> a #

foldl1 :: (a -> a -> a) -> Result a -> a #

toList :: Result a -> [a] #

null :: Result a -> Bool #

length :: Result a -> Int #

elem :: Eq a => a -> Result a -> Bool #

maximum :: Ord a => Result a -> a #

minimum :: Ord a => Result a -> a #

sum :: Num a => Result a -> a #

product :: Num a => Result a -> a #

Show a => Show (Result a) Source # 

Methods

showsPrec :: Int -> Result a -> ShowS #

show :: Result a -> String #

showList :: [Result a] -> ShowS #

NFData a => NFData (Result a) Source #

This only reduces a SomeException to WHNF.

Since: 0.5.1.0

Methods

rnf :: Result a -> () #

isSTMSuccess :: Result a -> Bool Source #

Check if a Result is a Success.

Execution

doTransaction :: MonadRef r n => M n r a -> IdSource -> n (Result a, n (), IdSource, TTrace) Source #

Run a STM transaction, returning an action to undo its effects.

stepTrans :: MonadRef r n => STMAction n r -> IdSource -> n (STMAction n r, n (), IdSource, [TVarId], [TVarId], TAction) Source #

Run a transaction for one step.