Structures, algebras, and morphisms

Structures describe reusable operations and values whose implementations are supplied as coherent evidence. Algebras and morphisms are specialized vocabulary over the same evidence foundation.

General structures

structure Hashes(hash:Type, value:Type) = {
    function hash(item:value) : hash
};

A structure may relate any number of type or value parameters. An implementation is an ordinary typed instance, not dynamic name lookup.

Algebras

algebra Monoid(a:Type) extends Semigroup(a) = {
    value empty : a;
    law leftIdentity(x:a) = combine(empty, x) === x
};

An algebra is centered on one carrier type. trait is an exact surface alias. Members may include functions, values, laws, and derivation logic.

Morphisms and bridges

bridge Convertible(a:Type,b:Type) = {
    function convert(item:a) : b
};

morphism and bridge are aliases for directional multi-type relationships. They do not create automatic global composition; composition requires explicit evidence and a coherent path.

Inheritance and requirements

algebra Group(a:Type) extends Monoid(a) = { ... };

structure OrderedCollection(c:Type1,a:Type)
    requires Ord(a) = { ... };

extends inherits members and laws. Multiple structure parents are allowed when resolution is coherent. requires states evidence needed to construct an instance.

Structures are not classes

A class gives nominal object identity, fields, inheritance, and dynamic method dispatch. A structure gives evidence that a type or relationship supports an abstraction. A class may implement algebras, but the hierarchies remain distinct.

Empty structures

An empty structure can still carry meaningful typed evidence—for example, that a target supports a capability. Evidence need not contain runtime fields to matter during checking and planning.

Common mistakes

Do not use a class when the real requirement is coherent evidence, and do not assume morphism paths compose globally without an explicit chosen instance. Inherited structure members must remain coherent across all parents.

Recap

structure is the general evidence contract; algebras and morphisms give single-carrier and directional vocabulary without changing that foundation.

Normative details: Language Reference §9.1–9.4.