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: 16, 3 new on this page
- 42Data: a value without a type
- numberA document: the tab is its type42
- numberA dashed tab: the container declares the type42
- addParts: a card inside a cardnumber1number2
- 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
- numberaA name tag: a binding for later steps3
- refA reference: a path from a root of the contextnamesa
- A dashed blue arrow: from a reference back to the step with its name
- ifNot evaluated: a part that its parent did not need“yes”testbooltruetruethentext“yes”“yes”elsetext“no”not evaluated
- ▸logThe run side: a magenta edge, and an effectnew“hi”text“hi”“hi”
- 1log“hi”An effect: a numbered ticket in the worldnew
- logA capability: an effect that a term can causenew
Nothing started yet. Select Next or Play.
- 1▸logtext“start”
- 2▸writetotaldatakey“total”valueaddnumber2number3
- 3▸logrefnamestotal
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.
Capabilities
Section titled “Capabilities”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.
The contract of a kind declares what it gives its parts. The kernel narrows the context of each part by that contract. check reads the same contract, thus it finds the #CAP! before a run.
The evaluation of pure ends with the error #CAP!: The context has no capability for the effect log.
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.
A capability also permits the kinds of its namespace. The capability store permits the effects store.update and store.remove.
The pictures on this page are evaluations. An evaluation records each effect, and it does none. A run is the same evaluation, but the host does each effect and gives back its result. Thus a step can read the result of the step before as last.
A test can give an evaluation a mock perform. Its answer becomes the result of the effect, without a promise. Each effect keeps a fixed address and its outcome, thus a host can record a run and replay it (decision D19).
A kind that holds effects has a runner. The same runner serves the evaluation and the run, thus the picture of an evaluation shows exactly what a run does. A run waits only when the host waits. Before that, it goes on at once.
A runner can wait for the host only when its parent can wait. In a run, an effect under a parent that cannot wait does not go to the host (decision D91). The effect keeps the outcome #CALC!, and the runner gives #CALC!. Pick a program and a host. The kernel does a run of the program, and the diagram shows each call of perform.
| Effect | Payload | Host got it | Outcome |
|---|
perform. A dashed arrow that ends at a bar is an effect that the run held. The host does not get it, and the effect keeps #CALC!. The two hosts give the same facts.Handlers
Section titled “Handlers”The kind handle answers the effects of its body with its own clauses. The host does not get these effects. Thus a mock, a log or a retry is a document, and the body stays the same.
{ "type": "handle", "value": { "with": [{ "op": ["log"], "do": { "type": "ref", "value": ["names", "payload"] } }], "body": { "type": "log", "value": [1] } }}- A clause
dogives the result of the effect, and it readsnames.payload. - A clause
abortstops the body, and its result is the result ofhandle. - The field
returnchanges the result of the body, and it readsnames.result.
A clause has the capabilities of the handle document. An effect of a clause goes to the next handle out, and then to the host. A pure part under handle still causes no effect.