CEL.Function.Overload (CEL v0.2.0)

Copy Markdown View Source

One signature of a CEL.Function, and the code that evaluates it.

  • :id — a name for this overload, unique within the environment; checked expressions record which overload each call resolved to.
  • :args — the argument types, as CEL.Type.t/0; for a :receiver call the receiver comes first. {:param, "T"} is a type parameter: every occurrence must have the same type.
  • :result — the result type, which may use the same parameters.
  • :eval — {Module, function}, called as Module.function(args, ...context) with the evaluated arguments as a list of CEL.Value.t/0, and returning {:ok, value}, {:error, reason} or {:unknown, reason}. Without :eval the overload can be type-checked but not evaluated.
  • :eval_context — extra arguments appended after the argument list, in order: :vars for the variable bindings, keyed by string name, :call for %{function: name, overload_id: id, expr_id: id}, and :types for the environment's CEL.TypeProvider.t/0, to read message arguments with.
  • :strict — when false, the function is also called with error and unknown arguments, as {:error, %CEL.Error{}} and {:unknown, %CEL.Unknown{}}. Defaults to true.

Other fields are used by CEL's built-in functions and may change.

Summary

Types

t()

@type t() :: %CEL.Function.Overload{
  args: CEL.Function.args(),
  combine: CEL.Function.combine(),
  eval: CEL.Function.eval(),
  eval_context: [CEL.Function.eval_context()],
  id: String.t(),
  on_dyn: CEL.Function.on_dyn(),
  result: CEL.Function.result(),
  strict: boolean()
}