View Source Wongi.Engine.DSL (Wongi.Engine v0.9.11)

Rule definition functions.

Summary

Functions

A matcher that computes some value across all its incoming tokens, across all execution paths.

Placeholder variable. Synonym for :_.

A matcher that passes if any of the sub-chains passes.

A matcher that always passes but declares a new variable in the token.

A filter that passes if the values are not equal.

A filter that passes if the values are equal.

A filter that passes if the value is a function that returns true.

A filter that passes if the value is a unary function that returns true.

An action that produces new facts.

A filter that passes if the first value is greater than the second.

A filter that passes if the first value is greater than or equal to the second.

A matcher that passes if the specified fact is present in the working memory.

A filter that passes if the first value is a member of the second, which is an enumerable.

A filter that passes if the first value is less than the second.

A filter that passes if the first value is less than or equal to the second.

Synonym for neg/3.

A matcher that passes if the entire sub-chain does not pass.

A matcher that passes if the specified fact is not present in the working memory.

Synonym for ncc/1.

A filter that passes if the first value is not a member of the second, which is an enumerable.

Variable declaration.

Types

@type action() :: any()
@type matcher() :: Wongi.Engine.DSL.Clause.t()
@opaque rule()
@type rule_option() :: {:forall, [matcher()]} | {:do, [action()]}

Functions

Link to this function

aggregate(fun, var, opts)

View Source

A matcher that computes some value across all its incoming tokens, across all execution paths.

The matcher produces exactly one token per partition group, unless the partition group contains no tokens, in which case the matcher does not pass for that group.

Placeholder variable. Synonym for :_.

@spec any([[matcher()]]) :: matcher()

A matcher that passes if any of the sub-chains passes.

A matcher that always passes but declares a new variable in the token.

The value can be constant or a function with arities 0, 1, or 2. A unary function receives the token as its argument. A binary function receives the token and the entire engine as its arguments.

A filter that passes if the values are not equal.

A filter that passes if the values are equal.

Link to this function

fact(s, p, o, opts \\ [])

View Source
@spec fact(any(), any(), any(), [Wongi.Engine.DSL.Has.option()]) :: matcher()

Synonym for has/3, has/4.

A filter that passes if the value is a function that returns true.

The function can have arities 0 or 1. A unary function receives the token as its argument.

A filter that passes if the value is a unary function that returns true.

The function will receive the variable as its argument.

@spec gen(any(), any(), any()) :: action()

An action that produces new facts.

Variables can be used to refer to values in the token.

A filter that passes if the first value is greater than the second.

A filter that passes if the first value is greater than or equal to the second.

Link to this function

has(s, p, o, opts \\ [])

View Source
@spec has(any(), any(), any(), [Wongi.Engine.DSL.Has.option()]) :: matcher()

A matcher that passes if the specified fact is present in the working memory.

:_ can be used as a wildcard that matches any value.

Variables can be declared using var/1. The first time a template that contains a variable is matched, the variable is bound to the value of the corresponding field in the fact. Subsequent matches will only succeed if the value of the field is equal to the bound value.

A filter that passes if the first value is a member of the second, which is an enumerable.

The name is misleading since the second value can be anything that implements Enumerable, but it is kept for similarity with the Ruby DSL.

A filter that passes if the first value is less than the second.

A filter that passes if the first value is less than or equal to the second.

@spec missing(any(), any(), any()) :: matcher()

Synonym for neg/3.

@spec ncc([matcher()]) :: matcher()

A matcher that passes if the entire sub-chain does not pass.

@spec neg(any(), any(), any()) :: matcher()

A matcher that passes if the specified fact is not present in the working memory.

Variables declared inside the neg matcher do not become bound, since the execution will only continue if there were no matching facts; however, if the same variable is used in multiple positions within the same neg template, unification will be done on it in the scope of the matcher.

@spec none([matcher()]) :: matcher()

Synonym for ncc/1.

A filter that passes if the first value is not a member of the second, which is an enumerable.

The name is misleading since the second value can be anything that implements Enumerable, but it is kept for similarity with the Ruby DSL.

@spec rule(atom(), [rule_option()]) :: rule()
@spec var(atom()) :: Wongi.Engine.DSL.Var.t()

Variable declaration.