Macro holmes::rule
[−]
[src]
macro_rules! rule { ($holmes:ident, $head_name:ident $head_inner:tt <= $($body_name:ident $body_inner:tt)&*, {$(let $bind:tt = $hexpr:tt);*}) => { ... }; ($holmes:ident, $($head_name:ident $head_inner:tt),* <= $($body_name:ident $inner:tt)&*) => { ... }; ($($head_name:ident $head_inner:tt),* <= $($body_name:ident $inner:tt)&*) => { ... }; ($($head_name:ident $head_inner:tt),* <= $($body_name:ident $inner:tt)&*, {$(let $bind:tt = $hexpr:tt);*}) => { ... }; }
Adds a Holmes rule to the system
Datalog Rules
rule!(holmes, baz([x], (7)) <= foo((3), [_]) & bar([_], x))
will work as per a normal datalog rule, matching on foo and bar, and generating a baz using any solutions found.
Extended Rules
Holmes rules can also have "where clauses" which call out to native code in the event of a match. For example,
rule!(holmes, baz([y], (8)) <= foo((3), [_]) & bar([_], x), {
let y = {f(x)}
})
would call the Holmes registered function f
on each output of x
, bind
the result to y
, and output it in the first slot of baz
.
For more information on the expression and bind syntax, see the hexpr!
and bind_match!
macro docs.