Rete.IR.Production (Rete v0.2.0)

Copy Markdown View Source

A rule or a query.

t/0 types every field. Three are not obvious:

  • :name names the production, but the generated RHS function is rhs_name/1 of it instead — a query owns its own name in its module.
  • :bind comes from the classified LHS, via lhs_bindings/1. So it excludes a negation's variables, and it is the union over a disjunction's branches. A variable only some branches bind is not in every token, so the RHS reads it defensively.
  • :rhs is nil until the production is escaped. The engine logically inserts and truth-maintains its return value. nil or [] inserts nothing.

Summary

Types

t()

@type t() :: %Rete.IR.Production{
  __ast__: map() | nil,
  bind: [atom()],
  hash: integer(),
  lhs: Rete.IR.lhs(),
  module: module(),
  name: atom(),
  opts: keyword(),
  rhs: (integer(), map() -> any()) | nil,
  type: :rule | :query
}