Skip to content

Effects

Some kinds change the world: log writes a line, and write writes a value to the store. These kinds are on the run side. Their cards have a magenta edge. Each effect becomes a numbered ticket in the world, in the order of the effects.

The glyphs so far: 15, 3 new on this page
  • 42Data: a value without a type
  • number
    42
    A document: the tab is its type
  • number
    42
    A dashed tab: the container declares the type
  • add
    number
    1
    number
    2
    Parts: a card inside a card
  • kindA kind: a document of type kind
  • OKDA rung: own, kind or default
  • 3A port: the result of a document
  • 0A sealed part: an evaluator cannot read it
  • #NAME?An error value, in a red port
  • numbera
    3
    A name tag: a binding for later steps
  • ref
    namesa
    A reference: a path from a root of the context
  • if
    test
    bool
    true
    true
    then
    text
    “yes”
    “yes”
    else
    text
    “no”
    not evaluated
    “yes”
    Not evaluated: a part that its parent did not need
  • ▸log
    text
    “hi”
    “hi”
    “hi”
    The run side: a magenta edge, and an effectnew
  • 1log“hi”An effect: a numbered ticket in the worldnew
  • logA capability: an effect that a term can causenew
Open in the playground

Nothing started yet. Select Next or Play.

seq
  1. 1
    ▸log
    text
    “start”
  2. 2
    ▸writetotal
    datakey“total”
    value
    add
    number
    2
    number
    3
  3. 3
    ▸log
    ref
    namestotal
The world: the effects, in orderNo effect yet.
The result shows at the end of the evaluation.
The first log, the write and the last log happen in the written order. The tickets show the order. The write gives its value to the name total, and the last log reads it.

Only the effects have numbers. For pure parts, the order of the evaluation does not change a result. For effects, the order is the meaning.

A term can cause an effect only when its context has the capability for that effect. A construct gives its parts the same capabilities or fewer. The kind pure gives its part no capability. Thus an effect inside pure fails with #CAP!, and the world does not change.

Open in the playground

The evaluation of pure ends with the error #CAP!: The context has no capability for the effect log.

pure
▸log
text
“hello”
“hello”
#CAP!
#CAP!
The result of the document: #CAP!
The root has the capabilities log and write. The kind pure gives its part none. The log asks for its effect and gets #CAP!.

Select the log card, and look at the panel. Its context has no capability. The capability is a part of the context, as a name is.