Skip to main content
Version: 1.0.18

ZRefM

A ZRefM[RA, RB, EA, EB, A, B] is a polymorphic, purely functional description of a mutable reference.

The fundamental operations of a ZRefMare 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.

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.

ZIO Chat

Hello! ๐Ÿ˜Š I'm your ZIO Chat Bot, designed to be your go-to resource for all things ZIO! Whether you're new to this powerful functional effect system or a seasoned pro, I'm here to assist you. ZIO empowers you to build concurrent and resilient applications in Scala, offering referential transparency, composable data types, type-safety, and more. So, go ahead and ask me anything about ZIO โ€“ I'm here to provide the answers you need! ๐Ÿค–