Rete.IR.Expr (Rete v0.1.0)

Copy Markdown View Source

A compile-time generated named function that lives in the ruleset module.

Expressions are the only executable part of the IR. They are emitted as public side-effect-free functions in the module that used Rete.Ruleset, so they can be captured, compared and shared between rules.

:code is a stable, readable unique id. Two structurally identical conditions in one module context produce the same code, which is what lets the network share nodes. :kind fixes the calling convention: :alpha is (fact) -> bindings_map | nil, :test is (bindings_map) -> boolean, and :join_filter is (token_bindings, fact_bindings) -> boolean. :fun is nil until the expression is escaped, and :__ast__ is compile-time only.

Summary

Types

What an expression is used for; fixes its calling convention.

t()

Types

kind()

@type kind() :: :alpha | :test | :join_filter

What an expression is used for; fixes its calling convention.

t()

@type t() :: %Rete.IR.Expr{
  __ast__: %{args: Macro.t(), body: Macro.t()} | nil,
  arity: 1 | 2,
  code: atom(),
  fun: (... -> any()) | nil,
  kind: kind() | nil,
  name: atom()
}