delay

Types

pub opaque type Delay(val, error)

Functions

pub fn all(effects: List(Delay(a, b))) -> Bool

run all effects in sequence and return True if all succeed note this will always run every effect

pub fn any(effects: List(Delay(a, b))) -> Bool

run all effects in sequence and return True if any succeeds note this is different than fallthrough/1 because it will always run every effect

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 every(effects: List(Delay(a, b))) -> List(Result(a, b))

run every effect in sequence and get their results

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

attempt multiple Delays until one returns an Ok unlike any/1 this will short circuit on the first 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