coeval
Nothing started yet. Select Next or Play.
- 1addanumber1number2
- 2multiplybrefnamesanumber10
- 3▸logrefnamesb
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.
The whole model in one loop
Section titled “The whole model in one loop”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 guide
Section titled “The guide”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
- DocumentsA value in an envelope. The tab of the card is the type.
- KindsA kind is a document that names an evaluator for each verb.
- The ladderA question goes to the own entry, then to the kind, then to the default.
- EvaluationResults come up through ports, and parts are sealed.
The context
- NamesA step with a name tag gives its result to the later steps.
- ChoicesAn evaluator decides which parts to evaluate.
- EffectsEffects keep their written order. A capability permits them.
- ContextA term reaches outside itself through five parts only.
- PathsA reference is a list of moves from a root of the context.
Order
- DirectionBack in a sequence, by moves in a structure, down and up in a tree.
- Derive and runOrder has a meaning only for effects.
- SchedulesWhen to compute is a separate layer.
Build
- CompositionLanguages compose through one merge. A conflict names its path.
- The playgroundBuild a document from the kinds, and step through its evaluation.
Use the kernel
Section titled “Use the kernel”The kernel is on npm as @mark1russell7/coeval. Its API is not stable before version 1.0.
npm install @mark1russell7/coevalimport { 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.