CEL.Function (CEL v0.2.0)

Copy Markdown View Source

A custom CEL function, registered with CEL.Env.build/1's :functions option. See the "Custom CEL functions" guide.

  • :name — the name expressions call it by.
  • :modes — how it is called: :global (f(x), the default), :receiver (x.f(y), where x is the first argument), or {:namespace, "ns"} (ns.f(x)). A function may list several.
  • :overloads — one CEL.Function.Overload per signature.

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

Summary

Types

Used by CEL's built-in functions.

{Module, function}; the other forms are CEL's own.

Extra arguments an overload's :eval receives; see CEL.Function.Overload.

How expressions call a function; :intrinsic is for operators.

Used by CEL's built-in functions.

An argument or result type: a CEL.Type.t/0, or {:param, name} for a type parameter. CEL's built-in functions use further forms.

t()

Types

args()

@type args() :: [pattern()]

combine()

@type combine() :: :assignable | :common

Used by CEL's built-in functions.

eval()

@type eval() :: nil | :intrinsic | {:mfa, mfa_target()} | mfa_target()

{Module, function}; the other forms are CEL's own.

eval_context()

@type eval_context() :: :types | :vars | :call

Extra arguments an overload's :eval receives; see CEL.Function.Overload.

mode()

@type mode() :: :global | :receiver | :intrinsic | {:namespace, String.t()}

How expressions call a function; :intrinsic is for operators.

on_dyn()

@type on_dyn() :: :match | :fallback

Used by CEL's built-in functions.

pattern()

@type pattern() :: CEL.Type.t() | {:param, String.t()} | builtin_pattern()

An argument or result type: a CEL.Type.t/0, or {:param, name} for a type parameter. CEL's built-in functions use further forms.

result()

@type result() :: pattern()

t()

@type t() :: %CEL.Function{
  dynamic_overloads: [CEL.Function.Overload.t()],
  modes: [mode()],
  name: String.t(),
  overloads: [CEL.Function.Overload.t()]
}