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

Safe HaskellSafe
LanguageHaskell98

Data.MRef.Types

Description

This module defines the "MRef" abstraction, which is a set of type-classes for things that behave like MVars. See the documentation there for more info.

This interface may be subject to future expansion. Presently, rather than providing something like tryTakeMVar, instances for "ReadRef sr m (Maybe a)" are provided, giving readReference the same type tryTakeMRef would have if it existed. There is currently nothing like tryPutMVar, though. Perhaps there should be. Or, perhaps this is the sort of thing the weird (to me) signature of atomicModifyIORef is for, and an argument for a similar signature for modifyStateRef or the addition of a new atomicModifyStateRef function.

I would like to resolve these questions in version 0.3 of this package.

Documentation

data MRef m a where #

Constructors

MRef :: (TakeMRef sr m a, PutMRef sr m a) => !sr -> MRef m a 
Instances
PutMRef (MRef STM a) IO a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

putMReference :: MRef STM a -> a -> IO () #

TakeMRef (MRef STM a) IO a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

takeMReference :: MRef STM a -> IO a #

NewMRef (MRef STM a) IO a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

newMReference :: a -> IO (MRef STM a) #

newEmptyMReference :: IO (MRef STM a) #

class HasMRef m where #

Methods

newMRef :: a -> m (MRef m a) #

newEmptyMRef :: m (MRef m a) #

Instances
HasMRef IO # 
Instance details

Defined in Data.MRef.Instances

Methods

newMRef :: a -> IO (MRef IO a) #

newEmptyMRef :: IO (MRef IO a) #

HasMRef STM # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

newMRef :: a -> STM (MRef STM a) #

newEmptyMRef :: STM (MRef STM a) #

class Monad m => NewMRef sr m a | sr -> a where #

Methods

newMReference :: a -> m sr #

newEmptyMReference :: m sr #

Instances
NewMRef (TVar (Maybe a)) IO a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

newMReference :: a -> IO (TVar (Maybe a)) #

newEmptyMReference :: IO (TVar (Maybe a)) #

NewMRef (TVar (Maybe a)) STM a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

newMReference :: a -> STM (TVar (Maybe a)) #

newEmptyMReference :: STM (TVar (Maybe a)) #

MonadIO m => NewMRef (MVar a) m a # 
Instance details

Defined in Data.MRef.Instances

Methods

newMReference :: a -> m (MVar a) #

newEmptyMReference :: m (MVar a) #

NewMRef (TMVar a) IO a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

newMReference :: a -> IO (TMVar a) #

newEmptyMReference :: IO (TMVar a) #

NewMRef (TMVar a) STM a # 
Instance details

Defined in Data.MRef.Instances.STM

NewMRef (MRef STM a) IO a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

newMReference :: a -> IO (MRef STM a) #

newEmptyMReference :: IO (MRef STM a) #

class Monad m => TakeMRef sr m a | sr -> a where #

Methods

takeMReference :: sr -> m a #

Instances
TakeMRef (TVar (Maybe a)) IO a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

takeMReference :: TVar (Maybe a) -> IO a #

TakeMRef (TVar (Maybe a)) STM a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

takeMReference :: TVar (Maybe a) -> STM a #

MonadIO m => TakeMRef (MVar a) m a # 
Instance details

Defined in Data.MRef.Instances

Methods

takeMReference :: MVar a -> m a #

TakeMRef (TMVar a) IO a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

takeMReference :: TMVar a -> IO a #

TakeMRef (TMVar a) STM a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

takeMReference :: TMVar a -> STM a #

TakeMRef (MRef STM a) IO a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

takeMReference :: MRef STM a -> IO a #

class Monad m => PutMRef sr m a | sr -> a where #

Methods

putMReference :: sr -> a -> m () #

Instances
PutMRef (TVar (Maybe a)) IO a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

putMReference :: TVar (Maybe a) -> a -> IO () #

PutMRef (TVar (Maybe a)) STM a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

putMReference :: TVar (Maybe a) -> a -> STM () #

MonadIO m => PutMRef (MVar a) m a # 
Instance details

Defined in Data.MRef.Instances

Methods

putMReference :: MVar a -> a -> m () #

PutMRef (TMVar a) IO a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

putMReference :: TMVar a -> a -> IO () #

PutMRef (TMVar a) STM a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

putMReference :: TMVar a -> a -> STM () #

PutMRef (MRef STM a) IO a # 
Instance details

Defined in Data.MRef.Instances.STM

Methods

putMReference :: MRef STM a -> a -> IO () #