monad-var-0.2.1.0: Generic operations over variables

Safe HaskellSafe
LanguageHaskell2010

MonadVar.Classes

Synopsis

Documentation

class Monad m => MonadNew m v where Source #

A type class for containers that can be created and initialized with a single value.

Minimal complete definition

new

Methods

new :: a -> m (v a) Source #

class (MonadRead m v, Monad m) => MonadLock m v where Source #

A type class for at most one element containers. An attempt to get a value from an empty container or to put a value into a full container results in a block. I.e. this is a type class for MVar-like things.

Minimal complete definition

hold, fill, tryHold, tryFill, tryRead, newEmpty, isEmpty

Methods

hold :: v a -> m a Source #

Get a value from a container. Block on empty. A la takeMVar.

fill :: v a -> a -> m () Source #

Put a value to a container. Block on full. A la putMVar.

tryHold :: v a -> m (Maybe a) Source #

Get a value from a container. Return Nothing on empty. A la tryTakeMVar.

tryFill :: v a -> a -> m Bool Source #

Put a value to a container. Return Nothing on full. A la tryPutMVar.

tryRead :: v a -> m (Maybe a) Source #

Read a value from a container. Return Nothing on empty. A la tryReadMVar.

newEmpty :: m (v a) Source #

Create an empty container. A la newEmptyMVar.

isEmpty :: v a -> m Bool Source #

Check whether a container is empty. A la isEmptyMVar.

class Monad m => MonadRead m v where Source #

A type class for containers from which a single value can be read.

Minimal complete definition

read

Methods

read :: v a -> m a Source #

class Monad m => MonadWrite m v where Source #

A type class for containers to which a single value can be written.

Minimal complete definition

write

Methods

write :: v a -> a -> m () Source #

class Monad m => MonadSwap m v where Source #

A type class for containers for which one value can be replaced with an another (not necessarily at the same position).

Minimal complete definition

swap

Methods

swap :: v a -> a -> m a Source #

Replace a value from a container by a new one and return the original value.

class MonadWrite m v => MonadMutate_ m v where Source #

A type class for mutable containers which can be mapped over.

Minimal complete definition

mutate_

Methods

mutate_ :: v a -> (a -> a) -> m () Source #

class (MonadRead m v, MonadMutate_ m v) => MonadMutate m v where Source #

A type class for one-element containers which can be mapped and folded over simultaneously. These are basically variables.

Minimal complete definition

mutate

Methods

mutate :: v a -> (a -> (a, b)) -> m b Source #

Mutate a variable and return an additional value.

class MonadFoldMutate m v where Source #

A type class for mutable containers which can be mapped and folded over simultaneously.

Minimal complete definition

foldMutate

Methods

foldMutate :: Monoid b => v a -> (a -> (a, b)) -> m b Source #

class MonadMutate_ m v => MonadMutateM_ f m v where Source #

A type class for mutable containers which can be monadically mapped over.

Minimal complete definition

mutateM_

Methods

mutateM_ :: v a -> (a -> f a) -> m () Source #

class (MonadMutate m v, MonadMutateM_ f m v) => MonadMutateM f m v where Source #

A type class for one-element containers which can be monadically mapped and folded over simultaneously. These are basically variables.

Minimal complete definition

mutateM

Methods

mutateM :: v a -> (a -> f (a, b)) -> m b Source #

Monadically mutate a variable and return an additional value.

class MonadFoldMutateM m n v where Source #

A type class for mutable containers which can be monadically mapped and folded over simultaneously.

Minimal complete definition

foldMutateM

Methods

foldMutateM :: Monoid b => v a -> (a -> m (a, b)) -> n b Source #