{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

-- | Tests for the computation of blockchain time.
--
-- The @BlockchainTime@ in consensus used to be ubiquitous throughout the code
-- base, but is now only used in one place: when we are checking if we should
-- produce a block. It is a simple abstraction that returns the current slot
-- number, /if it is known/ (it might be unknown of the current ledger state is
-- too far behind the wallclock). In addition to the problem of the current slot
-- being unknown, it must also deal with discontinuities in the system's
-- wallclock: NTP might adjust the clock forward or backward, or, worse, the
-- user might change their wallclock by a large amount. We don't try to deal
-- with all of these cases:
--
-- * if the clock jumps forward (so we "skip slots") this is no problem
-- * if the clock is moved back a small amount so that we are still in the same
--   slot when we expected to be in the next, also okay
-- * if the clock is moved back by more than that, so that the current slot
--   would actually /decrease/, we throw an exception; it's then up to the user
--   (or the wallet) to restart the node.
--
-- Since all our tests run in an IO simulator, we can test this by having the
-- clock behave very erratically. We then compute (in a model) what we expect
-- the behaviour of the @BlockchainTime@ to be given a specific erratic
-- behaviour, and then verify that it matches the model.
--
module Test.Consensus.BlockchainTime.Simple (tests) where

import           Control.Applicative (Alternative (..))
import qualified Control.Concurrent.Class.MonadMVar.Strict as Strict
import qualified Control.Concurrent.Class.MonadSTM.Strict as Strict
import           Control.Monad (MonadPlus, when)
import qualified Control.Monad.Class.MonadSTM.Internal as LazySTM
import           Control.Monad.Class.MonadTime
import qualified Control.Monad.Class.MonadTimer as MonadTimer
import           Control.Monad.Class.MonadTimer.SI
import           Control.Monad.Except (Except, runExcept, throwError)
import           Control.Monad.IOSim
import           Control.Monad.Reader (ReaderT (..), lift)
import           Control.ResourceRegistry
import           Control.Tracer
import           Data.Fixed
import qualified Data.Time.Clock as Time
import           NoThunks.Class (AllowThunk (..))
import           Ouroboros.Consensus.Block
import           Ouroboros.Consensus.BlockchainTime
import           Ouroboros.Consensus.Util.IOLike
import           Ouroboros.Consensus.Util.STM (withWatcher)
import           Ouroboros.Consensus.Util.Time
import           Test.QuickCheck hiding (Fixed)
import           Test.Tasty hiding (after)
import           Test.Tasty.QuickCheck hiding (Fixed)
import           Test.Util.Orphans.Arbitrary (genNominalDiffTime50Years)
import           Test.Util.Orphans.IOLike ()
import           Test.Util.Range
import           Test.Util.TestEnv (adjustQuickCheckTests)
import           Test.Util.Time

tests :: TestTree
tests :: TestTree
tests = TestName -> [TestTree] -> TestTree
testGroup TestName
"WallClock" [
      (Int -> Int) -> TestTree -> TestTree
adjustQuickCheckTests (Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
10) (TestTree -> TestTree) -> TestTree -> TestTree
forall a b. (a -> b) -> a -> b
$ TestName -> (TestDelayIO -> Property) -> TestTree
forall a. Testable a => TestName -> a -> TestTree
testProperty TestName
"delayNextSlot" TestDelayIO -> Property
prop_delayNextSlot
    , TestName -> (Schedule -> Property) -> TestTree
forall a. Testable a => TestName -> a -> TestTree
testProperty TestName
"delayClockShift"   Schedule -> Property
prop_delayClockShift
    , (Int -> Int) -> TestTree -> TestTree
adjustQuickCheckTests (Int -> Int -> Int
forall a b. a -> b -> a
const Int
1)  (TestTree -> TestTree) -> TestTree -> TestTree
forall a b. (a -> b) -> a -> b
$ TestName -> Property -> TestTree
forall a. Testable a => TestName -> a -> TestTree
testProperty TestName
"delayNoClockShift" Property
prop_delayNoClockShift
    ]

{-------------------------------------------------------------------------------
  Test for IO
-------------------------------------------------------------------------------}

-- | Parameters for testing 'timeUntilNextSlot' in some actual IO code
data TestDelayIO = TestDelayIO {
      -- | System start
      --
      -- Since we don't actually " start " the system in any way, we specify
      -- this as an offset _before_ the start of the test.
      TestDelayIO -> NominalDiffTime
tdioStart'  :: Time.NominalDiffTime

      -- | SlotNo length
      --
      -- Since this test is run in IO, we will keep the slot length short.
    , TestDelayIO -> SlotLength
tdioSlotLen :: SlotLength
    }
  deriving (Int -> TestDelayIO -> ShowS
[TestDelayIO] -> ShowS
TestDelayIO -> TestName
(Int -> TestDelayIO -> ShowS)
-> (TestDelayIO -> TestName)
-> ([TestDelayIO] -> ShowS)
-> Show TestDelayIO
forall a.
(Int -> a -> ShowS) -> (a -> TestName) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TestDelayIO -> ShowS
showsPrec :: Int -> TestDelayIO -> ShowS
$cshow :: TestDelayIO -> TestName
show :: TestDelayIO -> TestName
$cshowList :: [TestDelayIO] -> ShowS
showList :: [TestDelayIO] -> ShowS
Show)

instance Arbitrary TestDelayIO where
  arbitrary :: Gen TestDelayIO
arbitrary = do
      NominalDiffTime
tdioStart'  <- Gen NominalDiffTime
genNominalDiffTime50Years
      SlotLength
tdioSlotLen <- Integer -> SlotLength
slotLengthFromMillisec (Integer -> SlotLength) -> Gen Integer -> Gen SlotLength
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Integer, Integer) -> Gen Integer
forall a. Random a => (a, a) -> Gen a
choose (Integer
100, Integer
1_000)
      TestDelayIO -> Gen TestDelayIO
forall a. a -> Gen a
forall (m :: * -> *) a. Monad m => a -> m a
return TestDelayIO{SlotLength
NominalDiffTime
tdioStart' :: NominalDiffTime
tdioSlotLen :: SlotLength
tdioStart' :: NominalDiffTime
tdioSlotLen :: SlotLength
..}

-- | Just as a sanity check, also run the tests in IO
--
-- We override the maximum number of tests since there are slow.
--
-- NOTE: If the system is under very heavy load, this test /could/ fail:
-- the slot number after the delay could be later than the one we expect.
-- We don't relax the test because this is highly unlikely, and the stronger
-- test gives us a more useful property. Also see issue #3894.
prop_delayNextSlot :: TestDelayIO -> Property
prop_delayNextSlot :: TestDelayIO -> Property
prop_delayNextSlot TestDelayIO{SlotLength
NominalDiffTime
tdioStart' :: TestDelayIO -> NominalDiffTime
tdioSlotLen :: TestDelayIO -> SlotLength
tdioStart' :: NominalDiffTime
tdioSlotLen :: SlotLength
..} =
    IO Property -> Property
forall prop. Testable prop => IO prop -> Property
ioProperty IO Property
test
  where
    test :: IO Property
    test :: IO Property
test = do
        SystemStart
tdioStart  <- IO SystemStart
pickSystemStart
        let time :: SystemTime IO
time = SystemStart
-> Tracer IO (TraceBlockchainTimeEvent UTCTime) -> SystemTime IO
forall (m :: * -> *).
(MonadTime m, MonadDelay m) =>
SystemStart
-> Tracer m (TraceBlockchainTimeEvent UTCTime) -> SystemTime m
defaultSystemTime SystemStart
tdioStart Tracer IO (TraceBlockchainTimeEvent UTCTime)
forall (m :: * -> *) a. Applicative m => Tracer m a
nullTracer
        SlotNo
atStart    <- (SlotNo, NominalDiffTime) -> SlotNo
forall a b. (a, b) -> a
fst ((SlotNo, NominalDiffTime) -> SlotNo)
-> IO (SlotNo, NominalDiffTime) -> IO SlotNo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SystemTime IO -> SlotLength -> IO (SlotNo, NominalDiffTime)
forall (m :: * -> *).
IOLike m =>
SystemTime m -> SlotLength -> m (SlotNo, NominalDiffTime)
getWallClockSlot  SystemTime IO
time SlotLength
tdioSlotLen
        SlotNo
nextSlot   <-         SystemTime IO
-> SlotLength -> NominalDiffTime -> SlotNo -> IO SlotNo
forall (m :: * -> *).
IOLike m =>
SystemTime m -> SlotLength -> NominalDiffTime -> SlotNo -> m SlotNo
waitUntilNextSlot SystemTime IO
time SlotLength
tdioSlotLen NominalDiffTime
maxClockRewind SlotNo
atStart
        SlotNo
afterDelay <- (SlotNo, NominalDiffTime) -> SlotNo
forall a b. (a, b) -> a
fst ((SlotNo, NominalDiffTime) -> SlotNo)
-> IO (SlotNo, NominalDiffTime) -> IO SlotNo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SystemTime IO -> SlotLength -> IO (SlotNo, NominalDiffTime)
forall (m :: * -> *).
IOLike m =>
SystemTime m -> SlotLength -> m (SlotNo, NominalDiffTime)
getWallClockSlot  SystemTime IO
time SlotLength
tdioSlotLen
        -- Ensure the test can't hang forever, fail after two minutes instead
        Property -> IO Property
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Property -> IO Property) -> Property -> IO Property
forall a b. (a -> b) -> a -> b
$ Int -> Property -> Property
forall prop. Testable prop => Int -> prop -> Property
within Int
120_000_000 (Property -> Property) -> Property -> Property
forall a b. (a -> b) -> a -> b
$ [Property] -> Property
forall prop. Testable prop => [prop] -> Property
conjoin
          [ TestName -> Property -> Property
forall prop. Testable prop => TestName -> prop -> Property
counterexample TestName
"atStart + 1" (Property -> Property) -> Property -> Property
forall a b. (a -> b) -> a -> b
$ SlotNo
atStart SlotNo -> SlotNo -> SlotNo
forall a. Num a => a -> a -> a
+ SlotNo
1 SlotNo -> SlotNo -> Property
forall a. (Eq a, Show a) => a -> a -> Property
=== SlotNo
afterDelay
          , TestName -> Property -> Property
forall prop. Testable prop => TestName -> prop -> Property
counterexample TestName
"nextSlot"    (Property -> Property) -> Property -> Property
forall a b. (a -> b) -> a -> b
$ SlotNo
nextSlot    SlotNo -> SlotNo -> Property
forall a. (Eq a, Show a) => a -> a -> Property
=== SlotNo
afterDelay
          ]

    pickSystemStart :: IO SystemStart
    pickSystemStart :: IO SystemStart
pickSystemStart = UTCTime -> SystemStart
pick (UTCTime -> SystemStart) -> IO UTCTime -> IO SystemStart
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO UTCTime
forall (m :: * -> *). MonadTime m => m UTCTime
getCurrentTime
      where
        pick :: UTCTime -> SystemStart
        pick :: UTCTime -> SystemStart
pick = UTCTime -> SystemStart
SystemStart (UTCTime -> SystemStart)
-> (UTCTime -> UTCTime) -> UTCTime -> SystemStart
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NominalDiffTime -> UTCTime -> UTCTime
Time.addUTCTime (NominalDiffTime -> NominalDiffTime
forall a. Num a => a -> a
negate NominalDiffTime
tdioStart')

    -- Will only be needed when the system clock rolls back during the execution
    -- of this test, which is rather unlikely.
    maxClockRewind :: NominalDiffTime
    maxClockRewind :: NominalDiffTime
maxClockRewind = Double -> NominalDiffTime
secondsToNominalDiffTime Double
20

{-------------------------------------------------------------------------------
  Test delay using mock time
-------------------------------------------------------------------------------}

-- | Schedule defines the system time as offsets (in seconds) from the start
--
-- We limit the resolution of the offsets to 0.1 seconds to make the tests
-- easier to interpret and shrink (slot length is set to 1 seconds). We allow
-- the clock to go back at most 2 seconds.
newtype Schedule = Schedule { Schedule -> [Fixed E1]
getSchedule :: [Fixed E1] }
  deriving stock (Int -> Schedule -> ShowS
[Schedule] -> ShowS
Schedule -> TestName
(Int -> Schedule -> ShowS)
-> (Schedule -> TestName) -> ([Schedule] -> ShowS) -> Show Schedule
forall a.
(Int -> a -> ShowS) -> (a -> TestName) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Schedule -> ShowS
showsPrec :: Int -> Schedule -> ShowS
$cshow :: Schedule -> TestName
show :: Schedule -> TestName
$cshowList :: [Schedule] -> ShowS
showList :: [Schedule] -> ShowS
Show)
  deriving Context -> Schedule -> IO (Maybe ThunkInfo)
Proxy Schedule -> TestName
(Context -> Schedule -> IO (Maybe ThunkInfo))
-> (Context -> Schedule -> IO (Maybe ThunkInfo))
-> (Proxy Schedule -> TestName)
-> NoThunks Schedule
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> TestName)
-> NoThunks a
$cnoThunks :: Context -> Schedule -> IO (Maybe ThunkInfo)
noThunks :: Context -> Schedule -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> Schedule -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> Schedule -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy Schedule -> TestName
showTypeOf :: Proxy Schedule -> TestName
NoThunks via AllowThunk Schedule

-- | Translate an offset in the schedule to a slot
--
-- Assumes slot length is 1.
offsetToSlot :: Fixed E1 -> SlotNo
offsetToSlot :: Fixed E1 -> SlotNo
offsetToSlot = Word64 -> SlotNo
SlotNo (Word64 -> SlotNo) -> (Fixed E1 -> Word64) -> Fixed E1 -> SlotNo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fixed E1 -> Word64
forall b. Integral b => Fixed E1 -> b
forall a b. (RealFrac a, Integral b) => a -> b
floor

-- | Does a schedule ever go back?
--
-- Used for labelling.
scheduleGoesBack :: Schedule -> Bool
scheduleGoesBack :: Schedule -> Bool
scheduleGoesBack (Schedule [])     = Bool
False
scheduleGoesBack (Schedule (Fixed E1
t:[Fixed E1]
ts)) = Fixed E1 -> [Fixed E1] -> Bool
forall a. Ord a => a -> [a] -> Bool
go Fixed E1
t [Fixed E1]
ts
  where
    go :: Ord a => a -> [a] -> Bool
    go :: forall a. Ord a => a -> [a] -> Bool
go a
_ []     = Bool
False
    go a
x (a
y:[a]
ys) = a
y a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
x Bool -> Bool -> Bool
|| a -> [a] -> Bool
forall a. Ord a => a -> [a] -> Bool
go a
y [a]
ys

-- | How often do two subsequent time entries fall into the same slot?
--
-- Used for labelling.
scheduleCountSkips :: Schedule -> Int
scheduleCountSkips :: Schedule -> Int
scheduleCountSkips (Schedule [])     = Int
0
scheduleCountSkips (Schedule (Fixed E1
t:[Fixed E1]
ts)) = Fixed E1 -> [Fixed E1] -> Int
go Fixed E1
t [Fixed E1]
ts
  where
    go :: Fixed E1 -> [Fixed E1] -> Int
    go :: Fixed E1 -> [Fixed E1] -> Int
go Fixed E1
_ []     = Int
0
    go Fixed E1
x (Fixed E1
y:[Fixed E1]
ys) = (if Fixed E1 -> SlotNo
offsetToSlot Fixed E1
x SlotNo -> SlotNo -> Bool
forall a. Eq a => a -> a -> Bool
== Fixed E1 -> SlotNo
offsetToSlot Fixed E1
y then Int
1 else Int
0) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Fixed E1 -> [Fixed E1] -> Int
go Fixed E1
y [Fixed E1]
ys

-- | Predict the outcome of a given schedule
--
-- Returns the set of slot numbers that 'BlockchainTime' should report or,
-- if time moved backwards, the @(before, after)@ slot pair where @after@ is
-- more than the @maxClockRewind@ less than @before@.
--
-- NOTE: Assumes the slot length is 1 and max clock rewind is 2 for these sets.
model :: Int -> Schedule -> Either (SlotNo, SlotNo) [SlotNo]
model :: Int -> Schedule -> Either (SlotNo, SlotNo) [SlotNo]
model = \Int
need (Schedule [Fixed E1]
ss) ->
    -- Establish the invariant that the 'Schedule' is never empty
    let ss' :: [Fixed E1]
ss' = case [Fixed E1]
ss of
          [] -> [Fixed E1
0.0]
          [Fixed E1]
_  -> [Fixed E1]
ss
    in Except (SlotNo, SlotNo) [SlotNo]
-> Either (SlotNo, SlotNo) [SlotNo]
forall e a. Except e a -> Either e a
runExcept (Except (SlotNo, SlotNo) [SlotNo]
 -> Either (SlotNo, SlotNo) [SlotNo])
-> Except (SlotNo, SlotNo) [SlotNo]
-> Either (SlotNo, SlotNo) [SlotNo]
forall a b. (a -> b) -> a -> b
$
      (Word64 -> SlotNo
SlotNo Word64
0 SlotNo -> [SlotNo] -> [SlotNo]
forall a. a -> [a] -> [a]
:) ([SlotNo] -> [SlotNo])
-> Except (SlotNo, SlotNo) [SlotNo]
-> Except (SlotNo, SlotNo) [SlotNo]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int
-> Schedule
-> (Fixed E1, SlotNo)
-> Except (SlotNo, SlotNo) [SlotNo]
go (Int
need Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) ([Fixed E1] -> Schedule
Schedule [Fixed E1]
ss') (Fixed E1
0.0, Word64 -> SlotNo
SlotNo Word64
0)
  where
    -- | This let's us treat the schedule as an infinite stream of offsets.
    --
    -- INVARIANT: 'Schedule' is never empty
    --
    -- When there is no offset after the current one in the schedule, create
    -- one, exactly one slot length after the current one.
    advanceSchedule :: Schedule -> (Fixed E1, Schedule)
    advanceSchedule :: Schedule -> (Fixed E1, Schedule)
advanceSchedule (Schedule [Fixed E1]
ss) =
        case [Fixed E1]
ss of
          []    -> TestName -> (Fixed E1, Schedule)
forall a. HasCallStack => TestName -> a
error TestName
"invariant broken: empty schedule"
          [Fixed E1
s]   -> (Fixed E1
s,   [Fixed E1] -> Schedule
Schedule [Fixed E1
s Fixed E1 -> Fixed E1 -> Fixed E1
forall a. Num a => a -> a -> a
+ Fixed E1
1.0])
          Fixed E1
s:[Fixed E1]
ss' -> (Fixed E1
s,   [Fixed E1] -> Schedule
Schedule [Fixed E1]
ss')

    go ::
         Int
      -> Schedule
      -> (Fixed E1, SlotNo)
      -> Except (SlotNo, SlotNo) [SlotNo]
    go :: Int
-> Schedule
-> (Fixed E1, SlotNo)
-> Except (SlotNo, SlotNo) [SlotNo]
go Int
n Schedule
ss (Fixed E1
prevOffset, SlotNo
prevSlot)
        | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0
        = [SlotNo] -> Except (SlotNo, SlotNo) [SlotNo]
forall a. a -> ExceptT (SlotNo, SlotNo) Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return []
        | SlotNo
nextSlot SlotNo -> SlotNo -> Bool
forall a. Eq a => a -> a -> Bool
== SlotNo
prevSlot
        = Int
-> Schedule
-> (Fixed E1, SlotNo)
-> Except (SlotNo, SlotNo) [SlotNo]
go Int
n Schedule
ss' (Fixed E1
offset, SlotNo
nextSlot)
        | SlotNo
nextSlot SlotNo -> SlotNo -> Bool
forall a. Ord a => a -> a -> Bool
>  SlotNo
prevSlot
        = (SlotNo
nextSlot SlotNo -> [SlotNo] -> [SlotNo]
forall a. a -> [a] -> [a]
:) ([SlotNo] -> [SlotNo])
-> Except (SlotNo, SlotNo) [SlotNo]
-> Except (SlotNo, SlotNo) [SlotNo]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int
-> Schedule
-> (Fixed E1, SlotNo)
-> Except (SlotNo, SlotNo) [SlotNo]
go (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) Schedule
ss' (Fixed E1
offset, SlotNo
nextSlot)
        -- If time moved back, but not more than 2s, we don't throw an exception
        | Fixed E1
prevOffset Fixed E1 -> Fixed E1 -> Fixed E1
forall a. Num a => a -> a -> a
- Fixed E1
offset Fixed E1 -> Fixed E1 -> Bool
forall a. Ord a => a -> a -> Bool
<= Fixed E1
2
        = Int
-> Schedule
-> (Fixed E1, SlotNo)
-> Except (SlotNo, SlotNo) [SlotNo]
go Int
n Schedule
ss' (Fixed E1
offset, SlotNo
prevSlot)
        -- If time moved back too much, we should see an exception
        | Bool
otherwise
        = (SlotNo, SlotNo) -> Except (SlotNo, SlotNo) [SlotNo]
forall a. (SlotNo, SlotNo) -> ExceptT (SlotNo, SlotNo) Identity a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (SlotNo
prevSlot, SlotNo
nextSlot)
      where
        (Fixed E1
offset, Schedule
ss') = Schedule -> (Fixed E1, Schedule)
advanceSchedule Schedule
ss
        nextSlot :: SlotNo
nextSlot      = Fixed E1 -> SlotNo
offsetToSlot Fixed E1
offset

instance Arbitrary Schedule where
  arbitrary :: Gen Schedule
arbitrary =
     -- We only collect 100 samples. Generate a few more, potentially, but also
     -- often generate fewer (which would give us the default behaviour).
      [Fixed E1] -> Schedule
Schedule ([Fixed E1] -> Schedule) -> Gen [Fixed E1] -> Gen Schedule
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Fixed E1 -> Int -> Gen [Fixed E1]
go Fixed E1
0 (Int -> Gen [Fixed E1]) -> Gen Int -> Gen [Fixed E1]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (Int, Int) -> Gen Int
forall a. Random a => (a, a) -> Gen a
choose (Int
0, Int
110))
    where
      go :: Fixed E1 -> Int -> Gen [Fixed E1]
      go :: Fixed E1 -> Int -> Gen [Fixed E1]
go Fixed E1
_   Int
0 = [Fixed E1] -> Gen [Fixed E1]
forall a. a -> Gen a
forall (m :: * -> *) a. Monad m => a -> m a
return []
      go Fixed E1
now Int
n = do
          Fixed E1
now' <- [(Int, Gen (Fixed E1))] -> Gen (Fixed E1)
forall a. HasCallStack => [(Int, Gen a)] -> Gen a
frequency [
              -- If time goes back too often, most runs end in an exception
              (Int
100, (\Integer
delta -> Fixed E1
now Fixed E1 -> Fixed E1 -> Fixed E1
forall a. Num a => a -> a -> a
+ Integer -> Fixed E1
fixedFromDeci Integer
delta) (Integer -> Fixed E1) -> Gen Integer -> Gen (Fixed E1)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Integer, Integer) -> Gen Integer
forall a. Random a => (a, a) -> Gen a
choose (Integer
0, Integer
30))

              -- Go back a bit without exceeding the max clock rewind
            , (Int
10, (\Integer
delta -> Fixed E1 -> Fixed E1 -> Fixed E1
forall a. Ord a => a -> a -> a
max Fixed E1
0 (Fixed E1
now Fixed E1 -> Fixed E1 -> Fixed E1
forall a. Num a => a -> a -> a
- Integer -> Fixed E1
fixedFromDeci Integer
delta)) (Integer -> Fixed E1) -> Gen Integer -> Gen (Fixed E1)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Integer, Integer) -> Gen Integer
forall a. Random a => (a, a) -> Gen a
choose (Integer
0, Integer
2))

              -- Occassionally just pick an entirely random time
            , (Int
1, Integer -> Fixed E1
fixedFromDeci (Integer -> Fixed E1) -> Gen Integer -> Gen (Fixed E1)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Integer, Integer) -> Gen Integer
forall a. Random a => (a, a) -> Gen a
choose (Integer
0, Integer
100))
            ]
          (Fixed E1
now'Fixed E1 -> [Fixed E1] -> [Fixed E1]
forall a. a -> [a] -> [a]
:) ([Fixed E1] -> [Fixed E1]) -> Gen [Fixed E1] -> Gen [Fixed E1]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Fixed E1 -> Int -> Gen [Fixed E1]
go Fixed E1
now' (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)

      fixedFromDeci :: Integer -> Fixed E1
      fixedFromDeci :: Integer -> Fixed E1
fixedFromDeci = Integer -> Fixed E1
forall k (a :: k). Integer -> Fixed a
MkFixed

  shrink :: Schedule -> [Schedule]
shrink (Schedule [Fixed E1]
s) = [Fixed E1] -> Schedule
Schedule ([Fixed E1] -> Schedule) -> [[Fixed E1]] -> [Schedule]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Fixed E1 -> [Fixed E1]) -> [Fixed E1] -> [[Fixed E1]]
forall a. (a -> [a]) -> [a] -> [[a]]
shrinkList Fixed E1 -> [Fixed E1]
shrinkOffset [Fixed E1]
s
    where
      shrinkOffset :: Fixed E1 -> [Fixed E1]
      shrinkOffset :: Fixed E1 -> [Fixed E1]
shrinkOffset (MkFixed Integer
o) = Integer -> Fixed E1
forall k (a :: k). Integer -> Fixed a
MkFixed (Integer -> Fixed E1) -> [Integer] -> [Fixed E1]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
o

prop_delayClockShift :: Schedule -> Property
prop_delayClockShift :: Schedule -> Property
prop_delayClockShift Schedule
schedule =
    TestName -> Context -> Property -> Property
forall prop.
Testable prop =>
TestName -> Context -> prop -> Property
tabulate TestName
"schedule length"    [Range Int -> TestName
forall a. Show a => a -> TestName
show (Range Int -> TestName) -> Range Int -> TestName
forall a b. (a -> b) -> a -> b
$ Int -> Range Int
forall n. (Ord n, Show n, Num n) => n -> Range n
range ([Fixed E1] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (Schedule -> [Fixed E1]
getSchedule Schedule
schedule))] (Property -> Property) -> Property -> Property
forall a b. (a -> b) -> a -> b
$
    TestName -> Context -> Property -> Property
forall prop.
Testable prop =>
TestName -> Context -> prop -> Property
tabulate TestName
"schedule goes back" [Bool -> TestName
forall a. Show a => a -> TestName
show (Bool -> TestName) -> Bool -> TestName
forall a b. (a -> b) -> a -> b
$ Schedule -> Bool
scheduleGoesBack Schedule
schedule]             (Property -> Property) -> Property -> Property
forall a b. (a -> b) -> a -> b
$
    TestName -> Context -> Property -> Property
forall prop.
Testable prop =>
TestName -> Context -> prop -> Property
tabulate TestName
"schedule skips"     [Range Int -> TestName
forall a. Show a => a -> TestName
show (Range Int -> TestName) -> Range Int -> TestName
forall a b. (a -> b) -> a -> b
$ Int -> Range Int
forall n. (Ord n, Show n, Num n) => n -> Range n
range (Schedule -> Int
scheduleCountSkips Schedule
schedule)]   (Property -> Property) -> Property -> Property
forall a b. (a -> b) -> a -> b
$
    case Int -> Schedule -> Either (SlotNo, SlotNo) [SlotNo]
model Int
numSlots Schedule
schedule of
      Left (SlotNo
before, SlotNo
after) ->
        case Either Failure [SlotNo]
testResult of
          Left (FailureException SomeException
e) ->
            SlotNo -> SlotNo -> SomeException -> Property
checkException SlotNo
before SlotNo
after SomeException
e
          Left Failure
e ->
            TestName -> Property -> Property
forall prop. Testable prop => TestName -> prop -> Property
counterexample (TestName
"Unexpected simulator failure " TestName -> ShowS
forall a. [a] -> [a] -> [a]
++ Failure -> TestName
forall a. Show a => a -> TestName
show Failure
e) (Property -> Property) -> Property -> Property
forall a b. (a -> b) -> a -> b
$
            Bool -> Property
forall prop. Testable prop => prop -> Property
property Bool
False
          Right [SlotNo]
slots' ->
            TestName -> Property -> Property
forall prop. Testable prop => TestName -> prop -> Property
counterexample (TestName
"Expected exception but got " TestName -> ShowS
forall a. [a] -> [a] -> [a]
++ [SlotNo] -> TestName
forall a. Show a => a -> TestName
show [SlotNo]
slots') (Property -> Property) -> Property -> Property
forall a b. (a -> b) -> a -> b
$
            Bool -> Property
forall prop. Testable prop => prop -> Property
property Bool
False

      Right [SlotNo]
slots ->
        case Either Failure [SlotNo]
testResult of
          Left Failure
e ->
            TestName -> Property -> Property
forall prop. Testable prop => TestName -> prop -> Property
counterexample (TestName
"Expected normal termination, but got " TestName -> ShowS
forall a. [a] -> [a] -> [a]
++ Failure -> TestName
forall a. Show a => a -> TestName
show Failure
e) (Property -> Property) -> Property -> Property
forall a b. (a -> b) -> a -> b
$
            Bool -> Property
forall prop. Testable prop => prop -> Property
property Bool
False
          Right [SlotNo]
slots' ->
            [SlotNo]
slots' [SlotNo] -> [SlotNo] -> Property
forall a. (Eq a, Show a) => a -> a -> Property
=== [SlotNo]
slots
  where
    numSlots :: Int
    numSlots :: Int
numSlots = Int
100

    testResult :: Either Failure [SlotNo]
    testResult :: Either Failure [SlotNo]
testResult = UTCTime
-> Schedule
-> (forall {s}. OverrideDelay (IOSim s) [SlotNo])
-> Either Failure [SlotNo]
forall a.
UTCTime
-> Schedule
-> (forall s. OverrideDelay (IOSim s) a)
-> Either Failure a
overrideDelay UTCTime
dawnOfTime Schedule
schedule ((forall {s}. OverrideDelay (IOSim s) [SlotNo])
 -> Either Failure [SlotNo])
-> (forall {s}. OverrideDelay (IOSim s) [SlotNo])
-> Either Failure [SlotNo]
forall a b. (a -> b) -> a -> b
$
        SystemStart
-> SlotLength
-> NominalDiffTime
-> Int
-> OverrideDelay (IOSim s) [SlotNo]
forall (m :: * -> *).
(IOLike m, MonadTime m, MonadDelay (OverrideDelay m)) =>
SystemStart
-> SlotLength -> NominalDiffTime -> Int -> OverrideDelay m [SlotNo]
testOverrideDelay
          (UTCTime -> SystemStart
SystemStart UTCTime
dawnOfTime)
          (Integer -> SlotLength
slotLengthFromSec Integer
1)
          (Double -> NominalDiffTime
secondsToNominalDiffTime Double
2)
          Int
numSlots

    checkException :: SlotNo -> SlotNo -> SomeException -> Property
    checkException :: SlotNo -> SlotNo -> SomeException -> Property
checkException SlotNo
before SlotNo
after SomeException
e
      | Just (ExceptionInLinkedThread TestName
_ SomeException
e') <- SomeException -> Maybe ExceptionInLinkedThread
forall e. Exception e => SomeException -> Maybe e
fromException SomeException
e =
          SlotNo -> SlotNo -> SomeException -> Property
checkException SlotNo
before SlotNo
after SomeException
e'
      | Just (SystemClockMovedBack SlotNo
before' SlotNo
after') <- SomeException -> Maybe SystemClockMovedBackException
forall e. Exception e => SomeException -> Maybe e
fromException SomeException
e =
          TestName -> Property -> Property
forall prop. Testable prop => TestName -> prop -> Property
counterexample (TestName
"Got expected exception " TestName -> ShowS
forall a. [a] -> [a] -> [a]
++ SomeException -> TestName
forall a. Show a => a -> TestName
show SomeException
e) (Property -> Property) -> Property -> Property
forall a b. (a -> b) -> a -> b
$
          [Property] -> Property
forall prop. Testable prop => [prop] -> Property
conjoin [
              SlotNo
before' SlotNo -> SlotNo -> Property
forall a. (Eq a, Show a) => a -> a -> Property
=== SlotNo
before
            , SlotNo
after'  SlotNo -> SlotNo -> Property
forall a. (Eq a, Show a) => a -> a -> Property
=== SlotNo
after
            ]
      | Bool
otherwise =
          TestName -> Property -> Property
forall prop. Testable prop => TestName -> prop -> Property
counterexample (TestName
"Unexpected exception: " TestName -> ShowS
forall a. [a] -> [a] -> [a]
++ SomeException -> TestName
forall a. Show a => a -> TestName
show SomeException
e) (Property -> Property) -> Property -> Property
forall a b. (a -> b) -> a -> b
$
            Bool -> Property
forall prop. Testable prop => prop -> Property
property Bool
False

-- | Just as a sanity check, verify that this works in IO
prop_delayNoClockShift :: Property
prop_delayNoClockShift :: Property
prop_delayNoClockShift =
    IO Property -> Property
forall prop. Testable prop => IO prop -> Property
ioProperty (IO Property -> Property) -> IO Property -> Property
forall a b. (a -> b) -> a -> b
$ do
      UTCTime
now   <- IO UTCTime
forall (m :: * -> *). MonadTime m => m UTCTime
getCurrentTime
      [SlotNo]
slots <- OverrideDelay IO [SlotNo] -> IO [SlotNo]
forall a. OverrideDelay IO a -> IO a
originalDelay (OverrideDelay IO [SlotNo] -> IO [SlotNo])
-> OverrideDelay IO [SlotNo] -> IO [SlotNo]
forall a b. (a -> b) -> a -> b
$
                 SystemStart
-> SlotLength
-> NominalDiffTime
-> Int
-> OverrideDelay IO [SlotNo]
forall (m :: * -> *).
(IOLike m, MonadTime m, MonadDelay (OverrideDelay m)) =>
SystemStart
-> SlotLength -> NominalDiffTime -> Int -> OverrideDelay m [SlotNo]
testOverrideDelay
                   (UTCTime -> SystemStart
SystemStart UTCTime
now)
                   (Integer -> SlotLength
slotLengthFromMillisec Integer
100)
                   (Double -> NominalDiffTime
secondsToNominalDiffTime Double
20)
                   Int
5
      Property -> IO Property
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Property -> IO Property) -> Property -> IO Property
forall a b. (a -> b) -> a -> b
$ [SlotNo]
slots [SlotNo] -> [SlotNo] -> Property
forall a. (Eq a, Show a) => a -> a -> Property
=== [Word64 -> SlotNo
SlotNo Word64
n | Word64
n <- [Word64
0..Word64
4]]

-- | Note that that under load, the returned list could be missing certain slots
-- or contain more slots than requested. This means that tests using this
-- function can fail, also see issue #3894.
testOverrideDelay :: forall m. (IOLike m, MonadTime m, MonadDelay (OverrideDelay m))
                  => SystemStart
                  -> SlotLength
                  -> NominalDiffTime
                  -> Int  -- ^ Number of slots to collect
                  -> OverrideDelay m [SlotNo]
testOverrideDelay :: forall (m :: * -> *).
(IOLike m, MonadTime m, MonadDelay (OverrideDelay m)) =>
SystemStart
-> SlotLength -> NominalDiffTime -> Int -> OverrideDelay m [SlotNo]
testOverrideDelay SystemStart
systemStart SlotLength
slotLength NominalDiffTime
maxClockRewind Int
numSlots = do
    (ResourceRegistry (OverrideDelay m)
 -> OverrideDelay m (BlockchainTime (OverrideDelay m)))
-> (BlockchainTime (OverrideDelay m) -> OverrideDelay m ())
-> (BlockchainTime (OverrideDelay m) -> OverrideDelay m [SlotNo])
-> OverrideDelay m [SlotNo]
forall (m :: * -> *) a r.
(MonadSTM m, MonadMask m, MonadThread m, HasCallStack) =>
(ResourceRegistry m -> m a) -> (a -> m ()) -> (a -> m r) -> m r
bracketWithPrivateRegistry
      (\ResourceRegistry (OverrideDelay m)
registry -> ResourceRegistry (OverrideDelay m)
-> SystemTime (OverrideDelay m)
-> SlotLength
-> NominalDiffTime
-> OverrideDelay m (BlockchainTime (OverrideDelay m))
forall (m :: * -> *).
IOLike m =>
ResourceRegistry m
-> SystemTime m
-> SlotLength
-> NominalDiffTime
-> m (BlockchainTime m)
simpleBlockchainTime
                      ResourceRegistry (OverrideDelay m)
registry
                      (SystemStart
-> Tracer (OverrideDelay m) (TraceBlockchainTimeEvent UTCTime)
-> SystemTime (OverrideDelay m)
forall (m :: * -> *).
(MonadTime m, MonadDelay m) =>
SystemStart
-> Tracer m (TraceBlockchainTimeEvent UTCTime) -> SystemTime m
defaultSystemTime SystemStart
systemStart Tracer (OverrideDelay m) (TraceBlockchainTimeEvent UTCTime)
forall (m :: * -> *) a. Applicative m => Tracer m a
nullTracer)
                      SlotLength
slotLength
                      NominalDiffTime
maxClockRewind)
      (\BlockchainTime (OverrideDelay m)
_btime   -> () -> OverrideDelay m ()
forall a. a -> OverrideDelay m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
      ((BlockchainTime (OverrideDelay m) -> OverrideDelay m [SlotNo])
 -> OverrideDelay m [SlotNo])
-> (BlockchainTime (OverrideDelay m) -> OverrideDelay m [SlotNo])
-> OverrideDelay m [SlotNo]
forall a b. (a -> b) -> a -> b
$ \BlockchainTime (OverrideDelay m)
btime   -> do
      StrictTVar (OverrideDelay m) [SlotNo]
slotsVar <- [SlotNo] -> OverrideDelay m (StrictTVar (OverrideDelay m) [SlotNo])
forall (m :: * -> *) a. MonadSTM m => a -> m (StrictTVar m a)
uncheckedNewTVarM []
      TestName
-> Watcher (OverrideDelay m) SlotNo SlotNo
-> OverrideDelay m [SlotNo]
-> OverrideDelay m [SlotNo]
forall (m :: * -> *) a fp r.
(IOLike m, Eq fp, HasCallStack) =>
TestName -> Watcher m a fp -> m r -> m r
withWatcher
        TestName
"testOverrideDelay"
        ( BlockchainTime (OverrideDelay m)
-> (SlotNo -> OverrideDelay m ())
-> Watcher (OverrideDelay m) SlotNo SlotNo
forall (m :: * -> *).
IOLike m =>
BlockchainTime m -> (SlotNo -> m ()) -> Watcher m SlotNo SlotNo
knownSlotWatcher BlockchainTime (OverrideDelay m)
btime ((SlotNo -> OverrideDelay m ())
 -> Watcher (OverrideDelay m) SlotNo SlotNo)
-> (SlotNo -> OverrideDelay m ())
-> Watcher (OverrideDelay m) SlotNo SlotNo
forall a b. (a -> b) -> a -> b
$ \SlotNo
slotNo -> do
            STM (OverrideDelay m) () -> OverrideDelay m ()
forall a.
HasCallStack =>
STM (OverrideDelay m) a -> OverrideDelay m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM (OverrideDelay m) () -> OverrideDelay m ())
-> STM (OverrideDelay m) () -> OverrideDelay m ()
forall a b. (a -> b) -> a -> b
$ StrictTVar (OverrideDelay m) [SlotNo]
-> ([SlotNo] -> [SlotNo]) -> STM (OverrideDelay m) ()
forall (m :: * -> *) a.
MonadSTM m =>
StrictTVar m a -> (a -> a) -> STM m ()
modifyTVar StrictTVar (OverrideDelay m) [SlotNo]
slotsVar (SlotNo
slotNo SlotNo -> [SlotNo] -> [SlotNo]
forall a. a -> [a] -> [a]
:)
        ) (OverrideDelay m [SlotNo] -> OverrideDelay m [SlotNo])
-> OverrideDelay m [SlotNo] -> OverrideDelay m [SlotNo]
forall a b. (a -> b) -> a -> b
$ do
        -- Wait to collect the required number of slots
        STM (OverrideDelay m) [SlotNo] -> OverrideDelay m [SlotNo]
forall a.
HasCallStack =>
STM (OverrideDelay m) a -> OverrideDelay m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM (OverrideDelay m) [SlotNo] -> OverrideDelay m [SlotNo])
-> STM (OverrideDelay m) [SlotNo] -> OverrideDelay m [SlotNo]
forall a b. (a -> b) -> a -> b
$ do
          [SlotNo]
slots <- StrictTVar (OverrideDelay m) [SlotNo]
-> STM (OverrideDelay m) [SlotNo]
forall (m :: * -> *) a. MonadSTM m => StrictTVar m a -> STM m a
readTVar StrictTVar (OverrideDelay m) [SlotNo]
slotsVar
          Bool -> OverrideDelaySTM m () -> OverrideDelaySTM m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ([SlotNo] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [SlotNo]
slots Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
numSlots) (OverrideDelaySTM m () -> OverrideDelaySTM m ())
-> OverrideDelaySTM m () -> OverrideDelaySTM m ()
forall a b. (a -> b) -> a -> b
$ STM (OverrideDelay m) ()
OverrideDelaySTM m ()
forall a. STM (OverrideDelay m) a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
          [SlotNo] -> OverrideDelaySTM m [SlotNo]
forall a. a -> OverrideDelaySTM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([SlotNo] -> OverrideDelaySTM m [SlotNo])
-> [SlotNo] -> OverrideDelaySTM m [SlotNo]
forall a b. (a -> b) -> a -> b
$ [SlotNo] -> [SlotNo]
forall a. [a] -> [a]
reverse [SlotNo]
slots

{-------------------------------------------------------------------------------
  Test-programmable time
-------------------------------------------------------------------------------}

-- | IO wrapper where we can program the effect of 'threadDelay'
newtype OverrideDelay m a = OverrideDelay {
      forall (m :: * -> *) a.
OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
unOverrideDelay :: ReaderT (StrictTVar m Schedule) m a
    }
  deriving ( (forall a b. (a -> b) -> OverrideDelay m a -> OverrideDelay m b)
-> (forall a b. a -> OverrideDelay m b -> OverrideDelay m a)
-> Functor (OverrideDelay m)
forall a b. a -> OverrideDelay m b -> OverrideDelay m a
forall a b. (a -> b) -> OverrideDelay m a -> OverrideDelay m b
forall (m :: * -> *) a b.
Functor m =>
a -> OverrideDelay m b -> OverrideDelay m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> OverrideDelay m a -> OverrideDelay m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> OverrideDelay m a -> OverrideDelay m b
fmap :: forall a b. (a -> b) -> OverrideDelay m a -> OverrideDelay m b
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> OverrideDelay m b -> OverrideDelay m a
<$ :: forall a b. a -> OverrideDelay m b -> OverrideDelay m a
Functor
           , Functor (OverrideDelay m)
Functor (OverrideDelay m) =>
(forall a. a -> OverrideDelay m a)
-> (forall a b.
    OverrideDelay m (a -> b) -> OverrideDelay m a -> OverrideDelay m b)
-> (forall a b c.
    (a -> b -> c)
    -> OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m c)
-> (forall a b.
    OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m b)
-> (forall a b.
    OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a)
-> Applicative (OverrideDelay m)
forall a. a -> OverrideDelay m a
forall a b.
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a
forall a b.
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m b
forall a b.
OverrideDelay m (a -> b) -> OverrideDelay m a -> OverrideDelay m b
forall a b c.
(a -> b -> c)
-> OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m c
forall (f :: * -> *).
Functor f =>
(forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall (m :: * -> *). Applicative m => Functor (OverrideDelay m)
forall (m :: * -> *) a. Applicative m => a -> OverrideDelay m a
forall (m :: * -> *) a b.
Applicative m =>
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a
forall (m :: * -> *) a b.
Applicative m =>
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m b
forall (m :: * -> *) a b.
Applicative m =>
OverrideDelay m (a -> b) -> OverrideDelay m a -> OverrideDelay m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m c
$cpure :: forall (m :: * -> *) a. Applicative m => a -> OverrideDelay m a
pure :: forall a. a -> OverrideDelay m a
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
OverrideDelay m (a -> b) -> OverrideDelay m a -> OverrideDelay m b
<*> :: forall a b.
OverrideDelay m (a -> b) -> OverrideDelay m a -> OverrideDelay m b
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m c
liftA2 :: forall a b c.
(a -> b -> c)
-> OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m c
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m b
*> :: forall a b.
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m b
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a
<* :: forall a b.
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a
Applicative
           , Applicative (OverrideDelay m)
Applicative (OverrideDelay m) =>
(forall a b.
 OverrideDelay m a -> (a -> OverrideDelay m b) -> OverrideDelay m b)
-> (forall a b.
    OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m b)
-> (forall a. a -> OverrideDelay m a)
-> Monad (OverrideDelay m)
forall a. a -> OverrideDelay m a
forall a b.
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m b
forall a b.
OverrideDelay m a -> (a -> OverrideDelay m b) -> OverrideDelay m b
forall (m :: * -> *). Monad m => Applicative (OverrideDelay m)
forall (m :: * -> *) a. Monad m => a -> OverrideDelay m a
forall (m :: * -> *) a b.
Monad m =>
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m b
forall (m :: * -> *) a b.
Monad m =>
OverrideDelay m a -> (a -> OverrideDelay m b) -> OverrideDelay m b
forall (m :: * -> *).
Applicative m =>
(forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
OverrideDelay m a -> (a -> OverrideDelay m b) -> OverrideDelay m b
>>= :: forall a b.
OverrideDelay m a -> (a -> OverrideDelay m b) -> OverrideDelay m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m b
>> :: forall a b.
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m b
$creturn :: forall (m :: * -> *) a. Monad m => a -> OverrideDelay m a
return :: forall a. a -> OverrideDelay m a
Monad
           , Monad (OverrideDelay m)
Monad (OverrideDelay m) =>
(TestName -> OverrideDelay m ())
-> (TestName -> OverrideDelay m ())
-> MonadEventlog (OverrideDelay m)
TestName -> OverrideDelay m ()
forall (m :: * -> *).
Monad m =>
(TestName -> m ()) -> (TestName -> m ()) -> MonadEventlog m
forall (m :: * -> *). MonadEventlog m => Monad (OverrideDelay m)
forall (m :: * -> *).
MonadEventlog m =>
TestName -> OverrideDelay m ()
$ctraceEventIO :: forall (m :: * -> *).
MonadEventlog m =>
TestName -> OverrideDelay m ()
traceEventIO :: TestName -> OverrideDelay m ()
$ctraceMarkerIO :: forall (m :: * -> *).
MonadEventlog m =>
TestName -> OverrideDelay m ()
traceMarkerIO :: TestName -> OverrideDelay m ()
MonadEventlog
           , Monad (OverrideDelay m)
Monad (OverrideDelay m) =>
(forall e a. Exception e => e -> OverrideDelay m a)
-> (forall a b c.
    OverrideDelay m a
    -> (a -> OverrideDelay m b)
    -> (a -> OverrideDelay m c)
    -> OverrideDelay m c)
-> (forall a b c.
    OverrideDelay m a
    -> OverrideDelay m b -> OverrideDelay m c -> OverrideDelay m c)
-> (forall a b.
    OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a)
-> MonadThrow (OverrideDelay m)
forall e a. Exception e => e -> OverrideDelay m a
forall a b.
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a
forall a b c.
OverrideDelay m a
-> OverrideDelay m b -> OverrideDelay m c -> OverrideDelay m c
forall a b c.
OverrideDelay m a
-> (a -> OverrideDelay m b)
-> (a -> OverrideDelay m c)
-> OverrideDelay m c
forall (m :: * -> *).
Monad m =>
(forall e a. Exception e => e -> m a)
-> (forall a b c. m a -> (a -> m b) -> (a -> m c) -> m c)
-> (forall a b c. m a -> m b -> m c -> m c)
-> (forall a b. m a -> m b -> m a)
-> MonadThrow m
forall (m :: * -> *). MonadThrow m => Monad (OverrideDelay m)
forall (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> OverrideDelay m a
forall (m :: * -> *) a b.
MonadThrow m =>
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a
forall (m :: * -> *) a b c.
MonadThrow m =>
OverrideDelay m a
-> OverrideDelay m b -> OverrideDelay m c -> OverrideDelay m c
forall (m :: * -> *) a b c.
MonadThrow m =>
OverrideDelay m a
-> (a -> OverrideDelay m b)
-> (a -> OverrideDelay m c)
-> OverrideDelay m c
$cthrowIO :: forall (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> OverrideDelay m a
throwIO :: forall e a. Exception e => e -> OverrideDelay m a
$cbracket :: forall (m :: * -> *) a b c.
MonadThrow m =>
OverrideDelay m a
-> (a -> OverrideDelay m b)
-> (a -> OverrideDelay m c)
-> OverrideDelay m c
bracket :: forall a b c.
OverrideDelay m a
-> (a -> OverrideDelay m b)
-> (a -> OverrideDelay m c)
-> OverrideDelay m c
$cbracket_ :: forall (m :: * -> *) a b c.
MonadThrow m =>
OverrideDelay m a
-> OverrideDelay m b -> OverrideDelay m c -> OverrideDelay m c
bracket_ :: forall a b c.
OverrideDelay m a
-> OverrideDelay m b -> OverrideDelay m c -> OverrideDelay m c
$cfinally :: forall (m :: * -> *) a b.
MonadThrow m =>
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a
finally :: forall a b.
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a
MonadThrow
           , MonadThrow (OverrideDelay m)
MonadThrow (OverrideDelay m) =>
(forall e a.
 Exception e =>
 OverrideDelay m a -> (e -> OverrideDelay m a) -> OverrideDelay m a)
-> (forall e b a.
    Exception e =>
    (e -> Maybe b)
    -> OverrideDelay m a
    -> (b -> OverrideDelay m a)
    -> OverrideDelay m a)
-> (forall e a.
    Exception e =>
    OverrideDelay m a -> OverrideDelay m (Either e a))
-> (forall e b a.
    Exception e =>
    (e -> Maybe b)
    -> OverrideDelay m a -> OverrideDelay m (Either b a))
-> (forall e a.
    Exception e =>
    (e -> OverrideDelay m a) -> OverrideDelay m a -> OverrideDelay m a)
-> (forall e b a.
    Exception e =>
    (e -> Maybe b)
    -> (b -> OverrideDelay m a)
    -> OverrideDelay m a
    -> OverrideDelay m a)
-> (forall a b.
    OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a)
-> (forall a b c.
    OverrideDelay m a
    -> (a -> OverrideDelay m b)
    -> (a -> OverrideDelay m c)
    -> OverrideDelay m c)
-> (forall a b c.
    OverrideDelay m a
    -> (a -> ExitCase b -> OverrideDelay m c)
    -> (a -> OverrideDelay m b)
    -> OverrideDelay m (b, c))
-> MonadCatch (OverrideDelay m)
forall e a.
Exception e =>
OverrideDelay m a -> OverrideDelay m (Either e a)
forall e a.
Exception e =>
OverrideDelay m a -> (e -> OverrideDelay m a) -> OverrideDelay m a
forall e a.
Exception e =>
(e -> OverrideDelay m a) -> OverrideDelay m a -> OverrideDelay m a
forall a b.
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a
forall e b a.
Exception e =>
(e -> Maybe b) -> OverrideDelay m a -> OverrideDelay m (Either b a)
forall e b a.
Exception e =>
(e -> Maybe b)
-> OverrideDelay m a
-> (b -> OverrideDelay m a)
-> OverrideDelay m a
forall e b a.
Exception e =>
(e -> Maybe b)
-> (b -> OverrideDelay m a)
-> OverrideDelay m a
-> OverrideDelay m a
forall a b c.
OverrideDelay m a
-> (a -> OverrideDelay m b)
-> (a -> OverrideDelay m c)
-> OverrideDelay m c
forall a b c.
OverrideDelay m a
-> (a -> ExitCase b -> OverrideDelay m c)
-> (a -> OverrideDelay m b)
-> OverrideDelay m (b, c)
forall (m :: * -> *). MonadCatch m => MonadThrow (OverrideDelay m)
forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
OverrideDelay m a -> OverrideDelay m (Either e a)
forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
OverrideDelay m a -> (e -> OverrideDelay m a) -> OverrideDelay m a
forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
(e -> OverrideDelay m a) -> OverrideDelay m a -> OverrideDelay m a
forall (m :: * -> *) a b.
MonadCatch m =>
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a
forall (m :: * -> *) e b a.
(MonadCatch m, Exception e) =>
(e -> Maybe b) -> OverrideDelay m a -> OverrideDelay m (Either b a)
forall (m :: * -> *) e b a.
(MonadCatch m, Exception e) =>
(e -> Maybe b)
-> OverrideDelay m a
-> (b -> OverrideDelay m a)
-> OverrideDelay m a
forall (m :: * -> *) e b a.
(MonadCatch m, Exception e) =>
(e -> Maybe b)
-> (b -> OverrideDelay m a)
-> OverrideDelay m a
-> OverrideDelay m a
forall (m :: * -> *) a b c.
MonadCatch m =>
OverrideDelay m a
-> (a -> OverrideDelay m b)
-> (a -> OverrideDelay m c)
-> OverrideDelay m c
forall (m :: * -> *) a b c.
MonadCatch m =>
OverrideDelay m a
-> (a -> ExitCase b -> OverrideDelay m c)
-> (a -> OverrideDelay m b)
-> OverrideDelay m (b, c)
forall (m :: * -> *).
MonadThrow m =>
(forall e a. Exception e => m a -> (e -> m a) -> m a)
-> (forall e b a.
    Exception e =>
    (e -> Maybe b) -> m a -> (b -> m a) -> m a)
-> (forall e a. Exception e => m a -> m (Either e a))
-> (forall e b a.
    Exception e =>
    (e -> Maybe b) -> m a -> m (Either b a))
-> (forall e a. Exception e => (e -> m a) -> m a -> m a)
-> (forall e b a.
    Exception e =>
    (e -> Maybe b) -> (b -> m a) -> m a -> m a)
-> (forall a b. m a -> m b -> m a)
-> (forall a b c. m a -> (a -> m b) -> (a -> m c) -> m c)
-> (forall a b c.
    m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c))
-> MonadCatch m
$ccatch :: forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
OverrideDelay m a -> (e -> OverrideDelay m a) -> OverrideDelay m a
catch :: forall e a.
Exception e =>
OverrideDelay m a -> (e -> OverrideDelay m a) -> OverrideDelay m a
$ccatchJust :: forall (m :: * -> *) e b a.
(MonadCatch m, Exception e) =>
(e -> Maybe b)
-> OverrideDelay m a
-> (b -> OverrideDelay m a)
-> OverrideDelay m a
catchJust :: forall e b a.
Exception e =>
(e -> Maybe b)
-> OverrideDelay m a
-> (b -> OverrideDelay m a)
-> OverrideDelay m a
$ctry :: forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
OverrideDelay m a -> OverrideDelay m (Either e a)
try :: forall e a.
Exception e =>
OverrideDelay m a -> OverrideDelay m (Either e a)
$ctryJust :: forall (m :: * -> *) e b a.
(MonadCatch m, Exception e) =>
(e -> Maybe b) -> OverrideDelay m a -> OverrideDelay m (Either b a)
tryJust :: forall e b a.
Exception e =>
(e -> Maybe b) -> OverrideDelay m a -> OverrideDelay m (Either b a)
$chandle :: forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
(e -> OverrideDelay m a) -> OverrideDelay m a -> OverrideDelay m a
handle :: forall e a.
Exception e =>
(e -> OverrideDelay m a) -> OverrideDelay m a -> OverrideDelay m a
$chandleJust :: forall (m :: * -> *) e b a.
(MonadCatch m, Exception e) =>
(e -> Maybe b)
-> (b -> OverrideDelay m a)
-> OverrideDelay m a
-> OverrideDelay m a
handleJust :: forall e b a.
Exception e =>
(e -> Maybe b)
-> (b -> OverrideDelay m a)
-> OverrideDelay m a
-> OverrideDelay m a
$conException :: forall (m :: * -> *) a b.
MonadCatch m =>
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a
onException :: forall a b.
OverrideDelay m a -> OverrideDelay m b -> OverrideDelay m a
$cbracketOnError :: forall (m :: * -> *) a b c.
MonadCatch m =>
OverrideDelay m a
-> (a -> OverrideDelay m b)
-> (a -> OverrideDelay m c)
-> OverrideDelay m c
bracketOnError :: forall a b c.
OverrideDelay m a
-> (a -> OverrideDelay m b)
-> (a -> OverrideDelay m c)
-> OverrideDelay m c
$cgeneralBracket :: forall (m :: * -> *) a b c.
MonadCatch m =>
OverrideDelay m a
-> (a -> ExitCase b -> OverrideDelay m c)
-> (a -> OverrideDelay m b)
-> OverrideDelay m (b, c)
generalBracket :: forall a b c.
OverrideDelay m a
-> (a -> ExitCase b -> OverrideDelay m c)
-> (a -> OverrideDelay m b)
-> OverrideDelay m (b, c)
MonadCatch
           , MonadThrow (OverrideDelay m)
MonadThrow (OverrideDelay m) =>
(forall a. a -> OverrideDelay m a)
-> MonadEvaluate (OverrideDelay m)
forall a. a -> OverrideDelay m a
forall (m :: * -> *).
MonadEvaluate m =>
MonadThrow (OverrideDelay m)
forall (m :: * -> *) a. MonadEvaluate m => a -> OverrideDelay m a
forall (m :: * -> *).
MonadThrow m =>
(forall a. a -> m a) -> MonadEvaluate m
$cevaluate :: forall (m :: * -> *) a. MonadEvaluate m => a -> OverrideDelay m a
evaluate :: forall a. a -> OverrideDelay m a
MonadEvaluate
           , MonadCatch (OverrideDelay m)
MonadCatch (OverrideDelay m) =>
(forall b.
 ((forall a. OverrideDelay m a -> OverrideDelay m a)
  -> OverrideDelay m b)
 -> OverrideDelay m b)
-> (forall b.
    ((forall a. OverrideDelay m a -> OverrideDelay m a)
     -> OverrideDelay m b)
    -> OverrideDelay m b)
-> (forall a. OverrideDelay m a -> OverrideDelay m a)
-> (forall a. OverrideDelay m a -> OverrideDelay m a)
-> MonadMask (OverrideDelay m)
forall a. OverrideDelay m a -> OverrideDelay m a
forall b.
((forall a. OverrideDelay m a -> OverrideDelay m a)
 -> OverrideDelay m b)
-> OverrideDelay m b
forall (m :: * -> *). MonadMask m => MonadCatch (OverrideDelay m)
forall (m :: * -> *) a.
MonadMask m =>
OverrideDelay m a -> OverrideDelay m a
forall (m :: * -> *) b.
MonadMask m =>
((forall a. OverrideDelay m a -> OverrideDelay m a)
 -> OverrideDelay m b)
-> OverrideDelay m b
forall (m :: * -> *).
MonadCatch m =>
(forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> (forall a. m a -> m a)
-> (forall a. m a -> m a)
-> MonadMask m
$cmask :: forall (m :: * -> *) b.
MonadMask m =>
((forall a. OverrideDelay m a -> OverrideDelay m a)
 -> OverrideDelay m b)
-> OverrideDelay m b
mask :: forall b.
((forall a. OverrideDelay m a -> OverrideDelay m a)
 -> OverrideDelay m b)
-> OverrideDelay m b
$cuninterruptibleMask :: forall (m :: * -> *) b.
MonadMask m =>
((forall a. OverrideDelay m a -> OverrideDelay m a)
 -> OverrideDelay m b)
-> OverrideDelay m b
uninterruptibleMask :: forall b.
((forall a. OverrideDelay m a -> OverrideDelay m a)
 -> OverrideDelay m b)
-> OverrideDelay m b
$cmask_ :: forall (m :: * -> *) a.
MonadMask m =>
OverrideDelay m a -> OverrideDelay m a
mask_ :: forall a. OverrideDelay m a -> OverrideDelay m a
$cuninterruptibleMask_ :: forall (m :: * -> *) a.
MonadMask m =>
OverrideDelay m a -> OverrideDelay m a
uninterruptibleMask_ :: forall a. OverrideDelay m a -> OverrideDelay m a
MonadMask
           , MonadMonotonicTimeNSec (OverrideDelay m)
OverrideDelay m Time
MonadMonotonicTimeNSec (OverrideDelay m) =>
OverrideDelay m Time -> MonadMonotonicTime (OverrideDelay m)
forall (m :: * -> *).
MonadMonotonicTimeNSec m =>
m Time -> MonadMonotonicTime m
forall (m :: * -> *).
MonadMonotonicTime m =>
MonadMonotonicTimeNSec (OverrideDelay m)
forall (m :: * -> *). MonadMonotonicTime m => OverrideDelay m Time
$cgetMonotonicTime :: forall (m :: * -> *). MonadMonotonicTime m => OverrideDelay m Time
getMonotonicTime :: OverrideDelay m Time
MonadMonotonicTime
           , Monad (OverrideDelay m)
OverrideDelay m Word64
Monad (OverrideDelay m) =>
OverrideDelay m Word64 -> MonadMonotonicTimeNSec (OverrideDelay m)
forall (m :: * -> *).
Monad m =>
m Word64 -> MonadMonotonicTimeNSec m
forall (m :: * -> *).
MonadMonotonicTimeNSec m =>
Monad (OverrideDelay m)
forall (m :: * -> *).
MonadMonotonicTimeNSec m =>
OverrideDelay m Word64
$cgetMonotonicTimeNSec :: forall (m :: * -> *).
MonadMonotonicTimeNSec m =>
OverrideDelay m Word64
getMonotonicTimeNSec :: OverrideDelay m Word64
MonadMonotonicTimeNSec
           , Monad (OverrideDelay m)
Monad (OverrideDelay m) =>
(forall a. OverrideDelay m (MVar (OverrideDelay m) a))
-> (forall a. MVar (OverrideDelay m) a -> OverrideDelay m a)
-> (forall a. MVar (OverrideDelay m) a -> a -> OverrideDelay m ())
-> (forall a.
    MVar (OverrideDelay m) a -> OverrideDelay m (Maybe a))
-> (forall a.
    MVar (OverrideDelay m) a -> a -> OverrideDelay m Bool)
-> (forall a. MVar (OverrideDelay m) a -> OverrideDelay m Bool)
-> (forall a. a -> OverrideDelay m (MVar (OverrideDelay m) a))
-> (forall a. MVar (OverrideDelay m) a -> OverrideDelay m a)
-> (forall a.
    MVar (OverrideDelay m) a -> OverrideDelay m (Maybe a))
-> (forall a. MVar (OverrideDelay m) a -> a -> OverrideDelay m a)
-> (forall a b.
    MVar (OverrideDelay m) a
    -> (a -> OverrideDelay m b) -> OverrideDelay m b)
-> (forall a b.
    MVar (OverrideDelay m) a
    -> (a -> OverrideDelay m b) -> OverrideDelay m b)
-> (forall a.
    MVar (OverrideDelay m) a
    -> (a -> OverrideDelay m a) -> OverrideDelay m ())
-> (forall a b.
    MVar (OverrideDelay m) a
    -> (a -> OverrideDelay m (a, b)) -> OverrideDelay m b)
-> (forall a.
    MVar (OverrideDelay m) a
    -> (a -> OverrideDelay m a) -> OverrideDelay m ())
-> (forall a b.
    MVar (OverrideDelay m) a
    -> (a -> OverrideDelay m (a, b)) -> OverrideDelay m b)
-> MonadMVar (OverrideDelay m)
forall a. OverrideDelay m (MVar (OverrideDelay m) a)
forall a. a -> OverrideDelay m (MVar (OverrideDelay m) a)
forall a. MVar (OverrideDelay m) a -> OverrideDelay m a
forall a. MVar (OverrideDelay m) a -> OverrideDelay m Bool
forall a. MVar (OverrideDelay m) a -> OverrideDelay m (Maybe a)
forall a. MVar (OverrideDelay m) a -> a -> OverrideDelay m a
forall a. MVar (OverrideDelay m) a -> a -> OverrideDelay m Bool
forall a. MVar (OverrideDelay m) a -> a -> OverrideDelay m ()
forall a.
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m a) -> OverrideDelay m ()
forall a b.
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m b) -> OverrideDelay m b
forall a b.
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m (a, b)) -> OverrideDelay m b
forall (m :: * -> *).
Monad m =>
(forall a. m (MVar m a))
-> (forall a. MVar m a -> m a)
-> (forall a. MVar m a -> a -> m ())
-> (forall a. MVar m a -> m (Maybe a))
-> (forall a. MVar m a -> a -> m Bool)
-> (forall a. MVar m a -> m Bool)
-> (forall a. a -> m (MVar m a))
-> (forall a. MVar m a -> m a)
-> (forall a. MVar m a -> m (Maybe a))
-> (forall a. MVar m a -> a -> m a)
-> (forall a b. MVar m a -> (a -> m b) -> m b)
-> (forall a b. MVar m a -> (a -> m b) -> m b)
-> (forall a. MVar m a -> (a -> m a) -> m ())
-> (forall a b. MVar m a -> (a -> m (a, b)) -> m b)
-> (forall a. MVar m a -> (a -> m a) -> m ())
-> (forall a b. MVar m a -> (a -> m (a, b)) -> m b)
-> MonadMVar m
forall (m :: * -> *).
(MonadMask m, MonadMVar m) =>
Monad (OverrideDelay m)
forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
OverrideDelay m (MVar (OverrideDelay m) a)
forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
a -> OverrideDelay m (MVar (OverrideDelay m) a)
forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> OverrideDelay m a
forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> OverrideDelay m Bool
forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> OverrideDelay m (Maybe a)
forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> a -> OverrideDelay m a
forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> a -> OverrideDelay m Bool
forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> a -> OverrideDelay m ()
forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m a) -> OverrideDelay m ()
forall (m :: * -> *) a b.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m b) -> OverrideDelay m b
forall (m :: * -> *) a b.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m (a, b)) -> OverrideDelay m b
$cnewEmptyMVar :: forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
OverrideDelay m (MVar (OverrideDelay m) a)
newEmptyMVar :: forall a. OverrideDelay m (MVar (OverrideDelay m) a)
$ctakeMVar :: forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> OverrideDelay m a
takeMVar :: forall a. MVar (OverrideDelay m) a -> OverrideDelay m a
$cputMVar :: forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> a -> OverrideDelay m ()
putMVar :: forall a. MVar (OverrideDelay m) a -> a -> OverrideDelay m ()
$ctryTakeMVar :: forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> OverrideDelay m (Maybe a)
tryTakeMVar :: forall a. MVar (OverrideDelay m) a -> OverrideDelay m (Maybe a)
$ctryPutMVar :: forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> a -> OverrideDelay m Bool
tryPutMVar :: forall a. MVar (OverrideDelay m) a -> a -> OverrideDelay m Bool
$cisEmptyMVar :: forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> OverrideDelay m Bool
isEmptyMVar :: forall a. MVar (OverrideDelay m) a -> OverrideDelay m Bool
$cnewMVar :: forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
a -> OverrideDelay m (MVar (OverrideDelay m) a)
newMVar :: forall a. a -> OverrideDelay m (MVar (OverrideDelay m) a)
$creadMVar :: forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> OverrideDelay m a
readMVar :: forall a. MVar (OverrideDelay m) a -> OverrideDelay m a
$ctryReadMVar :: forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> OverrideDelay m (Maybe a)
tryReadMVar :: forall a. MVar (OverrideDelay m) a -> OverrideDelay m (Maybe a)
$cswapMVar :: forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a -> a -> OverrideDelay m a
swapMVar :: forall a. MVar (OverrideDelay m) a -> a -> OverrideDelay m a
$cwithMVar :: forall (m :: * -> *) a b.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m b) -> OverrideDelay m b
withMVar :: forall a b.
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m b) -> OverrideDelay m b
$cwithMVarMasked :: forall (m :: * -> *) a b.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m b) -> OverrideDelay m b
withMVarMasked :: forall a b.
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m b) -> OverrideDelay m b
$cmodifyMVar_ :: forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m a) -> OverrideDelay m ()
modifyMVar_ :: forall a.
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m a) -> OverrideDelay m ()
$cmodifyMVar :: forall (m :: * -> *) a b.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m (a, b)) -> OverrideDelay m b
modifyMVar :: forall a b.
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m (a, b)) -> OverrideDelay m b
$cmodifyMVarMasked_ :: forall (m :: * -> *) a.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m a) -> OverrideDelay m ()
modifyMVarMasked_ :: forall a.
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m a) -> OverrideDelay m ()
$cmodifyMVarMasked :: forall (m :: * -> *) a b.
(MonadMask m, MonadMVar m) =>
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m (a, b)) -> OverrideDelay m b
modifyMVarMasked :: forall a b.
MVar (OverrideDelay m) a
-> (a -> OverrideDelay m (a, b)) -> OverrideDelay m b
MonadMVar
           , Monad (OverrideDelay m)
OverrideDelay m UTCTime
Monad (OverrideDelay m) =>
OverrideDelay m UTCTime -> MonadTime (OverrideDelay m)
forall (m :: * -> *). Monad m => m UTCTime -> MonadTime m
forall (m :: * -> *). MonadTime m => Monad (OverrideDelay m)
forall (m :: * -> *). MonadTime m => OverrideDelay m UTCTime
$cgetCurrentTime :: forall (m :: * -> *). MonadTime m => OverrideDelay m UTCTime
getCurrentTime :: OverrideDelay m UTCTime
MonadTime
           , Eq (ThreadId (OverrideDelay m))
Monad (OverrideDelay m)
Ord (ThreadId (OverrideDelay m))
Show (ThreadId (OverrideDelay m))
OverrideDelay m (ThreadId (OverrideDelay m))
(Monad (OverrideDelay m), Eq (ThreadId (OverrideDelay m)),
 Ord (ThreadId (OverrideDelay m)),
 Show (ThreadId (OverrideDelay m))) =>
OverrideDelay m (ThreadId (OverrideDelay m))
-> (ThreadId (OverrideDelay m) -> TestName -> OverrideDelay m ())
-> MonadThread (OverrideDelay m)
ThreadId (OverrideDelay m) -> TestName -> OverrideDelay m ()
forall (m :: * -> *).
(Monad m, Eq (ThreadId m), Ord (ThreadId m), Show (ThreadId m)) =>
m (ThreadId m) -> (ThreadId m -> TestName -> m ()) -> MonadThread m
forall (m :: * -> *).
MonadThread m =>
Eq (ThreadId (OverrideDelay m))
forall (m :: * -> *). MonadThread m => Monad (OverrideDelay m)
forall (m :: * -> *).
MonadThread m =>
Ord (ThreadId (OverrideDelay m))
forall (m :: * -> *).
MonadThread m =>
Show (ThreadId (OverrideDelay m))
forall (m :: * -> *).
MonadThread m =>
OverrideDelay m (ThreadId (OverrideDelay m))
forall (m :: * -> *).
MonadThread m =>
ThreadId (OverrideDelay m) -> TestName -> OverrideDelay m ()
$cmyThreadId :: forall (m :: * -> *).
MonadThread m =>
OverrideDelay m (ThreadId (OverrideDelay m))
myThreadId :: OverrideDelay m (ThreadId (OverrideDelay m))
$clabelThread :: forall (m :: * -> *).
MonadThread m =>
ThreadId (OverrideDelay m) -> TestName -> OverrideDelay m ()
labelThread :: ThreadId (OverrideDelay m) -> TestName -> OverrideDelay m ()
MonadThread
           , MonadThread (OverrideDelay m)
OverrideDelay m ()
Int
-> OverrideDelay m ()
-> OverrideDelay m (ThreadId (OverrideDelay m))
MonadThread (OverrideDelay m) =>
(OverrideDelay m ()
 -> OverrideDelay m (ThreadId (OverrideDelay m)))
-> (Int
    -> OverrideDelay m ()
    -> OverrideDelay m (ThreadId (OverrideDelay m)))
-> (((forall a. OverrideDelay m a -> OverrideDelay m a)
     -> OverrideDelay m ())
    -> OverrideDelay m (ThreadId (OverrideDelay m)))
-> (forall a.
    OverrideDelay m a
    -> (Either SomeException a -> OverrideDelay m ())
    -> OverrideDelay m (ThreadId (OverrideDelay m)))
-> (forall e.
    Exception e =>
    ThreadId (OverrideDelay m) -> e -> OverrideDelay m ())
-> (ThreadId (OverrideDelay m) -> OverrideDelay m ())
-> OverrideDelay m ()
-> MonadFork (OverrideDelay m)
ThreadId (OverrideDelay m) -> OverrideDelay m ()
OverrideDelay m () -> OverrideDelay m (ThreadId (OverrideDelay m))
((forall a. OverrideDelay m a -> OverrideDelay m a)
 -> OverrideDelay m ())
-> OverrideDelay m (ThreadId (OverrideDelay m))
forall e.
Exception e =>
ThreadId (OverrideDelay m) -> e -> OverrideDelay m ()
forall a.
OverrideDelay m a
-> (Either SomeException a -> OverrideDelay m ())
-> OverrideDelay m (ThreadId (OverrideDelay m))
forall (m :: * -> *). MonadFork m => MonadThread (OverrideDelay m)
forall (m :: * -> *). MonadFork m => OverrideDelay m ()
forall (m :: * -> *).
MonadFork m =>
Int
-> OverrideDelay m ()
-> OverrideDelay m (ThreadId (OverrideDelay m))
forall (m :: * -> *).
MonadFork m =>
ThreadId (OverrideDelay m) -> OverrideDelay m ()
forall (m :: * -> *).
MonadFork m =>
OverrideDelay m () -> OverrideDelay m (ThreadId (OverrideDelay m))
forall (m :: * -> *).
MonadFork m =>
((forall a. OverrideDelay m a -> OverrideDelay m a)
 -> OverrideDelay m ())
-> OverrideDelay m (ThreadId (OverrideDelay m))
forall (m :: * -> *) e.
(MonadFork m, Exception e) =>
ThreadId (OverrideDelay m) -> e -> OverrideDelay m ()
forall (m :: * -> *) a.
MonadFork m =>
OverrideDelay m a
-> (Either SomeException a -> OverrideDelay m ())
-> OverrideDelay m (ThreadId (OverrideDelay m))
forall (m :: * -> *).
MonadThread m =>
(m () -> m (ThreadId m))
-> (Int -> m () -> m (ThreadId m))
-> (((forall a. m a -> m a) -> m ()) -> m (ThreadId m))
-> (forall a.
    m a -> (Either SomeException a -> m ()) -> m (ThreadId m))
-> (forall e. Exception e => ThreadId m -> e -> m ())
-> (ThreadId m -> m ())
-> m ()
-> MonadFork m
$cforkIO :: forall (m :: * -> *).
MonadFork m =>
OverrideDelay m () -> OverrideDelay m (ThreadId (OverrideDelay m))
forkIO :: OverrideDelay m () -> OverrideDelay m (ThreadId (OverrideDelay m))
$cforkOn :: forall (m :: * -> *).
MonadFork m =>
Int
-> OverrideDelay m ()
-> OverrideDelay m (ThreadId (OverrideDelay m))
forkOn :: Int
-> OverrideDelay m ()
-> OverrideDelay m (ThreadId (OverrideDelay m))
$cforkIOWithUnmask :: forall (m :: * -> *).
MonadFork m =>
((forall a. OverrideDelay m a -> OverrideDelay m a)
 -> OverrideDelay m ())
-> OverrideDelay m (ThreadId (OverrideDelay m))
forkIOWithUnmask :: ((forall a. OverrideDelay m a -> OverrideDelay m a)
 -> OverrideDelay m ())
-> OverrideDelay m (ThreadId (OverrideDelay m))
$cforkFinally :: forall (m :: * -> *) a.
MonadFork m =>
OverrideDelay m a
-> (Either SomeException a -> OverrideDelay m ())
-> OverrideDelay m (ThreadId (OverrideDelay m))
forkFinally :: forall a.
OverrideDelay m a
-> (Either SomeException a -> OverrideDelay m ())
-> OverrideDelay m (ThreadId (OverrideDelay m))
$cthrowTo :: forall (m :: * -> *) e.
(MonadFork m, Exception e) =>
ThreadId (OverrideDelay m) -> e -> OverrideDelay m ()
throwTo :: forall e.
Exception e =>
ThreadId (OverrideDelay m) -> e -> OverrideDelay m ()
$ckillThread :: forall (m :: * -> *).
MonadFork m =>
ThreadId (OverrideDelay m) -> OverrideDelay m ()
killThread :: ThreadId (OverrideDelay m) -> OverrideDelay m ()
$cyield :: forall (m :: * -> *). MonadFork m => OverrideDelay m ()
yield :: OverrideDelay m ()
MonadFork
           , PrimMonad (OverrideDelay m)
PrimMonad (OverrideDelay m) =>
(forall a. ST (PrimState (OverrideDelay m)) a -> OverrideDelay m a)
-> (forall b.
    (forall s. (forall a. ST s a -> OverrideDelay m a) -> b) -> b)
-> MonadST (OverrideDelay m)
forall a. ST (PrimState (OverrideDelay m)) a -> OverrideDelay m a
forall b.
(forall s. (forall a. ST s a -> OverrideDelay m a) -> b) -> b
forall (m :: * -> *).
PrimMonad m =>
(forall a. ST (PrimState m) a -> m a)
-> (forall b. (forall s. (forall a. ST s a -> m a) -> b) -> b)
-> MonadST m
forall (m :: * -> *). MonadST m => PrimMonad (OverrideDelay m)
forall (m :: * -> *) a.
MonadST m =>
ST (PrimState (OverrideDelay m)) a -> OverrideDelay m a
forall (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> OverrideDelay m a) -> b) -> b
$cstToIO :: forall (m :: * -> *) a.
MonadST m =>
ST (PrimState (OverrideDelay m)) a -> OverrideDelay m a
stToIO :: forall a. ST (PrimState (OverrideDelay m)) a -> OverrideDelay m a
$cwithLiftST :: forall (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> OverrideDelay m a) -> b) -> b
withLiftST :: forall b.
(forall s. (forall a. ST s a -> OverrideDelay m a) -> b) -> b
MonadST
           )


instance PrimMonad m => PrimMonad (OverrideDelay m) where
  type PrimState (OverrideDelay m) = PrimState m
  primitive :: forall a.
(State# (PrimState (OverrideDelay m))
 -> (# State# (PrimState (OverrideDelay m)), a #))
-> OverrideDelay m a
primitive = ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a)
-> ((State# (PrimState m) -> (# State# (PrimState m), a #))
    -> ReaderT (StrictTVar m Schedule) m a)
-> (State# (PrimState m) -> (# State# (PrimState m), a #))
-> OverrideDelay m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (State# (PrimState m) -> (# State# (PrimState m), a #))
-> ReaderT (StrictTVar m Schedule) m a
(State# (PrimState (ReaderT (StrictTVar m Schedule) m))
 -> (# State# (PrimState (ReaderT (StrictTVar m Schedule) m)), a #))
-> ReaderT (StrictTVar m Schedule) m a
forall a.
(State# (PrimState (ReaderT (StrictTVar m Schedule) m))
 -> (# State# (PrimState (ReaderT (StrictTVar m Schedule) m)), a #))
-> ReaderT (StrictTVar m Schedule) m a
forall (m :: * -> *) a.
PrimMonad m =>
(State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
primitive
  {-# INLINE primitive #-}

deriving via AllowThunk (OverrideDelay s a)
         instance NoThunks (OverrideDelay s a)

deriving via AllowThunk (StrictTVar (OverrideDelay s) a)
         instance NoThunks (StrictTVar (OverrideDelay s) a)

deriving via AllowThunk (StrictSVar (OverrideDelay s) a)
         instance NoThunks (StrictSVar (OverrideDelay s) a)

deriving via AllowThunk (StrictMVar (OverrideDelay s) a)
         instance NoThunks (StrictMVar (OverrideDelay s) a)

deriving via AllowThunk (Strict.StrictTVar (OverrideDelay s) a)
         instance NoThunks (Strict.StrictTVar (OverrideDelay s) a)

deriving via AllowThunk (Strict.StrictMVar (OverrideDelay s) a)
         instance NoThunks (Strict.StrictMVar (OverrideDelay s) a)

instance MonadTimer.MonadDelay (OverrideDelay (IOSim s)) where
  threadDelay :: Int -> OverrideDelay (IOSim s) ()
threadDelay Int
d = ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) ()
-> OverrideDelay (IOSim s) ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) ()
 -> OverrideDelay (IOSim s) ())
-> ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) ()
-> OverrideDelay (IOSim s) ()
forall a b. (a -> b) -> a -> b
$ (StrictTVar (IOSim s) Schedule -> IOSim s ())
-> ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) ()
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((StrictTVar (IOSim s) Schedule -> IOSim s ())
 -> ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) ())
-> (StrictTVar (IOSim s) Schedule -> IOSim s ())
-> ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) ()
forall a b. (a -> b) -> a -> b
$ \StrictTVar (IOSim s) Schedule
schedule -> do
      -- Do the original delay. This is important, because otherwise this
      -- turns into a busy loop in the simulator
      Int -> IOSim s ()
forall (m :: * -> *). MonadDelay m => Int -> m ()
MonadTimer.threadDelay Int
d
      -- However, the time /after/ the delay will be determined by the
      -- schedule (unless it is empty, in which case the threadDelay behaves
      -- as normal).
      Maybe UTCTime
mOverride <- STM (IOSim s) (Maybe UTCTime) -> IOSim s (Maybe UTCTime)
forall a. HasCallStack => STM (IOSim s) a -> IOSim s a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM (IOSim s) (Maybe UTCTime) -> IOSim s (Maybe UTCTime))
-> STM (IOSim s) (Maybe UTCTime) -> IOSim s (Maybe UTCTime)
forall a b. (a -> b) -> a -> b
$ StrictTVar (IOSim s) Schedule
-> (Schedule -> (Maybe UTCTime, Schedule))
-> STM (IOSim s) (Maybe UTCTime)
forall (m :: * -> *) s a.
MonadSTM m =>
StrictTVar m s -> (s -> (a, s)) -> STM m a
stateTVar StrictTVar (IOSim s) Schedule
schedule Schedule -> (Maybe UTCTime, Schedule)
nextDelay
      case Maybe UTCTime
mOverride of
        Maybe UTCTime
Nothing -> () -> IOSim s ()
forall a. a -> IOSim s a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
        Just UTCTime
t  -> UTCTime -> IOSim s ()
forall s. UTCTime -> IOSim s ()
setCurrentTime UTCTime
t
    where
      nextDelay :: Schedule -> (Maybe UTCTime, Schedule)
      nextDelay :: Schedule -> (Maybe UTCTime, Schedule)
nextDelay = \case
          Schedule []     -> (Maybe UTCTime
forall a. Maybe a
Nothing, [Fixed E1] -> Schedule
Schedule [])
          Schedule (Fixed E1
t:[Fixed E1]
ts) -> (UTCTime -> Maybe UTCTime
forall a. a -> Maybe a
Just (UTCTime -> Maybe UTCTime) -> UTCTime -> Maybe UTCTime
forall a b. (a -> b) -> a -> b
$ Fixed E1 -> UTCTime
offsetToTime Fixed E1
t, [Fixed E1] -> Schedule
Schedule [Fixed E1]
ts)

      offsetToTime :: Fixed E1 -> UTCTime
      offsetToTime :: Fixed E1 -> UTCTime
offsetToTime Fixed E1
t = NominalDiffTime -> UTCTime -> UTCTime
Time.addUTCTime (Fixed E1 -> NominalDiffTime
forall a b. (Real a, Fractional b) => a -> b
realToFrac Fixed E1
t) UTCTime
dawnOfTime

instance MonadDelay (OverrideDelay (IOSim s)) where
  threadDelay :: DiffTime -> OverrideDelay (IOSim s) ()
threadDelay DiffTime
d = ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) ()
-> OverrideDelay (IOSim s) ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) ()
 -> OverrideDelay (IOSim s) ())
-> ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) ()
-> OverrideDelay (IOSim s) ()
forall a b. (a -> b) -> a -> b
$ (StrictTVar (IOSim s) Schedule -> IOSim s ())
-> ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) ()
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((StrictTVar (IOSim s) Schedule -> IOSim s ())
 -> ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) ())
-> (StrictTVar (IOSim s) Schedule -> IOSim s ())
-> ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) ()
forall a b. (a -> b) -> a -> b
$ \StrictTVar (IOSim s) Schedule
schedule -> do
      -- Do the original delay. This is important, because otherwise this
      -- turns into a busy loop in the simulator
      DiffTime -> IOSim s ()
forall (m :: * -> *). MonadDelay m => DiffTime -> m ()
threadDelay DiffTime
d
      -- However, the time /after/ the delay will be determined by the
      -- schedule (unless it is empty, in which case the threadDelay behaves
      -- as normal).
      Maybe UTCTime
mOverride <- STM (IOSim s) (Maybe UTCTime) -> IOSim s (Maybe UTCTime)
forall a. HasCallStack => STM (IOSim s) a -> IOSim s a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM (IOSim s) (Maybe UTCTime) -> IOSim s (Maybe UTCTime))
-> STM (IOSim s) (Maybe UTCTime) -> IOSim s (Maybe UTCTime)
forall a b. (a -> b) -> a -> b
$ StrictTVar (IOSim s) Schedule
-> (Schedule -> (Maybe UTCTime, Schedule))
-> STM (IOSim s) (Maybe UTCTime)
forall (m :: * -> *) s a.
MonadSTM m =>
StrictTVar m s -> (s -> (a, s)) -> STM m a
stateTVar StrictTVar (IOSim s) Schedule
schedule Schedule -> (Maybe UTCTime, Schedule)
nextDelay
      case Maybe UTCTime
mOverride of
        Maybe UTCTime
Nothing -> () -> IOSim s ()
forall a. a -> IOSim s a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
        Just UTCTime
t  -> UTCTime -> IOSim s ()
forall s. UTCTime -> IOSim s ()
setCurrentTime UTCTime
t
    where
      nextDelay :: Schedule -> (Maybe UTCTime, Schedule)
      nextDelay :: Schedule -> (Maybe UTCTime, Schedule)
nextDelay = \case
          Schedule []     -> (Maybe UTCTime
forall a. Maybe a
Nothing, [Fixed E1] -> Schedule
Schedule [])
          Schedule (Fixed E1
t:[Fixed E1]
ts) -> (UTCTime -> Maybe UTCTime
forall a. a -> Maybe a
Just (UTCTime -> Maybe UTCTime) -> UTCTime -> Maybe UTCTime
forall a b. (a -> b) -> a -> b
$ Fixed E1 -> UTCTime
offsetToTime Fixed E1
t, [Fixed E1] -> Schedule
Schedule [Fixed E1]
ts)

      offsetToTime :: Fixed E1 -> UTCTime
      offsetToTime :: Fixed E1 -> UTCTime
offsetToTime Fixed E1
t = NominalDiffTime -> UTCTime -> UTCTime
Time.addUTCTime (Fixed E1 -> NominalDiffTime
forall a b. (Real a, Fractional b) => a -> b
realToFrac Fixed E1
t) UTCTime
dawnOfTime

-- | The IO instance just uses the default delay
instance MonadTimer.MonadDelay (OverrideDelay IO) where
  threadDelay :: Int -> OverrideDelay IO ()
threadDelay Int
d = ReaderT (StrictTVar IO Schedule) IO () -> OverrideDelay IO ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar IO Schedule) IO () -> OverrideDelay IO ())
-> ReaderT (StrictTVar IO Schedule) IO () -> OverrideDelay IO ()
forall a b. (a -> b) -> a -> b
$ (StrictTVar IO Schedule -> IO ())
-> ReaderT (StrictTVar IO Schedule) IO ()
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((StrictTVar IO Schedule -> IO ())
 -> ReaderT (StrictTVar IO Schedule) IO ())
-> (StrictTVar IO Schedule -> IO ())
-> ReaderT (StrictTVar IO Schedule) IO ()
forall a b. (a -> b) -> a -> b
$ \StrictTVar IO Schedule
_schedule -> Int -> IO ()
forall (m :: * -> *). MonadDelay m => Int -> m ()
MonadTimer.threadDelay Int
d

-- | The IO instance just uses the default delay
instance MonadDelay (OverrideDelay IO) where
  threadDelay :: DiffTime -> OverrideDelay IO ()
threadDelay DiffTime
d = ReaderT (StrictTVar IO Schedule) IO () -> OverrideDelay IO ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar IO Schedule) IO () -> OverrideDelay IO ())
-> ReaderT (StrictTVar IO Schedule) IO () -> OverrideDelay IO ()
forall a b. (a -> b) -> a -> b
$ (StrictTVar IO Schedule -> IO ())
-> ReaderT (StrictTVar IO Schedule) IO ()
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((StrictTVar IO Schedule -> IO ())
 -> ReaderT (StrictTVar IO Schedule) IO ())
-> (StrictTVar IO Schedule -> IO ())
-> ReaderT (StrictTVar IO Schedule) IO ()
forall a b. (a -> b) -> a -> b
$ \StrictTVar IO Schedule
_schedule -> DiffTime -> IO ()
forall (m :: * -> *). MonadDelay m => DiffTime -> m ()
threadDelay DiffTime
d

newtype OverrideDelaySTM m a =
    OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a)

deriving instance Alternative (STM m) => Alternative (OverrideDelaySTM m)
deriving instance Applicative (STM m) => Applicative (OverrideDelaySTM m)
deriving instance Functor     (STM m) => Functor     (OverrideDelaySTM m)
deriving instance Monad       (STM m) => Monad       (OverrideDelaySTM m)
deriving instance MonadPlus   (STM m) => MonadPlus   (OverrideDelaySTM m)
deriving instance MonadThrow  (STM m) => MonadThrow  (OverrideDelaySTM m)
deriving instance MonadCatch  (STM m) => MonadCatch  (OverrideDelaySTM m)

instance MonadSTM m => MonadSTM (OverrideDelay m) where
  type STM   (OverrideDelay m) = OverrideDelaySTM m
  atomically :: forall a.
HasCallStack =>
STM (OverrideDelay m) a -> OverrideDelay m a
atomically (OverrideDelaySTM (ReaderT StrictTVar m Schedule -> STM m a
stm)) =
    ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay ((StrictTVar m Schedule -> m a)
-> ReaderT (StrictTVar m Schedule) m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT (STM m a -> m a
forall a. HasCallStack => STM m a -> m a
forall (m :: * -> *) a.
(MonadSTM m, HasCallStack) =>
STM m a -> m a
atomically (STM m a -> m a)
-> (StrictTVar m Schedule -> STM m a)
-> StrictTVar m Schedule
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StrictTVar m Schedule -> STM m a
stm))

  type TVar    (OverrideDelay m) = LazySTM.TVar m
  newTVar :: forall a. a -> STM (OverrideDelay m) (TVar (OverrideDelay m) a)
newTVar     = ReaderT (StrictTVar m Schedule) (STM m) (TVar m a)
-> OverrideDelaySTM m (TVar m a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (TVar m a)
 -> OverrideDelaySTM m (TVar m a))
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) (TVar m a))
-> a
-> OverrideDelaySTM m (TVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (TVar m a)
-> ReaderT (StrictTVar m Schedule) (STM m) (TVar m a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (TVar m a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (TVar m a))
-> (a -> STM m (TVar m a))
-> a
-> ReaderT (StrictTVar m Schedule) (STM m) (TVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TVar m a)
forall a. a -> STM m (TVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TVar m a)
LazySTM.newTVar
  readTVar :: forall a. TVar (OverrideDelay m) a -> STM (OverrideDelay m) a
readTVar    = ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a)
-> (TVar m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> TVar m a
-> OverrideDelaySTM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (TVar m a -> STM m a)
-> TVar m a
-> ReaderT (StrictTVar m Schedule) (STM m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TVar m a -> STM m a
forall a. TVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> STM m a
LazySTM.readTVar
  writeTVar :: forall a. TVar (OverrideDelay m) a -> a -> STM (OverrideDelay m) ()
writeTVar TVar (OverrideDelay m) a
v = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> a
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (a -> STM m ())
-> a
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TVar m a -> a -> STM m ()
forall a. TVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m ()
LazySTM.writeTVar TVar m a
TVar (OverrideDelay m) a
v
  retry :: forall a. STM (OverrideDelay m) a
retry       = ReaderT (StrictTVar m Schedule) (STM m) a
-> STM (OverrideDelay m) a
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a
 -> STM (OverrideDelay m) a)
-> (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> STM m a
-> STM (OverrideDelay m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> STM (OverrideDelay m) a)
-> STM m a -> STM (OverrideDelay m) a
forall a b. (a -> b) -> a -> b
$ STM m a
forall a. STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a
retry
  orElse :: forall a.
STM (OverrideDelay m) a
-> STM (OverrideDelay m) a -> STM (OverrideDelay m) a
orElse (OverrideDelaySTM (ReaderT StrictTVar m Schedule -> STM m a
stm)) (OverrideDelaySTM (ReaderT StrictTVar m Schedule -> STM m a
stm')) =
    ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM ((StrictTVar m Schedule -> STM m a)
-> ReaderT (StrictTVar m Schedule) (STM m) a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((StrictTVar m Schedule -> STM m a)
 -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (StrictTVar m Schedule -> STM m a)
-> ReaderT (StrictTVar m Schedule) (STM m) a
forall a b. (a -> b) -> a -> b
$ \StrictTVar m Schedule
v -> StrictTVar m Schedule -> STM m a
stm StrictTVar m Schedule
v STM m a -> STM m a -> STM m a
forall a. STM m a -> STM m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => STM m a -> STM m a -> STM m a
`orElse` StrictTVar m Schedule -> STM m a
stm' StrictTVar m Schedule
v)
  modifyTVar :: forall a.
TVar (OverrideDelay m) a -> (a -> a) -> STM (OverrideDelay m) ()
modifyTVar TVar (OverrideDelay m) a
v = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> ((a -> a) -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (a -> a)
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> ((a -> a) -> STM m ())
-> (a -> a)
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TVar m a -> (a -> a) -> STM m ()
forall a. TVar m a -> (a -> a) -> STM m ()
forall (m :: * -> *) a.
MonadSTM m =>
TVar m a -> (a -> a) -> STM m ()
LazySTM.modifyTVar TVar m a
TVar (OverrideDelay m) a
v
  stateTVar :: forall s a.
TVar (OverrideDelay m) s
-> (s -> (a, s)) -> STM (OverrideDelay m) a
stateTVar  TVar (OverrideDelay m) s
v = ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a)
-> ((s -> (a, s)) -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (s -> (a, s))
-> OverrideDelaySTM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> ((s -> (a, s)) -> STM m a)
-> (s -> (a, s))
-> ReaderT (StrictTVar m Schedule) (STM m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TVar m s -> (s -> (a, s)) -> STM m a
forall s a. TVar m s -> (s -> (a, s)) -> STM m a
forall (m :: * -> *) s a.
MonadSTM m =>
TVar m s -> (s -> (a, s)) -> STM m a
LazySTM.stateTVar TVar m s
TVar (OverrideDelay m) s
v
  swapTVar :: forall a. TVar (OverrideDelay m) a -> a -> STM (OverrideDelay m) a
swapTVar   TVar (OverrideDelay m) a
v = ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a)
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> a
-> OverrideDelaySTM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (a -> STM m a) -> a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TVar m a -> a -> STM m a
forall a. TVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TVar m a -> a -> STM m a
LazySTM.swapTVar TVar m a
TVar (OverrideDelay m) a
v

  type TMVar   (OverrideDelay m) = LazySTM.TMVar m
  newTMVar :: forall a. a -> STM (OverrideDelay m) (TMVar (OverrideDelay m) a)
newTMVar      = ReaderT (StrictTVar m Schedule) (STM m) (TMVar m a)
-> OverrideDelaySTM m (TMVar m a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (TMVar m a)
 -> OverrideDelaySTM m (TMVar m a))
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) (TMVar m a))
-> a
-> OverrideDelaySTM m (TMVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (TMVar m a)
-> ReaderT (StrictTVar m Schedule) (STM m) (TMVar m a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (TMVar m a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (TMVar m a))
-> (a -> STM m (TMVar m a))
-> a
-> ReaderT (StrictTVar m Schedule) (STM m) (TMVar m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> STM m (TMVar m a)
forall a. a -> STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => a -> STM m (TMVar m a)
LazySTM.newTMVar
  newEmptyTMVar :: forall a. STM (OverrideDelay m) (TMVar (OverrideDelay m) a)
newEmptyTMVar = ReaderT (StrictTVar m Schedule) (STM m) (TMVar m a)
-> STM (OverrideDelay m) (TMVar (OverrideDelay m) a)
ReaderT (StrictTVar m Schedule) (STM m) (TMVar m a)
-> OverrideDelaySTM m (TMVar m a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (TMVar m a)
 -> STM (OverrideDelay m) (TMVar (OverrideDelay m) a))
-> (STM m (TMVar m a)
    -> ReaderT (StrictTVar m Schedule) (STM m) (TMVar m a))
-> STM m (TMVar m a)
-> STM (OverrideDelay m) (TMVar (OverrideDelay m) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (TMVar m a)
-> ReaderT (StrictTVar m Schedule) (STM m) (TMVar m a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (TMVar m a)
 -> STM (OverrideDelay m) (TMVar (OverrideDelay m) a))
-> STM m (TMVar m a)
-> STM (OverrideDelay m) (TMVar (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$ STM m (TMVar m a)
forall a. STM m (TMVar m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TMVar m a)
LazySTM.newEmptyTMVar
  takeTMVar :: forall a. TMVar (OverrideDelay m) a -> STM (OverrideDelay m) a
takeTMVar     = ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a)
-> (TMVar m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> TMVar m a
-> OverrideDelaySTM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (TMVar m a -> STM m a)
-> TMVar m a
-> ReaderT (StrictTVar m Schedule) (STM m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall a. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
LazySTM.takeTMVar
  tryTakeTMVar :: forall a.
TMVar (OverrideDelay m) a -> STM (OverrideDelay m) (Maybe a)
tryTakeTMVar  = ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
-> OverrideDelaySTM m (Maybe a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
 -> OverrideDelaySTM m (Maybe a))
-> (TMVar m a -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> TMVar m a
-> OverrideDelaySTM m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (Maybe a)
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (Maybe a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall a. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
LazySTM.tryTakeTMVar
  putTMVar :: forall a.
TMVar (OverrideDelay m) a -> a -> STM (OverrideDelay m) ()
putTMVar TMVar (OverrideDelay m) a
v    = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> a
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (a -> STM m ())
-> a
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> a -> STM m ()
forall a. TMVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m ()
LazySTM.putTMVar TMVar m a
TMVar (OverrideDelay m) a
v
  tryPutTMVar :: forall a.
TMVar (OverrideDelay m) a -> a -> STM (OverrideDelay m) Bool
tryPutTMVar TMVar (OverrideDelay m) a
v = ReaderT (StrictTVar m Schedule) (STM m) Bool
-> OverrideDelaySTM m Bool
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) Bool
 -> OverrideDelaySTM m Bool)
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) Bool)
-> a
-> OverrideDelaySTM m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m Bool -> ReaderT (StrictTVar m Schedule) (STM m) Bool
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m Bool -> ReaderT (StrictTVar m Schedule) (STM m) Bool)
-> (a -> STM m Bool)
-> a
-> ReaderT (StrictTVar m Schedule) (STM m) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> a -> STM m Bool
forall a. TMVar m a -> a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m Bool
LazySTM.tryPutTMVar TMVar m a
TMVar (OverrideDelay m) a
v
  readTMVar :: forall a. TMVar (OverrideDelay m) a -> STM (OverrideDelay m) a
readTMVar     = ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a)
-> (TMVar m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> TMVar m a
-> OverrideDelaySTM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (TMVar m a -> STM m a)
-> TMVar m a
-> ReaderT (StrictTVar m Schedule) (STM m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m a
forall a. TMVar m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m a
LazySTM.readTMVar
  writeTMVar :: forall a.
TMVar (OverrideDelay m) a -> a -> STM (OverrideDelay m) ()
writeTMVar TMVar (OverrideDelay m) a
v  = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> a
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (a -> STM m ())
-> a
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> a -> STM m ()
forall a. TMVar m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m ()
LazySTM.writeTMVar TMVar m a
TMVar (OverrideDelay m) a
v
  tryReadTMVar :: forall a.
TMVar (OverrideDelay m) a -> STM (OverrideDelay m) (Maybe a)
tryReadTMVar  = ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
-> OverrideDelaySTM m (Maybe a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
 -> OverrideDelaySTM m (Maybe a))
-> (TMVar m a -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> TMVar m a
-> OverrideDelaySTM m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (Maybe a)
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (Maybe a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> (TMVar m a -> STM m (Maybe a))
-> TMVar m a
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m (Maybe a)
forall a. TMVar m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m (Maybe a)
LazySTM.tryReadTMVar
  swapTMVar :: forall a. TMVar (OverrideDelay m) a -> a -> STM (OverrideDelay m) a
swapTMVar TMVar (OverrideDelay m) a
v   = ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a)
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> a
-> OverrideDelaySTM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (a -> STM m a) -> a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> a -> STM m a
forall a. TMVar m a -> a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> a -> STM m a
LazySTM.swapTMVar TMVar m a
TMVar (OverrideDelay m) a
v
  isEmptyTMVar :: forall a. TMVar (OverrideDelay m) a -> STM (OverrideDelay m) Bool
isEmptyTMVar  = ReaderT (StrictTVar m Schedule) (STM m) Bool
-> OverrideDelaySTM m Bool
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) Bool
 -> OverrideDelaySTM m Bool)
-> (TMVar m a -> ReaderT (StrictTVar m Schedule) (STM m) Bool)
-> TMVar m a
-> OverrideDelaySTM m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m Bool -> ReaderT (StrictTVar m Schedule) (STM m) Bool
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m Bool -> ReaderT (StrictTVar m Schedule) (STM m) Bool)
-> (TMVar m a -> STM m Bool)
-> TMVar m a
-> ReaderT (StrictTVar m Schedule) (STM m) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> STM m Bool
forall a. TMVar m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TMVar m a -> STM m Bool
LazySTM.isEmptyTMVar

  type TQueue  (OverrideDelay m) = LazySTM.TQueue m
  newTQueue :: forall a. STM (OverrideDelay m) (TQueue (OverrideDelay m) a)
newTQueue     = ReaderT (StrictTVar m Schedule) (STM m) (TQueue m a)
-> STM (OverrideDelay m) (TQueue (OverrideDelay m) a)
ReaderT (StrictTVar m Schedule) (STM m) (TQueue m a)
-> OverrideDelaySTM m (TQueue m a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (TQueue m a)
 -> STM (OverrideDelay m) (TQueue (OverrideDelay m) a))
-> (STM m (TQueue m a)
    -> ReaderT (StrictTVar m Schedule) (STM m) (TQueue m a))
-> STM m (TQueue m a)
-> STM (OverrideDelay m) (TQueue (OverrideDelay m) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (TQueue m a)
-> ReaderT (StrictTVar m Schedule) (STM m) (TQueue m a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (TQueue m a)
 -> STM (OverrideDelay m) (TQueue (OverrideDelay m) a))
-> STM m (TQueue m a)
-> STM (OverrideDelay m) (TQueue (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$ STM m (TQueue m a)
forall a. STM m (TQueue m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TQueue m a)
LazySTM.newTQueue
  readTQueue :: forall a. TQueue (OverrideDelay m) a -> STM (OverrideDelay m) a
readTQueue    = ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a)
-> (TQueue m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> TQueue m a
-> OverrideDelaySTM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (TQueue m a -> STM m a)
-> TQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall a. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
LazySTM.readTQueue
  tryReadTQueue :: forall a.
TQueue (OverrideDelay m) a -> STM (OverrideDelay m) (Maybe a)
tryReadTQueue = ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
-> OverrideDelaySTM m (Maybe a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
 -> OverrideDelaySTM m (Maybe a))
-> (TQueue m a
    -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> TQueue m a
-> OverrideDelaySTM m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (Maybe a)
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (Maybe a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall a. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
LazySTM.tryReadTQueue
  peekTQueue :: forall a. TQueue (OverrideDelay m) a -> STM (OverrideDelay m) a
peekTQueue    = ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a)
-> (TQueue m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> TQueue m a
-> OverrideDelaySTM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (TQueue m a -> STM m a)
-> TQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m a
forall a. TQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m a
LazySTM.peekTQueue
  tryPeekTQueue :: forall a.
TQueue (OverrideDelay m) a -> STM (OverrideDelay m) (Maybe a)
tryPeekTQueue = ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
-> OverrideDelaySTM m (Maybe a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
 -> OverrideDelaySTM m (Maybe a))
-> (TQueue m a
    -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> TQueue m a
-> OverrideDelaySTM m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (Maybe a)
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (Maybe a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> (TQueue m a -> STM m (Maybe a))
-> TQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m (Maybe a)
forall a. TQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m (Maybe a)
LazySTM.tryPeekTQueue
  writeTQueue :: forall a.
TQueue (OverrideDelay m) a -> a -> STM (OverrideDelay m) ()
writeTQueue TQueue (OverrideDelay m) a
v = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> a
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (a -> STM m ())
-> a
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> a -> STM m ()
forall a. TQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> a -> STM m ()
LazySTM.writeTQueue TQueue m a
TQueue (OverrideDelay m) a
v
  isEmptyTQueue :: forall a. TQueue (OverrideDelay m) a -> STM (OverrideDelay m) Bool
isEmptyTQueue = ReaderT (StrictTVar m Schedule) (STM m) Bool
-> OverrideDelaySTM m Bool
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) Bool
 -> OverrideDelaySTM m Bool)
-> (TQueue m a -> ReaderT (StrictTVar m Schedule) (STM m) Bool)
-> TQueue m a
-> OverrideDelaySTM m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m Bool -> ReaderT (StrictTVar m Schedule) (STM m) Bool
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m Bool -> ReaderT (StrictTVar m Schedule) (STM m) Bool)
-> (TQueue m a -> STM m Bool)
-> TQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m Bool
forall a. TQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m Bool
LazySTM.isEmptyTQueue
  flushTQueue :: forall a. TQueue (OverrideDelay m) a -> STM (OverrideDelay m) [a]
flushTQueue   = ReaderT (StrictTVar m Schedule) (STM m) [a]
-> OverrideDelaySTM m [a]
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) [a]
 -> OverrideDelaySTM m [a])
-> (TQueue m a -> ReaderT (StrictTVar m Schedule) (STM m) [a])
-> TQueue m a
-> OverrideDelaySTM m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m [a] -> ReaderT (StrictTVar m Schedule) (STM m) [a]
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m [a] -> ReaderT (StrictTVar m Schedule) (STM m) [a])
-> (TQueue m a -> STM m [a])
-> TQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> STM m [a]
forall a. TQueue m a -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> STM m [a]
LazySTM.flushTQueue
  unGetTQueue :: forall a.
TQueue (OverrideDelay m) a -> a -> STM (OverrideDelay m) ()
unGetTQueue TQueue (OverrideDelay m) a
v = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> a
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (a -> STM m ())
-> a
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> a -> STM m ()
forall a. TQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TQueue m a -> a -> STM m ()
LazySTM.unGetTQueue TQueue m a
TQueue (OverrideDelay m) a
v

  type TBQueue (OverrideDelay m) = LazySTM.TBQueue m
  newTBQueue :: forall a.
Natural -> STM (OverrideDelay m) (TBQueue (OverrideDelay m) a)
newTBQueue     = ReaderT (StrictTVar m Schedule) (STM m) (TBQueue m a)
-> OverrideDelaySTM m (TBQueue m a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (TBQueue m a)
 -> OverrideDelaySTM m (TBQueue m a))
-> (Natural
    -> ReaderT (StrictTVar m Schedule) (STM m) (TBQueue m a))
-> Natural
-> OverrideDelaySTM m (TBQueue m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (TBQueue m a)
-> ReaderT (StrictTVar m Schedule) (STM m) (TBQueue m a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (TBQueue m a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (TBQueue m a))
-> (Natural -> STM m (TBQueue m a))
-> Natural
-> ReaderT (StrictTVar m Schedule) (STM m) (TBQueue m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> STM m (TBQueue m a)
forall a. Natural -> STM m (TBQueue m a)
forall (m :: * -> *) a.
MonadSTM m =>
Natural -> STM m (TBQueue m a)
LazySTM.newTBQueue
  readTBQueue :: forall a. TBQueue (OverrideDelay m) a -> STM (OverrideDelay m) a
readTBQueue    = ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a)
-> (TBQueue m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> TBQueue m a
-> OverrideDelaySTM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall a. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
LazySTM.readTBQueue
  tryReadTBQueue :: forall a.
TBQueue (OverrideDelay m) a -> STM (OverrideDelay m) (Maybe a)
tryReadTBQueue = ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
-> OverrideDelaySTM m (Maybe a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
 -> OverrideDelaySTM m (Maybe a))
-> (TBQueue m a
    -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> TBQueue m a
-> OverrideDelaySTM m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (Maybe a)
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (Maybe a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall a. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
LazySTM.tryReadTBQueue
  peekTBQueue :: forall a. TBQueue (OverrideDelay m) a -> STM (OverrideDelay m) a
peekTBQueue    = ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a)
-> (TBQueue m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> TBQueue m a
-> OverrideDelaySTM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (TBQueue m a -> STM m a)
-> TBQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m a
forall a. TBQueue m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m a
LazySTM.peekTBQueue
  tryPeekTBQueue :: forall a.
TBQueue (OverrideDelay m) a -> STM (OverrideDelay m) (Maybe a)
tryPeekTBQueue = ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
-> OverrideDelaySTM m (Maybe a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
 -> OverrideDelaySTM m (Maybe a))
-> (TBQueue m a
    -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> TBQueue m a
-> OverrideDelaySTM m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (Maybe a)
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (Maybe a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> (TBQueue m a -> STM m (Maybe a))
-> TBQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m (Maybe a)
forall a. TBQueue m a -> STM m (Maybe a)
forall (m :: * -> *) a.
MonadSTM m =>
TBQueue m a -> STM m (Maybe a)
LazySTM.tryPeekTBQueue
  writeTBQueue :: forall a.
TBQueue (OverrideDelay m) a -> a -> STM (OverrideDelay m) ()
writeTBQueue TBQueue (OverrideDelay m) a
v = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> a
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (a -> STM m ())
-> a
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> a -> STM m ()
forall a. TBQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> a -> STM m ()
LazySTM.writeTBQueue TBQueue m a
TBQueue (OverrideDelay m) a
v
  lengthTBQueue :: forall a.
TBQueue (OverrideDelay m) a -> STM (OverrideDelay m) Natural
lengthTBQueue  = ReaderT (StrictTVar m Schedule) (STM m) Natural
-> OverrideDelaySTM m Natural
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) Natural
 -> OverrideDelaySTM m Natural)
-> (TBQueue m a -> ReaderT (StrictTVar m Schedule) (STM m) Natural)
-> TBQueue m a
-> OverrideDelaySTM m Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m Natural -> ReaderT (StrictTVar m Schedule) (STM m) Natural
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m Natural -> ReaderT (StrictTVar m Schedule) (STM m) Natural)
-> (TBQueue m a -> STM m Natural)
-> TBQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Natural
forall a. TBQueue m a -> STM m Natural
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Natural
LazySTM.lengthTBQueue
  isEmptyTBQueue :: forall a. TBQueue (OverrideDelay m) a -> STM (OverrideDelay m) Bool
isEmptyTBQueue = ReaderT (StrictTVar m Schedule) (STM m) Bool
-> OverrideDelaySTM m Bool
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) Bool
 -> OverrideDelaySTM m Bool)
-> (TBQueue m a -> ReaderT (StrictTVar m Schedule) (STM m) Bool)
-> TBQueue m a
-> OverrideDelaySTM m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m Bool -> ReaderT (StrictTVar m Schedule) (STM m) Bool
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m Bool -> ReaderT (StrictTVar m Schedule) (STM m) Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall a. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
LazySTM.isEmptyTBQueue
  isFullTBQueue :: forall a. TBQueue (OverrideDelay m) a -> STM (OverrideDelay m) Bool
isFullTBQueue  = ReaderT (StrictTVar m Schedule) (STM m) Bool
-> OverrideDelaySTM m Bool
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) Bool
 -> OverrideDelaySTM m Bool)
-> (TBQueue m a -> ReaderT (StrictTVar m Schedule) (STM m) Bool)
-> TBQueue m a
-> OverrideDelaySTM m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m Bool -> ReaderT (StrictTVar m Schedule) (STM m) Bool
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m Bool -> ReaderT (StrictTVar m Schedule) (STM m) Bool)
-> (TBQueue m a -> STM m Bool)
-> TBQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m Bool
forall a. TBQueue m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m Bool
LazySTM.isFullTBQueue
  flushTBQueue :: forall a. TBQueue (OverrideDelay m) a -> STM (OverrideDelay m) [a]
flushTBQueue   = ReaderT (StrictTVar m Schedule) (STM m) [a]
-> OverrideDelaySTM m [a]
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) [a]
 -> OverrideDelaySTM m [a])
-> (TBQueue m a -> ReaderT (StrictTVar m Schedule) (STM m) [a])
-> TBQueue m a
-> OverrideDelaySTM m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m [a] -> ReaderT (StrictTVar m Schedule) (STM m) [a]
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m [a] -> ReaderT (StrictTVar m Schedule) (STM m) [a])
-> (TBQueue m a -> STM m [a])
-> TBQueue m a
-> ReaderT (StrictTVar m Schedule) (STM m) [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> STM m [a]
forall a. TBQueue m a -> STM m [a]
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> STM m [a]
LazySTM.flushTBQueue
  unGetTBQueue :: forall a.
TBQueue (OverrideDelay m) a -> a -> STM (OverrideDelay m) ()
unGetTBQueue TBQueue (OverrideDelay m) a
v = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> a
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (a -> STM m ())
-> a
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> a -> STM m ()
forall a. TBQueue m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TBQueue m a -> a -> STM m ()
LazySTM.unGetTBQueue TBQueue m a
TBQueue (OverrideDelay m) a
v

  type TArray  (OverrideDelay m) = LazySTM.TArray m

  type TSem    (OverrideDelay m) = LazySTM.TSem m
  newTSem :: Integer -> STM (OverrideDelay m) (TSem (OverrideDelay m))
newTSem        = ReaderT (StrictTVar m Schedule) (STM m) (TSem m)
-> OverrideDelaySTM m (TSem m)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (TSem m)
 -> OverrideDelaySTM m (TSem m))
-> (Integer -> ReaderT (StrictTVar m Schedule) (STM m) (TSem m))
-> Integer
-> OverrideDelaySTM m (TSem m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (TSem m) -> ReaderT (StrictTVar m Schedule) (STM m) (TSem m)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (TSem m)
 -> ReaderT (StrictTVar m Schedule) (STM m) (TSem m))
-> (Integer -> STM m (TSem m))
-> Integer
-> ReaderT (StrictTVar m Schedule) (STM m) (TSem m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> STM m (TSem m)
forall (m :: * -> *). MonadSTM m => Integer -> STM m (TSem m)
LazySTM.newTSem
  waitTSem :: TSem (OverrideDelay m) -> STM (OverrideDelay m) ()
waitTSem       = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (TSem m -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> TSem m
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (TSem m -> STM m ())
-> TSem m
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TSem m -> STM m ()
forall (m :: * -> *). MonadSTM m => TSem m -> STM m ()
LazySTM.waitTSem
  signalTSem :: TSem (OverrideDelay m) -> STM (OverrideDelay m) ()
signalTSem     = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (TSem m -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> TSem m
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (TSem m -> STM m ())
-> TSem m
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TSem m -> STM m ()
forall (m :: * -> *). MonadSTM m => TSem m -> STM m ()
LazySTM.signalTSem
  signalTSemN :: Natural -> TSem (OverrideDelay m) -> STM (OverrideDelay m) ()
signalTSemN Natural
v  = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (TSem m -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> TSem m
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (TSem m -> STM m ())
-> TSem m
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> TSem m -> STM m ()
forall (m :: * -> *). MonadSTM m => Natural -> TSem m -> STM m ()
LazySTM.signalTSemN Natural
v

  type TChan   (OverrideDelay m) = LazySTM.TChan m
  newTChan :: forall a. STM (OverrideDelay m) (TChan (OverrideDelay m) a)
newTChan          = ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
-> STM (OverrideDelay m) (TChan (OverrideDelay m) a)
ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
-> OverrideDelaySTM m (TChan m a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
 -> STM (OverrideDelay m) (TChan (OverrideDelay m) a))
-> (STM m (TChan m a)
    -> ReaderT (StrictTVar m Schedule) (STM m) (TChan m a))
-> STM m (TChan m a)
-> STM (OverrideDelay m) (TChan (OverrideDelay m) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (TChan m a)
-> ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (TChan m a)
 -> STM (OverrideDelay m) (TChan (OverrideDelay m) a))
-> STM m (TChan m a)
-> STM (OverrideDelay m) (TChan (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$  STM m (TChan m a)
forall a. STM m (TChan m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TChan m a)
LazySTM.newTChan
  newBroadcastTChan :: forall a. STM (OverrideDelay m) (TChan (OverrideDelay m) a)
newBroadcastTChan = ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
-> STM (OverrideDelay m) (TChan (OverrideDelay m) a)
ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
-> OverrideDelaySTM m (TChan m a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
 -> STM (OverrideDelay m) (TChan (OverrideDelay m) a))
-> (STM m (TChan m a)
    -> ReaderT (StrictTVar m Schedule) (STM m) (TChan m a))
-> STM m (TChan m a)
-> STM (OverrideDelay m) (TChan (OverrideDelay m) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (TChan m a)
-> ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (TChan m a)
 -> STM (OverrideDelay m) (TChan (OverrideDelay m) a))
-> STM m (TChan m a)
-> STM (OverrideDelay m) (TChan (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$ STM m (TChan m a)
forall a. STM m (TChan m a)
forall (m :: * -> *) a. MonadSTM m => STM m (TChan m a)
LazySTM.newBroadcastTChan
  dupTChan :: forall a.
TChan (OverrideDelay m) a
-> STM (OverrideDelay m) (TChan (OverrideDelay m) a)
dupTChan          = ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
-> OverrideDelaySTM m (TChan m a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
 -> OverrideDelaySTM m (TChan m a))
-> (TChan m a
    -> ReaderT (StrictTVar m Schedule) (STM m) (TChan m a))
-> TChan m a
-> OverrideDelaySTM m (TChan m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (TChan m a)
-> ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (TChan m a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (TChan m a))
-> (TChan m a -> STM m (TChan m a))
-> TChan m a
-> ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TChan m a -> STM m (TChan m a)
forall a. TChan m a -> STM m (TChan m a)
forall (m :: * -> *) a.
MonadSTM m =>
TChan m a -> STM m (TChan m a)
LazySTM.dupTChan
  cloneTChan :: forall a.
TChan (OverrideDelay m) a
-> STM (OverrideDelay m) (TChan (OverrideDelay m) a)
cloneTChan        = ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
-> OverrideDelaySTM m (TChan m a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
 -> OverrideDelaySTM m (TChan m a))
-> (TChan m a
    -> ReaderT (StrictTVar m Schedule) (STM m) (TChan m a))
-> TChan m a
-> OverrideDelaySTM m (TChan m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (TChan m a)
-> ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (TChan m a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (TChan m a))
-> (TChan m a -> STM m (TChan m a))
-> TChan m a
-> ReaderT (StrictTVar m Schedule) (STM m) (TChan m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TChan m a -> STM m (TChan m a)
forall a. TChan m a -> STM m (TChan m a)
forall (m :: * -> *) a.
MonadSTM m =>
TChan m a -> STM m (TChan m a)
LazySTM.cloneTChan
  readTChan :: forall a. TChan (OverrideDelay m) a -> STM (OverrideDelay m) a
readTChan         = ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a)
-> (TChan m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> TChan m a
-> OverrideDelaySTM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (TChan m a -> STM m a)
-> TChan m a
-> ReaderT (StrictTVar m Schedule) (STM m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TChan m a -> STM m a
forall a. TChan m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TChan m a -> STM m a
LazySTM.readTChan
  tryReadTChan :: forall a.
TChan (OverrideDelay m) a -> STM (OverrideDelay m) (Maybe a)
tryReadTChan      = ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
-> OverrideDelaySTM m (Maybe a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
 -> OverrideDelaySTM m (Maybe a))
-> (TChan m a -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> TChan m a
-> OverrideDelaySTM m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (Maybe a)
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (Maybe a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> (TChan m a -> STM m (Maybe a))
-> TChan m a
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TChan m a -> STM m (Maybe a)
forall a. TChan m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TChan m a -> STM m (Maybe a)
LazySTM.tryReadTChan
  peekTChan :: forall a. TChan (OverrideDelay m) a -> STM (OverrideDelay m) a
peekTChan         = ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a)
-> (TChan m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> TChan m a
-> OverrideDelaySTM m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m a -> ReaderT (StrictTVar m Schedule) (STM m) a)
-> (TChan m a -> STM m a)
-> TChan m a
-> ReaderT (StrictTVar m Schedule) (STM m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TChan m a -> STM m a
forall a. TChan m a -> STM m a
forall (m :: * -> *) a. MonadSTM m => TChan m a -> STM m a
LazySTM.peekTChan
  tryPeekTChan :: forall a.
TChan (OverrideDelay m) a -> STM (OverrideDelay m) (Maybe a)
tryPeekTChan      = ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
-> OverrideDelaySTM m (Maybe a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
 -> OverrideDelaySTM m (Maybe a))
-> (TChan m a -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> TChan m a
-> OverrideDelaySTM m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (Maybe a)
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (Maybe a)
 -> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a))
-> (TChan m a -> STM m (Maybe a))
-> TChan m a
-> ReaderT (StrictTVar m Schedule) (STM m) (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TChan m a -> STM m (Maybe a)
forall a. TChan m a -> STM m (Maybe a)
forall (m :: * -> *) a. MonadSTM m => TChan m a -> STM m (Maybe a)
LazySTM.tryPeekTChan
  writeTChan :: forall a.
TChan (OverrideDelay m) a -> a -> STM (OverrideDelay m) ()
writeTChan TChan (OverrideDelay m) a
v      = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> a
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (a -> STM m ())
-> a
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TChan m a -> a -> STM m ()
forall a. TChan m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TChan m a -> a -> STM m ()
LazySTM.writeTChan TChan m a
TChan (OverrideDelay m) a
v
  unGetTChan :: forall a.
TChan (OverrideDelay m) a -> a -> STM (OverrideDelay m) ()
unGetTChan TChan (OverrideDelay m) a
v      = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (a -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> a
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (a -> STM m ())
-> a
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TChan m a -> a -> STM m ()
forall a. TChan m a -> a -> STM m ()
forall (m :: * -> *) a. MonadSTM m => TChan m a -> a -> STM m ()
LazySTM.unGetTChan TChan m a
TChan (OverrideDelay m) a
v
  isEmptyTChan :: forall a. TChan (OverrideDelay m) a -> STM (OverrideDelay m) Bool
isEmptyTChan      = ReaderT (StrictTVar m Schedule) (STM m) Bool
-> OverrideDelaySTM m Bool
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) Bool
 -> OverrideDelaySTM m Bool)
-> (TChan m a -> ReaderT (StrictTVar m Schedule) (STM m) Bool)
-> TChan m a
-> OverrideDelaySTM m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m Bool -> ReaderT (StrictTVar m Schedule) (STM m) Bool
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m Bool -> ReaderT (StrictTVar m Schedule) (STM m) Bool)
-> (TChan m a -> STM m Bool)
-> TChan m a
-> ReaderT (StrictTVar m Schedule) (STM m) Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TChan m a -> STM m Bool
forall a. TChan m a -> STM m Bool
forall (m :: * -> *) a. MonadSTM m => TChan m a -> STM m Bool
LazySTM.isEmptyTChan

instance MonadLabelledSTM m => MonadLabelledSTM (OverrideDelay m) where
  labelTVar :: forall a.
TVar (OverrideDelay m) a -> TestName -> STM (OverrideDelay m) ()
labelTVar TVar (OverrideDelay m) a
v    = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (TestName -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> TestName
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (TestName -> STM m ())
-> TestName
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TVar m a -> TestName -> STM m ()
forall a. TVar m a -> TestName -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TVar m a -> TestName -> STM m ()
LazySTM.labelTVar TVar m a
TVar (OverrideDelay m) a
v
  labelTMVar :: forall a.
TMVar (OverrideDelay m) a -> TestName -> STM (OverrideDelay m) ()
labelTMVar TMVar (OverrideDelay m) a
v   = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (TestName -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> TestName
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (TestName -> STM m ())
-> TestName
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> TestName -> STM m ()
forall a. TMVar m a -> TestName -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TMVar m a -> TestName -> STM m ()
LazySTM.labelTMVar TMVar m a
TMVar (OverrideDelay m) a
v
  labelTQueue :: forall a.
TQueue (OverrideDelay m) a -> TestName -> STM (OverrideDelay m) ()
labelTQueue TQueue (OverrideDelay m) a
v  = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (TestName -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> TestName
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (TestName -> STM m ())
-> TestName
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> TestName -> STM m ()
forall a. TQueue m a -> TestName -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TQueue m a -> TestName -> STM m ()
LazySTM.labelTQueue TQueue m a
TQueue (OverrideDelay m) a
v
  labelTBQueue :: forall a.
TBQueue (OverrideDelay m) a -> TestName -> STM (OverrideDelay m) ()
labelTBQueue TBQueue (OverrideDelay m) a
v = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (TestName -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> TestName
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (TestName -> STM m ())
-> TestName
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> TestName -> STM m ()
forall a. TBQueue m a -> TestName -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TBQueue m a -> TestName -> STM m ()
LazySTM.labelTBQueue TBQueue m a
TBQueue (OverrideDelay m) a
v
  labelTArray :: forall i e.
(Ix i, Show i) =>
TArray (OverrideDelay m) i e
-> TestName -> STM (OverrideDelay m) ()
labelTArray TArray (OverrideDelay m) i e
v  = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (TestName -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> TestName
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (TestName -> STM m ())
-> TestName
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TArray m i e -> TestName -> STM m ()
forall i e. (Ix i, Show i) => TArray m i e -> TestName -> STM m ()
forall (m :: * -> *) i e.
(MonadLabelledSTM m, Ix i, Show i) =>
TArray m i e -> TestName -> STM m ()
LazySTM.labelTArray TArray m i e
TArray (OverrideDelay m) i e
v
  labelTSem :: TSem (OverrideDelay m) -> TestName -> STM (OverrideDelay m) ()
labelTSem TSem (OverrideDelay m)
v    = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (TestName -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> TestName
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (TestName -> STM m ())
-> TestName
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TSem m -> TestName -> STM m ()
forall (m :: * -> *).
MonadLabelledSTM m =>
TSem m -> TestName -> STM m ()
LazySTM.labelTSem TSem m
TSem (OverrideDelay m)
v
  labelTChan :: forall a.
TChan (OverrideDelay m) a -> TestName -> STM (OverrideDelay m) ()
labelTChan TChan (OverrideDelay m) a
v   = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> (TestName -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> TestName
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (TestName -> STM m ())
-> TestName
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TChan m a -> TestName -> STM m ()
forall a. TChan m a -> TestName -> STM m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TChan m a -> TestName -> STM m ()
LazySTM.labelTChan TChan m a
TChan (OverrideDelay m) a
v

  labelTVarIO :: forall a.
TVar (OverrideDelay m) a -> TestName -> OverrideDelay m ()
labelTVarIO TVar (OverrideDelay m) a
v    = ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ())
-> (TestName -> ReaderT (StrictTVar m Schedule) m ())
-> TestName
-> OverrideDelay m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m () -> ReaderT (StrictTVar m Schedule) m ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT (StrictTVar m Schedule) m ())
-> (TestName -> m ())
-> TestName
-> ReaderT (StrictTVar m Schedule) m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TVar m a -> TestName -> m ()
forall a. TVar m a -> TestName -> m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TVar m a -> TestName -> m ()
LazySTM.labelTVarIO TVar m a
TVar (OverrideDelay m) a
v
  labelTMVarIO :: forall a.
TMVar (OverrideDelay m) a -> TestName -> OverrideDelay m ()
labelTMVarIO TMVar (OverrideDelay m) a
v   = ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ())
-> (TestName -> ReaderT (StrictTVar m Schedule) m ())
-> TestName
-> OverrideDelay m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m () -> ReaderT (StrictTVar m Schedule) m ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT (StrictTVar m Schedule) m ())
-> (TestName -> m ())
-> TestName
-> ReaderT (StrictTVar m Schedule) m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TMVar m a -> TestName -> m ()
forall a. TMVar m a -> TestName -> m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TMVar m a -> TestName -> m ()
LazySTM.labelTMVarIO TMVar m a
TMVar (OverrideDelay m) a
v
  labelTQueueIO :: forall a.
TQueue (OverrideDelay m) a -> TestName -> OverrideDelay m ()
labelTQueueIO TQueue (OverrideDelay m) a
v  = ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ())
-> (TestName -> ReaderT (StrictTVar m Schedule) m ())
-> TestName
-> OverrideDelay m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m () -> ReaderT (StrictTVar m Schedule) m ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT (StrictTVar m Schedule) m ())
-> (TestName -> m ())
-> TestName
-> ReaderT (StrictTVar m Schedule) m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TQueue m a -> TestName -> m ()
forall a. TQueue m a -> TestName -> m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TQueue m a -> TestName -> m ()
LazySTM.labelTQueueIO TQueue m a
TQueue (OverrideDelay m) a
v
  labelTBQueueIO :: forall a.
TBQueue (OverrideDelay m) a -> TestName -> OverrideDelay m ()
labelTBQueueIO TBQueue (OverrideDelay m) a
v = ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ())
-> (TestName -> ReaderT (StrictTVar m Schedule) m ())
-> TestName
-> OverrideDelay m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m () -> ReaderT (StrictTVar m Schedule) m ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT (StrictTVar m Schedule) m ())
-> (TestName -> m ())
-> TestName
-> ReaderT (StrictTVar m Schedule) m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TBQueue m a -> TestName -> m ()
forall a. TBQueue m a -> TestName -> m ()
forall (m :: * -> *) a.
MonadLabelledSTM m =>
TBQueue m a -> TestName -> m ()
LazySTM.labelTBQueueIO TBQueue m a
TBQueue (OverrideDelay m) a
v

instance MonadInspectSTM m => MonadInspectSTM (OverrideDelay m) where
  type InspectMonad (OverrideDelay m) = InspectMonad m
  inspectTVar :: forall (proxy :: (* -> *) -> *) a.
proxy (OverrideDelay m)
-> TVar (OverrideDelay m) a -> InspectMonad (OverrideDelay m) a
inspectTVar proxy (OverrideDelay m)
_  = Proxy m -> TVar m a -> InspectMonad m a
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadInspectSTM m =>
proxy m -> TVar m a -> InspectMonad m a
forall (proxy :: (* -> *) -> *) a.
proxy m -> TVar m a -> InspectMonad m a
inspectTVar (Proxy m
forall {k} (t :: k). Proxy t
Proxy :: Proxy m)
  inspectTMVar :: forall (proxy :: (* -> *) -> *) a.
proxy (OverrideDelay m)
-> TMVar (OverrideDelay m) a
-> InspectMonad (OverrideDelay m) (Maybe a)
inspectTMVar proxy (OverrideDelay m)
_ = Proxy m -> TMVar m a -> InspectMonad m (Maybe a)
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadInspectSTM m =>
proxy m -> TMVar m a -> InspectMonad m (Maybe a)
forall (proxy :: (* -> *) -> *) a.
proxy m -> TMVar m a -> InspectMonad m (Maybe a)
inspectTMVar (Proxy m
forall {k} (t :: k). Proxy t
Proxy :: Proxy m)

instance MonadTraceSTM m => MonadTraceSTM (OverrideDelay m) where
  traceTVar :: forall (proxy :: (* -> *) -> *) a.
proxy (OverrideDelay m)
-> TVar (OverrideDelay m) a
-> (Maybe a -> a -> InspectMonad (OverrideDelay m) TraceValue)
-> STM (OverrideDelay m) ()
traceTVar proxy (OverrideDelay m)
_ TVar (OverrideDelay m) a
v    = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> ((Maybe a -> a -> InspectMonad m TraceValue)
    -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (Maybe a -> a -> InspectMonad m TraceValue)
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> ((Maybe a -> a -> InspectMonad m TraceValue) -> STM m ())
-> (Maybe a -> a -> InspectMonad m TraceValue)
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy m
-> TVar m a
-> (Maybe a -> a -> InspectMonad m TraceValue)
-> STM m ()
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadTraceSTM m =>
proxy m
-> TVar m a
-> (Maybe a -> a -> InspectMonad m TraceValue)
-> STM m ()
forall (proxy :: (* -> *) -> *) a.
proxy m
-> TVar m a
-> (Maybe a -> a -> InspectMonad m TraceValue)
-> STM m ()
LazySTM.traceTVar Proxy m
forall {k} (t :: k). Proxy t
Proxy TVar m a
TVar (OverrideDelay m) a
v
  traceTMVar :: forall (proxy :: (* -> *) -> *) a.
proxy (OverrideDelay m)
-> TMVar (OverrideDelay m) a
-> (Maybe (Maybe a)
    -> Maybe a -> InspectMonad (OverrideDelay m) TraceValue)
-> STM (OverrideDelay m) ()
traceTMVar proxy (OverrideDelay m)
_ TMVar (OverrideDelay m) a
v   = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> ((Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
    -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> ((Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
    -> STM m ())
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy m
-> TMVar m a
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
-> STM m ()
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadTraceSTM m =>
proxy m
-> TMVar m a
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
-> STM m ()
forall (proxy :: (* -> *) -> *) a.
proxy m
-> TMVar m a
-> (Maybe (Maybe a) -> Maybe a -> InspectMonad m TraceValue)
-> STM m ()
LazySTM.traceTMVar Proxy m
forall {k} (t :: k). Proxy t
Proxy TMVar m a
TMVar (OverrideDelay m) a
v
  traceTQueue :: forall (proxy :: (* -> *) -> *) a.
proxy (OverrideDelay m)
-> TQueue (OverrideDelay m) a
-> (Maybe [a] -> [a] -> InspectMonad (OverrideDelay m) TraceValue)
-> STM (OverrideDelay m) ()
traceTQueue proxy (OverrideDelay m)
_ TQueue (OverrideDelay m) a
v  = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> ((Maybe [a] -> [a] -> InspectMonad m TraceValue)
    -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> ((Maybe [a] -> [a] -> InspectMonad m TraceValue) -> STM m ())
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy m
-> TQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadTraceSTM m =>
proxy m
-> TQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
forall (proxy :: (* -> *) -> *) a.
proxy m
-> TQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
LazySTM.traceTQueue Proxy m
forall {k} (t :: k). Proxy t
Proxy TQueue m a
TQueue (OverrideDelay m) a
v
  traceTBQueue :: forall (proxy :: (* -> *) -> *) a.
proxy (OverrideDelay m)
-> TBQueue (OverrideDelay m) a
-> (Maybe [a] -> [a] -> InspectMonad (OverrideDelay m) TraceValue)
-> STM (OverrideDelay m) ()
traceTBQueue proxy (OverrideDelay m)
_ TBQueue (OverrideDelay m) a
v = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> ((Maybe [a] -> [a] -> InspectMonad m TraceValue)
    -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> ((Maybe [a] -> [a] -> InspectMonad m TraceValue) -> STM m ())
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy m
-> TBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
forall (m :: * -> *) (proxy :: (* -> *) -> *) a.
MonadTraceSTM m =>
proxy m
-> TBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
forall (proxy :: (* -> *) -> *) a.
proxy m
-> TBQueue m a
-> (Maybe [a] -> [a] -> InspectMonad m TraceValue)
-> STM m ()
LazySTM.traceTBQueue Proxy m
forall {k} (t :: k). Proxy t
Proxy TBQueue m a
TBQueue (OverrideDelay m) a
v
  traceTSem :: forall (proxy :: (* -> *) -> *).
proxy (OverrideDelay m)
-> TSem (OverrideDelay m)
-> (Maybe Integer
    -> Integer -> InspectMonad (OverrideDelay m) TraceValue)
-> STM (OverrideDelay m) ()
traceTSem proxy (OverrideDelay m)
_ TSem (OverrideDelay m)
v    = ReaderT (StrictTVar m Schedule) (STM m) () -> OverrideDelaySTM m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) ()
 -> OverrideDelaySTM m ())
-> ((Maybe Integer -> Integer -> InspectMonad m TraceValue)
    -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> (Maybe Integer -> Integer -> InspectMonad m TraceValue)
-> OverrideDelaySTM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m () -> ReaderT (StrictTVar m Schedule) (STM m) ())
-> ((Maybe Integer -> Integer -> InspectMonad m TraceValue)
    -> STM m ())
-> (Maybe Integer -> Integer -> InspectMonad m TraceValue)
-> ReaderT (StrictTVar m Schedule) (STM m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy m
-> TSem m
-> (Maybe Integer -> Integer -> InspectMonad m TraceValue)
-> STM m ()
forall (m :: * -> *) (proxy :: (* -> *) -> *).
MonadTraceSTM m =>
proxy m
-> TSem m
-> (Maybe Integer -> Integer -> InspectMonad m TraceValue)
-> STM m ()
forall (proxy :: (* -> *) -> *).
proxy m
-> TSem m
-> (Maybe Integer -> Integer -> InspectMonad m TraceValue)
-> STM m ()
LazySTM.traceTSem Proxy m
forall {k} (t :: k). Proxy t
Proxy TSem m
TSem (OverrideDelay m)
v

newtype OverrideDelayAsync m a = OverrideDelayAsync {
    forall (m :: * -> *) a. OverrideDelayAsync m a -> Async m a
unOverrideDelayAsync :: Async m a
  }

instance (MonadAsync m, MonadMask m, MonadThrow (STM m)) => MonadAsync (OverrideDelay m) where
  type Async (OverrideDelay m) = OverrideDelayAsync m
  async :: forall a.
OverrideDelay m a -> OverrideDelay m (Async (OverrideDelay m) a)
async OverrideDelay m a
io = ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
-> OverrideDelay m (Async (OverrideDelay m) a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
 -> OverrideDelay m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
-> OverrideDelay m (Async (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$ (StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
 -> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a))
-> (StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$
    \StrictTVar m Schedule
schedule -> Async m a -> OverrideDelayAsync m a
forall (m :: * -> *) a. Async m a -> OverrideDelayAsync m a
OverrideDelayAsync (Async m a -> OverrideDelayAsync m a)
-> m (Async m a) -> m (OverrideDelayAsync m a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a -> m (Async m a)
forall a. m a -> m (Async m a)
forall (m :: * -> *) a. MonadAsync m => m a -> m (Async m a)
async (ReaderT (StrictTVar m Schedule) m a -> StrictTVar m Schedule -> m a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
forall (m :: * -> *) a.
OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
unOverrideDelay OverrideDelay m a
io) StrictTVar m Schedule
schedule)
  asyncBound :: forall a.
OverrideDelay m a -> OverrideDelay m (Async (OverrideDelay m) a)
asyncBound OverrideDelay m a
io = ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
-> OverrideDelay m (Async (OverrideDelay m) a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
 -> OverrideDelay m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
-> OverrideDelay m (Async (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$ (StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
 -> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a))
-> (StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$
    \StrictTVar m Schedule
schedule -> Async m a -> OverrideDelayAsync m a
forall (m :: * -> *) a. Async m a -> OverrideDelayAsync m a
OverrideDelayAsync (Async m a -> OverrideDelayAsync m a)
-> m (Async m a) -> m (OverrideDelayAsync m a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a -> m (Async m a)
forall a. m a -> m (Async m a)
forall (m :: * -> *) a. MonadAsync m => m a -> m (Async m a)
asyncBound (ReaderT (StrictTVar m Schedule) m a -> StrictTVar m Schedule -> m a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
forall (m :: * -> *) a.
OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
unOverrideDelay OverrideDelay m a
io) StrictTVar m Schedule
schedule)
  asyncOn :: forall a.
Int
-> OverrideDelay m a -> OverrideDelay m (Async (OverrideDelay m) a)
asyncOn Int
n OverrideDelay m a
io = ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
-> OverrideDelay m (Async (OverrideDelay m) a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
 -> OverrideDelay m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
-> OverrideDelay m (Async (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$ (StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
 -> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a))
-> (StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$
    \StrictTVar m Schedule
schedule -> Async m a -> OverrideDelayAsync m a
forall (m :: * -> *) a. Async m a -> OverrideDelayAsync m a
OverrideDelayAsync (Async m a -> OverrideDelayAsync m a)
-> m (Async m a) -> m (OverrideDelayAsync m a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> m a -> m (Async m a)
forall a. Int -> m a -> m (Async m a)
forall (m :: * -> *) a. MonadAsync m => Int -> m a -> m (Async m a)
asyncOn Int
n (ReaderT (StrictTVar m Schedule) m a -> StrictTVar m Schedule -> m a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
forall (m :: * -> *) a.
OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
unOverrideDelay OverrideDelay m a
io) StrictTVar m Schedule
schedule)
  asyncThreadId :: forall a. Async (OverrideDelay m) a -> ThreadId (OverrideDelay m)
asyncThreadId (OverrideDelayAsync Async m a
a) = Async m a -> ThreadId m
forall a. Async m a -> ThreadId m
forall (m :: * -> *) a. MonadAsync m => Async m a -> ThreadId m
asyncThreadId Async m a
a
  cancel :: forall a. Async (OverrideDelay m) a -> OverrideDelay m ()
cancel       = ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ())
-> (OverrideDelayAsync m a -> ReaderT (StrictTVar m Schedule) m ())
-> OverrideDelayAsync m a
-> OverrideDelay m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m () -> ReaderT (StrictTVar m Schedule) m ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT (StrictTVar m Schedule) m ())
-> (OverrideDelayAsync m a -> m ())
-> OverrideDelayAsync m a
-> ReaderT (StrictTVar m Schedule) m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Async m a -> m ()
forall a. Async m a -> m ()
forall (m :: * -> *) a. MonadAsync m => Async m a -> m ()
cancel (Async m a -> m ())
-> (OverrideDelayAsync m a -> Async m a)
-> OverrideDelayAsync m a
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OverrideDelayAsync m a -> Async m a
forall (m :: * -> *) a. OverrideDelayAsync m a -> Async m a
unOverrideDelayAsync
  cancelWith :: forall e a.
Exception e =>
Async (OverrideDelay m) a -> e -> OverrideDelay m ()
cancelWith Async (OverrideDelay m) a
a = ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ())
-> (e -> ReaderT (StrictTVar m Schedule) m ())
-> e
-> OverrideDelay m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m () -> ReaderT (StrictTVar m Schedule) m ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT (StrictTVar m Schedule) m ())
-> (e -> m ()) -> e -> ReaderT (StrictTVar m Schedule) m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Async m a -> e -> m ()
forall e a. Exception e => Async m a -> e -> m ()
forall (m :: * -> *) e a.
(MonadAsync m, Exception e) =>
Async m a -> e -> m ()
cancelWith (OverrideDelayAsync m a -> Async m a
forall (m :: * -> *) a. OverrideDelayAsync m a -> Async m a
unOverrideDelayAsync Async (OverrideDelay m) a
OverrideDelayAsync m a
a)
  asyncWithUnmask :: forall a.
((forall b. OverrideDelay m b -> OverrideDelay m b)
 -> OverrideDelay m a)
-> OverrideDelay m (Async (OverrideDelay m) a)
asyncWithUnmask (forall b. OverrideDelay m b -> OverrideDelay m b)
-> OverrideDelay m a
f = ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
-> OverrideDelay m (Async (OverrideDelay m) a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
 -> OverrideDelay m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
-> OverrideDelay m (Async (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$ (StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
 -> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a))
-> (StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$
    \StrictTVar m Schedule
schedule ->
      Async m a -> OverrideDelayAsync m a
forall (m :: * -> *) a. Async m a -> OverrideDelayAsync m a
OverrideDelayAsync (Async m a -> OverrideDelayAsync m a)
-> m (Async m a) -> m (OverrideDelayAsync m a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      ((forall b. m b -> m b) -> m a) -> m (Async m a)
forall a. ((forall b. m b -> m b) -> m a) -> m (Async m a)
forall (m :: * -> *) a.
MonadAsync m =>
((forall b. m b -> m b) -> m a) -> m (Async m a)
asyncWithUnmask
        (\forall b. m b -> m b
unmask ->
            let unmask' :: forall x. OverrideDelay m x -> OverrideDelay m x
                unmask' :: forall b. OverrideDelay m b -> OverrideDelay m b
unmask' (OverrideDelay (ReaderT StrictTVar m Schedule -> m x
m)) =
                  ReaderT (StrictTVar m Schedule) m x -> OverrideDelay m x
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m x -> OverrideDelay m x)
-> ReaderT (StrictTVar m Schedule) m x -> OverrideDelay m x
forall a b. (a -> b) -> a -> b
$ (StrictTVar m Schedule -> m x)
-> ReaderT (StrictTVar m Schedule) m x
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((StrictTVar m Schedule -> m x)
 -> ReaderT (StrictTVar m Schedule) m x)
-> (StrictTVar m Schedule -> m x)
-> ReaderT (StrictTVar m Schedule) m x
forall a b. (a -> b) -> a -> b
$ \StrictTVar m Schedule
schedule' -> m x -> m x
forall b. m b -> m b
unmask (StrictTVar m Schedule -> m x
m StrictTVar m Schedule
schedule')
            in ReaderT (StrictTVar m Schedule) m a -> StrictTVar m Schedule -> m a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
forall (m :: * -> *) a.
OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
unOverrideDelay (OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a)
-> OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
forall a b. (a -> b) -> a -> b
$ (forall b. OverrideDelay m b -> OverrideDelay m b)
-> OverrideDelay m a
f OverrideDelay m b -> OverrideDelay m b
forall b. OverrideDelay m b -> OverrideDelay m b
unmask') StrictTVar m Schedule
schedule
        )
  asyncOnWithUnmask :: forall a.
Int
-> ((forall b. OverrideDelay m b -> OverrideDelay m b)
    -> OverrideDelay m a)
-> OverrideDelay m (Async (OverrideDelay m) a)
asyncOnWithUnmask Int
n (forall b. OverrideDelay m b -> OverrideDelay m b)
-> OverrideDelay m a
f = ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
-> OverrideDelay m (Async (OverrideDelay m) a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
 -> OverrideDelay m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
-> OverrideDelay m (Async (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$ (StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
 -> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a))
-> (StrictTVar m Schedule -> m (Async (OverrideDelay m) a))
-> ReaderT (StrictTVar m Schedule) m (Async (OverrideDelay m) a)
forall a b. (a -> b) -> a -> b
$
    \StrictTVar m Schedule
schedule ->
      Async m a -> OverrideDelayAsync m a
forall (m :: * -> *) a. Async m a -> OverrideDelayAsync m a
OverrideDelayAsync (Async m a -> OverrideDelayAsync m a)
-> m (Async m a) -> m (OverrideDelayAsync m a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      Int -> ((forall b. m b -> m b) -> m a) -> m (Async m a)
forall a. Int -> ((forall b. m b -> m b) -> m a) -> m (Async m a)
forall (m :: * -> *) a.
MonadAsync m =>
Int -> ((forall b. m b -> m b) -> m a) -> m (Async m a)
asyncOnWithUnmask Int
n
        (\forall b. m b -> m b
unmask ->
            let unmask' :: forall x. OverrideDelay m x -> OverrideDelay m x
                unmask' :: forall b. OverrideDelay m b -> OverrideDelay m b
unmask' (OverrideDelay (ReaderT StrictTVar m Schedule -> m x
m)) =
                  ReaderT (StrictTVar m Schedule) m x -> OverrideDelay m x
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m x -> OverrideDelay m x)
-> ReaderT (StrictTVar m Schedule) m x -> OverrideDelay m x
forall a b. (a -> b) -> a -> b
$ (StrictTVar m Schedule -> m x)
-> ReaderT (StrictTVar m Schedule) m x
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((StrictTVar m Schedule -> m x)
 -> ReaderT (StrictTVar m Schedule) m x)
-> (StrictTVar m Schedule -> m x)
-> ReaderT (StrictTVar m Schedule) m x
forall a b. (a -> b) -> a -> b
$ \StrictTVar m Schedule
schedule' -> m x -> m x
forall b. m b -> m b
unmask (StrictTVar m Schedule -> m x
m StrictTVar m Schedule
schedule')
            in ReaderT (StrictTVar m Schedule) m a -> StrictTVar m Schedule -> m a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
forall (m :: * -> *) a.
OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
unOverrideDelay (OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a)
-> OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
forall a b. (a -> b) -> a -> b
$ (forall b. OverrideDelay m b -> OverrideDelay m b)
-> OverrideDelay m a
f OverrideDelay m b -> OverrideDelay m b
forall b. OverrideDelay m b -> OverrideDelay m b
unmask') StrictTVar m Schedule
schedule
        )

  waitCatchSTM :: forall a.
Async (OverrideDelay m) a
-> STM (OverrideDelay m) (Either SomeException a)
waitCatchSTM = ReaderT (StrictTVar m Schedule) (STM m) (Either SomeException a)
-> OverrideDelaySTM m (Either SomeException a)
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT (StrictTVar m Schedule) (STM m) (Either SomeException a)
 -> OverrideDelaySTM m (Either SomeException a))
-> (OverrideDelayAsync m a
    -> ReaderT
         (StrictTVar m Schedule) (STM m) (Either SomeException a))
-> OverrideDelayAsync m a
-> OverrideDelaySTM m (Either SomeException a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (Either SomeException a)
-> ReaderT (StrictTVar m Schedule) (STM m) (Either SomeException a)
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (Either SomeException a)
 -> ReaderT
      (StrictTVar m Schedule) (STM m) (Either SomeException a))
-> (OverrideDelayAsync m a -> STM m (Either SomeException a))
-> OverrideDelayAsync m a
-> ReaderT (StrictTVar m Schedule) (STM m) (Either SomeException a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Async m a -> STM m (Either SomeException a)
forall a. Async m a -> STM m (Either SomeException a)
forall (m :: * -> *) a.
MonadAsync m =>
Async m a -> STM m (Either SomeException a)
waitCatchSTM (Async m a -> STM m (Either SomeException a))
-> (OverrideDelayAsync m a -> Async m a)
-> OverrideDelayAsync m a
-> STM m (Either SomeException a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OverrideDelayAsync m a -> Async m a
forall (m :: * -> *) a. OverrideDelayAsync m a -> Async m a
unOverrideDelayAsync
  pollSTM :: forall a.
Async (OverrideDelay m) a
-> STM (OverrideDelay m) (Maybe (Either SomeException a))
pollSTM      = ReaderT
  (StrictTVar m Schedule) (STM m) (Maybe (Either SomeException a))
-> OverrideDelaySTM m (Maybe (Either SomeException a))
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) (STM m) a -> OverrideDelaySTM m a
OverrideDelaySTM (ReaderT
   (StrictTVar m Schedule) (STM m) (Maybe (Either SomeException a))
 -> OverrideDelaySTM m (Maybe (Either SomeException a)))
-> (OverrideDelayAsync m a
    -> ReaderT
         (StrictTVar m Schedule) (STM m) (Maybe (Either SomeException a)))
-> OverrideDelayAsync m a
-> OverrideDelaySTM m (Maybe (Either SomeException a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STM m (Maybe (Either SomeException a))
-> ReaderT
     (StrictTVar m Schedule) (STM m) (Maybe (Either SomeException a))
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (STM m (Maybe (Either SomeException a))
 -> ReaderT
      (StrictTVar m Schedule) (STM m) (Maybe (Either SomeException a)))
-> (OverrideDelayAsync m a
    -> STM m (Maybe (Either SomeException a)))
-> OverrideDelayAsync m a
-> ReaderT
     (StrictTVar m Schedule) (STM m) (Maybe (Either SomeException a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Async m a -> STM m (Maybe (Either SomeException a))
forall a. Async m a -> STM m (Maybe (Either SomeException a))
forall (m :: * -> *) a.
MonadAsync m =>
Async m a -> STM m (Maybe (Either SomeException a))
pollSTM (Async m a -> STM m (Maybe (Either SomeException a)))
-> (OverrideDelayAsync m a -> Async m a)
-> OverrideDelayAsync m a
-> STM m (Maybe (Either SomeException a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OverrideDelayAsync m a -> Async m a
forall (m :: * -> *) a. OverrideDelayAsync m a -> Async m a
unOverrideDelayAsync

instance (IOLike m, MonadDelay (OverrideDelay m)) => IOLike (OverrideDelay m) where
  forgetSignKeyKES :: forall v. KESAlgorithm v => SignKeyKES v -> OverrideDelay m ()
forgetSignKeyKES = ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ()
forall (m :: * -> *) a.
ReaderT (StrictTVar m Schedule) m a -> OverrideDelay m a
OverrideDelay (ReaderT (StrictTVar m Schedule) m () -> OverrideDelay m ())
-> (SignKeyKES v -> ReaderT (StrictTVar m Schedule) m ())
-> SignKeyKES v
-> OverrideDelay m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m () -> ReaderT (StrictTVar m Schedule) m ()
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (StrictTVar m Schedule) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT (StrictTVar m Schedule) m ())
-> (SignKeyKES v -> m ())
-> SignKeyKES v
-> ReaderT (StrictTVar m Schedule) m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SignKeyKES v -> m ()
forall v. KESAlgorithm v => SignKeyKES v -> m ()
forall (m :: * -> *) v.
(IOLike m, KESAlgorithm v) =>
SignKeyKES v -> m ()
forgetSignKeyKES

overrideDelay :: UTCTime
              -> Schedule
              -> (forall s. OverrideDelay (IOSim s) a)
              -> Either Failure a
overrideDelay :: forall a.
UTCTime
-> Schedule
-> (forall s. OverrideDelay (IOSim s) a)
-> Either Failure a
overrideDelay UTCTime
start Schedule
schedule forall s. OverrideDelay (IOSim s) a
ma = (forall s. IOSim s a) -> Either Failure a
forall a. (forall s. IOSim s a) -> Either Failure a
runSim ((forall s. IOSim s a) -> Either Failure a)
-> (forall s. IOSim s a) -> Either Failure a
forall a b. (a -> b) -> a -> b
$ do
    UTCTime -> IOSim s ()
forall s. UTCTime -> IOSim s ()
setCurrentTime UTCTime
start
    StrictTVar (IOSim s) Schedule
scheduleVar <- Schedule -> IOSim s (StrictTVar (IOSim s) Schedule)
forall (m :: * -> *) a.
(HasCallStack, MonadSTM m, NoThunks a) =>
a -> m (StrictTVar m a)
newTVarIO Schedule
schedule
    ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) a
-> StrictTVar (IOSim s) Schedule -> IOSim s a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (OverrideDelay (IOSim s) a
-> ReaderT (StrictTVar (IOSim s) Schedule) (IOSim s) a
forall (m :: * -> *) a.
OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
unOverrideDelay OverrideDelay (IOSim s) a
forall s. OverrideDelay (IOSim s) a
ma) StrictTVar (IOSim s) Schedule
scheduleVar

originalDelay :: OverrideDelay IO a -> IO a
originalDelay :: forall a. OverrideDelay IO a -> IO a
originalDelay OverrideDelay IO a
ma = ReaderT (StrictTVar IO Schedule) IO a
-> StrictTVar IO Schedule -> IO a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (OverrideDelay IO a -> ReaderT (StrictTVar IO Schedule) IO a
forall (m :: * -> *) a.
OverrideDelay m a -> ReaderT (StrictTVar m Schedule) m a
unOverrideDelay OverrideDelay IO a
ma) (TestName -> StrictTVar IO Schedule
forall a. HasCallStack => TestName -> a
error TestName
"schedule unused")