Folds over the error and value types of the ZRef.
Folds over the error and value types of the ZRef. This is a highly
polymorphic method that is capable of arbitrarily transforming the error
and value types of the ZRef. For most use cases one of the more specific
combinators implemented in terms of fold will be more ergonomic but this
method is extremely useful for implementing new combinators.
Reads the value from the ZRef.
Writes a new value to the ZRef, with a guarantee of immediate
consistency (at some cost to performance).
Writes a new value to the ZRef without providing a guarantee of
immediate consistency.
Maps and filters the get value of the ZRef with the specified partial
function, returning a ZRef with a get value that succeeds with the
result of the partial function if it is defined or else fails with None.
Transforms the set value of the ZRef with the specified function.
Transforms the set value of the ZRef with the specified fallible
function.
Transforms both the set and get values of the ZRef with the
specified functions.
Transforms both the set and get values of the ZRef with the
specified fallible functions.
Transforms both the set and get errors of the ZRef with the
specified functions.
Filters the get value of the ZRef with the specified predicate,
returning a ZRef with a get value that succeeds with its result if the
predicate is satisfied or else fails with None.
Transforms the get value of the ZRef with the specified function.
Transforms the get value of the ZRef with the specified fallible
function.
Returns a read only view of the ZRef.
Unifies the error types of the ZRef by mapping both error types with the
specified functions.
Unifies the value types of the ZRef by mapping both value types with the
specified function.
Returns a write only view of the ZRef.
A
ZRef[EA, EB, A, B]is a polymorphic, purely functional description of a mutable reference. The fundamental operations of aZRefaresetandget.settakes a value of typeAand sets the reference to a new value, potentially failing with an error of typeEA.getgets the current value of the reference and returns a value of typeB, potentially failing with an error of typeEB.When the error and value types of the
ZRefare unified, that is, it is aZRef[E, E, A, A], theZRefalso supports atomicmodifyandupdateoperations. All operations are guaranteed to be safe for concurrent access.NOTE: While
ZRefprovides the functional equivalent of a mutable reference, the value inside theZRefshould be immutable. For performance reasonsZRefis implemented in terms of compare and swap operations rather than synchronization. These operations are not safe for mutable values that do not support concurrent access.