Documentation
¶
Overview ¶
Package core is ontos/core (L0): the frozen value model.
Bytes = finite octet strings Value = Atom(Bytes) | Tuple(Value*)
A value is finite, immutable, well-founded (a finite tree, never cyclic), uninterpreted, and compared by structural identity. This package defines what a value is and when two values are the same — nothing else. There is no byte encoding here (that is the codec package) and no interpretation of atoms or shapes. See docs/spec/ontos-core.md.
Common Value API (all three cores) ¶
The Go, Rust, and TypeScript cores expose the same conceptual surface so a developer who learns one can predict the others. Every core provides, by its own naming convention:
- Construct — NewAtom(bytes) / NewTuple(items...) (Rust Value::atom/tuple, TS atom/tuple).
- Atom bytes + length — Atom.Bytes and Atom.Len.
- Tuple children + arity + indexed access — Tuple.Items, Tuple.Len, and Tuple.At (matching Rust Tuple::at / TS Tuple.at).
- Structural equality — Value.Equal and the package-level Equal (Rust PartialEq, TS equals).
- Diagnostic string — Value.String (Rust Display, TS toString); this is not a canonical encoding.
Intentional per-language extras ¶
Some members exist in only one core because they are idiomatic to that language and have no natural cross-core analogue; they are intentional, not accidental gaps. Go classifies a Value with an ordinary type switch or type assertion on the Value interface (e.g. a, ok := v.(Atom)), so it needs no is_atom/as_atom helpers; those exist only in Rust, where Value is a closed enum. The TS-only kind discriminant and toJSON/toHex serve JavaScript consumers that lack Rust enums and Go interfaces and want a stable JSON shape; Go has no such runtime JSON contract and so omits them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Atom ¶
type Atom struct {
// contains filtered or unexported fields
}
Atom is an opaque finite byte string. The bytes have no built-in interpretation.
Construct atoms with Atom (which copies); the held bytes are not exposed by reference, so an Atom is immutable once built.
func NewAtom ¶
NewAtom builds an Atom from a defensive copy of bytes. A nil slice yields the empty atom.
type Tuple ¶
type Tuple struct {
// contains filtered or unexported fields
}
Tuple is a finite ordered tuple of values. Arity, order, and multiplicity are part of the value's identity.
func NewTuple ¶
NewTuple builds a Tuple from a defensive copy of items.
A nil child is not a value: the L0 set is generated only by Atom and Tuple (see docs/spec/ontos-core.md §1), so a nil Value interface cannot be a tuple child. Go has no closed sum type to enforce this statically, so the constructor is the gate — it panics on a nil child rather than admitting a malformed tuple that would later panic in Equal/Encode. Constructing a value from untrusted bytes goes through the codec's Decode, which never produces a nil child; this guard protects the in-process construction path.
func (Tuple) Equal ¶
Equal: a Tuple equals another Tuple of the same arity whose children are elementwise equal in order; never an Atom.
type Value ¶
type Value interface {
// Equal reports structural identity with other.
Equal(other Value) bool
// String renders a diagnostic form (not a canonical encoding).
String() string
// contains filtered or unexported methods
}
Value is a foundational ontos value: either an Atom or a Tuple, and never anything else. The unexported marker method keeps the sum type closed: only Atom and Tuple in this package can implement it.