ZRefM

sealed abstract class ZRefM[-RA, -RB, +EA, +EB, -A, +B]

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 type A and sets the reference to a new value, requiring an environment of type RA and potentially failing with an error of type EA. get gets the current value of the reference and returns a value of type B, requiring an environment of type RB and potentially failing with an error of type EB.

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.

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.

Companion:
object
class Object
trait Matchable
class Any
ZRefM[RA, RB, EA, EB, A, B]

Value members

Abstract methods

def foldAllM[RC <: RA & RB, RD <: RB, EC, ED, C, D](ea: EA => EC, eb: EB => ED, ec: EB => EC, ca: C => B => ZIO[RC, EC, A], bd: B => ZIO[RD, ED, D]): ZRefM[RC, RD, EC, ED, C, D]

Folds over the error and value types of the ZRefM, allowing access to the state in transforming the set value. This is a more powerful version of foldM but requires unifying the environment and error types.

Folds over the error and value types of the ZRefM, allowing access to the state in transforming the set value. This is a more powerful version of foldM but requires unifying the environment and error types.

def foldM[RC <: RA, RD <: RB, EC, ED, C, D](ea: EA => EC, eb: EB => ED, ca: C => ZIO[RC, EC, A], bd: B => ZIO[RD, ED, D]): ZRefM[RC, RD, EC, ED, C, D]

Folds over the error and value types of the ZRefM. This is a highly polymorphic method that is capable of arbitrarily transforming the error and value types of the ZRefM. For most use cases one of the more specific combinators implemented in terms of foldM will be more ergonomic but this method is extremely useful for implementing new combinators.

Folds over the error and value types of the ZRefM. This is a highly polymorphic method that is capable of arbitrarily transforming the error and value types of the ZRefM. For most use cases one of the more specific combinators implemented in terms of foldM will be more ergonomic but this method is extremely useful for implementing new combinators.

def get: ZIO[RB, EB, B]

Reads the value from the ZRefM.

Reads the value from the ZRefM.

def set(a: A): ZIO[RA, EA, Unit]

Writes a new value to the ZRefM, with a guarantee of immediate consistency (at some cost to performance).

Writes a new value to the ZRefM, with a guarantee of immediate consistency (at some cost to performance).

def setAsync(a: A): ZIO[RA, EA, Unit]

Writes a new value to the ZRefM without providing a guarantee of immediate consistency.

Writes a new value to the ZRefM without providing a guarantee of immediate consistency.

Concrete methods

final def collect[C](pf: PartialFunction[B, C]): ZRefM[RA, RB, EA, Option[EB], A, C]

Maps and filters the get value of the ZRefM with the specified partial function, returning a ZRefM with a get value that succeeds with the result of the partial function if it is defined or else fails with None.

Maps and filters the get value of the ZRefM with the specified partial function, returning a ZRefM with a get value that succeeds with the result of the partial function if it is defined or else fails with None.

final def collectM[RC <: RB, EC >: EB, C](pf: PartialFunction[B, ZIO[RC, EC, C]]): ZRefM[RA, RC, EA, Option[EC], A, C]

Maps and filters the get value of the ZRefM with the specified effectual partial function, returning a ZRefM with a get value that succeeds with the result of the partial function if it is defined or else fails with None.

Maps and filters the get value of the ZRefM with the specified effectual partial function, returning a ZRefM with a get value that succeeds with the result of the partial function if it is defined or else fails with None.

final def contramap[C](f: C => A): ZRefM[RA, RB, EA, EB, C, B]

Transforms the set value of the ZRefM with the specified function.

Transforms the set value of the ZRefM with the specified function.

final def contramapM[RC <: RA, EC >: EA, C](f: C => ZIO[RC, EC, A]): ZRefM[RC, RB, EC, EB, C, B]

Transforms the set value of the ZRefM with the specified effectual function.

Transforms the set value of the ZRefM with the specified effectual function.

final def dimap[C, D](f: C => A, g: B => D): ZRefM[RA, RB, EA, EB, C, D]

Transforms both the set and get values of the ZRefM with the specified functions.

Transforms both the set and get values of the ZRefM with the specified functions.

final def dimapError[EC, ED](f: EA => EC, g: EB => ED): ZRefM[RA, RB, EC, ED, A, B]

Transforms both the set and get errors of the ZRefM with the specified functions.

Transforms both the set and get errors of the ZRefM with the specified functions.

final def dimapM[RC <: RA, RD <: RB, EC >: EA, ED >: EB, C, D](f: C => ZIO[RC, EC, A], g: B => ZIO[RD, ED, D]): ZRefM[RC, RD, EC, ED, C, D]

Transforms both the set and get values of the ZRefM with the specified effectual functions.

Transforms both the set and get values of the ZRefM with the specified effectual functions.

final def filterInput[A1 <: A](f: A1 => Boolean): ZRefM[RA, RB, Option[EA], EB, A1, B]

Filters the set value of the ZRefM with the specified predicate, returning a ZRefM with a set value that succeeds if the predicate is satisfied or else fails with None.

Filters the set value of the ZRefM with the specified predicate, returning a ZRefM with a set value that succeeds if the predicate is satisfied or else fails with None.

final def filterInputM[RC <: RA, EC >: EA, A1 <: A](f: A1 => ZIO[RC, EC, Boolean]): ZRefM[RC, RB, Option[EC], EB, A1, B]

Filters the set value of the ZRefM with the specified effectual predicate, returning a ZRefM with a set value that succeeds if the predicate is satisfied or else fails with None.

Filters the set value of the ZRefM with the specified effectual predicate, returning a ZRefM with a set value that succeeds if the predicate is satisfied or else fails with None.

final def filterOutput(f: B => Boolean): ZRefM[RA, RB, EA, Option[EB], A, B]

Filters the get value of the ZRefM with the specified predicate, returning a ZRefM with a get value that succeeds if the predicate is satisfied or else fails with None.

Filters the get value of the ZRefM with the specified predicate, returning a ZRefM with a get value that succeeds if the predicate is satisfied or else fails with None.

final def filterOutputM[RC <: RB, EC >: EB](f: B => ZIO[RC, EC, Boolean]): ZRefM[RA, RC, EA, Option[EC], A, B]

Filters the get value of the ZRefM with the specified effectual predicate, returning a ZRefM with a get value that succeeds if the predicate is satisfied or else fails with None.

Filters the get value of the ZRefM with the specified effectual predicate, returning a ZRefM with a get value that succeeds if the predicate is satisfied or else fails with None.

def fold[EC, ED, C, D](ea: EA => EC, eb: EB => ED, ca: C => Either[EC, A], bd: B => Either[ED, D]): ZRefM[RA, RB, EC, ED, C, D]

Folds over the error and value types of the ZRefM.

Folds over the error and value types of the ZRefM.

def foldAll[EC, ED, C, D](ea: EA => EC, eb: EB => ED, ec: EB => EC, ca: C => B => Either[EC, A], bd: B => Either[ED, D]): ZRefM[RA & RB, RB, EC, ED, C, D]

Folds over the error and value types of the ZRefM, allowing access to the state in transforming the set value but requiring unifying the error type.

Folds over the error and value types of the ZRefM, allowing access to the state in transforming the set value but requiring unifying the error type.

def getAndSet(a: A): ZIO[R, E, A]
Implicitly added by UnifiedSyntax

Writes a new value to the RefM, returning the value immediately before modification.

Writes a new value to the RefM, returning the value immediately before modification.

def getAndUpdate[R1 <: R, E1 >: E](f: A => ZIO[R1, E1, A]): ZIO[R1, E1, A]
Implicitly added by UnifiedSyntax

Atomically modifies the RefM with the specified function, returning the value immediately before modification.

Atomically modifies the RefM with the specified function, returning the value immediately before modification.

def getAndUpdateSome[R1 <: R, E1 >: E](pf: PartialFunction[A, ZIO[R1, E1, A]]): ZIO[R1, E1, A]
Implicitly added by UnifiedSyntax

Atomically modifies the RefM with the specified partial function, returning the value immediately before modification. If the function is undefined on the current value it doesn't change it.

Atomically modifies the RefM with the specified partial function, returning the value immediately before modification. If the function is undefined on the current value it doesn't change it.

final def map[C](f: B => C): ZRefM[RA, RB, EA, EB, A, C]

Transforms the get value of the ZRefM with the specified function.

Transforms the get value of the ZRefM with the specified function.

final def mapM[RC <: RB, EC >: EB, C](f: B => ZIO[RC, EC, C]): ZRefM[RA, RC, EA, EC, A, C]

Transforms the get value of the ZRefM with the specified effectual function.

Transforms the get value of the ZRefM with the specified effectual function.

@silent("unreachable code")
def modify[R1 <: R, E1 >: E, B](f: A => ZIO[R1, E1, (B, A)]): ZIO[R1, E1, B]
Implicitly added by UnifiedSyntax

Atomically modifies the RefM with the specified function, which computes a return value for the modification. This is a more powerful version of update.

Atomically modifies the RefM with the specified function, which computes a return value for the modification. This is a more powerful version of update.

def modifySome[R1 <: R, E1 >: E, B](default: B)(pf: PartialFunction[A, ZIO[R1, E1, (B, A)]]): ZIO[R1, E1, B]
Implicitly added by UnifiedSyntax

Atomically modifies the RefM with the specified function, which computes a return value for the modification if the function is defined in the current value otherwise it returns a default value. This is a more powerful version of updateSome.

Atomically modifies the RefM with the specified function, which computes a return value for the modification if the function is defined in the current value otherwise it returns a default value. This is a more powerful version of updateSome.

final def readOnly: ZRefM[RA, RB, EA, EB, Nothing, B]

Returns a read only view of the ZRefM.

Returns a read only view of the ZRefM.

final def tapInput[RC <: RA, EC >: EA, A1 <: A](f: A1 => ZIO[RC, EC, Any]): ZRefM[RC, RB, EC, EB, A1, B]

Performs the specified effect every time a value is written to this ZRefM.

Performs the specified effect every time a value is written to this ZRefM.

final def tapOutput[RC <: RB, EC >: EB](f: B => ZIO[RC, EC, Any]): ZRefM[RA, RC, EA, EC, A, B]

Performs the specified effect very time a value is read from this ZRefM.

Performs the specified effect very time a value is read from this ZRefM.

def update[R1 <: R, E1 >: E](f: A => ZIO[R1, E1, A]): ZIO[R1, E1, Unit]
Implicitly added by UnifiedSyntax

Atomically modifies the RefM with the specified function.

Atomically modifies the RefM with the specified function.

def updateAndGet[R1 <: R, E1 >: E](f: A => ZIO[R1, E1, A]): ZIO[R1, E1, A]
Implicitly added by UnifiedSyntax

Atomically modifies the RefM with the specified function, returning the value immediately after modification.

Atomically modifies the RefM with the specified function, returning the value immediately after modification.

def updateSome[R1 <: R, E1 >: E](pf: PartialFunction[A, ZIO[R1, E1, A]]): ZIO[R1, E1, Unit]
Implicitly added by UnifiedSyntax

Atomically modifies the RefM with the specified partial function. If the function is undefined on the current value it doesn't change it.

Atomically modifies the RefM with the specified partial function. If the function is undefined on the current value it doesn't change it.

def updateSomeAndGet[R1 <: R, E1 >: E](pf: PartialFunction[A, ZIO[R1, E1, A]]): ZIO[R1, E1, A]
Implicitly added by UnifiedSyntax

Atomically modifies the RefM with the specified partial function. If the function is undefined on the current value it returns the old value without changing it.

Atomically modifies the RefM with the specified partial function. If the function is undefined on the current value it returns the old value without changing it.

final def writeOnly: ZRefM[RA, RB, EA, Unit, A, Nothing]

Returns a write only view of the ZRefM.

Returns a write only view of the ZRefM.