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

Safe Haskell | Safe-Inferred
Language | Haskell98

Data.MRef.Types

Description

This module defines the "MRef" abstraction, which is a set of type-classes for things that behave like `MVar`s. 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 :: Type -> Type) a where Source #

Constructors

MRef :: forall sr (m :: Type -> Type) a. (TakeMRef sr m a, PutMRef sr m a) => !sr -> MRef m a |

#### Instances

Instances details

NewMRef (MRef STM a) IO a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods newMReference :: a -> IO (MRef STM a) Source # newEmptyMReference :: IO (MRef STM a) Source #
PutMRef (MRef STM a) IO a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods putMReference :: MRef STM a -> a -> IO () Source #
TakeMRef (MRef STM a) IO a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods takeMReference :: MRef STM a -> IO a Source #

class HasMRef (m :: Type -> Type) where Source #

Methods

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

newEmptyMRef :: m (MRef m a) Source #

#### Instances

Instances details

HasMRef STM Source # |
Instance details Defined in Data.MRef.Instances.STM Methods newMRef :: a -> STM (MRef STM a) Source # newEmptyMRef :: STM (MRef STM a) Source #
HasMRef IO Source # |
Instance details Defined in Data.MRef.Instances Methods newMRef :: a -> IO (MRef IO a) Source # newEmptyMRef :: IO (MRef IO a) Source #

class Monad m => NewMRef sr (m :: Type -> Type) a | sr -> a where Source #

Methods

newMReference :: a -> m sr Source #

See `newMVar`

newEmptyMReference :: m sr Source #

See `newEmptyMVar`

#### Instances

Instances details

NewMRef (TVar (Maybe a)) STM a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods newMReference :: a -> STM (TVar (Maybe a)) Source # newEmptyMReference :: STM (TVar (Maybe a)) Source #
NewMRef (TVar (Maybe a)) IO a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods newMReference :: a -> IO (TVar (Maybe a)) Source # newEmptyMReference :: IO (TVar (Maybe a)) Source #
MonadIO m => NewMRef (MVar a) m a Source # |
Instance details Defined in Data.MRef.Instances Methods newMReference :: a -> m (MVar a) Source # newEmptyMReference :: m (MVar a) Source #
NewMRef (TMVar a) STM a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods newMReference :: a -> STM (TMVar a) Source # newEmptyMReference :: STM (TMVar a) Source #
NewMRef (TMVar a) IO a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods newMReference :: a -> IO (TMVar a) Source # newEmptyMReference :: IO (TMVar a) Source #
NewMRef (MRef STM a) IO a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods newMReference :: a -> IO (MRef STM a) Source # newEmptyMReference :: IO (MRef STM a) Source #

class Monad m => TakeMRef sr (m :: Type -> Type) a | sr -> a where Source #

Methods

takeMReference :: sr -> m a Source #

See `takeMVar`

#### Instances

Instances details

TakeMRef (TVar (Maybe a)) STM a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods takeMReference :: TVar (Maybe a) -> STM a Source #
TakeMRef (TVar (Maybe a)) IO a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods takeMReference :: TVar (Maybe a) -> IO a Source #
MonadIO m => TakeMRef (MVar a) m a Source # |
Instance details Defined in Data.MRef.Instances Methods takeMReference :: MVar a -> m a Source #
TakeMRef (TMVar a) STM a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods takeMReference :: TMVar a -> STM a Source #
TakeMRef (TMVar a) IO a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods takeMReference :: TMVar a -> IO a Source #
TakeMRef (MRef STM a) IO a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods takeMReference :: MRef STM a -> IO a Source #

class Monad m => PutMRef sr (m :: Type -> Type) a | sr -> a where Source #

Methods

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

See `putMVar`

#### Instances

Instances details

PutMRef (TVar (Maybe a)) STM a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods putMReference :: TVar (Maybe a) -> a -> STM () Source #
PutMRef (TVar (Maybe a)) IO a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods putMReference :: TVar (Maybe a) -> a -> IO () Source #
MonadIO m => PutMRef (MVar a) m a Source # |
Instance details Defined in Data.MRef.Instances Methods putMReference :: MVar a -> a -> m () Source #
PutMRef (TMVar a) STM a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods putMReference :: TMVar a -> a -> STM () Source #
PutMRef (TMVar a) IO a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods putMReference :: TMVar a -> a -> IO () Source #
PutMRef (MRef STM a) IO a Source # |
Instance details Defined in Data.MRef.Instances.STM Methods putMReference :: MRef STM a -> a -> IO () Source #