cascalog.logic.predmacro documentation

This namespace contains functions that help to define predicate
macro instances, and compile predicate macro instances out into
sequences of RawPredicate instances.

IPredMacro

build-predmacro

(build-predmacro input-decl output-decl raw-predicates)
Build a predicate macro via input and output declarations. This
function takes a sequence of declared inputs, a seq of declared
outputs and a sequence of raw predicates. Upon use, any variable
name not in the input or output declarations will be replaced with a
random Cascalog variable (uniqued by appending a suffix, so nullable
vs non-nullable will be maintained).

expand

(expand _ input output)
Returns a sequence of vectors suitable to feed into
cascalog.parse/normalize.

predmacro

macro

(predmacro & body)
A more general but more verbose way to create predicate macros.

Creates a function that takes in [invars outvars] and returns a
list of predicates. When making predicate macros this way, you must
create intermediate variables with gen-nullable-var(s). This is
because unlike the (<- [?a :> ?b] ...) way of doing pred macros,
Cascalog doesn't have a declaration for the inputs/outputs.

See https://github.com/nathanmarz/cascalog/wiki/Predicate-macros

predmacro*

(predmacro* fun)
Functional version of predmacro. See predmacro for details.

predmacro?

(predmacro? o)

use-as-filter?

(use-as-filter? output-decl outvars)
If a predicate macro had a single output variable defined and you
try to use it with no output variables, the predicate macro acts as
a filter.

validate-declarations!

(validate-declarations! input-decl output-decl)
Assert that the same variables aren't used on input and output when
defining a predicate macro.