-- | Unlifted "System.Timeout".
--
-- @since 0.1.0.0
module UnliftIO.Timeout
  ( timeout
  ) where

import qualified System.Timeout as S
import Control.Monad.IO.Unlift

-- | Unlifted 'S.timeout'.
--
-- @since 0.1.0.0
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