Skip to content

Standard HQL library

The declarations HQL ships with live in std/, written in HQL rather than described in prose. One file per module, mirroring the extension split: core, doc, graph, knowledge, retrieval.

These cards and those files say the same thing twice, which is a real cost worth naming. The division is that the file is the declaration and the card is the argument. std/graph.hql states that Link<S, T> : Edge<S, T>; graph-type explains why an edge is the primitive and why its payload is Data. When the two disagree, the card is describing something that no longer exists, and the card is what gets fixed.

std/ is deliberately not the corpus. The corpus records what was considered and may keep a withdrawn spelling beside a current one; a standard library may not. There is one declaration of Edge, and it is the one that is true now.

Parsed and checked, not evaluated

The parser reads the type statement, and every file in std/ checks: hql check std/graph.hql prints Unit, and a test walks the folder so a file added there cannot be silently left unchecked.

Checking is not evaluating. A declaration yields Unit and introduces no value and no case in the implemented lattice; constructing a value of a declared record type is separate work. What holds today is that each declaration is coherent — its parents exist, its parents can be narrowed together, a parameter is a name no type already has, and a subtype does not turn a required field optional — and that where a declaration restates a type the binary already holds, the two agree. type Card : Doc checks; type Card : Edge is refused as a contradiction. The rules are in the grammar.

That agreement is the point of the folder. std/ is not a second opinion about the type lattice; it is the lattice written down where a reader can find it, and a file that drifts from the binary now fails rather than going unread.

A standard library is a bootstrap non-goal in requirements, and that still holds: having a home for the declarations is not the same as shipping a library of functions.

See type-system for :, generics and refinement, hql/core for the vocabulary, and hql/extensions for the modules the layout follows.