module UnliftIO.Timeout
( timeout
) where
import qualified System.Timeout as S
import Control.Monad.IO.Unlift
timeout :: MonadUnliftIO m => Int -> m a -> m (Maybe a)
timeout :: Int -> m a -> m (Maybe a)
timeout Int
x m a
y = ((forall a. m a -> IO a) -> IO (Maybe a)) -> m (Maybe a)
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (((forall a. m a -> IO a) -> IO (Maybe a)) -> m (Maybe a))
-> ((forall a. m a -> IO a) -> IO (Maybe a)) -> m (Maybe a)
forall a b. (a -> b) -> a -> b
$ \forall a. m a -> IO a
run -> Int -> IO a -> IO (Maybe a)
forall a. Int -> IO a -> IO (Maybe a)
S.timeout Int
x (IO a -> IO (Maybe a)) -> IO a -> IO (Maybe a)
forall a b. (a -> b) -> a -> b
$ m a -> IO a
forall a. m a -> IO a
run m a
y