Skip to content
Open Saka

Flows

A Flow names a computation. Reading it computes a Bag from data, without changing any data.

def declares a Flow. Other Flows can use its name:

def colors = {"red", "blue", "blue"}
def color_names = colors%
color_names // {"blue", "red"}

Inside braces, let names an intermediate result. The name is available after its let, and it cannot change:

def built = {
let first! num = 1
let second! num = first + 1
{first, second}
}
built // {1, 2}

The braces collect their expressions into one result Bag. A let names a result without adding it to that Bag.

SakaQL works out each Flow’s Set and cardinality from its expression. You can also state a contract, and the result must fit it:

def one! num = 1
def maybe? str = "red"
def flags* bool = {true, false}
def few: num'0..3 = {1, 2}
def wrong! num = {1, 2} // error SK4301

wrong promises exactly one number but computes two.