Rete.Network.Node.Query (Rete v0.8.0)

Copy Markdown View Source

A terminal node for a query. Holds the tokens that reached it, to be read back by name.

:params is what the head of the query binds. These are the keys of its tokens, and they are the only way to read it. Rete.Engine.query/3 takes exactly these, so a read is one map lookup. An empty list is a query with no parameters, or one whose head binds nothing. Its tokens all key on %{}, and they come back in arrival order.

The patterns of the head do not reach here. The generated function matches them, and hands this node the bindings it took out. See Rete.DSL.Codegen.query_def/1.

:head is those patterns rendered as source, one string each, and [] for a query with no head. Nothing matches on it. It is here for one message: a bare name given to Rete.Engine.query/3 names the call to write in its place. Without this the message would print a placeholder, because nothing else here knows the head.

Summary

Types

t()

@type t() :: %Rete.Network.Node.Query{
  bind: [atom()],
  hash: integer(),
  head: [String.t()],
  id: non_neg_integer() | nil,
  module: module(),
  name: atom(),
  params: [atom()],
  rhs: fun()
}