IORef< T> class
final
Mutable reference in the IO monad.
Allows having a reference that can be read and mutated inside the IO monad. Can be used in conjunction with a closure to preserve a state across multiple IO function calls, or in any other case where code is run inside an IO monad.
In most cases, the State monad should be used, and IORef must be viewed as a last resort, as it holds a mutable field inside itself that can be modified inside of the IO monad.
Properties
- hashCode → int
-
The hash code for this object.
read-onlyinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
Methods
-
modify(
Endo< T> update) → IO< Unit> - Works almost identical to the write method, but instead of taking a value that needs to be written, takes an Endo function, applies the IORef's current value to it and writes the result to the IORef.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
read(
) → IO< T> - Extracts a current value of the IORef and returns it inside the IO monad.
-
toString(
) → String -
A string representation of this object.
inherited
-
write(
T value) → IO< Unit> -
Writes the given value to the IORef and returns a
Unit
inside the IO monad.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited