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 :: forall (m :: * -> *) a.
MonadUnliftIO m =>
Int -> m a -> m (Maybe a)
timeout Int
x m a
y = forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO forall a b. (a -> b) -> a -> b
$ \forall a. m a -> IO a
run -> forall a. Int -> IO a -> IO (Maybe a)
S.timeout Int
x forall a b. (a -> b) -> a -> b
$ forall a. m a -> IO a
run m a
y