Skip to content

Expression Language Reference

Constants

Noop

Signature: Const

Aliases: _

No operation

Returns true without input validation. Used in place of matchers for uninteresting signals.

Null

Signature: Const

Null value

True

Signature: Const

Logical true

False

Signature: Const

Logical false

Pi

Signature: Const

Pi constant

E

Signature: Const

Euler's number

Inf

Signature: Const

Infinity

Eps

Signature: Const

Machine epsilon

NaN

Signature: Const

Not a number

Thread

Signature: Const

Thread id

Not really a constant, but useful for branching the test input conditions.

Math Functions

Sin

Signature: Unary

Sinus function

Cos

Signature: Unary

Cosinus function

Tan

Signature: Unary

Tangens function

Asin

Signature: Unary

Arcsin function

Acos

Signature: Unary

Arccos function

Atan

Signature: Unary

Arctan function

Sinh

Signature: Unary

Hyperbolic sin

Cosh

Signature: Unary

Hyperbolic cos

Tanh

Signature: Unary

Hyperbolic tan

Asinh

Signature: Unary

Hyperbolic arcsin

Acosh

Signature: Unary

Hyperbolic arccos

Atanh

Signature: Unary

Hyperbolic arctan

Exp

Signature: Unary

Exponential (e^x)

Erf

Signature: Unary

Error function

Erfc

Signature: Unary

Error function complement

Gamma

Signature: Unary

Gamma function

Abs

Signature: Unary

Absolute value

Ceil

Signature: Unary

Ceil

Floor

Signature: Unary

Floor

Round

Signature: Unary

Round to nearest integer

Hint: To round to ndigits precision after the decimal point, use Mul(ndigits) | Round | Div(ndigits) combo.

Sqrt

Signature: Unary

Square root

Sign

Signature: Unary

Sign

Arithmetic Operators

Neg

Signature: Unary

Negate

Examples:

  • 42 | Neg\(\mapsto\)-42

Add

Signature: Binary

Addition

Examples:

  • [2, -1] | Add\(\mapsto\)1
  • 2 | Add(-1)\(\mapsto\)1

Sub

Signature: Binary

Subtraction

Examples:

  • [2, 1] | Sub\(\mapsto\)-1
  • 2 | Sub(1)\(\mapsto\)1

Mul

Signature: Binary

Multiplication

Examples:

  • [2, 3] | Mul\(\mapsto\)6
  • 2 | Mul(3)\(\mapsto\)6

Div

Signature: Binary

Division

  1. \([ ] \mapsto [x, y] \mapsto x / y\)
  2. \([y] \mapsto [x] \mapsto x / y\)

Examples:

  • [6, 3] | Div\(\mapsto\)2
  • 6 | Div(3)\(\mapsto\)2

Pow

Signature: Binary

To power

X to power p 1. \([ ] \mapsto [x, p] \mapsto x^p\) 2. \([p] \mapsto [x] \mapsto x^p\)

Examples:

  • [2, 3] | Pow\(\mapsto\)8
  • 2 | Pow(3)\(\mapsto\)8

Log

Signature: Binary

Logarithm

Logarithm with base b: 1. \([ ] \mapsto [x, b] \mapsto log_b(x)\) 2. \([b] \mapsto [x] \mapsto log_b(x)\)

Examples:

  • [8, 2] | Log\(\mapsto\)3
  • 8 | Log(2)\(\mapsto\)3

Mod

Signature: Binary

Modulo

Modulo of x: 1. \([ ] \mapsto [x, m] \mapsto x % m\) 2. \([m] \mapsto [x] \mapsto x % m\)

Examples:

  • [7, 4] | Mod\(\mapsto\)3
  • 7 | Mod(4)\(\mapsto\)3

Quot

Signature: Binary

Quotient

Quotient of x: 1. \([ ] \mapsto [x, d] \mapsto x // d\) 2. \([d] \mapsto [x] \mapsto x // d\)

Examples:

  • [7, 4] | Quot\(\mapsto\)1
  • 7 | Quot(4)\(\mapsto\)1

BitNot

Signature: Unary

Bitwise not

Examples:

  • 0b1010 | BitNot\(\mapsto\)0b0101

BitAnd

Signature: Binary

Bitwise and

Examples:

  • [0b1010, 0b1100] | BitAnd\(\mapsto\)0b1000

BitOr

Signature: Binary

Bitwise or

Examples:

  • [0b1010, 0b1100] | BitOr\(\mapsto\)0b1110

BitXor

Signature: Binary

Bitwise xor

Examples:

  • [0b1010, 0b1100] | BitXor\(\mapsto\)0b0110

BitLshift

Signature: Binary

Bitwise left shift

  1. \([ ] \mapsto [x, s] \mapsto x \texttt{ << } s\)
  2. \([s] \mapsto [x] \mapsto x \texttt{ << } s\)

Examples:

  • [0b1010, 2] | BitLshift\(\mapsto\)0b101000

BitRshift

Signature: Binary

Bitwise right shift

  1. \([ ] ↦ [x, s] ↦ x \texttt{ >> } s\)
  2. \([s] ↦ [x] ↦ x \texttt{ >> } s\)

Examples:

  • [0b1010, 2] | BitRshift\(\mapsto\)0b0010

Relation Operators

Eq

Signature: Binary

Is equal

Examples:

  • [1, 1] | Eq\(\mapsto\)true
  • 41 | Eq(42)\(\mapsto\)false

Ne

Signature: Binary

Not equal

Examples:

  • [1, 2] | Ne\(\mapsto\)true
  • 42 | Ne(42)\(\mapsto\)false

Lt

Signature: Binary

Lesser than

Examples:

  • [1, 2] | Lt\(\mapsto\)true
  • 41 | Lt(42)\(\mapsto\)false

Le

Signature: Binary

Lesser or equal

Examples:

  • [1, 2] | Le\(\mapsto\)true
  • 42 | Le(42)\(\mapsto\)true

Gt

Signature: Binary

Greater than

Examples:

  • [2, 1] | Gt\(\mapsto\)true
  • 43 | Gt(42)\(\mapsto\)false

Ge

Signature: Binary

Greater or equal

Examples:

  • [2, 1] | Ge\(\mapsto\)true
  • 42 | Ge(42)\(\mapsto\)true

Approx

Signature: Binary

Aliases: near

Floating point approximately equal

Based on numpy.isclose: abs(x - ref) <= (atol + rtol * abs(ref))

Rhs parameters: ref: reference value rtol: relative tolerance, default = 1e-05 atol: absolute tolerance, default = 1e-08

Rhs dynamic evaluation: 1. ref -> [ref, default, default] 2. [ref] -> [ref, default, default] 3. [ref, rtol] -> [ref, rtol , default] 4. [ref, rtol, atol] -> [ref, rtol , atol ]

Examples:

  • [42, 42] | Approx\(\mapsto\)true
  • 42 | Approx(42.0 + 1e-09)\(\mapsto\)true
  • 42 | Approx(42.001)\(\mapsto\)false

Relative tolerance 1e-03 * pi | Approx([3.14, 0.001])\(\mapsto\)true Absolute tolerance 0.01 * pi | Approx([3.14, 0, 0.01])\(\mapsto\)true

Set Operators

Union

Signature: Binary

Set union

Examples:

  • [[1, 2], [2, 3]] | Union\(\mapsto\)[1, 2, 3]
  • [1, 2] | Union([2, 3])\(\mapsto\)[1, 2, 3]

Intersect

Signature: Binary

Set intersection

Examples:

  • [[1, 2], [2, 3]] | Intersect\(\mapsto\)[2]
  • [1, 2] | Intersect([2, 3])\(\mapsto\)[2]

Diff

Signature: Binary

Set difference

Examples:

  • [[1, 2], [2, 3]] | Diff\(\mapsto\)[1]
  • [1, 2] | Diff([2, 3])\(\mapsto\)[1]

Set Relation Operators

SetEq

Signature: Binary

Equal as set

Examples:

  • [[1, 2], [2, 1]] | SetEq\(\mapsto\)true
  • [1, 2] | SetEq([2, 1])\(\mapsto\)true

Subset

Signature: Binary

Is subset

Examples:

  • [[1, 2], [1, 2, 3]] | Subset\(\mapsto\)true
  • [1, 2] | Subset([1, 2, 3])\(\mapsto\)true

  • [[1, 2, 3], [2, 3]] | Subset\(\mapsto\)false

  • [1, 2, 3] | Subset([2, 3])\(\mapsto\)false

  • [[1, 2], []] | Subset\(\mapsto\)true

  • [[], []] | Subset\(\mapsto\)true

Superset

Signature: Binary

Is superset

Examples:

  • [[1, 2, 3], [1, 2]] | Superset\(\mapsto\)true
  • [1, 2, 3] | Superset([1, 2])\(\mapsto\)true

  • [[2, 3], [1, 2, 3]] | Superset\(\mapsto\)false

  • [2, 3] | Superset([1, 2, 3])\(\mapsto\)false

  • [[], [1, 2]] | Superset\(\mapsto\)true

  • [[], []] | Superset\(\mapsto\)true

ProperSubset

Signature: Binary

Is proper subset

Examples:

  • [[1, 2], [1, 2, 3]] | ProperSubset\(\mapsto\)true
  • [1, 2] | ProperSubset([1, 2, 3])\(\mapsto\)true

  • [[1, 2, 3], [2, 3]] | ProperSubset\(\mapsto\)false

  • [1, 2, 3] | ProperSubset([2, 3])\(\mapsto\)false

  • [[1, 2], []] | ProperSubset\(\mapsto\)true

  • [[], []] | ProperSubset\(\mapsto\)false

ProperSuperset

Signature: Binary

Is proper superset

Examples:

  • [[1, 2, 3], [1, 2]] | ProperSuperset\(\mapsto\)true
  • [1, 2, 3] | ProperSuperset([1, 2])\(\mapsto\)true

  • [[2, 3], [1, 2, 3]] | ProperSuperset\(\mapsto\)false

  • [2, 3] | ProperSuperset([1, 2, 3])\(\mapsto\)false

  • [[], [1, 2]] | ProperSuperset\(\mapsto\)true

  • [[], []] | ProperSuperset\(\mapsto\)false

In

Signature: Binary

Element is in

Examples:

  • [1, [1, 2]] | In\(\mapsto\)true
  • 3 | In([1, 2])\(\mapsto\)false

NotIn

Signature: Binary

Element is not in

Examples:

  • [3, [1, 2]] | NotIn\(\mapsto\)true
  • 1 | NotIn([1, 2])\(\mapsto\)false

Ni

Signature: Binary

Aliases: contains

Contains element

Examples:

  • [[1, 2], 1] | Ni\(\mapsto\)true
  • 3 | Ni([1, 2])\(\mapsto\)false

NotNi

Signature: Binary

Not contains element

Examples:

  • [[1, 2], 3] | NotNi\(\mapsto\)true
  • 1 | NotNi([1, 2])\(\mapsto\)false

Branching Operators

Bool

Signature: Unary

Aliases: truthy

Predicate on boolean transform (aka truthy)

Examples:

  • 42 | Bool\(\mapsto\)true
  • 0 | Bool\(\mapsto\)false
  • "false" | Bool\(\mapsto\)true
  • "" | Bool\(\mapsto\)false
  • [1] | Bool\(\mapsto\)true
  • [] | Bool\(\mapsto\)false
  • {} | Bool\(\mapsto\)false
  • null | Bool\(\mapsto\)false

Not

Signature: Unary

Aliases: falsy, nil

Logical complement

Examples:

  • 42 | Nil\(\mapsto\)false
  • 0 | Nil\(\mapsto\)true

And

Signature: Binary

Logical and

Generic behavior: if first operand is truthy, returns second operand, otherwise first

Examples:

  • [true, false] | And\(\mapsto\)false
  • [true, true] | And\(\mapsto\)true

Generic behavior:

  • ["foo", [42, 43]] | And\(\mapsto\)[42, 43]
  • ["" , [42, 43]] | And\(\mapsto\)""

  • 13 | And(42)\(\mapsto\)42

  • [] | And(42)\(\mapsto\)[]

If-Else using composition:

  • true | And(42) | Or(13)\(\mapsto\)42
  • false | And(42) | Or(13)\(\mapsto\)13

Or

Signature: Binary

Logical or

Generic behavior: if first operand is truthy, returns first operand, second otherwise

Examples:

  • [true, false] | Or\(\mapsto\)true
  • [false, false] | Or\(\mapsto\)false

Generic behavior:

  • ["foo", [42, 43]] | Or\(\mapsto\)"foo"
  • ["" , [42, 43]] | Or\(\mapsto\)[42, 43]

  • 13 | Or(42)\(\mapsto\)13

  • [] | Or(42)\(\mapsto\)42

If-Else using composition:

  • true | And(42) | Or(13)\(\mapsto\)42
  • false | And(42) | Or(13)\(\mapsto\)13

Unary Structural transforms

Id

Signature: Unary

Identity function

Examples:

  • 42 | Id\(\mapsto\)42

Transp

Signature: Unary

Transpose multidimensional list, turning rows into columns

May be used to zip sequences of equal length.

Examples:

  • [[1, 2, 3], [4, 5, 6]] | Transp\(\mapsto\)[[1, 4], [2, 5], [3, 6]]

Cartesian

Signature: Unary

Cartesian product

Examples:

  • [[1, 2], [3, 4]] | Cartesian\(\mapsto\)[[1, 3], [1, 4], [2, 3], [2, 4]]

Reverse

Signature: Unary

Reverse sequence

Examples:

  • [1, 2, 3] | Reverse\(\mapsto\)[3, 2, 1]

Uniques

Signature: Unary

Filter unique elements

Examples:

  • [1, 2, 1, 3, 2] | Uniques\(\mapsto\)[1, 2, 3]

Items

Signature: Unary

Extract key-value pairs from object

Examples:

  • {"a": 1, "b": 2} | Items\(\mapsto\)[["a", 1], ["b", 2]]

Keys

Signature: Unary

Extract keys from object

Examples:

  • {"a": 1, "b": 2} | Keys\(\mapsto\)["a", "b"]

Values

Signature: Unary

Extract values from object

Examples:

  • {"a": 1, "b": 2} | Values\(\mapsto\)[1, 2]

Enumerate

Signature: Unary

Enumerate sequence

Enumerate sequence with index.

Examples:

  • [1, 2, 3] | Enumerate\(\mapsto\)[[0, 1], [1, 2], [2, 3]]

Flatten

Signature: Unary

Flatten nested list

Examples:

  • [[1, 2], [3, 4]] | Flatten\(\mapsto\)[1, 2, 3, 4]

ToList

Signature: Unary

Put argument into a list

Equivalent to At([""])

Examples:

  • 42 | List\(\mapsto\)[42]

Unary Generators

Arange

Signature: Unary

Generate range of numbers

Return evenly spaced values within a given interval.

Parameters: 1. start: start value 2. stop: stop value 3. step: step value

Parameters dynamic evaluation: 1. stop: int -> [0, stop, 1] 2. [start, stop] -> [start, stop, 1] 3. [start, stop, step] -> [start, stop, step]

Examples:

  • 6 | Arange\(\mapsto\)[0,1,2,3,4,5]
  • [2,6] | Arange\(\mapsto\)[2,3,4,5]
  • [1,9,2] | Arange\(\mapsto\)[1,3,5,7]
  • [5,1,-1] | Arange\(\mapsto\)[5,4,3,2]

  • "2:6" | Arange\(\mapsto\)[2,3,4,5]

  • "1:9:2" | Arange\(\mapsto\)[1,3,5,7]
  • "5:1:-1" | Arange\(\mapsto\)[5,4,3,2]

String Transforms

Parse

Signature: Unary

Parse string as json

Examples:

  • '{"a": 42}' | Parse\(\mapsto\){"a": 42}

Serialize

Signature: Unary

Aliases: str

Serialize json as string

Examples:

  • {"a": 42} | Serialize\(\mapsto\)'{"a":42}'

Re

Signature: Binary

Aliases: regex

Regular expression match

If input is not a string, match it's serialized form.

Examples:

  • ["[0-9]+", "42"] | Re\(\mapsto\)true
  • "42" | Re("[0-9]+")\(\mapsto\)true

Format

Signature: Variadic

Aliases: fmt

Format string with the given parameter list.

Constant expressions are supported for the token list, s.t. "%s" | Fmt(Pi) produces "3.141592653589793E0"

Examples:

  • ["Hello, %s!", ["world"]] | Format\(\mapsto\)"Hello, world!"
  • "%d + %d = %d" | Format(2,2,4)\(\mapsto\)"2 + 2 = 4"

Structural properties

Card

Signature: Unary

Set cardinality (uniques count)

Examples:

  • [1, 2, 1, 3, 2] | Card\(\mapsto\)3
  • {"a": 1, "b": 2} | Card\(\mapsto\)2

Size

Signature: Unary

Sequence size

Examples:

  • [1, 1, 1] | Size\(\mapsto\)3
  • {"a": 1, "b": 2} | Size\(\mapsto\)2

Sum

Signature: Unary

Summation reduction

Equivalent to Reduce(Add)

Examples:

  • [1, 2, 3] | Sum\(\mapsto\)6

Prod

Signature: Unary

Multiplication reduction

Equivalent to Reduce(Mul)

Examples:

  • [1, 2, 3] | Prod\(\mapsto\)6

Avg

Signature: Unary

Arythmetic average

Examples:

  • [1, 2, 3] | Avg\(\mapsto\)2

Binary Structural transforms

Slide

Signature: Binary

Sliding-window iteration

Sliding window iteration by specified window width.

Examples:

  • [1,2,3,4,5] | Slide(3)\(\mapsto\)[[1,2,3],[2,3,4],[3,4,5]]
  • [1,2,3,4,5] | Slide(42)\(\mapsto\)[]

Stride

Signature: Binary

Striding iteration

Striding iteration by specified step width. Reminder subsequence smaller then step width is discarded.

Examples:

  • [1,2,3,4,5,6] | Stride(2)\(\mapsto\)[[1,2],[3,4],[5,6]]
  • [1,2,3,4,5] | Stride(3)\(\mapsto\)[[1,2,3]]

Chunks

Signature: Binary

Split into chunks of specified max width

Similar to Stride, but includes the last subsequence smaller then step width.

Examples:

  • [1,2,3,4,5,6] | Chunks(2)\(\mapsto\)[[1,2],[3,4],[5,6]]
  • [1,2,3,4,5] | Chunks(3)\(\mapsto\)[[1,2,3],[4,5]]

Repeat

Signature: Binary

Repeat value in list

Examples:

  • 42 | Repeat(3)\(\mapsto\)[42, 42, 42]
  • 1 | Repeat(3) | Repeat(2)\(\mapsto\)[[1,1,1],[1,1,1]]

Concat

Signature: Binary

Aliases: cat

Concatenate sequences

Examples:

  • [[1, 2], [3, 4]] | Concat\(\mapsto\)[1, 2, 3, 4]
  • "Hello, " | Concat("World!")\(\mapsto\)"Hello, World!"

Push

Signature: Binary

Push element into a front of sequence

Examples:

  • [[1, 2], 3] | Push\(\mapsto\)[3, 1, 2]
  • [1, 2] | Push(3)\(\mapsto\)[3, 1, 2]

At

Signature: Binary

Transform json value with given query

Query evaluation rules:

  1. Array index (negative resolves as reverse): \(q: int \mapsto x: list \mapsto x_q\)
  2. Array slice: \(q: slice \mapsto x: list \mapsto x[start:stop:step]\)
  3. JSON Pointer: \(q: str \mapsto x: any \mapsto x_q\)
  4. Array pack: \(q: list \mapsto x: any \mapsto [x_{q_1}, x_{q_2}, ...]\)
  5. Object pack: \(\{key: q_1, \$q_2: q_3, ...\} \mapsto x: any \mapsto \{ key: x_{q_1}, q_2: x_{q_3}, ...\}\)

Examples:

Array index:

  • [1, 2, 3] | At(2)\(\mapsto\)3
  • [1, 2, 3] | At(3)\(\mapsto\)nullptr
  • 42 | At(0)\(\mapsto\)nullptr

Array slice:

  • [1,2,3,4,5,6,7,8] | At("::2")\(\mapsto\)[1,3,5,7]
  • [1,2,3,4,5,6,7,8] | At("4:")\(\mapsto\)[5,6,7,8]
  • [1,2,3,4,5,6,7,8] | At("-1:0:-1")\(\mapsto\)[8,7,6,5,4,3,2,1]

JSON Pointer:

  • "foo" | At("")\(\mapsto\)"foo"
  • {"a": 42, "b": 13} | At("/a")\(\mapsto\)42

Array pack:

  • {"a": 42, "b": 13} | At(["/a", "/b"])\(\mapsto\)[42, 13]
  • 42 | At([""])\(\mapsto\)[42]

Object pack:

  • {"a": 42, "b": 13} | At({"f": "/a", "g": "/b"})\(\mapsto\){"f": 42, "g": 13}
  • {"a": 42, "b": 13} | At({"$/b": "/a"})\(\mapsto\){"13": 42}

Lookup

Signature: Binary

Lookup table function

Parametrized at design time with fixed array or object, produces the value at corresponding At query given as eval-time argument. Equivalent to Flip(At(...))

Examples:

  • 0 | Lookup([1,2,3])\(\mapsto\)1
  • "/foo" | Lookup([1,2,3])\(\mapsto\)null

C

Signature: Binary

Aliases: let

User-defined constant

Produced expression will return the design-time parameter on evaluation, ignoring input.

Examples:

  • 13 | C(42)\(\mapsto\)42

Decorate

Signature: Special

Aliases: cast

Reserialize decorated type as decorator

Undecorate

Signature: Special

Aliases: uncast

Reserialize decorator as decorated type

High-Order

Reduce

Signature: Binary

Aliases: fold

Reduce sequence with binary operator

To set specific initial value, use composition with Push, e.g. Push(0) | Reduce(Add)

For reverse operation, see Unfold

Examples:

  • [-1, 2, 3] | Reduce(Add)\(\mapsto\)4
  • [-1, 2, 3] | Reduce(Mul)\(\mapsto\)-6

Map

Signature: Binary

Apply param expr to every element of sequence

Examples:

  • [1, 2, 3] | Map(Add(1))\(\mapsto\)[2, 3, 4]

Filter

Signature: Binary

Filter sequence by predicate param

Examples:

  • [1, 2, 3, 4] | Filter(Gt(2))\(\mapsto\)[3, 4]

Count

Signature: Binary

Count matches by predicate param

Examples:

  • [1, 2, 3, 4] | Count(Gt(2))\(\mapsto\)2

Each

Signature: Binary

Test predicate for each item in a sequence

Equivalent to Count(p | Not) | Eq(0)

Examples:

  • [1, 2, 3, 4] | Each(Gt(2))\(\mapsto\)false
  • [1, 2, 3, 4] | Slide(2) | Each(Lt)\(\mapsto\)true

Sort

Signature: Binary

Sort list by key function

Examples:

  • [3, 1, 2] | Sort\(\mapsto\)[1, 2, 3]
  • [3, 1, 2] | Sort(Id)\(\mapsto\)[1, 2, 3]
  • [-3, 1, -2] | Sort(Abs)\(\mapsto\)[1, -2, -3]
  • [3, 1, 2] | Sort | Reverse\(\mapsto\)[3, 2, 1]

Min

Signature: Binary

Min value by key function

Examples:

  • [-3, 1, -2] | Min\(\mapsto\)1
  • [-3, 1, -2] | Min(Abs)\(\mapsto\)-3

Max

Signature: Binary

Max value by key function

Examples:

  • [-3, 1, -2] | Max\(\mapsto\)1
  • [-3, 1, -2] | Max(Abs)\(\mapsto\)-3

Argmin

Signature: Binary

Min value index by key function

Examples:

  • [-3, 1, -2] | Argmin\(\mapsto\)0
  • [-3, 1, -2] | Argmin(Abs)\(\mapsto\)1

Argmax

Signature: Binary

Max value index by key function

Examples:

  • [-3, 1, -2] | Argmax\(\mapsto\)1
  • [-3, 1, -2] | Argmax(Abs)\(\mapsto\)0

Recur

Signature: Ternary

Apply recursion to parameter expr and initial value

n | Recur(f, x) \(\mapsto ◯ⁿ f(x)\)

Examples:

  • 0 | Recur(Add(1), 0)\(\mapsto\)3
  • 3 | Recur(Mul(-1), 1)\(\mapsto\)-1

Unfold

Signature: Ternary

Put results of recursive fn call on initial value into an array

n | Unfold(f, x)\(\mapsto [x, ◯¹f(x), ◯²f(x), ..., ◯ⁿ f(x)]\)

Examples:

  • 3 | Unfold(Add(1), 0)\(\mapsto\)[0, 1, 2, 3]
  • 3 | Unfold(Mul(-1), 1)\(\mapsto\)[1,-1, 1,-1]

Overload

Signature: Special

Aliases: op

Bind type-specific operator handler to function

Expression Overload(op, f) instructs f to use operator op on invocation instead of the default generic.

Operator parameter singleton can be referenced with string key or constructed in place using type tag.

This operator handler is propagated downstream to all terminal subexpression in f. Result of f(x) is also reserialized (undecorated) as operator type, unless f is constant or boolean expression.

Examples:

  • [0.5, 2] | Overload("complex", Add(1))\(\mapsto\)[1.5, 2]

Bind

Signature: Variadic

!not implemented! bind design-time parameters

Any

Signature: Variadic

Match any predicate

Examples:

  • 3 | Any(Gt(2), Lt(0))\(\mapsto\)true
  • 0 | Any(Gt(2), Lt(0))\(\mapsto\)false

All

Signature: Variadic

Match all predicates

Examples:

  • 3 | All(Gt(2), Lt(0))\(\mapsto\)false
  • 2.5 | All(Gt(2), Lt(3))\(\mapsto\)true

Saturate

Signature: Variadic

Saturate matches in order

Examples:

  • 3 | Saturate(Gt(2), Lt(0))\(\mapsto\)true
  • 0 | Saturate(Gt(2), Lt(0))\(\mapsto\)false

  • [2,4,8,42,1,2] | Saturate(42, Mod(2)|0)\(\mapsto\)true

  • [2,4,8,41,2] | Saturate(42, Mod(2)|0)\(\mapsto\)false
  • [2,4,8,42] | Saturate(42, Mod(2)|0)\(\mapsto\)false

Compose

Signature: Variadic

Compose functions

Examples:

  • 3 | Compose(Add(1), Mul(2))\(\mapsto\)7
  • 4 | Compose(Add(1), Mul(2))\(\mapsto\)9

Infix operator form (pipe):

  • Add(1) | Mul(2)\(\equiv\)Compose(Mul(2), Add(1))
  • 3 | Add(1) | Mul(2)\(\mapsto\)7

Fork

Signature: Variadic

Pack results from enveloped functions into an array

Allows to combine different properties in a single expression

Examples:

  • [1,2,3] | Fork(Reduce(Add), Size)\(\mapsto\)[6,3]

Infix operator form (ampersand):

  • Add(1) & Mul(2)\(\equiv\)Fork(Add(1), Mul(2))
  • [1,2,3] | Reduce(Add) & Size\(\mapsto\)[6,3]
  • [1,2,3] | Reduce(Add) & Size | Div\(\mapsto\)2

Flip

Signature: Binary

Flips design-time and eval-time parameters.

Useful for binding lhs operands to non-commutative operators. Unlike Haskell's flip, won't change the order or eval-time parameters - for that case use the Reverse keyword instead.

Examples:

  • 2 | Div(1)\(\mapsto\)2
  • 2 | Flip(Div(1))\(\mapsto\)0.5

Try

Signature: Binary

Evaluate function and return result or null if it throws

Examples:

  • 42 | Try(Add(1))\(\mapsto\)43
  • "foo" | Try(Add(1))\(\mapsto\)null

TryCatch

Signature: Binary

Evaluate function and return result or error info if it throws

Examples:

42 | TryCatch(Div(0)) \(\mapsto\) { "err": "zero division", "fn": ":div", "x": 42 }

Evaluation handlers

Default

Signature: Binary

Aliases: d

Return x if not null, else return default value

Examples:

  • null | Default(42)\(\mapsto\)42
  • 13 | Default(42)\(\mapsto\)13

Error

Signature: Special

Error

Error object (work in progress)