Trees: types and items
The types of one subject, and the tree that follows them.
Types #
A type names one kind of thing in the subject. Each has:
- an identifier, which other types refer to it by. It defaults to the name and never changes. (The file calls it the type’s key.)
- a name, for people to read;
- a meaning, which explains what it is;
- a kind: leaf, list or map.
The browser app and the command line call a type a building block. This documentation says type.
Leaf, list and map #
- A leaf is of nothing. A compost heap is a leaf.
- A list is of exactly one type. The beds are a list of Bed.
- A map is of a set of types, each at most once. An allotment is a map of Beds, Compost, Greenhouse and Shed.
A map’s children are in alphabetical order by name, ignoring case, with the identifier breaking ties. A list’s members keep the sequence they were added in.
The Tree names its root type, which can be of any kind. Types refer to each other only by identifier, so one type can be used in many places. A type that holds itself through maps alone is refused, because an item of it could never end.
Meaning #
A meaning should be clear and concise, with enough detail for a person or an AI agent to understand the tree. Use as many sentences or paragraphs as you need. It is shown beside the type everywhere, and the Template’s glossary puts every meaning on one page. Barntree writes none of them.
$ vendor/bin/barntree type:show Allotment Beds
Barn: …/allotment
Allotment
Revision: 1 (3c46bfb7e7251ee4a668cf2dd6a79557)
File token: 5f075e17e9f96751d733594974e8696b748ec2aeafa09d1342c5a0f819e70106
identifier: Beds
name: Beds
meaning: The raised beds, each growing one crop at a time.
kind: list
of:
0: Bed
tags:
uses:
0: Allotment
root: no
items:
0: 84fc43d1a40986ec
structure:
Beds [Beds, list]
Bed [Bed, leaf]
uses are the types that hold this one; items are the ids of its items in the saved tree.
Items #
The tree is made of items. An item follows one type, and has an id that Barntree generates and nobody types. What it holds depends on its type’s kind:
- a map item holds one item for each type of its map;
- a list item holds its members, any number of them, each with a name you give it;
- a leaf item holds nothing.
Every item is an item of its own, list items included, so a list can be the root. The root item and the members have names. Any other item takes its type’s name. The members of one list have different names, and so do the entries of one map, so a path of names from the root finds at most one item.
The skeleton #
A Template can leave its tree out, and most hand-written ones do. Barntree then builds the skeleton: the root, and every map entry below it, down to empty lists and leaves, each with a fresh id. Save the Template once and the ids stay the same from then on. A new Construction always starts from the skeleton.
$ vendor/bin/barntree template:show Allotment --view=skeleton
Barn: …/allotment
Allotment
Revision: 1 (3c46bfb7e7251ee4a668cf2dd6a79557)
File token: 5f075e17e9f96751d733594974e8696b748ec2aeafa09d1342c5a0f819e70106
Allotment [Allotment, map]
Beds [Beds, list]
Compost [Compost, leaf]
Shed [Shed, leaf]
The same Template with the beds added is on the Keep a Template page, and the Construction made from it is on the next.
Tags #
A Tree can declare tags, each with a name and a meaning, and a type can carry some of them. A tag says that types in different places belong together, which the tree on its own can’t say. A house tags its kitchen and its bathroom Plumbed, one on each floor. Every item of a tagged type carries its tags. A declared tag that no type carries is kept.
In the allotment, a bed and the compost heap both need Watered. The tags are written in the Template’s file, and shown by the app and by an export. The app and the command line don’t edit them.
$ vendor/bin/barntree export Allotment
Allotment
|
+--Beds
+--Compost [Watered]
+--Greenhouse
+--Shed
A Tree without tags refuses a document that has them.
What a Tree does not do #
- It knows nothing of what it is about. Whether a tomato soup is a good starter in August is for you to decide.
- It keeps no history of itself. An edit returns a new Tree. When to save it, and whether to keep the old one, is up to you: Templates and Constructions keep revisions.