state

a state is every action folded over the empty state.

run actions through step, starting from no todos.

=> |% +$ todo [done=? text=@t] +$ action $% [%add text=@t] [%done index=@ud] == ++ step |= [todos=(list todo) =action] ^- (list todo) ?- -.action %add (snoc todos [%.n text.action]) :: %done =/ old (snag index.action todos) =/ finished=todo old(done %.y) (snap todos index.action finished) == ++ actions ^- (list action) :~ [%add 'milk'] [%add 'eggs'] [%done 1] [%add 'bread'] == --
glossary

=> sets the subject to its head, then evaluates its tail against it.

=>([a=1 b=2] b) is 2.

|% makes a core: a battery of named arms, each written ++ name.

reach an arm back out with =< or arm:core.

=<  a
|%
++  a  5
--

is 5.

^: turns a type into a factory gate that molds any noun to that type.

(^:(@ud) 5) is 5.

$: makes a tuple mold, naming each face in a cell.

$:(x=@ y=@) is the mold [x=@ y=@].

$= wraps a mold with a face, naming the value it produces.

$=(x @) is the mold x=@.

|= makes a gate: a function with one named sample, then a body.

the body runs with the sample bound.

call the gate to run it.

(|=(a=@ (add a 1)) 4) is 5.

list is the type of a null-terminated sequence.

(list @) is a list of atoms; the empty list is ~.

^- casts a value to a named type: it checks the value fits and relabels it.

^-(@ 42) is 42.

irregular forms:

a leading backtick cast - the type in backticks, then the value - is ^-

?- switches on a tagged union, requiring a branch for every case - no default.

?-(& %.y 1 %.n 2) is 1.

%: calls a gate with several arguments, gathering them into one sample.

%:(add 2 3) is 5.

irregular forms:

(gate a b c) is %:(gate a b c)

snoc appends one element to the end of a list.

(snoc `(list @)`~[1 2] 4) is ~[1 2 4].

:* makes a tuple of many elements, nesting to the right.

:*(1 2 3) is [1 2 3].

irregular forms:

[a b c d] is :*(a b c d)

=/ pins a named value (a face) into the subject for the lines below it.

name=value optionally declares the type.

=/(a 3 (add a a)) is 6.

snag picks a list element by index, counting from zero.

(snag 1 `(list @)`~[8 9 10]) is 9.

%= resolves a wing with some faces changed.

=/(a [x=1 y=2] a(x 9)) is [x=9 y=2].

irregular forms:

a(x 9) is %=(a x 9)

$(a b) restarts a loop with a changed to b

snap replaces the element at an index, giving the new list.

(snap `(list @)`~[1 2 3] 1 9) is ~[1 9 3].

:~ makes a null-terminated list.

:~(1 2 3) is ~[1 2 3].

irregular forms:

~[a b c] is :~(a b c)

$% makes a head-tagged union: each case is a cell led by a @tas tag that picks it.

$%([%a p=@] [%b q=@]) is an %a cell or a %b cell.