Rete.IR.Test (Rete v0.8.0)

Copy Markdown View Source

A guard over bindings only, with no fact input.

A rule-level guard produces this — defrule r(...) when <guard> do — and so do guards lifted out of a condition, when they only reference variables bound upstream. :bind is what the guard reads, not what it introduces.

:source records which of the two the author wrote, so that a message about the guard names the construct they can find in their file. The advice differs as well. A head guard reads only what the head binds, so it cannot move onto a condition the way a rule level guard can. It is compile-time only, in the way :__ast__ is, and Rete.IR.escape/1 drops it.

It has no default, for the same reason :__ast__ has none. A default of :rule would survive escape/1 and read as a claim about what the author wrote, which the escaped struct cannot make. nil records that nobody asked. Rete.DSL.Parser sets it at both places that build a test.

Summary

Types

t()

@type t() :: %Rete.IR.Test{
  __ast__: %{guard: Macro.t(), bind: %{required(atom()) => Macro.t()}} | nil,
  bind: [atom()],
  expr: Rete.IR.Expr.t(),
  source: :rule | :head | nil
}