{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Hedgehog.Extras.Test.Concurrent
( threadDelay
, module Control.Concurrent.Async.Lifted
, module System.Timeout.Lifted
) where
import Control.Applicative
import Control.Concurrent.Async.Lifted
import qualified Control.Concurrent.Lifted as IO
import Control.Monad.Base
import Control.Monad.IO.Class
import Control.Monad.Trans.Control
import Control.Monad.Trans.Resource
import Data.Function
import Data.Int
import qualified GHC.Stack as GHC
import System.IO (IO)
import System.Timeout.Lifted
import qualified UnliftIO
import Hedgehog
import qualified Hedgehog as H
threadDelay :: (MonadTest m, MonadIO m) => Int -> m ()
threadDelay :: forall (m :: * -> *). (MonadTest m, MonadIO m) => Int -> m ()
threadDelay Int
n = m () -> m ()
(HasCallStack => m ()) -> m ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack (m () -> m ()) -> (IO () -> m ()) -> IO () -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO () -> m ()
forall (m :: * -> *) a.
(MonadTest m, MonadIO m, HasCallStack) =>
IO a -> m a
H.evalIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Int -> IO ()
forall (m :: * -> *). MonadBase IO m => Int -> m ()
IO.threadDelay Int
n
instance MonadBase IO (ResourceT IO) where
liftBase :: forall α. IO α -> ResourceT IO α
liftBase = IO α -> ResourceT IO α
forall α. IO α -> ResourceT IO α
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
instance MonadBaseControl IO (ResourceT IO) where
type StM (ResourceT IO) a = a
liftBaseWith :: forall a. (RunInBase (ResourceT IO) IO -> IO a) -> ResourceT IO a
liftBaseWith = ((forall a. ResourceT IO a -> IO a) -> IO a) -> ResourceT IO a
(RunInBase (ResourceT IO) IO -> IO a) -> ResourceT IO a
forall b.
((forall a. ResourceT IO a -> IO a) -> IO b) -> ResourceT IO b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
UnliftIO.withRunInIO
restoreM :: forall a. StM (ResourceT IO) a -> ResourceT IO a
restoreM = a -> ResourceT IO a
StM (ResourceT IO) a -> ResourceT IO a
forall a. a -> ResourceT IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure