delay

Types

pub opaque type Delay(val, error)

Functions

pub fn delay_effect(f: fn() -> Result(a, b)) -> Delay(a, b)

store an effect to be run later if f returns an Error then chain will stop

pub fn drain(delayed: Delay(a, b)) -> Nil

run a delayed effect and throw away the result short-circuiting if any in the chain returns an Error

pub fn fallthrough(options: List(Delay(a, b))) -> Result(a, b)

attempt multiple Delays until one returns an Ok

pub fn flat_map(
  delayed: Delay(a, b),
  f: fn(a) -> Result(Delay(c, b), b),
) -> Delay(c, b)

map and then flatten Delay

pub fn flatten(delayed: Delay(Delay(a, b), b)) -> Delay(a, b)

flatten nested Delay

pub fn map(
  delayed: Delay(a, b),
  f: fn(a) -> Result(c, b),
) -> Delay(c, b)

chains an operation onto an existing delay to be run one then into the next if delayed has already error’d then f will be ignored

pub fn repeat(
  delayed: Delay(a, b),
  repitions: Int,
) -> List(Result(a, b))

repeat a Delay and return the results in a list

pub fn retry(
  delayed: Delay(a, b),
  retries: Int,
  delay: Int,
) -> Delay(a, b)

returns a Delay that will be re-attempted retries times with delay ms in between NOTE: delay is ignored in JS

pub fn retry_with_backoff(
  delayed: Delay(a, b),
  retries: Int,
) -> Delay(a, b)

returns a Delay that will be re-attempted retries times with an increasing backoff delay NOTE: there is no backoff in JS

pub fn run(delayed: Delay(a, b)) -> Result(a, b)

run a delayed effect and get the result short-circuiting if any in the chain returns an Error

Search Document