EffectTalk

Ref.make, Ref.get, Ref.update

Ref is a mutable reference for concurrent state. Use Ref.make(initial) to create one. Ref.get reads the value; Ref.update atomically replaces it with a function of the current value. All operations are effectful.

  • Use Ref.make(initial) to create a Ref
  • Use Ref.get(ref) to read the current value
  • Use Ref.update(ref, fn) - fn receives current, returns new
Loading code editor...