PgRest.Planner.Result (PgRest v0.2.0)

Copy Markdown View Source

Helpers for planner steps that run over a list and stop at the first error.

Summary

Functions

Runs fun (returning :ok | {:error, error}) on each item: :ok, or the first error.

Maps fun (returning {:ok, value} | {:error, error}) over enum: {:ok, values} in order, or the first error.

Folds fun (returning {:ok, acc} | {:error, error}) over enum, stopping at the first error.

Functions

all_ok(enum, fun)

@spec all_ok(Enumerable.t(), (term() -> :ok | {:error, term()})) ::
  :ok | {:error, term()}

Runs fun (returning :ok | {:error, error}) on each item: :ok, or the first error.

map_ok(enum, fun)

@spec map_ok(Enumerable.t(), (term() -> {:ok, term()} | {:error, term()})) ::
  {:ok, list()} | {:error, term()}

Maps fun (returning {:ok, value} | {:error, error}) over enum: {:ok, values} in order, or the first error.

reduce_ok(enum, acc, fun)

@spec reduce_ok(Enumerable.t(), term(), (term(), term() ->
                                     {:ok, term()} | {:error, term()})) ::
  {:ok, term()} | {:error, term()}

Folds fun (returning {:ok, acc} | {:error, error}) over enum, stopping at the first error.