Spectre.Execution.Expression (Spectre v0.3.0)

Copy Markdown View Source

Closed expression language used by data-driven execution programs.

Expressions can read the immutable Work input, current state, or last operation result; embed a portable literal; and assemble maps or lists. They never contain callbacks, modules, quoted code, or arbitrary MFAs.

Summary

Functions

Evaluates a normalized expression against a reduced data environment.

Normalizes one authored expression into its canonical closed form.

Writes a value at a closed map/list path without creating atoms.

Normalizes a non-empty state path.

Types

t()

@type t() :: map()

Functions

evaluate(value, env)

@spec evaluate(t(), map()) :: {:ok, term()} | {:error, term()}

Evaluates a normalized expression against a reduced data environment.

normalize(value)

@spec normalize(term()) :: {:ok, t()} | {:error, term()}

Normalizes one authored expression into its canonical closed form.

put(value, path, replacement)

@spec put(term(), [String.t() | non_neg_integer()], term()) ::
  {:ok, term()} | {:error, term()}

Writes a value at a closed map/list path without creating atoms.

state_path(value)

@spec state_path(term()) :: {:ok, [String.t() | non_neg_integer()]} | {:error, term()}

Normalizes a non-empty state path.