| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Control.Monad.IOSim
Synopsis
- data IOSim s a
- type STMSim = STM
- runSim :: (forall s. IOSim s a) -> Either Failure a
- runSimOrThrow :: (forall s. IOSim s a) -> a
- runSimStrictShutdown :: (forall s. IOSim s a) -> Either Failure a
- data Failure
- runSimTrace :: (forall s. IOSim s a) -> SimTrace a
- runSimTraceST :: IOSim s a -> ST s (SimTrace a)
- monadicIOSim_ :: Testable a => (forall s. PropertyM (IOSim s) a) -> Property
- monadicIOSim :: (Testable a, forall s. Monad (m s)) => (SimTrace Property -> Property) -> (forall s a1. m s a1 -> IOSim s a1) -> (forall s. PropertyM (m s) a) -> Property
- runIOSimGen :: (SimTrace a -> Property) -> (forall s. Gen (IOSim s a)) -> Gen Property
- monadicIOSimPOR_ :: Testable a => (forall s. PropertyM (IOSim s) a) -> Property
- monadicIOSimPOR :: (Testable a, forall s. Monad (m s)) => (ExplorationOptions -> ExplorationOptions) -> (Maybe (SimTrace Property) -> SimTrace Property -> Property) -> (forall s a1. m s a1 -> IOSim s a1) -> (forall s. PropertyM (m s) a) -> Property
- runIOSimPORGen :: Testable test => (ExplorationOptions -> ExplorationOptions) -> (Maybe (SimTrace a) -> SimTrace a -> test) -> (forall s. Gen (IOSim s a)) -> Gen Property
- exploreSimTrace :: forall a test. Testable test => (ExplorationOptions -> ExplorationOptions) -> (forall s. IOSim s a) -> (Maybe (SimTrace a) -> SimTrace a -> test) -> Property
- controlSimTrace :: Maybe Int -> ScheduleControl -> (forall s. IOSim s a) -> SimTrace a
- data ScheduleMod = ScheduleMod {
- scheduleModTarget :: StepId
- scheduleModControl :: ScheduleControl
- scheduleModInsertion :: [StepId]
- data ScheduleControl
- = ControlDefault
- | ControlAwait [ScheduleMod]
- | ControlFollow [StepId] [ScheduleMod]
- type ExplorationSpec = ExplorationOptions -> ExplorationOptions
- data ExplorationOptions = ExplorationOptions {}
- stdExplorationOptions :: ExplorationOptions
- withScheduleBound :: Int -> ExplorationSpec
- withBranching :: Int -> ExplorationSpec
- withStepTimelimit :: Int -> ExplorationSpec
- withReplay :: ScheduleControl -> ExplorationSpec
- liftST :: ST s a -> IOSim s a
- setCurrentTime :: UTCTime -> IOSim s ()
- unshareClock :: IOSim s ()
- type SimTrace a = Trace (SimResult a) SimEvent
- newtype Time = Time DiffTime
- data Trace a b where
- Cons b (Trace a b)
- Nil a
- pattern SimTrace :: Time -> IOSimThreadId -> Maybe ThreadLabel -> SimEventType -> SimTrace a -> SimTrace a
- pattern SimPORTrace :: Time -> IOSimThreadId -> Int -> Maybe ThreadLabel -> SimEventType -> SimTrace a -> SimTrace a
- pattern TraceDeadlock :: Time -> [Labelled IOSimThreadId] -> SimTrace a
- pattern TraceLoop :: SimTrace a
- pattern TraceMainReturn :: Time -> Labelled IOSimThreadId -> a -> [Labelled IOSimThreadId] -> SimTrace a
- pattern TraceMainException :: Time -> Labelled IOSimThreadId -> SomeException -> [Labelled IOSimThreadId] -> SimTrace a
- pattern TraceRacesFound :: [ScheduleControl] -> SimTrace a -> SimTrace a
- pattern TraceInternalError :: String -> SimTrace a
- traceEvents :: SimTrace a -> [(Time, IOSimThreadId, Maybe ThreadLabel, SimEventType)]
- traceResult :: Bool -> SimTrace a -> Either Failure a
- data SimResult a
- data SimEvent
- = SimEvent {
- seTime :: !Time
- seThreadId :: !IOSimThreadId
- seThreadLabel :: !(Maybe ThreadLabel)
- seType :: !SimEventType
- | SimPOREvent {
- seTime :: !Time
- seThreadId :: !IOSimThreadId
- seStep :: !Int
- seThreadLabel :: !(Maybe ThreadLabel)
- seType :: !SimEventType
- | SimRacesFound [ScheduleControl]
- = SimEvent {
- data SimEventType
- = EventSay String
- | EventSayEvaluationError SomeException
- | EventLog Dynamic
- | EventLogEvaluationError SomeException
- | EventMask MaskingState
- | EventThrow SomeException
- | EventThrowTo SomeException IOSimThreadId
- | EventThrowToBlocked
- | EventThrowToWakeup
- | EventThrowToUnmasked (Labelled IOSimThreadId)
- | EventEvaluationError SomeException
- | EventEvaluationSuccess
- | EventThreadForked IOSimThreadId
- | EventThreadFinished
- | EventThreadUnhandled SomeException
- | EventUniqueCreated Integer
- | EventTxCommitted [Labelled TVarId] [Labelled TVarId] (Maybe Effect)
- | EventTxAborted (Maybe Effect)
- | EventTxBlocked [Labelled TVarId] (Maybe Effect)
- | EventTxWakeup [Labelled TVarId]
- | EventUnblocked [IOSimThreadId]
- | EventThreadDelay TimeoutId Time
- | EventThreadDelayFired TimeoutId
- | EventTimeoutCreated TimeoutId IOSimThreadId Time
- | EventTimeoutFired TimeoutId
- | EventRegisterDelayCreated TimeoutId TVarId Time
- | EventRegisterDelayFired TimeoutId
- | EventTimerCreated TimeoutId TVarId Time
- | EventTimerCancelled TimeoutId
- | EventTimerFired TimeoutId
- | EventThreadStatus IOSimThreadId IOSimThreadId
- | EventSimStart ScheduleControl
- | EventThreadSleep
- | EventThreadWake
- | EventDeschedule Deschedule
- | EventFollowControl ScheduleControl
- | EventAwaitControl StepId ScheduleControl
- | EventPerformAction StepId
- | EventReschedule ScheduleControl
- | EventEffect VectorClock Effect
- | EventRaces Races
- type ThreadLabel = String
- data IOSimThreadId
- = RacyThreadId [Int]
- | ThreadId [Int]
- data Labelled a = Labelled {
- l_labelled :: !a
- l_label :: !(Maybe String)
- data Unique (s :: k)
- traceM :: Typeable a => a -> IOSim s ()
- traceSTM :: Typeable a => a -> STMSim s ()
- ppTrace :: Show a => SimTrace a -> String
- ppTrace_ :: Trace a SimEvent -> String
- ppEvents :: [(Time, IOSimThreadId, Maybe ThreadLabel, SimEventType)] -> String
- ppSimEvent :: Int -> Int -> Int -> SimEvent -> String
- ppDebug :: SimTrace a -> x -> x
- selectTraceEvents :: (Time -> SimEventType -> Maybe b) -> SimTrace a -> [b]
- selectTraceEvents' :: (Time -> SimEventType -> Maybe b) -> Trace a SimEvent -> [b]
- selectTraceEventsDynamic :: forall a b. Typeable b => SimTrace a -> [b]
- selectTraceEventsDynamicWithTime :: forall a b. Typeable b => SimTrace a -> [(Time, b)]
- selectTraceEventsDynamic' :: forall a b. Typeable b => Trace a SimEvent -> [b]
- selectTraceEventsDynamicWithTime' :: forall a b. Typeable b => Trace a SimEvent -> [(Time, b)]
- selectTraceEventsSay :: SimTrace a -> [String]
- selectTraceEventsSayWithTime :: SimTrace a -> [(Time, String)]
- selectTraceEventsSay' :: Trace a SimEvent -> [String]
- selectTraceEventsSayWithTime' :: Trace a SimEvent -> [(Time, String)]
- selectTraceRaces :: SimTrace a -> [ScheduleControl]
- traceSelectTraceEvents :: (Time -> SimEventType -> Maybe b) -> Trace a SimEvent -> Trace a b
- traceSelectTraceEventsDynamic :: forall a b. Typeable b => Trace a SimEvent -> Trace a b
- traceSelectTraceEventsSay :: Trace a SimEvent -> Trace a String
- printTraceEventsSay :: SimTrace a -> IO ()
- newtype EventlogEvent = EventlogEvent String
- newtype EventlogMarker = EventlogMarker String
- data Timeout s
- newTimeout :: DiffTime -> IOSim s (Timeout s)
- readTimeout :: Timeout s -> STM s TimeoutState
- cancelTimeout :: Timeout s -> IOSim s ()
- awaitTimeout :: Timeout s -> STM s Bool
Simulation monad
Instances
| MonadCatch (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods catch :: (HasCallStack, Exception e) => IOSim s a -> (e -> IOSim s a) -> IOSim s a # catchNoPropagate :: Exception e => IOSim s a -> (ExceptionWithContext e -> IOSim s a) -> IOSim s a # | |||||||||||||||||||||||||||||||||
| MonadMask (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods mask :: HasCallStack => ((forall a. IOSim s a -> IOSim s a) -> IOSim s b) -> IOSim s b # uninterruptibleMask :: HasCallStack => ((forall a. IOSim s a -> IOSim s a) -> IOSim s b) -> IOSim s b # generalBracket :: HasCallStack => IOSim s a -> (a -> ExitCase b -> IOSim s c) -> (a -> IOSim s b) -> IOSim s (b, c) # | |||||||||||||||||||||||||||||||||
| MonadThrow (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods throwM :: (HasCallStack, Exception e) => e -> IOSim s a # rethrowM :: Exception e => ExceptionWithContext e -> IOSim s a # | |||||||||||||||||||||||||||||||||
| Alternative (IOSim s) Source # | |||||||||||||||||||||||||||||||||
| Applicative (IOSim s) Source # | |||||||||||||||||||||||||||||||||
| Functor (IOSim s) Source # | |||||||||||||||||||||||||||||||||
| Monad (IOSim s) Source # | |||||||||||||||||||||||||||||||||
| MonadPlus (IOSim s) Source # | |||||||||||||||||||||||||||||||||
| MonadFail (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| MonadFix (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| MonadInspectMVar (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Associated Types
Methods inspectMVar :: proxy (IOSim s) -> MVar (IOSim s) a -> InspectMVarMonad (IOSim s) (Maybe a) | |||||||||||||||||||||||||||||||||
| MonadLabelledMVar (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| MonadMVar (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Associated Types
Methods newEmptyMVar :: IOSim s (MVar (IOSim s) a) takeMVar :: MVar (IOSim s) a -> IOSim s a putMVar :: MVar (IOSim s) a -> a -> IOSim s () tryTakeMVar :: MVar (IOSim s) a -> IOSim s (Maybe a) tryPutMVar :: MVar (IOSim s) a -> a -> IOSim s Bool isEmptyMVar :: MVar (IOSim s) a -> IOSim s Bool newMVar :: a -> IOSim s (MVar (IOSim s) a) readMVar :: MVar (IOSim s) a -> IOSim s a tryReadMVar :: MVar (IOSim s) a -> IOSim s (Maybe a) swapMVar :: MVar (IOSim s) a -> a -> IOSim s a withMVar :: MVar (IOSim s) a -> (a -> IOSim s b) -> IOSim s b withMVarMasked :: MVar (IOSim s) a -> (a -> IOSim s b) -> IOSim s b modifyMVar_ :: MVar (IOSim s) a -> (a -> IOSim s a) -> IOSim s () modifyMVar :: MVar (IOSim s) a -> (a -> IOSim s (a, b)) -> IOSim s b modifyMVarMasked_ :: MVar (IOSim s) a -> (a -> IOSim s a) -> IOSim s () modifyMVarMasked :: MVar (IOSim s) a -> (a -> IOSim s (a, b)) -> IOSim s b | |||||||||||||||||||||||||||||||||
| MonadTraceMVar (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| MonadAsync (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Associated Types
Methods async :: IOSim s a -> IOSim s (Async (IOSim s) a) asyncBound :: IOSim s a -> IOSim s (Async (IOSim s) a) asyncOn :: Int -> IOSim s a -> IOSim s (Async (IOSim s) a) asyncThreadId :: Async (IOSim s) a -> ThreadId (IOSim s) withAsync :: IOSim s a -> (Async (IOSim s) a -> IOSim s b) -> IOSim s b withAsyncBound :: IOSim s a -> (Async (IOSim s) a -> IOSim s b) -> IOSim s b withAsyncOn :: Int -> IOSim s a -> (Async (IOSim s) a -> IOSim s b) -> IOSim s b waitSTM :: Async (IOSim s) a -> STM (IOSim s) a pollSTM :: Async (IOSim s) a -> STM (IOSim s) (Maybe (Either SomeException a)) waitCatchSTM :: Async (IOSim s) a -> STM (IOSim s) (Either SomeException a) waitAnySTM :: [Async (IOSim s) a] -> STM (IOSim s) (Async (IOSim s) a, a) waitAnyCatchSTM :: [Async (IOSim s) a] -> STM (IOSim s) (Async (IOSim s) a, Either SomeException a) waitEitherSTM :: Async (IOSim s) a -> Async (IOSim s) b -> STM (IOSim s) (Either a b) waitEitherSTM_ :: Async (IOSim s) a -> Async (IOSim s) b -> STM (IOSim s) () waitEitherCatchSTM :: Async (IOSim s) a -> Async (IOSim s) b -> STM (IOSim s) (Either (Either SomeException a) (Either SomeException b)) waitBothSTM :: Async (IOSim s) a -> Async (IOSim s) b -> STM (IOSim s) (a, b) wait :: Async (IOSim s) a -> IOSim s a poll :: Async (IOSim s) a -> IOSim s (Maybe (Either SomeException a)) waitCatch :: Async (IOSim s) a -> IOSim s (Either SomeException a) cancel :: Async (IOSim s) a -> IOSim s () cancelWith :: Exception e => Async (IOSim s) a -> e -> IOSim s () uninterruptibleCancel :: Async (IOSim s) a -> IOSim s () waitAny :: [Async (IOSim s) a] -> IOSim s (Async (IOSim s) a, a) waitAnyCatch :: [Async (IOSim s) a] -> IOSim s (Async (IOSim s) a, Either SomeException a) waitAnyCancel :: [Async (IOSim s) a] -> IOSim s (Async (IOSim s) a, a) waitAnyCatchCancel :: [Async (IOSim s) a] -> IOSim s (Async (IOSim s) a, Either SomeException a) waitEither :: Async (IOSim s) a -> Async (IOSim s) b -> IOSim s (Either a b) waitEitherCatch :: Async (IOSim s) a -> Async (IOSim s) b -> IOSim s (Either (Either SomeException a) (Either SomeException b)) waitEitherCancel :: Async (IOSim s) a -> Async (IOSim s) b -> IOSim s (Either a b) waitEitherCatchCancel :: Async (IOSim s) a -> Async (IOSim s) b -> IOSim s (Either (Either SomeException a) (Either SomeException b)) waitEither_ :: Async (IOSim s) a -> Async (IOSim s) b -> IOSim s () waitBoth :: Async (IOSim s) a -> Async (IOSim s) b -> IOSim s (a, b) race :: IOSim s a -> IOSim s b -> IOSim s (Either a b) race_ :: IOSim s a -> IOSim s b -> IOSim s () concurrently :: IOSim s a -> IOSim s b -> IOSim s (a, b) concurrently_ :: IOSim s a -> IOSim s b -> IOSim s () asyncWithUnmask :: ((forall b. IOSim s b -> IOSim s b) -> IOSim s a) -> IOSim s (Async (IOSim s) a) asyncOnWithUnmask :: Int -> ((forall b. IOSim s b -> IOSim s b) -> IOSim s a) -> IOSim s (Async (IOSim s) a) withAsyncWithUnmask :: ((forall c. IOSim s c -> IOSim s c) -> IOSim s a) -> (Async (IOSim s) a -> IOSim s b) -> IOSim s b withAsyncOnWithUnmask :: Int -> ((forall c. IOSim s c -> IOSim s c) -> IOSim s a) -> (Async (IOSim s) a -> IOSim s b) -> IOSim s b compareAsyncs :: Async (IOSim s) a -> Async (IOSim s) b -> Ordering | |||||||||||||||||||||||||||||||||
| MonadEventlog (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods traceEventIO :: String -> IOSim s () traceMarkerIO :: String -> IOSim s () flushEventLog :: IOSim s () | |||||||||||||||||||||||||||||||||
| MonadFork (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods forkIO :: IOSim s () -> IOSim s (ThreadId (IOSim s)) forkOn :: Int -> IOSim s () -> IOSim s (ThreadId (IOSim s)) forkIOWithUnmask :: ((forall a. IOSim s a -> IOSim s a) -> IOSim s ()) -> IOSim s (ThreadId (IOSim s)) forkFinally :: IOSim s a -> (Either SomeException a -> IOSim s ()) -> IOSim s (ThreadId (IOSim s)) throwTo :: Exception e => ThreadId (IOSim s) -> e -> IOSim s () killThread :: ThreadId (IOSim s) -> IOSim s () getNumCapabilities :: IOSim s Int | |||||||||||||||||||||||||||||||||
| MonadThread (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Associated Types
Methods myThreadId :: IOSim s (ThreadId (IOSim s)) labelThread :: ThreadId (IOSim s) -> String -> IOSim s () threadLabel :: ThreadId (IOSim s) -> IOSim s (Maybe String) | |||||||||||||||||||||||||||||||||
| MonadST (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| MonadInspectSTM (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Associated Types
Methods inspectTVar :: proxy (IOSim s) -> TVar (IOSim s) a -> InspectMonadSTM (IOSim s) a inspectTMVar :: proxy (IOSim s) -> TMVar (IOSim s) a -> InspectMonadSTM (IOSim s) (Maybe a) | |||||||||||||||||||||||||||||||||
| MonadLabelledSTM (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods labelTVar :: TVar (IOSim s) a -> String -> STM (IOSim s) () labelTMVar :: TMVar (IOSim s) a -> String -> STM (IOSim s) () labelTQueue :: TQueue (IOSim s) a -> String -> STM (IOSim s) () labelTBQueue :: TBQueue (IOSim s) a -> String -> STM (IOSim s) () labelTArray :: (Ix i, Show i) => TArray (IOSim s) i e -> String -> STM (IOSim s) () labelTSem :: TSem (IOSim s) -> String -> STM (IOSim s) () labelTChan :: TChan (IOSim s) a -> String -> STM (IOSim s) () labelTVarIO :: TVar (IOSim s) a -> String -> IOSim s () labelTMVarIO :: TMVar (IOSim s) a -> String -> IOSim s () labelTQueueIO :: TQueue (IOSim s) a -> String -> IOSim s () labelTBQueueIO :: TBQueue (IOSim s) a -> String -> IOSim s () labelTArrayIO :: (Ix i, Show i) => TArray (IOSim s) i e -> String -> IOSim s () labelTSemIO :: TSem (IOSim s) -> String -> IOSim s () labelTChanIO :: TChan (IOSim s) a -> String -> IOSim s () | |||||||||||||||||||||||||||||||||
| MonadSTM (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Associated Types
Methods atomically :: HasCallStack => STM (IOSim s) a -> IOSim s a newTVar :: a -> STM (IOSim s) (TVar (IOSim s) a) readTVar :: TVar (IOSim s) a -> STM (IOSim s) a writeTVar :: TVar (IOSim s) a -> a -> STM (IOSim s) () orElse :: STM (IOSim s) a -> STM (IOSim s) a -> STM (IOSim s) a modifyTVar :: TVar (IOSim s) a -> (a -> a) -> STM (IOSim s) () modifyTVar' :: TVar (IOSim s) a -> (a -> a) -> STM (IOSim s) () stateTVar :: TVar (IOSim s) s0 -> (s0 -> (a, s0)) -> STM (IOSim s) a swapTVar :: TVar (IOSim s) a -> a -> STM (IOSim s) a check :: Bool -> STM (IOSim s) () newTMVar :: a -> STM (IOSim s) (TMVar (IOSim s) a) newEmptyTMVar :: STM (IOSim s) (TMVar (IOSim s) a) takeTMVar :: TMVar (IOSim s) a -> STM (IOSim s) a tryTakeTMVar :: TMVar (IOSim s) a -> STM (IOSim s) (Maybe a) putTMVar :: TMVar (IOSim s) a -> a -> STM (IOSim s) () tryPutTMVar :: TMVar (IOSim s) a -> a -> STM (IOSim s) Bool readTMVar :: TMVar (IOSim s) a -> STM (IOSim s) a tryReadTMVar :: TMVar (IOSim s) a -> STM (IOSim s) (Maybe a) swapTMVar :: TMVar (IOSim s) a -> a -> STM (IOSim s) a writeTMVar :: TMVar (IOSim s) a -> a -> STM (IOSim s) () isEmptyTMVar :: TMVar (IOSim s) a -> STM (IOSim s) Bool newTQueue :: STM (IOSim s) (TQueue (IOSim s) a) readTQueue :: TQueue (IOSim s) a -> STM (IOSim s) a tryReadTQueue :: TQueue (IOSim s) a -> STM (IOSim s) (Maybe a) peekTQueue :: TQueue (IOSim s) a -> STM (IOSim s) a tryPeekTQueue :: TQueue (IOSim s) a -> STM (IOSim s) (Maybe a) flushTQueue :: TQueue (IOSim s) a -> STM (IOSim s) [a] writeTQueue :: TQueue (IOSim s) a -> a -> STM (IOSim s) () isEmptyTQueue :: TQueue (IOSim s) a -> STM (IOSim s) Bool unGetTQueue :: TQueue (IOSim s) a -> a -> STM (IOSim s) () newTBQueue :: Natural -> STM (IOSim s) (TBQueue (IOSim s) a) readTBQueue :: TBQueue (IOSim s) a -> STM (IOSim s) a tryReadTBQueue :: TBQueue (IOSim s) a -> STM (IOSim s) (Maybe a) peekTBQueue :: TBQueue (IOSim s) a -> STM (IOSim s) a tryPeekTBQueue :: TBQueue (IOSim s) a -> STM (IOSim s) (Maybe a) flushTBQueue :: TBQueue (IOSim s) a -> STM (IOSim s) [a] writeTBQueue :: TBQueue (IOSim s) a -> a -> STM (IOSim s) () lengthTBQueue :: TBQueue (IOSim s) a -> STM (IOSim s) Natural isEmptyTBQueue :: TBQueue (IOSim s) a -> STM (IOSim s) Bool isFullTBQueue :: TBQueue (IOSim s) a -> STM (IOSim s) Bool unGetTBQueue :: TBQueue (IOSim s) a -> a -> STM (IOSim s) () newTSem :: Integer -> STM (IOSim s) (TSem (IOSim s)) waitTSem :: TSem (IOSim s) -> STM (IOSim s) () signalTSem :: TSem (IOSim s) -> STM (IOSim s) () signalTSemN :: Natural -> TSem (IOSim s) -> STM (IOSim s) () newTChan :: STM (IOSim s) (TChan (IOSim s) a) newBroadcastTChan :: STM (IOSim s) (TChan (IOSim s) a) dupTChan :: TChan (IOSim s) a -> STM (IOSim s) (TChan (IOSim s) a) cloneTChan :: TChan (IOSim s) a -> STM (IOSim s) (TChan (IOSim s) a) readTChan :: TChan (IOSim s) a -> STM (IOSim s) a tryReadTChan :: TChan (IOSim s) a -> STM (IOSim s) (Maybe a) peekTChan :: TChan (IOSim s) a -> STM (IOSim s) a tryPeekTChan :: TChan (IOSim s) a -> STM (IOSim s) (Maybe a) writeTChan :: TChan (IOSim s) a -> a -> STM (IOSim s) () unGetTChan :: TChan (IOSim s) a -> a -> STM (IOSim s) () isEmptyTChan :: TChan (IOSim s) a -> STM (IOSim s) Bool newTVarIO :: a -> IOSim s (TVar (IOSim s) a) readTVarIO :: TVar (IOSim s) a -> IOSim s a newTMVarIO :: a -> IOSim s (TMVar (IOSim s) a) newEmptyTMVarIO :: IOSim s (TMVar (IOSim s) a) newTQueueIO :: IOSim s (TQueue (IOSim s) a) newTBQueueIO :: Natural -> IOSim s (TBQueue (IOSim s) a) newTChanIO :: IOSim s (TChan (IOSim s) a) newBroadcastTChanIO :: IOSim s (TChan (IOSim s) a) | |||||||||||||||||||||||||||||||||
| MonadTraceSTM (IOSim s) Source # | This instance adds a trace when a variable was written, just after the stm transaction was committed. Traces the first value using dynamic tracing, like | ||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods traceTVar :: proxy (IOSim s) -> TVar (IOSim s) a -> (Maybe a -> a -> InspectMonadSTM (IOSim s) TraceValue) -> STM (IOSim s) () traceTMVar :: proxy (IOSim s) -> TMVar (IOSim s) a -> (Maybe (Maybe a) -> Maybe a -> InspectMonadSTM (IOSim s) TraceValue) -> STM (IOSim s) () traceTQueue :: proxy (IOSim s) -> TQueue (IOSim s) a -> (Maybe [a] -> [a] -> InspectMonadSTM (IOSim s) TraceValue) -> STM (IOSim s) () traceTBQueue :: proxy (IOSim s) -> TBQueue (IOSim s) a -> (Maybe [a] -> [a] -> InspectMonadSTM (IOSim s) TraceValue) -> STM (IOSim s) () traceTSem :: proxy (IOSim s) -> TSem (IOSim s) -> (Maybe Integer -> Integer -> InspectMonadSTM (IOSim s) TraceValue) -> STM (IOSim s) () traceTVarIO :: TVar (IOSim s) a -> (Maybe a -> a -> InspectMonadSTM (IOSim s) TraceValue) -> IOSim s () traceTMVarIO :: TMVar (IOSim s) a -> (Maybe (Maybe a) -> Maybe a -> InspectMonadSTM (IOSim s) TraceValue) -> IOSim s () traceTQueueIO :: TQueue (IOSim s) a -> (Maybe [a] -> [a] -> InspectMonadSTM (IOSim s) TraceValue) -> IOSim s () traceTBQueueIO :: TBQueue (IOSim s) a -> (Maybe [a] -> [a] -> InspectMonadSTM (IOSim s) TraceValue) -> IOSim s () traceTSemIO :: TSem (IOSim s) -> (Maybe Integer -> Integer -> InspectMonadSTM (IOSim s) TraceValue) -> IOSim s () | |||||||||||||||||||||||||||||||||
| MonadSay (IOSim s) Source # | `IOSim s` instance is strict: the string will be evaluated to normal form,
if an exception is encountered it is thrown in the current thread, and the
log will contain | ||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| MonadTest (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods exploreRaces :: IOSim s () | |||||||||||||||||||||||||||||||||
| MonadCatch (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods catch :: Exception e => IOSim s a -> (e -> IOSim s a) -> IOSim s a catchJust :: Exception e => (e -> Maybe b) -> IOSim s a -> (b -> IOSim s a) -> IOSim s a try :: Exception e => IOSim s a -> IOSim s (Either e a) tryJust :: Exception e => (e -> Maybe b) -> IOSim s a -> IOSim s (Either b a) handle :: Exception e => (e -> IOSim s a) -> IOSim s a -> IOSim s a handleJust :: Exception e => (e -> Maybe b) -> (b -> IOSim s a) -> IOSim s a -> IOSim s a onException :: IOSim s a -> IOSim s b -> IOSim s a bracketOnError :: IOSim s a -> (a -> IOSim s b) -> (a -> IOSim s c) -> IOSim s c generalBracket :: IOSim s a -> (a -> ExitCase b -> IOSim s c) -> (a -> IOSim s b) -> IOSim s (b, c) | |||||||||||||||||||||||||||||||||
| MonadEvaluate (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| MonadMask (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods mask :: ((forall a. IOSim s a -> IOSim s a) -> IOSim s b) -> IOSim s b uninterruptibleMask :: ((forall a. IOSim s a -> IOSim s a) -> IOSim s b) -> IOSim s b mask_ :: IOSim s a -> IOSim s a uninterruptibleMask_ :: IOSim s a -> IOSim s a getMaskingState :: IOSim s MaskingState interruptible :: IOSim s a -> IOSim s a allowInterrupt :: IOSim s () | |||||||||||||||||||||||||||||||||
| MonadMaskingState (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| MonadThrow (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| MonadMonotonicTimeNSec (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods | |||||||||||||||||||||||||||||||||
| MonadTime (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods getCurrentTime :: IOSim s UTCTime | |||||||||||||||||||||||||||||||||
| MonadDelay (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods threadDelay :: Int -> IOSim s () | |||||||||||||||||||||||||||||||||
| MonadTimer (IOSim s) Source # | |||||||||||||||||||||||||||||||||
| MonadUnique (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Associated Types
| |||||||||||||||||||||||||||||||||
| MonadMonotonicTime (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods getMonotonicTime :: IOSim s Time | |||||||||||||||||||||||||||||||||
| MonadDelay (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types Methods threadDelay :: DiffTime -> IOSim s () | |||||||||||||||||||||||||||||||||
| MonadTimer (IOSim s) Source # | |||||||||||||||||||||||||||||||||
| PrimMonad (IOSim s) Source # | This provides access to (almost) everything from the
Since: 1.4.1.0 | ||||||||||||||||||||||||||||||||
| Monoid a => Monoid (IOSim s a) Source # | |||||||||||||||||||||||||||||||||
| Semigroup a => Semigroup (IOSim s a) Source # | |||||||||||||||||||||||||||||||||
| NoThunks a => NoThunks (StrictTVar (IOSim s) a) Source # | |||||||||||||||||||||||||||||||||
| NoThunks (IOSim s a) Source # | Just like the IO instance, we don't actually check anything here | ||||||||||||||||||||||||||||||||
| type InspectMVarMonad (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| type MVar (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types type MVar (IOSim s) | |||||||||||||||||||||||||||||||||
| type Async (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types type Async (IOSim s) | |||||||||||||||||||||||||||||||||
| type ThreadId (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| type InspectMonadSTM (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| type STM (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types type STM (IOSim s) | |||||||||||||||||||||||||||||||||
| type TArray (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| type TBQueue (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types type TBQueue (IOSim s) | |||||||||||||||||||||||||||||||||
| type TChan (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| type TMVar (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| type TQueue (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types type TQueue (IOSim s) | |||||||||||||||||||||||||||||||||
| type TSem (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| type TVar (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types type TVar (IOSim s) | |||||||||||||||||||||||||||||||||
| type Unique (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
| type PrimState (IOSim s) Source # | |||||||||||||||||||||||||||||||||
Defined in Control.Monad.IOSim.Types | |||||||||||||||||||||||||||||||||
Run simulation
runSimOrThrow :: (forall s. IOSim s a) -> a Source #
For quick experiments and tests it is often appropriate and convenient to simply throw failures as exceptions.
runSimStrictShutdown :: (forall s. IOSim s a) -> Either Failure a Source #
Like runSim but fail when the main thread terminates if there are other
threads still running or blocked. If one is trying to follow a strict thread
clean-up policy then this helps testing for that.
Simulation terminated a failure.
Constructors
| FailureException SomeException | The main thread terminated with an exception. |
| FailureDeadlock ![Labelled IOSimThreadId] | The threads all deadlocked. |
| FailureSloppyShutdown [Labelled IOSimThreadId] | The main thread terminated normally but other threads were still
alive, and strict shutdown checking was requested.
See |
| FailureEvaluation SomeException | An exception was thrown while evaluation the trace. This could be an internal assertion failure of `io-sim` or an unhandled exception in the simulation. |
| FailureInternal String | An internal failure of the simulator. Please open an issue at https://github.com/input-output-hk/io-sim/issues. |
Instances
| Exception Failure Source # | |
Defined in Control.Monad.IOSim Methods toException :: Failure -> SomeException # fromException :: SomeException -> Maybe Failure # displayException :: Failure -> String # backtraceDesired :: Failure -> Bool # | |
| Show Failure Source # | |
runSimTrace :: (forall s. IOSim s a) -> SimTrace a Source #
See runSimTraceST below.
runSimTraceST :: IOSim s a -> ST s (SimTrace a) Source #
The most general method of running IOSim is in the lazy ST monad. One
can recover failures or the result from SimTrace with
traceResult, or access SimEventTypes generated by
the computation with traceEvents. A slightly more
convenient way is exposed by runSimTrace.
QuickCheck Monadic combinators
monadicIOSim_ :: Testable a => (forall s. PropertyM (IOSim s) a) -> Property Source #
Like https://hackage.haskell.org/package/QuickCheck-2.14.3/docs/Test-QuickCheck-Monadic.html#v:monadicST.
Note: it calls traceResult in non-strict mode, e.g. leaked threads do not
cause failures.
Since: 1.4.1.0
Arguments
| :: (Testable a, forall s. Monad (m s)) | |
| => (SimTrace Property -> Property) | Allows to trace either (\e -> counterexample (show e) False) id . traceResult False as |
| -> (forall s a1. m s a1 -> IOSim s a1) | natural transformation from |
| -> (forall s. PropertyM (m s) a) | |
| -> Property |
A more general version of monadicIOSim_, which:
- allows to run in monad stacks build on top of
IOSim; - gives more control how to attach debugging information to failed tests.
Note, to use this combinator your monad needs to be defined as:
newtype M s a = M s { runM :: ReaderT State (IOSim s) a }It's important that `M s` is a monad. For such a monad one you'll need provide
a natural transformation:
-- the state could also be created as an IOSim computation.
nat :: forall s a. State -> M s a -> IOSim s a
nat state m = runStateT (runM m) state
Since: 1.4.1.0
runIOSimGen :: (SimTrace a -> Property) -> (forall s. Gen (IOSim s a)) -> Gen Property Source #
Like <runSTGen https://hackage.haskell.org/package/QuickCheck-2.14.3/docs/Test-QuickCheck-Monadic.html#v:runSTGen>.
Since: 1.4.1.0
Explore races using IOSimPOR
monadicIOSimPOR_ :: Testable a => (forall s. PropertyM (IOSim s) a) -> Property Source #
Like <monadicST https://hackage.haskell.org/package/QuickCheck-2.14.3/docs/Test-QuickCheck-Monadic.html#v:monadicST>, but using IOSimPOR schedule exploration.
Note: it calls traceResult in non-strict mode, e.g. leaked threads do not
cause failures.
testProperty "example" $
monadicIOSimPOR_ $ do
x <- run (pure (1 :: Int))
assert (x == 1)Since: 1.10.0.0
monadicIOSimPOR :: (Testable a, forall s. Monad (m s)) => (ExplorationOptions -> ExplorationOptions) -> (Maybe (SimTrace Property) -> SimTrace Property -> Property) -> (forall s a1. m s a1 -> IOSim s a1) -> (forall s. PropertyM (m s) a) -> Property Source #
A IOSimPOR variant of monadicIOSim_, which:
- explores alternative schedules using
exploreSimTrace; - allows to run in monad stacks build on top of
IOSim; - gives more control how to attach debugging information to failed tests.
Note, to use this combinator your monad needs to be defined as:
newtype M s a = M { runM :: ReaderT State (IOSim s) a }It's important that `M s` is a monad. For such a monad you'll need to
provide a natural transformation:
-- the state could also be created as an IOSim computation.
nat :: forall s a. State -> M s a -> IOSim s a
nat state m = runStateT (runM m) state
Since: 1.10.0.0
runIOSimPORGen :: Testable test => (ExplorationOptions -> ExplorationOptions) -> (Maybe (SimTrace a) -> SimTrace a -> test) -> (forall s. Gen (IOSim s a)) -> Gen Property Source #
Like <runSTGen
https://hackage.haskell.org/package/QuickCheck-2.14.3/docs/Test-QuickCheck-Monadic.html#v:runSTGen>,
but evaluates generated simulations using exploreSimTrace.
The callback receives the previously passing trace (if any) and the current trace being checked.
Since: 1.10.0.0
IOSimPOR is a different interpreter of IOSim which has the ability to
discover race conditions and replay the simulation using a schedule which
reverts them. For extended documentation how to use it see
here.
IOSimPOR only discovers races between events which happen in the same time
slot. In IOSim and IOSimPOR time only moves explicitly through timer
events, e.g. things like threadDelay,
registerDelay or the
NonStandard API. The usual
QuickCheck techniques can help explore different schedules of
threads too.
Arguments
| :: forall a test. Testable test | |
| => (ExplorationOptions -> ExplorationOptions) | modify default exploration options |
| -> (forall s. IOSim s a) | a simulation to run |
| -> (Maybe (SimTrace a) -> SimTrace a -> test) | a callback which receives the previous trace (e.g. before reverting a race condition) and current trace |
| -> Property |
Execute a simulation, discover & revert races. Note that this will execute
the simulation multiple times with different schedules, and thus it's much
more costly than a simple runSimTrace (also the simulation environments has
much more state to track and hence it is slower).
On property failure it will show the failing schedule (ScheduleControl)
which can be passed to controlSimTrace to reproduce the failure without
discovering the schedule.
Arguments
| :: Maybe Int | limit on the computation time allowed per scheduling step, for catching infinite loops etc. |
| -> ScheduleControl | a schedule to replay note: must be either |
| -> (forall s. IOSim s a) | a simulation to run |
| -> SimTrace a |
Run a simulation using a given schedule. This is useful to reproduce failing cases without exploring the races.
data ScheduleMod Source #
A schedule modification inserted at given execution step.
Constructors
| ScheduleMod | |
Fields
| |
Instances
| Show ScheduleMod Source # | |
Defined in Control.Monad.IOSimPOR.Types Methods showsPrec :: Int -> ScheduleMod -> ShowS # show :: ScheduleMod -> String # showList :: [ScheduleMod] -> ShowS # | |
| Eq ScheduleMod Source # | |
Defined in Control.Monad.IOSimPOR.Types | |
| Ord ScheduleMod Source # | |
Defined in Control.Monad.IOSimPOR.Types Methods compare :: ScheduleMod -> ScheduleMod -> Ordering # (<) :: ScheduleMod -> ScheduleMod -> Bool # (<=) :: ScheduleMod -> ScheduleMod -> Bool # (>) :: ScheduleMod -> ScheduleMod -> Bool # (>=) :: ScheduleMod -> ScheduleMod -> Bool # max :: ScheduleMod -> ScheduleMod -> ScheduleMod # min :: ScheduleMod -> ScheduleMod -> ScheduleMod # | |
data ScheduleControl Source #
Modified execution schedule.
Constructors
| 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
| Show ScheduleControl Source # | |
Defined in Control.Monad.IOSimPOR.Types Methods showsPrec :: Int -> ScheduleControl -> ShowS # show :: ScheduleControl -> String # showList :: [ScheduleControl] -> ShowS # | |
| Eq ScheduleControl Source # | |
Defined in Control.Monad.IOSimPOR.Types Methods (==) :: ScheduleControl -> ScheduleControl -> Bool # (/=) :: ScheduleControl -> ScheduleControl -> Bool # | |
| Ord ScheduleControl Source # | |
Defined in Control.Monad.IOSimPOR.Types Methods compare :: ScheduleControl -> ScheduleControl -> Ordering # (<) :: ScheduleControl -> ScheduleControl -> Bool # (<=) :: ScheduleControl -> ScheduleControl -> Bool # (>) :: ScheduleControl -> ScheduleControl -> Bool # (>=) :: ScheduleControl -> ScheduleControl -> Bool # max :: ScheduleControl -> ScheduleControl -> ScheduleControl # min :: ScheduleControl -> ScheduleControl -> ScheduleControl # | |
Exploration options
data ExplorationOptions Source #
Race exploration options.
Constructors
| ExplorationOptions | |
Fields
| |
Instances
| Show ExplorationOptions Source # | |
Defined in Control.Monad.IOSim.Types Methods showsPrec :: Int -> ExplorationOptions -> ShowS # show :: ExplorationOptions -> String # showList :: [ExplorationOptions] -> ShowS # | |
withBranching :: Int -> ExplorationSpec Source #
Lift ST computations
Simulation time
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.
Simulation trace
type SimTrace a = Trace (SimResult a) SimEvent Source #
A type alias for IOSim simulation trace. It comes with useful pattern
synonyms.
Instances
| NFData Time # | |||||
Defined in Control.Monad.Class.MonadTime.SI | |||||
| Generic Time # | |||||
Defined in Control.Monad.Class.MonadTime.SI Associated Types
| |||||
| Show Time # | |||||
| Eq Time # | |||||
| Ord Time # | |||||
| NoThunks Time # | |||||
| type Rep Time # | |||||
Defined in Control.Monad.Class.MonadTime.SI | |||||
A cons list with polymorphic nil.
Usually used with a being a non empty sum type.
Bundled Patterns
| pattern SimTrace :: Time -> IOSimThreadId -> Maybe ThreadLabel -> SimEventType -> SimTrace a -> SimTrace a | |
| pattern SimPORTrace :: Time -> IOSimThreadId -> Int -> Maybe ThreadLabel -> SimEventType -> SimTrace a -> SimTrace a | |
| pattern TraceDeadlock :: Time -> [Labelled IOSimThreadId] -> SimTrace a | |
| pattern TraceLoop :: SimTrace a | |
| pattern TraceMainReturn :: Time -> Labelled IOSimThreadId -> a -> [Labelled IOSimThreadId] -> SimTrace a | |
| pattern TraceMainException :: Time -> Labelled IOSimThreadId -> SomeException -> [Labelled IOSimThreadId] -> SimTrace a | |
| pattern TraceRacesFound :: [ScheduleControl] -> SimTrace a -> SimTrace a | |
| pattern TraceInternalError :: String -> SimTrace a |
Instances
| Bifoldable Trace Source # | |
| Bifunctor Trace Source # | |
| Bitraversable Trace Source # | |
Defined in Data.List.Trace Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Trace a b -> f (Trace c d) # | |
| 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 => Applicative (Trace a) Source # | |
| Functor (Trace a) Source # | |
| Monoid a => Monad (Trace a) Source # | |
| Monoid a => MonadPlus (Trace a) Source # | |
| Monoid a => MonadFail (Trace a) Source # | |
Defined in Data.List.Trace | |
| Monoid a => MonadFix (Trace a) Source # | |
Defined in Data.List.Trace | |
| Monoid a => Monoid (Trace a b) Source # | |
| Semigroup a => Semigroup (Trace a b) Source # | |
| (Show b, Show a) => Show (Trace a b) Source # | |
| (Eq b, Eq a) => Eq (Trace a b) Source # | |
| (Ord b, Ord a) => Ord (Trace a b) Source # | |
traceEvents :: SimTrace a -> [(Time, IOSimThreadId, Maybe ThreadLabel, SimEventType)] Source #
Turn SimTrace into a list of timestamped events.
Arguments
| :: Bool | if True the simulation will fail if there are any threads which didn't terminated when the main thread terminated. |
| -> SimTrace a | simulation trace |
| -> Either Failure a |
Fold through the trace and return either Failure or a simulation
result, i.e. the return value of the main thread.
A result type of a simulation.
Constructors
| MainReturn !Time !(Labelled IOSimThreadId) a ![Labelled IOSimThreadId] | Return value of the main thread. |
| MainException !Time !(Labelled IOSimThreadId) SomeException ![Labelled IOSimThreadId] | Exception thrown by the main thread. |
| Deadlock !Time ![Labelled IOSimThreadId] | Deadlock discovered in the simulation. Deadlocks are discovered if simply the simulation cannot do any progress in a given time slot and there's no event which would advance the time. |
| Loop | Only returned by IOSimPOR when a step execution took longer than
|
| InternalError String | An |
Trace is a recursive data type, it is the trace of a IOSim
computation. The trace will contain information about thread scheduling,
blocking on TVars, 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 discovered races.
See also: traceEvents,
traceResult, selectTraceEvents,
selectTraceEventsDynamic and
printTraceEventsSay.
Constructors
| SimEvent | Used when using |
Fields
| |
| SimPOREvent | Only used for IOSimPOR |
Fields
| |
| SimRacesFound [ScheduleControl] | Only used for IOSimPOR |
Instances
data SimEventType Source #
Events recorded by the simulation.
Constructors
| EventSay String | holds value of |
| EventSayEvaluationError SomeException | holds error resulted from evaluation of the expression passed to |
| EventLog Dynamic | holds a dynamic value of |
| EventLogEvaluationError SomeException | holds error resulted from evaluation of the expression passed to |
| EventMask MaskingState | masking state changed |
| EventThrow SomeException | throw exception |
| EventThrowTo SomeException IOSimThreadId | throw asynchronous exception ( |
| EventThrowToBlocked | the thread which executed |
| EventThrowToWakeup | the thread which executed |
| EventThrowToUnmasked (Labelled IOSimThreadId) | a target thread of |
| EventEvaluationError SomeException | |
| EventEvaluationSuccess | |
| EventThreadForked IOSimThreadId | forked a thread |
| EventThreadFinished | thread terminated normally |
| EventThreadUnhandled SomeException | thread terminated by an unhandled exception |
| EventUniqueCreated Integer | created the n-th |
| EventTxCommitted | committed STM transaction |
| EventTxAborted (Maybe Effect) | |
| EventTxBlocked | STM transaction blocked (due to |
| EventTxWakeup [Labelled TVarId] | changed vars causing retry |
| EventUnblocked [IOSimThreadId] | unblocked threads by a committed STM transaction |
| EventThreadDelay TimeoutId Time | thread delayed |
| EventThreadDelayFired TimeoutId | thread woken up after a delay |
| EventTimeoutCreated TimeoutId IOSimThreadId Time | new timeout created (via |
| EventTimeoutFired TimeoutId | timeout fired |
| EventRegisterDelayCreated TimeoutId TVarId Time | registered delay (via |
| EventRegisterDelayFired TimeoutId | registered delay fired |
| EventTimerCreated TimeoutId TVarId Time | a new |
| EventTimerCancelled TimeoutId | a |
| EventTimerFired TimeoutId | a |
| EventThreadStatus | event traced when |
Fields
| |
| EventSimStart ScheduleControl | IOSimPOR event: new execution started exploring the given schedule. |
| EventThreadSleep | IOSimPOR event: the labelling thread was runnable, but its execution
was delayed, until Event inserted to mark a difference between a failed trace and a similar passing trace. |
| EventThreadWake | IOSimPOR event: marks when the thread was rescheduled by IOSimPOR |
| EventDeschedule Deschedule | IOSim and IOSimPOR event: a thread was descheduled |
| EventFollowControl ScheduleControl | IOSimPOR event: following given schedule |
| EventAwaitControl StepId ScheduleControl | IOSimPOR event: thread delayed to follow the given schedule |
| EventPerformAction StepId | IOSimPOR event: perform action of the given step |
| EventReschedule ScheduleControl | IOSimPOR event: reschedule a thread following the given
|
| EventEffect VectorClock Effect | IOSimPOR event: executed effect; Useful for debugging IOSimPOR or showing compact information about thread execution. |
| EventRaces Races | IOSimPOR event: races. Races are updated while we execute a simulation. Useful for debugging IOSimPOR. |
Instances
| Show SimEventType Source # | |
Defined in Control.Monad.IOSim.Types Methods showsPrec :: Int -> SimEventType -> ShowS # show :: SimEventType -> String # showList :: [SimEventType] -> ShowS # | |
type ThreadLabel = String Source #
data IOSimThreadId Source #
A thread id.
IOSimPOR: RacyThreadId indicates that this thread is taken into account
when discovering races. A thread is marked as racy iff
exploreRaces was
executed in it or it's a thread forked by a racy thread.
Constructors
| RacyThreadId [Int] | A racy thread ( |
| ThreadId [Int] | A non racy thread. They have higher priority than racy threads in
|
Instances
| NFData IOSimThreadId Source # | |||||
Defined in Control.Monad.IOSim.CommonTypes Methods rnf :: IOSimThreadId -> () # | |||||
| Generic IOSimThreadId Source # | |||||
Defined in Control.Monad.IOSim.CommonTypes Associated Types
| |||||
| Show IOSimThreadId Source # | |||||
Defined in Control.Monad.IOSim.CommonTypes Methods showsPrec :: Int -> IOSimThreadId -> ShowS # show :: IOSimThreadId -> String # showList :: [IOSimThreadId] -> ShowS # | |||||
| Eq IOSimThreadId Source # | |||||
Defined in Control.Monad.IOSim.CommonTypes Methods (==) :: IOSimThreadId -> IOSimThreadId -> Bool # (/=) :: IOSimThreadId -> IOSimThreadId -> Bool # | |||||
| Ord IOSimThreadId Source # | |||||
Defined in Control.Monad.IOSim.CommonTypes Methods compare :: IOSimThreadId -> IOSimThreadId -> Ordering # (<) :: IOSimThreadId -> IOSimThreadId -> Bool # (<=) :: IOSimThreadId -> IOSimThreadId -> Bool # (>) :: IOSimThreadId -> IOSimThreadId -> Bool # (>=) :: IOSimThreadId -> IOSimThreadId -> Bool # max :: IOSimThreadId -> IOSimThreadId -> IOSimThreadId # min :: IOSimThreadId -> IOSimThreadId -> IOSimThreadId # | |||||
| Hashable IOSimThreadId Source # | |||||
Defined in Control.Monad.IOSim.CommonTypes | |||||
| NoThunks IOSimThreadId Source # | |||||
Defined in Control.Monad.IOSim.CommonTypes Methods noThunks :: Context -> IOSimThreadId -> IO (Maybe ThunkInfo) wNoThunks :: Context -> IOSimThreadId -> IO (Maybe ThunkInfo) showTypeOf :: Proxy IOSimThreadId -> String | |||||
| type Rep IOSimThreadId Source # | |||||
Defined in Control.Monad.IOSim.CommonTypes type Rep IOSimThreadId = D1 ('MetaData "IOSimThreadId" "Control.Monad.IOSim.CommonTypes" "io-sim-1.10.0.0-inplace" 'False) (C1 ('MetaCons "RacyThreadId" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Int])) :+: C1 ('MetaCons "ThreadId" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Int]))) | |||||
A labelled value.
For example labelThread or labelTVar will insert a label to IOSimThreadId
(or TVarId).
Constructors
| Labelled | |
Fields
| |
Instances
| Functor Labelled Source # | |||||
| Generic (Labelled a) Source # | |||||
Defined in Control.Monad.IOSim.CommonTypes Associated Types
| |||||
| Show a => Show (Labelled a) Source # | |||||
| Eq a => Eq (Labelled a) Source # | |||||
| Ord a => Ord (Labelled a) Source # | |||||
Defined in Control.Monad.IOSim.CommonTypes | |||||
| type Rep (Labelled a) Source # | |||||
Defined in Control.Monad.IOSim.CommonTypes type Rep (Labelled a) = D1 ('MetaData "Labelled" "Control.Monad.IOSim.CommonTypes" "io-sim-1.10.0.0-inplace" '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)))) | |||||
Abstract unique symbols à la Data.Unique.
Dynamic Tracing
traceM :: Typeable a => a -> IOSim s () Source #
IOSim has the ability to store any Typeable value in its trace which
can then be recovered with selectTraceEventsDynamic or
selectTraceEventsDynamic'.
Note: traceM evaluates the a to WHNF, exceptions are thrown by the
current thread and the trace will include EventLogEvaluationError.
Pretty printers
ppTrace :: Show a => SimTrace a -> String Source #
Pretty print simulation trace.
Note: this is not a streaming function, it will evaluate the whole trace before printing it. If you need to print a very large trace, you might want to use
ppTraceshow (ppSimEvent0 0 0)
ppEvents :: [(Time, IOSimThreadId, Maybe ThreadLabel, SimEventType)] -> String Source #
Pretty print a timestamped event.
Arguments
| :: Int | width of the time |
| -> Int | width of thread id |
| -> Int | width of thread label |
| -> SimEvent | |
| -> String |
Pretty print a SimEvent.
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.
Selectors
list selectors
selectTraceEvents :: (Time -> SimEventType -> Maybe b) -> SimTrace a -> [b] Source #
Select events according to the predicate function. It throws an error if
the simulation ends with Failure.
selectTraceEvents' :: (Time -> SimEventType -> Maybe b) -> Trace a SimEvent -> [b] Source #
Like selectTraceEvents, but it returns even if the simulation trace ends
with Failure. It also works with any return type, not only SimResult
like selectTraceEvents does.
selectTraceEventsDynamic :: forall a b. Typeable b => SimTrace a -> [b] Source #
Select all the traced values matching the expected type. It relies on the sim's dynamic trace facility.
For convenience, it throws exceptions for abnormal sim termination.
selectTraceEventsDynamicWithTime :: forall a b. Typeable b => SimTrace a -> [(Time, b)] Source #
Like selectTraceEventsDynamic but it also captures time of the trace
event.
selectTraceEventsDynamic' :: forall a b. Typeable b => Trace a SimEvent -> [b] Source #
Like selectTraceEventsDynamic but it returns even if the simulation
trace ends with Failure. It also works with any return type, not only
SimResult like selectTraceEventsDynamic does.
selectTraceEventsDynamicWithTime' :: forall a b. Typeable b => Trace a SimEvent -> [(Time, b)] Source #
Like selectTraceEventsDynamicWithTime' but it also captures time of the
trace event. It also works with any return type, not only SimResult like
selectTraceEventsDynamicWithTime does.
selectTraceEventsSay :: SimTrace a -> [String] Source #
Get a trace of EventSay.
For convenience, it throws exceptions for abnormal sim termination.
selectTraceEventsSayWithTime :: SimTrace a -> [(Time, String)] Source #
Like selectTraceEventsSay but it also captures time of the trace event.
selectTraceEventsSay' :: Trace a SimEvent -> [String] Source #
Like selectTraceEventsSay but it returns even if the simulation trace
ends with Failure. It also works with any return type, not only SimResult
like selectTraceEventsSay does.
selectTraceEventsSayWithTime' :: Trace a SimEvent -> [(Time, String)] Source #
Like selectTraceEventsSay' but it also captures time of the trace event.
selectTraceRaces :: SimTrace a -> [ScheduleControl] Source #
trace selectors
traceSelectTraceEvents :: (Time -> SimEventType -> Maybe b) -> Trace a SimEvent -> Trace a b Source #
The most general select function. It is a total function.
traceSelectTraceEventsDynamic :: forall a b. Typeable b => Trace a SimEvent -> Trace a b Source #
Select dynamic events. It is a total function.
traceSelectTraceEventsSay :: Trace a SimEvent -> Trace a String Source #
Select say events. It is a total function.
IO printer
printTraceEventsSay :: SimTrace a -> IO () Source #
Print all EventSay to the console.
For convenience, it throws exceptions for abnormal sim termination.
Eventlog
newtype EventlogEvent Source #
Wrapper for Eventlog events so they can be retrieved from the trace with
selectTraceEventsDynamic.
Constructors
| EventlogEvent String |
newtype EventlogMarker Source #
Wrapper for Eventlog markers so they can be retrieved from the trace with
selectTraceEventsDynamic.
Constructors
| EventlogMarker String |
Low-level API
readTimeout :: Timeout s -> STM s TimeoutState Source #
cancelTimeout :: Timeout s -> IOSim s () Source #
awaitTimeout :: Timeout s -> STM s Bool Source #