package rea

  1. Overview
  2. Docs

Mutable ref cells for asynchronous programming.

Operations on mutable ref cells are atomic such that when an update of a ref cell is in progress other operations on the ref cell will suspend.

type 'v t

Represents a mutable ref cell for asynchronous programming.

val create : 'v -> 'v t

create value creates a new mutable ref cell with given value.

val read : 'v t -> ('R, 'e, 'v, < ('R, 'D) pointed' ; ('R, 'D) suspend'.. > as 'D) er

read mut effect returns the current value of the mutable ref cell.

val mutate : 'v op'1 -> 'v t -> ('R, 'e, unit, < ('R, 'D) pointed' ; ('R, 'D) suspend'.. > as 'D) er

mutate fn mut effect updates the mutable ref cell with the given synchronous function.

val modify : ('v -> 'v * 'a) -> 'v t -> ('R, 'e, 'a, < ('R, 'D) pointed' ; ('R, 'D) suspend'.. > as 'D) er

modify fn mut effect updates the mutable ref cell with the given synchronous function.

val try_mutate : ('v -> ('R, 'e, 'v, 'D) er) -> 'v t -> ('R, 'e, unit, < ('R, 'D) monad' ; ('R, 'D) errors' ; ('R, 'D) suspend'.. > as 'D) er

try_mutate ef mut effect updates the mutable ref cell with the given asynchronous effect.

val try_modify : ('v -> ('R, 'e, 'v * 'a, 'D) er) -> 'v t -> ('R, 'e, 'a, < ('R, 'D) monad' ; ('R, 'D) errors' ; ('R, 'D) suspend'.. > as 'D) er

try_modify ef mut effect updates the mutable ref cell with the given asynchronous effect.