stateref-0.2.1.1: Abstraction for things that work like IORef.

Data.MRef.Instances

Description

This module exports no new symbols of its own. It defines basic class instances for creating, reading, and writing MVars, and re-exports MVar.

Synopsis

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) 
DefaultMRef (MVar a) IO a 
MonadIO m => PutMRef (MVar a) m a 
MonadIO m => TakeMRef (MVar a) m a 
MonadIO m => NewMRef (MVar a) m a 
MonadIO m => NewRef (MVar a) m (Maybe a) 

class Monad m => MonadIO m where

Methods

liftIO :: IO a -> m a

Instances

data STM a

A monad supporting atomic memory transactions.

data TMVar a

A TMVar is a synchronising variable, used for communication between concurrent threads. It can be thought of as a box, which may be empty or full.

Instances

Typeable1 TMVar 
Eq (TMVar a) 
DefaultMRef (TMVar a) STM a 
PutMRef (TMVar a) IO a 
PutMRef (TMVar a) STM a 
TakeMRef (TMVar a) IO a 
TakeMRef (TMVar a) STM a 
NewMRef (TMVar a) IO a 
NewMRef (TMVar a) STM a 
MonadIO m => ReadRef (TMVar a) m (Maybe a) 
ReadRef (TMVar a) STM (Maybe a) 
MonadIO m => NewRef (TMVar a) m (Maybe a) 
NewRef (TMVar a) STM (Maybe a) 

data TVar a

Shared memory locations that support atomic memory transactions.

Instances

Typeable1 TVar 
Eq (TVar a) 
PutMRef (TVar (Maybe a)) IO a 
PutMRef (TVar (Maybe a)) STM a 
TakeMRef (TVar (Maybe a)) IO a 
TakeMRef (TVar (Maybe a)) STM a 
NewMRef (TVar (Maybe a)) IO a 
NewMRef (TVar (Maybe a)) STM a 
DefaultStateRef (TVar a) STM a 
MonadIO m => ModifyRef (TVar a) m a 
ModifyRef (TVar a) STM a 
MonadIO m => ReadRef (TVar a) m a 
ReadRef (TVar a) STM a 
MonadIO m => WriteRef (TVar a) m a 
WriteRef (TVar a) STM a 
MonadIO m => NewRef (TVar a) m a 
NewRef (TVar a) STM a 

atomically :: STM a -> IO a

Perform a series of STM actions atomically.

You cannot use atomically inside an unsafePerformIO or unsafeInterleaveIO. Any attempt to do so will result in a runtime error. (Reason: allowing this would effectively allow a transaction inside a transaction, depending on exactly when the thunk is evaluated.)

However, see newTVarIO, which can be called inside unsafePerformIO, and which allows top-level TVars to be allocated.