set

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package set implements deixis-set-v1, slot-member form — the finite-set container by self-keying.

set(S) = Node(None, { e(x) ↦ Node(Some(x), ∅) | x ∈ S })

See docs/design/0005-set-keys.md. e is a lawful member encoder for the slot — x ≈ y ⟺ e(x) = e(y), canonical — and the codec law then does every job a set semantics needs, with nothing invented: membership is key membership, idempotence is inherited from the floor's duplicate-key refusal, set identity reduces to node identity, and enumeration order is spelling order (a set carries no order of its own).

Under ADR 0010 this profile explicitly uses Node[Option[T]]: the set node is unvalued, and every member is a valued node without children. There is deliberately no repair anywhere: a mis-keyed entry is refused, never re-keyed, and recognition never prefers a representative among ≈-equal members — either may sit under their shared key.

The node-member form (member(n) = n, e the deixis codec combinator) is gated on the codec axis and is not implemented here.

Index

Constants

View Source
const Profile = "deixis-set-v1"

Profile is the name of the profile this package implements (slot-member form).

Variables

This section is empty.

Functions

func Contains

func Contains[T any](node deixis.Node[deixis.Option[T]], member T, e func(T) []byte) bool

Contains is membership: x ∈ S iff e(x) ∈ dom — one lookup, no enumeration.

Defined over set nodes (recognize first where provenance is unknown); on an arbitrary node it answers key membership, which coincides on the image. It never reads a member's own value.

func IsSet

func IsSet[T any](node deixis.Node[deixis.Option[T]], e func(T) []byte) bool

IsSet reports whether node is a set node: Recognize without the reason.

func Of

func Of[T any](members []T, e func(T) []byte) (deixis.Node[deixis.Option[T]], error)

Of is the set node of members under the member encoder e: Node(None, {e(x) ↦ Node(Some(x), ∅)}), entries fed in slice order.

Two ≈-equal members spell the same key, and the floor refuses the duplicate — idempotence is inherited, not implemented. The returned error carries the shared key.

Types

type Reason

type Reason string

Reason is why a node is not a set node: the refusals of the slot-member form, by their stable codes.

const (
	// MisKeyed: a member Node(Some(x), ∅) under a key k ≠ e(x).
	MisKeyed Reason = "mis_keyed"
	// StructMember: a child whose own value is None — the image of a Struct child.
	StructMember Reason = "struct_member"
	// LeafNode: the set node itself is Node(Some(x), ∅) — the image of a bare Leaf.
	LeafNode Reason = "leaf_node"
	// ValuedSetNode: a set node with at least one member that carries its own value,
	// Node(Some(t), m) with m ≠ ∅. New in N; the childless case is LeafNode's.
	ValuedSetNode Reason = "valued_set_node"
	// MemberWithChildren: a member Node(Some(x), m) with m ≠ ∅. New in N.
	MemberWithChildren Reason = "member_with_children"
)

func Recognize

func Recognize[T any](node deixis.Node[deixis.Option[T]], e func(T) []byte) (Reason, bool)

Recognize is exact-or-refusal recognition of the slot-member image: an unvalued node whose every child is a valued node without children, coherent with its key (k = e(x)). It returns ("", true) for a set node and the refusal's reason otherwise.

A node with several defects has several reasons that apply, and any of them may be returned: 0005 fixes the verdict, not an order among reasons. A key outside im(e) cannot cohere with any member, so it needs no check of its own — it reduces to mis-keying.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL