Rete.IR.Production (Rete v0.1.0)

Copy Markdown View Source

A rule or a query.

Fields are typed by t/0. Three are not obvious:

  • :name names the production, but the generated RHS function is rhs_name/1 of it, because a query owns its own name in its module.
  • :bind is computed from the classified LHS by lhs_bindings/1, so it excludes a negation's variables and 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. Its return value is logically inserted and truth maintained, and 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
}