Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Grid diagrams

The transaction-aligned species: rows sharing one discrete, labelled time axis, mixing event streams with held-value cells. See the syntax reference for the notation.

Each diagram below is rendered from the file named beneath it, pulled straight out of the Swirly submodule.

gridAxis

The apparatus on its own: a labelled transaction axis, a dashed boundary opening each column, and a stream that never fires.

t012s

examples/gridAxis.txt
% A transaction grid. Grid mode replaces the continuous marble timeline with a
% discrete, labelled axis that every row shares: `@` declares the columns, and
% one dashed boundary opens each of them.
%
% `>` declares a stream row. Its slots are empty here, so the line just runs
% through — Sodium streams never complete, so there is no `|` to write.

@ t | 0 | 1 | 2

> s |  |  |

gridStreams

Three streams sharing one axis. Where two of them fire in the same transaction, that is a single column, so you can see it at a glance.

t0123402s1102030s2

examples/gridStreams.txt
% Stream rows carry one slot per transaction, so the source lines up with the
% diagram. A value is typeset on the line rather than inside a marble, and a
% blank slot means the stream did not fire in that transaction.

@ t | 0 | 1 | 2 | 3 | 4

> s1 | 0 |    | 2  |    |

> s2 |   | 10 | 20 | 30 |

gridCell

A cell holds a value until something replaces it. The dividers are derived from the slots, falling wherever a slot carries a value.

t012345‘a’‘b’‘c’c

examples/gridCell.txt
% A cell row holds a value across an interval. `=` declares one, and its box is
% divided wherever the held value changes: a non-empty slot opens a new run and
% a blank one extends the run before it, so the dividers are derived rather
% than written out.

@ t | 0 | 1 | 2 | 3 | 4 | 5

= c | 'a' |  | 'b' |  | 'c' |

gridHold

hold turns a stream into a cell, one transaction behind, and to closes the box before the axis ends.

t012345‘a’‘b’‘c’c‘b’‘c’s1

examples/gridHold.txt
% `hold` turns a stream into a cell, one transaction behind: s1 fires 'b' in
% transaction 1 and c starts holding it in transaction 2.
%
% `to` closes the box early, at the boundary that opens the column it names.
% The line carries on to the same arrowhead every other row reaches.

@ t | 0 | 1 | 2 | 3 | 4 | 5

= c | 'a' |  | 'b' |  | 'c' |
to = 5

> s1 |  | 'b' |  | 'c' |  |

gridSwitch

switch: a slot naming another row refers to that row rather than being a literal, so c3 holds first c1 and then c2.

t01234‘a’‘b’‘c’‘d’‘e’c1‘V’‘W’‘X’‘Y’‘Z’c2c1c2c3‘a’‘b’‘X’‘Y’‘Z’c4

examples/gridSwitch.txt
% `switch` — a cell whose value is another cell. A slot naming another row in
% the diagram resolves to a reference to that row rather than to a literal, so
% c3 holds c1 and then c2, and c4 is what the switched cell yields.

@ t | 0 | 1 | 2 | 3 | 4

= c1 | 'a' | 'b' | 'c' | 'd' | 'e'

= c2 | 'V' | 'W' | 'X' | 'Y' | 'Z'

= c3 | c1 |  | c2 |  |

= c4 | 'a' | 'b' | 'X' | 'Y' | 'Z'

gridAnnotations

Annotation rows address the same columns as everything else but draw no line, for commenting on a transaction.

t012345‘a’‘b’c‘a’a1‘b’a2

examples/gridAnnotations.txt
% Annotation rows, declared with `.`, address the same columns as every other
% row but draw no line of their own — they comment on a transaction rather than
% carrying a stream or a cell.

@ t | 0 | 1 | 2 | 3 | 4 | 5

= c | 'a' |  | 'b' |  |  |
to = 3

. a1 |  | 'a' |  |  |  |

. a2 |  |  | 'b' |  |  |

gridNested

Split transactions. A column label can name a nested transaction, and each level of nesting lightens the line that opens it.

t[0][0,0][0,1][1][1,0][‘a’,‘b’][‘c’]s1‘a’‘b’‘c’s2

examples/gridNested.txt
% Split transactions. A column label may name a nested transaction, and each
% leading `>` on it marks one more level of nesting, which lightens the grid
% line that opens that column.

@ t | [0] | >[0,0] | >[0,1] | [1] | >[1,0]

> s1 | ['a','b'] |  |  | ['c'] |

> s2 |  | 'a' | 'b' |  | 'c'