Portability | portable |
---|---|
Stability | none |
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.
:: a | An initial value |
-> m (r a) |
Create new reference.
:: r a | Reference |
-> m a |
Reads a reference.
:: r a | Reference |
-> a | New value |
-> m () |
Write to reference.
:: 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.