Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

abstract part def

This notebook introduces abstract part def together with the flow-typed action def it performs; after running it you can state a system’s purpose as an executable functional construct, not a comment.

Chapter 1 builds the model of a toaster’s purpose and structure from first principles. This first notebook declares what the whole toasting system does: transform bread into toast, stated as typed input and output flows through an action the system performs. Subsequent notebooks add component types, specialization, and composition.

item def Bread;
item def Toast;

Bread and Toast are item definitions: typed flows with no mechanism, ready to be the in and out parameters of the action below.

action def ToastBread {
    doc /* Transform bread into toast acceptable to its user. */
    in bread : Bread;
    out toast : Toast;
}

ToastBread states the purpose functionally: bread in, toast out. The doc keeps the acceptance language (“acceptable to its user”) as the seed of a measure of effectiveness Chapter 3 builds; the action names no mechanism and no part.

abstract part def ToastingSystem {
    perform action toastBread : ToastBread;
}

ToastingSystem performs ToastBread: the abstract subject carries out the stated purpose without committing to a mechanism or a concrete part.

The assembled increment loads against the cumulative model with no diagnostics: assert model.ok passes silently, confirming all four declarations resolve together. The next cell checks what happens when one does not.

Expected error: expected a /* ... */ comment body

A doc written as a quoted string rather than a /* */ comment block is a syntax error, reported in bad.diagnostics[0].

kind : partDef
id   : ToasterDemo::ToastingSystem

model.find() resolves ToastingSystem by its qualified name, confirming the abstract subject is indexed.

kind : actionDef
id   : ToasterDemo::ToastBread

The same lookup on ToastBread confirms the performed action is indexed too, separately from the part def that performs it.

The ToastBread and ToastingSystem declarations printed above loaded without error, and the two model.find() calls above confirm each is now part of the model, shown by the kind and id printed below each.

Try the chapter exercise in exercises/ch01/exercise.ipynb: declare item defs for a coffee maker’s flows, an action def with a doc and typed in/out flows, and an abstract part def that performs it, and verify it loads.