Documentation
¶
Overview ¶
Package value provides immutable, language-neutral refinement values.
Index ¶
- Constants
- func DataKindEqual(a, b DataKind) bool
- func DataKindEqualWith(a, b DataKind, ov DataKindEqOverrides) bool
- func Fold[R any](d DataKind, cs DataKindCases[R]) R
- type BoolData
- type Data
- func (d Data) Boolean() (bool, bool)
- func (d Data) Constructor() (string, bool)
- func (d Data) Elements() []Data
- func (d Data) Entries() []MapEntry
- func (d Data) EqualWith(other Data, step func(uint64) error) (bool, error)
- func (d Data) Fields() []DataField
- func (d Data) Kind() DataKind
- func (d Data) Lookup(name string) (Data, bool)
- func (d Data) LookupKey(key Text) (Data, bool)
- func (d Data) Number() (Number, bool)
- func (d Data) ReplaceFields(changes []DataField) (Data, error)
- func (d Data) Size() int
- func (d Data) Text() (Text, bool)
- type DataField
- type DataKind
- type DataKindCases
- type DataKindEqOverrides
- type ListData
- type MapData
- type MapEntry
- type Number
- func (n Number) Add(other Number) Number
- func (n Number) Ceiling() Number
- func (n Number) Compare(other Number) int
- func (n Number) Decimal() (string, error)
- func (n Number) Divide(other Number) (Number, error)
- func (n Number) ExactFloat32() (Number, error)
- func (n Number) ExactFloat64() (Number, error)
- func (n Number) FixedWidth(bits uint, signed bool) (Number, error)
- func (n Number) Floor() Number
- func (n Number) IsInteger() bool
- func (n Number) Multiply(other Number) Number
- func (n Number) Negate() Number
- func (n Number) Remainder(other Number) (Number, error)
- func (n Number) RoundFloat32() (Number, error)
- func (n Number) RoundFloat64() (Number, error)
- func (n Number) RoundHalfEven() Number
- func (n Number) Show() string
- func (n Number) Sign() int
- func (n Number) Subtract(other Number) Number
- func (n Number) Truncate() Number
- func (n Number) Wrap(bits uint, signed bool) (Number, error)
- type NumberData
- type RecordData
- type Text
- type TextData
- type Timestamp
- func (t Timestamp) CivilSecondsUntil(other Timestamp) (Number, error)
- func (t Timestamp) Compare(other Timestamp) int
- func (t Timestamp) Equal(other Timestamp) bool
- func (t Timestamp) Fraction() Number
- func (t Timestamp) LeapSecond() bool
- func (t Timestamp) OffsetKnown() bool
- func (t Timestamp) OffsetMinutes() int
- func (t Timestamp) Raw() string
- func (t Timestamp) SISecondsUntil(other Timestamp) (Number, error)
- func (t Timestamp) Show() string
- type TimestampError
- type VariantData
Constants ¶
const LeapTableVersion = "IERS-C72-2026-07-06"
The dates are facts from the IERS leap-second table, Bulletin C 72 (2026-07-06). The bulletin confirms no December 2026 leap. Future possible leap labels are unknown instead of relying on a live fetch or silently accepting speculation. Sources: https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat
https://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat
Variables ¶
This section is empty.
Functions ¶
func DataKindEqual ¶
DataKindEqual reports structural equality of a and b.
func DataKindEqualWith ¶
func DataKindEqualWith(a, b DataKind, ov DataKindEqOverrides) bool
DataKindEqualWith reports structural equality of a and b under ov.
func Fold ¶
func Fold[R any](d DataKind, cs DataKindCases[R]) R
Fold reduces DataKind by one-level case analysis.
Types ¶
type Data ¶
type Data struct {
// contains filtered or unexported fields
}
Data is an immutable, function-free payload tree. It does not assert that a schema's structure or refinements have been validated. Nominal type identity belongs to the checked contract; wrappers do not change this raw payload. Its zero value is the explicit Null constructor, never an absent field.
func Map ¶
Map constructs an immutable string-keyed map. Entry order has no semantic meaning: construction sorts by exact UTF-16 code units. Escape spelling is already decoded by Text, while case and Unicode normalization remain exact.
func Record ¶
Record field order is retained. Duplicate names are an error, even if their values agree. Native escaped UTF-16 object keys remain in schemajson.Node; these are checked-language field identifiers, not a native JSON AST.
func Variant ¶
Variant distinguishes Nothing/Just, Null/NonNull, Err/Ok, and user-defined alternatives. Constructor names/arity are checked against the contract later.
func (Data) Constructor ¶
func (Data) EqualWith ¶
EqualWith is structural equality, with explicit work charging. Record order does not affect equality; list/constructor argument order does. The callback is called before each compared node and each scalar code unit/digit. The iterative traversal is safe for trees deeper than the Go call stack.
func (Data) ReplaceFields ¶
ReplaceFields applies all changes to an existing record in one immutable transformation. It does not validate refinements: the validating update layer must validate the completed candidate once, never intermediate field states. Missing targets and duplicate edits fail without modifying any input.
type DataKindCases ¶
type DataKindCases[R any] struct { NumberData func() R TextData func() R BoolData func() R ListData func() R RecordData func() R VariantData func() R MapData func() R }
DataKindCases selects one handler per DataKind variant for Fold.
type DataKindEqOverrides ¶
type DataKindEqOverrides struct {
NumberData func(x, y NumberData) (eq, handled bool)
TextData func(x, y TextData) (eq, handled bool)
BoolData func(x, y BoolData) (eq, handled bool)
ListData func(x, y ListData) (eq, handled bool)
RecordData func(x, y RecordData) (eq, handled bool)
VariantData func(x, y VariantData) (eq, handled bool)
MapData func(x, y MapData) (eq, handled bool)
}
DataKindEqOverrides carries optional per-variant hooks for DataKindEqualWith. A hook returning handled=false falls through to the derived comparison.
type Number ¶
type Number struct {
// contains filtered or unexported fields
}
Number is an immutable exact rational. Its zero value is zero. No mutable math/big object is exposed or shared between arithmetic operations.
func ParseNumber ¶
ParseNumber accepts decimal integers/fractions/exponents or a rational n/d. Errors deliberately omit input values. Callers must budget input size before parsing; this value primitive does not own a validation execution budget.
func (Number) Decimal ¶
Decimal returns an exact finite decimal for wire encodings which support it. Nonterminating fractions fail instead of silently rounding (e.g. 1/3).
func (Number) ExactFloat32 ¶
ExactFloat32 and ExactFloat64 admit only finite IEEE-754 values whose mathematical value is exactly n. They do not convert through a host float, so their result is deterministic and retains the exact rational value.
func (Number) ExactFloat64 ¶
func (Number) FixedWidth ¶
FixedWidth rejects values outside the explicitly requested integer type. The returned value is unchanged. Wrapping must use Wrap explicitly.
func (Number) Remainder ¶
Remainder uses a quotient truncated toward zero; a nonzero remainder has the dividend's sign. It is integer-only and never rounds a fractional operand.
func (Number) RoundFloat32 ¶
RoundFloat32 and RoundFloat64 explicitly round to the nearest finite IEEE value, resolving ties toward an even significand. A result which would be an infinity is rejected. IEEE signed zero has no distinct language identity.
func (Number) RoundFloat64 ¶
func (Number) RoundHalfEven ¶
func (Number) Show ¶
Show is canonical: reduced fractions have positive denominators; whole numbers have no denominator. The payload is never rounded or normalized in place; all Number instances are immutable mathematical values.
type NumberData ¶
type NumberData struct{}
type RecordData ¶
type RecordData struct{}
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text stores the exact UTF-16 sequence, including unpaired surrogate code units. Conversion to a Unicode-scalar wire encoding is explicitly fallible; it must never replace a code unit with U+FFFD silently.
func ReadText ¶
ReadText accepts quoted text and JSON-style escapes, retaining each escaped UTF-16 unit exactly. Invalid UTF-8, controls, and malformed escapes fail.
func TextFromUTF8 ¶
func TextFromUnits ¶
func (Text) CodePointLength ¶
CodePointLength counts valid UTF-16 surrogate pairs as one code point and every other code unit, including an unmatched surrogate, as one. It does not normalize text and matches Java String.codePointCount semantics.
func (Text) Compare ¶
Compare returns exact UTF-16 code-unit order without allocating or applying Unicode normalization. It is the canonical order for typed map keys.
type Timestamp ¶
type Timestamp struct {
// contains filtered or unexported fields
}
Timestamp preserves the RFC 3339 payload spelling, numeric offset and exact fraction. Calendar work uses only UTC; no clock, locale, zone database or I/O participates. The zero value is the Unix epoch, not the current time.
func ParseTimestamp ¶
ParseTimestamp accepts the RFC 3339 profile, including lower-case t/z, unbounded decimal fractional precision, numeric offsets and known leap labels. As with Number parsing, the caller must budget input size before this primitive.
func (Timestamp) CivilSecondsUntil ¶
CivilSecondsUntil is explicit civil-coordinate arithmetic, not an assertion about elapsed SI seconds. It excludes inserted leap seconds between endpoints and refuses a leap-labelled endpoint, which has no unique ordinary coordinate.
func (Timestamp) Compare ¶
Compare orders UTC instants, distinguishing a leap second from the following midnight. Offset spelling and decimal precision do not alter instant equality. -00:00 denotes a known UTC instant with unknown local offset, per RFC 3339 §4.3.
func (Timestamp) LeapSecond ¶
func (Timestamp) OffsetKnown ¶
func (Timestamp) OffsetMinutes ¶
func (Timestamp) SISecondsUntil ¶
SISecondsUntil includes leap seconds in the pinned history. Outside the post-1972, announced interval, a physical elapsed duration is unknown; civil coordinate arithmetic remains available under its explicit name above.
type TimestampError ¶
func (*TimestampError) Error ¶
func (e *TimestampError) Error() string
type VariantData ¶
type VariantData struct{}