ZRefM
A ZRefM[RA, RB, EA, EB, A, B]
is a polymorphic, purely functional description of a mutable reference.
The fundamental operations of a ZRefM
are set
and get
.
set
takes a value of typeA
and sets the reference to a new value, requiring an environment of typeRA
and potentially failing with an error of typeEA
.get
gets the current value of the reference and returns a value of typeB
, requiring an environment of typeRB
and potentially failing with an error of typeEB
.
When the error and value types of the ZRefM
are unified, that is, it is a ZRefM[E, E, A, A]
, the ZRefM
also supports atomic modify
and update
operations.
Note:
Unlike
ZRef
,ZRefM
allows performing effects within update operations, at some cost to performance. Writes will semantically block other writers, while multiple readers can read simultaneously.