ref-fd-0.4.0.1: A type class for monads with references using functional dependencies.

Copyright(c) Harvard University 2006-2011 (c) Geoffrey Mainland 2011-2014
LicenseBSD-style
MaintainerGeoffrey Mainland <mainland@cs.drexel.edu>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe
LanguageHaskell98

Control.Monad.Ref

Description

 

Synopsis

Documentation

class Monad m => MonadRef r m | m -> r where Source

The MonadRef type class abstracts over the details of manipulating references, allowing one to write code that uses references and can operate in any monad that supports reference operations.

Minimal complete definition

newRef, readRef, writeRef

Methods

newRef :: a -> m (r a) Source

Create a new reference

readRef :: r a -> m a Source

Read the value of a reference

writeRef :: r a -> a -> m () Source

Write a new value to a reference

modifyRef :: r a -> (a -> a) -> m () Source

Mutate the contents of a reference

modifyRef' :: r a -> (a -> a) -> m () Source

Strict version of modifyRef

Instances

class MonadRef r m => MonadAtomicRef r m | m -> r where Source

Minimal complete definition

atomicModifyRef

Methods

atomicModifyRef :: r a -> (a -> (a, b)) -> m b Source

Atomically mutate the contents of a reference

atomicModifyRef' :: r a -> (a -> (a, b)) -> m b Source

Strict version of atomicModifyRef. This forces both the value stored in the reference as well as the value returned.