    -- | Unlifted "Control.Concurrent.MVar".
    --
    -- @since 0.1.0.0
    module UnliftIO.MVar
      ( MVar
      , newEmptyMVar
      , newMVar
      , takeMVar
      , putMVar
      , readMVar
      , swapMVar
      , tryTakeMVar
      , tryPutMVar
      , isEmptyMVar
      , withMVar
      , withMVarMasked
      , modifyMVar
      , modifyMVar_
      , modifyMVarMasked
      , modifyMVarMasked_
      , tryReadMVar
      , mkWeakMVar
      ) where

    import System.Mem.Weak (Weak)
    import Control.Concurrent.MVar (MVar)
    import Control.Monad.IO.Unlift
    import qualified Control.Concurrent.MVar as M

    -- | Lifted 'M.newEmptyMVar'.
    --
    -- @since 0.1.0.0
    newEmptyMVar :: MonadIO m => m (MVar a)
    newEmptyMVar :: forall (m :: * -> *) a. MonadIO m => m (MVar a)
    newEmptyMVar = IO (MVar a) -> m (MVar a)
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO IO (MVar a)
    forall a. IO (MVar a)
    M.newEmptyMVar

    -- | Lifted 'M.newMVar'.
    --
    -- @since 0.1.0.0
    newMVar :: MonadIO m => a -> m (MVar a)
    newMVar :: forall (m :: * -> *) a. MonadIO m => a -> m (MVar a)
    newMVar = IO (MVar a) -> m (MVar a)
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO (MVar a) -> m (MVar a))
    -> (a -> IO (MVar a)) -> a -> m (MVar a)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> IO (MVar a)
    forall a. a -> IO (MVar a)
    M.newMVar

    -- | Lifted 'M.takeMVar'.
    --
    -- @since 0.1.0.0
    takeMVar :: MonadIO m => MVar a -> m a
    takeMVar :: forall (m :: * -> *) a. MonadIO m => MVar a -> m a
    takeMVar = IO a -> m a
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO a -> m a) -> (MVar a -> IO a) -> MVar a -> m a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . MVar a -> IO a
    forall a. MVar a -> IO a
    M.takeMVar

    -- | Lifted 'M.putMVar'.
    --
    -- @since 0.1.0.0
    putMVar :: MonadIO m => MVar a -> a -> m ()
    putMVar :: forall (m :: * -> *) a. MonadIO m => MVar a -> a -> m ()
    putMVar MVar a
    var = IO () -> m ()
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> (a -> IO ()) -> a -> m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . MVar a -> a -> IO ()
    forall a. MVar a -> a -> IO ()
    M.putMVar MVar a
    var

    -- | Lifted 'M.readMVar'.
    --
    -- @since 0.1.0.0
    readMVar :: MonadIO m => MVar a -> m a
    readMVar :: forall (m :: * -> *) a. MonadIO m => MVar a -> m a
    readMVar = IO a -> m a
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO a -> m a) -> (MVar a -> IO a) -> MVar a -> m a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . MVar a -> IO a
    forall a. MVar a -> IO a
    M.readMVar

    -- | Lifted 'M.swapMVar'.
    --
    -- @since 0.1.0.0
    swapMVar :: MonadIO m => MVar a -> a -> m a
    swapMVar :: forall (m :: * -> *) a. MonadIO m => MVar a -> a -> m a
    swapMVar MVar a
    var = IO a -> m a
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO a -> m a) -> (a -> IO a) -> a -> m a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . MVar a -> a -> IO a
    forall a. MVar a -> a -> IO a
    M.swapMVar MVar a
    var

    -- | Lifted 'M.tryTakeMVar'.
    --
    -- @since 0.1.0.0
    tryTakeMVar :: MonadIO m => MVar a -> m (Maybe a)
    tryTakeMVar :: forall (m :: * -> *) a. MonadIO m => MVar a -> m (Maybe a)
    tryTakeMVar = IO (Maybe a) -> m (Maybe a)
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO (Maybe a) -> m (Maybe a))
    -> (MVar a -> IO (Maybe a)) -> MVar a -> m (Maybe a)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . MVar a -> IO (Maybe a)
    forall a. MVar a -> IO (Maybe a)
    M.tryTakeMVar

    -- | Lifted 'M.tryPutMVar'.
    --
    -- @since 0.1.0.0
    tryPutMVar :: MonadIO m => MVar a -> a -> m Bool
    tryPutMVar :: forall (m :: * -> *) a. MonadIO m => MVar a -> a -> m Bool
    tryPutMVar MVar a
    var = IO Bool -> m Bool
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Bool -> m Bool) -> (a -> IO Bool) -> a -> m Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . MVar a -> a -> IO Bool
    forall a. MVar a -> a -> IO Bool
    M.tryPutMVar MVar a
    var

    -- | Lifted 'M.isEmptyMVar'.
    --
    -- @since 0.1.0.0
    isEmptyMVar :: MonadIO m => MVar a -> m Bool
    isEmptyMVar :: forall (m :: * -> *) a. MonadIO m => MVar a -> m Bool
    isEmptyMVar = IO Bool -> m Bool
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Bool -> m Bool) -> (MVar a -> IO Bool) -> MVar a -> m Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . MVar a -> IO Bool
    forall a. MVar a -> IO Bool
    M.isEmptyMVar

    -- | Lifted 'M.tryReadMVar'.
    --
    -- @since 0.1.0.0
    tryReadMVar :: MonadIO m => MVar a -> m (Maybe a)
    tryReadMVar :: forall (m :: * -> *) a. MonadIO m => MVar a -> m (Maybe a)
    tryReadMVar = IO (Maybe a) -> m (Maybe a)
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO (Maybe a) -> m (Maybe a))
    -> (MVar a -> IO (Maybe a)) -> MVar a -> m (Maybe a)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . MVar a -> IO (Maybe a)
    forall a. MVar a -> IO (Maybe a)
    M.tryReadMVar

    -- | Unlifted 'M.withMVar'.
    --
    -- @since 0.1.0.0
    withMVar :: MonadUnliftIO m => MVar a -> (a -> m b) -> m b
    withMVar :: forall (m :: * -> *) a b.
    MonadUnliftIO m =>
    MVar a -> (a -> m b) -> m b
    withMVar MVar a
    var a -> m b
    f = ((forall a. m a -> IO a) -> IO b) -> m b
    forall b. ((forall a. m a -> IO a) -> IO b) -> m b
    forall (m :: * -> *) b.
    MonadUnliftIO m =>
    ((forall a. m a -> IO a) -> IO b) -> m b
    withRunInIO (((forall a. m a -> IO a) -> IO b) -> m b)
    -> ((forall a. m a -> IO a) -> IO b) -> m b
    forall a b. (a -> b) -> a -> b
    $ \forall a. m a -> IO a
    run -> MVar a -> (a -> IO b) -> IO b
    forall a b. MVar a -> (a -> IO b) -> IO b
    M.withMVar MVar a
    var (m b -> IO b
    forall a. m a -> IO a
    run (m b -> IO b) -> (a -> m b) -> a -> IO b
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> m b
    f)

    -- | Unlifted 'M.withMVarMasked'.
    --
    -- @since 0.1.0.0
    withMVarMasked :: MonadUnliftIO m => MVar a -> (a -> m b) -> m b
    withMVarMasked :: forall (m :: * -> *) a b.
    MonadUnliftIO m =>
    MVar a -> (a -> m b) -> m b
    withMVarMasked MVar a
    var a -> m b
    f = ((forall a. m a -> IO a) -> IO b) -> m b
    forall b. ((forall a. m a -> IO a) -> IO b) -> m b
    forall (m :: * -> *) b.
    MonadUnliftIO m =>
    ((forall a. m a -> IO a) -> IO b) -> m b
    withRunInIO (((forall a. m a -> IO a) -> IO b) -> m b)
    -> ((forall a. m a -> IO a) -> IO b) -> m b
    forall a b. (a -> b) -> a -> b
    $ \forall a. m a -> IO a
    run -> MVar a -> (a -> IO b) -> IO b
    forall a b. MVar a -> (a -> IO b) -> IO b
    M.withMVarMasked MVar a
    var (m b -> IO b
    forall a. m a -> IO a
    run (m b -> IO b) -> (a -> m b) -> a -> IO b
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> m b
    f)

    -- | Unlifted 'M.modifyMVar_'.
    --
    -- @since 0.1.0.0
    modifyMVar_ :: MonadUnliftIO m => MVar a -> (a -> m a) -> m ()
    modifyMVar_ :: forall (m :: * -> *) a.
    MonadUnliftIO m =>
    MVar a -> (a -> m a) -> m ()
    modifyMVar_ MVar a
    var a -> m a
    f = ((forall a. m a -> IO a) -> IO ()) -> m ()
    forall b. ((forall a. m a -> IO a) -> IO b) -> m b
    forall (m :: * -> *) b.
    MonadUnliftIO m =>
    ((forall a. m a -> IO a) -> IO b) -> m b
    withRunInIO (((forall a. m a -> IO a) -> IO ()) -> m ())
    -> ((forall a. m a -> IO a) -> IO ()) -> m ()
    forall a b. (a -> b) -> a -> b
    $ \forall a. m a -> IO a
    run -> MVar a -> (a -> IO a) -> IO ()
    forall a. MVar a -> (a -> IO a) -> IO ()
    M.modifyMVar_ MVar a
    var (m a -> IO a
    forall a. m a -> IO a
    run (m a -> IO a) -> (a -> m a) -> a -> IO a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> m a
    f)

    -- | Unlifted 'M.modifyMVar'.
    --
    -- @since 0.1.0.0
    modifyMVar :: MonadUnliftIO m => MVar a -> (a -> m (a, b)) -> m b
    modifyMVar :: forall (m :: * -> *) a b.
    MonadUnliftIO m =>
    MVar a -> (a -> m (a, b)) -> m b
    modifyMVar MVar a
    var a -> m (a, b)
    f = ((forall a. m a -> IO a) -> IO b) -> m b
    forall b. ((forall a. m a -> IO a) -> IO b) -> m b
    forall (m :: * -> *) b.
    MonadUnliftIO m =>
    ((forall a. m a -> IO a) -> IO b) -> m b
    withRunInIO (((forall a. m a -> IO a) -> IO b) -> m b)
    -> ((forall a. m a -> IO a) -> IO b) -> m b
    forall a b. (a -> b) -> a -> b
    $ \forall a. m a -> IO a
    run -> MVar a -> (a -> IO (a, b)) -> IO b
    forall a b. MVar a -> (a -> IO (a, b)) -> IO b
    M.modifyMVar MVar a
    var (m (a, b) -> IO (a, b)
    forall a. m a -> IO a
    run (m (a, b) -> IO (a, b)) -> (a -> m (a, b)) -> a -> IO (a, b)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> m (a, b)
    f)

    -- | Unlifted 'M.modifyMVarMasked_'.
    --
    -- @since 0.1.0.0
    modifyMVarMasked_ :: MonadUnliftIO m => MVar a -> (a -> m a) -> m ()
    modifyMVarMasked_ :: forall (m :: * -> *) a.
    MonadUnliftIO m =>
    MVar a -> (a -> m a) -> m ()
    modifyMVarMasked_ MVar a
    var a -> m a
    f = ((forall a. m a -> IO a) -> IO ()) -> m ()
    forall b. ((forall a. m a -> IO a) -> IO b) -> m b
    forall (m :: * -> *) b.
    MonadUnliftIO m =>
    ((forall a. m a -> IO a) -> IO b) -> m b
    withRunInIO (((forall a. m a -> IO a) -> IO ()) -> m ())
    -> ((forall a. m a -> IO a) -> IO ()) -> m ()
    forall a b. (a -> b) -> a -> b
    $ \forall a. m a -> IO a
    run -> MVar a -> (a -> IO a) -> IO ()
    forall a. MVar a -> (a -> IO a) -> IO ()
    M.modifyMVarMasked_ MVar a
    var (m a -> IO a
    forall a. m a -> IO a
    run (m a -> IO a) -> (a -> m a) -> a -> IO a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> m a
    f)

    -- | Unlifted 'M.modifyMVarMasked'.
    --
    -- @since 0.1.0.0
    modifyMVarMasked :: MonadUnliftIO m => MVar a -> (a -> m (a, b)) -> m b
    modifyMVarMasked :: forall (m :: * -> *) a b.
    MonadUnliftIO m =>
    MVar a -> (a -> m (a, b)) -> m b
    modifyMVarMasked MVar a
    var a -> m (a, b)
    f = ((forall a. m a -> IO a) -> IO b) -> m b
    forall b. ((forall a. m a -> IO a) -> IO b) -> m b
    forall (m :: * -> *) b.
    MonadUnliftIO m =>
    ((forall a. m a -> IO a) -> IO b) -> m b
    withRunInIO (((forall a. m a -> IO a) -> IO b) -> m b)
    -> ((forall a. m a -> IO a) -> IO b) -> m b
    forall a b. (a -> b) -> a -> b
    $ \forall a. m a -> IO a
    run -> MVar a -> (a -> IO (a, b)) -> IO b
    forall a b. MVar a -> (a -> IO (a, b)) -> IO b
    M.modifyMVarMasked MVar a
    var (m (a, b) -> IO (a, b)
    forall a. m a -> IO a
    run (m (a, b) -> IO (a, b)) -> (a -> m (a, b)) -> a -> IO (a, b)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> m (a, b)
    f)

    -- | Unlifted 'M.mkWeakMVar'.
    --
    -- @since 0.1.0.0
    mkWeakMVar :: MonadUnliftIO m => MVar a -> m () -> m (Weak (MVar a))
    mkWeakMVar :: forall (m :: * -> *) a.
    MonadUnliftIO m =>
    MVar a -> m () -> m (Weak (MVar a))
    mkWeakMVar MVar a
    var m ()
    f = ((forall a. m a -> IO a) -> IO (Weak (MVar a)))
    -> m (Weak (MVar a))
    forall b. ((forall a. m a -> IO a) -> IO b) -> m b
    forall (m :: * -> *) b.
    MonadUnliftIO m =>
    ((forall a. m a -> IO a) -> IO b) -> m b
    withRunInIO (((forall a. m a -> IO a) -> IO (Weak (MVar a)))
     -> m (Weak (MVar a)))
    -> ((forall a. m a -> IO a) -> IO (Weak (MVar a)))
    -> m (Weak (MVar a))
    forall a b. (a -> b) -> a -> b
    $ \forall a. m a -> IO a
    run -> MVar a -> IO () -> IO (Weak (MVar a))
    forall a. MVar a -> IO () -> IO (Weak (MVar a))
    M.mkWeakMVar MVar a
    var (m () -> IO ()
    forall a. m a -> IO a
    run m ()
    f)