Logic Functions

Logic Functions

if

available since: 1.0.0

Conditional control flow function. Only one of 'then' or 'else' is executed.

struct {
  • condition :bool
  • else :E
  • then :T
}
  • T
  • E

Example:

Query:
e.if({
  • condition: e.equal(d.string("foo"), d.string("bar")),
  • then: d.string("foo and bar are equal"),
  • else: d.string("foo and bar are not equal"),
}
)
Result:
"foo and bar are not equal"

not

available since: 1.0.0

not logically negates its boolean argument.

expression...boolbool

Example:

Query:
e.not(d.bool(true))

assertModelRef

available since: 1.0.0

Takes a model ref and asserts its case to be a "case".

struct {
  • ref :refmodel(T)
  • value :union {}
}
struct {}

Example:

Query:
e.assertModelRef({
  • ref: e.tag(d.string("_tag")),
  • value: e.first(e.all(e.tag(d.string("_tag")))),
}
)
Result:
{ "model": [ "RumQCGlURNcXIqvD", "qWbVomsJmZDcxXUf" ], "tag": "_role" }

or

available since: 1.0.0

or takes a list of boolean expressions and returns logical or.

listexpression...boolbool

Example:

Query:
e.or(d.bool(true), d.bool(false))
Result:
true

switchCase

available since: 1.0.0

Takes a union and switches on its case. Returns the result of calling the matching case expression in "cases" with the unwrapped union value.

struct {}T

Example:

Query:
e.switchCase(e.data(d.union("foo", d.string("bar"))), e.foo(f.function(["_value_0"], {
  • scope: "_value_0",
}
)
)
)
Result:
"bar"

with

available since: 1.0.0

Passes the result of an expression as the first parameter of the given function.

Example:

Query:
e.with(d.string("foo"), f.function(["_value_0"], {
  • scope: "_value_0",
}
)
)
Result:
"foo"

assertCase

available since: 1.0.0

Takes a union and asserts its case to be a "case". It returns the unwrapped union value or an error if the assertion fails.

struct {}T

Example:

Query:
e.assertCase({
  • case: "foo",
  • value: e.data(d.union("foo", d.string("bar"))),
}
)
Result:
"bar"

equal

available since: 1.0.0

equal takes a tuple of two values of any type and reports whether they are the same.

Example:

Query:
e.equal(d.string("foo"), d.string("bar"))

assertPresent

available since: 1.0.0

Takes an arbitrary value that could be null and asserts that it is not null. Returns an error if the assertion fails.

T

Example:

Query:
e.assertPresent(d.string("foo"))
Result:
"foo"

switchModelRef

available since: 1.0.0

Takes a persistent value and switches on its model ref. Returns the result of calling the matching case expression or default if none matched.

struct {
  • cases :mapexpressionTS
  • default :expressionTD
  • value :T
}
  • S
  • D

and

available since: 1.0.0

and takes a list of boolean expressions and returns logical and.

listexpression...boolbool

Example:

Query:
e.and(d.bool(true), d.bool(false))