lifted-base-0.2.3.6: lifted IO operations from the base library

Copyright | Bas van Dijk
License | BSD-style
Maintainer | Bas van Dijk <v.dijk.bas@gmail.com>
Stability | experimental
Safe Haskell | Trustworthy
Language | Haskell98

Control.Concurrent.MVar.Lifted

Description

This is a wrapped version of Control.Concurrent.MVar with types generalized from `IO` to all monads in either `MonadBase` or `MonadBaseControl`.

Synopsis

- data MVar a :: * -> *
- newEmptyMVar :: MonadBase IO m => m (MVar a)
- newMVar :: MonadBase IO m => a -> m (MVar a)
- takeMVar :: MonadBase IO m => MVar a -> m a
- putMVar :: MonadBase IO m => MVar a -> a -> m ()
- readMVar :: MonadBase IO m => MVar a -> m a
- swapMVar :: MonadBase IO m => MVar a -> a -> m a
- tryTakeMVar :: MonadBase IO m => MVar a -> m (Maybe a)
- tryPutMVar :: MonadBase IO m => MVar a -> a -> m Bool
- isEmptyMVar :: MonadBase IO m => MVar a -> m Bool
- withMVar :: MonadBaseControl IO m => MVar a -> (a -> m b) -> m b
- modifyMVar_ :: MonadBaseControl IO m => MVar a -> (a -> m a) -> m ()
- modifyMVar :: MonadBaseControl IO m => MVar a -> (a -> m (a, b)) -> m b
- modifyMVarMasked_ :: MonadBaseControl IO m => MVar a -> (a -> m a) -> m ()
- modifyMVarMasked :: MonadBaseControl IO m => MVar a -> (a -> m (a, b)) -> m b
- mkWeakMVar :: MonadBaseControl IO m => MVar a -> m () -> m (Weak (MVar a))
- withMVarMasked :: MonadBaseControl IO m => MVar a -> (a -> m b) -> m b
- tryReadMVar :: MonadBase IO m => MVar a -> m (Maybe a)

# Documentation

data MVar a :: * -> *

An `MVar` (pronounced "em-var") is a synchronising variable, used for communication between concurrent threads. It can be thought of as a a box, which may be empty or full.

Instances

Eq (MVar a) |

newEmptyMVar :: MonadBase IO m => m (MVar a) Source

Generalized version of `newEmptyMVar`.

newMVar :: MonadBase IO m => a -> m (MVar a) Source

Generalized version of `newMVar`.

takeMVar :: MonadBase IO m => MVar a -> m a Source

Generalized version of `takeMVar`.

putMVar :: MonadBase IO m => MVar a -> a -> m () Source

Generalized version of `putMVar`.

readMVar :: MonadBase IO m => MVar a -> m a Source

Generalized version of `readMVar`.

swapMVar :: MonadBase IO m => MVar a -> a -> m a Source

Generalized version of `swapMVar`.

tryTakeMVar :: MonadBase IO m => MVar a -> m (Maybe a) Source

Generalized version of `tryTakeMVar`.

tryPutMVar :: MonadBase IO m => MVar a -> a -> m Bool Source

Generalized version of `tryPutMVar`.

isEmptyMVar :: MonadBase IO m => MVar a -> m Bool Source

Generalized version of `isEmptyMVar`.

withMVar :: MonadBaseControl IO m => MVar a -> (a -> m b) -> m b Source

Generalized version of `withMVar`.

modifyMVar_ :: MonadBaseControl IO m => MVar a -> (a -> m a) -> m () Source

Generalized version of `modifyMVar_`.

modifyMVar :: MonadBaseControl IO m => MVar a -> (a -> m (a, b)) -> m b Source

Generalized version of `modifyMVar`.

modifyMVarMasked_ :: MonadBaseControl IO m => MVar a -> (a -> m a) -> m () Source

Generalized version of `modifyMVarMasked_`.

modifyMVarMasked :: MonadBaseControl IO m => MVar a -> (a -> m (a, b)) -> m b Source

Generalized version of `modifyMVarMasked`.

mkWeakMVar :: MonadBaseControl IO m => MVar a -> m () -> m (Weak (MVar a)) Source

Generalized version of `mkWeakMVar`.

Note any monadic side effects in `m` of the "finalizer" computation are discarded.

withMVarMasked :: MonadBaseControl IO m => MVar a -> (a -> m b) -> m b Source

Generalized version of `withMVarMasked`.

tryReadMVar :: MonadBase IO m => MVar a -> m (Maybe a) Source

Generalized version of `tryReadMVar`.