Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype IOSim s a = IOSim { }
- runIOSim :: IOSim s a -> SimA s a
- traceM :: Typeable a => a -> IOSim s ()
- traceSTM :: Typeable a => a -> STMSim s ()
- liftST :: ST s a -> IOSim s a
-
data
SimA
s a
where
- Return :: a -> SimA s a
- Say :: String -> SimA s b -> SimA s b
- Output :: Dynamic -> SimA s b -> SimA s b
- LiftST :: ST s a -> (a -> SimA s b) -> SimA s b
- GetMonoTime :: ( Time -> SimA s b) -> SimA s b
- GetWallTime :: ( UTCTime -> SimA s b) -> SimA s b
- SetWallTime :: UTCTime -> SimA s b -> SimA s b
- UnshareClock :: SimA s b -> SimA s b
- NewTimeout :: DiffTime -> ( Timeout ( IOSim s) -> SimA s b) -> SimA s b
- UpdateTimeout :: Timeout ( IOSim s) -> DiffTime -> SimA s b -> SimA s b
- CancelTimeout :: Timeout ( IOSim s) -> SimA s b -> SimA s b
- Throw :: SomeException -> SimA s a
- Catch :: Exception e => SimA s a -> (e -> SimA s a) -> (a -> SimA s b) -> SimA s b
- Evaluate :: a -> (a -> SimA s b) -> SimA s b
- Fork :: IOSim s () -> ( ThreadId -> SimA s b) -> SimA s b
- GetThreadId :: ( ThreadId -> SimA s b) -> SimA s b
- LabelThread :: ThreadId -> String -> SimA s b -> SimA s b
- Atomically :: STM s a -> (a -> SimA s b) -> SimA s b
- ThrowTo :: SomeException -> ThreadId -> SimA s a -> SimA s a
- SetMaskState :: MaskingState -> IOSim s a -> (a -> SimA s b) -> SimA s b
- GetMaskState :: ( MaskingState -> SimA s b) -> SimA s b
- YieldSim :: SimA s a -> SimA s a
- ExploreRaces :: SimA s b -> SimA s b
- Fix :: (x -> IOSim s x) -> (x -> SimA s r) -> SimA s r
- type StepId = ( ThreadId , Int )
- type STMSim = STM
- newtype STM s a = STM { }
- runSTM :: STM s a -> StmA s a
-
data
StmA
s a
where
- ReturnStm :: a -> StmA s a
- ThrowStm :: SomeException -> StmA s a
- NewTVar :: Maybe String -> x -> ( TVar s x -> StmA s b) -> StmA s b
- LabelTVar :: String -> TVar s a -> StmA s b -> StmA s b
- ReadTVar :: TVar s a -> (a -> StmA s b) -> StmA s b
- WriteTVar :: TVar s a -> a -> StmA s b -> StmA s b
- Retry :: StmA s b
- OrElse :: StmA s a -> StmA s a -> (a -> StmA s b) -> StmA s b
- SayStm :: String -> StmA s b -> StmA s b
- OutputStm :: Dynamic -> StmA s b -> StmA s b
- TraceTVar :: forall s a b. TVar s a -> ( Maybe a -> a -> ST s TraceValue ) -> StmA s b -> StmA s b
-
data
StmTxResult
s a
- = StmTxCommitted a [ SomeTVar s] [ SomeTVar s] [ SomeTVar s] [ Dynamic ] [ String ] TVarId
- | StmTxBlocked [ SomeTVar s]
- | StmTxAborted [ SomeTVar s] SomeException
-
data
StmStack
s b a
where
- AtomicallyFrame :: StmStack s a a
- OrElseLeftFrame :: StmA s a -> (a -> StmA s b) -> Map TVarId ( SomeTVar s) -> [ SomeTVar s] -> [ SomeTVar s] -> StmStack s b c -> StmStack s a c
- OrElseRightFrame :: (a -> StmA s b) -> Map TVarId ( SomeTVar s) -> [ SomeTVar s] -> [ SomeTVar s] -> StmStack s b c -> StmStack s a c
- data family Timeout (m :: Type -> Type )
- newtype TimeoutException = TimeoutException TimeoutId
- setCurrentTime :: UTCTime -> IOSim s ()
- unshareClock :: IOSim s ()
-
data
ScheduleControl
- = ControlDefault
- | ControlAwait [ ScheduleMod ]
- | ControlFollow [ StepId ] [ ScheduleMod ]
- data ScheduleMod = ScheduleMod { }
- data ExplorationOptions = ExplorationOptions { }
- type ExplorationSpec = ExplorationOptions -> ExplorationOptions
- withScheduleBound :: Int -> ExplorationSpec
- withBranching :: Int -> ExplorationSpec
- withStepTimelimit :: Int -> ExplorationSpec
- withReplay :: ScheduleControl -> ExplorationSpec
- stdExplorationOptions :: ExplorationOptions
- newtype EventlogEvent = EventlogEvent String
- newtype EventlogMarker = EventlogMarker String
-
data
SimEventType
- = EventSimStart ScheduleControl
- | EventSay String
- | EventLog Dynamic
- | EventMask MaskingState
- | EventThrow SomeException
- | EventThrowTo SomeException ThreadId
- | EventThrowToBlocked
- | EventThrowToWakeup
- | EventThrowToUnmasked ( Labelled ThreadId )
- | EventThreadForked ThreadId
- | EventThreadFinished
- | EventThreadUnhandled SomeException
- | EventTxCommitted [ Labelled TVarId ] [ Labelled TVarId ] ( Maybe Effect)
- | EventTxAborted ( Maybe Effect)
- | EventTxBlocked [ Labelled TVarId ] ( Maybe Effect)
- | EventTxWakeup [ Labelled TVarId ]
- | EventTimerCreated TimeoutId TVarId Time
- | EventTimerUpdated TimeoutId Time
- | EventTimerCancelled TimeoutId
- | EventTimerExpired TimeoutId
- | EventThreadSleep
- | EventThreadWake
- | EventDeschedule Deschedule
- | EventFollowControl ScheduleControl
- | EventAwaitControl StepId ScheduleControl
- | EventPerformAction StepId
- | EventReschedule ScheduleControl
- | EventUnblocked [ ThreadId ]
-
data
SimEvent
-
=
SimEvent
{
- seTime :: ! Time
- seThreadId :: ! ThreadId
- seThreadLabel :: !( Maybe ThreadLabel )
- seType :: ! SimEventType
-
|
SimPOREvent
{
- seTime :: ! Time
- seThreadId :: ! ThreadId
- seStep :: ! Int
- seThreadLabel :: !( Maybe ThreadLabel )
- seType :: ! SimEventType
- | SimRacesFound [ ScheduleControl ]
-
=
SimEvent
{
-
data
SimResult
a
- = MainReturn ! Time a ![ Labelled ThreadId ]
- | MainException ! Time SomeException ![ Labelled ThreadId ]
- | Deadlock ! Time ![ Labelled ThreadId ]
- | Loop
- type SimTrace a = Trace ( SimResult a) SimEvent
-
data
Trace
a b
where
- pattern Trace :: Time -> ThreadId -> Maybe ThreadLabel -> SimEventType -> SimTrace a -> SimTrace a
- pattern SimTrace :: Time -> ThreadId -> Maybe ThreadLabel -> SimEventType -> SimTrace a -> SimTrace a
- pattern SimPORTrace :: Time -> ThreadId -> Int -> Maybe ThreadLabel -> SimEventType -> SimTrace a -> SimTrace a
- pattern TraceMainReturn :: Time -> a -> [ Labelled ThreadId ] -> SimTrace a
- pattern TraceMainException :: Time -> SomeException -> [ Labelled ThreadId ] -> SimTrace a
- pattern TraceDeadlock :: Time -> [ Labelled ThreadId ] -> SimTrace a
- pattern TraceRacesFound :: [ ScheduleControl ] -> SimTrace a -> SimTrace a
- pattern TraceLoop :: SimTrace a
- ppTrace :: Show a => SimTrace a -> String
- ppTrace_ :: SimTrace a -> String
- ppSimEvent :: Int -> Int -> Int -> SimEvent -> String
- ppDebug :: SimTrace a -> x -> x
- type TraceEvent = SimEventType
-
data
Labelled
a =
Labelled
{
- l_labelled :: !a
- l_label :: !( Maybe String )
-
data
ThreadId
- = RacyThreadId [ Int ]
- | ThreadId [ Int ]
- childThreadId :: ThreadId -> Int -> ThreadId
- setRacyThread :: ThreadId -> ThreadId
- newtype TVarId = TVarId Int
- newtype TimeoutId = TimeoutId Int
- newtype ClockId = ClockId [ Int ]
- newtype VectorClock = VectorClock { }
- unTimeoutId :: TimeoutId -> Int
- type ThreadLabel = String
- type TVarLabel = String
-
data
TVar
s a =
TVar
{
- tvarId :: ! TVarId
- tvarLabel :: !( STRef s ( Maybe TVarLabel ))
- tvarCurrent :: !( STRef s a)
- tvarUndo :: !( STRef s [a])
- tvarBlocked :: !( STRef s ([ ThreadId ], Set ThreadId ))
- tvarVClock :: !( STRef s VectorClock )
- tvarTrace :: !( STRef s ( Maybe ( Maybe a -> a -> ST s TraceValue )))
- data SomeTVar s where
-
data
Deschedule
- = Yield
- | Interruptable
- | Blocked
- | Terminated
- | Sleep
- type SimM s = IOSim s
- type SimSTM = STM
Documentation
Instances
Return :: a -> SimA s a | |
Say :: String -> SimA s b -> SimA s b | |
Output :: Dynamic -> SimA s b -> SimA s b | |
LiftST :: ST s a -> (a -> SimA s b) -> SimA s b | |
GetMonoTime :: ( Time -> SimA s b) -> SimA s b | |
GetWallTime :: ( UTCTime -> SimA s b) -> SimA s b | |
SetWallTime :: UTCTime -> SimA s b -> SimA s b | |
UnshareClock :: SimA s b -> SimA s b | |
NewTimeout :: DiffTime -> ( Timeout ( IOSim s) -> SimA s b) -> SimA s b | |
UpdateTimeout :: Timeout ( IOSim s) -> DiffTime -> SimA s b -> SimA s b | |
CancelTimeout :: Timeout ( IOSim s) -> SimA s b -> SimA s b | |
Throw :: SomeException -> SimA s a | |
Catch :: Exception e => SimA s a -> (e -> SimA s a) -> (a -> SimA s b) -> SimA s b | |
Evaluate :: a -> (a -> SimA s b) -> SimA s b | |
Fork :: IOSim s () -> ( ThreadId -> SimA s b) -> SimA s b | |
GetThreadId :: ( ThreadId -> SimA s b) -> SimA s b | |
LabelThread :: ThreadId -> String -> SimA s b -> SimA s b | |
Atomically :: STM s a -> (a -> SimA s b) -> SimA s b | |
ThrowTo :: SomeException -> ThreadId -> SimA s a -> SimA s a | |
SetMaskState :: MaskingState -> IOSim s a -> (a -> SimA s b) -> SimA s b | |
GetMaskState :: ( MaskingState -> SimA s b) -> SimA s b | |
YieldSim :: SimA s a -> SimA s a | |
ExploreRaces :: SimA s b -> SimA s b | |
Fix :: (x -> IOSim s x) -> (x -> SimA s r) -> SimA s r |
ReturnStm :: a -> StmA s a | |
ThrowStm :: SomeException -> StmA s a | |
NewTVar :: Maybe String -> x -> ( TVar s x -> StmA s b) -> StmA s b | |
LabelTVar :: String -> TVar s a -> StmA s b -> StmA s b | |
ReadTVar :: TVar s a -> (a -> StmA s b) -> StmA s b | |
WriteTVar :: TVar s a -> a -> StmA s b -> StmA s b | |
Retry :: StmA s b | |
OrElse :: StmA s a -> StmA s a -> (a -> StmA s b) -> StmA s b | |
SayStm :: String -> StmA s b -> StmA s b | |
OutputStm :: Dynamic -> StmA s b -> StmA s b | |
TraceTVar :: forall s a b. TVar s a -> ( Maybe a -> a -> ST s TraceValue ) -> StmA s b -> StmA s b |
data StmTxResult s a Source #
StmTxCommitted |
A committed transaction reports the vars that were written (in order of first write) so that the scheduler can unblock other threads that were blocked in STM transactions that read any of these vars. It reports the vars that were read, so we can update vector clocks appropriately.
The third list of vars is ones that were created during this
transaction. This is useful for an implementation of
It also includes the updated TVarId name supply. |
StmTxBlocked [ SomeTVar s] |
A blocked transaction reports the vars that were read so that the scheduler can block the thread on those vars. |
StmTxAborted [ SomeTVar s] SomeException |
An aborted transaction reports the vars that were read so that the vector clock can be updated. |
data StmStack s b a where Source #
AtomicallyFrame :: StmStack s a a |
Executing in the context of a top level
|
OrElseLeftFrame :: StmA s a -> (a -> StmA s b) -> Map TVarId ( SomeTVar s) -> [ SomeTVar s] -> [ SomeTVar s] -> StmStack s b c -> StmStack s a c |
Executing in the context of the
left
hand side of an
|
OrElseRightFrame :: (a -> StmA s b) -> Map TVarId ( SomeTVar s) -> [ SomeTVar s] -> [ SomeTVar s] -> StmStack s b c -> StmStack s a c |
Executing in the context of the
right
hand side of an
|
data family Timeout (m :: Type -> Type ) Source #
Instances
data Timeout IO | |
Defined in Control.Monad.Class.MonadTimer |
|
data Timeout ( IOSim s) Source # | |
Defined in Control.Monad.IOSim.Types
data
Timeout
(
IOSim
s)
|
|
newtype Timeout ( ReaderT r m) | |
Defined in Control.Monad.Class.MonadTimer |
|
newtype Timeout ( StateT s m) | |
Defined in Control.Monad.Class.MonadTimer |
|
newtype Timeout ( WriterT w m) | |
Defined in Control.Monad.Class.MonadTimer |
|
newtype Timeout ( RWST r w s m) | |
Defined in Control.Monad.Class.MonadTimer |
newtype TimeoutException Source #
Instances
Eq TimeoutException Source # | |
Defined in Control.Monad.IOSim.Types (==) :: TimeoutException -> TimeoutException -> Bool Source # (/=) :: TimeoutException -> TimeoutException -> Bool Source # |
|
Show TimeoutException Source # | |
Defined in Control.Monad.IOSim.Types |
|
Exception TimeoutException Source # | |
Defined in Control.Monad.IOSim.Types |
setCurrentTime :: UTCTime -> IOSim s () Source #
Set the current wall clock time for the thread's clock domain.
unshareClock :: IOSim s () Source #
Put the thread into a new wall clock domain, not shared with the parent thread. Changing the wall clock time in the new clock domain will not affect the other clock of other threads. All threads forked by this thread from this point onwards will share the new clock domain.
data ScheduleControl Source #
ControlDefault |
default scheduling mode |
ControlAwait [ ScheduleMod ] |
if the current control is
|
ControlFollow [ StepId ] [ ScheduleMod ] |
follow the steps then continue with schedule
modifications. This control is set by
|
Instances
Eq ScheduleControl Source # | |
Defined in Control.Monad.IOSim.Types (==) :: ScheduleControl -> ScheduleControl -> Bool Source # (/=) :: ScheduleControl -> ScheduleControl -> Bool Source # |
|
Ord ScheduleControl Source # | |
Defined in Control.Monad.IOSim.Types compare :: ScheduleControl -> ScheduleControl -> Ordering Source # (<) :: ScheduleControl -> ScheduleControl -> Bool Source # (<=) :: ScheduleControl -> ScheduleControl -> Bool Source # (>) :: ScheduleControl -> ScheduleControl -> Bool Source # (>=) :: ScheduleControl -> ScheduleControl -> Bool Source # max :: ScheduleControl -> ScheduleControl -> ScheduleControl Source # min :: ScheduleControl -> ScheduleControl -> ScheduleControl Source # |
|
Show ScheduleControl Source # | |
Defined in Control.Monad.IOSim.Types |
data ScheduleMod Source #
ScheduleMod | |
|
Instances
Eq ScheduleMod Source # | |
Defined in Control.Monad.IOSim.Types (==) :: ScheduleMod -> ScheduleMod -> Bool Source # (/=) :: ScheduleMod -> ScheduleMod -> Bool Source # |
|
Ord ScheduleMod Source # | |
Defined in Control.Monad.IOSim.Types compare :: ScheduleMod -> ScheduleMod -> Ordering Source # (<) :: ScheduleMod -> ScheduleMod -> Bool Source # (<=) :: ScheduleMod -> ScheduleMod -> Bool Source # (>) :: ScheduleMod -> ScheduleMod -> Bool Source # (>=) :: ScheduleMod -> ScheduleMod -> Bool Source # max :: ScheduleMod -> ScheduleMod -> ScheduleMod Source # min :: ScheduleMod -> ScheduleMod -> ScheduleMod Source # |
|
Show ScheduleMod Source # | |
Defined in Control.Monad.IOSim.Types |
data ExplorationOptions Source #
Instances
Show ExplorationOptions Source # | |
Defined in Control.Monad.IOSim.Types |
withBranching :: Int -> ExplorationSpec Source #
newtype EventlogEvent Source #
Wrapper for Eventlog events so they can be retrieved from the trace with
selectTraceEventsDynamic
.
newtype EventlogMarker Source #
Wrapper for Eventlog markers so they can be retrieved from the trace with
selectTraceEventsDynamic
.
data SimEventType Source #
Instances
Show SimEventType Source # | |
Defined in Control.Monad.IOSim.Types |
Trace
is a recursive data type, it is the trace of a
IOSim
computation.
The trace will contain information about thread sheduling, blocking on
TVar
s, and other internal state changes of
IOSim
. More importantly it
also supports traces generated by the computation with
say
(which
corresponds to using
putStrLn
in
IO
),
traceEventM
, or dynamically typed
traces with
traceM
(which generalise the
base
library
traceM
)
It also contains information on races discovered.
See also:
traceEvents
,
traceResult
,
selectTraceEvents
,
selectTraceEventsDynamic
and
printTraceEventsSay
.
SimEvent | |
|
|
SimPOREvent | |
|
|
SimRacesFound [ ScheduleControl ] |
Instances
MainReturn ! Time a ![ Labelled ThreadId ] | |
MainException ! Time SomeException ![ Labelled ThreadId ] | |
Deadlock ! Time ![ Labelled ThreadId ] | |
Loop |
A
cons
list with polymorphic
nil
, thus an octopus.
Usually used with
a
being a non empty sum type.
pattern Trace :: Time -> ThreadId -> Maybe ThreadLabel -> SimEventType -> SimTrace a -> SimTrace a |
Deprecated: Use
|
pattern SimTrace :: Time -> ThreadId -> Maybe ThreadLabel -> SimEventType -> SimTrace a -> SimTrace a | |
pattern SimPORTrace :: Time -> ThreadId -> Int -> Maybe ThreadLabel -> SimEventType -> SimTrace a -> SimTrace a | |
pattern TraceMainReturn :: Time -> a -> [ Labelled ThreadId ] -> SimTrace a | |
pattern TraceMainException :: Time -> SomeException -> [ Labelled ThreadId ] -> SimTrace a | |
pattern TraceDeadlock :: Time -> [ Labelled ThreadId ] -> SimTrace a | |
pattern TraceRacesFound :: [ ScheduleControl ] -> SimTrace a -> SimTrace a | |
pattern TraceLoop :: SimTrace a |
Instances
Bitraversable Trace Source # | |
Defined in Data.List.Trace bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Trace a b -> f ( Trace c d) Source # |
|
Bifoldable Trace Source # | |
Bifunctor Trace Source # | |
Monoid a => Monad ( Trace a) Source # | |
Functor ( Trace a) Source # | |
Monoid a => MonadFix ( Trace a) Source # | |
Monoid a => MonadFail ( Trace a) Source # | |
Monoid a => Applicative ( Trace a) Source # | |
Defined in Data.List.Trace |
|
Eq a => Eq1 ( Trace a) Source # | |
Ord a => Ord1 ( Trace a) Source # | |
Defined in Data.List.Trace |
|
Show a => Show1 ( Trace a) Source # | |
Monoid a => Alternative ( Trace a) Source # | |
Monoid a => MonadPlus ( Trace a) Source # | |
( Eq b, Eq a) => Eq ( Trace a b) Source # | |
( Ord b, Ord a) => Ord ( Trace a b) Source # | |
Defined in Data.List.Trace |
|
( Show b, Show a) => Show ( Trace a b) Source # | |
Semigroup a => Semigroup ( Trace a b) Source # | |
Monoid a => Monoid ( Trace a b) Source # | |
ppDebug :: SimTrace a -> x -> x Source #
Trace each event using
trace
; this is useful when a trace ends with
a pure error, e.g. an assertion.
type TraceEvent = SimEventType Source #
Deprecated: Use
SimEventType
instead.
Labelled | |
|
Instances
Eq a => Eq ( Labelled a) Source # | |
Ord a => Ord ( Labelled a) Source # | |
Defined in Control.Monad.IOSim.Types compare :: Labelled a -> Labelled a -> Ordering Source # (<) :: Labelled a -> Labelled a -> Bool Source # (<=) :: Labelled a -> Labelled a -> Bool Source # (>) :: Labelled a -> Labelled a -> Bool Source # (>=) :: Labelled a -> Labelled a -> Bool Source # |
|
Show a => Show ( Labelled a) Source # | |
Generic ( Labelled a) Source # | |
type Rep ( Labelled a) Source # | |
Defined in Control.Monad.IOSim.Types
type
Rep
(
Labelled
a) =
D1
('
MetaData
"Labelled" "Control.Monad.IOSim.Types" "io-sim-0.2.0.0-G47lzFOFdKi874hOfjQqmW" '
False
) (
C1
('
MetaCons
"Labelled" '
PrefixI
'
True
) (
S1
('
MetaSel
('
Just
"l_labelled") '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
a)
:*:
S1
('
MetaSel
('
Just
"l_label") '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
(
Maybe
String
))))
|
RacyThreadId [ Int ] | |
ThreadId [ Int ] |
Instances
Eq ThreadId Source # | |
Ord ThreadId Source # | |
Defined in Control.Monad.IOSim.CommonTypes |
|
Show ThreadId Source # | |
setRacyThread :: ThreadId -> ThreadId Source #
Instances
Enum TVarId Source # | |
Defined in Control.Monad.IOSim.CommonTypes succ :: TVarId -> TVarId Source # pred :: TVarId -> TVarId Source # toEnum :: Int -> TVarId Source # fromEnum :: TVarId -> Int Source # enumFrom :: TVarId -> [ TVarId ] Source # enumFromThen :: TVarId -> TVarId -> [ TVarId ] Source # enumFromTo :: TVarId -> TVarId -> [ TVarId ] Source # enumFromThenTo :: TVarId -> TVarId -> TVarId -> [ TVarId ] Source # |
|
Eq TVarId Source # | |
Ord TVarId Source # | |
Defined in Control.Monad.IOSim.CommonTypes |
|
Show TVarId Source # | |
Instances
Enum TimeoutId Source # | |
Defined in Control.Monad.IOSim.CommonTypes succ :: TimeoutId -> TimeoutId Source # pred :: TimeoutId -> TimeoutId Source # toEnum :: Int -> TimeoutId Source # fromEnum :: TimeoutId -> Int Source # enumFrom :: TimeoutId -> [ TimeoutId ] Source # enumFromThen :: TimeoutId -> TimeoutId -> [ TimeoutId ] Source # enumFromTo :: TimeoutId -> TimeoutId -> [ TimeoutId ] Source # enumFromThenTo :: TimeoutId -> TimeoutId -> TimeoutId -> [ TimeoutId ] Source # |
|
Eq TimeoutId Source # | |
Ord TimeoutId Source # | |
Defined in Control.Monad.IOSim.CommonTypes |
|
Show TimeoutId Source # | |
Instances
Eq ClockId Source # | |
Ord ClockId Source # | |
Defined in Control.Monad.IOSim.CommonTypes |
|
Show ClockId Source # | |
newtype VectorClock Source #
Instances
Show VectorClock Source # | |
Defined in Control.Monad.IOSim.CommonTypes |
unTimeoutId :: TimeoutId -> Int Source #
type ThreadLabel = String Source #
TVar | |
|
data Deschedule Source #
Instances
Show Deschedule Source # | |
Defined in Control.Monad.IOSim.CommonTypes |