| Portability | portable | 
|---|---|
| Stability | none | 
Data.Reference
Description
Reference is class which generalizes references and monads they exists in. It means that IORef, STRef and others can be accessed by common interface.
Documentation
class Monad m => Reference r m whereSource
Class connecting mutable variable and monad it exists in.
Methods
Arguments
| :: a | An initial value  | 
| -> m (r a) | 
Create new reference.
Arguments
| :: r a | Reference  | 
| -> m a | 
Reads a reference.
Arguments
| :: r a | Reference  | 
| -> a | New value  | 
| -> m () | 
Write to reference.
Arguments
| :: r a | Reference  | 
| -> (a -> m (a, b)) | Computation  | 
| -> m b | Result of computation  | 
Modify the reference. Default implementation is provided but it MUST be overloaded if the reference is atomic to provide an atomic write.