moonrockz/rego/value does not have a README file

    DecimalError

    pub(all) suberror DecimalError {
    InvalidDecimal(text~ : String)
    DivisionByZero
    NonIntegerModulo
    NonFiniteFloat
    } derive(Eq,
    Debug
    )

    Raised when parsing or evaluating a Decimal breaks a rule.

    ValueError

    pub(all) suberror ValueError {
    InvalidNumber(DecimalError)
    InvalidJson(message~ : String)
    InvalidYaml(message~ : String)
    MultipleYamlDocuments(count~ : Int)
    } derive(Eq,
    Debug
    )

    Raised when a runtime Value conversion or construction fails.
    impl Show for ValueError

    Decimal

    Exact arbitrary-precision decimal number represented canonically as coeff * 10^exp. Invariant: if coeff == 0, then exp == 0; otherwise coeff is not divisible by 10. Structural equality therefore equals mathematical equality (1 == 1.0 == 1e0).
    impl Compare for Decimal
    impl Show for Decimal

    Decimal::Decimal

    fn Decimal::Decimal(text : String) -> Decimal raise DecimalError

    Parses a Rego numeric string (optional leading -, integer/fraction, optional scientific exponent e/E) into a canonical Decimal.

    Decimal::abs

    fn Decimal::abs(self : Decimal) -> Decimal

    Absolute value of this decimal.

    Decimal::add

    fn Decimal::add(self : Decimal, other : Decimal) -> Decimal

    Exact decimal addition.

    Decimal::ceil

    fn Decimal::ceil(self : Decimal) -> Decimal

    Ceiling to the smallest integer greater than or equal to self.

    Decimal::compare

    fn Decimal::compare(self : Decimal, other : Decimal) -> Int

    Total mathematical order on Decimal.

    Decimal::div

    fn Decimal::div(self : Decimal, other : Decimal) -> Decimal raise DecimalError

    Exact decimal division when terminating, else rounded to 50 significant digits (half away from zero). Raises DivisionByZero when other is zero.

    Decimal::floor

    fn Decimal::floor(self : Decimal) -> Decimal

    Floor to the greatest integer less than or equal to self.

    Decimal::from_bigint

    Constructs a Decimal from an arbitrary-precision BigInt.

    Decimal::from_double

    fn Decimal::from_double(n : Double) -> Decimal raise DecimalError

    Constructs a Decimal from a finite IEEE-754 Double.

    Decimal::from_int

    fn Decimal::from_int(n : Int) -> Decimal

    Constructs a Decimal from a 32-bit integer.

    Decimal::from_int64

    fn Decimal::from_int64(n : Int64) -> Decimal

    Constructs a Decimal from a 64-bit integer.

    Decimal::is_integer

    fn Decimal::is_integer(self : Decimal) -> Bool

    Reports whether this decimal has no fractional part.

    Decimal::is_negative

    fn Decimal::is_negative(self : Decimal) -> Bool

    Reports whether this decimal is strictly negative.

    Decimal::is_zero

    fn Decimal::is_zero(self : Decimal) -> Bool

    Reports whether this decimal is zero.

    Decimal::mul

    fn Decimal::mul(self : Decimal, other : Decimal) -> Decimal

    Exact decimal multiplication.

    Decimal::neg

    fn Decimal::neg(self : Decimal) -> Decimal

    Negates this decimal.

    Decimal::one

    fn Decimal::one() -> Decimal

    One (1).

    Decimal::rem

    fn Decimal::rem(self : Decimal, other : Decimal) -> Decimal raise DecimalError

    Integer remainder (a % b). Raises DivisionByZero if other is zero, or NonIntegerModulo if either operand has a fractional part.

    Decimal::round

    fn Decimal::round(self : Decimal) -> Decimal

    Rounds to the nearest integer, half away from zero (matching OPA round).

    Decimal::sub

    fn Decimal::sub(self : Decimal, other : Decimal) -> Decimal

    Exact decimal subtraction.

    Decimal::to_bigint

    Returns the exact BigInt value when this decimal is an integer.

    Decimal::to_double

    fn Decimal::to_double(self : Decimal) -> Double

    Converts this decimal to an approximate IEEE-754 Double.

    Decimal::to_int

    fn Decimal::to_int(self : Decimal) -> Int?

    Returns the exact 32-bit integer value when this decimal is an integer in the Int32 range.

    Decimal::to_int64

    fn Decimal::to_int64(self : Decimal) -> Int64?

    Returns the exact 64-bit integer value when this decimal is an integer in the Int64 range.

    Decimal::to_string

    fn Decimal::to_string(self : Decimal) -> String

    Formats the decimal as canonical Rego/JSON numeric text.

    Decimal::trunc

    fn Decimal::trunc(self : Decimal) -> Decimal

    Truncates this decimal toward zero, discarding any fractional digits.

    Decimal::zero

    fn Decimal::zero() -> Decimal

    Zero (0).

    RegoObject

    type RegoObject derive(Eq, Hash,
    Debug
    )

    An immutable Rego object storing entries canonically sorted by key. Supports arbitrary Value keys (not only strings), matching OPA semantics.

    RegoObject::compare

    fn RegoObject::compare(self : RegoObject, other : RegoObject) -> Int

    RegoObject::empty

    fn RegoObject::empty() -> RegoObject

    Constructs an empty Rego object ({}).

    RegoObject::entries

    fn RegoObject::entries(self : RegoObject) -> ReadOnlyArray[(Value, Value)]

    Returns the sorted (key, value) entries of this object.

    RegoObject::from_strings

    fn RegoObject::from_strings(pairs : ArrayView[(String, Value)]) -> RegoObject

    Constructs a canonical Rego object from string-keyed entries.

    RegoObject::get

    fn RegoObject::get(self : RegoObject, key : Value) -> Value?

    Binary search lookup by key in O(log n).

    RegoObject::get_string

    fn RegoObject::get_string(self : RegoObject, key : String) -> Value?

    Lookup by string key.

    RegoObject::insert

    fn RegoObject::insert(self : RegoObject, key : Value, value : Value) -> RegoObject

    Returns a new object with (key, value) inserted or updated.

    RegoObject::is_empty

    fn RegoObject::is_empty(self : RegoObject) -> Bool

    Reports whether this object is empty.

    RegoObject::length

    fn RegoObject::length(self : RegoObject) -> Int

    Number of key-value entries in this object.

    RegoObject::of

    fn RegoObject::of(pairs : ArrayView[(Value, Value)]) -> RegoObject

    Constructs a canonical Rego object from key-value pairs. When duplicate keys appear in pairs, the later entry wins.

    RegoObject::remove

    fn RegoObject::remove(self : RegoObject, key : Value) -> RegoObject

    Returns a new object with key removed when present.

    RegoSet

    An immutable, canonically sorted and deduplicated Rego set.
    impl Compare for RegoSet

    RegoSet::compare

    fn RegoSet::compare(self : RegoSet, other : RegoSet) -> Int

    RegoSet::contains

    fn RegoSet::contains(self : RegoSet, target : Value) -> Bool

    Binary search membership check in O(log n).

    RegoSet::diff

    fn RegoSet::diff(self : RegoSet, other : RegoSet) -> RegoSet

    Set difference (self - other).

    RegoSet::empty

    fn RegoSet::empty() -> RegoSet

    Constructs an empty Rego set.

    RegoSet::insert

    fn RegoSet::insert(self : RegoSet, item : Value) -> RegoSet

    Returns a new set with item inserted.

    RegoSet::intersection

    fn RegoSet::intersection(self : RegoSet, other : RegoSet) -> RegoSet

    Set intersection (self & other).

    RegoSet::is_empty

    fn RegoSet::is_empty(self : RegoSet) -> Bool

    Reports whether this set is empty.

    RegoSet::items

    fn RegoSet::items(self : RegoSet) -> ReadOnlyArray[Value]

    Returns the sorted unique elements of this set.

    RegoSet::length

    fn RegoSet::length(self : RegoSet) -> Int

    Number of distinct elements in this set.

    RegoSet::of

    fn RegoSet::of(values : ArrayView[Value]) -> RegoSet

    Constructs a canonical Rego set from arbitrary values, sorting and deduplicating them under OPA's total Value order.

    RegoSet::union

    fn RegoSet::union(self : RegoSet, other : RegoSet) -> RegoSet

    Set union (self | other).

    Value

    pub(all) enum Value {
    Null
    Bool(Bool)
    Number(Decimal)
    String(String)
    Array(ReadOnlyArray[Value])
    Object(RegoObject)
    Set(RegoSet)
    } derive(Eq, Hash,
    Debug
    )

    Immutable Rego runtime value. Set and Object hold canonical opaque containers so unsorted or duplicate-key states are unrepresentable.
    impl Compare for Value
    impl Show for Value

    Value::array

    fn Value::array(items : ArrayView[Value]) -> Value

    Constructs a Value::Array from an immutable copy of items.

    Value::compare

    fn Value::compare(self : Value, other : Value) -> Int

    Total deterministic order across all Value variants matching OPA v1.23.0.

    Value::format_rego

    fn Value::format_rego(self : Value) -> String

    Formats a Value as an OPA Rego literal (used inside collections and for display).

    Value::format_template

    fn Value::format_template(self : Value) -> String

    Formats a Value for Rego template string interpolation ($"..."): top-level strings render unquoted, while nested collections use OPA's canonical Rego formatting ([1, "a"], set(), {42}, {"a": "b"}).

    Value::from_json

    fn Value::from_json(json :
    Json
    ) -> Value raise ValueError

    Converts a MoonBit Json value into an immutable Rego Value, preserving exact arbitrary-precision decimals when Json::Number retains its repr.

    Value::from_json_string

    fn Value::from_json_string(text : String) -> Value raise ValueError

    Parses a JSON string into an immutable Rego Value.

    Value::from_yaml

    Converts a @yaml.Yaml value into an immutable Rego Value, preserving exact decimal representation on Real(_, repr~) when available.

    Value::from_yaml_string

    fn Value::from_yaml_string(text : String) -> Value raise ValueError

    Parses a single-document YAML string into an immutable Rego Value.

    Value::int

    fn Value::int(n : Int) -> Value

    Constructs a Value::Number from an Int32.

    Value::object

    fn Value::object(pairs : ArrayView[(Value, Value)]) -> Value

    Constructs a Value::Object from (key, value) pairs.

    Value::set

    fn Value::set(items : ArrayView[Value]) -> Value

    Constructs a Value::Set from items.

    Value::string_object

    fn Value::string_object(pairs : ArrayView[(String, Value)]) -> Value

    Constructs a Value::Object from string-keyed pairs.

    Value::to_json_string

    fn Value::to_json_string(self : Value) -> String

    Serializes a Rego Value to compact JSON matching OPA json.marshal.

    Value::to_yaml_string

    fn Value::to_yaml_string(self : Value) -> String

    Serializes a Rego Value to YAML text (valid YAML 1.2 superset of JSON).

    Value::type_name

    fn Value::type_name(self : Value) -> String

    OPA type_name string for this value.