Module

Effect.Ref

Package
purescript-refs
Repository
purescript/purescript-refs

This module defines an effect and actions for working with global mutable variables.

Note: Control.Monad.ST provides a safe alternative to global mutable variables when mutation is restricted to a local scope.

#Ref Source

data Ref :: Type -> Type

A value of type Ref a represents a mutable reference which holds a value of type a.

#new Source

new :: forall s. s -> Effect (Ref s)

Create a new mutable reference containing the specified value.

#read Source

read :: forall s. Ref s -> Effect s

Read the current value of a mutable reference

#modify' Source

modify' :: forall b s. (s -> { state :: s, value :: b }) -> Ref s -> Effect b

Update the value of a mutable reference by applying a function to the current value.

#modify Source

modify :: forall s. (s -> s) -> Ref s -> Effect s

Update the value of a mutable reference by applying a function to the current value. The updated value is returned.

#modify_ Source

modify_ :: forall s. (s -> s) -> Ref s -> Effect Unit

#write Source

write :: forall s. s -> Ref s -> Effect Unit

Update the value of a mutable reference to the specified value.

Modules
Effect.Ref