module Control.Concurrent.STM.TVar.Extra where import Control.Concurrent.STM import Prelude overTVar :: (a -> a) -> TVar a -> STM a overTVar :: forall a. (a -> a) -> TVar a -> STM a overTVar a -> a f TVar a var = TVar a -> (a -> (a, a)) -> STM a forall s a. TVar s -> (s -> (a, s)) -> STM a stateTVar TVar a var (\a x -> (a -> a f a x, a -> a f a x)) overTVarIO :: (a -> a) -> TVar a -> IO a overTVarIO :: forall a. (a -> a) -> TVar a -> IO a overTVarIO = (STM a -> IO a forall a. STM a -> IO a atomically .) ((TVar a -> STM a) -> TVar a -> IO a) -> ((a -> a) -> TVar a -> STM a) -> (a -> a) -> TVar a -> IO a forall b c a. (b -> c) -> (a -> b) -> a -> c . (a -> a) -> TVar a -> STM a forall a. (a -> a) -> TVar a -> STM a overTVar modifyTVarIO :: TVar a -> (a -> a) -> IO () modifyTVarIO :: forall a. TVar a -> (a -> a) -> IO () modifyTVarIO = (STM () -> IO () forall a. STM a -> IO a atomically .) (((a -> a) -> STM ()) -> (a -> a) -> IO ()) -> (TVar a -> (a -> a) -> STM ()) -> TVar a -> (a -> a) -> IO () forall b c a. (b -> c) -> (a -> b) -> a -> c . TVar a -> (a -> a) -> STM () forall a. TVar a -> (a -> a) -> STM () modifyTVar writeTVarIO :: TVar a -> a -> IO () writeTVarIO :: forall a. TVar a -> a -> IO () writeTVarIO = (STM () -> IO () forall a. STM a -> IO a atomically .) ((a -> STM ()) -> a -> IO ()) -> (TVar a -> a -> STM ()) -> TVar a -> a -> IO () forall b c a. (b -> c) -> (a -> b) -> a -> c . TVar a -> a -> STM () forall a. TVar a -> a -> STM () writeTVar