Skip to content

coeval

A document gets its meaning from a question, not from a definition. Each picture on this site is a document, drawn by the same rules. Select Play at the right.
Open in the playground

Nothing started yet. Select Next or Play.

seq
  1. 1
    adda
    number
    1
    number
    2
  2. 2
    multiplyb
    ref
    namesa
    number
    10
  3. 3
    ▸log
    ref
    namesb
The world: the effects, in orderNo effect yet.
The result shows at the end of the evaluation.

coeval is a base for declarative languages. Each language stores its programs as JSON documents. coeval gives the parts that all of these languages share. These parts are the documents, the ladder that finds an evaluator and the context of a term. They are also the split between pure work and effects, and one merge of languages.

Each idea has a page with a live diagram. The diagrams use the kernel of the repository, thus each answer comes from real code.

A store holds documents. The derive side computes the view from the store, without an effect. An event starts a run, and a run causes effects in a written order. The effects change the store, and the loop starts again.

The run side ran 0 times. The derive side evaluated 3 times and kept 0 results.
derive: pure, in any orderrun: effects, in written ordercountleftall done1. find the card2. toggle it3. save itStoredone: 1total: 3View1 of 3 doneevent
Click a card starts the full loop. The event starts a run, the run writes the store, and the derive side computes again. Write from another tab changes the store directly. The derive side computes again, and the run does not start, because a change of data does not repeat an effect. The kernel evaluates each step, and a node whose reads did not change keeps its result.

Each page of the guide adds one or two glyphs to the pictures, and it uses all of the glyphs before it. Read the pages in this order.

The document

  1. DocumentsA value in an envelope. The tab of the card is the type.
  2. KindsA kind is a document that names an evaluator for each verb.
  3. The ladderA question goes to the own entry, then to the kind, then to the default.
  4. EvaluationResults come up through ports, and parts are sealed.

The context

  1. NamesA step with a name tag gives its result to the later steps.
  2. ChoicesAn evaluator decides which parts to evaluate.
  3. EffectsEffects keep their written order. A capability permits them.
  4. ContextA term reaches outside itself through five parts only.
  5. PathsA reference is a list of moves from a root of the context.

Order

  1. DirectionBack in a sequence, by moves in a structure, down and up in a tree.
  2. Derive and runOrder has a meaning only for effects.
  3. SchedulesWhen to compute is a separate layer.

Build

  1. CompositionLanguages compose through one merge. A conflict names its path.
  2. The playgroundBuild a document from the kinds, and step through its evaluation.

The kernel is on npm as @mark1russell7/coeval. Its API is not stable before version 1.0.

Terminal window
npm install @mark1russell7/coeval
import { STD_MACHINE, prepare } from "@mark1russell7/coeval";
const plan = prepare(STD_MACHINE, { type: "add", value: [2, { type: "multiply", value: [3, 4] }] });
plan.evaluate(); // { ok: true, value: 14 }

prepare compiles the document one time into a plan. A plan evaluates many times, and an error comes back as a value with a code and a place. The decisions and the research tell why the kernel works this way.